Skip to content

Instantly share code, notes, and snippets.

View rsp's full-sized avatar

Rafał Pocztarski rsp

View GitHub Profile
@ssippe
ssippe / cartesianProduct.ts
Created April 20, 2017 00:33
Typescript Cartesian Product
const f = (a: any[], b: any[]): any[] =>
[].concat(...a.map(a2 => b.map(b2 => [].concat(a2, b2))));
export const cartesianProduct = (a: any[], b: any[], ...c: any[]) => {
if (!b || b.length === 0) {
return a;
}
const [b2, ...c2] = c;
const fab = f(a, b);
return cartesianProduct(fab, b2, c2);
@robertpainsi
robertpainsi / .gitconfig
Last active December 1, 2022 20:05
.gitconfig
[branch]
autosetupmerge = true
[core]
editor = gedit --wait --new-window
pager = less -x1,5
whitespace = trailing-space,space-before-tab,tabwidth=4
[color]
ui = auto
@briceburg
briceburg / git.md
Created November 22, 2015 05:42
git - checking fast-forward-ness
git merge-base --is-ancestor master HEAD

from man git merge-base

A common idiom to check "fast-forward-ness" between two commits A and B is (or at least used to be) to compute the merge base between A and B, and check if it is the same as A, in which case, A is an ancestor of B. You will see this idiom used

@vkostyukov
vkostyukov / statuses.md
Last active February 13, 2024 21:39
HTTP status codes used by world-famous APIs
API Status Codes
[Twitter][tw] 200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504
[Stripe][stripe] 200, 400, 401, 402, 404, 429, 500, 502, 503, 504
[Github][gh] 200, 400, 422, 301, 302, 304, 307, 401, 403
[Pagerduty][pd] 200, 201, 204, 400, 401, 403, 404, 408, 500
[NewRelic Plugins][nr] 200, 400, 403, 404, 405, 413, 500, 502, 503, 503
[Etsy][etsy] 200, 201, 400, 403, 404, 500, 503
[Dropbox][db] 200, 400, 401, 403, 404, 405, 429, 503, 507
@zeusdeux
zeusdeux / socketio.md
Last active March 18, 2020 22:51
Vanilla websockets vs socket.io

Vanilla websockets vs socket.io

Note: The points below are a comparison of using vanilla websockets on client and server and using 'em via socket.io and not about why only use socket.io

  • Native websockets provide us with only a send method to send data to the server. Send accepts only string input (not too sure about this). Socket.io lets us emit arbitrary events with arbitrary data (even binary blobs) to the server.
  • To receive messages on a vanilla websocket you can only assign a handler for the message event. The data you receive is mostly likely to be text (again not too sure about this) and you will have to parse it manually before consuming it. Socket.io lets the server and client both emit arbitrary events and handles all the parsing and packing/unpacking.
  • Socket.io gives us both a server and a client. Implementing a vanilla websocket server isn't something that you would want to do per project since it's quite painful. You will have to implement [RFC6455](https://tools.ietf.org/h

EDIT from 2019: Hi folks. I wrote this gist for myself and some friends, and it seems like it's gotten posted somewhere that's generated some (ahem, heated) discussion. The whitespace was correct when it was posted, and since then GitHub changed how it formats <pre> tags. Look at the raw text if you care about this. I'm sure someone could tell me how to fix it, but (thank you @anzdaddy for suggesting a formatting workaround) honestly this is a random throwaway gist from 2015, and someone more knowledgable about this comparison should just write a proper blog post about it. If you comment here I'll hopefully see it and stick a link to it up here. Cheers. @oconnor663

Here's the canonical TOML example from the TOML README, and a YAML version of the same.

title = "TOML Example"
 
@menzenski
menzenski / helloworld.asm
Created February 4, 2015 15:24
Hello World in Assembly language (x86-64 Unix-like operating systems, NASM syntax)
; MacOS X: /usr/local/bin/nasm -f macho64 *.s && ld -macosx_version_min 10.7 *.o
; Solaris/FreeBSD/DragonFly: nasm -f elf64 -D UNIX *.s && ld *.o
; NetBSD: nasm -f elf64 -D UNIX -D NetBSD *.s && ld *.o
; OpenBSD: nasm -f elf64 -D UNIX -D OpenBSD *.s && ld -static *.o
; OpenIndiana: nasm -f elf64 -D UNIX *.s && ld -m elf_x86_64 *.o
; Linux: nasm -f elf64 *.s && ld *.o
%ifdef NetBSD
section .note.netbsd.ident
dd 7,4,1
@ericelliott
ericelliott / essential-javascript-links.md
Last active April 22, 2024 10:15
Essential JavaScript Links
@jobsamuel
jobsamuel / readme.md
Last active January 19, 2024 18:26
Run NodeJS as a Service on Ubuntu 14.04 LTS

Run NodeJS as a Service on Ubuntu 14.04 LTS

With Node you can write very fast JavaScript programs serverside. It's pretty easy to install Node, code your program, and run it. But > how do you make it run nicely in the background like a true server?

  • Go to /etc/init/
  • $ sudo vim yourapp.conf
  • Paste script.conf
  • $ sudo start yourapp
  • And when you wanna kill the process $ sudo stop yourapp
@staltz
staltz / introrx.md
Last active May 2, 2024 12:31
The introduction to Reactive Programming you've been missing