Skip to content

Instantly share code, notes, and snippets.

@ivanhoe011
ivanhoe011 / customElement.js
Created April 16, 2019 22:38
Custom HTML element simulating iframe
class HTMLInclude extends HTMLElement {
static observedAttributes = ['href'];
async attributeChangedCallback(name, value) {
if (name === 'href') {
this.innerHTML = await (await fetch(value)).text();
}
}
}
customElements.define('html-include', HTMLInclude);
@ivanhoe011
ivanhoe011 / key.md
Created February 28, 2019 11:35
Twitter (un)official Consumer Key

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN

Consumer key: IQKbtAYlXLripLGPWd0HUA

@ivanhoe011
ivanhoe011 / combineReducers.js
Created November 28, 2018 08:54
Custom root reducer
'use strict';
// from https://github.com/jokeyrhyme/wow-healer-bootcamp/blob/master/utils/combineReducers.js
/**
@param {Object} reducers
@returns {Function}
*/
export default function (keyedReducers = {}, ...reducers) {
return function (state = new Map(), action) {
@ivanhoe011
ivanhoe011 / undo_stash_clear.md
Last active October 29, 2018 21:51
Recover the code after accidental git stash clear
  1. Find the lost stash:
git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git log --merges --no-walk --grep=WIP
  1. Apply the stashed code back:
git stash apply <stash_commit_hash>
@ivanhoe011
ivanhoe011 / _kill-outline.scss
Created September 29, 2018 08:10
Gets rid of the annoying outline for mouse users but preserves it for keyboard users, and is ignored by browsers that don’t support :focus-visible.
:focus:not(:focus-visible) { outline: none }
@ivanhoe011
ivanhoe011 / duration.php
Last active September 4, 2018 11:56
Format duration given in seconds like a zero padded hh:mm:ss string.
<?php
/**
* Format seconds like a zero padded hh:mm:ss string
* Usage:
* calcDuration(3705); // "1:01:45"
*
* @param integer $seconds
* @return string
*/
function calcDuration($seconds)
@ivanhoe011
ivanhoe011 / .block
Created August 20, 2018 05:02 — forked from mbostock/.block
The Gist to Clone All Gists
license: gpl-3.0
@ivanhoe011
ivanhoe011 / po2json.js
Created August 7, 2018 07:48 — forked from zaach/po2json.js
PO parser from http://jsgettext.berlios.de/lib/Gettext.js adapted for Node.js and modified to be more like po2json.pl
#!/usr/bin/env node
/*
PO parser from http://jsgettext.berlios.de/lib/Gettext.js
adapted for Node.js and modified to be more like po2json.pl
- Zach Carter <zcarter@cse.usf.edu>
*/
/*
Pure Javascript implementation of Uniforum message translation.
@ivanhoe011
ivanhoe011 / mixins.scss
Last active August 6, 2018 10:24
Sass helper for theme colors
/**
* Helper to get a color value from the color-map
* Usage:
* background-color: palette(some-special-blue);
*
* @param $key The color name (key from the map)
*/
@function palette($key) {
@if map-has-key($ci-palette, $key) {
@return map-get($ci-palette, $key);
@ivanhoe011
ivanhoe011 / .eslintrc.json
Created July 21, 2018 10:41
ESLint setup for react, jsx, es2018, class properties, etc...
{
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"eslint-config-prettier"
],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",