The Learn to Code Movement

The Learn To Code Movement

I’ve started to wonder if by focusing so much on learning code, we’re losing focus on how to support one of our most important assets in the technology industry.

Technology and languages change constantly, so what was taught in a college coding class a few years ago is now outdated.

This is a big problem, and one that will only become more severe over time. Just think about an iOS developer who in a few years might be coding entirely in Swift , Apple’s newly launched language. This type of rapid change is absent from almost all other industries, yet remains a serious concern for us.

Here are just a few ideas that come to mind:

1. Encourage pair programming
In case you’re not familiar, this is where two programmers work on the same computer at the same time so they can solve problems together. Every programmer has different strengths and weaknesses, so taking time to code together with different people in the company can be a great learning experience.

2. Make learning free
A lot of technology companies offer some pretty awesome benefits, like catered lunches, healthy snacks and gym memberships. Education should be a part of that, too. Give employees budgets to buy educational books, or offer to pay for couple technical conferences a year that they may want to attend. The easier you make it for your team to continue learning, the more likely they are to take advantage of educational resources—and that ultimately helps both them and your company.

3. Set learning time during work hours
Some companies set aside a few hours every week for everyone to stop working and spend time doing something that makes them better. This could be taking a typing class, playing an online programming course, refactoring some old code, or even coding a side project using a new language.

Not one way to learning but many.

learning is a personal process and different things work for different people. Some people like books, others prefer online videos, and some just like to dig in and experiment. The best way to tackle different learning styles is by having a good mix of tools—and ways for developers to get access to them—so they continue to grow in the way that’s best for them.

Have you successfully implemented an education program for your development team?

3 Ways to Motivate People to Work Harder Faster and Smarter

3 Ways to Motivate People to Work Harder Faster and Smarter

1. Threaten them.

2. Pay them lots of money.

3. Make their work/work space fun.

In today’s workplace, threatening people has not been effective. Paying them lots of money (even if you can afford it) has only shown short-term success. Only number three, making their workplace enjoyable, has a track record of effecting real change. It is time managers learned how to create an atmosphere that is challenging, creative and fun for employees as well as for themselves.

FUN IS PRODUCTIVE

Imagine a work world where people love their work environment, and they are calm, stress-free and happy all day long. People who are in good spirits are more likely to be productive. Their mental attitude produces increased oxygen, endorphins, and blood flow to the brain, which enables them to think more clearly and creatively. They are more relaxed, more accepting of others, and more likely to share their sense of humor.

Laughter creates a bond that brings others together; people like to be with employees who are having fun. Creativity, intuition and flexibility are key to successful operation of organizations today. In stimulating environments, employees enjoy their time at work and they will also excel at work. A fun workplace is not only more productive, but it attracts people and profits.

So far so good take it easy… let create a Fun Workplace… :)

Executing Background Tasks With Scheduler in Rails

Executing Background Tasks with Scheduler in Rails

rufus-scheduler is a handy gem that allows you to perform background jobs. In this article we will show you how to use rufus-scheduler in your Rails applications. Let’s get started:

Setup

In order to use rufus-scheduler, we must first add the rufus-scheduler gem to our Gemfile. To do this, open up your Gemfile and add in the line listed below:

Gemfile
1
gem 'rufus-scheduler'

Run a bundle install to install the gem:

1
bundle install

Great, we need to create an initializer that will contain the jobs we wish to schedule. Create a new initializer called scheduler.rb in the config/initializers directory and add in the code listed below:

config/initializers/scheduler.rb
1
2
3
4
5
require 'rufus-scheduler'

scheduler = Rufus::Scheduler::singleton

# jobs go below here.

Now we are ready to schedule jobs.

Scheduling the Jobs

rufus-scheduler provides a simple syntax for scheduling jobs. You can schedule both one time jobs and recurring jobs. One time jobs can be either scheduled at a specific time, or you can tell rufus to wait a specific amount of time before running the job (a delayed job). For recurring jobs and delayed jobs, you can either use a simple plain English (30m = 30 minutes, etc.) format or you can use the cron format for scheduling jobs. For this article we’ll focus on the English format:

Recurring the Jobs
Scheduling recurring jobs is easy. Simply use the following format in your scheduler.rb file:

config/initializers/scheduler.rb
1
2
3
scheduler.every '5s' do
  # do stuff
end

The code above would perform your background task every 5 seconds. The list below will give you an idea of what time units are supported:

s Example: 5s - seconds, specifies the number of seconds you wish to wait.
m Example: 5m - the number of minutes you wish to wait.
h Example: 5h - the number of hours you wish to wait.
d Example: 5d - the number of days you wish to wait.
w Example: 5w - the number of weeks you wish to wait.
M Example: 5M - the number of months you wish to wait.
y Example: 1y - the number of years you wish to wait.

For example, the following code would tell rufus you wish to schedule a job for every 11 and a half hours:

config/initializers/scheduler.rb
1
2
3
scheduler.every '11h30m' do
  # do stuff
end

Scheduling a delayed job is easy. The syntax is similar to the recurring syntax listed above, but we use the .in method instead of .every. For example, the following code would run a task 4 hours after the server starts:

config/initializers/scheduler.rb
1
2
3
scheduler.in '4h' do
  # do stuff
end

Scheduling the Jobs for Specific Dates/Times
You can also schedule a job for a specific date and time. To do this we use the at method. For example, the following code would run at 12:01am on December 1st, 2017:

config/initializers/scheduler.rb
1
2
3
scheduler.at '2017/12/01 00:01:00' do
  # do stuff
end

Important Caveats

1. Because rufus-scheduler runs in process, the scheduler will reset if your Rails server gets restarted. This means that the timer for your jobs will get reset, so don’t count on any monthly or yearly jobs getting called. If you need to persist jobs across server resets, use a job backend. We will show you how to do this in another article.
2. Rufus does not work with Active Job.
3. Some additional setup is needed for production environments (see below).

Production Setup

Production servers require a bit of additional setup. On most production web servers, idle Ruby processes are killed. In order for rufus to work, you’ll need to stop this from happening. For Passenger/Nginx you can copy the following code below to your nginx.conf config file for your website after the line that says passenger_enabled on;.

nginx.conf
1
2
3
passenger_spawn_method direct;
passenger_min_instances 1;
passenger_pool_idle_time 0;

rufus-scheduler is a simple, easy to use scheduler that provides great functionality. It can be used for stuff like sending emails, cleaning up temp files, and much more.

So far so good, That’s it!!! See ya!!! :)

4 Startups Mark Zuckerberg Created Before Facebook

4 Startups Mark Zuckerberg Created Before Facebook

1. ZuckNet
Mark’s father – Edward Zuckerberg was a dental practitioner, who ran his clinic from the first floor of their home. This made communication between the family members a hassle, because everyone was always running up and down the stairs. To combat with this problem, 11 year old Zuckerberg came up with the idea of an intranet that allowed anyone to login from any computer in the house and send a message. This served as an instant chat system, that was exclusive just to the Zuckerberg family. Randi Zukerberg, Mark’s elder sister, later told People.com how his this was “the first example of when he started building things-and he never stopped.”

Another interesting fact about ZuckNet is that it was quite similar to the very popular AOL instant that into existence, later the same year. To quote Randi again, Mark was ‘10 levels ahead’ even at 11.

2. Synapse Media Player

4 Startups Mark Zuckerberg Created Before Facebook

In high school, Zuckerberg wrote a computer program that used machine learning to determine a user’s music listening habits and recommended more music based on the genre, artist, taste, which was pretty much like what Last.fm does today. This app was built in 2000, and was featured by SlashDot and PC magazine back then with an amazing review + a rating of 3 on 5.

Both Microsoft and AOL approached Zuckerberg for buying Synapse + a job offer, but he turned them down and posted the app online for free. He also turned down a full-time employment opportunity at the two corporate giants and went on to enroll at Harvard.

An excerpt from the review: “This is by far the most innovative media player I have see to date the only function I find it lacking is a more advanced tag editor and the ability to group by Album.”

3. CourseMatch
By the time Zuckerberg started classes at Harvard, he was already known as the, ‘Programming prodigy’. As an early project in his sophomore year, he started CourseMatch, which helped the students at Harvard in picking the courses they want, at the start of every semester. Through CourseMatch, you could see the number of students enrolled in a particular course and a list of all the people who signed up for the same course, allowing you to find out all the courses your class-mates were taking, before making a choice.

4. FaceMash

4 Startups Mark Zuckerberg Created Before Facebook

FaceMash is by far the most talked about things that Zuckerberg created as it is said to have initiated the beginning of Facebook. FaceMash presented the user with two pictures of either male or female students at Harvard and asked them to choose the better looking one.

Arie Hasit, Zuckerberg’s room-mate at Harvard explained that he had built the Website ‘just for fun’.

The Website soon went viral after its launch over the weekend. The traffic was so overwhelming that it lead to the shutting down of one of the Harvard’s network switches making it impossible for a group of students to access the internet.

The site was taken down by Harvard management four hours later, after multiple complaints from students stating that their pictures were used in FaceMash without prior permission.

FaceMash also landed Zuckerberg into trouble.He was brought before the administrative board and was charged with violation of internet privacy rules and reach of computer security. He was made to publicly apologize, while the student paper wrote articles about how ‘inappropriate the whole concept of FaceMash was’.

52 Simple Things to Be Your Best Every Day

52 Simple Things to Be Your Best Every Day

Millions of people go to work every day, but they don’t bring the best parts of themselves to the job–often because they don’t know how. They may be stuck in a rut, never quite able to feel they’re doing truly excellent work.

If you like what you do and you want to take it to the next level, concentrate on these 52 simple things.

1. Make people feel special: encourage and empower people at every chance.

2. Find work you love and put your heart and soul into it: choose a job you love and you will never have to work another day in your life.

3. Focus on the task at hand: do the best you can where you are with what you have.

4. Treat every task as important: every job is a self-portrait of the person who does it.

5. Always do the right thing, even when it’s hard: don’t let what you cannot do interfere with what you can.

6. Delegate whenever you can: you get the best out of people when you believe in their talent.

7. Take initiative: even if you’re already very good at your job, do whatever you can to push your limits.

8. Be part of the solution: don’t be known as someone who is always complaining about something.

9. Tell the truth: let people know they can count on you to be honest even when it creates difficulties.

10. Help as many people as you can along the way: become someone people seek out for assistance.

11. Avoid gossip always: it should go without saying, but turn a deaf ear to gossip and rumors.

12. Maintain a positive attitude: a positive attitude is always contagious.

13. Double your income by tripling your knowledge: don’t let your knowledge and skills become outdated.

14. Mind your emotions: when you’re angry, count to 10; before you speak, count to 100.

15. Make small daily improvements for stunning results: most of the time, success consists of a series of little daily efforts.

16. Sharpen your skills and focus on mastering your talents: avoid boredom–and learn a new skill to keep you on top of your game.

17. Be masterful at what you do despite the obstacles: no person fails who does their best.

18. Don’t feed your fears: have faith that you will make it through.

19. Always be prepared: success occurs when opportunity meets preparation.

20. Ask for help when you need it: there is no such thing as a self-made person; you will reach your goals only with the help of others.

21. Set goals and get results: it’s important to know where you are going, how you will get there, and what the outcome will be.

22. Be all that you can be: don’t settle for less than your highest potential.

23. Don’t worry about getting credit for getting things done: you can accomplish almost anything if you don’t worry about who gets the credit.

24. Preserve your integrity: make daily choices that are consistent with your values.

25. Be a good role model: live by your values and walk your talk.

26. Don’t accept “good enough”: do everything with excellence.

27. Persevere with persistence: success is largely a matter of hanging on long after others have let go.

28. Consider leadership something that exists wherever you are: make the most of yourself in every situation.

29. Say please and thank you: it really does matter.

30. Show respect: the more you give, the more you receive.

31. Accept responsibility: take full responsibility with full confidence to get the job done well.

32. Be determined to be your best: the difference between the impossible and the possible lies in your determination.

33. Remember you are what you think: it is important to accentuate the positive and eliminate the negative.

34. Erase your limitations: when you can conquer your fears, it’s like lifting a hundred pounds of cement off your shoulders.

35. Treat failure as a step toward success: failure is never fatal, but not trying is.

36. Be trustworthy: make promises and keep your word.

37. Become an expert: make the most of your knowledge.

38. Respect people’s time: everyone is busy. when you have someone’s attention, be quick and succinct.

39. Be an active listener: make sure you listen at least as much as you speak.

40. Honor your commitments: when you make a promise, keep it.

41. Be a great team player: maximize your contribution.

42. Let go of restrictions: don’t be limited by the scope of your thinking. Think big and succeed big.

43. Deliver results: when you are given a directive, get it done well and on time.

44. Be transparent: the more transparent you are with information, the more people will understand why you do what you do.

45. Be kind: be unfailingly kind, polite, and gracious with everyone you meet–no matter what his or her role, and no matter how you’re feeling.

46. Manage your stress: take every action to minimize stress at work, because you don’t want it to get the best of you.

47. Be dependable: be consistent in yourself and reliable in your performance.

48. Communicate with heart: sincerity helps you avoid many blunders and misunderstandings.

49. Work with purpose: bring meaning to everything you do.

50. Be true to yourself: everything you do should represent who you are.

51. Make every moment count: we do not count years until there is nothing else to count.

52. Lead from within: everything you need for a successful life is within you now.

So far so good, That’s it!!! See ya!!! :)

Sessions Expiring

Sessions Expiring

To improve user security, we may wish to expire the user’s session after they are inactive for a given amount of time. In order to do this, we simply set the expire_after parameter when setting up our session store. For example:

config/initializers/session_store.rb
1
Rails.application.config.session_store :cookie_store, key: '_example_session', expire_after: 15.minutes

The line above would expire the session after 15 minutes of inactivity. This means that the user’s session variables would get wiped once time reaches 15 minutes since the user last accessed the Rails application. If the user refreshes the page, the timer gets refreshed.

So far so good, That’s it!!! See ya!!! :)

Dynamic Programming With Ruby

Dynamic Programming with Ruby

I had a task to analyse the value of a cookie set by a tool on the subdomain. The value of the cookie set looked something like this:

1
"18337|20120404|True#Q0A|18342|21-30|20120404|18344#Q1|18349|NO PARTNER|20120404|18351#Q2|18352|EMPLOYED|20120404|18353#Q4|18432|STRUGGLING|18539|WANT|20120404|18541#Q3|18358|EMPLOYED|20120404|18359#"

My task was to try to decipher the values of set inside the cookie and how they changed depending on the progress through the application that set the values. I was told the answers to questions sat next to the ID of the question. For example, the answer to the “age” question (21-30) was related to the question 18342 and would always appear as |18342|21-30|. I started out with some tests and ended up with a method like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Answers
  attr_accessor :age, :employment_status, :has_partner

  def parse(cookie_contents)
    items = cookie_contents.split("|")
    items.each_index do | i |
       current = items[i]
       if (current == "18342")
         @age = items[i+1]
       elsif (current == "18352")
         @employment_status = items[i+1]
       elsif (current == "18349")
         @current_partner = items[i+1]
       end
    end
  end
end

Of course, I wanted to avoid the growing if-else statement so found a way that I could do it dynamically and focus just on the mapping from an ID to an attribute. The resulting code looked like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Answers
  attr_accessor :age, :employment_status, :has_partner

  Mappings = {
    "18342" => :age=,
    "18352" => :employment_status=,
    "18349" => :has_partner=
  }

  def parse(cookie_contents)
    items = cookie_contents.split("|")
    items.each_index do | i |
       current = items[i]
       if (Mappings.has_key?(current))
          self.public_send(Mappings[current], items[i+1])
       end
    end
  end
end

By the end of the analysis, I discovered that multiple IDs mapped to the same properties and all I had to do was add another entry into the map defining which ID mapped to what property on the object.

So far so good, That’s it!!! See ya!!! :)

Rails Flash Messages Styles

Rails Flash Messages Styles

If you’re using Ruby on Rails with Twitter Bootstrap or other css framworks, then you may want to display flash messages with the alert styles. Here is a quick and easy way of doing so.

You just need to quickly extend application_helper.rb with the following:

application_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module ApplicationHelper
  def bootstrap_class_for(flash_type)
    case flash_type
      when "success"
        "alert-success"
      when "error"
        "alert-danger"
      when "alert"
        "alert-warning"
      when "notice"
        "alert-info"
      else
        flash_type.to_s
      end
  end
end

Now when you call a flash message, you can use the following in your view:

1
2
3
4
5
6
<% flash.each do |type, message| %>
  <div class="alert <%= bootstrap_class_for(type) %> alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <%= message %>
  </div>
<% end %>

And just use:

1
flash[:success] = "Credit card type saved successfully!"

As success message:

1
flash[:alert] = "Alerting you to the monkey on your car!"

So far so good, That’s it!!! See ya!!! :)

Why Do I Do This… Why Do I Blog? Why Do I Email Every Week?

Why Do I Do This... Why Do I Blog? Why Do I Email Every Week?

With all the hate, all the times I’ve been called a spammer, scammer, deceptive, and just about every other negative thing you can imagine, it would be easy for me to quit. So what keeps me going?

It’s true. I get a lot of very negative feedback on the things I do.

It hurts. It sucks. It makes me want to quit. But I keep going anyways. Because every now and then, I get an email from guys in USA… an email that gives me fuel for the fire that I’ve started… an email that makes me believe that what I am doing is important – not for me, not because I have anything special or unique, but because my mundane and ordinary problems and solutions are the same mundane and ordinary problems that other people need to solve. And sometimes, the impact of my solutions are far beyond anything that I ever expected.

That One Moment Of Impact
So why do I keep going? It’s that one positive note… that tweet from some random person… that person who takes the time to reply to an email and let me know that I’ve made an impact… this is why I do what I do.

What Will They Say About You When You’re Gone?

What Will They Say About You When You’re Gone?

If you’ve ever written a line of Ruby, you’ve been impacted by the work of Jim Weirich: developer, teacher, mentor, speaker. By all accounts, he was a great person. Was… Sadly, Jim died recently.

I didn’t know Jim, personally. In fact I only recently met him in person for the first time at Reddot ruby conf 2014 in Singapor. I had the pleasure of meeting him very briefly, introducing myself. It was great to finally say “hi” to him, though. I learned a lot from his talks and I still use his ideas of “protocols” instead of “interfaces” in dynamic languages like Ruby and JavaScript. But I’m not going to go in to some lengthy soliloquy about Jim’s life and impact on me.

What really struck me about Jim’s passing was not the impact he had on me, personally, but the impact that he had on a very large number of developers around the world. For a few days after his death, I saw a countless number of tweets and retweets about how Jim had touched people’s lives. I saw stories of how he had changed people’s perspectives on code, on mentoring, and all other aspects of software development. One tweet in particular stuck out, talking about how Jim’s knowledge and wisdom had made this person realize their own inadequacies and how Jim was the only person they had ever met who had been gracious enough to apologize for that.

All of these tweets, the thousands of comments posted on Jim’s last commit in Github, that software development companies around the world paid tribute to him via their public websites – the stories, the lives touched – all of this has me wondering: what will they say of me, when I’m gone? And what will they say about you? Will you have made an impact on the lives of other developers? Will you have shared your knowledge, sought opportunities to teach, entertain and enrich the lives of others?

What impact have you had on the lives of others? What will they say about you, when you’re gone?