Skip to content

Instantly share code, notes, and snippets.

@ivanzoid
ivanzoid / setupGOROOT.sh
Created August 26, 2012 10:43
Aumatically setup $GOROOT in HomeBrew
#
# Place this code to your .profile, .bashrc, .bash_profile or whatever
#
program_exists () {
type "$1" &> /dev/null ;
}
if program_exists go; then
#
# Without arguments:
#
#!/bin/bash -ex
main()
{
# …
}
//usr/bin/env go run $0 -- "$@"; exit $?
//
// Use this script to maintain a set of github gists as files.
//
// Usage:
// - install 'gist' program (https://github.com/defunkt/gist)
// - make sure you have Go (https://golang.org) installed
// - make a folder somewhere where you want to store your gists.
// - place gist-update.go (https://gist.github.com/ivanzoid/611177bbd3f5cb0604810f07080757b3#file-gist-update-go) to this folder
# Bash compare strings
if [ "$x" = "valid" ]; then
echo "x has the value 'valid'"
fi
if [ "$x" != "valid" ]; then
echo "x has the value 'valid'"
fi
program_exists () {
type "$1" &> /dev/null ;
}
if ! program_exists foo; then
echo "Please install foo"
exit 2
fi
#!/bin/bash -ex
usage()
{
local PROG_NAME=`basename $0`
echo "Usage: $PROG_NAME params"
}
main()
{
#
# Without arguments:
#
#!/bin/bash -ex
main()
{
# …
}
if [ -f "$file" ]; then
echo "$file found."
fi
if [ ! -f "$file"]; then
echo "$file not found."
fi
package main
import (
"fmt"
"os"
)
func dlog(format string, args ...interface{}) {
fmt.Fprintf(os.Stderr, format, args...)
fmt.Fprintf(os.Stderr, "\n")
package main
import (
"fmt"
"strings"
"strconv"
"errors"
)
func determineImageDimensions(fileName string) (width, height uint64, err error) {