This file contains hidden or 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 WoodOfLife | |
include Enumerable | |
ROWS = 50 | |
COLUMNS = 50 | |
EXAMPLE = Array.new(ROWS * COLUMNS) { rand(2) }.join | |
attr_reader :cells, :rows, :columns | |
def initialize(options = {}) |
This file contains hidden or 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 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'sqlite3' | |
gem 'activerecord', "~> 6.0.0.rc2" | |
end | |
require 'active_record' |
This file contains hidden or 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
# Railslove Ruby programming exercise A4 | |
# | |
# To run the following exercise you need to have rspec installed. | |
# Then inspect the failing specs by running `rspec translations.rb` | |
# | |
# This excercise is special, because it's the first one where you're allowed to require active_support. ;-) | |
# | |
# (!) The task is to navigate and write into a nested hash via a path represented as `.` separated keys. | |
# | |
# (?) Maybe start with the underling algorithm to expand a collection to a "directed graph" |
This file contains hidden or 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
c=[' ',?█].cycle;w="173322172322\n2322232223221322\n23222322262322\n263322232225\n23123322232233\n23222322232233\n2322353643".chars.reduce([]){|r,n|n==$/?r<<n:r<<c.next*n.to_i;r}.join.split($/).map{|c|c.chars.map{|c|c*2}.join<<$/}.map{|r|r*2}.join;loop{$><<"\e[2J\e[1;1H"<<w.chars.map{|t|"\e[38;5;#{rand(230)}m#{t}"}*'';sleep 1} |
This file contains hidden or 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
# Railslove Ruby programming exercise A3 | |
# | |
# To run the following exercise you need to have rspec installed. | |
# Then inspect the failing specs by running `rspec mission.rb` | |
# | |
# How well did the avengers manage their time on their missions? | |
# Your task is to group all time entries by mission and then sum the minutes in total per avenger. | |
# After grouping the entries the expected response looks something like: | |
# | |
# { |
This file contains hidden or 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
# Railslove Ruby programming exercise A2 | |
# | |
# To run the following exercise you need to have rspec installed. | |
# Then inspect the failing specs by running `rspec subset.rb` | |
# | |
# The task is to get all possible subsets of a group of Railslovers (without duplicates). | |
# So return a collection containing a group of each Railslover alone, | |
# then a group of pairs, then groups of 3, etc... | |
# The empty group is not considered a valid Railslove group. :) | |
# |
This file contains hidden or 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
# Railslove Ruby programming exercise A1 | |
# | |
# To run the following exercise you need to have rspec installed. | |
# Then watch the output of `rspec filter.rb` and see 3 of 4 failing specs. | |
# | |
# The task is to filter a given collection (L#31) for entries that contain unique pairs. | |
# While filtering return the same structure and keep the ranking. | |
# | |
# Write code in the body of the filter method to make the tests pass. | |
# |
This file contains hidden or 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'action_controller/railtie';run Class.new(Rails::Application){config.secret_key_base=?x;routes{root to:->_{[200,{},[]]}}}.initialize! |
This file contains hidden or 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
// ==UserScript== | |
// @name Mangopay Notifications | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description simulate mangopay notifications direct from the dashboard | |
// @author Lars Brillert | |
// @include /https://dashboard.sandbox.mangopay.com/Users/\d+/WalletTransactions/\d+/ | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ |
This file contains hidden or 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 FASTER IMPORTER | |
# | |
# the built-in import is not very efficient. | |
# It grabs every record, builds the ActiveRecord object | |
# and calls #as_indexed_json on it. | |
# | |
# for large sets of data that spans multiple relations, | |
# this can take a lot of time to complete. | |
# | |
# the elasticsearch-rails client provides a relatively simple interface for |
NewerOlder