Skip to content

Instantly share code, notes, and snippets.

@alloy-d
alloy-d / miu.go
Created July 19, 2010 02:06
A program that derives strings in Hofstadter's MIU-system in a brainless (but idiomatic Go) manner.
// Warning: eats memory quickly.
// Resource limiting recommended.
package main
import (
"fmt"
"os"
"strings"
)
@bradfitz
bradfitz / gist:1080828
Created July 13, 2011 17:38
Go optional args, v2
package main
import (
"fmt"
)
type Person struct {
Name string
Age int
Position string
#!/bin/bash
# ---------------------------------------------------------------------------
# OO support functions
# Kludged by Pim van Riezen <pi@madscience.nl>
# ---------------------------------------------------------------------------
DEFCLASS=""
CLASS=""
THIS=0
@nifl
nifl / grok_vi.mdown
Created August 29, 2011 17:23
Your problem with Vim is that you don't grok vi.

Answer by Jim Dennis on Stack Overflow question http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Your problem with Vim is that you don't grok vi.

You mention cutting with yy and complain that you almost never want to cut whole lines. In fact programmers, editing source code, very often want to work on whole lines, ranges of lines and blocks of code. However, yy is only one of many way to yank text into the anonymous copy buffer (or "register" as it's called in vi).

The "Zen" of vi is that you're speaking a language. The initial y is a verb. The statement yy is a simple statement which is, essentially, an abbreviation for 0 y$:

0 go to the beginning of this line. y yank from here (up to where?)

@nithinphilips
nithinphilips / mediatomb-ipk.mkd
Created February 13, 2012 07:26
Creating Mediatomb IPK packages

Creating Mediatomb IPK packages

The easiest option to create mediatomb IPK packages is probably to use the optware system to cross-compile on a PC. This guide shows how.

Based on the cross-compile guide at http://mybookworld.wikidot.com/cross-compile-for-mbwe-using-optware

*The code blocks with '$' prefix is a command that should be pasted or typed into a terminal window. On Ubuntu, use the GNOME Terminal program. When

@lamberta
lamberta / vbox.sh
Created August 6, 2012 04:31
Convenience wrapper around VBoxManage for controlling VirtualBox virtual machines.
#!/usr/bin/env bash
# Convenience wrapper around VBoxManage for controlling VirtualBox virtual machines.
#
# Headless Ubuntu server gets stuck at boot menu on unsuccessful boots:
# http://serverfault.com/questions/243343/headless-ubuntu-server-machine-sometimes-stuck-at-grub-menu
function print_help {
echo "Usage: $(basename $0) [options] name"
echo "Easy control of VirtualBox virtual machines."
echo " -h Show this usage guide."
@jordanorelli
jordanorelli / templates.go
Created August 9, 2012 21:42
primitive template cache in Go with os.Stat
package core
import (
"bytes"
"fmt"
"html/template"
"io/ioutil"
"net/http"
"os"
"path/filepath"
@jdillick
jdillick / find_closest_sha1.py
Created January 17, 2013 16:06
Found this little gem of python for comparing a git repo to an un-versioned copy of the code. I returns the closest commit hash from the git repository corresponding to your code. This works great when you don't know what version of the code you have running.
#!/usr/bin/env python
import subprocess
import shlex
import sys
import os
import operator
gitdir,workdir=map(os.path.realpath,sys.argv[1:3])
os.chdir(gitdir)
proc=subprocess.Popen(shlex.split('git rev-list --all'),stdout=subprocess.PIPE)
@mrnugget
mrnugget / a.md
Created April 13, 2013 11:13
When streaming a `exec.Command` output with `StdoutPipe()` the text gets streamed when using a shell script and a Node.js file, but now using a python file and ruby file. Why?

Running this gist:

go run main.go

The output:

2013/04/13 13:09:11 --------------
2013/04/13 13:09:11 Starting script: ./print_sleep_print.sh
2013/04/13 13:09:11 READ LINE: First line. Going to sleep for 10 seconds now
@scttnlsn
scttnlsn / queue.go
Last active July 5, 2023 14:30
Queue server in Go
package main
import (
"bufio"
"flag"
"fmt"
"net"
"strconv"
"strings"
"time"