Closet Coder

I work in my closet. I code. Yep.

Getting Git

| Comments

I recently converted all of my professional projects over to github and switched my dev workflow to use git.

Oh, what a difference a tool makes.

First off, git just works.  It’s awesome to be able to switch branches super easily… and even create a branch after you’ve begun work on it.  Realizing that you’ve started a new feature and need it to be in it’s own “silo” is great.   What you want is for it not to be a pain to merge it back together.   Honestly, I wish we had this at my old job where having multiple levels and several branches would have been highly beneficial.

Secondly, it is a bit of an adjustment to get your mind around a distributed vcs, but it is very powerful once you’re there.  Realizing that a commit is really just versioning off what you have into your local repository and then pushing is really sharing that with some remote repo can be tricky at first.   Once you realize how easy it would be to share and simultaneously work on projects as a result, it is pretty incredible.

To give you an idea, I want to show you a typical svn workflow and the corresponding git workflow.

1
2
3
4
5
6
$ svn co http://svnhub.com/project/trunk
... do some work ...
$ svn up
... resolve some conflicts ..
$ svn status
$ svn commit

Easy, right? Yes, it requires very little… but what if you have no network connection? What if you want to quickly switch a branch? Nonetheless… lets look at the same kind of thing in git

1
2
3
4
5
6
7
$ git clone git@github.com:/username/repo
... do some work ...
$ git add <changed files>
$ git commit -a -m "commit message"
$ git pull origin
... resolve conflicts if any ...
$ git push origin master

So if you’re transitioning off of SVN and you want to move to git, that is probably a workflow you will probably become very familiar with–but the power behind it is amazing. I highly encourage you to watch Scot Chacon’s ‘Getting Git’ talk–it will change the way you think about version control!

Why Programmers Should Play Go

| Comments

Shapes in Go aren’t unlike software design patterns. While there is nothing preventing you from placing logic in your views, this shape is recognized to be a weak one. Think of Gang-of-Four design patterns: the MVC, Adapter, and Factory patterns are recognized to be helpful in some circumstances (and not appropriate in others). On a lower level, iteration and recursion have commonly recognized shapes, as do database normalization vs. denormalization. Even if you can’t hold an entire program or algorithm in your head at once, recognizing common shapes helps you to understand what is going on.

via Rail Spikes: Why programmers should play Go.

Fixing "Freemium" Issues in the App Store

| Comments

Recently, Apple allowed Apps that are free to add in-app charges in order to allow users to “try before they buy.”

Interestingly, BrainJuice, a developer of the game Arcade Hockey recently decided to move to this freemium model, but made a major mistep in my opinion.  The original app was $0.99, but the newly updated version is free, but contains ads.  In order to turn off the ads, you must pay $0.99, which will mean that you basically paid twice for the same app.  There might be a bug fix or two here and there, but nothing deserving of doubling the price of an app.

To me, this feels like a bait and switch, but the author insists there was no other way.   He asserts that it was highly undesireable to create a second free version of the app because of the way their APIs keys work with a third party service they use.  I think there was a way around this, which I’ll explain here:

  1. BEFORE you switch to the freemium model, you create a new update that "phones home" with a unique identifier for the device which "registers" the device
  2. Give the users at least a month to download the update and launch it once so that they are officially "tagged"
  3. Within the freemium app, create a check if the "ads" flag is still on to check the server to see if the device ID is in the "nice" list.  If so, turn the flag off... your user has already paid.
  4. If not, turn on a "dont check" flag so you don't have to keep checking and wasting lots of bandwidth.

Does this approach have its problems?   Of course.   If the users somehow misses the “middle” upgrade, then they miss out.   It also puts you at risk for security issues.  However, it does afford you the ability to grant users a free copy at your whim.

Unfortunately, because BrainJuice didn’t think through the problem the whole way, they have abandoned a good and vocal portion of their fanbase–so this doesn’t help them at all.

But for you who are thinking of transitioning… think twice, and get it right.

Installing Memcached 1.4.4 on Mac OS X 10.6 Snow Leopard

| Comments

Wincent.com has a great article on how to install memcached 1.4.1 on Mac OS X 10.6 Snow Leopard.

Now that memcached 1.4.4 is out, I thought it would be nice to update it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
curl -O http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar xzvf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure
make
make verify
sudo make install

curl -O http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz
tar xzvf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure
make
make test
sudo make install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env ruby
require 'pathname'

# memcached requires an absolute path for the -P switch
root = (Pathname.new(__FILE__).dirname + '..').realpath
pidfile = root + 'tmp' + 'memcached.pid'

if not pidfile.exist?
  puts "memcached not running: starting"
  system 'memcached', '-d', '-P', pidfile, '-l', '127.0.0.1'
else
  puts "memcached running: stopping"
  pid = pidfile.read.chomp
  system 'kill', pid

  # it appears that memcached doesn't clean up its pid file
  # unless you send it a QUIT signal (TERM, KILL, HUP don't)
  # unfortuantely, QUIT on Mac OS X causes memcached to crash
  pidfile.delete
end

25 Tips for Intermediate Git Users

| Comments

Version Control Systems are critical when it comes to keeping your code in a place you can actually use it.   Git is one of those systems that will change how you think about VCS because it suddenly makes it easy and fast to branch and merge.

Become more efficient at git and quit wasting time with Subversion merges and remote repositories: 25 Tips for Intermediate Git Users

Autoficiency

| Comments

Over the course of human history, we’ve generally done things as best as we can, working the same tasks over and over again.   Our brains have gotten good at repetitive tasks, though our hearts long for something unique and challenging.   Only in the past 200 years have we begun to truly automate much of our lives.   With the dawn of the industrial age, we’ve seen automation begin to change our lives.

With the ubiquity of computers, automation has been taken to an entirely new level, allowing us to not only automate large processes, but even small ones.   I have a love for automating things and improving efficiency that continues to grow–but not for automation’s sake–for the sake of being able to experience the things we were meant to experience in this life: relationships.  Getting the drudgery out of the way and enabling us to spend time with family and friends is the point.   If we are automating our lives away, what is the point of life anyway?

This blog is meant to be an outlet to discuss automation of the drudgery of life including computers, programming, best practices, hacking life, etc.