Skip to content

Instantly share code, notes, and snippets.

View jimeh's full-sized avatar

Jim Myhrberg jimeh

View GitHub Profile
@jimeh
jimeh / decode.rb
Created August 20, 2011 13:56
Ruby-based Benchmark of MessagePack vs. JSON & Yajl
# encoding: utf-8
require 'bench_press'
require 'json'
require 'yajl'
require 'msgpack'
extend BenchPress
reps 10_000
@jimeh
jimeh / flymake-elisp.el
Created August 7, 2011 22:09
FlyMakeElisp
;;
;;; FlyMake Lisp
;;
;; from: http://www.emacswiki.org/emacs/FlymakeElisp
;;
(defun flymake-elisp-init ()
(unless (string-match "^ " (buffer-name))
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
@jimeh
jimeh / birds-of-paradise-theme.el
Created August 7, 2011 12:42
Slightly tweaked version of Paul M. Rodrigues' Emacs port of the Birds Of Paradise theme for Coda
;;; birds-of-paradise-theme.el --- custom theme for faces
;; Copyright (C) 2011 Paul M. Rodriguez <paulmrodriguez@gmail.com>
;; This file is not part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
@jimeh
jimeh / show-and-hide-any-app.applescript
Created June 8, 2011 00:45
AppleScript to help make any app toggle-able via a global hotkeys like the Twitter and Sparrow apps.
-----------------------------------------
-- Show and Hide <application>
-----------------------------------------
--
-- This script allows you to easily
-- toggle the visibility of a specific
-- app, similar to how Twitter and
-- Sparrow toggle with their global
-- hotkey option.
--
@jimeh
jimeh / en.rb
Created April 17, 2011 10:13
Locale template for fuzzyclock gem.
# encoding: utf-8
class FuzzyClock
@@locales ||= {}
@@locales[:en] = {
:about => "it's about %t",
:hour => {
0 => "twelve",
1 => "one",
2 => "two",
@jimeh
jimeh / jquery.myplugin.coffee
Created April 7, 2011 23:44
Example jQuery plugin written in CoffeeScript, and the resulting compiled JavaScript file.
$.fn.extend
myplugin: (options) ->
self = $.fn.myplugin
opts = $.extend {}, self.default_options, options
$(this).each (i, el) ->
self.init el, opts
self.log el if opts.log
$.extend $.fn.myplugin,
default_options:
@jimeh
jimeh / com.rabbitmq.rabbitmq-server.plist
Created March 24, 2011 10:47
Mac OS X launchctl plist for Homebrew-based RabbitMQ installations. Place in: ~/Library/LaunchAgents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.rabbitmq.rabbitmq-server</string>
<key>Program</key>
<string>/usr/local/sbin/rabbitmq-server</string>
@jimeh
jimeh / wait_while.rb
Created February 3, 2011 09:32
wait while &block returns true
# Public: Wait while block returns false by repeatedly calling the block until
# it returns true.
#
# Useful to wait for external systems to do something. Like launching daemons
# in integration tests. Which you're not actually doing right? >_<
#
# timeout - Integer specifying how many seconds to wait for.
# retry_interval - Interval in seconds between calling block while it's
# - returning false.
# block - A block which returns true or false. It should only return
#
# UPDATE!
# Instead of using this monkey-patch, it's better if you simply use the following
# in your environment.rb file:
#
# config.gem "ghazel-daemons", :lib => "daemons"
# gem "ghazel-daemons"
# require "daemons"
#
# This will force-load the 'ghazel-daemons' gem and make sure it's used instead of
@jimeh
jimeh / delayed_job.rb
Created March 26, 2010 22:42
delayed_job.rb: Capistrano tasks to "properly" start/stop/restart the delayed_job daemon.
#
# NOTICE: The stop/restart tasks won't work properly due to a bug in the daemons gem
# unless you use the ghazel-daemons gem by putting this in your environment.rb file:
#
# config.gem "ghazel-daemons", :lib => "daemons"
# gem "ghazel-daemons"
# require "daemons"
#
# This will force-load the 'ghazel-daemons' gem and make sure it's used instead of
# the 'daemons' gem. It works even with the 'daemons' gem installed, so you won't