Skip to content

Instantly share code, notes, and snippets.

@reklis
reklis / Example.cpp
Created September 15, 2015 19:40
reliability-and-flow-control
/*
Reliability and Flow Control Example
From "Networking for Game Programmers" - http://www.gaffer.org/networking-for-game-programmers
Author: Glenn Fiedler <gaffer@gaffer.org>
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
@imjasonh
imjasonh / markdown.css
Last active May 24, 2024 22:56
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@maxpert
maxpert / hash_test.go
Created March 16, 2015 02:18
JumpConsistentHash
package main
import "fmt"
type hash_function func (uint64, int32) int32
func main() {
for j := 1; j < 32; j++ {
simulate_rebalance("JumpConsistentHash", 32, int32(32 + j), JumpConsistentHash)
simulate_rebalance("ModConsistentHash", 32, int32(32 + j), ModConsistentHash)
@denji
denji / golang-tls.md
Last active May 29, 2024 10:16 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
package httptimeout
import (
"net/http"
"time"
"fmt"
)
type TimeoutTransport struct {
http.Transport
@cloudwu
cloudwu / dh.c
Last active June 19, 2022 15:38
Diffie-Hellman Key Exchange
// The biggest 64bit prime
#define P 0xffffffffffffffc5ull
#define G 5
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <stdlib.h>
// calc a * b % p , avoid 64bit overflow
@yuitest
yuitest / rainbow
Last active December 30, 2015 16:59
いえい!
#!/usr/bin/env dash
base64 -d <<__EOH__ | exec gzip -dc
H4sIAK1zzVIAA7VaUXajMAx8+c0V+sMRYCHk5XGUPQP3/900JViWZiTZ6farxa5tzUgjWTAM8ufr
77jNy3bblnGbxnH/eXATD85Zk3z4ejLW/7cPnT9XdZ5Rn2eyB1wmOTY9xya5v551UytM37s8xm1Z
ytH18w6bTksOO47lvyFe9M7jTtEPjAP2LZqKaqv1mHV//QrHECCd/J1LTefS0/aYElYNcD4z4w3D
2nPo95k1UcbV4GFfI7MYqc4972LC/Jww7/L/tC8WeyLS5h5+roAZai2NE85d0vTCVtZ6OfwOorXT
emh+bFzOtmPWvD3mMusuf9XKueon3McbA3kn9uZguxaehJcYh2U41QhonDxYIu4dDUhgpCWiflZv
3Kop1zOJeooeAMj0xAFUoznrPeRsPAOEImHkjhyXJbaCYkXSgWYdydZ9FTd1IDRIwLU4slvdYB2c
7Rxh+oX4q0YY+CRC/P58cLeIw5OZ8mF6/RqKK4uT9kpBpd/WwkEUC71bt0NpZlwEeBdSBruaAyes
@artyom
artyom / epoll.go
Created November 1, 2013 12:21
Using epoll from Go.
package main
import (
"log"
"os"
"syscall"
)
func main() {
f, err := os.Open("/tmp/pipe")
@dmichael
dmichael / httpclient.go
Last active October 18, 2023 20:07
Light wrapper for the Go http client adding (essential) timeouts for both connect and readwrite.
package httpclient
import (
"net"
"net/http"
"time"
)
type Config struct {
ConnectTimeout time.Duration
@renexu
renexu / iparesign
Last active December 17, 2015 10:49
#!/usr/bin/env bash
if [[ ! ( # any of the following are not true
# 1st arg is an existing regular file
-f "$1" &&
# ...and it has a .ipa extension
"${1##*.}" == "ipa" &&
# 2nd arg is an existing regular file
-f "$2" &&
# ...and it has an .mobileprovision extension