Skip to content

Instantly share code, notes, and snippets.

View seth's full-sized avatar

Seth Falcon seth

View GitHub Profile
log_level :info
log_location STDOUT
node_name 'admin'
client_key
'/home/vagrant/work/.chef/admin.pem'
validation_client_name 'chef-validator'
validation_key '/etc/chef-server/chef-validator.pem'
chef_server_url 'https://chef-server:443'
syntax_check_cache_path '/home/vagrant/work/.chef/syntax_check_cache'
-module(fake_gen).
-export([
pop/1,
push/2,
start/0,
start2/0,
server_loop2/1
]).
@seth
seth / draw.R
Created March 6, 2013 06:25
Notes on comparing effectiveness of random list element selection as found in Erlang's pg2 vs using random:uniform. Also comparing effect under concurrent access of erlang:now() vs os:timestamp().
library("lattice")
z <- read.table("all.txt", colClasses=rep("integer", 4))
names(z) <- c("pg_rand", "pg_rand_os", "u_rand", "u_rand_os")
all <- stack(z)
names(all) <- c("item", "func")
tapply(all$item, all$func, table)
histogram(~item|func, data=all, type="count", breaks=0:50)
@seth
seth / Makefile
Created November 6, 2012 17:24
Template Makefile for Erlang projects
DEPS = $(CURDIR)/deps
DIALYZER_OPTS = -Wunderspecs
# List dependencies that should be included in a cached dialyzer PLT file.
# DIALYZER_DEPS = deps/app1/ebin \
# deps/app2/ebin
DEPS_PLT = {{name}}.plt
@seth
seth / output.txt
Created September 6, 2012 19:48
Example sending empty binary over a TCP socket
Let's actually see what's going on. Change client to send via this "tunnel":
socat -v TCP4-LISTEN:9898,fork TCP4:localhost:5678
> 2012/09/06 14:05:24.413264 length=5 from=0 to=4
hello
This confirms that sending <<>> is, eventually, a nop in the sense of no data sent over the wire. But it takes a number of function calls to not send anything.
;; this seems to work as well and is more general. It was slow on
;; first load, then pretty snappy. Worked for mail and chrome
(require 'org-mac-link-grabber)
(add-hook 'org-mode-hook
(lambda ()
(define-key org-mode-map (kbd "C-c g") 'omlg-grab-link)))
Hi.
class Chef::EncryptedDataBagItem
def [](key)
value = @enc_hash[key]
if key == "id" || value.nil?
value
else
self.class.decrypt_value(value, @secret)
end
end
end
# Borrowed heavily from http://github.com/atmos/cinderella
username = node[:login_name] || node[:current_user]
user_uid = node[:etc][:passwd][username]["uid"]
user_gid = node[:login_group]
DEFAULT_RUBY_VERSION = "1.8.7-p302"
rvm_init = 'source "$HOME/.rvm/scripts/rvm"'
@seth
seth / special_char_test.erl
Created March 17, 2011 05:28
Example of multi-generator list comprehension to generate a matrix of test cases
term_special_chars_test_() ->
SpecialChars = ["!", "(", ")", "{", "}", "[", "]",
"^", "\"", "~", "*", "?", ":", "\\"],
Formats = ["foo~sbar", "~sb", "a~s", "a~sb"],
Terms = [ ?i2b(io_lib:format(F, ["\\" ++ C])) ||
F <- Formats, C <- SpecialChars ],
[ ?_assertEqual(T, hd(lucene:parse(T))) || T <- Terms ].