Skip to content

Instantly share code, notes, and snippets.


Thijs Cadier thijsc

View GitHub Profile
thijsc / assignment.rb
Last active Aug 8, 2020
Little wrapper script around Kafka command line tools to assign topics.
View assignment.rb
#!/usr/bin/env ruby
require "fileutils"
require "json"
ZOOKEEPER = raise "Put your zookeeper list here"
DEFAULT_BROKER_LIST = raise "put your broker list here (1,2,3)
FileUtils.rm_f "/tmp/topics.json"
FileUtils.rm_f "/tmp/assignment.json"
thijsc / lifetime_value.rb
Created Apr 17, 2018
Calculating lifetime value example
View lifetime_value.rb
# Customer Acquisition Cost
@total_cac = 5_000.0
@discounts = 1_000.0
@new_customers = 30
@cac =
(@total_cac + @discounts) / @new_customers
puts "Customer Acquisition Cost: #{@cac}"
thijsc / benchmark.rb
Created Dec 6, 2017
Naive Ruby backtrace benchmark
View benchmark.rb
require "benchmark"
puts(Benchmark.measure {
1_000_000.times do
1 + 1
puts(Benchmark.measure {
1_000_000.times do
thijsc / Gemfile
Created Jul 10, 2017
Barebones standalone Ruby app with AppSignal
View Gemfile
source ''
gem "appsignal"
thijsc / Gemfile
Created Jul 6, 2017
Sequel standalone example
View Gemfile
source ''
gem 'sequel'
gem 'sqlite3'
gem 'appsignal'
use std::env;
fn main() {
let first = env::args().nth(1);
match first {
Some(ref value) if value == "create" => println!("in create"),
Some(_) => println!("smt else"),
None => println!("No arg given")
thijsc / screenshots.rake
Last active Feb 3, 2021
Example of creating screenshots of your site using Capybara and Selenium, for details:
View screenshots.rake
Capybara.default_driver = :selenium
include Capybara::DSL
def take_screenshot(path, name, convert_options={})
# Wait for JS to load data and so on
sleep 2
thijsc / gist:2652300
Created May 10, 2012
Professional delete this code after date x spec
View gist:2652300
scenario "make sure this feature is removed after July 1st" do
raise('Remove this feature!') if > Time.parse('2012-07-01')
thijsc / gist:1391107
Created Nov 24, 2011
Select item from chosen js select with Capybara and Selenium
View gist:1391107
def select_from_chosen(item_text, options)
field = find_field(options[:from])
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
View gist:296000
class Tosti
def self.validate(*ingredients, preparation_method)
ingredients.include?(:brood) && ingredients.length > 1 && preparation_method == :grill