Skip to content

Instantly share code, notes, and snippets.


J. Voigt joyrexus

View GitHub Profile
joyrexus /
Last active February 1, 2023 08:51 — forked from joelambert/README
RAF replacements for setTimeout and setInterval

Drop in replace functions for setTimeout and setInterval that make use of requestAnimationFrame.

See overview article and Paul Irish's earlier post.

Courtesty of Joe Lambert

Copyright 2011, Joe Lambert.
Free to use under the MIT license.
joyrexus /
Last active January 24, 2023 19:15
POST with curl

Below are a few examples of POSTing form data and file-uploads with curl.

For guidance on when to use which method, see form-data vs -urlencoded.

For details and more examples, see the POST section of the official tutorial.

In the examples below, suppose we need to POST data to, the canonical address for the shoes resource (a "collection" resource, in REST-speak) of a particular user (joyrexus):

joyrexus /
Created March 28, 2014 16:59
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 January 9, 2023 08:55
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 January 6, 2023 10:35
collapsible markdown

collapsible markdown?


yes, even hidden code blocks!

print("hello world!")
joyrexus /
Last active January 3, 2023 14:54 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery


// jQuery
$(document).ready(function() {
  // code
joyrexus /
Last active December 13, 2022 22:30 — 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 November 29, 2022 12:53
nested templates in go

Example of nested templates.

Given this file layout ...

├── server.go
└── templates
    ├── profiles.html
    └── layout.html
joyrexus /
Last active November 23, 2022 15:03
Form/file uploads with hapi.js

Demo of multipart form/file uploading with hapi.js.


npm install
npm run setup
npm run server

Then ...

joyrexus / index.js
Last active November 9, 2022 18:29
demo parser/chunker
View index.js
const fs = require("fs");
const axios = require("axios");
const { parse } = require("csv-parse");
const Renderer = require("squirrelly");
class Template {
constructor(template) {
this.template = template;