Skip to content

Instantly share code, notes, and snippets.

{
"Id": "Policy1371509616384",
"Statement": [
{
"Sid": "Stmt1371509665536",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::BUCKET_NAME/*",
@alexmoore
alexmoore / vnode_helper.rb
Last active December 16, 2015 21:59
Little helper class to figure out on which vnodes a particular hash resides.
class VNodeHelper
attr_reader :ring_size, :n_val
def initialize(ring_size, n_val)
@ring_size = ring_size
@n_val = n_val
@vnode_size = (2 ** 160 / @ring_size)
end
package Blah;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class SelectManyIterable<TSource, TResult> implements Iterable<TResult>
{
public interface TransformProvider<TSource, TResult>
{
@alexmoore
alexmoore / push.rb
Created August 31, 2012 21:46
[hg]|[git] push -m 'it real good'
require 'Win32API'
Beep = Win32API.new('kernel32', 'Beep', ['I', 'I'], 'I')
def Rest(ms)
sleep(ms / 1000.0)
end
c = 1046
d = 1175
e = 1319
@alexmoore
alexmoore / latency.txt
Created May 31, 2012 18:26 — forked from jboner/latency.txt
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
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@alexmoore
alexmoore / about.md
Last active September 26, 2015 19:27 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer

Programming Achievements: How to Level Up as a Developer

  1. Select a particular experience to pursue.
  2. Pursue that experience to completion. (Achievement unlocked!)
  3. Reflect on that experience. Really soak it in. Maybe a blog post would be in order?
  4. Return to Step 1, this time selecting a new experience.

This gist is a fork of the gist from this blog post.

require 'rubygems'
require 'faker'
#Let's see if we can make a fake person...
person_name = Faker::Name.name
person_email = Faker::Internet.email
person_company = Faker::Company.name
person_company_slogan = Faker::Company.bs
person_phone = Faker::PhoneNumber.phone_number
person_address = Faker::Address.street_address
require 'rubygems'
require 'faker'
require 'activerecord'
1000.times do
# make a person
# save this person
end
@alexmoore
alexmoore / large.sh
Created September 25, 2014 19:05
Find large Objects
#!/bin/bash
# For each node, search for reading large object messages, write to largeobject.read file
for NODE in 10.58.9*; do
IP=`echo "$NODE" | cut -d '-' -f1`;
cat $NODE/lo.r.console.log | sed "s/.*Reading large object of size \([0-9]*\) from \(<<.*>>\)\/\(<<.*>>\)/\{\"$IP\",\2,\3,\1\},/" | sort | uniq > $NODE/lo.r.list ;
done
# For each node, search for writing large object messages, write to largeobject.write file
for NODE in 10.58.9*;
FindPrimaries = fun(Bucket, Key, Ring) ->
BKey = {Bucket,Key},
DocIdx = riak_core_util:chash_key(BKey),
BucketProps = riak_core_bucket:get_bucket(Bucket, Ring),
[NValue] = [Y || {X1, Y} <- BucketProps, n_val == X1],
CHBin = chashbin:create(riak_core_ring:chash(Ring)),
Itr = chashbin:iterator(DocIdx, CHBin),
{Primaries, Itr2} = chashbin:itr_pop(3, Itr),
Primaries
end.