Skip to content

Instantly share code, notes, and snippets.

> ./wer.py "stats - transcript.txt" "stats - google.txt"
wer distance: 442
accuracy: 70.75%
@codekitchen
codekitchen / gist:f1a28015672d2dcfe3ee1980cf6e7ef2
Last active September 14, 2016 16:32
shell session: using SNI with dinghy-http-proxy
codekitchen:~
> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
967b5f9d819e codekitchen/dinghy-http-proxy:2.5.0 "/app/docker-entrypoi" 24 hours ago Up 24 hours 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:19322->19322/udp dinghy_http_proxy
codekitchen:~
> cd ~/.dinghy/certs/
codekitchen:~/.dinghy/certs
> openssl req -x509 -newkey rsa:2048 -keyout cdn.antenna.docker.key -out cdn.antenna.docker.crt -days 365 -nodes -subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=cdn.antenna.docker"
Generating a 2048 bit RSA private key
......................+++
rule '.json' => '.yml' do |t|
doc = YAML.load_file(t.source)
doc = cfn_strings(doc)
File.open(t.name, 'wb') { |f| f.write(JSON.pretty_generate(doc)) }
end
# finds any %{Ref: Thing} or %{Fn::Name: [Args]} inside strings,
# and turns the string into a Fn::Join with those objects interpolated
def cfn_strings(object)
case object
require 'json'
module HashWithDupCheck
refine Hash do
def []=(k,v)
raise(ArgumentError, "key already exists: #{k.inspect}") if key?(k)
end
end
end
@codekitchen
codekitchen / crashy.rb
Last active August 29, 2015 14:26
nokogiri + libxml memory corruption
# This segfault was tested on Ubuntu Precise, With Ruby 2.1.6 and 2.2.2.
# It does _not_ crash on OS X Yosemite.
gem 'nokogiri', '1.6.6.2'
gem 'libxml-ruby', '2.8.0'
require 'nokogiri'
require 'libxml' # comment out this line, and no crash
message = "<h2>BOOM!</h2>"
truncated_pwd () {
local pwdmaxlen=45
local trunc_symbol="…"
local dir=${PWD##*/}
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen ))
NEW_PWD=${PWD/#$HOME/\~}
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen ))
if [ ${pwdoffset} -gt "0" ]
then
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen}
__aws_creds_prompt ()
{
if [ -n "$AWS_CREDS_NAME" ]; then
echo "${EMR}[AWS ${AWS_CREDS_NAME}]${NONE}"
fi
}
[ pid=24674, timestamp=1433829718 ] Process aborted! signo=SIGSEGV(11), reason=SI_KERNEL, si_addr=0x0, randomSeed=1433829677
[ pid=24674 ] Crash log dumped to /var/tmp/passenger-crash-log.1433829718
[ pid=24674 ] Date, uname and ulimits:
Tue Jun 9 06:01:58 UTC 2015
Linux 3.2.0-75-virtual #110-Ubuntu SMP Tue Dec 16 19:24:01 UTC 2014 x86_64 x86_64
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 8192
coredump(blocks) 0

Keybase proof

I hereby claim:

  • I am codekitchen on github.
  • I am codekitchen (https://keybase.io/codekitchen) on keybase.
  • I have a public key whose fingerprint is 43A4 2E14 33CA 797D 45CF 2A63 62DE 8403 00EA 4F5F

To claim this, I am signing this object:

@codekitchen
codekitchen / common.yml
Created March 13, 2015 00:20
example of what docker-compose + cloudgate might look like
db:
image: postgres:9.3
expose:
- "5432"
redis:
image: redis:2.8
expose:
- "6379"