This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var networks = [{ | |
url: "https://squareup.com/login?return_to=%2Ffavicon.ico", | |
name: "Square" | |
}, { | |
url: "https://www.instagram.com/accounts/login/?next=%2Ffavicon.ico", | |
name: "Instagram" | |
}, { | |
url: "https://twitter.com/login?redirect_after_login=%2Ffavicon.ico", | |
name: "Twitter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ctx = null, usingWebAudio = true; | |
try { | |
if (typeof AudioContext !== 'undefined') { | |
ctx = new AudioContext(); | |
} else if (typeof webkitAudioContext !== 'undefined') { | |
ctx = new webkitAudioContext(); | |
} else { | |
usingWebAudio = false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const genRandomStr = (length = 16) { | |
let t = ''; | |
while (t.length < 16) { | |
t = t + Math.random().toString(36).substr(2); | |
} | |
return t.substr(0, length); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# https://stackoverflow.com/a/23877974/3474615 | |
while [[ $EXT_PREFIX != "ioio" ]] # change 'ioio' to your desired prefix (can only use lowercase a-p) | |
do | |
rm key.pem manifest_key.txt extension_id.txt | |
2>/dev/null openssl genrsa 2048 | openssl pkcs8 -topk8 -nocrypt -out key.pem | |
2>/dev/null openssl rsa -in key.pem -pubout -outform DER | openssl base64 -A > manifest_key.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Water Canvas by Almer Thie (http://code.almeros.com). | |
* Description: A realtime water ripple effect on an HTML5 canvas. | |
* Copyright 2010 Almer Thie. All rights reserved. | |
* | |
* Example: http://code.almeros.com/code-examples/water-effect-canvas/ | |
* Tutorial: http://code.almeros.com/water-ripple-canvas-and-javascript | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usually I use this in my app's config file, in case I need to disable all cache from the app | |
// Cache is from `js-cache`, something like `import Cache from 'js-cache';` | |
const cacheable = true, | |
cache = new Cache(); | |
// On request, return the cached version, if any | |
axios.interceptors.request.use(request => { | |
// Only cache GET requests | |
if (request.method === 'get' && cacheable) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
JPEG orientation transform | |
See https://magnushoff.com/jpeg-orientation.html | |
*/ | |
img[data-orientation="2"] { | |
transform: rotateY(180deg); | |
} | |
img[data-orientation="3"] { | |
transform: rotate(180deg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Extracted from https://gist.github.com/alexandrudima/bda598fbed179a581986b634cc94ab8d */ | |
/** | |
* Returns the number in the set [0, 1]. | |
* - O => Darkest Black. | |
* - 1 => Lightest white. | |
* @see http://www.w3.org/TR/WCAG20/#relativeluminancedef | |
* | |
* @param {Object} color | |
* @param {Number} color.r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get image orientation from EXIF header | |
* | |
* Referenced: | |
* - https://gist.github.com/nezed/d536ccdace84c6f2ef13da47a8fd6bdb | |
* - https://gist.github.com/wonnage/9d2e73d9228f5a0b300d75babe2c3796 | |
* - https://github.com/blueimp/JavaScript-Load-Image/blob/master/js/load-image-meta.js | |
* | |
* @param {String} imageUrl | |
* @return {Promise} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
var fs = require('fs') | |
var argv = require('optimist').argv | |
var rxVideoID = /v=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ | |
var link = argv._.toString() | |
var videoID = link.match(rxVideoID)[1] | |
http.get("http://www.youtube.com/get_video_info?video_id="+videoID, function(res) { | |
var chunks = [] |
NewerOlder