Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Gauthier ngauthier

View GitHub Profile
@ngauthier
ngauthier / timeout_and_tick.go
Created Feb 10, 2015
Golang timeout and tick loop
View timeout_and_tick.go
// 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
Created Jul 5, 2012
Rdio "native" in linux
View README.md

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
View field_sampler.go
package fieldsampler
import (
"github.com/honeycombio/beeline-go/sample"
)
const (
// CustomSampleRateFieldName is the field to use to override the default Sample Rate
CustomSampleRateFieldName = "CustomSampleRate"
View migrate.sh
#!/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
View errors.js
(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,
View README.md

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 / README.md
Last active Sep 5, 2018
install ruby 2.0.0-p0 on ubuntu
View README.md

Installs ruby-2.0.0-p0 on ubuntu via checkinstall so it's in your package manager and you can remove it.

Quick install:

curl -L https://gist.github.com/ngauthier/5039249/raw/1868bf4714052b40e2bb7fdf3f40fbeb5d730bca/ruby-2-install-ubuntu.sh | bash -s
@ngauthier
ngauthier / docker-cleanup.sh
Created Jan 29, 2015
Clean up docker containers and images
View docker-cleanup.sh
# 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
View keybase.md

Keybase proof

I hereby claim:

  • I am ngauthier on github.
  • I am ngauthier (https://keybase.io/ngauthier) on keybase.
  • I have a public key ASDxB3I8Mq8d2GMauNlQdEGZKiu29cVrnz_zK6gLX-XU_go

To claim this, I am signing this object:

@ngauthier
ngauthier / scraping.rb
Last active Mar 1, 2017
Scraping the Web with Ruby Code
View scraping.rb
#!/usr/bin/env ruby
# From: http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html
require 'capybara'
require 'capybara/poltergeist'
require 'csv'
require 'gdbm'
class NickBot
include Capybara::DSL