Skip to content

Instantly share code, notes, and snippets.

fisk();
throw new Error('fisk');
@davidhellsing
davidhellsing / gist:6d5d8fd1a62943e43a6a91f6982e63b8
Last active February 20, 2019 13:38
Simple, functional animation of values using React Native Easing
import { Easing } from 'react-native'
/*
* Function that animates a value from 0 - 1
* Uses React Native’s Easing functions
* Returns an object that has a stop() function
*/
interface Args {
duration: number,
@davidhellsing
davidhellsing / gist:6fbd8b82d14cec8482e9d9b427aae62c
Created January 17, 2018 00:20
simple vanillaJS smooth scroll
<html>
<head>
<style>
#content{height: 8000px; width: 800px; margin: 0 auto; background: yellow;position: relative;}
</style>
</head>
<body>
<div id="content">
Lorem<br>
Lorem<br>
@davidhellsing
davidhellsing / gist:01ecaecd4245441a81280310f7e847bc
Last active December 15, 2017 13:11
Haystack needle recursive
findKey = (haystack, needle) => {
let found = false
const iterate = (obj) => (
Object.keys(obj).forEach((key) => {
if (found === false) {
if (key === needle) {
found = key
} else if (obj[key] && typeof obj[key] === 'object') {
iterate(obj[key])
}
var keys = [37, 38, 39, 40]
var prevent = (e) => {
if ( e.type != 'keydown' || keys.indexOf(e.keyCode) != -1 ) {
e.preventDefault()
return false
}
}
var disableScroll = (node) => {
node = node || window
node.onwheel = node.ontouchmove = document.onkeydown = prevent
@davidhellsing
davidhellsing / gist:04c9490212ec04fdf99f
Created October 21, 2015 12:07
Fix: Cairo for el Capitan
xcode-select --install
@davidhellsing
davidhellsing / gist:b8a24b537750de4064cc
Created November 24, 2014 13:22
Fix: X11 for Yosemite

sudo ln -s /opt/X11 /usr/X11

@davidhellsing
davidhellsing / gist:e6eea9c6659ca9c23e7a
Created October 24, 2014 09:31
Postgres fix for yosemite

sudo mkdir -p /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat_tmp}/

@davidhellsing
davidhellsing / gist:f2c4842e3fea551a32ce
Last active August 29, 2015 14:07
Fix Brew for OSX Yosemite
vi /usr/local/Library/brew.rb

Change line 1 from:

#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

to:

#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0

Save and exit

// example:
// var stateHandler = State(node, function(state) { this.className = state.active ? 'active' : '' })
// stateHandler.set({ active: true })
var states = {}
function State(elem, render) {
if ( states.hasOwnProperty(elem) )
return states[elem]
if ( !(this instanceof State) ) {
var instance = new State(elem, render)