Skip to content

Instantly share code, notes, and snippets.

Xavier Shay xaviershay

Block or report user

Report or block xaviershay

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xaviershay
xaviershay / migration_sql.rb
Created Aug 14, 2015
Get SQL output from a Rails migration
View migration_sql.rb
#!/usr/bin/env ruby
require_relative 'config/environment'
path = ARGV.shift || raise("specify migration as first argument")
require_relative path
filename = File.basename(path, ".rb")
timestamp, name = filename.split("_", 2)
View gist:865e3cd84c5defe9ed65dd16de2ece80
rrffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaffaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaafaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
View gist:005ca2ba734ab2bc4cded90e3680441f
symbols = %w(1L 1 1R 1L1 1R1 b bL bR bL1 bR1 b2 b3 c cL cR cL1 cR1 c2)
tape = %w(1R 1R cL1)
cursor = 0
L = -1
R = +1
state = 1
@xaviershay
xaviershay / repro-2165.sh
Last active Mar 19, 2019
Sample repro script for bundler.
View repro-2165.sh
#!/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 / http_client_spec.rb
Created Dec 13, 2011
Running a rack app in a thread for integration tests.
View http_client_spec.rb
require 'integration_helper'
require 'rack'
require 'rack/handler/webrick'
describe HttpClient do
before :all do
@server = WEBrick::HTTPServer.new(
:Port => 9293,
:Logger => Rails.logger,
:AccessLog => Rails.logger
@xaviershay
xaviershay / rewrite.rb
Created Jan 10, 2013
Proof-of-concept squid proxy settings for proxying http://rubygems.org/ Tested on one project on my local machine both cold, and warm with internet turned off.
View rewrite.rb
#!/usr/bin/env ruby
# url rewriter for rubygems squid proxy
STDOUT.sync = true
while line = gets
url = line.split(' ')[0]
# Cargo-culted this conditional, not sure if it is necessary
response = if url
@xaviershay
xaviershay / LdapAuthenticator.java
Created Jul 24, 2012
LDAP Authentication for dropwizard
View LdapAuthenticator.java
package com.squareup.alcatraz.auth;
import com.google.common.base.Optional;
import com.unboundid.ldap.sdk.Filter;
import com.unboundid.ldap.sdk.LDAPConnection;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.ResultCode;
import com.unboundid.ldap.sdk.SearchRequest;
import com.unboundid.ldap.sdk.SearchResult;
import com.unboundid.ldap.sdk.SearchResultEntry;
@xaviershay
xaviershay / vegan-month.md
Created Nov 19, 2011
Vegan Month Curriculum
View vegan-month.md

Vegan Month Logo

Back in Melbourne circa 2010/11, Jodie, Jared and I used to run a [monthly vegan mentoring group][vegan-month]. I have gone back through the mailing lists and collected much of the curriculum and information from the program into this single document, so that I can distribute it more widely. The program was designed not just to get you through the first month nutritionally, but to expose you to a variety of foods and ideas that may be new to you. It emphasises that veganism is a shift sideways, not a sacrifice.

@xaviershay
xaviershay / github_requests.md
Last active Apr 11, 2018
Pull request feature requests
View github_requests.md

Hello Github,

Pull requests are not serving me well on large reviews. Here are some problems and suggested enhancements that would make me happy.

  • Mark comment as "resolved" (see google docs for an example). As code changes, comments get lost or made redundant, and it is not clear (to either the author or reviewers) which are still relevant and which have been addressed. Resolving a comment doesn't need to make it dissappear, but I need to be able to see "which comments have not been addressed" somehow. This feature would be the most useful to me.
  • Reply to a comment. This can be done in effect on line comments (assuming there is only one), but cannot on PR comments. Particularly with many threads, the lack of this makes a review hard to follow.
  • Explicit "approve/block" life cycle. The block is actually more important to me ... often on a PR that has been incrementally improved I want to "block" final merge of it until I get a chance to rebase/squash and generally pretty it up. The block can be over
View Me and vegetarianism
(Pre 2008 dates are pretty rough I can't really remember)
Aug 2005: Try going vegetarian, lasts a week. Mostly cooked the same stuff sans-meat. FAIL.
Nov 2005: Go to a lecture by Peter Singer, cannot disagree, so become vegetarian. I knew one other vegetarian at this point.
Sep 2006: Go vegan for 30 days. Tried replacing yoghurt with soyghurt BAD MOVE. Did not know vegan desserts existed. Reverted after 30 days, but ate "more vegan".
Apr 2008: Go vegan for a 6-day hike, didn't feel like eating animal products after. Haven't since.
Jan 2008: Cut out bread and cereal for 30 days ("raw-ish until dinner"). Reverted - expensive and you need to be on the ball with shopping habits - though eat a *lot* more fruit now.
Lessons Learned:
- Slow progression, gradually incorporate new recipes
You can’t perform that action at this time.