View lmdb.tcl
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
# LVDB - LLOOGG Memory DB | |
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com> | |
# All Rights Reserved | |
# TODO | |
# - cron with cleanup of timedout clients, automatic dump | |
# - the dump should use array startsearch to write it line by line | |
# and may just use gets to read element by element and load the whole state. | |
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands. | |
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump! |
View install-protoc-macos-macports.sh
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
sudo port install automake libtool autogen autoconf | |
wget https://github.com/protocolbuffers/protobuf/archive/v3.14.0.tar.gz | |
tar -xzvf protobuf-3.14.0.tar.gz | |
cd protobuf-3.14.0 | |
./autogen.sh | |
./configure | |
make | |
sudo make install | |
go install google.golang.org/protobuf/cmd/protoc-gen-go # run outside of project with module, add $GOBIN to $PATH |
View vm-setup.sh
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
#!/bin/bash -e | |
echo ' | |
PATH=$HOME/go/bin:$PATH | |
export GOPATH=$HOME | |
export CDPATH=.:$HOME/src/golang.org/x:$HOME/go/src:$HOME/src/github.com:$HOME/src/github.com/nf:$HOME/src/github.com/adg | |
export EDITOR=vim | |
' >> ~/.profile | |
sudo apt-get update |
View skiplist.go
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
// Implementation of a SkipList using the original paper's algorithm: | |
// https://15721.courses.cs.cmu.edu/spring2018/papers/08-oltpindexes1/pugh-skiplists-cacm1990.pdf | |
// | |
// Example usage: | |
// sl := db.NewSkipList() | |
// sl.Insert([]byte("foo"), []byte("bar")) | |
// sl.Insert([]byte("foo"), []byte("world")) | |
// fmt.Println(string(sl.Search([]byte("foo")))) | |
// | |
package db |
View sqlite_table_valued.py
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
from peewee import * | |
from playhouse.sqlite_ext import TableFunction | |
import json | |
# https://github.com/coleifer/peewee/ | |
# Basic connection and sql execution | |
db = SqliteDatabase('foo.db') | |
db.connect() | |
db.execute_sql( | |
"CREATE TABLE IF NOT EXISTS pageAds (pageid STRING, adid_list JSON);") |
View kpuHJCy8.go
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 (l *list) Remove(item []byte) bool { | |
key, _ := hashstructure.Hash(item, nil) | |
l.head.lock() | |
pred := l.head | |
curr := pred.next | |
curr.lock() | |
for curr.key < key { | |
pred.unlock() |
View 6sgN7riQ.go
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 (l *list) Add(item []byte) bool { | |
key, _ := hashstructure.Hash(item, nil) | |
l.head.lock() | |
pred := l.head | |
curr := pred.next | |
curr.lock() | |
// Displace locks during each iteration. | |
// We keep the lock for curr when unlocking pred. |
View U8fs+UoJ.go
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
type node struct { | |
mu sync.Mutex | |
item []byte | |
key uint64 | |
next *node | |
} | |
func (n *node) lock() { | |
n.mu.Lock() | |
} |
View VCqDGiuN.go
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 | |
import ( | |
"fmt" | |
"sortedlist/coarselist" | |
"sync" | |
) | |
func main() { | |
l := coarselist.New() |
View eaU5rn8d.go
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 (l *list) Add(item []byte) bool { | |
var pred, curr *node | |
key, _ := hashstructure.Hash(item, nil) | |
l.mu.Lock() | |
defer l.mu.Unlock() | |
pred = l.head | |
curr = pred.next | |
for curr.key < key { |
NewerOlder