Skip to content

Instantly share code, notes, and snippets.

View raggi's full-sized avatar

James Tucker raggi

View GitHub Profile
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (Darwin)
mQINBFEkHmoBEACqeBffB0ytt4m3qvZi3+PLDeh8aQ8irYJl4BXm+A5Gih0ApTE1
+ahMCFuqSfN0MJDvFxcFYPHto4GTQZqG8h+J0AVnh/8zoJnVrvi6k/il1gs0oZSz
lJ9xJb5Wu9sL0ohST51DcOW/JnVEEsz5EamnzNwxFsIHLFmqmZ9gRFeeauKWMpQl
GUlFggMuuGb+LUDEsI3XMv4ISce1F3vugNLXrhanpjKH/qmqTgDQlxIazvxzI87b
VArV9Ol5MSc7o+xvFPR6vozLlGM4I9rUj/kfwVQX6A4ga6TE9D9qdArqRtDPARQN
0vkApbbpQilQy0ydw50O+M6MtKaxqe65h7y2cxr5enmaZNdqxRByv+qf7ilKXcmr
daCoTVPvWi9H/o2Ufxia6GrC4E5qaEL35WWADYV+LNH2P33izu6Vnw0CCfNsFBlw
switch (count % 8)
{
case 0:;
<D3492>:;
*to++ = *from++ ;
case 7:;
*to++ = *from++ ;
case 6:;
*to++ = *from++ ;
case 5:;
$sure = false
t = Thread.new {
begin
# nada
ensure
sleep
$sure = true
# cleanup all the things
end
@raggi
raggi / .gitignore
Last active March 30, 2017 05:50
Example plain text gem indexer
specs.4.8
prerelease_specs.4.8
versions.list
names.list
specs
deps
gems
@raggi
raggi / bm_dci_pounding.rb
Last active September 22, 2016 23:19
Show the effects of method cache damage from runtime extend, as it relates to extend vs. delegate for DCI.
require 'benchmark'
number_of_rails_methods = 300
@rails = Class.new do
number_of_rails_methods.times do |i|
class_eval <<-RUBY
def call#{"%02d" % i} # def call01
end # end
RUBY
@raggi
raggi / validate_local_cache.sh
Last active December 11, 2015 23:39
A script to validate your local gem cache against the public s3 repositories. If you find mismatches that contain both local and remote values, please post them in comments.
#!/usr/bin/env sh
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
class Safeware
def initialize(app)
@app = app
end
# This dup pattern is used frequently to avoid race conditions on state stored
# inside this middleware. It's not foolproof, but if you're just using
# single-reference instance variables (instance variables with primitive
# values (not data structures)) then it works well.
@raggi
raggi / v.zsh
Created May 29, 2012 17:04
Vim server per-directory
#!/usr/bin/env zsh
which -s vim > /dev/null && VIM=vim
which -s gvim > /dev/null && VIM=gvim
which -s mvim > /dev/null && VIM=mvim
[[ -e /Applications/MacVim.app/Contents/MacOS/Vim ]] && VIM="/Applications/MacVim.app/Contents/MacOS/Vim"
[[ -z "${VIM}" ]] && echo "No vim found" && exit 1
# Console vim just gets a straight pass through, as there's no quick way to
#!/bin/bash
ramfs_size_mb=1024
mount_point=~/volatile
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`
newfs_hfs -v 'Volatile' ${ramdisk_dev}
mkdir -p ${mount_point}
mount -o noatime -t hfs ${ramdisk_dev} ${mount_point}
echo "remove with:"
@raggi
raggi / zmq_push
Created May 18, 2012 17:22
ZeroMQ push in ZSH
#!/usr/bin/env zsh
set -e
autoload -U tcp_open
tcp_open $1 $2 zmq
msg=$(cat -)
tcp_send -s zmq $(print -nf '\x01\x00\x%02x\x00%s' $((1 + ${#msg})) "$msg")
tcp_close zmq