Skip to content

Instantly share code, notes, and snippets.

View theophoric's full-sized avatar
💭
👾

theophoric theophoric

💭
👾
View GitHub Profile
find . -name '*erb' | \
xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | \
bash
/*
An interface is a category of type that defines a set of methods. An interface is valid as long as it or the value it holds ( e.g. a struct ) implements those methods
*/
package main
import (
package main
import (
"bytes"
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"net/http"
@theophoric
theophoric / http_errors.go
Created March 10, 2014 05:41
testing errors
package main
import (
"errors"
"fmt"
)
type HttpError struct {
code int
error
@theophoric
theophoric / struct_field_setting.go
Created March 11, 2014 00:13
setting dynamic content into struct
package main
import (
"fmt"
"reflect"
)
type Node struct {
Name string
Code int
@theophoric
theophoric / storage.go
Last active November 17, 2022 13:02
How to store + decode objects in golang using leveldb + gob
package main
import (
"bytes"
"encoding/gob"
"fmt"
"time"
"github.com/syndtr/goleveldb/leveldb"
)
@theophoric
theophoric / foos.go
Created April 17, 2014 17:20
custom slices
package main
import "fmt"
type foo int
type foos []foo
func (f foos) first() foo {
if len(f) == 0 {
@theophoric
theophoric / gist:11264841
Created April 24, 2014 18:36
password --> md5 hash ( hex-encoded )
node -e "console.log(require('crypto').createHash('md5').update('YOUR PASSWORD HERE','utf8').digest('hex'))"
@theophoric
theophoric / gist:d917551198035523d79a
Created June 11, 2014 20:28
reload osx audio kernal
sudo kextunload /System/Library/Extensions/AppleHDA.kext
sudo kextload /System/Library/Extensions/AppleHDA.kext
@theophoric
theophoric / gist:9cdf706fcf8da3d4440d
Created June 27, 2014 18:47
delete all local branches that have been merged with master
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d