Skip to content

Instantly share code, notes, and snippets.

module Enumerable
def first_to_finish
threads = collect { |args| { yield(args) } }
loop until done = threads.detect { |t| !t.alive? }
puts [5, 3, 1, 2, 4].first_to_finish { |x| sleep x }
fnordfish /
Last active December 9, 2019 20:01
My vagrant guidelines for happy devboxes

Very rough description on how I use [Vagrant][vagrant]. Uses some SSH magic to get easy git access to your private repos.

Host Setup

  • Use most recent version of [vagrant][vagrant].
  • Some tools and plugins:
    • [vagrant-dns][vagrant-dns] (MacOS only!) starts a local DNS Server, so that you can access your webserver with a domain name (not only an IP). After installation (vagrant plugin install vagrant-dns) run vagrant dns --install to initially setup some system configurations on your system. This will require you to enter your password once.
require 'rspec'
require 'set'
class Traverser
attr_reader :elements, :satisfied
def initialize(elements, satisfied:)
@elements = elements
@satisfied = satisfied
jareware /
Last active March 21, 2024 15:14
Conversion script between the TTML & SRT subtitle formats


Conversion script between the TTML & SRT subtitle formats. This is particularly useful with Adobe Premiere, as it doesn't understand the SRT format (which is joyously simple and interoperable). TTML-XML is probably the most straightforward subtitle format it does understand, hence this tool.

Note that due to the simplicity of the SRT format, this conversion is extremely lossy for all the bells and whistles supported by TTML. Not like you'd want fixed-pixel font sizes etc in your subtitles anyway, but you've been warned.

rmehner /
Created April 6, 2014 14:41
Reinstalls all rbenv rubies. Keeping that here for the regular libyaml update ;-)
for ruby in ~/.rbenv/versions/*; do
rbenv uninstall -f ${ruby##*/}
rbenv install ${ruby##*/}
# config/initializers/paperclip.rb
# If you want to disable paperclip attachments to S3 in the development environment,
# remove the comments from the "if" condition below and restart the server.
#if Rails.env.staging? || Rails.env.production?
Paperclip::Attachment.default_options[:storage] = :s3
Paperclip::Attachment.default_options[:s3_credentials] = {
:bucket => "app-#{Rails.env}",
:access_key_id => '<ACCESS_KEY_ID>',
:secret_access_key => '<SECRET_ACCESS_KEY>'
lucaong /
Last active August 29, 2015 13:56


A stupidly simple implementation of a kind of "sorta immutable" struct that can be instantiated as conveniently as an OpenStruct but after instantiation it doesn't let me (easily) add fields or mutate them:

guy = name: "John", age: 23 )

# readers:             #=> "John"
guy.age #=&gt; 23
skade / (slash)etc(slash)hosts
Last active January 2, 2016 02:19
Get Facebook off your internet
#ignore stupid sites
brandonb927 /
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see
# Alot of these configs have been taken from the various places
# on the web, most from here
marktheunissen / pedantically_commented_playbook.yml
Last active March 31, 2024 18:45 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.