Skip to content

Instantly share code, notes, and snippets.

View jcf's full-sized avatar
❤️

James Conroy-Finn jcf

❤️
View GitHub Profile
@jcf
jcf / List used GroupIDs just because I can.rb
Created December 29, 2008 02:12
We list UIDs so why not PrimaryGroupIDs in an equally slow fashion?!
#!/usr/bin/env ruby -wKU
groups = %x(dscl . -list /Groups).split("\n")
gids = []
groups.each do |group|
gids += [%x(dscl . -read /Groups/#{group} PrimaryGroupID).split[-1].to_i]
end
puts gids.sort
module Paths
def self.method_names
@method_names ||= []
end
module InstanceMethods
# Add your nested resources below
NESTED_ROUTES = {
:account => :payment
}
#!/opt/local/bin/bash
# .git/hooks/commit-msg
exec < /dev/tty
commit_message=$1
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
branch=${ref#refs/heads/}
# Exit if commit message empty
a {-webkit-transition-duration: .33s; -webkit-transition-property: color, background;}
dl#sidebarlinks dd {-webkit-transition:-webkit-transform .33s linear}
dl#sidebarlinks dd:hover {-webkit-transform:rotate(-3deg);}
-module(example).
-export([fac/1, mult/2]).
fac(1) ->
1;
fac(N) ->
N * fac(N - 1).
mult(X, Y) ->
X * Y.
-module(list_length).
-export([list_length/1]).
list_length([]) ->
0;
list_length([First | Rest]) ->
1 + list_length(Rest).
@jcf
jcf / gist:130146
Created June 15, 2009 14:51
Some useful resources regarding AppleScript in Cocoa
A Few Examples of using Scripting Bridge:
http://developer.apple.com/documentation/Cocoa/Conceptual/ScriptingBridgeConcepts/UsingScriptingBridge/UsingScriptingBridge.html#//apple_ref/doc/uid/TP40006104-CH4-DontLinkElementID_12
A note of Performance & Optimisation with Scripting Bridge:
http://developer.apple.com/documentation/Cocoa/Conceptual/ScriptingBridgeConcepts/ImproveScriptingBridgePerf/ImproveScriptingBridgePerf.html#//apple_ref/doc/uid/TP40006104-CH6-SW1
NSAppleScript Technote/Example:
http://developer.apple.com/technotes/tn2006/tn2084.html
def foo(bar = {})
if bar.any?
bar.keys
end
end
# exhibit a
{:conditions => case f.to_s
when 'active' then {:state => @@states[2]}
when 'disabled' then {:state => @@states[0..1]}
when 'all' then {}
else {:state => @@states[3]}
end}
# exhibit b
case f.to_s
@jcf
jcf / monitor.rb
Created July 8, 2009 12:16
Monitor file operations within a folder and it's subfolders and spawn a builder process accordingly
#!/usr/bin/env ruby
require "find"
require "optparse"
require "rubygems"
require "session"
require "webby"
begin
require "inotify"