Skip to content

Instantly share code, notes, and snippets.

View mndrix's full-sized avatar

Michael Hendricks mndrix

View GitHub Profile
@douglas
douglas / update_git_repos.sh
Created October 14, 2011 15:04
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@mndrix
mndrix / example.txt
Created January 26, 2013 21:33
Prolog definition of infinite Fibonacci sequence
?- fibs(F), take(F, 20, _).
F = [0, 1, 1, 2, 3, 5, 8, 13, 21|...],
freeze(_G2395, zip_with(plus, [2584, 4181|_G2395], [4181|_G2395], _G2395)).
@mndrix
mndrix / julian.pl
Last active December 15, 2015 00:29
Modified Julian Day calculations in Prolog. This experiment might form the basis of a date library someday.
:- module(julian, [ date_name/2
, day_of_week/2
, gregorian/3
]).
:- use_module(library(clpfd)).
% This module represents times, dates and sets of those using
% terms of the form =|datetime(MJD, Nano)|=. =MJD= is an
% integer representing the modified Julian day. =Nano= is an
% integer representing the number of nanoseconds since midnight
@campoy
campoy / letitfail.go
Last active January 6, 2024 07:26
This example shows how to have a set of goroutines running concurrently and processing requests. Panics from goroutines are recovered and the worker is restarted. You can download it and run it directly using `go run letitfail.go`
package main
import (
"bufio"
"fmt"
"os"
"time"
)
const numWorkers = 3
@schmichael
schmichael / gist:7379338
Created November 8, 2013 23:32
Transparently compress and upload a file in golang
package main
import (
"bufio"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"