Skip to content

Instantly share code, notes, and snippets.

View xlab's full-sized avatar
:octocat:
Hacking

Max Kupriianov xlab

:octocat:
Hacking
View GitHub Profile
@xlab
xlab / keybase.md
Created October 1, 2014 14:27
Keybase proof

Keybase proof

I hereby claim:

  • I am xlab on github.
  • I am xlab (https://keybase.io/xlab) on keybase.
  • I have a public key whose fingerprint is 8F39 7B4E 96AB 1977 5C15 C3C6 DE3F 4FEA 5B0A DCE5

To claim this, I am signing this object:

<snippet>
<content><![CDATA[
type ${1:type}s []*${1:type}
func (s ${1:type}s) Len() int { return len(s) }
func (s ${1:type}s) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s ${1:type}s) Less(i, j int) bool { return s[i].${2:field} < s[j].${2:field} }
]]></content>
<tabTrigger>gosort</tabTrigger>
<scope>source.go</scope>
@xlab
xlab / mapred_builtins.js
Created September 5, 2014 22:19
Riak MapReduce built-in functions
/** Helper functions start **/
var RiakHelper = function() {
return {
numericSorter: function(first, second) {
return first - second;
}
};
}();
@xlab
xlab / floatpoint_golang_mk802.txt
Last active August 29, 2015 14:04
mk802 notes
$ go test -bench=BenchmarkUint -run=XXX
PASS
BenchmarkUint32Div7 20000000 126 ns/op
BenchmarkUint32Div37 20000000 126 ns/op
BenchmarkUint32Div123 20000000 126 ns/op
BenchmarkUint32Div763 20000000 126 ns/op
BenchmarkUint32Div1247 20000000 126 ns/op
BenchmarkUint32Div9305 20000000 126 ns/op
BenchmarkUint32Div13307 20000000 126 ns/op
BenchmarkUint32Div52513 20000000 126 ns/op
@xlab
xlab / gist:f424553333847db9f4cf
Last active August 29, 2015 14:04
Convert c-array int32[] to go-slice []int32
func arrayToSliceInt32(ptr unsafe.Pointer, size int) (ints []int32) {
hdr := reflect.SliceHeader{
Data: uintptr(ptr),
Len: size,
Cap: size,
}
cints := *(*[]int32)(unsafe.Pointer(&hdr))
ints = make([]int32, size)
// TODO: bech this
copy(ints, cints)
@xlab
xlab / products.go
Last active June 21, 2017 18:52
Example of calling the Google's Merchant API (content scope) from Go lang.
// Package products is an example of calling the Google's Merchant API (content scope) from Go lang.
package products
import (
"strconv"
"code.google.com/p/goauth2/oauth"
"code.google.com/p/google-api-go-client/content/v2"
)
@xlab
xlab / smscloud.yaml
Last active August 29, 2015 14:04
cloud-configs
#cloud-config
hostname: smscloud1
ssh_authorized_keys:
- ssh-rsa: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDU/iKFrHQh6/y7QJyeVDJTUjD3u6dlhgLf2SE2pOfdIx9YL06zudlKikR5VekX2hEltdO87XTPOp/yCslC/dHMtndhYQV/gmlCQRbeugI7sg1FcCLjllA8Uiw5UskUUjas9Od1VACzLIC4E1u24JSCJTkz7IonhIrhWTcZAfGxIP/dVQqdBOFjNGSxjSoRZgHsQE8WMQ1oQqBIzZqre0f9VvaB6Q4zKSC0bOQR30CreB6+XdB6NsetQ9pwzQAswXtf1wSj8S8ekic1NCgont1SlxMmF6lH0gDVKNBXkC3o1X063N/N0IxypUdgxp7kzcca3kxv+bIsAeXylXRnmGH9
users:
- name: xlab
coreos-ssh-import-github: xlab
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b8ea]
runtime stack:
runtime.panic(0x4f2980, 0x671578)
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/runtime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x6fcaef11
goroutine 4 [syscall]:
@xlab
xlab / gist:e3982b2f44319a44ebb9
Created May 1, 2014 00:39
.ObjectByName("ctrl")
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b60a]
runtime stack:
runtime.panic(0x4f2780, 0x671578)
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/runtime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x6fcaef11
goroutine 4 [syscall]:
@xlab
xlab / gist:e09445cee8a25d07dd2a
Created May 1, 2014 00:37
.Property("ctrl")
panic: invalid memory address or nil pointer dereference
fatal error: panic during malloc
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x41b5ea]
runtime stack:
runtime.panic(0x4f2760, 0x671578)
C:/Users/ADMINI~1/AppData/Local/Temp/2/makerelease529514319/go/src/pkg/runtime/panic.c:233 +0x2b
runtime: unexpected return pc for runtime.sigpanic called from 0x6fcaef11
goroutine 4 [syscall]: