Skip to content

Instantly share code, notes, and snippets.

View DrGo's full-sized avatar
💭
Palm oil. know the facts!

DrGo

💭
Palm oil. know the facts!
View GitHub Profile
@jmcarbo
jmcarbo / install_golang.sh
Last active April 12, 2016 14:10
Install golang
sudo apt-get update -y && sudo apt-get install -y -q curl build-essential ca-certificates git mercurial bzr
sudo mkdir -p /goroot && sudo chown -R `whoami` /goroot && curl https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1
sudo mkdir -p /gopath && sudo chown -R `whoami` /gopath
export GOROOT=/goroot
export GOPATH=/gopath
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
echo "export GOROOT=/goroot" >> ~/.profile
echo "export GOPATH=/gopath" >> ~/.profile
echo "export PATH=$PATH:$GOROOT/bin:$GOPATH/bin" >> ~/.profile
@jpillora
jpillora / csrand.go
Last active April 12, 2016 23:46
Hash DRBG implementation in Go (Golang) from the TOR project
/*
* Copyright (c) 2014, Yawning Angel <yawning at torproject dot org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
// Package lex implements the lexical scanner for Suneido
package lex
import (
"bytes"
"strings"
"unicode"
"unicode/utf8"
)
@infogulch
infogulch / multisort.go
Last active May 6, 2016 23:59
How to design a Go slice type that needs to be sortable in many ways.
// How to design a Go slice type that needs to be sortable in many ways.
package main
import (
"fmt"
"sort"
)
type data struct {
i int
@tmaiaroto
tmaiaroto / pre-commit
Last active July 30, 2016 22:29
A Go Commit Hook for Less Future Headaches
#!/bin/bash
#
# Check a "few" things to help write more maintainable Go code.
#
# OK, it's fairly comprehensive. So simply remove or comment out
# anything you don't want.
#
# Don't forget to install (go get) each of these tools.
# More info at the URLs provided.
#
@w7dup
w7dup / diff.go
Created April 20, 2013 15:03
Go: Working through the diff algorithms from Myers "An O(ND) Difference Algorithm and Its Variations"
package main
import "fmt"
/*******************************************************************************
* Reference:
* An O(ND) Difference Algorithm and Its Variations
* Eugene W. Myers
*******************************************************************************/
@nucleartide
nucleartide / explicit.js
Last active March 25, 2019 15:08
Explicit Go-style error handling with ES6 destructuring. No more try-catch!
function explicit(ctx, fn) {
return function() {
try {
const result = fn.apply(ctx, arguments)
return [null, result]
} catch (err) {
return [err, null]
}
}
@shaunlee
shaunlee / dblayer.go
Last active January 28, 2020 19:24
Golang database layer
package main
import (
"fmt"
"strings"
"database/sql"
)
const (
SQL_INSERT = "INSERT INTO %s (%s) VALUES (%s)"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Amir Salihefendic
" http://amix.dk - amix@amix.dk
"
" Version:
" 5.0 - 29/05/12 15:43:36
"
" Blog_post:
" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github
@iamralch
iamralch / searchr.go
Created July 11, 2015 11:50
searchr - a sample application that works with pipes
package main
import (
"bufio"
"flag"
"fmt"
"io"
"os"
"strings"
)