Skip to content

Instantly share code, notes, and snippets.

View jonmagic's full-sized avatar

Jonathan Hoyt jonmagic

View GitHub Profile
alias st='osascript /path/to/theme-switcher.scpt'
class ApplicationController < ActionController::Base
include SessionAuthentication
# ...

Keybase proof

I hereby claim:

  • I am jonmagic on github.
  • I am jonmagic ( on keybase.
  • I have a public key whose fingerprint is 803A EE9B 6F2C DC04 7FCF B59C A6BE 6D15 DF67 5762

To claim this, I am signing this object:

jonmagic / gist:10012852
Last active August 29, 2015 13:58
How to sign out of Gmail.
1. Click on the little picture or icon in the upper right and click "Sign out”.
2. Then on the next screen click "Sign in with a different account”.
3. Click “Remove”
4. Click the X next to the account you want to sign out of.
5. Click “Done”
6. Congratulations now you are signed out.
require "benchmark"
class Foo
def initialize(bar)
@bar = bar
attr_reader :bar
def do_case
jonmagic / callback-block.rb
Last active August 29, 2015 14:16
Callbacks in Ruby
irb(main):001:0> class Foo
irb(main):002:1> def set_callback(&block)
irb(main):003:2> @callback = block
irb(main):004:2> end
irb(main):006:1* def run
irb(main):007:2> 10.times do |n|
irb(main):008:3* if @callback
irb(main):009:3> end
jonmagic / results.txt
Last active August 29, 2015 14:21
I've got two arrays with identical elements in different orders that I need to compare and the order doesn't matter. Should I use sort or array subtraction?
Rehearsal --------------------------------------------
sort 1.140000 0.010000 1.150000 ( 1.166011)
subtract 0.610000 0.030000 0.640000 ( 0.672543)
----------------------------------- total: 1.790000sec
user system total real
sort 1.240000 0.010000 1.250000 ( 1.254706)
subtract 0.620000 0.030000 0.650000 ( 0.672024)
module Addon
def self.included(base)
base.class_eval do
before_save :update_addon
def update_addon
puts "updating addon"
/* utilities.js */
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright