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 evolve_cell(cell, neighbours) | |
if cell == 1 | |
if neighbours.inject(&:+) == 2 || neighbours.inject(&:+) == 3 | |
1 | |
else | |
0 | |
end | |
else | |
if neighbours.inject(&:+) == 3 | |
1 |
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 Cell | |
CHARACTERS = { :live => 'X', :dead => 'O' } | |
attr_reader :live | |
def self.live | |
new(:live) | |
end | |
def self.dead |
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 Cell | |
def self.random | |
number = Random.rand(100) | |
if number > 50 | |
live | |
else | |
dead | |
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
#!/bin/bash | |
set -e | |
#!/bin/bash | |
set -e | |
ansible $@ -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory --private-key=~/.vagrant.d/insecure_private_key -u vagrant |
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
diff --git a/lib/psych/handlers/document_stream.rb b/lib/psych/handlers/document_stream.rb | |
index e429993..25d10fb 100644 | |
--- a/lib/psych/handlers/document_stream.rb | |
+++ b/lib/psych/handlers/document_stream.rb | |
@@ -18,5 +18,19 @@ module Psych | |
@block.call pop | |
end | |
end | |
+ | |
+ class StrictDocumentStream < DocumentStream |
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
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"time" | |
) | |
type Conn struct { | |
num int |
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 'spec_helper' | |
require 'open3' | |
describe 'unnest' do | |
it 'can unnest nested class definitions in a file' do | |
example_input = <<-EOF | |
module A::B | |
class C::D::E < F::G | |
def initialize(foo) | |
@foo = foo |
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 Mixin | |
def fail | |
raise "ARRRGH!" | |
end | |
alias_method :blurgh, :fail | |
end | |
class Includer | |
include Mixin |
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
<% unless form.object.errors.empty? %> | |
<div class="alert alert-danger"> | |
<p><strong>Bummer!</strong> Try again after fixing this up:</p> | |
<% form.object.errors.full_messages.each do |message| %> | |
<ul> | |
<li><%= message %></li> | |
</ul> | |
<% end %> | |
</div> | |
<% 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
renameKey = (from, to, obj) -> | |
results = {} | |
for k, v of obj | |
if k == from | |
results[to] = v | |
else | |
results[k] = v | |
results | |