Skip to content

Instantly share code, notes, and snippets.

View surma's full-sized avatar
🍑

Surma surma

🍑
View GitHub Profile
@surma
surma / list.go
Created June 21, 2011 12:43
Unexpected behaviour of go linker?
package list
var List map[string]string = make(map[string]string)
@surma
surma / loop.php
Created August 7, 2011 19:00
Peter's Liste
<!-- SNIP -->
<ul id="sources" class="meta_categories">
<?php
function getFormattedCategory($category, $show_count) {
$link = get_category_link($category->term_id);
$result = "<a href=\"".$link."\">".$category->name."</a>";
if($show_count) {
$result .= "(".$category->count.")";
}
if($category->category_description != "") {
@surma
surma / .bash_profile
Created September 14, 2011 10:32
Bash Prompt Code
# Colors
COLOR_WHITE='\033[1;37m'
COLOR_LIGHTGRAY='\033[0;37m'
COLOR_GRAY='\033[1;30m'
COLOR_BLACK='\033[0;30m'
COLOR_RED='\033[0;31m'
COLOR_LIGHTRED='\033[1;31m'
COLOR_GREEN='\033[0;32m'
COLOR_LIGHTGREEN='\033[1;32m'
COLOR_BROWN='\033[0;33m'
#if UNITY_EDITOR
private static void _init(string AppId) {}
private static void _authorize(int permissions) {getInstance().loggedOut();}
private static void _logout() {getInstance().loggedOut();}
private static void _graphRequest(string methodname, string[] param, string method) {getInstance().requestFailed("Not implemented");}
private static void _deleteSession() {}
#elif UNITY_IPHONE
[System.Runtime.InteropServices.DllImport("__Internal")]
extern static private void _init(string AppId);
[System.Runtime.InteropServices.DllImport("__Internal")]
@surma
surma / Makefile
Created December 23, 2011 17:08
Cgo Testcase
include $(GOROOT)/src/Make.inc
TARG=testcase
CGOFILES=\
testcase.go\
CGO_OFILES=\
testcase.o\
@surma
surma / gist:3104871
Created July 13, 2012 13:24
Single-Line-Ifs
//...
func conditionalFailf(w http.ResponseWriter, fail bool, code int, format string, v ...interface{}) bool {
if fail {
log.Printf(format, v...)
http.Error(w, fmt.Sprintf(format, v...), code)
}
return fail
}
@surma
surma / github_forall.sh
Created August 6, 2012 23:22
Journey to my own Android ROM

Motivation

  • Make testing new releases easy for me. No tedious reinstalling of my common apps
  • Some graphical customizations for nerdcred
  • Ability to patch things
  • Deeper understanding

Plan

  • Be as vanilla as possible for easy version upgrade
@surma
surma / code.go
Created August 17, 2012 21:34
Embed extension for gist.io
package main
import "fmt"
func main() {
fmt.Println("Hello World")
}
@surma
surma / crosscompile.sh
Last active October 11, 2015 18:08
Cross-Compiler-Script for Go projects
#!/bin/bash
PLATFORMS=${PLATFORMS:-"darwin/amd64 linux/amd64"}
APPNAME=${1:-$(basename `pwd`)}
README=${2:-README.md}
VERSION=$(cat $README | tail -n4 | grep -i Version | cut -d' ' -f2)
for platform in $PLATFORMS; do
export GOOS=$(echo $platform | cut -d/ -f1)
export GOARCH=$(echo $platform | cut -d/ -f2)
@surma
surma / runme.sh
Created November 26, 2012 19:34
Go Crosschain builder
#!/bin/bash
cd $GOROOT/src
./clean.bash
for GOOS in darwin linux openbsd freebsd netbsd plan9; do
for GOARCH in 386 amd64; do
GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 ./make.bash --no-clean
done
done
unset GOOS