Skip to content

Instantly share code, notes, and snippets.

View OutThisLife's full-sized avatar
🏠
Working from home

brooklyn! OutThisLife

🏠
Working from home
View GitHub Profile
@OutThisLife
OutThisLife / evts.js
Created July 27, 2018 19:48
Get all event listeners from chrome.
// This is to list all events on the page:
[].slice.call(document.querySelectorAll('*'))
.map(el => ({ el, listeners: Object.entries(getEventListeners(el)) }))
.filter(el => el.listeners.length)
// Use with a mutationobserver to confirm that events are detaching:
const _getEventListeners = getEventListeners
const getAll = () => [].slice.call(document.querySelectorAll('*'))
.map(el => ({ el, listeners: Object.entries(_getEventListeners(el)) }))
.filter(el => el.listeners.length)
@OutThisLife
OutThisLife / log.js
Last active July 26, 2018 15:17
Simple template-literal colorized logger --- log.info`The only thing that will highlight is ${thisVariableHere}`
/**
* Example usage:
log.warn`Some message with ${variables} highlighted`;
log.blue`Some message everything highlighted`;
log.info`Some message with ${variables} highlighted`;
log.blueBG`Some message everything highlighted`;
*/
const colours = {
reset: '\x1b[0m',
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
@OutThisLife
OutThisLife / deps
Last active April 21, 2018 07:04
rollup config
"babel-cli": "latest",
"babel-core": "latest",
"babel-eslint": "latest",
"babel-plugin-external-helpers": "latest",
"babel-plugin-styled-components": "latest",
"babel-plugin-transform-object-rest-spread": "latest",
"babel-preset-env": "latest",
"babel-preset-flow": "latest",
"babel-preset-react": "latest",
"eslint-plugin-flowtype-errors": "latest",
@OutThisLife
OutThisLife / raf.js
Last active April 18, 2018 20:43
singleton raf loop
// @flow
export const renders: Array<Function> = []
let animId: AnimationFrameID
export default ((): void => {
if (typeof window === 'undefined') {
return
}
const stop = () => window.cancelAnimationFrame(animId)
@OutThisLife
OutThisLife / .editorconfig
Last active August 9, 2018 16:45
dev tools
root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 2
// Pretend this is in a store somewhere.
const pageData = {
title: 'My Data',
copy: 'Lorem ipsum dolar sit amet',
fields: {
testimonial: {
name: 'Bob Ross',
copy: 'Everything is amazing'
},
rating: 5
@OutThisLife
OutThisLife / sanfrancisco-font.css
Created February 2, 2018 19:00
San Francisco Web Font
/** WARNING - USE AT OWN RISK */
/** IT IS AGAINST APPLE'S POLICY TO USE SF PRO FOR ANYTHING OTHER THAN iOS/tvOS/macOS/watchOS DESIGN & DEVELOPMENT */
/** https://sf.abarba.me/LICENSE.pdf */
/** 1. Copy/import this file into your main css/scss file */
/** 2. Change css font-family: to "SF Text", "SF Display" or "SF Mono" */
/** 3. Apply font-weight or italic to html elements */
/** THANK YOU */
/** I host these fonts on Cloudfront with SSL in all AWS regions for the best performance and reliability */
@OutThisLife
OutThisLife / tween.js
Created January 24, 2018 18:49
Tween between two numbers and return the value as it updates.
import eases from 'eases'
const defaults = {
start: 0,
to: 0,
speed: 650,
easing: 'sineOut',
onUpdate: () => {},
handleEnd: () => {},
handleStart: () => {}
const log = new Proxy({}, {
get: (_, colour) => function() {
console.log(`%c ${[].slice.call(arguments).join(' ')}`, `color: ${colour}`)
}
})
// example
log.tomato('I am tomato')
log.chocolate('I am chocolate')
log.cornflowerblue('I am cornflowerblue')