Skip to content

Instantly share code, notes, and snippets.

View c4milo's full-sized avatar
:octocat:

Camilo Aguilar c4milo

:octocat:
View GitHub Profile
@creationix
creationix / convert.js
Last active March 31, 2020 07:15
Convert a hex string (base-16) to a base-65536 (16-bit) string.
function hexToBase65536(hex) {
var result = "";
for (var i = hex.length ; i > 0; i -= 4) {
result += String.fromCharCode(parseInt(hex.substring(i - 4, i), 16));
}
return result;
}
@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

Consul Consistency

As Kyle brought up, Consul at the moment has a single known case of a potential inconsistency (Could be unknown cases lurking). Currently Consul works by electing a leader, who "leases" the position for LeaderLeaseTimeout interval. At each interval, it checks that a quorum of nodes still believes it to be the leader. At the same time, if a follower does not hear from the leader within randomInterva(HeartbeatTimeout, 2 * HeartbeatTimeout), it will start a new election.

package main
import (
"fmt"
"math/rand"
"strconv"
"time"
"github.com/octplane/mnemo"
)
@c4milo
c4milo / ejabberd.conf
Created May 18, 2014 18:47
Upstart script for Ejabberd
# Ubuntu upstart file at /etc/init/ejabberd.conf
respawn
respawn limit 20 5
start on runlevel [2345]
stop on runlevel [06]
script
exec start-stop-daemon --start --name ejabberd --user ejabberd --chuid ejabberd --exec /usr/local/sbin/ejabberdctl -- start
@jakejscott
jakejscott / server.go
Created May 20, 2014 00:53
negroni + httprouter
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/julienschmidt/httprouter"
"net/http"
)
func main() {
@paulirish
paulirish / args.gn
Last active May 17, 2024 00:09
How to build Chromium to hack on DevTools
# Build arguments for the gn build
# You can set these with `gn args out/Default`
# ( and they're stored in src/out/Default/args.gn )
# See "gn args out/Default --list" for available build arguments
# component build, because people love it
is_component_build = true
# release build, because its faster
is_debug = true
@indexzero
indexzero / README.md
Last active August 29, 2015 14:12
Myo C++ Header files. Who wants to write a node binding for this?

The state of Myo bindings in Node.js

... any takers? Comment on this gist! The discussion all started from a Tweet:

Who's going to be the first to write a wrapper for the @thalmic #myo C++ library? Latest headers: https://gist.github.com/indexzero/60d1224f0082f0d16f14

As pointed out by @c4milo there are a number of libraries that exist, but from first glance they all have deficiencies:

@ryanuber
ryanuber / raft-boltdb
Last active August 29, 2015 14:14
Raft backend benchmarks
BenchmarkBoltStore_FirstIndex-5 1000000 1932 ns/op
BenchmarkBoltStore_LastIndex-5 1000000 1907 ns/op
BenchmarkBoltStore_GetLog-5 300000 5931 ns/op
BenchmarkBoltStore_StoreLog-5 5000 266819 ns/op
BenchmarkBoltStore_StoreLogs-5 5000 300801 ns/op
BenchmarkBoltStore_DeleteRange-5 5000 322467 ns/op
BenchmarkBoltStore_Set-5 10000 247162 ns/op
BenchmarkBoltStore_Get-5 1000000 2176 ns/op
BenchmarkBoltStore_SetUint64-5 10000 240333 ns/op
BenchmarkBoltStore_GetUint64-5 1000000 2209 ns/op
@nhocki
nhocki / aho_corasick.cpp
Created April 2, 2015 04:00
Aho-Corasick Algorithm in C++
///////////////////////////////////////////////////////////////
// Aho-Corasick's algorithm, as explained in //
// http://dx.doi.org/10.1145/360825.360855 //
///////////////////////////////////////////////////////////////
// Max number of states in the matching machine.
// Should be equal to the sum of the length of all keywords.
const int MAXS = 6 * 50 + 10;
// Number of characters in the alphabet.