Skip to content

Instantly share code, notes, and snippets.

Avatar

Laust Rud Jacobsen rud

View GitHub Profile
View milk.md

On steaming milk

If you go to Italy and order a coffee, they'll serve it with full fat milk that's been steamed to perfection. You'll love it and come back telling everyone how good the coffee is in Italy. But it's not just about the coffee - it's also about the milk. So if you want the velvety texture and natural sweetness that comes from slightly caramelised milk, it's essential to steam properly.

Milk steaming should happen in two distinct stages: stretching and spinning. Stretching means introducing air into the milk via the steam wand to increase its volume, while spinning is whipping the steamed milk into the desired velvety texture.

Start with a clean cold pitcher, a milk thermometer and cold fresh milk. Use only as much milk as you need for the drink.

To begin stretching, sink the tip of the steam wand deep into the milk and open it right up. Bring the tip up to just below the surface so you hear a ch-ch-ch sound. If there's no sound the steam wand is too far down, meaning you aren't introducing

@rud
rud / z_airbrake.rb
Created Apr 18, 2018 — forked from 2called-chaos/z_airbrake.rb
Airbrake 6.3 config
View z_airbrake.rb
Airbrake.configure do |config|
# project specific
config.project_key = ''
# use git SHA & current commit as app version
config.app_version = "Ruby: #{RUBY_VERSION} » Rails: #{Rails::VERSION::STRING} » " << `cd #{Rails.root} && git log -1 --pretty="%h - %B" HEAD`
# can always be 1
config.project_id = 1
@rud
rud / openstruct_benchmark.rb
Created Feb 2, 2018
OpenStruct performance in ruby 2.4.
View openstruct_benchmark.rb
# Code from http://www.chrisrolle.com/en/blog/struct-vs-openstruct-benchmark
# gem install benchmark-ips
require 'benchmark/ips'
require 'ostruct'
class GCSuite
def warming(*)
run_gc
View chunked-event-publishing.md

Chunked event publishing - design overview

Class: EventCollector

Roles:

  • #enqueue_event(payload, target queue name): stores messages to be sent in a simple array
  • #publish() send everything currently enqueued to external queue system (here: RabbitMQ); if the publish fails for any reason, messages are kept in memory for later retry (along with grumbling in logs, etc).
  • #clear_events_to_publish! is useful in rollback scenarios
  • .thread_singleton_instance accessor with lazy initialization, like ActiveRecord::Base.connection. This allows for easy setup, and persistent state across requests (should flushing fail we can retry on next request on the same thread). The thread_singleton_instance also easy replacement with a simple test implementation, think ActionMailer. Sending actual messages in test is best restricted to a few integration test scenarios.
@rud
rud / database.yml
Created Jan 24, 2016
ActiveRecord::Base - set short timeouts for production queries, nothing end-users do should be taking this long
View database.yml
# Do not suffer slow queries in production:
aggressive_timeout_settings: &aggressive_timeout_settings
adapter: postgresql
encoding: unicode
connect_timeout: 1 # second - network handshake time
checkout_timeout: 1 # second - connection pool checkout wait time
variables:
statement_timeout: 2500 # ms - maximum time for a single SQL query
production:
View gist:1f0110f4771db1d1eea5
### Keybase proof
I hereby claim:
* I am rud on github.
* I am rud (https://keybase.io/rud) on keybase.
* I have a public key whose fingerprint is 2949 8980 F3BE 3D8F FC0B E75D 3E50 71F8 6896 12B4
To claim this, I am signing this object:
@rud
rud / prune.sh
Created Oct 21, 2013
Simple script for deleting local already merged branches, and prune remote tracking branches where the report part no longer exists. As a practical convenience, it will not delete a few long-lived local branches such as "develop", "master", and "production". This is built on ideas from http://stevenharman.net/git-clean-delete-already-merged-bran…
View prune.sh
#!/bin/sh
# Simple script for pruning local branches already merged,
# and remove remote tracking branches that have been deleted
# Default to "origin" if no remote is passed
remote=${1-origin}
# Branches to keep, regardless of their current merge state
permanent_branches="develop|master|production"
@rud
rud / vol
Created Nov 12, 2012 — forked from bjensen/vol
open the newest file of a directory in $EDITOR
View vol
# --------------------------------------------------------
# vol as a shell script
# --------------------------------------------------------
# You would put this code in a directory that's in your
# path, like ~/bin (PATH=~/bin:$PATH in your .bashrc to
# add a directory like that to your path.)
# The invokation syntax is the same as that of the
# function.
# --------------------------------------------------------
# Example usage:
@rud
rud / vol
Created Nov 12, 2012 — forked from bjensen/vol
open the newest file of a directory in vim
View vol
# --------------------------------------------------------
# vol as a shell script
# --------------------------------------------------------
# You would put this code in a directory that's in your
# path, like ~/bin (PATH=~/bin:$PATH in your .bashrc to
# add a directory like that to your path.)
# The invokation syntax is the same as that of the
# function.
# --------------------------------------------------------
# Example usage:
You can’t perform that action at this time.