Skip to content

Instantly share code, notes, and snippets.

@nickng
nickng / main_test.go
Last active February 5, 2020 13:18
Abstraction has a cost
package main
import (
"testing"
)
func BenchmarkIface(b *testing.B) {
var (
sum int
x interface{} = 1
@nickng
nickng / ptr_sendrecv.go
Created November 7, 2017 10:57
A fast and unsafe send/receive using pointer
type Buffer struct {
ptr unsafe.Pointer
}
// Send is a generic sending function that sends val through the Buffer b.
func (b *Buffer) Send(val interface{}) {
b.ptr = unsafe.Pointer(&val)
}
// Recv is a generic receiving function that receives from Buffer b and writes
@nickng
nickng / keybase.md
Created October 24, 2017 10:52
Keybase

Keybase proof

I hereby claim:

  • I am nickng on github.
  • I am nicholascwng (https://keybase.io/nicholascwng) on keybase.
  • I have a public key ASAeVW4C2J8RXuzsxaqovGie-KBqvuAS9x8WjmPxUjcsmwo

To claim this, I am signing this object:

@nickng
nickng / git-outofmyway.sh
Last active September 11, 2017 16:40
git outofmyway: Alias to get remote changes from git preserving log history as much as possible
#!/bin/sh
. "$(git --exec-path)/git-sh-setup"
# git outofmyway
_oomw() {
REMOTE="origin"
if [ "$#" = "1" ]
then
REMOTE="$1"
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include <unistd.h>
#define MAX 30000
#define TAG 0
int main(int argc, char *argv[])
{
@nickng
nickng / Deminified bookmarklet.js
Created July 6, 2013 11:17
Mendeley Web Import
(function (root, factory) {
if (typeof exports == "object") module.exports = factory();
else if (typeof define == "function" && define.amd) define(factory);
else root.Spinner = factory()
})(this, function () {
var prefixes = ["webkit", "Moz", "ms", "O"],
animations = {}, useCssAnimations;
function createEl(tag, prop) {
var el = document.createElement(tag || "div"),
@nickng
nickng / P_A.spr
Created July 20, 2012 13:03
Session C broadcast
local protocol P at A(role B) {
}