Skip to content

Instantly share code, notes, and snippets.

Thorsten Ball mrnugget

Block or report user

Report or block mrnugget

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mrnugget
mrnugget / read_one_byte.go
Created Mar 16, 2014
Use `stty` to change the operation mode of the terminal to disable line-buffering and non-echoing of typed characters. This lets us read one byte from STDIN. This version is currently tested with OS X
View read_one_byte.go
package main
import (
"bytes"
"fmt"
"log"
"os"
"os/exec"
)
@mrnugget
mrnugget / test_stty.go
Last active Aug 29, 2015
Changing and resetting stty settings
View test_stty.go
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
"os"
"strings"
)
@mrnugget
mrnugget / progbar.go
Created Apr 19, 2014
Simple command line progress bar in Go
View progbar.go
package main
import (
"flag"
"fmt"
"io"
"log"
"net/http"
"net/url"
"os"
@mrnugget
mrnugget / postgis.txt
Created May 20, 2014
postgis error with json-c
View postgis.txt
% 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 Aug 29, 2015
Go snippet: make http requests concurrently but timeout after a specified interval
View http_timeout.go
package main
import "log"
import "net/http"
import "time"
type Response struct {
StatusCode int
Url string
}
View time_after.go
package main
import (
"time"
)
func main() {
ticker := time.Tick(100 * time.Millisecond)
for {
select {
@mrnugget
mrnugget / Gemfile
Created Jul 9, 2014
sidetiq problems
View Gemfile
source 'https://rubygems.org'
gem 'sidekiq', '~> 3'
gem 'sidetiq', '~> 0.6.1'
View simple.c
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 Sep 8, 2014
Copies the binary representation of an integer to a string
View intncpy.c
#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 Oct 18, 2014
Fix PostgreSQL after upgrading to Yosemite if PostgreSQL was installed via homebrew
View fix_postgres.sh
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
You can’t perform that action at this time.