- GitHub Staff
- https://justinherrick.com/
- @jah2488
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
module Main exposing (..) | |
import Html exposing (Html, div, text) | |
import Dict exposing (Dict) | |
names : String -> Dict String (List String) | |
names str = | |
str | |
|> String.split ", " | |
|> List.map (\name -> String.split " " name) |
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
# Structured and Nested | |
obj = { | |
container_a = { | |
name: "Foo", | |
contents: [item_a, item_b, item_e] | |
} | |
container_b = { | |
name: "Bar", | |
contents: [item_c, item_d, item_z] | |
} |
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
it 'sets the state to "gameover" when there is a winner' do | |
game = Game.new | |
game.state = "running" | |
expect { game.winner! }.to change { game.state }.from("running").to("gameover") | |
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
module Main exposing (..) | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.App as App | |
import Html.Events exposing (onInput, onBlur, onClick) | |
import String exposing (length, left, dropLeft, slice, filter, fromList, toList) | |
import Char exposing (isDigit) | |
import Json.Decode as JsonD | |
import Json.Encode as JsonE |
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
#!/usr/bin/env ruby | |
# This script will create the folder structure and files | |
# needed for doing a kata using TDD. | |
kata_name = (ARGV[0] || 'morning') | |
dir_name = kata_name + "_kata" | |
# These are all the commands we will run | |
# in the order in which we will run them. |
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
rm my_blog.db ; ruby seed.rb | sqlite3 my_blog.db && sqlite3 my_blog.db |
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
def inspect_class(klass) | |
klass.new.methods.sort.each do |meth| | |
just = klass.new.methods.sort.max_by(&:length).length | |
hjust = just / 2 | |
klass_meth = klass.new.method(meth) | |
label = "#{klass}.new.#{meth.to_s.ljust(just)}" | |
location = "is defined in #{klass_meth.owner.to_s.ljust(hjust)}" | |
response = [label, location] |
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' | |
module Logger | |
def log(title, opts = {}) | |
__blocks[title] = { | |
successful: true, | |
parent: __blocks[:current], | |
cascade: opts.fetch(:cascade, false) | |
} | |
__blocks[:current] = title |
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 Test | |
def initialize | |
puts "I've been created" | |
end | |
end | |
module Foo | |
def self.check | |
tester |
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
#!/usr/bin/env bash | |
# vim: set ft=ruby: | |
# This file executes as a bash script, which turns around and executes Ruby via | |
# the line below. The -x argument to Ruby makes it discard everything before | |
# the second "!ruby" shebang. This allows us to work on Linux, where the | |
# shebang can only have one argument so we can't directly say | |
# "#!/usr/bin/env ruby --disable-gems". Thanks for that, Linux. | |
# | |
# If this seems confusing, don't worry. You can treat it as a normal Ruby file |