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
@ivanzoid
ivanzoid / gist:8353510
Last active March 24, 2021 15:03
Insert & delete rows in UITableView with animation
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];
}
}
#
# 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 "os"
func fileExists(reqFilePath string) bool {
_, err := os.Stat(reqFilePath)
exists := false
if err == nil {
exists = true
} else {
package main
import "strconv"
func interfaceToFloat(value interface{}) float64 {
if value == nil {
return 0.0
}
switch typedValue := value.(type) {
case float64:
package main
import (
"log"
"os"
"path/filepath"
)
func main() {
searchDir, err := os.Getwd()
package main
import (
"bufio"
"log"
"os"
"strings"
)
func main() {
package main
import (
"fmt"
"os"
"flag"
"path/filepath"
)
func usage() {