Skip to content

Instantly share code, notes, and snippets.

@michaelhood
michaelhood / .cvimrc
Created July 22, 2018 08:37 — forked from troyp/.cvimrc
.cvimrc
" ________
" | |
" | CVIMRC |
" |________|
" ,----------,
" | settings |
" '----------'
set localconfig
import r2 from '@mcro/r2'
import puppeteer from 'puppeteer'
import * as _ from 'lodash'
const sleep = ms => new Promise(res => setTimeout(res, ms))
const onFocus = page => {
return page.evaluate(() => {
return new Promise(res => {
if (document.hasFocus()) {
res()
@michaelhood
michaelhood / _1_"script async defer" blocks "load" event.md
Created June 15, 2018 21:00 — forked from jakub-g/_1_"script async defer" blocks "load" event.md
Beware of "script async defer" blocking HTML "load" event

Beware of <script async defer> blocking HTML "load" event

2015.10.07 t

On the importance of simulated latency testing, and bulletproofing your page from the third-party JS load failures

TL;DR

@michaelhood
michaelhood / background.js
Created April 24, 2018 07:37 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@michaelhood
michaelhood / bash-template
Created March 23, 2018 06:32 — forked from renzok/bash-template
A template bash script based on google style guide with some little improvements
#!/bin/bash
# Here short description of this script
# This is just a template to be used for writing new bash scripts
###
# Based on Google Style Guide: https://google.github.io/styleguide/shell.xml
# General remarks
# * Executables should have no extension (strongly preferred) or a .sh extension.
# * Libraries must have a .sh extension and should not be executable
@michaelhood
michaelhood / concentrate.js
Last active July 5, 2017 07:31 — forked from kdzwinel/concentrate.js
DevTools snippet that lets you focus on a single element during developement
(function() {
function hideEverythingAround($el) {
const $parent = $el.parentElement;
$parent.style.transition = 'background-color 150ms ease-in';
$parent.style.backgroundColor = 'white';
$parent.childNodes.forEach($child => {
if($child !== $el && $child.style) {
@michaelhood
michaelhood / disable-full-sync-on-flush.sh
Created June 20, 2017 10:57 — forked from mkrakauer-rio/disable-full-sync-on-flush.sh
Docker for Mac - Disable full disk sync on flush
cd ~/Library/Containers/com.docker.docker/Data/database/
git reset --hard
cat com.docker.driver.amd64-linux/disk/full-sync-on-flush
# if you see true, continue
echo false > com.docker.driver.amd64-linux/disk/full-sync-on-flush
cat com.docker.driver.amd64-linux/disk/full-sync-on-flush
# you should now see false
git add com.docker.driver.amd64-linux/disk/full-sync-on-flush
git commit -s -m "Disable flushing"
# wait for docker to restart
@michaelhood
michaelhood / .block
Created June 18, 2017 06:34 — forked from ColinEberhardt/.block
London Marathon Finish Times 2016
license: mit
@michaelhood
michaelhood / TrueColour.md
Created June 8, 2017 09:05 — forked from XVilka/TrueColour.md
True Colour (16 million colours) support in various terminal applications and terminals

Colours in terminal

It's a common confusion about terminal colours... Actually we have this:

  • plain ascii
  • ansi escape codes (16 colour codes with bold/italic and background)
  • 256 colour palette (216 colours + 16 ansi + 24 gray) (colors are 24bit)
  • 24bit true colour ("888" colours (aka 16 milion))
printf "\x1b[${bg};2;${red};${green};${blue}m\n"
@michaelhood
michaelhood / histogram.sql
Created June 4, 2017 19:03 — forked from wolever/histogram.sql
Functions to create and draw histograms with PostgreSQL.
-- Functions to create and draw histograms with PostgreSQL.
--
-- psql# WITH email_lengths AS (
-- -# SELECT length(email) AS length
-- -# FROM auth_user
-- -# LIMIT 100
-- -# )
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths))
-- bucket | range | count | bar | cumbar | cumsum | cumpct
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------