This file contains hidden or 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
/** | |
* Convert #1a2b3c to { r: 26, g: 43, b: 60 } | |
* @param {string} hex | |
* @returns {*} | |
* @see https://stackoverflow.com/a/5624139 | |
*/ | |
function hexToRgb(hex) { | |
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | |
return result ? { |
This file contains hidden or 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
/** | |
* Convert #1a2b3c to { h: 210, g: 40, b: 17 } | |
* @param {string} hex | |
* @returns {*} | |
* @see https://stackoverflow.com/q/46432335/3027390 | |
* @see https://stackoverflow.com/a/46432866/3027390 | |
*/ | |
function hexToHsl(hex) { | |
const rgb = _f.hexToRgb(hex); | |
const r = rgb.r / 255; |
This file contains hidden or 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
source "https://rubygems.org" | |
# Hello! This is where you manage which Jekyll version is used to run. | |
# When you want to use a different version, change it below, save the | |
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: | |
# | |
# bundle exec jekyll serve | |
# | |
# This will help ensure the proper Jekyll version is running. | |
# Happy Jekylling! | |
# gem "jekyll", "~> 4.2.0" |
This file contains hidden or 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
[user] | |
name = John Smith | |
email = [email protected] | |
[color] | |
ui = auto | |
[alias] | |
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
co = checkout | |
[push] | |
default = tracking |
This file contains hidden or 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 _patchFs() { | |
if (fs.hasOwnProperty('_mockedFiles')) { | |
return; | |
} | |
fs._readFileReal = fs.readFile; | |
fs._mockedFiles = {}; | |
fs.mockFile = function(filePath, fileContent) { | |
fs._mockedFiles[filePath] = fileContent; | |
}; | |
fs.readFile = function(filePath, cb) { |
This file contains hidden or 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
/** | |
* @param {string} url | |
* @returns {Promise<string>} | |
* @private | |
*/ | |
async function _fetchRemote(url) { | |
const http = /^https:/.test(url) ? require('https') : require('http'); | |
return new Promise((resolve, reject) => { | |
http.get(url, res => { | |
res.setEncoding('utf8'); |
This file contains hidden or 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
/** | |
* Convert cli-style arguments to reasonable key-value hashmap object | |
* @param {string[]} args Raw cli args | |
* @param {boolean} dropFirstTwo Useful for nodejs (drops two leading args) | |
* @returns Object<string|number|boolean> | |
* @example | |
* yargify(['--foo=bar', '--qux="hello world", '--fred', '-x=42', '-y=false']) | |
* // => {foo: 'bar', qux: 'hello world', fred: true, x: 42, y: false} | |
*/ | |
function yargify(args, dropFirstTwo=true) { |
This file contains hidden or 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
<?php | |
ini_set('user_agent', 'ThybziDiscogsClient/1.1 +http://thybzi.com/wishlist'); | |
define('BASE_URI', 'https://api.discogs.com/'); | |
define('API_TOKEN', 'YOUR_TOKEN_HERE'); // get one on https://www.discogs.com/settings/developers | |
define('CACHE_DIR', __DIR__ . '/../cache/'); | |
define('CACHE_LIFE', 24 * 60 * 60); | |
define('PER_PAGE', 100); | |
function getUriContent($uri) { |
This file contains hidden or 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
class Test { | |
constructor() { | |
this.processData({}).then((data) => { | |
console.log(data); | |
}) | |
} | |
async processData(data) { | |
data = await this.one(data); |
This file contains hidden or 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 getTransitionendEventName() { | |
if ('ontransitionend' in window) { | |
// Firefox 16+, IE 10+, Chrome 26+, Opera 12.1+, Safari 6.1+ | |
return 'transitionend'; | |
} else if ('onwebkittransitionend' in window) { | |
// Chrome 4+, Safari 3.1+ | |
return 'webkitTransitionEnd'; | |
} else if ('onmoztransitionend' in window) { | |
// Firefox 4+ | |
return 'mozTransitionEnd'; |
NewerOlder