Skip to content

Instantly share code, notes, and snippets.

Avatar

Jakob Skjerning koppen

View GitHub Profile
View chromedriver_update.sh
# Chromedriver installer
#
# This script follows the process outlined on the ChromeDriver Version Selection
# page at https://chromedriver.chromium.org/downloads/version-selection to
# install a Chromedriver version that matches your currently installed version
# of Chrome.
#
# It installs the chromedriver binary into ~/bin/. If an existing chromedriver
# is installed it will be replaced by the updated binary.
@koppen
koppen / configure.log
Last active Feb 22, 2021
Ruby 2.3, OpenSSL, RVM, macOS Mojave
View configure.log
configure: WARNING: you should use --build, --host, --target
checking for ruby... /Users/jakob/.rvm/rubies/ruby-2.6.0/bin/ruby
*** using http instead of https ***
config.guess already exists
*** using http instead of https ***
config.sub already exists
checking build system type... x86_64-apple-darwin18.7.0
checking host system type... x86_64-apple-darwin18.7.0
checking target system type... x86_64-apple-darwin18.7.0
checking whether the C compiler works... yes
@koppen
koppen / issue.md
Last active Nov 26, 2021
To rocket or not
View issue.md

Alright, let's talk about the elephant in the room; hash rockets.

I get it, the JavaScript-style hash notation with colons is popular, but I still fail to see the benefit over the good, old hash rocket.

@samphippen recently wrote about this and his arguments pretty much reflect my own.

I openly admit to being biased but here are the arguments as I see them:

In favor of colons

@koppen
koppen / download.sh
Created Nov 16, 2017
Download n URLs
View download.sh
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 10 ]; do
let COUNTER=COUNTER+1
wget "http://domæne.dk/navn?id=$COUNTER"
done
@koppen
koppen / delayed_job_helpers.rb
Last active Sep 28, 2020
Delayed::Job helpers
View delayed_job_helpers.rb
module Delayed::Job::Ext
module_function
# Returns all failed jobs
def failed_jobs
Delayed::Job.where.not(:last_error => nil).order(:failed_at)
end
def failed_with(message)
failed_jobs.
View fizz.rb
def do_stuff
list = [1, 2, 3, 4, 5]
list.map { |value|
return "Fizz" if value == 3
value
}
end
p do_stuff
View presenter.rb
# frozen_string_literal: true
# A generic presenter class
class Presenter < SimpleDelegator
attr_reader :view
class << self
# Returns true if object has been wrapped in a Presenter
def decorated?(object)
object.is_a?(Presenter)
end
@koppen
koppen / repro.rb
Created Sep 14, 2016
Reproduction steps for ActiveRecord `touch` not clearing changes in `lock_version` when used with optimistic locking
View repro.rb
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails", github: "rails/rails"
View recreate_activerecord_models.rb
# Recreate ActiveRecord models from Delayed Job jobs.
# Ensure that we recreate the full model
ActiveRecord::Base.partial_updates = false
Delayed::Job.all.each do |job|
# Deserialize the Delayed Job handler. As we've been using the `.delay` syntax
# and no custom jobs, this returns a Delayed::PerformableMethod
pfm = YAML.load(job.handler)
View foo.sql
SELECT * FROM (SELECT * FROM unnest(string_to_array('janson morke nils', ' '))) a, (SELECT * FROM unnest(string_to_array('janson morke nils', ' '))) b;