View setupGOROOT.sh
# | |
# Place this code to your .profile, .bashrc, .bash_profile or whatever | |
# | |
program_exists () { | |
type "$1" &> /dev/null ; | |
} | |
if program_exists go; then |
View gist:8353510
NSMutableArray *indexPathsToDelete = [NSMutableArray new]; | |
for (Object *object in newObjects) | |
{ | |
if (![currentObjects containsObject:object]) { | |
int row = [newObjects indexOfObject:object]; | |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0]; | |
[indexPathsToDelete addObject:indexPath]; | |
} | |
} |
View Bash script template without arguments.sh
# | |
# Without arguments: | |
# | |
#!/bin/bash -ex | |
main() | |
{ | |
# … | |
} |
View Bash test file exists.sh
if [ -f "$file" ]; then | |
echo "$file found." | |
fi | |
if [ ! -f "$file"]; then | |
echo "$file not found." | |
fi |
View Golang debug log.go
package main | |
import ( | |
"fmt" | |
"os" | |
) | |
func dlog(format string, args ...interface{}) { | |
fmt.Fprintf(os.Stderr, format, args...) | |
fmt.Fprintf(os.Stderr, "\n") |
View Golang file exists.go
package main | |
import "os" | |
func fileExists(reqFilePath string) bool { | |
_, err := os.Stat(reqFilePath) | |
exists := false | |
if err == nil { | |
exists = true | |
} else { |
View Golang interface conversions.go
package main | |
import "strconv" | |
func interfaceToFloat(value interface{}) float64 { | |
if value == nil { | |
return 0.0 | |
} | |
switch typedValue := value.(type) { | |
case float64: |
View Golang iterate files.go
package main | |
import ( | |
"log" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
searchDir, err := os.Getwd() |
View Golang mysql -B output processing.go
package main | |
import ( | |
"bufio" | |
"log" | |
"os" | |
"strings" | |
) | |
func main() { |
View Golang program with single argument.go
package main | |
import ( | |
"fmt" | |
"os" | |
"flag" | |
"path/filepath" | |
) | |
func usage() { |
OlderNewer