Skip to content

Instantly share code, notes, and snippets.

/*
macOS fork bug reproducer for https://github.com/golang/go/issues/33565
cc -o fork-leak fork-leak.c
while true; do sh -c 'exec ./fork-leak 1 $$'; done
In another terminal, run:
while sleep 2; do pgrep fork-leak; done
package main
import (
"fmt"
"log"
"os"
"time"
)
func main() {
@jacobvosmaer
jacobvosmaer / Makefile
Last active August 29, 2015 13:57
Reproducing TagLib 1.9.1 errors on OS X 10.9.2
LDFLAGS = -ltag
test: all
./enumeration_order
./mp4-loop mp4.m4a
all: mp4-loop enumeration_order
mp4-loop: mp4-loop.cpp
@jacobvosmaer
jacobvosmaer / DRBD 8.4.2 on Ubuntu 12.04
Last active August 29, 2015 13:57
Also make the docs
# drbd8-utils does not match the drbd kernel module so we need to compile from source
# install dependencies
sudo apt-get install autoconf gcc flex make git-core xsltproc # xsltproc is for the manpages
# check the DRBD kernel module version
cat /proc/drbd
# clone
cd /tmp && git clone -b drbd-8.4.2 git://git.drbd.org/drbd-8.4.git # assuming kernel module for DRBD 8.4.2
@jacobvosmaer
jacobvosmaer / flattener.rb
Created February 24, 2014 13:19
Hash flattener for Ruby
class Flattener
def initialize(separator='_')
@separator = separator
end
def flatten(hash, prefix=nil)
Enumerator.new do |yielder|
hash.each do |key, value|
raise "Bad key: #{key.inspect}" unless key.is_a?(String)
key = [prefix, key].join(@separator) if prefix
vagrant@lucid32:~/taglib-ruby$ uname -a
Linux lucid32 2.6.32-38-generic #83-Ubuntu SMP Wed Jan 4 11:13:04 UTC 2012 i686 GNU/Linux
vagrant@lucid32:~/taglib-ruby$
vagrant@lucid32:~/taglib-ruby$ git log -1
commit bbbdb3b7f7016c8351d9e4d8787c2bdef3d18b9f
Author: Robin Stocker <robin@nibor.org>
Date: Sat Sep 29 16:32:36 2012 +0200
Add building section to contributing

Acceptance tests with Capybara and Rspec (quick and dirty)

A simple acceptance test for the RailsGirls Ideas App.

Installation

Add the following lines to your Gemfile:

gem 'rspec-rails'
gem 'capybara'
@jacobvosmaer
jacobvosmaer / LICENSE
Created August 13, 2012 15:59 — forked from matsimitsu/LICENSE
mongoid-sync
Copyright (c) 2012 Robert Beekman
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
@jacobvosmaer
jacobvosmaer / gist:3188296
Created July 27, 2012 14:22
Terminal touch typing shortcuts in OS X

Terminal touch typing shortcuts in OS X

Remapping CAPS LOCK to Control also has benefits outside of the terminal in OS X (10.7).

Remapping CAPS LOCK and enable the Meta key

OS X's terminal becomes a much happier place if you remap CAPS LOCK to the Control key, and if you enable the Option key. One downside of this, which applies only in Terminal.app, is that you can no longer enter symbols which can only be

@jacobvosmaer
jacobvosmaer / gist:3187346
Created July 27, 2012 10:35
Open all files with git merge conflicts in Vim

Open all files with git merge conflicts in MacVim

git diff --name-only | uniq | xargs mvim

When git encounters a merge conflict, e.g. during a rebase, it drops you back into the shell with a dirty working directory. I like this one-liner for opening all files with a merge conflict in MacVim.

Once you're in Vim, you can then switch between the files with :n and :prev, or another favourite: :w | n (save current file and open the next command line-supplied file).

UPDATE: see below for a version that works with real terminal commands.