Skip to content

Instantly share code, notes, and snippets.

View thijsc's full-sized avatar

Thijs Cadier thijsc

View GitHub Profile
@thijsc
thijsc / config.json
Created July 6, 2023 10:17
Custom dashboard for reporting hosts
{
"title": "Reporting hosts",
"description": "",
"visuals": [
{
"title": "All",
"line_label": "%name%",
"display": "LINE",
"format": "number",
"draw_null_as_zero": true,
@thijsc
thijsc / Apdex.json
Last active June 28, 2023 09:29
Custom dashboard config for apdex score and counts
{
"title": "Apdex",
"description": "",
"visuals": [
{
"title": "Apdex",
"line_label": "%namespace%",
"display": "LINE",
"format": "number",
"draw_null_as_zero": false,
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
ethernets:
ens1f0:
match:
macaddress: {{ hostvars[inventory_hostname]['interfaces']['ens1f0'] }}
ens1f1:
match:
@thijsc
thijsc / lifetime_value.rb
Created April 17, 2018 18:39
Calculating lifetime value example
# 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
thijsc / gist:1391107
Created November 24, 2011 11:08
Select item from chosen js select with Capybara and Selenium
def select_from_chosen(item_text, options)
field = find_field(options[:from])
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
page.execute_script("$('##{field[:id]}').val('#{option_value}')")
end
@thijsc
thijsc / screenshots.rake
Last active February 3, 2021 22:38
Example of creating screenshots of your site using Capybara and Selenium, for details: http://blog.appsignal.com/blog/2015/07/21/automated-screenshots-using-capybara.html
BROWSER_WIDTH = 1600
BROWSER_HEIGHT = 1200
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
retinafy_screen
@thijsc
thijsc / assignment.rb
Last active August 8, 2020 09:07
Little wrapper script around Kafka command line tools to assign topics.
#!/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
thijsc / benchmark.rb
Created December 6, 2017 12:12
Naive Ruby backtrace benchmark
require "benchmark"
puts(Benchmark.measure {
1_000_000.times do
1 + 1
end
})
puts(Benchmark.measure {
1_000_000.times do
@thijsc
thijsc / Gemfile
Created July 10, 2017 19:16
Barebones standalone Ruby app with AppSignal
source 'https://rubygems.org'
gem "appsignal"
@thijsc
thijsc / Gemfile
Created July 6, 2017 14:58
Sequel standalone example
source 'https://rubygems.org'
gem 'sequel'
gem 'sqlite3'
gem 'appsignal'