Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
# frozen_string_literal: true
require 'shellwords'
require 'logger'
logger = Logger.new($stdout)
command = ARGV.join(" ")
logger.info "Examining #{command.inspect}"
@maxjacobson
maxjacobson / Dockerfile
Last active September 7, 2018 13:31
elm dev environment dockerfile -- doesn't copy code into the image (which means it wouldn't be useful in production), you're expected to use it by volume-mounting your source code into `/elm-code`
FROM node:10.9.0-jessie
WORKDIR /elm-code
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
RUN apt-get update && \
apt-get upgrade --yes && \
apt-get install --yes \
wget && \
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
Thread.new do
begin
10.times do
puts "Running inside thread..."
sleep rand
end
raise "boom!"
rescue => ex
puts "An error occured: #{ex}"
# 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
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div id="field">
<div id="goal"></div>
<div id="ball"> </div>
</div>