Skip to content

Instantly share code, notes, and snippets.

View Swatinem's full-sized avatar

Arpad Borsos Swatinem

View GitHub Profile
@tj
tj / Makefile
Created January 12, 2012 04:56
Stylus web service makefile example
STYLES = $(wildcard stylesheets/*.styl)
CSS = $(STYLES:.styl=.css)
COMPRESSED = $(CSS:.css=.min.css)
all: $(CSS)
style.min.css: $(COMPRESSED)
@cat $^ > $@
15:15 <@isaacs> something i've noticed: .0 is effectively "preview release"
15:15 <@isaacs> i think it's ok to make minor API changes in .1
15:15 <@isaacs> but we should never tell anyone that.
15:15 <@isaacs> :)
15:16 <@isaacs> you can call 0.9.99 a preview release, but still no one will install it.
15:16 <@isaacs> until it has the actual "stable" flag on it, they're too scared.
15:16 <@isaacs> so we put that flag on it just a little bit before it's actually true.
module.exports = Liner
var Transform = require('stream').Transform;
var util = require('util');
util.inherits(Liner, Transform);
function Liner(options) {
Transform.call(this, options);
// We're only objectMode on the readable side, not writable.
$ cat t.js
gc();
var before = process.memoryUsage();
var express = require(process.argv[2]);
gc();
var after = process.memoryUsage();
var diff = {}
for (var i in before) diff[i] = after[i] - before[i]
@tj
tj / example.js
Created July 31, 2013 18:48
console.api()
function params(fn) {
var str = fn.toString();
var sig = str.match(/\(([^)]*)\)/)[1];
if (!sig) return [];
return sig.split(', ');
}
console.api = function(obj){
console.log();
var proto = Object.getPrototypeOf(obj);
@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
@sebmarkbage
sebmarkbage / Move.md
Last active August 29, 2015 14:01
Object Rest Destructuring and Spread Initializer (ES7 proposal)
@s-panferov
s-panferov / option.ts
Created November 30, 2014 12:15
Option and Result types from Rust in TypeScript
interface Option<T> {
map <U>(fn: (a: T) => U): Option<U>;
isSome(): boolean;
isNone(): boolean;
isSomeAnd(fn: (a: T) => boolean): boolean;
isNoneAnd(fn: () => boolean): boolean;
unwrap(): T;
unwrapOr(def: T): T;
unwrapOrElse(f: () => T): T;
map<U>(f: (a: T) => U): Option<U>;
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@binaerbaum
binaerbaum / arch-linux-install
Last active April 6, 2022 03:16 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI NVMe system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# Set swiss-french keymap