Skip to content

Instantly share code, notes, and snippets.

@mediocregopher
mediocregopher / panic_test.go
Last active February 4, 2019 19:53
this benchmark panics on arm64
package panicker
import (
"runtime"
. "testing"
"github.com/mediocregopher/radix/v3"
)
func BenchmarkPanic(b *B) {
package main
import (
"log"
"time"
"github.com/mediocregopher/mediocre-go-lib/mrand"
radix "github.com/mediocregopher/radix.v3"
)
0xC34976Ee7A9dAD5d4F1802C190B0967E58b137F0
@mediocregopher
mediocregopher / brainfuck.rs
Created June 16, 2016 04:36
Simple implementation of a brainfuck interpreter in rust
/*
[dependencies]
clap = "2"
*/
extern crate clap;
use clap::{Arg, App};
use std::num::Wrapping;
use std::io::Read;
@mediocregopher
mediocregopher / brpc.go
Created June 15, 2016 23:40
An RPC system from Go inspired by the http.Handler system
// Package brpc, stands for better-rpc. It's better than normal RPC, because it
// allows for saner chaining of rpc handlers
package brpc
import (
"encoding/json"
"net/http"
"golang.org/x/net/context"
)
@mediocregopher
mediocregopher / client.go
Last active June 8, 2016 17:39
Example of a TLS echo server and client which also use the PROXY protocol
package main
import (
"crypto/tls"
"fmt"
"io"
"log"
"net"
"os"
)
@mediocregopher
mediocregopher / go-deps-refs.sh
Created February 1, 2016 21:11
Prints out the revisions of all checked out dependencies of a go project that can be found in GOPATH
#!/bin/sh
function printDep {
dep="$1"
if [ "$dep" == "." ]; then return 0; fi
cd "$GOPATH/src/$dep"
if [ -d ".git" ]; then
echo "$dep (git) - $(git log --abbrev-commit --oneline -n 1)"
return 0
package main
import (
"fmt"
)
type Set map[interface{}]bool
func Intersection(s1, s2 Set) Set {
rs := Set{}
@mediocregopher
mediocregopher / deets.md
Last active December 28, 2015 22:59 — forked from MarcoPolo/deets.md

Cryptic's Crypto Details:

Registration

In-browser

  • The user chooses a username and password
  • A pub/priv key is generated and stored in a structure called the user blob. (A user will have the option to upload their own set of keys too)
  • The user blob also contains a file tree which will store uploaded files (with their encryption key) and folders (for organizing files).
  • The user blob is encrypted with the PBKDF2 hash of the user's password.
user> (def fiz (cycle [nil nil "Fiz"]))
#'user/fiz
user> (def buzz (cycle [nil nil nil nil "Buzz"]))
#'user/buzz
user> (take 15 (map (partial apply str) (map list fiz buzz)))
("" "" "Fiz" "" "Buzz" "Fiz" "" "" "Fiz" "Buzz" "" "Fiz" "" "" "FizBuzz")