Learning to code is the same as learning a second language. You must recognize the amount of energy it takes to learn french, and apply it to learning ruby. Your final goal - which for the HN crowd would be something like building a SaaS web app, is equivalent to writing a novel.
But before you get to your novel you must learn how to speak and think in the language. You need to know the vocabulary and how to write sentences and then paragraphs. Start with ruby or javascript, and become comfortable with the vocabulary. Learn about strings, arrays, loops, methods, functions and classes. Understand the basics of input and output. Commit all the small code snippets or phrases to your rote memory. You need to know what a for loop is in your sleep. Write it over and over again until its ingrained in your memory, until you can write it without looking at any documentation. This will be the boring part, but you need these tools to continue to the more rewarding states that involve creativity.
From here start reading small programs ( As a front-end developer I started by reading jquery plug-ins I was using for websites, sticking with ones with less then 300 lines of code). Read every statement of these programs and if you don’t know what something does, google it.
Write every line out for yourself, making sure you know what everything does. Writing out code it the ultimate way to learn. Do this as much as possible.
Translate these small programs into English. Actually write out the translation. Then a few days later try to write the program yourself by only looking at the translation you wrote. Try to memorize patterns you notice. Think of features you would want to add to these programs- try adding them! These 300 line programs are like essays.
When you are ready to write you own essay, start off by building a calculator. If you still don’t have any idea how one would go about building a calculator, go back to reading more programs written by other people. When you are looking at other programs try and find elements that you could use to build a calculator.
If you are ready for the calculator then you are transitioning from merely knowing the vocabulary of a the language to creating something meaningful with it. When creating a program start by thinking of everything you need, gather all your requirements. “I am going to to need to create buttons that a user can press”, “ I am going to need a method for a plus operation”, “I am going to need to store values pressed in an instance variable.” Take your requirements and ideas and build it.
From here, build bigger and bigger programs. As they get bigger they are no longer programs but applications. Keep reading other code are writing it. Learn about frameworks and databases. Buy books on application development and read them. Try and get some consulting work- If you have a responsibility to a client it will help motivate you. Create your own small applications, and then slowly morph it into your novel.
Writing code is the real key- think of writing at least 50 lines of code a day.