Skip to content

Instantly share code, notes, and snippets.


J. Voigt joyrexus

View GitHub Profile
joyrexus /
Last active Apr 17, 2021
form-data vs -urlencoded

Nice answer on stackoverflow to the question of when to use one or the other content-types for POSTing data, viz. application/x-www-form-urlencoded and multipart/form-data.

“The moral of the story is, if you have binary (non-alphanumeric) data (or a significantly sized payload) to transmit, use multipart/form-data. Otherwise, use application/x-www-form-urlencoded.”

Matt Bridges' answer in full:

The MIME types you mention are the two Content-Type headers for HTTP POST requests that user-agents (browsers) must support. The purpose of both of those types of requests is to send a list of name/value pairs to the server. Depending on the type and amount of data being transmitted, one of the methods will be more efficient than the other. To understand why, you have to look at what each is doing

joyrexus /
Last active Apr 14, 2021
collapsible markdown

collapsible markdown?


yes, even hidden code blocks!

print("hello world!")
joyrexus /
Last active Apr 10, 2021 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery


// jQuery
$(document).ready(function() {
  // code
joyrexus /
Created Mar 28, 2014
Nested grouping of arrays


A multi-level groupBy for arrays inspired by D3's nest operator.

Nesting allows elements in an array to be grouped into a hierarchical tree structure; think of it like the GROUP BY operator in SQL, except you can have multiple levels of grouping, and the resulting output is a tree rather than a flat table. The levels in the tree are specified by key functions.

See this fiddle for live demo.

joyrexus /
Last active Apr 6, 2021 — forked from dergachev/
Create a GIF screencast

Convert a screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF


To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

joyrexus / http-errors.js
Created Jun 6, 2016 — forked from moleike/http-errors.js
HTTP Error classes in Node.js
View http-errors.js
'use strict';
const statusCodes = require('http').STATUS_CODES;
function createError(code, name) {
return function(message) {
Error.captureStackTrace(this, this.constructor); = name;
this.message = message;
this.statusCode = code;
joyrexus /
Last active Apr 4, 2021
Perl one-liners


perl -e 'print "hello world!\n"'

A simple filter:

perl -ne 'print if /REGEX/'

Filter out blank lines (in place):

joyrexus /
Last active Apr 4, 2021 — forked from btoone/
curl tutorial

An introduction to curl using GitHub's API.


Makes a basic GET request to the specifed URI


Includes HTTP-Header information in the output

joyrexus /
Last active Feb 15, 2021
Comparison of jQuery and vanilla JS for basic DOM manipulation.

jQuery vs native JS

Selecting Elements

var divs = $("div");

var divs = document.querySelectorAll("div");
joyrexus /
Last active Feb 15, 2021
The Stable Marriage Problem

My implementation of the Gale/Shapley algorithm in Python. This algorithm is designed to address the Stable Marriage Problem.

Compare this recursive variant with the implementations on Rosetta Code.

Problem description

Given an equal number of men and women to be paired for marriage, each man ranks all the women in order of his preference and each women ranks all the men in order of her preference.

A stable set of engagements for marriage is one where no man prefers a women over the one he is engaged to, where that other woman also prefers that man over the one she is engaged to. I.e. with consulting marriages, there would be no reason for the engagements between the people to change.