g
: 04.11.12, 60€, Grüne Converse Sneakersb
: 08.01.14, 13€, Blaue YouTurn Sneakterr
: 27.02.15, 45€, Rote Converse Sneakersw
: 09.03.15, 20€, Weiße Converse Chucks
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 with_last(enumerable, length = enumerable.length) | |
Enumerator.new do |yielder| | |
enumerable.each_with_index do |element, index| | |
yielder.yield(element, index == length - 1) | |
end | |
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
license: gpl-3.0 |
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
puts "Starting..." | |
forks = 10.times.map do |i| | |
fork do | |
puts "In fork #{i}" | |
sleep(i) | |
puts "End fork #{i}" | |
end | |
end.to_a |
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 'csv' | |
require 'nokogiri' | |
filename = "timeentries" | |
doc = File.open("#{filename}.xml") { |f| Nokogiri::XML(f) } | |
entries = doc.css('time-entry') | |
CSV.open("#{filename}.csv", "wb") do |csv| |
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 a_random_method_not_defined_in_a_class | |
puts self.class # outputs ExampleClass | |
puts @a_private_member # works | |
end | |
class ExampleClass | |
def initialize(a_private_member) | |
@a_private_member = a_private_member | |
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
git log -i --format=oneline | sed -n '/.*[Mm]ake \(.*\) great again.*/ s//\1/p' | |
# Or even: | |
git log -i --format=oneline | sed -n '/.*[Mm]ake \(.*\) great again.*/ s//\1/p' | ruby -ne 'BEGIN{a=[]};a<<$_.strip;END{puts a.join(", ")}' | |
# A bit shorter and maybe more performant (so use this if you want to make many things great again, e.g. the whole of america): | |
git log -i --format=oneline | sed -n '/.*[Mm]ake \(.*\) great again.*/ s//\1/p' | ruby -ne 'print ", " if $.!=1;print $_.strip;END{puts}' |
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
ls | awk 'NR%50!=25' | xargs rm |
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 | |
MAIN=${2:-development} | |
OPEN=open | |
MRS=$(git remote show -n origin | sed -n '/^ Fetch URL: git@\(.*\):\(.*\)\.git$/ s//https:\/\/\1\/\2\/merge_requests\//p') | |
if [ -z "$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
// I just figured out you could do this in ES6: | |
function foo ({ a = 3, b = 5 } = {}) { | |
console.log(a, b); | |
} | |
foo() // => 3 5 | |
foo({a: 0}) // => 0 5 | |
foo({b: 0}) // => 3 0 | |
foo({a: 4, b: 6}) // => 4 6 |