Skip to content

Instantly share code, notes, and snippets.

@paulcarey
paulcarey / toggle_desktop_image.rb
Created December 13, 2010 22:30
Switch between two desktop images on OS X e.g. a standard image and a texture for use behind transparent windows like Terminal or MacVim
#!/usr/bin/env ruby
STD_IMG_REF = '/Users/paulcarey/.std_desktop_image.txt'
IMG_SRC = '/Users/paulcarey/dev/images/ir_black_bg.png'
def current_img
cmd = "defaults read com.apple.Desktop Background | grep ImageFilePath | tail -n 2 | head -n 1"
res = `#{cmd}`
res = res.split('=')[1].strip
res[1, res.size - 3]
// Example 1
function (clientCallback) {
redis.set('foo1', 'bar1');
redis.set('foo2', 'bar2', clientCallback);
}
// Example 2
function (clientCallback) {
redis.set('foo1', 'bar1', function () {
redis.set('foo2', 'bar2', clientCallback);
#!/bin/bash
# Use the HOST_ENV variable to set the prompt color so the environment
# is obvious at the prompt
# Add it to .bashrc and optionally /etc/skel/.bashrc
function setprompt {
# Format is ESC[Value;...;Valuem
#!/usr/bin/env ruby
require 'rubygems'
require 'relaxdb'
require 'Ruby2Ruby'
require 'spec/spec_models'
c = Module.const_get ARGV[0]
s = RubyToRuby.translate c
puts s
it "should know one another" do
# Code in the cdb block is executed if and only if it hasn't already been run.
cdb do
p1, p2 = Player.stock(:name => "p1"), Player.stock(:name => "p2")
p1.acquaint p2
end
p1.should know(p2) # p1 and p2 are methods that load players by names p1 and p2
p2.should know(p1)
end