Skip to content

Instantly share code, notes, and snippets.

View petrosh's full-sized avatar

Alex Petrosh petrosh

View GitHub Profile
function logColor(color, args) {
console.log(`%c ${args.join(' ')}`, `color: ${color}`);
}
const log = {
aliceblue: (...args) => { logColor('aliceblue', args)},
antiquewhite: (...args) => { logColor('antiquewhite', args)},
aqua: (...args) => { logColor('aqua', args)},
aquamarine: (...args) => { logColor('aquamarine', args)},
azure: (...args) => { logColor('azure', args)},
@oliveratgithub
oliveratgithub / emojis.json
Last active April 26, 2024 22:35
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "👩‍👩‍👧‍👧", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "👩‍👩‍👧‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "👩‍👩‍👦‍👦", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "👨‍👩&z
@JordanReiter
JordanReiter / input-month-polyfill.js
Last active January 25, 2023 08:55
Polyfill for input type="month" with no dependencies.
(function() {
var monthInputs = document.querySelectorAll('input[type="month"]'),
checkDateInput = document.createElement('input'),
dateSupported = false,
months = [],
lang = document.documentElement.lang || navigator.language,
DEFAULT_SPAN = 5;
if (monthInputs[0].type === 'month') {
// browser supports month input; no need for polyfill
@glebm
glebm / RenderWhitespace.md
Last active September 26, 2017 11:17
Render whitespace on GitHub
@SimplGy
SimplGy / renameToHash.sh
Last active July 27, 2023 07:30
Rename files with a hash based on their contents. eg: `abc.jpg` to `3101ace8db9f.jpg`. Useful for detecting duplicates.
#!/bin/bash
# TODO: skip tiny files (so small they couldn't be photos)
# TODO: make sure sym links and other file system oddities are handled
# TODO: look at paralellization for perf boost
#
# Constants
#
CHAR_COUNT=12
BLOCK_COUNT=6
@mixin for-size($range) {
$phone-upper-boundary: 600px;
$tablet-portrait-upper-boundary: 900px;
$tablet-landscape-upper-boundary: 1200px;
$desktop-upper-boundary: 1800px;
@if $range == phone-only {
@media (max-width: #{$phone-upper-boundary - 1}) { @content; }
} @else if $range == tablet-portrait-up {
@media (min-width: $phone-upper-boundary) { @content; }
@benwells
benwells / reduce-example.js
Created May 12, 2016 13:40
Using Array.reduce to sum a property in an array of objects
var accounts = [
{ name: 'James Brown', msgCount: 123 },
{ name: 'Stevie Wonder', msgCount: 22 },
{ name: 'Sly Stone', msgCount: 16 },
{ name: 'Otis Redding', msgCount: 300 } // Otis has the most messages
];
// get sum of msgCount prop across all objects in array
var msgTotal = accounts.reduce(function(prev, cur) {
return prev + cur.msgCount;
anonymous
anonymous / .block
Created April 14, 2016 17:39
Calendar Heatmap (vertical with colorbrewer.css options) - US Flights 1998-2007
height: 750
license: gpl-3.0
@sgentle
sgentle / gist:58e3e37c28a7662d014f
Created April 26, 2015 10:08
Audio loops in CoffeeScript with fetch and Promises
ctx = new (AudioContext || webkitAudioContext)
addAudio = (src) ->
fetch src
.then (response) -> response.arrayBuffer()
.then (audioData) -> new Promise (accept) -> ctx.decodeAudioData audioData, accept
.then (buffer) ->
node = ctx.createBufferSource()
node.buffer = buffer
node.loop = true
node.connect ctx.destination
@lelandrichardson
lelandrichardson / eachAsync.js
Created March 13, 2015 15:17
Asynchronous Serial iteration
function eachAsync(iter, list, delay) {
var i = 0,
stopped = false,
fwhenDone;
delay = delay || 0;
function run() {
iter(list[i], done);
}
function hold() {