Search
Twitter Updates
Fitness
Wednesday
Feb082012

Ruby: Caching Technique

In this article, we’re going to explore some of the issues involved in caching as they apply generically to programming. Then we’re going to suggest a novel solution, build some proof of concept code, and then finally implement the caching code. We’ll implement the caching in stages so that you can clearly understand the ruby constructs involved. Actually, you could think of this whole article as a vehicle by which to demonstrate the following concepts in ruby:

  • code blocks
  • thread local variables
  • nested hashes
  • accessing the stack trace
  • using bindings

The best approach to understanding these concepts would probably be to create a single ruby file and add the code snippets to it as we go. This way, you can run the tests and follow along with the development process. You can also twiddle with the code during the various stages to see how things work.

So, let’s dig in…

Click to read more ...

Thursday
Feb022012

Finding the OSX mouse cursor

Often developers have multiple high resolution screens.  Finding a tiny mouse cursor on this expanse can sometimes be anoying.  I propose that OSX add a new gesture such that when you shake your mouse back and forth or shake your finger back and forth on the trackpad that the mouse cursor will produce some sort of visual display that easily draws attention to its location.

Wednesday
Feb012012

We need DTerm for iOS

Most ssh terminal apps for iOS are sluggish due to fact that they attempt to work like a regular ssh terminal session.  I think DTerm (see video: http://decimus.net/DTerm) has the right idea.  Enter your command in a standard textarea field on OSX then execute.  It will toggle the display into output mode where the keyboard goes away and you can easily scroll around and select/copy text from the results.  Then when you tap command line field at the top it toggles back into command line entry mode featuring tab completion, left-right arrows to step back and forth through prior commands from the history (along with their results showing on the bottom half of the screen), and a list-mode display of command history only a tap away.  

This should handle 90% of what you do on the command-line.  For the other 10%, like curses apps, vi, things that require direct interaction / IO, the app would flip to a regular ssh terminal session mode.  Upon exit, it would go right back to normal DTerm mode.

Sunday
Jan152012

Ruby Optimized: Using inline C and Java

For the pure joy of programming this weekend, I updated my Levenshtein module with inline Java and C language optimizations. The Levenshtein string distance algorithm is a great way to determine how similar two strings are to each other. However, it is very CPU intensive. Therefore, I added Java and C versions of the core algorithm which produce 90x and 500x improvements in performance over the pure ruby implementation. In this post, I'll demonstrate how to use the RubyInline and java_inline gems to incorporate C and Java code directly in your ruby source code.

Click to read more ...

Tuesday
Dec272011

Squarespace: Replacing Navigation Section with Custom Login Button

If the 'Navigation' page section didn't contain the critical 'Login' widget then it would probably be removed from most SquareSpace sites. In this article, we're going to learn how to replace this section with a custom login button and social icons bar that appears up in the site header.

Click to read more ...