Skip to content

Instantly share code, notes, and snippets.

class App < ActiveRecord::Base
end
@dlchet
dlchet / gist:574331
Created September 10, 2010 20:41 — forked from bixu/gist:573973
Vagrant::Config.run do |config|
# Choose our base box:
config.vm.box = "centos"
# Talk to our central Chef server:
config.chef.run_list.clear
config.chef.chef_server_url = "https://chef.domain.com"
config.chef.validation_key_path = "validation.pem"
config.vm.provisioner = :chef_server
config.chef.add_role("vagrant-unstable")
# can be found in features/support/env.rb
require 'pp'
require 'features/support/user'
require 'factory_girl_rails'
@dlchet
dlchet / test.rb
Created February 16, 2012 20:44
how to use rspec stubbing to first raise, then return
module Test
def catcher
begin
pp Foo.bar
rescue Exception
pp "errored"
end
end
end
@dlchet
dlchet / floats.rb
Created February 23, 2012 03:13
float code, commented
class Float # because we are re-opening class float, anywhere we refer to self in
def pretty_s # this method will be the floating point number we call "pretty_s" on.
num = "%.12g" % self # num is a string representation of self with 12 decimal places
num.sub!(/\.(.*?)0+$/,".$1") # remove any trailing zeroes
# might be like 2. at this point # if we had all zeroes, there would be nothing after the decimal point
num = num[0..-2] if num[-1] == '.' # thus, let's remove the decimal point in that case
num # and return our string
end
end
p 1.1-0.9 # >> 0.20000000000000007 # floating point yuckiness means that we get this number instead of 0.2
@dlchet
dlchet / dask-book-chap2.ipynb
Created January 13, 2023 13:31
dask-book-chap2.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.