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
/** | |
* 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 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 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 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 = jsmith@example.com | |
[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 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 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 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 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 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
/** | |
* The second lightest JS template engine! (And still so unsafe one) | |
* Only replaces variables inside {{ }} (HTML-escaped) and {{{ }}} (unescaped) | |
* Second lightest after the original https://gist.github.com/thybzi/1e46eb8b23c11d55752ae4ac89a1cd13 | |
* @param {string} template | |
* @param {object} data | |
* @returns {string} | |
* @example | |
* tpl2( | |
* '<div class="{{ classname }}">{{{ item.content }}}</div>', |
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
/** | |
* The lightest JS template engine ever! (And the most unsafe one) | |
* Only replaces variables inside {{ }} (without any escaping) | |
* @param {string} template | |
* @param {object} data | |
* @example | |
* tpl( | |
* '<div class="{{ classname }}">{{item.title}}</div>', | |
* { classname: 'ololo', item: { ad: 'zzz', title: 'afffa!!bazinga' } } | |
* ); |
NewerOlder