Skip to content

Instantly share code, notes, and snippets.

Avatar

J. Voigt joyrexus

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

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.
http://www.opensource.org/licenses/mit-license.php
@joyrexus
joyrexus / README.md
Last active January 24, 2023 19:15
POST with curl
View README.md

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 https://foo.io/users/joyrexus/shoes, the canonical address for the shoes resource (a "collection" resource, in REST-speak) of a particular user (joyrexus):

@joyrexus
joyrexus / README.md
Created March 28, 2014 16:59
Nested grouping of arrays
View README.md

nest.js

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
joyrexus / README.md
Last active January 9, 2023 08:55
form-data vs -urlencoded
View README.md

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
joyrexus / README.md
Last active January 6, 2023 10:35
collapsible markdown
View README.md

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

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

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@joyrexus
joyrexus / README.md
Last active December 13, 2022 22:30 — forked from btoone/curl.md
curl tutorial
View README.md

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

@joyrexus
joyrexus / README.md
Last active November 29, 2022 12:53
nested templates in go
View README.md

Example of nested templates.

Given this file layout ...

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

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

Usage

npm install
npm run setup
npm run server

Then ...

@joyrexus
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;
}