Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby --disable-gems
# Roll your own two-factor authentication! Place this file on a USB key, make
# it executable, then run:
#
# two-factor --setup
#
# Now place each TOTP secret in its own file in the `keys/` directory. I like
# to name them after the website they apply to, but any name is fine. To
# generate a token, plug in your USB key and:
@xaviershay
xaviershay / mobility.md
Last active December 28, 2015 15:29
Mobility routine, 17th November 2013

Time: 25-30 minutes.

Goal: Better back, front, and overhead squats. Very basic gymnastic conditioning.

"Limber 11" ([video][limber-11])

  • Foam roll ITB, 10 passes
  • Foam roll aductors, 10 passes
  • Ball glutes, 30-60s each
  • Bent leg cross, 5 each side
@xaviershay
xaviershay / bm_sorted_set.rb
Last active December 28, 2015 15:09
Benchmark showing sorted set being slower when rbtree is used. https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L575
require 'set'
require 'benchmark'
begin
require 'rbtree'
puts "using rbtree"
# https://github.com/ruby/ruby/blob/trunk/lib/set.rb#L575
rescue LoadError
puts "NOT using rbtree"
end
@xaviershay
xaviershay / ruby_live_gc_stats.rb
Created November 10, 2013 21:17
naive jstat proof-of-concept for ruby
Thread.new do
GC::Profiler.enable
current_message = ""
epoch = Time.now
total_time = 0
gc_events = 0
heap_use = 0
heap_size = 0
fmt = "%7s %5s %15s %15s %10s"
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
@xaviershay
xaviershay / overall_summary.rb
Last active December 23, 2015 16:59
Shows a summary checklist of a pluralsight screencast source.
#!/usr/bin/env ruby
require 'colorize'
def pair(label, value)
puts "%-15s%s" % [label, value ? "✓".green : "✗".red]
end
Dir['database-your-friend-m*'].each do |f|
puts f
@xaviershay
xaviershay / vimtype.rb
Created September 22, 2013 02:44
Creates a mapping that will type out the given text into vim.
# Usage:
#
# ruby vimtype.rb | pbcopy
# type text
# ^D
#
# That outputs a map command bound to <leader>x, in vim type : then paste in
# the command, :set paste, then hit <leader>x
string = ARGF.read
package com.atlassian.stash.plugin.webook;
import com.atlassian.stash.event.pull.PullRequestRescopedEvent;
import com.atlassian.stash.hook.repository.AsyncPostReceiveRepositoryHook;
import com.atlassian.stash.hook.repository.RepositoryHookContext;
import com.atlassian.stash.nav.NavBuilder;
import com.atlassian.stash.pull.PullRequestRef;
import com.atlassian.stash.repository.RefChange;
import com.atlassian.stash.repository.RefChangeType;
import com.atlassian.stash.repository.Repository;
@xaviershay
xaviershay / repro-2165.sh
Last active March 19, 2019 13:18
Sample repro script for bundler.
#!/bin/bash
set -ex
ISSUE=2165
ROOT_DIR=/tmp/repro-$ISSUE
REPO_DIR=$ROOT_DIR/repo
PROJECT_DIR=$ROOT_DIR/project
mkdir -p $ROOT_DIR
@xaviershay
xaviershay / repro-1489.sh
Last active July 25, 2020 22:27
Sample repro script for bundler issues
#!/bin/bash
set -ex
mkdir -p /tmp/repro-1489
cd /tmp/repro-1489
bundle env
# Bundler 1.3.5
# Ruby 2.0.0 (2013-06-27 patchlevel 247) [x86_64-darwin12.4.0]