Skip to content

Instantly share code, notes, and snippets.

@statonjr
statonjr / gist:6092758
Last active December 20, 2015 07:19
Calca example

mass of moon = 73.483E+21 kg

mass = 3,000 kg

mass of moon * mass => 22.0449e25kg^2

@statonjr
statonjr / gist:5940369
Created July 6, 2013 16:20
Writing a constitution is hard work. If you had to write a constitution today, what would you write?
We the People of Utopia establish this Constitution to enhance Liberty, establish Justice, insure domestic Tranquility, provide for the common defense, and promote the general Welfare.
Article I.
Section I. All legislative Powers herein granted shall be vested in a Congress of Utopia, which shall consist of a Senate and House of Representatives.
@statonjr
statonjr / gist:5338511
Created April 8, 2013 17:09
Add a custom date filed to a contact
tell application "Contacts"
set thisContact to item 1 of (get selection)
set creationDate to creation date of thisContact
tell thisContact
make new custom date at end of custom dates with properties {label:"creation date", value:creationDate}
end tell
save thisContact
end tell
@statonjr
statonjr / fmp_repository.rb
Last active December 15, 2015 12:59
Repository Pattern example
# FileMaker Pro!
module Simple
class FMPRepository
attr_reader :cases
def initialize
@cases = []
end
@statonjr
statonjr / gist:5264434
Created March 28, 2013 16:05
Example repository pattern
module Simple
class Repository
def self.configure(options = {})
@mappings ||= {}
@mappings.merge!(options)
end
def self.reset!
@mappings = {}
end
Check out README.md to get started editing Clojure with Emacs.
require 'roar/representer/json'
require 'roar/representer/json/hal'
require 'roar/representer/feature/hypermedia'
require 'lib/api/representers/dealership_representer'
module DealershipsRepresenter
include Roar::Representer::JSON
include Roar::Representer::JSON::HAL
include Roar::Representer::Feature::Hypermedia
@statonjr
statonjr / compressed_requests.rb
Created January 30, 2013 19:35
Uncompress request bodies on the fly
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
@statonjr
statonjr / gstore-benchmarks.txt
Last active December 11, 2015 06:58
GStore/PStore benchmarks from Maglev Ruby, MRI 1.9.3, and JRuby
Mac OS X 10.8.2
2.6 GHz i7 Processor
16 GB RAM
JRUBY_OPTS="-J-Xmx1024m --1.9"
##########
maglev-ruby --version
maglev 1.1RC1 (ruby 1.8.7) (2012-12-06 rev 1.1RC1-29699)[Darwin x86_64]
@statonjr
statonjr / static_resource.rb
Created January 3, 2013 23:17
Static resource for webmachine-ruby
class StaticResource < Webmachine::Resource
def encodings_provided
{"gzip" => :encode_gzip, "identity" => :encode_identity}
end
def allowed_methods
%W[GET]
end