Thursday, March 26, 2015

5 Lessons Learned From the 30 Day Github Challenge

Today, I completed my 30 day Github challenge.  That challenge was inspired by others who came before me.  It was an adventure that took me through web applications and other scripts.  It was a worthwhile experience.  Here are my takeaways.


1.  You get a lot done
Even if any one day doesn't feel like a big accomplishment, it's pretty cool to look back and see what those little steps added up to.  Seeing progress on 9 different projects feels good.

2.  You appreciate the mundane
Commits focused on boring things like code cleanup, docs, and tests matter.  They shine a light on what's good or not-so-good about your project.  I uncovered bugs that might have otherwise not been spotted.  Some good dumb refactoring was also a great way to get commits in on those not-feeling-so-smart days.

3.  Your learning is project-oriented
This challenge encourages focus on projects.  There are some things that are best learned in that context.  The practical challenges of getting Flask and Angular to work together is one example that comes to mind.

4.  Life challenges your ambition
Life has a way of running interference on projects that require any sort of commitment.  Expect it and keep your daily ambitions small to take it into account.  I've grappled with a move to a new place and illness among other things during the past month.  Having tiny goals was a lifesaver for me.

5.  You get reacquainted with old code
Revisiting old projects is a great way to get commits in.  It gives you perspective to how you've come along as a programmer.  My final commit for this challenge was a 4-year-old addon I wrote for Blender.  In a way, it feels like reconnecting with old friends.


Take up this 30 day challenge.  It's satisfying, fun, and challenging.  You'll grow as a developer having done it.

Sunday, March 1, 2015

Basics of Working with Git

Git is an empowering version control tool.  Everyone gets a copy of the repository.  You get freedom to experiment and take chances.  That wiggle room is helpful when working on your creation.

If you haven't yet, go install it.  Here's a link for getting a good setup for Windows. 


Setting Up Your Project

Fire up GitBash.  This gives you a Linux-like environment to work with.  Linux expertise is not needed to follow along.

To keep things simple, make a folder and initialize it.  Here's what to do....

username@YOURCOMPUTER ~
mkdir myproject

username@YOURCOMPUTER ~
cd myproject

username@YOURCOMPUTER ~/myproject
$ git init
Initialized empty Git repository in c:/Users/username/myproject/.git/

username@YOURCOMPUTER ~/myproject (master)
$


The git init command sets up your initial repository.  That repository keeps track of file changes.  A special folder called .git handles the magic of managing those changes.  You need not understand the contents of that folder.

We need a file for git to keep track of.  Make a file called hello.txt.  Put some text in it.  Something like below should do for an example...

hello there, how are you?

With that set up, you now have what you need to learn the basics of how git works.  The working directory has the current copy of the files you're working on.  Hello.txt lives there right now.  


Setting Up To Commit

You should always know the state of your project before committing things to Git.  Here's how you do that...

username@YOURCOMPUTER ~/myproject (master)
$ git status
On branch master

Initial commit

Untracked files:
  (use "git add ..." to include in what will be committed)

        hello.txt

nothing added to commit but untracked files present (use "git add" to track)

username@YOURCOMPUTER ~/myproject (master)
$


Git status tells you the state of your project.  Note the "Untracked files" section.  Those are the files that are currently not being managed by Git right now.  We want hello.txt under Git management so do the following... 

username@YOURCOMPUTER ~/myproject (master)
$ git add hello.txt


Check the new state of things by running git status again...


username@YOURCOMPUTER ~/myproject (master)
$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached ..." to unstage)

        new file:   hello.txt


username@YOURCOMPUTER ~/myproject (master)
$


Note that hello.txt file is now under "Changes to be committed".  That's because we did a git add on that file.  That command put hello.txt in a place called a staging area.  That area holds a snapshot of the file changes about to be committed to the repository.
  

Commits and Commit Logs

Let's add our first item to that repository by doing a commit....


username@YOURCOMPUTER ~/myproject (master)
$ git commit -m "my first commit"
[master (root-commit) bbbc1cf] my first commit
 1 file changed, 1 insertion(+)
 create mode 100644 hello.txt

username@YOURCOMPUTER ~/myproject (master)
$


The git commit command sends a snapshot of changes that you staged into the repository.  The repository is a collection of those snapshots complete with information about the changes associated with them.  

Congratulation!  You succeeded in making your first commit to a git repository.  To confirm, check the commit history with the git log command.


username@YOURCOMPUTER ~/myproject (master)
$ git log
commit bbbc1cf06977dd40780430a5665f94f083e2bc98
Author: you
Date:   Sat Feb 28 15:38:47 2015 -0500

    my first commit

username@YOURCOMPUTER ~/myproject (master)
$


Summary

And so there you have it.  What we've learned so far.....

  1. We know that we can create a repos with git init.
  2. We know that you can take individual files and set up their changes to be saved using git add.
  3. We know how git commit takes the staged changes of our files and sends them to a saved collection of changes called the repository.
  4. We understand the difference between working directories, staging, and the repository.  The working directory holds the current files being edited.  Staging holds a snapshot ready to commit.  The repository holds a collection of those snapshots.

That should cover the bare basics of git to begin with.  Was this a helpful intro?  Let me know in the comments.









Wednesday, December 10, 2014

A Nice Usage of Laziness and Named Tuples in Python

When scraping sites, I sometimes find myself with upwards to a couple hundred html files in one local directory. By taking advantage of the lazy evaluation allowed via the yield syntax, it's really easy to process them all.


A couple of things to note here. Since there is a yield statement present in soup_line, it behaves as a generator. One Beautiful Soup object is created and returned. Then it stops until the next loop around. This saves on a lot of time and loading of stuff into memory.

 I wanted a nice way to keep track of the names of the files associated with soup objects which called for some sort of tuple. SoupFilePair was the solution. This is an example of what's called a namedtuple. These objects behave just like regular tuples but can also double as a sort of "light-weight class". I like them because you don't have to remember as much what order the tuples were in that you were returning. Running "type" on the object will tell you what's what. It's sort of a nice bit of extra documentation whenever you need it.

I really like named tuples and laziness. It makes handling some of the bigger more complicated data beasties so much simpler to tame.

Thursday, June 26, 2014

4 Ways to Awesomeness at Khan Academy Math

Khan Academy makes it possible to get good at a lot of math fast.  Being an open-ended site when it comes to learning it helps.  Here are 4 tricks that can help you get super far with it.

1.  Do Math When You Don't Have a Math Class.
Nobody doubts Khan Academy has helped a lot of people with their math grades.  However, doing it when you don't have any classroom obligations is awesome.  With no daytime curriculum to distract you, it frees you up to jump around at will.

I mix things up a lot.  I have no problem jumping around between algebra, geometry, calculus, and so on.  If geometry gets frustrating, I switch to something like statistics and come back to geom later.  I find it really helps refresh me and sometimes brings new perspectives.


2.  Set Your Own Goals.
There are a lot of good ways to set a goal but the point is that you should have something to shoot for.  Khan Academy gives you lots of reward badge opportunities.  While those are good, don't hesitate to get creative and make up your own goals

Here is how I do goal setting.  I have one wall in my study area where I have a bunch of Post-It notes with goals written on them and another wall to place the badges I won.  I give them cutesy little titles like you'd see on some X-Box achievement.  When I earn one, I stick a gold star on it and move it to my "win wall".  Looking at those badges and seeing what I've reached feels really good.


3.  Be Resourceful.
Sal Khan by himself does a really good job most of the time in his videos.  Just remember there are other good resources out there.  The discussion areas are helpful.  Looking at old problems you messed up on is a huge help.  We all learn in different ways so all I can say is do what works for you.  Trust yourself to know how to find the help you need.

For some cases, I find that just watching videos over and over and bombing on questions doesn't necessarily help by itself.  Sometime, I need detailed paper notes.  There are plenty of other Youtube channels that are helpful too.  Patrick JMT and Yay Math are examples of some I turn to that are stylistically different than Sal.  That's completely fine.  A fresh and different perspective is sometimes what's needed to get things to click.


4.  Take Care of Yourself.
Take a break.  Exercise.  Eat right.  Sleep.  Do things other than math with your life.  Walk away from the computer if you find math is getting too frustrating.    Go hang out with your friends.  There's nothing about math that's worth getting stressed and frustrated about.  Stress and poor health are bad.  Being relaxed, healthy, and alert gets you a lot further with your math endeavors.


Now Get To It!
There's only one warning.  Following these pointers might not just make you better at math.  You might actually find yourself enjoying it!  If you do become one of those people, that's okay.  I won't tell.

Sunday, September 23, 2012

It Doesn't Take A Genius

Let's talk about smarts.  I recently upgraded an open source 3D addon in Python that generates step pyramids.  It involved linear algebra and a functional programming idea.  Some time ago, I would have looked at that combination and have had a formula like this go through my head...

 Open Source + 3D  Math + Python + Functional Programming = Smart Hacker

To be honest with you, I never fit the "smart hacker" profile before and I don't think I fit it now.  The good news is you don't NEED to be in order to pull off stuff like that.  Here's how I managed it.

I Played
My script required working with quaternions and vectors.  These are linear algebra concepts that are way beyond what I took in college.  Rather than diving into the math, I decided to pull pieces out of other people's open source code and play with parameters.  In the end, all I learned was that vectors and quaternions can be used to make points that circle around an axis.  Conceptually, it's no weirder than spokes coming out from the center of a bicycle wheel.

I Used List Comprehensions
List comprehensions are a neat little spin on the functional programming ideas of maps and filters.  Put simply, it's nice syntactic sugar for turning one list into another list.  I like them because they allow me to easily make these baby loops to work my way towards a final result.  Here’s what it looks like to go from a set of angles into the corner points of a pyramid step.



What I like about this approach is how it lets me easily see the flow of the entire list from one form to another to another.  An imperative for-loop flow would have encouraged me to make bigger loops that did more.  I probably would have also been more inclined to see things on a point by point basis instead of seeing the state of the list as a whole.  This isn't to say "normal" for loops don't have their place.  I just think that list comprehensions are less brain hurt than the alternative would have been in this function.

It Doesn’t Take a Wizard/Rockstar/Whatever
So there you have it. I made a 3D art tool with the help of a simple functional programming trick and copied code.  It didn’t come from being a genius.  It came from poking around, playing, and learning from people who are smarter than I am.  It’s the basis of most of what I’ve done and it’s an all around fun way to learn and build stuff.  I'd encourage anyone to take this approach.  Never back down from a problem just because it looks too advanced.  Do it anyways.

Monday, October 31, 2011

Traffic, Technology, and Treasure


These are my lean startup experiences for October. It's a concrete example of how I've applied the “build-measure-learn” approach to Blender Addons during the past month.

Growth by Weekly Release
The big experiment was seeing whether or not I could raise traffic 35% in a month by doing weekly add-on releases for Blender. Results exceeded expectations with a growth of 56% for October. However, traffic by itself is just a vanity metric.

The details in the traffic data said a lot about what users want. A script called “Curve Mangler” released early on in the month gave traffic an early bump because visitors like curve add-ons. On the other hand, the “Orphan Cleanup” data utility add-on didn't excite people as much. 

The clues are in Google Analytics. Digging deep uncovers an interesting form of indirect communication. Users often will express their desires by way of their behavior at the site. It's a great way to help set priorities in a way that helps to reach goals.

Direct communication also plays a big part. My tools in this regard are forum boards and social networks. It's great for morale because it makes me feel part of a community. I learn a lot from them. Their feedback and encouragement helps me make my add-ons better. It also helps drive traffic to my site.

Testing Technical Assumptions
It is okay to do a technical experiment just to satisfy curiosity so long as you have a set definition of success or failure within a reasonable amount of time. For example, I wanted to see if I could easily control particle fountains with an armature. The experiment failed. I'm okay with that.

Failure is sometimes the womb through which better ideas are born. In this particular case, I found a way to use generated curves to provide new ways to visualize and test out armatures. This means a new add-on project to kick off November with.

Money Pressure vs. Money Goals
A startup needs to turn a profit at some point. My approach was to put that issue on the back burner. It made more sense to focus on building up a decent reputation as an open source developer while also securing a day job. That much has been done.

Here's another reason it was right to wait til now.  I believe money pressure for a startup is a bad thing because it's distracting. Money goals, on the other hand, are generally good. The key thing is to be in the position to start off with a modest goal. It makes no sense to try making 2000 dollars in a month when I haven't even proved I could pull in 20. A modest financial metric can be handled just like any other piece of data. Less pressure allows for clearer thinking and, in turn, smarter pivots.

Closing Thoughts
October was a great month and I am excited about what November might bring. New add-on projects, a new day job, and other things in the work ensure there's never a dull moment. I look forward to reporting new progress soon.

Monday, October 3, 2011

When It Feels Like a Video Game

Wow!  This was a wild week.  Someone in the Blender project gave me commit rights to one of their repositories.  Huge honor!  On top of that, the Mohegan Sun Casino hired me as a Java programmer.  Big relief!  Despite all the excitement, a lot still happened with Blender Addons. 

Here's what's happening there.

1.  Step Pyramid appears to going into the next official Blender release.
2.  Particle Tracer is in consideration for a later release.
3.  "Particle Man", "Orphan Slayer", and "Mangler Suite" are addons in development for October.
4.  Disappointing September traffic lead to new site design tweaks for Blender Addons.

Lean startup principles helped me get all this in motion.  Time with users and studying the results of my past work helped inform my next move.  Even the failures, unpleasant as they were, gave me a sweet data set to work off of. 

Of course, the most fascinating thing about this whole learn-and-build process is it feels like a video game.  There's something about it that reminds me of the hours of Civilization and Caesar that I used to put in.  I can't put it into words why that is but I'm sure not complaining.  It's intense but it's also a heck of a lot of fun.