Skip to content

Instantly share code, notes, and snippets.

require 'rubygems'
require 'eventmachine'
module ChatClient
def self.list
@list ||= []
end
def post_init
@name = "anonymous_#{rand(99999)}"
[pjackson@host]$ cat ~/.ssh/environment
ORACLE_BASE="/opt/oracle"
ORACLE_HOME="/opt/oracle/product/10.2.0/client_1"
DYLD_LIBRARY_PATH=/opt/oracle/product/10.2.0/client_1/lib
[pjackson@host]$ sudo grep PermitUser /etc/ssh/sshd_config
PermitUserEnvironment yes
@neerajsingh0101
neerajsingh0101 / to_xml
Created April 26, 2010 13:06 — forked from josevalim/to_xml
to_xml agreement
> [User.first, User.last].to_xml
# master branch
<users type="array">
<user>
<name>John</name>
</user>
<user>
<name>Mary</name>
</user>
</users>
@neerajsingh0101
neerajsingh0101 / capybara cheat sheet
Created March 30, 2012 02:56 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@neerajsingh0101
neerajsingh0101 / Gemfile
Created April 24, 2012 22:36 — forked from drogus/Gemfile
Router
gem "actionpack"
gem "thin"
module Anagram
class Dictionary < Hash
def initialize(dict_file="/usr/share/dict/american-english")
words = File.read(dict_file).split(?\n)
words.group_by(&:length).each do |k,v|
self[k] = v.group_by(&:chr)
end
end
source 'http://rubygems.org'
#gem 'rails', '4.0.0.beta1'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'

This histogram shows the distribution of GitHub Gist API response times (in milliseconds) for a sample of 10,000 requests as observed by bl.ocks.org.

The distribution roughly follows a log-normal distribution, which is unsurprising for a complex process that has multiple independently-random sources of delay. The mode response time was in the range 120-140ms, while the median response time was 206ms. The middle 80% of requests were in the range 114-527ms. About 11% of requests took longer than 500ms, and 5% of requests took longer than one second. (The rightmost bin in the histogram includes these long requests.)

Since API endpoints vary dramatically in their computational cost, the distribution of response times is likely multimodal. In this dataset, 96% of requests were for a single gist (/gists/42), while the remaining 4% of requests were to list a user’s gist (/users/fred/gists). By separating the API requests for a single

['json','rest-client','pry'].each {|lib| require lib}
module Helper
def self.get_data_from_api(url)
response = RestClient.get url
response.force_encoding('utf-8')
JSON.parse response
end
end
class PriceCalculator
ITEM_UNIT_PRICES = {
milk: 3.97,
bread: 2.17,
banana: 0.99,
apple: 0.89
}