Fun with first class functions in Go
There are times I need to wrap a function with extra behavior. Also I need to wrap this behavior in different ways based on some configuration.
One option is to define a configurable object with a method that wrapped the specific behavior. Based on some state in the object the wrapping method would behave differently.
However, for fun, and . . .
My confusion surrounding casting a function into an object
Being new to Go I was confused by how some packages in Go adapt functions into objects. The net/http package provides such an adapter.
It is really easy in Go to create a basic web server. The function
http.Handle takes a pattern and a
http.Handler object. When a request is made that matches a provided pattern the handler's
. . .
A look at my favourite configuration settings
I have been using tmux for a couple of years now, I committed a
tmux.conf to my dotfiles repo two years ago this week. I find that it is an excellent way to organize projects, share a session for pairing, or just ensure W or Q don't ruin your day! I just wrote a post on how I use it a Iora Health to manage my development environment that . . .
Implementing the Enumerator (not)
I am a big fan of the Enumerator in Ruby. So I wanted to see if there was something similar in Go. But before I started my search I was curious to see if I could implement a crude version myself.
In Ruby we would just implement the
each method and include the Enumerator module. So if I could implement an
each method in Go it would be close . . .
Resources, best practices, and diving in
My programing language of choice is Ruby. I just love to work with it. As a former Java developer, Ruby has made my life so much better. Apart from the beautiful language, Ruby also has a great community. This more than anything is what makes Ruby so powerful.
So why would I be interested in a different language? Well much of it has to . . .
Unfortunately there is no backup silver bullet, so to ensure that I have the computers in my home backed up and secured I use a mix of services. In the following sections I will describe how I use Time Machine, Arq and GitHub to keep my data backed up and secure.
Time Machine and Drobo
I use Time Machine to fully backup 3 MacBooks and a . . .
Convert subfolder into Git submodule
Recently I had the need to refactor a large repository we use at work. The layout of the repository was as follows
~ $ cd ~/Development/LUF (master) Development $ ls src/ (master) Development $ cd src; ls AAR/ MSEL/ SigEvServer/ WebServices/ (master) src $
All the apps in the src folder were Rails app (except AAR) and I wanted to
move each . . .
How to apply changes to all open VIM buffers
A simple way to make modifications to a lot of file is to open all of them
in vi and apply the search and replace to every file that is buffered. The
easiest way to do this is as follows:
:bufdo %s/pattern/substitution/ge | update
Breaking down the command we can see what each part is doing.
|bufdo||apply to all buffers|
|g||apply to all . . .|
Using rebase instead of merge when pulling from remote
Instead of doing a regular pull
git pull# aka: git fetch && git merge remotes/origin/BRANCH BRANCH
To avoid the all the merge commit messages you can run the following command instead
git pull --rebase# aka: git fetch && git rebase remotes/origin/BRANCH BRANCH
I actually have the following in my ~/.gitconfig file
[alias] up = !sh . . .
Setting up ssh keys
On each machine type ssh somemachine.example.com and make a connection with your regular password. This will create a .ssh dir in your home directory with the proper perms.
On your primary machine (the machine that you will ssh from) where you want your secret keys to live (let's say kermit), type
$ ssh-keygen -t dsa
This will . . .