Skip to content

Instantly share code, notes, and snippets.

@DrBoolean
DrBoolean / three_envs.js
Last active May 24, 2021 02:31
Tail of three envs
const compose = (f, g) => x => f(g(x))
const Id = x =>
({
fold: f => f(x),
map: f => Id(f(x))
})
Id.of = Id
const Tuple = (_1, _2) =>
@jasorod
jasorod / SVGPath.swift
Last active January 31, 2024 19:13 — forked from dotcypress/SVGPath.swift
SVG path to CGPath converter
//
// SVGPath.swift
// SVGPath
//
// Created by Tim Wood on 1/21/15.
// Updated by Vitaly Domnikov 10/6/2015
// Updated by Jason Rodriguez 08/29/2017
// Copyright (c) 2015 Tim Wood, Vitaly Domnikov, Jason Rodriguez. All rights reserved.
import Foundation
@bmeck
bmeck / chatting.js
Last active April 1, 2017 00:48
a chat server using generators to manage connection state.
'use strict';
/*::
type Client = Object;
type Channel = string;
*/
const channels/*: Map<Channel, Set<Client>> */ = new Map;
const clients/*: Map<Client, Set<Channel>> */ = new WeakMap;
const join = (name, client) => {
if (!channels.has(name)) {
@teameh
teameh / PanResponder_Overview.js
Last active October 21, 2023 05:28
React native PanResponder interface overview
this._panResponder = PanResponder.create({
// ----------- NEGOTIATION:
// A view can become the touch responder by implementing the correct negotiation methods.
// Should child views be prevented from becoming responder on first touch?
onStartShouldSetPanResponderCapture: (evt, gestureState) => () => {
console.info('onStartShouldSetPanResponderCapture');
return true;
},
@nixta
nixta / AGSSingleFingerZoomGestureRecognizer.swift
Last active March 23, 2021 13:17
A Google-Maps like single-finger zoom gesture for the ArcGIS Runtime SDK for iOS. Awesome idea, Google Maps team! 👏👏👏
//
// AGSSingleFingerZoomGestureRecognizer.swift
//
// Created by Nicholas Furness on 6/17/16.
// Copyright © 2016 Esri. All rights reserved.
//
import Foundation
import ArcGIS
@DrBoolean
DrBoolean / SumProductList.js
Last active March 27, 2018 20:54
Either and Tuple (the canonical Sum/Product types, respectively) used to make a List
const {Left, Right} = require('data.either')
const Tuple = require('fantasy-tuples').Tuple2
//List :: Either Null (Tuple a List)
const empty = () =>
Left(null)
const cons = (x, l) =>
Right(Tuple(x, l))
@brunotavares
brunotavares / react-native-double-tap.js
Last active June 4, 2022 17:14
Double tap gesture recognition for React Native.
const DOUBLE_PRESS_DELAY = 300;
// ...
/**
* Double Press recognition
* @param {Event} e
*/
handleImagePress(e) {
const now = new Date().getTime();
@jondot
jondot / keybez.md
Created January 14, 2016 16:49
ios keyboard bezier
  onKeyboardWillHide(e) {
    Animated.timing(this.state.height, {
      toValue: this.listViewMaxHeight,
      duration: e.duration,
      easing: Easing.bezier(0.1, 0.76, 0.55, 0.9)
    }).start();
  },

 onKeyboardWillShow(e) {
@jimbolla
jimbolla / protectFromUnmount.js
Created November 16, 2015 19:38
protectFromUnmount
function protectFromUnmount() {
let callbacks = {};
let count = 0;
const noop = value => value;
const wrapCallback = id => function(...params) {
const raceSafeCallbacks = callbacks;
if (!raceSafeCallbacks)
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent