Skip to content

Instantly share code, notes, and snippets.

View shanebo's full-sized avatar

Shane Thacker shanebo

View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@bkeating
bkeating / graphiql-dark-mode.css
Last active April 25, 2023 13:31
GraphiQL One Dark Alt (Dark Mode) theme by Ben Keating
<style>
/* GraphiQL One Dark Alt (Dark Mode) theme by Ben Keating[1]
* Colors taken from Atom's One Dark theme[2]. Add this file to the end of
* your <head> block[3] to override built-in default styling.
*
* [1]. https://twitter.com/flowpoke
* [2]. https://github.com/atom/atom/tree/master/packages/one-dark-ui
* [3]. e.g. `.../site-packages/graphene_django/templates/graphene/graphiql.html`
*/
@tomysmile
tomysmile / mac-setup-redis.md
Last active March 18, 2024 22:12
Brew install Redis on Mac

type below:

brew update
brew install redis

To have launchd start redis now and restart at login:

brew services start redis
@bendc
bendc / nodelist-iteration.js
Created January 13, 2015 14:39
ES6: Iterating over a NodeList
var elements = document.querySelectorAll("div"),
callback = (el) => { console.log(el); };
// Spread operator
[...elements].forEach(callback);
// Array.from()
Array.from(elements).forEach(callback);
// for...of statement
@brock
brock / nodereinstall.sh
Last active April 17, 2024 08:26
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"
@ondrek
ondrek / luhn.js
Created October 14, 2013 18:04 — forked from ShirtlessKirk/luhn.js
// Variant of Avraham Plotnitzky's String.prototype method mixed with the "fast" version
// see: https://sites.google.com/site/abapexamples/javascript/luhn-validation
function luhnChk(luhn) {
var len = luhn.length,
mul = 0,
prodArr = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]],
sum = 0;
while (len--) {
@willurd
willurd / web-servers.md
Last active April 26, 2024 12:46
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
@markthiessen
markthiessen / getWeeksInMonth.js
Last active April 25, 2024 02:05
JavaScript - get weeks in a month as array of start and end days
//note: month is 0 based, just like Dates in js
function getWeeksInMonth(year, month) {
const weeks = [],
firstDate = new Date(year, month, 1),
lastDate = new Date(year, month + 1, 0),
numDays = lastDate.getDate();
let dayOfWeekCounter = firstDate.getDay();
for (let date = 1; date <= numDays; date++) {
@eikes
eikes / getTimezone.js
Created February 15, 2012 14:39
Get or estimate browsers timezone name in JavaScript
var d = new Date();
var usertime = d.toLocaleString();
// Some browsers / OSs provide the timezone name in their local string:
var tzsregex = /\b(ACDT|ACST|ACT|ADT|AEDT|AEST|AFT|AKDT|AKST|AMST|AMT|ART|AST|AWDT|AWST|AZOST|AZT|BDT|BIOT|BIT|BOT|BRT|BST|BTT|CAT|CCT|CDT|CEDT|CEST|CET|CHADT|CHAST|CIST|CKT|CLST|CLT|COST|COT|CST|CT|CVT|CXT|CHST|DFT|EAST|EAT|ECT|EDT|EEDT|EEST|EET|EST|FJT|FKST|FKT|GALT|GET|GFT|GILT|GIT|GMT|GST|GYT|HADT|HAEC|HAST|HKT|HMT|HST|ICT|IDT|IRKT|IRST|IST|JST|KRAT|KST|LHST|LINT|MART|MAGT|MDT|MET|MEST|MIT|MSD|MSK|MST|MUT|MYT|NDT|NFT|NPT|NST|NT|NZDT|NZST|OMST|PDT|PETT|PHOT|PKT|PST|RET|SAMT|SAST|SBT|SCT|SGT|SLT|SST|TAHT|THA|UYST|UYT|VET|VLAT|WAT|WEDT|WEST|WET|WST|YAKT|YEKT)\b/gi;
// In other browsers the timezone needs to be estimated based on the offset:
var timezonenames = {"UTC+0":"GMT","UTC+1":"CET","UTC+2":"EET","UTC+3":"EEDT","UTC+3.5":"IRST","UTC+4":"MSD","UTC+4.5":"AFT","UTC+5":"PKT","UTC+5.5":"IST","UTC+6":"BST","UTC+6.5":"MST","UTC+7":"THA","UTC+8":"AWST","UTC+9":"AWDT","UTC+9.5":"ACST"
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];