Skip to content

Instantly share code, notes, and snippets.

View mrnugget's full-sized avatar

Thorsten Ball mrnugget

View GitHub Profile
@mrnugget
mrnugget / test_stty.go
Last active August 29, 2015 14:00
Changing and resetting stty settings
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"os"
"strings"
)
@mrnugget
mrnugget / postgis.txt
Created May 20, 2014 07:51
postgis error with json-c
% brew install postgis
==> Downloading http://download.osgeo.org/postgis/source/postgis-2.1.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/postgis-2.1.2.tar.gz
==> ./autogen.sh
;==> ./configure --with-projdir=/usr/local --with-jsondir=/usr/local/opt/json-c --with-pgconfig=/usr/local/Cellar/postgresql/9.3.4/bin/pg_config --disable-nls
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
checking for pj_get_release in -lproj... yes
configure: error: Cannot find json dev files in "/usr/local/opt/json-c"
@mrnugget
mrnugget / http_timeout.go
Last active August 29, 2015 14:02
Go snippet: make http requests concurrently but timeout after a specified interval
package main
import "log"
import "net/http"
import "time"
type Response struct {
StatusCode int
Url string
}
@mrnugget
mrnugget / time_after.go
Created June 5, 2014 16:24
golang time.After
package main
import (
"time"
)
func main() {
ticker := time.Tick(100 * time.Millisecond)
for {
select {
@mrnugget
mrnugget / Gemfile
Created July 9, 2014 08:23
sidetiq problems
source 'https://rubygems.org'
gem 'sidekiq', '~> 3'
gem 'sidetiq', '~> 0.6.1'
@mrnugget
mrnugget / simple.c
Created August 15, 2014 12:37
Stack Usage
int main(int argc, char *argv[])
{
int i = 10;
int j = 15;
int k = 20;
int l = i + j;
return 0;
}
@mrnugget
mrnugget / intncpy.c
Created September 8, 2014 15:36
Copies the binary representation of an integer to a string
#include <string.h>
#include <stdio.h>
#define INT_BITS_NUM (8 * sizeof(int))
void intncpy(int src, char *dest, int len)
{
int bit = INT_BITS_NUM - 1;
int pos, is_set;
@mrnugget
mrnugget / fix_postgres.sh
Created October 18, 2014 10:27
Fix PostgreSQL after upgrading to Yosemite if PostgreSQL was installed via homebrew
mkdir /usr/local/var/postgres/pg_tblspc
mkdir /usr/local/var/postgres/pg_twophase
mkdir /usr/local/var/postgres/pg_stat_tmp
mkdir /usr/local/var/postgres/pg_stat
@mrnugget
mrnugget / fzzcd.sh
Created October 21, 2014 08:17
Use fzz to interactively find a file and then `cd` to the directory of the top result
cdfzz() {
local file=$(fzz find . -iname "*{{}}*" | head -n 1)
local filedir=$(dirname ${file})
cd ${filedir}
}
@mrnugget
mrnugget / Makefile
Created November 1, 2014 08:24
Dotfiles Makefile
DOTFILE_PATH := $(shell pwd)
$(HOME)/.%: %
ln -sf $(DOTFILE_PATH)/$^ $@
irb: $(HOME)/.irbrc
ack: $(HOME)/.ackrc
git: $(HOME)/.gitconfig $(HOME)/.githelpers $(HOME)/.gitignore
psql: $(HOME)/.psqlrc
zsh: $(HOME)/.zprofile