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
View safe_bundle_standalone.sh
#!/bin/bash
set -ex
bundle install --standalone
digest=$(md5 -q Gemfile)
cmd="raise \"Gemfile changed\" if %x[md5 -q Gemfile].chomp != \"${digest}\""
echo $cmd > bundle/bundler/setup.rb.new
cat bundle/bundler/setup.rb >> bundle/bundler/setup.rb.new
@xaviershay
xaviershay / check-for-fixes.rb
Last active Aug 29, 2015
Finds all github issue URLs in project comments and exits non-zero if any of them are no longer open.
View check-for-fixes.rb
#!/usr/bin/env ruby
require 'tmpdir'
require 'net/http'
require 'openssl'
require 'uri'
require 'json'
require 'date'
def file_cache(key)
View fracking.md

This weekend I spent many hours learning about hydraulic fracturing, commonly known as "fracking". I watched Gasland, Fracknation, and read pages and pages of articles, reports, and regulations.

There is a lot of FUD on both sides, but it seems clear there is a realistic probability that gas extraction has negative health impacts in a non-trivial number of communities. This probability, especially given the bad track record of the oil and gas industry, should be sufficient to justify more caution than is currently being applied.

I don't trust the US EPA. I am sure they have good individual people, but as an organisation they appear crippled by budget cuts and political pressure. The US government made an explicit bipartisan decision with the 2005 Energy Policy Act to reduce regulatory oversight on fracking, enabling companies to move faster with possibly dangerous technology. This is inexcusable. Gas prices in the US are less than half most of the world. Slow down.

Many farmers want drilling on their land

@xaviershay
xaviershay / props.md
Last active Aug 29, 2015
Californa General Election Proposition Voting Guide
View props.md

Californa General Election Proposition Voting Guide

I can't even vote here, but this is where I live so I have opinions. I'm no expert on any of these issues, so am open to persuasion.

Prop 2: State Budget Stabilization Account

I don't even know what's going on here. It appears both sides of legislature are trying to dig themselves out of a pretty major budgetary defecit by setting requirements for paying down debts. They claim this is good for schools. Educate Our State feels they are crooks and not only would this be bad for schools, but schools have been getting the bad end of the budget for decades. Both sides are shouting at each other and I can't find the signal.

It is unanimously supported by democrat and republican candidates, so I'm slightly on a Yes vote. Could be a mistake: so was the 2005 Energy Policy Act.

View the-glass-cage.md

Cross-posted at Goodreads

"The Glass Cage" Review

What if the cost of machines that think is people who don’t?

Nicholas Carr's The Glass Cage is an important counterpoint to the dominant automation-at-all-costs mindset of Silicon Valley. That more automation is better is not as obvious a conclusion as many of us would like to believe. Carr is definitely not anti-technology though. This book is level-headed in discussing the positive and negative trends in automation, backed by a large amount of research. From pilots to doctors to inuit hunters, Carr present a comprehensive overview of automation across society today.

Three themes in particular stuck in my mind.

View gist:985315a776e07c6fa4e6
$ cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)
$ rpm -qf /usr/bin/ruby
ruby-2.0.0.353-22.el7_0.x86_64
$ rpm -qf /usr/share/ruby/csv.rb
ruby-libs-2.0.0.353-22.el7_0.x86_64
$ for x in $(ruby -e 'puts $LOAD_PATH'); do ls $x | grep -q json && echo $x; done
ls: cannot access /usr/local/share/ruby/site_ruby: No such file or directory
ls: cannot access /usr/local/lib64/ruby/site_ruby: No such file or directory
$ for x in $(ruby -rjson -e 'puts $LOAD_PATH'); do ls $x | grep -q json && echo $x; done
View gist:a76a1bca03c212ff1c69
module ValueObject
def self.included(klass)
klass.extend(ClassMethods)
klass.attributes # Force instantiation
end
def initialize(data)
data.each do |key, value|
instance_variable_set("@#{key}", value)
end
View gist:26071
benburkert_: xaviershay: nice job on the unique stuff in dm-sweatshop :D
[12:42pm] benburkert_: do you have commit rights to dm-more?
[12:42pm] xaviershay: for the future, I also have a patch here for extlib: http://github.com/xaviershay/extlib/tree/master
[12:43pm] xaviershay: benburkert_: cheers :), no commit rights
[12:43pm] benburkert_: k, i'll bug sam about it next time i see him online
View gist:26076
require 'benchmark'
n = 100000
Benchmark.bmbm do |x|
x.report('tr') { n.times { "created-at".tr( '-', '_') }}
x.report('gsub') { n.times { "created-at".gsub('-', '_') }}
end
<<-EOS
View gist:26082
~/Code/dm-more-sam/dm-constraints (master)$ rake
(in /Users/xavier/Code/dm-more-sam/dm-constraints)
Loaded suite .
Started
Finished in 0.000155 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
Could not load do_postgres: Could not find RubyGem do_postgres (~> 0.9.7)
You can’t perform that action at this time.