Skip to content

Instantly share code, notes, and snippets.

View BMorearty's full-sized avatar
🐮
moo

Brian Morearty BMorearty

🐮
moo
View GitHub Profile
@BMorearty
BMorearty / gist:809775
Created February 3, 2011 16:59
How to reset the timezone after handling a request.
around_filter :set_time_zone
def set_time_zone
old_time_zone = Time.zone
Time.zone = current_user.time_zone if logged_in?
yield
ensure
Time.zone = old_time_zone
end
@BMorearty
BMorearty / parse.py
Created January 29, 2012 22:14
Tries to parse XML file and print node names. Fails if it has null bytes.
from xml.dom.pulldom import START_ELEMENT, END_ELEMENT, parse
from xml.sax import SAXParseException
doc = parse("mal.xml")
for event, node in doc:
if event == START_ELEMENT:
print node.nodeName
@BMorearty
BMorearty / mal.xml
Created January 29, 2012 22:14
XML file with null bytes
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>Application Version</key>
<string>Put null chars here. In vim you can use ^Q^2.</string>
</dict>
</plist>
@BMorearty
BMorearty / gist:2983961
Created June 24, 2012 16:52 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p0
### UPDATE: ruby-debuy19 is no longer maintained, use https://github.com/cldwalker/debugger
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2983961)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p194 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
@BMorearty
BMorearty / Trying to install ree
Created February 4, 2013 22:05
Unable to install ree with rvm. It tells the compiler to look for includes and libs in /opt/local/include and /opt/local/lib, neither of which exists.
~$ rvm remove ree
/Users/brian/.rvm/src/ree-1.8.7-2012.02 has already been removed.
/Users/brian/.rvm/rubies/ree-1.8.7-2012.02 has already been removed.
Removing ree-1.8.7-2012.02 aliases...
Removing ree-1.8.7-2012.02 wrappers...
Removing ree-1.8.7-2012.02 environments...
Removing ree-1.8.7-2012.02 binaries...
~$ rvm install ree
Searching for binary rubies, this might take some time.
[2013-02-05 10:54:16] ./installer
Welcome to the Ruby Enterprise Edition installer
This installer will help you install Ruby Enterprise Edition 1.8.7-2012.02.
Don't worry, none of your system files will be touched if you don't want them
to, so there is no risk that things will screw up.
You can expect this from the installation process:
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
system.
@BMorearty
BMorearty / With openssl-dir param: install.log
Last active December 12, 2015 04:49
First log is from this command: rvm_rubygems_version=1.8.24 rvm install ree --without-tk --without-tcl -C "--with-openssl-dir=$HOME/.rvm/usr". Second log is from this command: rvm_rubygems_version=1.8.24 rvm install ree --without-tk --without-tcl
[2013-02-05 11:33:46] ./installer
Welcome to the Ruby Enterprise Edition installer
This installer will help you install Ruby Enterprise Edition 1.8.7-2012.02.
Don't worry, none of your system files will be touched if you don't want them
to, so there is no risk that things will screw up.
You can expect this from the installation process:
1. Ruby Enterprise Edition will be compiled and optimized for speed for this
system.
@BMorearty
BMorearty / gist:7242886
Created October 31, 2013 00:57
Error when running docker server
Loading containers: |panic: runtime error: index out of range
goroutine 1 [running]:
runtime.panic(0x8e42a0, 0x101ae17)
/usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/dotcloud/docker.(*Runtime).Children(0xc210099060, 0x0, 0x0, 0xc, 0x8, ...)
/go/src/github.com/dotcloud/docker/runtime.go:527 +0x168
github.com/dotcloud/docker.(*Container).Start(0xc210167700, 0xc2100968a0, 0x0, 0x0)
/go/src/github.com/dotcloud/docker/container.go:859 +0x1429
github.com/dotcloud/docker.(*Runtime).Register(0xc210099060, 0xc210167700, 0x40, 0xc21021ea00)
if ActiveRecord.method_defined? :pluck
raise "Upgraded to Rails 3.2, eh? It's time to remove the activerecord31_pluck.rb monkeypatch."
end
module ActiveRecord
class Base
class << self
delegate :pluck, :to =>:scoped
end
end
#!/usr/bin/env ruby
require 'async'
require 'kernel/sync'
require 'async/http'
require 'protocol/http'
endpoint = Async::HTTP::Endpoint.new(URI.parse('https://www.airbnb.com'))
client = Async::HTTP::Client.new(endpoint)
request = Protocol::HTTP::Request['GET', '/help/home', Protocol::HTTP::Headers[{}], nil]