Skip to content

Instantly share code, notes, and snippets.

@ngauthier
ngauthier / timeout_and_tick.go
Created February 10, 2015 18:14
Golang timeout and tick loop
// keepDoingSomething will keep trying to doSomething() until either
// we get a result from doSomething() or the timeout expires
func keepDoingSomething() (bool, error) {
timeout := time.After(5 * time.Second)
tick := time.Tick(500 * time.Millisecond)
// Keep trying until we're timed out or got a result or got an error
for {
select {
// Got a timeout! fail with a timeout error
case <-timeout:
@ngauthier
ngauthier / README.md
Last active December 8, 2023 13:56
install ruby 2.0.0-p0 on ubuntu
@ngauthier
ngauthier / Gemfile
Created March 23, 2012 16:42
Demo Sinatra App
source :rubygems
gem 'sinatra'
@ngauthier
ngauthier / readme.md
Created December 24, 2011 04:30
Convert 3DS video for YouTube 3D

Assuming the file is named "source.avi":

ffmpeg -i source.avi  -map 0:2 -map 0:1 -vcodec rawvideo -s 480x480 right.avi
ffmpeg -i source.avi  -map 0:0 -map 0:1 -vcodec rawvideo -s 480x480 -vf pad=960:480:0:0:violet -y left.avi
ffmpeg -i left.avi -vf "movie=right.avi [ovl]; [in][ovl] overlay=480:0 [out]" -an -y -b 4096k done.avi

Then upload "done.avi" to youtube. View the video, click "Edit Info" => "3D Video" => "This video is already in 3D" => "Save Changes"

@ngauthier
ngauthier / README.md
Created July 5, 2012 20:10
Rdio "native" in linux

I like Rdio and linux. Rdio works great in a browser except for one thing: keyboard shortcuts!!!

When coding, I like to be able to play/pause my music quickly, meaning I don't want to switch windows. I figured out a way to do this:

Google Chrome --app

First, I made a file in my ~/bin called rdio that runs:

google-chrome --app=http://rdio.com
package fieldsampler
import (
"github.com/honeycombio/beeline-go/sample"
)
const (
// CustomSampleRateFieldName is the field to use to override the default Sample Rate
CustomSampleRateFieldName = "CustomSampleRate"
#!/usr/bin/env bash
set -e
USAGE="Usage: migrate <up|down|new|init>"
# http://www.postgresql.org/docs/9.5/static/libpq-envars.html
export PGDATABASE=${PGDATABASE:-meetspace}
cd `dirname $0`/../migrations
(function() {
window.onerror = function(message, url, line, column) {
if (typeof url === "undefined" || url === null || url === "") {
return;
}
var data = JSON.stringify({
message: message,
url: url,
line: line,

Honeycomb Beeline Golang - Field Sampler

Usage:

// Configure it with a default sample rate
hook, err := fieldsampler.NewFieldSamplerHook(1)
if err != nil {
	log.Fatal(err)
}
@ngauthier
ngauthier / docker-cleanup.sh
Created January 29, 2015 14:49
Clean up docker containers and images
# Docker
function docker-cleanup {
# Find all containers that have exited
containers=`docker ps -a -q -f status=exited | xargs`
if [[ $containers ]]; then
# Remove exited containers
docker rm $containers
else
echo "No containers to remove"
fi