Skip to content

Instantly share code, notes, and snippets.

@jonhoo
jonhoo / README.md
Last active Jul 19, 2021
Distributed RWMutex in Go
View README.md
@addyosmani
addyosmani / README.md
Last active Jan 19, 2022 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger
View README.md

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@mattdesl
mattdesl / gist:10218005
Created Apr 9, 2014
pseudo-code for perlin-noise based generative impressionist paintings
View gist:10218005
render
for each particle
x, y = particle.position
color = sample( colorMap, x, y )
noise = sample( noiseMap, x, y )
angle = noise * PI * 2
particle.velocity.add( cos(angle), sin(angle) )
@pabigot
pabigot / rotate.cc
Created Nov 19, 2013
C++11 template function to perform integer rotations without invoking undefined behavior. See http://blog.regehr.org/archives/1063
View rotate.cc
/* See http://blog.regehr.org/archives/1063
*/
#include <type_traits>
#include <cstdint>
#include <limits>
#include <typeinfo>
#ifndef ARGTYPE
#define ARGTYPE uint32_t
#endif /* ARGTYPE */
@wsargent
wsargent / docker_cheat.md
Last active Nov 11, 2021
Docker cheat sheet
View docker_cheat.md
@arnehormann
arnehormann / must.go
Created Sep 23, 2013
usage example for reflect.MakeFunc: create panic-on-error wrappers which do not pass the error (in a comfortable but probably rather slow way)
View must.go
import "reflect"
// assumption for fptr: func with error as last argument
func makeMust(fptr interface{}) {
must := func(in []reflect.Value) []reflect.Value {
if err := in[len(in)-1]; !err.IsNil() {
panic(err.Interface())
}
return in[:len(in)-1]
}
@cuadue
cuadue / cubism-websockets.html
Created Sep 3, 2013
Streaming data to cubism.js with websockets
View cubism-websockets.html
<!DOCTYPE html>
<meta charset='utf-8'>
<head>
<title>Cubism + Websockets</title>
<script language='javascript' src='d3.min.js'></script>
<script language='javascript' src='cubism.v1.js'></script>
<script language='javascript'>
/* I can never seem to remember:
Array.push() appends to the end, and returns the new length
View shell-stuff.sh
#!/bin/bash
# stop on errors and undeclared variables
set -e -u -o pipefail
err() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $@" >&2
}
@minikomi
minikomi / persona.go
Last active Dec 11, 2015
mozilla persona test
View persona.go
package main
import (
"encoding/json"
"fmt"
"github.com/gorilla/sessions"
"io/ioutil"
"log"
"net/http"
"net/url"
View Three Wise Monkeys.md

Date: [date]

Between us [company name] and you [customer name].

Summary:

In short; neither of us will share any confidential information about each-other, by any means, with anyone else.

What’s confidential information?