The Birds and the Bees of the Build Process

You already know how babies are made.  Hopefully in science class you went over the mating rituals of robins, but tell me dear reader, do you know where executable programs come from? Has anyone ever educated you on the delicate process of how human-written code is made into a machine-readable program? Today we are going to explore how usable computer programs are created-  which turns a game coded by you, into an executable game played by me on the computer.

two_robins

 

 

 

 

 

 

 

The Build Process

Imagine your friend wants you to try out a new game she just created. You say ok, and your friends sends you a tar file called ‘niubi-awesome-4.20.tar.gz’. Oh no. How in the world are you going to turn ‘niubi-awesome-4.20.tar.gz’ into an enjoyable time waster?

 

Untarring the Tarball

First download ‘niubi-awesome-4.20.tar.gz’ then untar the tarball. Type the command tar -zxvf Untarring the file will turn it into a directory.

 rad@cool:~$tar -zxvf niubi-awesome-4.20.tar.gz 

Make

CD into your new ‘niubi-awesome-4.20.tar.gz’ directory.  Now it is time to turn your human -readable code into machine-readable code by using make.

 rad@cool~/Desktop/niubi-awesome-4.20$make

Make Install

Make Install finishes up the compilation process.

 rad@cool~/Desktop/niubi-awesome-4.20$make install

 

Important Take-Home Concepts:

1. Source code is for humans, binary code is for machines

2. Turning a human-readable code into machine readable code is called compiling

3. Often in Linux you have to compile source code, in Microsoft you mainly deal with precompiled binary files

 

More Information:

https://openhatch.org/missions/tar/hints

http://unix.stackexchange.com/questions/20864/what-happens-in-each-step-of-the-linux-kernel-building-process

 

 

 

 

 

 

Arduino Gains a new BFF, Vim

I am still working on constructing an Arduino mood lamp for my room :)

In the last post I’ve written about my desire to program my Arduino Uno without using the Arduino IDE. I am happy to report  that I’ve escaped from the warm, but suffocating embrace of the Arduino IDE, and I’m now running my own tool chain in which I solely use Vim, and avr-gcc.

I did away with the Arduino IDE because I wanted to better familiarize myself with Vim and the command line.  That and I wanted to build my nerd cred. Ok, it was mostly about the nerd cred ;)  If you are curious about the particular setup I used, you can fork it from here.

Make

Compiling Code in Action!

 

 

 

 

 

 

 

 

Looking Ahead

Now I need to beef up my literacy of microcontroller schematic diagrams, capacitors, resistors, and all that good stuff.  I also want to become more adept at manipulating C source code.  I am intimidated but excited about the next steps of my Arduino journey!

 

Ciao, Mondo

So far so good! It never ceases to amaze me how long it takes to get a working environment up and running.  I will spare you the dirty details, and proceed to succinctly summarize my process of setting up Arduino on Linux.

Act I: Read what the heck is an Arduino

Act II: Set up Arduino on Linux. This by far is the best tutorial EVER! I love it when the writer doesn’t over-estimate my intelligence. Technical writers take note, this is what good documentation looks like.

Act III: Fix grayed-out Serial Port Thanks Mark for reminding me why Unix permissions are so important.  Your how-to page hit the spot!

The Next Step

I am not quite finished yet.  I’m still trying to find a way to bypass the Arduino IDE, and use Vim instead. It has been an uphill battle to say the least.  The holy grail for me is to be able to write and compile C in Vim. That being said, I don’t understand how to use plugins in Vim, and I am shamefully clueless on how to install the  Pathogen package. Oh well, I might end up swallowing my pride and use the Arduino IDE, or implement a hybrid solution where I am using the Vim text editor but compiling on the Arduino IDE. At any rate, I will keep you posted!

Arduino

Yay, my Arduino is alive!

 

Project Light Bright

 Light Bright

After about a year of collecting dust I am finally ready to break out the Arduino, and embark on my first project.  I am going to make my very own mood light!

green_light

 

 

 

 

 

 

Basically my lamp will change colors. I am not sure if the change will occur in set time intervals (every 5 minutes for instance), or if I will control the color of the light with a switch. I am still drawing up my model.

 

Why?

My dark room is the primary motivation behind this project. I live in a basement apartment and my room gets absolutely no sunlight. I think my mood and productivity will improve if I had a little colorful box of light by my side.

my_bedroom

 

 

 

 

 

 

Furthermore, this is the perfect chance for me to develop my skills in C and to learn more about circuitry.  C is a powerful, and it is a perfect tool when you need a speedy language to communicate to your hardware.  Right now I am scouring the internet for Arduino projects written in C.  I have found this, but honesty I am still doing my research. Suggestions are much appreciated :)

 

Bash Beyond Memorization

For a very long time I thought  Bash was only about memorizing a very long list of commands:

 

Controlling your computer through the command line can make you feel like a geek with authority, until you find yourself navigating through this:

radbox@cool:~$ cd Desktop/Projects/Website/Photos

 

This problem can be solved by using ‘autocomplete’, but wouldn’t it be nice if you didn’t have to type this long train of text to begin with?

 

Shell Scripting to the Rescue

Well, you don’t have to to! You can make an executable shell script which would directly hop to the desired directory.  We will begin by heading to the terminal:

 

radbox@cool:~$

 

Now open the text editor gedit:

 

radbox@cool:~$ gedit

 

You should now be in gedit:

gedit

 

 

 

 

 

 

Type #!/bin/bash, this will make your script executable:

#!/bin/bash

 

 

 

Ok, now type in the desired directory path underneath #!/bin/bash, for me it would be cd Desktop/Projects/Website/Photos:

#!/bin/bash

 

cd Desktop/Projects/Website/Photos

 

 

Now save (your script should be in your home directory). Be sure to add .sh   For example, the name of this file is photos.sh

 

Head back to the terminal and type chmod 700 photos.sh  This changes the permission settings so only the owner can execute the script:

radbox@cool:~$ chmod 700 photos.sh

 

Type in your script. For me I will type ./photos.sh  ./ makes your script executable:

radbox@cool:~$ ./photos.sh

Proceed to do the bunny dance:

 

Advice is Cheap, but Expensive to Use: The Case for Project-Based Learning

The Beginning

Back before I knew what a variable was, and I thought git was an idiot, twice a month I would haunt Beijing Linux Users Group meetings.  These gatherings were filled with developers engaging in lively discussions about technology.  After formal talks, geeks would wistfully recall the days before Unity while nursing bottles of Qingdao beer.  I left each meeting equal parts inspired…and confused. But regardless, I wanted in.  I wanted to be that code slinging superstar. So one day, I took a seasoned Linux veteran aside. and asked, “how do I learn how to code?”  The friendly fellow reflectively responded with , “build something.”  Throughout my journey that has been by far the best and worst advice given to me.

Itching Curiosity

I remember how I felt when I heard those words.  Build something? Me? At that point, the extent of my scripting talents was limited to using a Python IDE as a giant alternative calculator.  How was I going to build something, or better yet, solve a problem, when I couldn’t even identify a problem?

Tutorial Purgatory

Fast forward a year. My life has been a revolving door of tutorials, and books especially designed for n00bs :)  I have a special name for this period of learning- tutorial purgatory.  You know enough to have a semi-decent conversation about the new concepts you are learning- but you can’t apply said concepts outside of the tutorial examples.

Now What

Before I continue, it must be said that tutorials have been, and continue to be indispensable vehicles that have gotten me to where I am today.  I have learned all sorts of fundamental information through tutorial.  Heck, I plan on starting a new one next week.

But the bottom line is I didn’t aspire to become a programmer just to muddle my way through an endless loop of tutorials.  I am learning how to code because I want to become a badass, rogue hacker.

How to Be a Badass-in-Training

Codecademy: Not all tutorials are created equal. Codecademy offers a balanced blend of tutorial, and miniature projects.  If you made up your mind that you want to learn how to program like five minutes ago, then this is a good place to start.

OpenHatch: OpenHatch is a non-for-profit which helps new developers contribute to open source projects.  The ‘missions’ are fun ways to learn important concepts such as working with tar archives, and git.  The website is very nice, however I suggest finding a real live person to help you with one of the projects. When it comes to Open Hatch, I find that having a physical mentor beats IRC chats any day, especially when you are brand new at this stuff.

Be the Critic

Take some time out to make a list of everything that makes your life a little less pleasant.  Is your alarm clock not doing the trick? Are you looking for an even easier way to split up the bill? Are you trying to find a more intuitive way to organize your smart phone’s address book? After you’ve made your list, see if you could use what you already know to solve some of these problems. For example, you could write a simple Python script to calculate and split the bill, or if you are interested in hardware you could make your own alarm clock by using an arduino micro-controller.

And finally, don’t be a stranger. If you are working on a cool project, please let me know!

 

 

 

Back Again

It has been awhile since I have last posted. All I can say is that a lot has changed since August.  In September, I quit my job as an ESL teacher, packed my bags, and moved from Beijing all the way to Portland to pursue my dream to become a developer.  This is my story.

Portland Hacker Scene

 

 

 

 

 

The amount of energy, talent, and entrepreneurial spirit in the Portland tech scene is breathtaking.  There are tech meetups almost everyday! Walking around Portland is heady, comparable to Greenwich Village in the 1960′s, Silicon Valley during the late 90′s, and Brooklyn during the mid-aughts.

My First Talk!

For almost two years, I have been a member of various Linux/Python user groups.  Usually at user groups, every month a person would volunteer to give a presentation about a project they are working on, or a tech topic that they are passionate about.  Everyone, regardless of level, is encouraged to speak, but in practice only the more experienced engineers actually volunteer.  I appreciate, and greatly value these type of advance talks, but I have always longed to attend a presentation that spoke to my fumbled attempts at entering the world of developing.  Since no one stepped up to give such a talk, I decided to take matters into my own hands, and give the newbie presentation that I always wanted to hear.  Here are the slides, just in case you are interested.

My First Programming Position!

And finally my journey leads me here. After a crazy amount of networking (and the recommendations of good friends), I am now interning at Trapit. My position includes conducting unit tests, and  fixing code.  However, the most exciting part of my internship includes a machine learning project.  Machine learning is a branch of artificial intelligence.  Part of my job is to teach the app how to recognize Chinese characters.  When I am not sharpening my Python skills, I am usually practicing Chinese.  The best part of this internship is that I get the chance to merge my love for Mandarin with my burgeoning skills in programming.  Words can not express the gratitude I have for landing such an exciting position!

 

 

Vim vs. Emacs

Next month, I will be pursing a certificate in computer information science, so in the spirit of preparation I am teaching myself C++.  Learning C++ presented a perfect chance for me to graduate from a gui text editor to a command-line one.  After reading, Adam Temple’s take on the Vim vs. Emacs, I decided that Vim would probably be easier for a noob like me to grasp.

After about a week of Vim, I have to say that editting is significantly faster than with Geditt. Sure, I needed to remember some commands, but once I mastered them, changing, and finding text has almost become almost automated. Finding the mouse, highlighting the text, and then looking for the command is a huge waste of mental resources.

 

Using keyboard shortcuts has made typing a rather elegant affair, and contrasts greatly from the stop and go approach of using a mouse. I am a fan.

 

 

 

Coffee Script Success

The sweet nectar of success! After many unsuccessful tries I finally loaded my very first mini app!

Hello World :)

 

 

 

 

 

 

 

How much for today’s fresh roast, sir?

Price of coffee

 

 

 

 

 

 

 

 

 

It took me a whole weekend to figure out how to get this to work.  I didn’t know if I would pull through, I was tempted to give up several times, but I persevered.  Maybe that is what makes the world of IT so special- developing and programming pushes you to achieve things that several days ago seemed impossible.

Adventures in AVD

Armed with a copy of Head First Python and an article by the same author, I downloaded the SDK manager and contructed my own Android Virtual Device, AVD.

 

I had some issues with Android 4.01. After some poking around on google, I discovered that some of the drivers were not available. So instead of wrestling with Android 4.01, which I don’t run on my phone anyway, I just downloaded the software for Android 2.3.3.

 

 

 

 

 

 

I was able to run Android 2.3.3, subsequently I installed SL4A which would enable me to use Python, but I ran into this problem.  Notice that the resizing buttons are missing. Adjusting the size of the virtual device did not remedy the problem.

 

 

 

 

 

 

 

 

As I said before, I can run all of the apps fine, but it is a pain in the butt that I cannot move the AVD screen around :(