This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function knife-ips { | |
knife search node "name:$1" -aec2.public_ipv4 | grep 'ec2.public_ipv4' | awk '{print $2}' | |
} | |
# example: knife-ips "my-node-name-prefix*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
MAINTAINER Andrew Hodges "[email protected]" | |
ENV REFRESHED_AT 2013-09-04 | |
RUN sed 's/main$/main universe/' -i /etc/apt/sources.list | |
RUN apt-get update | |
RUN apt-get upgrade -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Macro do | |
# ... | |
def extract_expressions({ :__block__, _, exprs }), do: exprs | |
def extract_expressions(nil), do: [] | |
def extract_expressions(expr), do: [expr] | |
# ... | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule BitString.Example do | |
import BitString | |
defbitstring data_frame do | |
_ :: 1 | |
stream_id :: 31 | |
flags :: 8 | |
length :: 24 | |
_ :: 1 | |
_ :: 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiber' # for Fiber#alive? | |
module Enumerable | |
DEFAULT_MAX_FIBERS = 20 | |
def each_in_fibers(max_fibers = nil, &block) | |
# If the enumerable object can tell us how big it is, cool. | |
# Unlike #each_in_threads, it doesn't really matter here. | |
# BUT I'M GOING TO DO THIS ANYWAY! BWAHAHAHAA! | |
if respond_to? :size |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
lsof | grep facebook | awk -F'>' '{print $2}' | sort | uniq -c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE VIEW table_stats AS ( | |
SELECT t.relname AS table, | |
n_live_tup AS approx_rows, | |
heap_blks_read + heap_blks_hit AS reads, | |
round(100 * heap_blks_hit::numeric / (heap_blks_hit + heap_blks_read + 0.0001), 3) AS cache_hit_rate, | |
round(100 * idx_blks_hit::numeric / ( idx_blks_hit + idx_blks_read + 0.0001), 3) AS idx_cache_hit_rate, | |
round(100 * idx_scan::numeric / ( seq_scan + idx_scan + 0.0001), 3) AS idx_usage_pct | |
FROM pg_statio_user_tables AS t | |
FULL OUTER | |
JOIN pg_stat_user_tables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WithArchive | |
def with_archive | |
columns = column_names | |
archive_class = const_get(:Archive) | |
archive_columns = columns.map { |c| c == 'state' ? "'disabled' AS state" : c } | |
from <<-sql | |
(#{unscoped.select(columns.join(', ')).to_sql} | |
UNION | |
#{archive_class.unscoped.select(archive_columns.join(', ')).to_sql} | |
) as #{table_name} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(trie). | |
%% Compile Options | |
-compile({no_auto_import, [get/2, put/2]}). | |
%% API | |
-export([get/2, | |
new/0, | |
put/2, | |
put/3]). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expand(Bin) -> | |
expand_1(Bin, [<<>>], []). | |
append(C, Prefixes) -> | |
lists:map(fun (Prefix) -> | |
<<Prefix/binary, C>> | |
end, Prefixes). | |
expand_1(Bin, Prefixes, Acc) -> | |
expand_1(Bin, Prefixes, Prefixes, Acc). |