Skip to content

Instantly share code, notes, and snippets.

View 0x0dea's full-sized avatar

D.E. Akers 0x0dea

  • North Carolina, US
View GitHub Profile
require 'stringio'
def find_constant const
return nil unless Object.const_defined? const
value = Object.const_get const
$stderr = StringIO.new
Object.const_set const, nil
print "Wanted to see if you were here today! yes/no? "
def handle_yes
puts "sweet! What time is good for you?"
time = gets.chomp
puts "Right on, I'll see you at #{time}!!"
end
def handle_no
puts "Sad. Next week it is!"
@0x0dea
0x0dea / mnemo
Last active October 1, 2015 20:10
#!/usr/bin/env ruby
#/ Usage: mnemo [filename]
#/
#/ Options:
#/ -h, --help Show this help message
#/ -v, --version Show application version
VERSION = "1.0.1"
LETTER_MAP = {
require 'minitest/autorun'
require 'minitest/pride'
# Given a flat array of positive integers, partition it into three sub-arrays
# whose sums are 5, 7, and 5, respectively, or nil if doing so is impossible.
#
# The argument is the syllable (mora) count of each word in some phrase, and
# the purpose of this method is cutting (kiru) the phrase into chunks which
# satisfy the 5-7-5 rule imposed upon modern haiku.
def kiru morae
require 'open3'
i, o = Open3.popen2 'ruby repl.rb'
line = nil
puts 'Gimme Ruby expressions to evaluate (in another process).'
Thread.new do
i.puts line while line = gets
i.close