Navigation Menu

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:8052234
Created December 20, 2013 09:03
Clean git repo: "error: The following untracked working tree files would be overwritten by checkout"
git clean -d -fx ""
@davidhellsing
davidhellsing / gist:7600706
Created November 22, 2013 14:28
IE detection including IE10+11
var ie = (function() {
var v = 3
, div = document.createElement( 'div' )
, all = div.getElementsByTagName( 'i' )
do
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->'
while
(all[0])
return v > 4 ? v : document.documentMode
}())
@davidhellsing
davidhellsing / gist:7597680
Created November 22, 2013 10:10
OS X apache - create a local dev directory
$ cd /Library/WebServer
$ sudo -s
$ mv Documents Documents.old
$ sudo ln -s [projpath] .
$ mv [dirname] Documents
# Now just goto http://localhost and see all your local projects
@davidhellsing
davidhellsing / gist:7488964
Last active December 28, 2015 10:49
Module prefix
(function(a, i, n, o) {
n = i.length && typeof require == 'function' ? (function(e, j, q) {
q = []
for(j=0; j<i.length; j++){
q.push(require(i[j]))
}
return e.apply(o, q)
}(n)) : n.call(o)
@davidhellsing
davidhellsing / gist:6140433
Last active December 20, 2015 13:39
Animate anything with easing and requestFrame.
Animate = (function() {
var requestFrame = (function(){
var r = 'RequestAnimationFrame'
return window.requestAnimationFrame ||
window['webkit'+r] ||
window['moz'+r] ||
window['o'+r] ||
window['ms'+r] ||
function( callback ) {