Skip to content

Instantly share code, notes, and snippets.

View xiel's full-sized avatar
🖖

Felix Leupold xiel

🖖
View GitHub Profile
@xiel
xiel / delete-folders-with-name.sh
Created February 18, 2019 22:36
Delete all folders with a specific name recursively (including their contents)
Delete all folders with given name, example “.svn” etc.
find . -type d -name '.svn' -print -exec rm -rf {} \;
find . -type d -name '.idea' -print -exec rm -rf {} \;
find . -type d -name '.sass-cache' -print -exec rm -rf {} \;
find . -type d -name 'node_modules' -print -exec rm -rf {} \;
@xiel
xiel / gist:c5f645e89499874f4d1f5c99da002041
Created February 19, 2019 21:55
Add Spaces to Dock in OS X
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'; killall Dock
@xiel
xiel / optionalChain.ts
Last active July 8, 2019 11:14
Optional Chaning in Typescript
/**
* Optional Chaining in Typescript
* lets you safely access nested properties, while preserving type information
*
* Usage:
* type TData = { foo: Optional<{ bar: Optional<number> }> }
* const data: TData = { foo: undefined }
* const num = optionalChain(() => data.foo!.bar)
*/
type Optional<T> = T | undefined
@xiel
xiel / gist:46d9e67edc93a6e470bf737802657a05
Created March 2, 2019 16:51
Typescript | Conditional Types
interface foo {
foo1: string
foo2: string
blubb: string
}
interface bar {
bar1: number
bar2: number
blubb: number
@xiel
xiel / conditional-types.ts
Last active March 2, 2019 16:52
Typescript | Conditional Types
/*
tyescript different sets of parameters OR function signature
*/
interface foo {
foo1: string
foo2: string
blubb: string
}
interface bar {
@xiel
xiel / facebook-normalize-wheel.js
Created September 3, 2019 18:52 — forked from akella/facebook-normalize-wheel.js
Facebook attempt at normalizing wheel event
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule normalizeWheel
* @typechecks
@xiel
xiel / index.html
Created September 3, 2019 19:36
JS Bin Touchpad pinch demo // source https://jsbin.com/wukevep
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Touchpad pinch demo" />
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
http://experimental.mural.ly/vnext-mural/sticky/200/webglbody {
-ms-scroll-rails: none;
}
@xiel
xiel / vapor.1.gif
Last active October 30, 2019 15:36 — forked from mathdroid/vapor.1.gif
👀
vapor.1.gif
@xiel
xiel / gestureProjection.ts
Created January 3, 2020 19:06
projection function, returning distance that is to be expected from a release velocity of a gesture (spring / animation)
const DECAY_FAST = 0.99
const DECAY_NORMAL = 0.998
const projection = (velocityPxMs: number) => (velocityPxMs * DECAY_FAST) / (1 - DECAY_FAST)
@xiel
xiel / useScrollDirection.ts
Created January 30, 2020 11:12
useScrollDirection react hook
import { useEffect, useRef, useState } from 'react'
import { getDocumentScrollPos } from '../helpers/getDocumentScrollPos'
import isPassiveSupported from '../helpers/isPassiveSupported'
type AxisName = 'x' | 'y'
type ScrollDir = '' | 'positive' | 'negative'
interface ScrollDirState {
dir: ScrollDir
hitThreshold: boolean
isAtMin: boolean