Math.round(Math.random()*(36**8)).toString(36)
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
// BROWSER | |
// ASCII to HEX | |
const a2h = s => [].map.call(s, c => c.charCodeAt(0).toString(16)).join(''); | |
// a2h('mystring'); | |
// HEX to ASCII | |
const h2a = s => s.match(/.{1,2}/g).map(c => String.fromCharCode(parseInt(c, 16))).join(''); | |
// h2a('6d79737472696e67'); |
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 ratio(w, h, a = w, b = h) { | |
return b ? ratio(w, h, b, a % b) : [w / a, h / a]; | |
} | |
ratio(640, 480); // [4,3] |
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
# https://articles.inqk.net/2020/02/10/jekyll-permalinks.html | |
# place in `_plugins` directory | |
module Jekyll | |
module Drops | |
class UrlDrop < Drop | |
def build | |
@context.registers[:site].time.strftime("%s") | |
end | |
end | |
end |
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 getAllFocusableElements = (parent) => Array.from(parent.querySelectorAll('*')).filter(elm => elm.tabIndex > -1).sort((a,b) => a.tabIndex > b.tabIndex ? 1 : a.tabIndex < b.tabIndex ? -1 : 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
# Prevents liquid syntax being processed inside of code fences | |
Jekyll::Hooks.register :documents, :pre_render do |page, payload| | |
docExt = page.extname.tr('.', '') | |
# only process if we deal with a markdown file | |
if payload['site']['markdown_ext'].include? docExt | |
page.content.gsub!(/^(\s*?)(```[\s\S]+?```)(\s*?)$/, '\1{% raw %}\2{% endraw %}\3') | |
end | |
end |
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
javascript:(function(){fetch(document.location+'media?size=l').then(r => r.blob()).then(blob => URL.createObjectURL(blob)).then(url => {let a = document.createElement('a'); a.href = url; a.download = document.location.href.replace(/^.*\/p\/([^\/]+)\/.*$/,'$1.jpg'); a.click(); })}()) |