Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@jimweirich
jimweirich / sample.rb
Created August 28, 2012 01:30
Spikes in Rspec/Given
# Spike in rspec-given
# The following now works in a proof of concept spike.
# When an exception happens during a When block (and there
# result variable to catch it), the result will be a "Touchy"
# object that re-raises the exception from the When block
# on every single method you could call on it.
describe "Empty Stack" do
When(:result) { empty_stack.pop }

RocketSocket

This library was created out of my frustrations working with the Ruby's built-in Socket classes when writing Working With Sockets. It provides two functions: 1) A better way of building sockets with the common options that are more configurable/portable, and 2) A built-in way of framing messages in an safe and efficient manner. Nothing fancy.

RocketSocket::Build

socket = RocketSocket::Build.host('0.0.0.0').port(8080).ssl.read_timeout(60).write_timeout(10).listen(512).tcp
socket.write_timeout #=> 10
@fetep
fetep / README.md
Created August 4, 2012 03:24
non-plaintext statsd updates

over here, https://gist.github.com/3243702, i proposed extending the text protocol by supporting updating a timer with multiple values at once (to help statsd clients that do a bit of batching for efficiency). this makes the update string a bit expensive to parse (especially because you have to get to the end of a potentially long string to even know what kind of update you have).

so here are some thoughts on a different way to encode the statsd update.

if we chose one of these, so we could call this protocol version "2" in our zeromq input (e.g. zmq message payload would be "2;").

@bradfitz
bradfitz / diskchecker.pl
Created July 24, 2012 21:05
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]
Capistrano::Configuration.instance.load do
namespace :deploy do
namespace :amee do
namespace :ss3 do
desc "[internal] Copies ss3.yml file to app servers"
task :upload, :except => { :no_release => true } do
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jboner
jboner / latency.txt
Last active May 13, 2025 17:54
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
Team,
Diablo 3 comes out tomorrow. Since 90% of you won't be able to concentrate anyways let's just meet tomorrow after lunch in the Lounge for an impromptu Lan party.
Need a refresher on why you need to play Diablo 3 ? http://www.youtube.com/watch?v=geuAc8F7Gt0&feature=g-hist
P.S: I call dips on jewelry drops.
- tobi
@dhh
dhh / gist:2643144
Created May 9, 2012 08:57
Coding stats from the new Basecamp
bcx david$ rake stats
+----------------------+-------+-------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+-------+-------+---------+---------+-----+-------+
| Controllers | 3704 | 2942 | 72 | 479 | 6 | 4 |
| Helpers | 1901 | 1529 | 13 | 261 | 20 | 3 |
| Models | 5310 | 4116 | 50 | 653 | 13 | 4 |
| Libraries | 2167 | 1593 | 51 | 200 | 3 | 5 |
| Integration tests | 297 | 217 | 6 | 1 | 0 | 215 |
| Functional tests | 3897 | 3065 | 61 | 11 | 0 | 276 |

The example runs, as long as you use the included prelude (it really only needs the first couple of lines):

$ ruby -rprelude alias.rb