View country_code_to_name.js
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 countryCodeToName(code) { | |
const data = { | |
"AD": "Andorra", | |
"AE": "United Arab Emirates", | |
"AF": "Afghanistan", | |
"AG": "Antigua and Barbuda", | |
"AI": "Anguilla", | |
"AL": "Albania", | |
"AM": "Armenia", | |
"AO": "Angola", |
View region_code_lookup.js
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
// Raw data from: https://github.com/country-regions/country-region-data/blob/master/data.json | |
const data = JSON.parse('[{"countryName":"Afghanistan","countryShortCode":"AF","regions":[{"name":"Badakhshan","shortCode":"BDS"},{"name":"Badghis","shortCode":"BDG"},{"name":"Baghlan","shortCode":"BGL"},{"name":"Balkh","shortCode":"BAL"},{"name":"Bamyan","shortCode":"BAM"},{"name":"Daykundi","shortCode":"DAY"},{"name":"Farah","shortCode":"FRA"},{"name":"Faryab","shortCode":"FYB"},{"name":"Ghazni","shortCode":"GHA"},{"name":"Ghor","shortCode":"GHO"},{"name":"Helmand","shortCode":"HEL"},{"name":"Herat","shortCode":"HER"},{"name":"Jowzjan","shortCode":"JOW"},{"name":"Kabul","shortCode":"KAB"},{"name":"Kandahar","shortCode":"KAN"},{"name":"Kapisa","shortCode":"KAP"},{"name":"Khost","shortCode":"KHO"},{"name":"Kunar","shortCode":"KNR"},{"name":"Kunduz","shortCode":"KDZ"},{"name":"Laghman","shortCode":"LAG"},{"name":"Logar","shortCode":"LOW"},{"name":"Maidan Wardak","shortCode":"WAR"},{"name":"Nangarhar","shortCode":"NAN |
View browser-icon.js
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
/*** | |
* Given a slightly messy set of input strings, attempt to match a well-known browser name, and return an icon | |
* | |
* Examples: | |
* inferBrowserIcon('safari') // exact match | |
* inferBrowserIcon('Safari Mobile 15.4') // matches "safari" from input string | |
* inferBrowserIcon('Firefox 99', 128) // pick a specific size (from sizes) | |
* inferBrowserIcon('unknownbrowser') // fallback if no match | |
* inferBrowserIcon(null, 128, 'brave') // You know the browser-logos repo key | |
*/ |
View geoip.js
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 requestIp = require('request-ip'); | |
function getIp (req) { | |
let ip = null; | |
try { | |
//ip = (req.headers['x-forwarded-for'] || '').split(',').pop() || | |
// req.connection.remoteAddress || | |
// req.socket.remoteAddress || | |
// req.connection.socket.remoteAddress; |
View browserquest-load-external-spritesheet.js
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
// Register an external sprite, CORS headers required for images | |
game.loadSprite('skeletonplayer', { | |
"id": "skeletonplayer", | |
"width": 48, | |
"height": 48, | |
"filepath_1": "http://filestore.b-cdn.net/skeleton_1.png", | |
"filepath_2": "http://filestore.b-cdn.net/skeleton_2.png", | |
"filepath_3": "http://filestore.b-cdn.net/skeleton_3.png", | |
"animations": { | |
"atk_right": { |
View raf.js
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
/** | |
* RAF Performance Checking | |
* | |
* Will enable and disable a flag on the window object | |
* When Javascript performance suffers, so that optional features | |
* Can be Disabled or delayed | |
*/ | |
(function () { | |
var lastTimestamp = + new Date(); |
View ocdb-jquery.js
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
/** | |
* Instant Data for your OCDB Project (requires jQuery) | |
* | |
* Just use magic classes or data attributes matching your string data and they'll be automatically filled | |
* | |
* Example: | |
* | |
* <h1 data-for-h1></h1> <!-- This gets populated with data from the key `h1` --> | |
* | |
*/ |
View changelog-life-embed.html
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
/** | |
* Changelog.life Widget Embed (Beta) | |
* Replace 'changelogging' with your Changelog subdomain | |
* Then, place this script tag where you want your changelog dot to appear. | |
*/ | |
See an example on Codepen: https://codepen.io/kidGodzilla/pen/gOLymGB | |
<script onload="_changeloglife_init('changelogging')" id="changelog_life" src="https://changelog.life/embed.js"></script> |
View natural-transcription-mapping.js
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 currentTs() { | |
return (+ new Date()) - window._startTime || 0; | |
} | |
function cutTranscription() { | |
clearTimeout(window._silenceTimr); | |
window._cutoffTimr = null; | |
let piece = (_recognizedSpeech[0] || '').substring(_transcriptionLength); | |
_transcriptionLength = (_recognizedSpeech[0] || '').length; |
View embed-widget.html
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
<!-- indie.am Player Embed Script --> | |
<script> | |
window._indieam_username = 'james'; // Change this to your own log ID, typically indie.am/<log_id> | |
document.querySelector('head').innerHTML += '<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/cleanslate"><style>#indieam_container{position:fixed!important;padding:18px 20px!important;bottom:0!important;left:0!important;z-index:999999999999!important}.indieam_circle{cursor:pointer!important}.indieam_circle>img{width:65px!important;height:65px!important;border-radius:50%!important;box-shadow:1px 2px 22px #00000044!important}#indieam_container>iframe{position:fixed!important;bottom:-88px!important;left:-27px!important;transform-origin:0 0!important;transform:scale(.8)!important;height:750px!important;width:500px!important;display:none!important}#indieam_container>iframe.indieam_in{display:block!important}#indieam_container,#indieam_container iframe { overflow-y: hidden !important }</style>'; | |
function _indieam_toggl |
NewerOlder