Skip to content

Instantly share code, notes, and snippets.

@xaviershay
xaviershay / gist:a76a1bca03c212ff1c69
Created August 2, 2015 14:05
fast_value_object.rb
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
@xaviershay
xaviershay / standalone_rom_sql.rb
Created July 20, 2015 02:00
Standalone script to play around with ROM. http://rom-rb.org/
# Standalone script to try http://rom-rb.org/ with a database
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rom'
gem 'rom-sql'
gem 'rom-rails'
gem 'activemodel'
$ 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
@xaviershay
xaviershay / the-glass-cage.md
Last active August 29, 2015 14:07
The Glass Cage

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.

@xaviershay
xaviershay / props.md
Last active August 29, 2015 14:07
Californa General Election Proposition Voting Guide

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.

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 / check-for-fixes.rb
Last active August 29, 2015 14:03
Finds all github issue URLs in project comments and exits non-zero if any of them are no longer open.
#!/usr/bin/env ruby
require 'tmpdir'
require 'net/http'
require 'openssl'
require 'uri'
require 'json'
require 'date'
def file_cache(key)
#!/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 / github_requests.md
Last active April 11, 2018 03:20
Pull request feature requests

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

2013 Reading List

I read sixty-six books this year, one more than last. You can find the full list over at Good Reads, but here are my top picks.

Philosophy

A Manual For Creating Atheists by Peter Boghossian

The best book on teaching critical thinking I have read. Includes "intervention dialogues" transcripts, plenty of research, genuine compassion and empathy for other people, plus a wealth of experience in the author, who has been teaching philosophy and talking about faith for decades.