Skip to content

Instantly share code, notes, and snippets.

View seiflotfy's full-sized avatar

Seif Lotfy seiflotfy

View GitHub Profile
func (cf *CuckooFilter) getComponents(data []byte) (uint, uint, []byte) {
hash := cf.getHash(data)
f := hash[0:cf.fingerprintSize]
i1 := uint(binary.BigEndian.Uint32(hash))
i2 := i1 ^ uint(binary.BigEndian.Uint32(cf.getHash(f)))
return i1, i2, f
}
package pmc
import (
"hash/fnv"
"math/rand"
"strconv"
)
func georand(w uint) uint8 {
hasher := fnv.New64a()
class Punkt
{
public:
// Overload + operator to add two Punkt objects.
Punkt operator+(const Punkt& p)
{
Punkt new_p;
new_p.x = x + p.x;
new_p.y = y + p.y;
return new_p;
local myset = ARGV[1]
local mykey = ARGV[3]
local set_length = tonumber(ARGV[2])
if redis.call('ZRANK', myset, mykey) then
redis.call('ZINCRBY', myset, 1.0, mykey)
elseif redis.call('ZCARD', myset) < set_length then
redis.call('ZADD', myset, 1.0, mykey)
else
local value = redis.call('ZRANGE', myset,0,0, 'withscores')
{
// you may set specific environment variables here
// e.g "env": { "PATH": "$HOME/go/bin:$PATH" }
// in values, $PATH and ${PATH} are replaced with
// the corresponding environment(PATH) variable, if it exists.
//"env": {"GOPATH": "$HOME/Projects/go:$HOME/Projects/go/src/github.com/originalilluminaughty/watchly/local/", "PATH": "$GOPATH/bin:$PATH" },
"env": {"GOPATH": "$HOME/Projects/go/:$HOME/Projects/go/src/github.com/skizzehq/skizze/:$HOME/Projects/go/src/github.com/skizzehq/skizze/vendor", "PATH": "$GOPATH/bin:$PATH" },
(pprof) top10
52MB of 52MB total ( 100%)
Dropped 38 nodes (cum <= 0.26MB)
Showing top 10 nodes out of 14 (cum >= 52MB)
flat flat% sum% cum cum%
35.50MB 68.27% 68.27% 52MB 100% github.com/golang/protobuf/proto.(*Buffer).dec_slice_string
16.50MB 31.73% 100% 16.50MB 31.73% github.com/golang/protobuf/proto.(*Buffer).DecodeStringBytes
0 0% 100% 52MB 100% datamodel/protobuf._Skizze_Add_Handler
0 0% 100% 52MB 100% github.com/golang/protobuf/proto.(*Buffer).Unmarshal
0 0% 100% 52MB 100% github.com/golang/protobuf/proto.(*Buffer).unmarshalType
(pprof) list protobuf
Total: 52MB
ROUTINE ======================== datamodel/protobuf._Skizze_Add_Handler in /Users/seif/Projects/go/src/github.com/skizzehq/skizze/src/datamodel/protobuf/skizze.pb.go
0 52MB (flat, cum) 100% of Total
. . 1052: return out, nil
. . 1053:}
. . 1054:
. . 1055:func _Skizze_Add_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
. . 1056: in := new(AddRequest)
. 52MB 1057: if err := dec(in); err != nil {
@seiflotfy
seiflotfy / Geeky Ogre
Created September 26, 2016 17:03
Geeky Ogre
Individual Contributor License Agreement (“Agreement”)
Thank you for your interest in the open source projects managed by Geeky Ogre, Inc. (“Geeky Ogre”). In
order to clarify the intellectual property license granted with Contributions from any person or
entity, Geeky Ogre must have a Contributor License Agreement (“CLA”) on file that has been signed
by each Contributor, indicating agreement to the license terms below. This license is for your
@seiflotfy
seiflotfy / trumpnumbers.go
Created September 27, 2016 02:18
Trump Number Generator - Go
package trumpnumbers
// The Trump number generator, requires a high seed to return a number > 0 and
// Trump numbers do not need to be tested, everybody loves it everybody thinks it great and it just works.
// Rand is a Trump random number generator. It implements the rand.Source interface.
type Rand struct {
State uint64
Inc uint64 // must be odd and >= 1000000000
}
#Make sure your intervals are sorted
A = [(1,2), (5,6), (6,8), (8,10)]
B = [(2,3), (8,9), (11, 18)]
print "A =", A
print "B =", B
def intersects(a, b):
start = max(a[0], b[0])
end = min(a[1], b[1])
return end - start >= 0