This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
"strconv" | |
"errors" | |
) | |
func determineImageDimensions(fileName string) (width, height uint64, err error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func dlog(format string, args ...interface{}) { | |
fmt.Fprintf(os.Stderr, format, args...) | |
fmt.Fprintf(os.Stderr, "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -f "$file" ]; then | |
echo "$file found." | |
fi | |
if [ ! -f "$file"]; then | |
echo "$file not found." | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Without arguments: | |
# | |
#!/bin/bash -ex | |
main() | |
{ | |
# … | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
usage() | |
{ | |
local PROG_NAME=`basename $0` | |
echo "Usage: $PROG_NAME params" | |
} | |
main() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program_exists () { | |
type "$1" &> /dev/null ; | |
} | |
if ! program_exists foo; then | |
echo "Please install foo" | |
exit 2 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Without arguments: | |
# | |
#!/bin/bash -ex | |
main() | |
{ | |
# … | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Place this code to your .profile, .bashrc, .bash_profile or whatever | |
# | |
program_exists () { | |
type "$1" &> /dev/null ; | |
} | |
if program_exists go; then |
NewerOlder