Learnings Week 20 2011
Following last week's learnings, here's another dose of little bits and pieces I've learned over the past week or so.
- Using
cd -is a good way to jump to the "prevous directory." That is to say if you change from$HOMEto~/source/github/and then to/opt/graphite/current/webapp, at that point if you entercd -you'll jump back to~/source/github/. fcwill pop open$EDITORwith the previous command so you can clean it up, or fix the command. I've found this incredibly useful to turn shell-one-liners that organically grow to hundreds of lines into simple scripts.- (This learning was the inspiration for an earlier pseudo-rant) Inside of the redis codebase is a library for dynamic strings in C which is rather magical! When allocating a new "magic string", the library actually allocates a block of memory larger than the string itself, and prepends the string portion of the memory with a struct filled with meta-data. Making your block look something like
[[struct sdshdr][char *]]. The pointer you pass around is to the[char *]block, allowing you to easily print and work with the string as per normal. In order to free this memory, the library provides afree(2)wrapper which doesfree(s - sizeof(sdshdr));While normally, doublefree(2)calls can be detected and alerted in Glibc, an accidental double-free on this structure will explode in spectacular and hard-to-trace-without-valgrind ways! - If you need to print a number when echoing a variable, such as in a for loop, use:
typeset -Z5 x. This will make thexvariable 5 digits long. I found this to be very useful for quickly generating a sequential list of serial numbers, e.g.for x in {1..10}; do typeset -Z5 x; echo "ZTX1${x}A"; done - You can use the "Git Publish" feature of the Jenkins Git plugin to push tags to GitHub for successful builds. When used in conjuction with GitHub's "downloads" feature, which auto-generates tarballs for tags, you can automate creation of pre-tested nightly snapshots, graciously hosted by GitHub.
academia activerecord ada amber android apture async bart bdd beer birthday blimpy brainfuck buzzwords c campdevops cheetah chrome ci cocoa conference continuousdeployment cucumber devops documentation drupal epoll europe evernote facebook family food fosdem fosdem2012 fosdem2013 ganglia gerrit git github gla graphite home homosex hubboard hudson identica javascript jekyll jenkins jenkinsci jenkinsconf jenkinsconf2012 juctokyo juggling justintv learnings linux literature livecoding lookout media meetups microblogging miscellaneous mono offtopic opbart opengrok openmoko opensource opinion ops parrots photos presentation programming protesting puppet puppetconf puppetconf2012 python ragequit rails rdoc redis resin ri roadtrip ruby running scale scale10x screencast security selenium slide smalltalk soapopera software development sonic ssh stupidhacks tablet tor tripdiary twitter twos usenet vagrant video voyeurism wtf
