Skip to content

Instantly share code, notes, and snippets.

class Location:
def __init__(self):
pass
def degreesPerHour(self):
return self.degreesAtNoon / ((self.sunSetsAt - self.sunRisesAt) / 2)
class Forecast:
def __init__(self, startsAt):
# Hitting Memcached while running tests is a _really_ bad idea. This class is basically a glorified hash, keeping track of what's given to it,
# seems to work acceptably in test env.
# The way the Cache module works, it assumes a constant named CACHE to keep the actual holder for cached data - this class provides what seems to be needed for the
# engine not to complain
class MockCached
class Value
attr_reader :value
def initialize(value, expiry=nil)
@value = value
@expiry = expiry
== overview:
builtin: rake, rubygems, json, securerandom, HMAC digests
removed: base64 (unpack("m*"))
== nye ting:
Hash syntax ( {foo: "bar"} #=> {:foo => "bar"})
require 'test/unit'
class Size
include Comparable
attr_reader :size
SIZE_LIST = %w(xxs xs s m l xl xxl)
def self.method_missing(m,*args,&blk)
if SIZE_LIST.include?(m.to_s)
return new(m.to_s)
(function(Camping) {
var Blog = {
Models: {
},
Controllers: {
},
Views: {
}
};
Camping.goes(Blog);
RATIONALE =<<_END
The case for a maybe:
We all know true and false, right? Larry Wall once said that truth should be
considered evident; therefore anything in Perl is either true or false, along with
anything else it may be. Truth is just an aspect.
And we use it easily, with the if/else construct:
if something
do_something
class Project
has_many :events, :order => "created_at asc", :dependent => :destroy do
def nevermind
find(:all, :conditions => {:action => 99})
end
end
end
@zmalltalker
zmalltalker / udev_rules_for_nexus_one_on_fedora_14.mdown
Created November 25, 2010 11:49
This is a proven udev rule for running adb in Fedora 14

I had trouble getting the Android toolchain working under Fedora 14 with my Nexus One. The Android documentation only gives the correct udev rules for Ubuntu, so I had to dig around to find something that worked.

The solution

My solution is to add the following into /etc/udev/rules.d/51-nexus-one.rules. You should not need anything besides this to get it working.

SUBSYSTEM=="usb", ATTRS{idProduct}=="4e12", ATTRS{idVendor}=="18d1", MODE="0666" SYMLINK+="android_adb"

After which you run udevadm control --reload-rules, and plug in your phone. At this point, lsusb should display your Nexus in the listing.

@zmalltalker
zmalltalker / bzip2 vs pbzip2
Created February 22, 2011 08:18
pbzip2 runs on several cores
So let's see how bzip2 performs. It will run on a single core:
log ➤ time bzip2 test.log
bzip2 test.log 95.70s user 0.38s system 99% cpu 1:36.84 total
99% cpu. 1.36 minutes. Not too shabby
Now, for some multi core action, let's see how pbzip2 performs:
log ➤ time pbzip2 test.log
@zmalltalker
zmalltalker / gist:1891397
Created February 23, 2012 07:53
Very simple upstart script for Unicorn
chdir /var/www/rails_apps/the_one
env RAILS_ENV=production
exec /usr/bin/bundle exec unicorn_rails -c config/unicorn.rb
respawn
# This start on stanza works, but it's simplistic
# Will add a stop on stanza once I make up my mind about stop on
start on runlevel [3]