Will:
#!/usr/bin/env ruby
class Fountain
def self.x=(x)
@x = x
end| lvar = 1 | |
| defined?(lvar) # => "local-variable" | |
| defined?(no_lvar) | |
| $gvar = 1 | |
| defined?($gvar) # => "global-variable" | |
| defined?($no_gvar) # => nil | |
| CONST = 1 | |
| defined?(CONST) # => "constant" |
Will:
#!/usr/bin/env ruby
class Fountain
def self.x=(x)
@x = x
end| require "English" | |
| def some_method | |
| # I didn't know it would still be set here | |
| $ERROR_INFO # => #<RuntimeError: hell> | |
| end | |
| begin | |
| raise "hell" | |
| rescue |
| is everything working? | |
| no yes | |
| you're done! | |
| are your tests passing? great job! open a PR | |
| yes no | |
| write a failing test, make your tests pass, | |
| go back to beginning go back to beginning |
| # usage: | |
| # ruby trie.rb chatter | |
| word = ARGV.first || ["chatter", "helio", "wonder", "gosli"].sample | |
| class Node | |
| def add(chars) | |
| return if chars.empty? | |
| char = chars.shift |
| require 'readline' | |
| def reminder | |
| puts "vi editing mode? #{Readline.vi_editing_mode?}" | |
| puts "emacs editing mode? #{Readline.emacs_editing_mode?}" | |
| puts "Try: | |
| writing something! | |
| going up and down in history | |
| going forward and backwards some characters |
| #!/usr/bin/env ruby | |
| require 'json' | |
| require 'yaml' | |
| def simple_structure(orig) | |
| case orig | |
| when Hash | |
| simple = {} | |
| orig.each do |key, value| |
| trap('INT') do | |
| print("\n") | |
| exit | |
| end | |
| output = Enumerator.new do |yielder| | |
| chars = "▁▂▃▄▅▆█".split("") | |
| chars = chars + chars.reverse | |
| nums = (0..(chars.length - 1)).to_a | |
| loop do |
| require 'github_api' # gem install github_api | |
| require 'readline' | |
| require 'fileutils' | |
| FileUtils.touch("./safe") | |
| username = Readline.readline("Enter your github username: ") | |
| pw = Readline.readline("Enter your regular github password: ") | |
| one_time_password = Readline.readline("Enter your one time password: ") |
| require 'nokogiri' | |
| failing = Nokogiri::HTML(File.read(ARGV.first)) | |
| def node_to_just_classes(node) | |
| { | |
| 'name' => node.name, | |
| 'classes' => (node.attributes["class"]&.value&.split(" ")&.compact || []), | |
| 'children' => node.children.map { |child| node_to_just_classes(child) } | |
| } |