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
func IsInSlice(slice []int, searching int) bool { | |
intSlice := make(sort.IntSlice, len(slice)) | |
copy(intSlice, slice) | |
sort.Sort(intSlice) | |
return sort.SearchInts(intSlice, searching) < len(slice) | |
} |
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 | |
/* | |
#cgo CFLAGS: -x objective-c | |
#cgo LDFLAGS: -framework Cocoa | |
#import <Cocoa/Cocoa.h> | |
int | |
StartApp(void) { | |
[NSAutoreleasePool new]; |
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
func SetProcessName(name string) error { | |
argv0str := (*reflect.StringHeader)(unsafe.Pointer(&os.Args[0])) | |
argv0 := (*[1 << 30]byte)(unsafe.Pointer(argv0str.Data))[:argv0str.Len] | |
n := copy(argv0, name) | |
if n < len(argv0) { | |
argv0[n] = 0 | |
} | |
// Syscall PRCTL, not working on Darwin for me |
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
Vagrant::Config.run do |config| | |
# ssh settings: | |
config.ssh.private_key_path = "~/.ssh/vagrant.key" | |
config.ssh.max_tries = 5 | |
config.ssh.timeout = 10 | |
# default port forwarding | |
config.vm.forward_port('ssh', 22, 2222, :auto => true) |
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
func(t reflect.Type) { | |
log.Printf("%+v", t.Field(0).Tag.Get("woot")) | |
}(reflect.TypeOf(Dummy{1})) |
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
file, err := os.Create("go.cprof") | |
if err != nil { | |
log.Fatal(err) | |
} | |
pprof.StartCPUProfile(file) | |
// ... | |
pprof.StopCPUProfile() |
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
# Let's figure out what we have in the beggning | |
git fsck --full --strict --unreachable | |
git count-objects -v | |
# Filter ALL branches deleteing `db/seeds_assets` | |
git filter-branch -f --tree-filter 'rm -rf db/seeds_assets' -- --all | |
# Remove original reflogs | |
rm -rf .git/refs/original/ |
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
#... | |
gem 'backup', require: false, | |
github: 'kavu/backup', | |
branch: 'bump_fog_version', | |
ref: 'c3fd8e6eb4f464de1c8' | |
gem 'whenever', require: false | |
#... |
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
build_package_combined_patch() { | |
local package_name="$1" | |
{ | |
curl https://github.com/funny-falcon/ruby/compare/p385...p385_falcon.diff | patch -p1 | |
autoconf | |
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS | |
make -j 8 | |
make install | |
} >&4 2>&1 | |
} |
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
require 'minitest/autorun' | |
class MyClass | |
def initialize | |
@a = 1 | |
end | |
def a | |
"not a 1" | |
end |