This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A wrapper class that defines ".again", but passes through all other methods to | |
# the wrapped class. | |
class AgainWrapper < BasicObject | |
def initialize(wrapped_object, again_method) | |
@again_method = again_method | |
@wrapped_object = wrapped_object | |
end | |
def again | |
@wrapped_object.send(@again_method) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'syntax_tree' | |
# Create a node visitor that walks the syntax tree looking for blocks. | |
class BlockFinder < SyntaxTree::Visitor | |
attr_reader :first_block | |
visit_method def visit_do_block(node) | |
puts "found a brace block node!" | |
@first_block ||= node | |
# Don't traverse further | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`gem install -i /tmp/tmpgems --no-document pry-byebug` | |
Dir['/tmp/tmpgems/gems/*'].each { |gem| $LOAD_PATH << (gem + '/lib') } | |
require 'pry-byebug' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry-byebug' | |
module ListComprehension | |
def self.execute(block) | |
context = OuterBlockContextClass.new | |
# Set up variables + blocks | |
context.instance_eval(&block) | |
# evaluate the comprehension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'erb' | |
class Note | |
def initialize(qvnote) | |
@root_dir = qvnote | |
end | |
def parse | |
cell_string = cells.map do |cell| | |
case cell['type'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console = Object.new | |
def console.log(*x) | |
puts x.map(&:to_s).join(',') | |
end | |
class Object | |
def method_missing(*args) | |
return args[0] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MIN = { x: -2, y: -1 }, MAX = { x: 1, y: 1 }; | |
const WIDTH = HEIGHT = 1000; | |
function getEscapeCount(c) { | |
let z = { a: 0, b: 0 }; | |
for (let i = 0; i < 100; i++) { | |
if (Math.pow(z.a, 2) + Math.pow(z.b, 2) > 4) return i; | |
z = { a: Math.pow(z.a, 2) - Math.pow(z.b, 2) + c.a, b: z.a * z.b + c.b }; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i audio.mp3 -f image2 -loop 1 -r 25 -i image.jpg -shortest -vcodec libx264 -acodec aac out.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Echoer | |
def call(env) | |
request = Rack::Request.new(env) | |
puts '---' | |
puts request.body.read | |
return [200, {}, ['ok']] | |
end | |
end | |
run Echoer.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Echoer | |
def call(env) | |
request = Rack::Request.new(env) | |
puts '---' | |
puts request.body.read | |
return [200, {}, ['ok']] | |
end | |
end | |
run Echoer.new |
NewerOlder