Skip to content

Instantly share code, notes, and snippets.

View kennethgeerts's full-sized avatar
🏠
Working from home

Kenneth Geerts kennethgeerts

🏠
Working from home
View GitHub Profile
require 'tty-prompt'
require 'colorize'
NAMES = %w[Vera Willy Nele Tim Jules Katrien Kenneth Joris Lien].shuffle
PLACES = ['in de living', 'in de keuken', 'in de hal', 'in een badkamer', 'in de eetkamer', 'in een slaapkamer boven', 'in de speelkamer', 'op de trap', 'rond het huis'].shuffle
WEAPONS = ['de kerstworst', 'Winnie The Pooh', 'de shampoo', 'het kaske van den tv', 'de kolenschop', 'het kussen', 'de voetbal', 'de wc-rol', 'de pollepel']
File.open('gotcha.txt', 'w') { |file| file.puts(NAMES, '-', PLACES, '-', WEAPONS) }
loop do
100.times { puts }
puts 'Welkom op de De Mulder-weekend-GOTCHA!'.magenta, ''
input = TTY::Prompt.new.ask('Wat is je naam?') { |q| q.modify(:trim, :capitalize) }

Keybase proof

I hereby claim:

  • I am kennethgeerts on github.
  • I am kennethgeerts (https://keybase.io/kennethgeerts) on keybase.
  • I have a public key ASDyw5dQvQVDdPy6Ls2nxFPUi9y4auOtdaP2Vkb1HA1ytgo

To claim this, I am signing this object:

Squashing commits on a feature branch

Suppose you did 3 commits on a feature branch called feature:

ae1a4a5 Foo
a5827db Bar
62d4c80 Baz

Make sure develop branch is up to date:

class FoodChain
VERSION = 2
def self.song
0.upto(7).map { |n| FoodChainStanza.nth(n) }.join("\n")
end
end
class FoodChainStanza
ANIMALS = %w(fly spider bird cat dog goat cow horse)
@kennethgeerts
kennethgeerts / recursion.rb
Created February 17, 2015 11:23
recursion
require 'benchmark'
class Integer
def performant_factorial
(1..self).reduce(:*) || 1
end
def recursive_factorial
self == 0 ? 1 : self * (self - 1).recursive_factorial
end
def document_actions_form_tag
capture do
concat form_tag('', method: :post, id: 'document_actions_form')
input_name_value_pairs(request.params).each do |name_value_pair|
concat tag('input', { name: name_value_pair.first, value: name_value_pair.last, type: 'hidden' })
end
clazz = Class.new do
def checkbox_header
@kennethgeerts
kennethgeerts / en.yml
Created October 16, 2014 14:05
en.yml
en:
hello: "Hello world"
activemodel:
models:
record: Record
user: User
attributes:
record:
customer_id: Customer ID
name: Customer Name
def search_field(field, operator, attributes = {})
field_op = "#{field}_#{operator}"
value = (params[:q][field_op] if params[:q])
title = t(".#{field_op}")
label_tag = content_tag :label, title
attributes[:name] = "q[#{field_op}]"
attributes[:type] ||= 'text'
attributes[:value] = value
input_tag = content_tag :input, nil, attributes
[label_tag, input_tag].join.html_safe
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Usage:
# Remove the .sh file extension when you put the script in your hooks folder!
#
@kennethgeerts
kennethgeerts / Preferences.sublime-settings
Created April 22, 2014 12:45
Preferences.sublime-settings
{
"auto_complete_commit_on_tab": true,
"caret_style": "solid",
"color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",