Quantcast
Channel: The Sleepless Geek
Browsing latest articles
Browse All 25 View Live

Seeing where Ruby methods come from

When it comes to reflection - asking an object or class to tell you about itself - Ruby makes a lot of sense. If you want to know what methods an object has, for example, you just ask it:...

View Article



Chaining jQuery Pseudoselectors

I just finished a very simple Javascript tweak to an app. Here was the requirement: "When the user opens our sign-in modal, we should focus the on the first input." Whatever code I wrote, I would put...

View Article

Image may be NSFW.
Clik here to view.

Introducing Bindler

Rails. Hobos. Bundler. Bindles.I awoke one day last week with this comic idea percolating in my brain. Too bad I'm lousy at drawing.

View Article

Image may be NSFW.
Clik here to view.

IE: Still the biggest yak to shave

My conclusion after a day and a half of fixing IE-only Javascript bugs.And this is IE8, mind you.Come on, Microsoft. Just use Webkit, already.

View Article

PHP: now running in the browser!

Got this email from a recruiter just now:Hope you are doing well. We have an urgent requirement forPHP Front End Developer . Please go through the below mentioned job opportunity and let me know your...

View Article


Watching your log for a specific value

If you use Unix, you probably know about piping one command's output through another. You may also know that tail -f somefilewill show you whatever gets added to the end of a file in real time.While...

View Article

Image may be NSFW.
Clik here to view.

Best error message ever

A while back, I sent a text message and got this error back from AT&T.Wow... thanks. I... didn't know you cared?Apparently they just append the text of the message (this one was to my wife) to the...

View Article

Using Ruby for SCP file transfers

Today I needed to write a Ruby script to fetch a file using SCP. I thought it would be nice if it also displayed a "percent complete" counter as it went. This is what I came up with.require...

View Article


Short Rubyzip tutorial

Rubyzip is a handy tool for creating zip files with a Ruby script. But to me, the documentation doesn't make it immediately obvious how to use the thing. This quick tutorial should get you started.Say...

View Article


Where cliche is a mandate

A recruiting company that spams me has the slogan "Where Commitment is a Passion."What does that even mean?"We're always looking for stuff to commit to. I just committed to eating a whole jar of...

View Article

Using git cherry-pick

One Git command that I've found to be really useful lately is "git cherry-pick". It lets you take a single commit from one branch and apply it to another.For example, say you're working on your...

View Article

Authorized_keys and SCP

I have SSH access to a machine, and I want to add my public key to the `authorized_keys` file so I don't have to type a password to log in. A friend taught me a neat command for doing this:% cat...

View Article

Ruby's String#unpack and Array#pack and Unicode

At work, I'm exporting some data for use by a system that doesn't understand Unicode. I ran across an Obie Fernandez post explaining his approach.One method he showed was this:def to_ascii_iconv...

View Article


Image may be NSFW.
Clik here to view.

Ruby's Set class

Yesterday at work, we ran into an interesting problem. We're creating the new version of an application and discarding the old, ugly code. But we need to migrate some data: the old system has (let's...

View Article

Understanding Rack applications

I'm starting to understand Ruby's Rack application architecture, and it's really cool. It's a simple concept, but very powerful, because of the ways it lets you stack up different components with...

View Article


Using the Execute Around pattern in Ruby

At my last job, I wrote a script that was run by a cron job overnight. The script was supposed to go through a MySQL table of scheduled database queries and, if they met some sanity checks, run them....

View Article

Metaprogramming Danger Box

In my last post, I showed how one can use the "execute around" pattern in Ruby to log any calls to a method, without cluttering the methods themselves with logging calls.That gave us code like this:def...

View Article


Sometimes you can be too DRY

In a Rails app, my favorite idiom for describing what users can and cannot do goes like this:# In view code, for example... link_to "Edit Widget", edit_widget_path if current_user.can_edit?(widget) #...

View Article

Testing a Rails 3.1 Engine's Javascript with Jasmine

At work, we've got a Rails engine that provides some complex drop-in forms to various applications. The forms have associated Javascript which, on Rails 3.0, we had to copy and paste between...

View Article

Faster feedback

In programming, the faster you get feedback from your code, the more productive you can be.For example, suppose you're going to use the Javascript Date class in a web page to do some time calculations....

View Article

The beauty of xargs

Every time we deploy our Rails application, our deployment tool creates a new folder based on the date and time, puts the right files in it, and when everything is ready to go, updates a symlink to...

View Article


New gem: Authority

I recently released a new Ruby gem for authorization in Rails apps. It's called Authority. You can find the code and extensive documentation on Github; the gem is hosted on RubyGems. I also wrote a...

View Article


Programming music: Afriki Djigui Theatri

I've been meaning to write a post about music I like to listen to while programming. My main criteria is that it doesn't have words I can understand, because that triggers the language part of my...

View Article

Hubbub

I like to imagine that somewhere in Silicon Valley, there is a sandwich shop which caters to nerds. They send out special deals via RSS feed. Naturally, they call this the PubsubHubbub Sub Club.Based...

View Article

Notification from long-running tasks

Yesterday I thought of a technique which has become a real time-saver for me. (I'm sure I'm not the first person to think of this; I remember reading something similar in Time Management for System...

View Article

Browsing latest articles
Browse All 25 View Live




Latest Images