Skip to content

Instantly share code, notes, and snippets.

View Intro_to_faker_gem.rb
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
View Faker_Loop.rb
require 'rubygems'
require 'faker'
require 'activerecord'
1000.times do
# make a person
# save this person
end
@alexmoore
alexmoore / about.md
Last active Sep 26, 2015 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
View about.md

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.

@alexmoore
alexmoore / latency.txt
Created May 31, 2012 — forked from jboner/latency.txt
Latency numbers every programmer should know
View latency.txt
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 / push.rb
Created Aug 31, 2012
[hg]|[git] push -m 'it real good'
View push.rb
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 / vnode_helper.rb
Last active Dec 16, 2015
Little helper class to figure out on which vnodes a particular hash resides.
View vnode_helper.rb
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
View public-access-bucket-policy.json
{
"Id": "Policy1371509616384",
"Statement": [
{
"Sid": "Stmt1371509665536",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::BUCKET_NAME/*",
View erl_helpers.sh
function list_erlangs() {
read -ra AvailableErls <<< `ls -l $ERL_HOME | awk '/^d/' | cut -d ' ' -f12-`
Current=`ls -l $ERL_HOME | awk '/^l/' | sed 's/^l.*-> \(.*\)/\1/'`
for i in "${AvailableErls[@]}"; do
if [ $i = $Current ]; then echo "$Current *"; else echo $i; fi
done
}
function change_current_erlang() {
Target=$1
View fizzbuzz.erl
-module(fizzbuzz).
-export([print_fizz_buzz/0,fizzbuzz/1]).
print_fizz_buzz() ->
Each = fun(I) ->
print_fizz_buzz(fizzbuzz(I)) end,
lists:foreach(Each, lists:seq(1,100)).
print_fizz_buzz(I) when is_integer(I) -> io:fwrite("~p~n", [I]);
print_fizz_buzz(I) -> io:fwrite("~s~n", [I]).
@alexmoore
alexmoore / .emacs
Created Sep 30, 2013
Add this to your .emacs file to autoload the tools for the current erlang with https://github.com/alexmoore/erls
View .emacs
;; setup erlang mode
(setq erlang-root-dir "/Users/alex/erlangs/current")
(setq erlang-lib-dir (concat erlang-root-dir "/lib/erlang/lib"))
(setq load-path
(cons (concat erlang-lib-dir
"/"
(car (directory-files erlang-lib-dir nil "^tools\-"))
"/emacs" )
load-path))