Skip to content

Instantly share code, notes, and snippets.

@naiquevin
naiquevin / comp.py
Last active April 13, 2019 15:09
Function composition in Python inspired by Clojure's `comp` function
## Update! Found an alternative approach that's concise and feels much more idiomatic
def compose (f, g):
return lambda x: f(g(x))
def comp(*args):
return reduce(compose, args[1:], args[0])
def comp1(*args):
@juliangruber
juliangruber / 1.md
Last active November 21, 2021 21:13
@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet
@deoxxa
deoxxa / decode-utf8.js
Created December 27, 2013 03:46
Decode UTF-8 bytes
var decode = function decode(bytes) {
var points = [];
var i = 0, j = 0;
while (i < bytes.length) {
if ((bytes[i] & 0x80) === 0) {
points.push(bytes[i] & 0x7f);
i += 1;
} else if ((bytes[i] & 0xE0) === 0xC0) {
points.push(((bytes[i] & 0x1F) << 6) + (bytes[i+1] & 0x7f));
@dandean
dandean / private-npmjs-registry.md
Last active February 5, 2025 05:47
How I got the npmjs.org registry running on my mac.

Install CouchDB (1.5)

$ brew install couchdb

It may throw an exception while compiling erlang. If so, you need to install a different gcc, reinstall erlang, then try the couchdb install again:

$ brew install apple-gcc42
$ brew reinstall -v --use-gcc erlang

Virtual DOM and diffing algorithm

There was a [great article][1] about how react implements it's virtual DOM. There are some really interesting ideas in there but they are deeply buried in the implementation of the React framework.

However, it's possible to implement just the virtual DOM and diff algorithm on it's own as a set of independent modules.

@rvagg
rvagg / npm2csvgz.js
Created January 24, 2014 11:38
Stream example
var request = require('request')
, json = require('JSONStream')
, through2 = require('through2')
, csv = require('csv-write-stream')
, zlib = require('zlib')
, fs = require('fs')
request({url: 'https://registry.npmjs.org/-/all'})
.pipe(json.parse('*'))
.pipe(through2.obj(function (data, enc, callback) {
@zahradil
zahradil / gist:8800421
Created February 4, 2014 09:15
btrfs: how to use and create snapshotable btrfs volume
sudo apt-get install btrfs-tools
sudo su
mkdir /data
cd /data
# create 500 MB file
dd if=/dev/zero of=/data/datadisk bs=1024 count=500000
# create btrfs
@trevnorris
trevnorris / perf-flame-graph-notes.md
Last active December 24, 2023 05:25
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@fabiokung
fabiokung / Usage.md
Last active August 29, 2015 14:01
base Docker image for Heroku Buildpacks

as a buildpack maintainer

$ git clone https://github.com/heroku/heroku-buildpack-ruby.git  # or any other buildpack
$ cd heroku-buildpack-ruby
heroku-buildpack-ruby $ cat Dockerfile
FROM fabiokung/heroku-buildpack-base

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q ruby2.0
# more stuff specific to this buildpack...