Skip to content

Instantly share code, notes, and snippets.

View eric-wood's full-sized avatar
🥑
probably snacking

Eric Wood eric-wood

🥑
probably snacking
View GitHub Profile
class Shoutout
%w(yo yoyo yoyoma).each do |action|
define_method("perform_#{action}") do |argument|
"performing #{action.gsub('_', ' ')}"
end
end
end
shout = Shoutout.new
puts shout.yo()
@eric-wood
eric-wood / hash_with_indifferent_access.rb
Created March 24, 2015 18:36
HashWithIndifferentAccess
class HashWithIndifferentAccess < Hash
def [](_)
'meh'
end
end
@alphabet = [" ","a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
"m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
def encrypt(message)
key_length = message.length
message.downcase.split("").map! { |x|
idx_number = @alphabet.index(x)
finish = idx_number.to_i + key_length.to_i
unless finish < 27
@eric-wood
eric-wood / main.rb
Last active August 29, 2015 14:14
Midi threading puzzle...
# NOTE:
# the following code works GREAT, since UniMIDI::Input#gets blocks (just like stdin's gets)
input = UniMIDI::Input.use(:first)
Thread.new do
loop { p input.gets }
end
# ...but the following code only returns once and no subsequent notes are printed...
# test of Sequencer::Reader
@eric-wood
eric-wood / crappy_sequencer.rb
Created December 20, 2014 23:20
Read the first 5 MIDI notes presented, play 'em back
require 'unimidi'
input = UniMIDI::Input.use(:first)
output = UniMIDI::Output.use(:first)
puts "-" * 100
puts "Start playing some notes plz"
puts "-" * 100
data = []
@eric-wood
eric-wood / timing.rb
Last active August 29, 2015 14:11
timing
timer = Thread.new do
Thread.current[:delay] = 1
loop do
sleep(Thread.current[:delay])
puts "boom! #{Thread.current[:delay]}"
end
end
sleep(3)
timer[:delay] = 2
@eric-wood
eric-wood / .zshrc
Created October 6, 2014 22:36
zsh errors
. /Users/ericw/git/dotfiles/shell_shenanigans.sh
source /Users/ericw/git/dotfiles/.zshrc
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
#eval "$(rbenv init -)"
source '/usr/local/share/chruby/chruby.sh'
source '/usr/local/share/chruby/auto.sh'
@eric-wood
eric-wood / gist:25b4cd87e8645feed84e
Created October 3, 2014 18:36
tilde.club welcome email
Hello. You now have a user account on the http://tilde.club world wide web server. This is the dumbest thing I have ever done. Welcome!
An email with your password and username should have arrived by now. It is INCREDIBLY INCREDIBLY LIKELY that it went into your spam folder. It will have come from root@tilde.club. If it didn't arrive you can send me an email and tell me so. I don't mind. Give it a couple hours.
Who am I? I am the system administrator, Paul Ford. Like any system administrator, I will be slow to respond, will get everything wrong, and will act imperiously while never acknowledging wrongdoing. Consider this part of your authentic tilde.club experience!
NEW USER TUTORIAL
tilde.club is just a tiny tiny server running linux on the amazon cloud. Using tilde.club requires you to understand shells and ssh. If you don't know about those things, consider this a challenge and opportunity to learn! This concludes the tutorial.
@eric-wood
eric-wood / idk.md
Created October 2, 2014 06:59
Auto-attach for screen/tmux on login!

Keeping a tmux/screen session going, the easy way

Hey so what if you wanted tmux or screen to pop open your session every time you log in, and then automatically log you out when you detach?!

That'd be pretty convenient.

Here add this to your ~/.bash_profile:

[[ $TERM != "screen" ]] &amp;&amp; tmux att &amp;&amp; exit
@@events = {
distance: [],
angle: []
}
def register_event(name, &block)
@@events[name] << &block
return block
end