Skip to content

Instantly share code, notes, and snippets.

View aybabtme's full-sized avatar
👶
I may be slow to respond. Newborn in the house.

Antoine Grondin aybabtme

👶
I may be slow to respond. Newborn in the house.
View GitHub Profile
@aybabtme
aybabtme / ring_election.go
Created November 23, 2013 22:52
Attempt at describing the ring election algorithm described in assignment 4 of CSI3505...
package main
type Phase int
var (
// Track how many phases necessary
phase = Phase(0)
)
// States
double[] genVArr(int n, double timeStep, int[] configuration) {
double[] output = new double[n];
double currentTime = timeStep;
for (int i = 0; i < n; i++) {
output[i] = v(currentTime, configuration)
currentTime += timeStep;
}
return output;
}
@aybabtme
aybabtme / to_buffer_or_not_to_buffer.go
Last active December 27, 2015 15:39
Quick measurement of performance given various buffering size when reading/writing a file sequentially. For demo purpose.
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/dustin/go-humanize"
"github.com/gonum/plot"
"github.com/gonum/plot/plotter"
"github.com/gonum/plot/plotutil"
<!DOCTYPE html>
<html>
<head>
<title>Value cannot be null.<br>Parameter name: s</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
@aybabtme
aybabtme / gist:7094937
Last active December 26, 2015 04:39
How To Get In Viet Nam

How To Get In Viet Nam

La [version française est ici][french].

Here I write quickly about the basics you should be aware of.

Background

Viet Nam is a developing country, so there are a lot of things that will look sketchy to you when dealing with getting there, and once you get there.

Also, if you've never been in a developing country before, you might want to read a bit about Viet Nam before getting there. There are many things you take for granted as normal behaviour that aren't necessarily something you should do there. For instance:

Comment Aller Au Viet Nam

[English version here][eng].

Un petit guide de trucs de base que vous devriez savoir.

Vous devriez être capable de communiquer en anglais pour aller au Viet Nam, les gens ne parlent pas français là-bas. Certains pensent que parce que c'est une ancienne colonie française, les gens parlent français. Non, sauf quelques rares exceptions.

Préambule

Le Viet Nam est un pays en voie de développement, donc il y a plusieurs chose qui vont avoir l'air louche quant vous allez procéder à vous rendre là, ainsi que quand vous allez être là.

package main
import (
"bytes"
"fmt"
"strconv"
)
type Node struct {
next *Node
@aybabtme
aybabtme / Main.java
Created October 10, 2013 03:27
Pseudo functional programming in Java
public class Main {
// Pseudo lambda
public interface Operation {
double apply(double arg);
}
// Takes in pseudo-lambda
public static double times(Operation toApply, int times) {
double result = 1.0;
package main
import (
"strconv"
"testing"
)
func Benchmark_LookupBeforeWrite_FullMap(b *testing.B) {
testMap := fillWholeMap(b.N)
@aybabtme
aybabtme / gist:5930862
Last active December 19, 2015 09:09
gocov panic
% gocov test
2013/07/04 19:52:31 Concurrent N=5
2013/07/04 19:52:31 Test - Sequence of operations by group, concurrent request in each groups
2013/07/04 19:52:31 Put operations
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x38 pc=0xc407b]
goroutine 7 [running]:
sync/atomic.AddUint32()
/Users/antoine/go/src/pkg/sync/atomic/asm_amd64.s:44 +0xb