Skip to content

Instantly share code, notes, and snippets.

votes CF
"back in black" => { 201005211200 => '1', 201005201159 => '1', 201005201157 => '1', 201005011900 => '1', 201004190600 => '1' },
"black album" => { 201005021800 => '1', 201005010600 => '1' },
"black star" => { 201005011000 => '1' }
cached_counts CF
"back in black" => { 'cached_count' => 2, 'counted_until' => 201005011931 },
"black album" => { 'cached_count' => 1, 'counted_until' => 201005010600 }
#!/usr/bin/env ruby
# vim:set ts=4 sw=4 et ai:
#############################################################################
# Copyright (c) 2007, Toby DiPasquale
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
@codeslinger
codeslinger / black-scholes.c
Created July 12, 2010 02:50 — forked from ecounysis/LICENSE.txt
Black-Scholes Option Pricing Model in C
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double Normal(double);
double N(double, double, double, double, double);
double delta(double, double, double, double, double);
double delta2(double, double, double);
double ND2(double, double, double);
#!/bin/sh
set -e
priority=2
basedir=/usr/lib/jvm/jdk1.7.0
basediralias=/usr/lib/jvm/jdk1.7.0
mandir=/usr/lib/jvm/jdk1.7.0/man
jdiralias=jdk1.7.0
srcext=1.gz
We couldn’t find that file to show.
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
@codeslinger
codeslinger / foo.rb
Created March 16, 2010 20:57
problem with module attribute keeping value over multiple Rails requests
#
# -=[ Problem ]=-
#
# On the first Rails request, after calling Foo.configure in
# config/environments/development.rb, @@provider is the correct
# object and so Foo.doit() succeeds. On the second request, though,
# it raises the ArgumentError b/c @@provider is now nil. What am I
# doing wrong?
#
# This file lives in lib/foo.rb in a Rails 2.3.5 project
# Power law (log tail) distribution
# Copyright(C) 2010 Salvatore Sanfilippo
# this code is under the public domain
# min and max are both inclusive
# n is the distribution power: the higher, the more biased
def powerlaw(min,max,n)
max += 1
pl = ((max**(n+1) - min**(n+1))*rand() + min**(n+1))**(1.0/(n+1))
max-1-pl.to_i
require 'yaml'
class Hash
def filter(*keys)
self.inject({}) {|h,(k,v)| h[k] = v if keys.include?(k); h}
end
end
test_hash = {'one' => 1, 'two' => 2, 'three' => 3}
puts test_hash.to_yaml
(in /Users/toby/code/friendly)
All dependencies seem to be installed.
/opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/json-1.1.3/lib/json/common.rb:60: warning: already initialized constant State
.................................................................................FFFFFFF.........................................................................................................................................
1)
NoMethodError in 'Friendly::DataStore retrieving all based on a query gets the data from the dataset for the klass and makes it an arary'
undefined method `map' for nil:NilClass
/Users/toby/code/friendly/spec/../lib/friendly/data_store.rb:20:in `all'
./spec/unit/data_store_spec.rb:29: