This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'set' | |
# First I wanted to get an idea of the timing of the various approaches | |
def time | |
start = Time.now | |
yield | |
puts Time.now.to_f - start.to_f | |
end | |
# This optimizes for redundant strings of values, front-loading them to maximize duplicates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
com = { cyberfox: {} }; | |
/** | |
* Convert a property name into a human readable string by replacing _ with | |
* spaces, and upcasing the first letter of each word. | |
* | |
* @param {string} property The property name to convert into a readable name. | |
* @return {string} The property name converted to a friendly readable format. | |
* @private | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# | |
# Usage: | |
# security dump-keychain -d login.keychain > keychain_logins.txt | |
# # Lots of clicking 'Always Allow', or just 'Allow', until it's done... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Testing HTML5 Canvas element</title> | |
<script src="jquery.min.js" type="text/javascript"></script> | |
</head> | |
<body> | |
This is a test of the HTML5 Canvas element. | |
<canvas id="drawing_canvas" width="800" height="600" style="position: absolute; top: 0; left: 0;"> | |
</canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sqlite3' | |
require 'sequel' | |
# Adding this monkey-patch makes it work on MacRuby. | |
module Sequel | |
class Dataset | |
def single_record | |
record = nil | |
clone(:limit=>1).each{|r| record = r; return r} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mv ~/Library/Preferences/JBidwatcher/jbdb ~/Library/Preferences/JBidwatcher/jbdb.save | |
mv ~/.jbidwatcher/jbdb ~/Library/Preferences/JBidwatcher/jbdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TableDelegate.rb | |
# | |
# An example of capturing double-clicks and a yellow-fade technique in MacRuby. | |
# The yellow fade technique implementation is a ruby-ized translation | |
# of http://www.bdunagan.com/2009/04/26/core-animation-on-the-mac/ | |
# Created by Morgan Schweers on February 26, 2011. | |
framework 'Cocoa' | |
class TableDelegate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'http://rubygems.org' | |
gem 'rails', '3.0.3' | |
# Edit this Gemfile to bundle your application's dependencies. | |
# This preamble is the current preamble for Rails 3 apps; edit as needed. | |
gem 'mysql' | |
gem 'delayed_job' | |
gem 'unicorn' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based off of Rails, by way of http://www.raulparolari.com/Rails/class_inheritable | |
class Class | |
def class_inheritable_reader(*syms) | |
syms.each do |sym| | |
class_eval <<-EOS | |
def self.#{sym} | |
read_inheritable_attr(:#{sym}) | |
end | |
EOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'inheritable_attrs' | |
class Entity < NSManagedObject | |
class_inheritable_accessor :entity_name | |
self.entity_name = 'Entity' | |
def self.inherited(sub) | |
sub.entity_name = sub.to_s | |
end |