Skip to content

Instantly share code, notes, and snippets.

# I'm just working on a quick script...
true_positives = ...
false_negatives = ...
# Using printf debugging I'd normally do this
p true_positives
p false_negatives
@chrislloyd
chrislloyd / control.coffee
Created March 19, 2011 12:37
Watch out for all the code BTW, this is a hack job.
delay = (ms, fn) ->
setTimeout fn, ms
Array::max = ->
max = @[0];
for elm in @ when elm > max
max = elm
max
class NSResponder
def acceptsFirstResponder= val
(@acceptsFirstResponder = val).tap do
instance_eval do
def acceptsFirstResponder
@acceptsFirstResponder
end
self
end
# Kup. A small all-coffee template language with a syntax like css
#
# Based on:
# * CoffeeKup - https://github.com/mauricemach/coffeekup
# * jQuery Builder - https://github.com/quackingduck/jquery.builder.js
# TODO:
# * stricter regex for tags
# The compiler, takes your template and returns a compiled one
@chrislloyd
chrislloyd / core_ext.rb
Created February 23, 2011 13:51
A few handy snippets when working with MacRuby.
class Symbol
def to_selector
"#{self}:".to_sym
end
end
class NSObject
require 'rake/clean'
CLOBBER.add *File.read('.gitignore').split
require 'parslet'
tree = {:multi=>
[{:tag=>{:name=>"Foo"}},
{:block=>{:name=>"Foo", :multi=>[{:static=>"Bar"}]}}]}
transformer = Parslet::Transform.new do
rule :static => simple(:text) do
'STATIC'
# Load environment variables
env_path = File.expand_path('../env.yml', __FILE__)
YAML.load_file(env_path).each_with_object(ENV) do |(k,v), env|
env[k.to_s.upcase] = v.to_s
end if File.exists?(env_path)
---
gem: --no-rdoc --no-ri
require 'fileutils'
require 'rubygems'
require 'titleize'
def is_artist_folder?(path)
Dir.glob(File.join(path, "*")).any? { |contained_file| File.directory?(contained_file) }
end
def get_artist_name(path)