Skip to content

Instantly share code, notes, and snippets.

View igrigorik's full-sized avatar
:octocat:

Ilya Grigorik igrigorik

:octocat:
View GitHub Profile
$_g := neo4j:open('neodb.neo')
$bob := g:add-v(g:map('name','Bob'))
$john := g:add-v(g:map('name','John'))
$alice := g:add-v(g:map('name','Alice'))
$e1 := g:add-e($bob,'link',$john)
$e2 := g:add-e($john,'link',$alice)
$e3 := g:add-e($alice,'link',$bob)
$e1/weight := 10
$e2/weight := 1
$e3/weight := 20
# example for multi-fiber workers
require "fiber"
require "eventmachine"
results = []
work = [:a, :b, :c]
EventMachine.run {
Fiber.new do
#!/bin/bash
# domainavailable
# Fast, domain name checker to use from the shell
# Use globs for real fun:
# domainavailable blah{1..3}.{com,net,org,co.uk}
# Inspired by foca / giles:
# http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html
trap 'exit 1' INT TERM EXIT
@igrigorik
igrigorik / stats.rb
Created March 25, 2010 04:37 — forked from tmm1/stats.rb
require 'socket'
require 'rubygems'
require 'collectd/pkt'
class Stats
def initialize name, instance, opts = {}
@name, @instance = name, instance
@sock = UDPSocket.new
@sock.connect opts[:host] || '239.192.74.66',
# 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
#
class FiberedMutex
#
# Creates a new FiberedMutex
#
def initialize
@waiting = []
@locked = false
end
#
This example shows how to setup an environment running Rails 3 beta under 1.9.2-head with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.2-head
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.2-head@rails3
# java -cp zookeeper-3.3.0.jar:log4j-1.2.15.jar:conf org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.cfg
### Basics: creating & deleting nodes
jruby-1.4.0 > require 'zookeeper'
jruby-1.4.0 > @zk = ZooKeeper.new(:host => "localhost:2181", :watcher => SilentWatcher.new)
=> #<ZooKeeper:0x175b28d8>
jruby-1.4.0 > @zk.exists("/test")
http://www.snailinaturtleneck.com/blog/2010/05/05/with-a-name-like-mongo-it-has-to-be-good/
"The highlight, for me, was Eliot Horowitz’s talk on sharding. He set up a MongoDB cluster of 25
large EC2 instances and started hammering them... 8,000,000 operations per second... The whole
audience burst into applause."
8M op/s, across 25 machines
~320,000 op/s for single node
0.000003125 s/op or 3.125 µs/op (microseconds/op)
http://www.postrank.com/
http://apidocs.postrank.com/
http://apidocs.postrank.com/Feed-API
http://www.postrank.com/feed/f5e2f6c0fb48c7ce2f9efd6bf62870c6
http://apidocs.postrank.com/Feed-API
http://feeds.postrank.com/f5e2f6c0fb48c7ce2f9efd6bf62870c6?level=1&q=ipad&format=json
https://analytics.postrank.com/tour
http://briancray.com/2010/01/04/popular-posts-social-media-engagement-postrank-top-posts-api/
http://labs.postrank.com/
http://labs.postrank.com/realtime/map