Jog to get Smarter

Uncategorized
Exercise affects the brain as well as the body.  I've acquired the habit of running around the block 1-2 times per day as a way to get up, get the blood to circulate, and to focus my attention on what I'm working on.  It turns out, recent research says this makes me smarter!  Especially if I do distance jogging, and I'm a rat. I'll stick to running around the block. NYT: Which Type of Exercise Is Best for the Brain?
Read More

show all project code (a find-git-xargs example)

Uncategorized
The following command finds all your project's Javascript files that aren't installed via NPM. It then does a "git blame" so you can see who wrote which bits of code, and how old the code is. find . -path ./node_modules -prune -o -name '*.js' | xargs -n1 git blame --date=short -- If you're using OSX, install the GNU versions of the Unix tools gfind . -path ./node_modules -prune -o -name '*.js' | gxargs -n1 git blame --date=short -- Those who don't understand Unix will be doomed to reimplement it. Poorly. :)
Read More

devops: per-process swap usage

Uncategorized
awk '/Name/{name=$2}; /VmSwap/{printf "%20st%s %sn",name,$2,$3}END{ print ""}' /proc/*/status inspired from: adnans Output:      chromium-browse 19664 kB      chromium-browse 6128 kB         avahi-daemon 320 kB         avahi-daemon 220 kB               colord 644 kB                 smbd 840 kB
Read More

console.log macro in Sublime Text

Uncategorized
Here's how to make a selection macro in Sublime Text.  Type the word "beer", select it, then press a key to turn it into a console.log statement! Here's how to do it: 1. Create the console.log template: Click Tools > Developer > New Snippet... Paste the following: <![CDATA[ console.log("$SELECTION"); ]]> log Save the above as log.sublime-snippet 2. Create a keybinding to the snippet: Click Sublime Text > Preferences > Key Bindings Paste this bit into the middle of the keymap:  {   "keys": ["ctrl+shift+l"],    "command": "insert_snippet",    "args": { "name": "Packages/User/log.sublime-snippet" } }, Save it. To use, type beer in your program. Double-click to select it, then hit your "log this message" keyboard command ctrl+shift+l. Boom! console.log("beer");
Read More

Linux is awsome

Uncategorized
At work we process many millions of emails a day, so we get a lot of bounces. The following code helps me make the system smarter. It translates to "for the most recent five users who's received a bounce message, find all of their bounces in the last 24 hours and show me the Subject lines, with user and date information." find `ls -1t | head -5` -type f -mtime -1 -print0 | xargs -0 egrep Subject /dev/null | less
Read More

tiny "Hello World" webserver

Uncategorized
I'm writing a Nginx configuration that will wrap password protection on top of a bunch of dependent web servers. For testing, I want a few "hello world" type web servers, each of one gives a different message, but is really tiny. The following is what I came up with -- great for testing. # USAGE: # python ./hello.py free beer  import SimpleHTTPServer import StringIO import SocketServer import sys PORT = 8000 class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):     MESSAGE = ' '.join(sys.argv[1:])          def send_head(self):         self.send_response(200)         self.send_header("Content-type", 'text/plain')         self.end_headers()         return StringIO.StringIO(self.MESSAGE)      httpd = SocketServer.TCPServer(("", PORT), MyHandler) print "serving at port", PORT httpd.serve_forever()
Read More

Norris Numbers: adding code is great, until…

Uncategorized
Programmers get stuck at a certain amount of complexity. Newbies can write brute-force programs up to 2,000 lines or so, but beyond that it's too hard to manage. You can't keep everything in your brain. Experienced programmers have other tools -- abstraction -- to get up to 20,000 lines in a single project. There are other complexity walls: at 200K, then 2M. There might be a hard limit of any project at 3M lines: "the growth rate seems to slow down significantly no matter how many people (hundreds) or years are involved (decades). " Norris Numbers The author also clearly highlights the problem of Every Line is a Potential Bug -- go read!
Read More