Skip to content

Instantly share code, notes, and snippets.

View stvnrynlds's full-sized avatar
🤖
beep boop bop

Steven Reynolds stvnrynlds

🤖
beep boop bop
View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@willurd
willurd / web-servers.md
Last active July 26, 2024 13:45
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 27, 2024 07:37
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@stvnrynlds
stvnrynlds / HTMLVideoElement.js
Last active July 6, 2018 21:12
Properties and methods of the HTML video element
/*
Sources:
- MDN: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement
- WHATWG: https://html.spec.whatwg.org/multipage/embedded-content.html#media-element
*/
// METHODS
video.load(); // Reload video; No args
video.play(); // Play video; No args
video.pause(); // Pause video; No args
function isbnLookup(id) {
var url = "https://www.googleapis.com/books/v1/volumes?country=US&q=isbn:"+id;
var options = {contentType : "application/json"};
var resp = UrlFetchApp.fetch(url, options);
if (resp == null || resp == "") return "N/A";
var respdata = JSON.parse(resp.getContentText());
if (respdata["items"].length == 0) return "Not found";
return respdata["items"][0]["volumeInfo"]["title"];
}