Skip to content

Instantly share code, notes, and snippets.

View notahat's full-sized avatar

Pete Yandell notahat

View GitHub Profile
# Here's everything I have in my .zshrc to set up my PATH for homebrew and asdf:
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
eval "$(/opt/homebrew/bin/brew shellenv)"
source $HOMEBREW_PREFIX/opt/asdf/libexec/asdf.sh
# The resulting $PATH looks like this:
#

Keybase proof

I hereby claim:

  • I am notahat on github.
  • I am notahat (https://keybase.io/notahat) on keybase.
  • I have a public key ASBqO0GTuXC19c1Vf9IeExNNmrbDfTmw47SxvTu6G-P3BAo

To claim this, I am signing this object:

$ ping 111.118.175.56
PING 111.118.175.56 (111.118.175.56): 56 data bytes
64 bytes from 111.118.175.56: icmp_seq=0 ttl=55 time=15.581 ms
64 bytes from 111.118.175.56: icmp_seq=1 ttl=55 time=17.552 ms
64 bytes from 111.118.175.56: icmp_seq=2 ttl=55 time=17.283 ms
^C
--- 111.118.175.56 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 15.581/16.805/17.552/0.873 ms
@notahat
notahat / gist:c72cee07f9a74e61a2d0
Last active August 29, 2015 14:11
Private classes in Ruby, version 2
module PrivateClass
def self.included(mod)
*parent, child = mod.name.split("::")
Object.const_get(parent.join("::")).private_constant(child)
end
end
module Container
class PublicThing
def hello

Keybase proof

I hereby claim:

  • I am notahat on github.
  • I am notahat (https://keybase.io/notahat) on keybase.
  • I have a public key whose fingerprint is A466 A52F 204A DE5E 9F85 8F1B C009 0778 6D7E E91A

To claim this, I am signing this object:

@notahat
notahat / gist:c84e1784893d31f4e594
Created December 15, 2014 06:01
Private classes in Ruby
module Container
class PublicThing
def hello
PrivateThing.new.hello
end
end
class PrivateThing
def hello
"Hello, world!"
# On a new ubuntu 14.04 box, as root, with the following variables
# export BUILDBOX_AGENT_NAME="buildbox-agent-N"
# export BUILDBOX_AGENT_ACCESS_TOKEN="<your token here>"
# export BUILDBOX_AGENT_SSH_PRIVATE_KEY="<an ssh private key>"
# export BUILDBOX_AGENT_SSH_PUBLIC_KEY="<an ssh public key>"
# Make tmp totally in memory
echo "none /tmp tmpfs size=4g 0 0" >> /etc/fstab
mount /tmp
class PagingEnumerator < Enumerator
def initialize(&block)
super do |yielder|
page = 0
loop do
items = block.call(page)
break if items.empty?
items.each {|item| yielder.yield(item) }
page += 1
@notahat
notahat / valid.rb
Created October 11, 2012 02:50
Testing fail?
# I have a class that delegates functionality to a couple of objects that it
# constructs. I want to test this in isolation. I want to make sure that the
# objects are constructed with the right arguments. I also want to make sure
# that the results from the objects are handled correctly.
#
# I'm finding it hard to structure the code and test in a way that isn't
# cumbersome. What's below works, but it feels like a lot of stubbing and setup
# for something the should be simpler.
#
# Anyone got a better approach for this?
class Dependency
def self.foo
puts "Foo"
end
def self.bar
puts "Bar"
end
end