Skip to content

Instantly share code, notes, and snippets.

@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)
@raphaelschaad
raphaelschaad / RSPlayPauseButton.h
Last active July 25, 2016 21:44
Edit: this Gist has now a proper repo and even a CocoaPod: https://github.com/raphaelschaad/RSPlayPauseButton
//
// RSPlayPauseButton.h
//
// Created by Raphael Schaad on 2014-03-22.
// This is free and unencumbered software released into the public domain.
//
#import <UIKit/UIKit.h>
@spr
spr / ExampleDelegate.h
Last active March 22, 2017 10:57
An Example NSURLConnection delegate
//
// ExampleDelegate.h
// Example
//
// Created by Scott Robertson on 2/10/13.
// Copyright (c) 2013 Scott Robertson. All rights reserved.
//
#import <Foundation/Foundation.h>
@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)) {
@davidmerrique
davidmerrique / zoomify.jsx
Last active April 14, 2017 06:17
Photoshop Script to save multiple sizes of an image. I use it for work.
var inFolder = Folder.selectDialog("Please select folder to process");
if(inFolder !== null) {
var fileList = inFolder.getFiles(/\.(jpg|tif|psd|)$/i);
var outfolderName = prompt('Folder name', 'zoom');
var outfolder = new Folder(decodeURI(inFolder) + "/" + outfolderName);
if (!outfolder.exists) outfolder.create();
for(var a = 0; a < fileList.length; a++) {
@AramZS
AramZS / all-ll.html
Last active September 25, 2017 12:05
LazyLoad techniques
<!-- http://www.vox.com/2015/1/29/7947263/media-internet-poetry -->
<img
class="vox-lazy-load m-chorus-asset__in-entry-body"
src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
alt=" "
data-chorus-asset-id="3356728"
data-full-size="https://cdn2.vox-cdn.com/thumbor/JjbTvM14EYv6600xMXvyxzNw4BA=/cdn0.vox-cdn.com/uploads/chorus_asset/file/3356728/Vox.0.png"
data-original="https://cdn1.vox-cdn.com/uploads/chorus_asset/file/3356728/Vox.0.png" />
<noscript>
<img
@indragiek
indragiek / Theming.swift
Last active February 3, 2018 23:21
Swift API for theming on iOS
// Created by Indragie on 5/3/15.
// Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
import UIKit
public protocol ThemeType {
typealias Target
func apply(target: Target)
}
@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))
@natecook1000
natecook1000 / VulgarFraction.swift
Created August 28, 2014 03:08
Vulgar Fractions
// (c) 2014 Nate Cook, licensed under the MIT License
/**
Returns a tuple with the closest compound fraction possible with Unicode's built-in "vulgar fractions".
See here: http://www.unicode.org/charts/PDF/U2150.pdf
:param: number The floating point number to convert.
:returns: A tuple (String, Double): the string representation of the closest possible vulgar fraction and the value of that string
@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