Skip to content

Instantly share code, notes, and snippets.

@seabaylea
seabaylea / BuildWithNSURLSession.md
Created June 11, 2016 16:02
How to build a Swift toolchain on Linux with full Dispatch and NSURLSession support

Follow the instructions to checkout a full Swift build for Linux:

git clone https://github.com/apple/swift.git
cd swift
./utils/update-checkout --clone

Update the libdispatch component to use the 'experimental/foundation' branch:

cd swift-corelibs-libdispatch
@beaucharman
beaucharman / debounce.js
Last active February 25, 2022 20:35
An ES6 implementation of the debounce function. "Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called. As in 'execute this function only if 100 milliseconds have passed without it being called.'" - CSS-Tricks (https://css-tricks.com/the-difference-between-throttling-and-debounc…
function debounce(callback, wait, immediate = false) {
let timeout = null
return function() {
const callNow = immediate && !timeout
const next = () => callback.apply(this, arguments)
clearTimeout(timeout)
timeout = setTimeout(next, wait)
@lukewhitehouse
lukewhitehouse / README.md
Last active September 10, 2015 11:01
Check for if an element is in view

Check for if an element is in view

This script allows you to tell when an element becomes visible in the browser window. You can use this to apply styling/animations to elements.

Instructions

Add this to your javascript. Make sure jQuery is called before this script.

Requirements

  • jQuery
@stuartjmoore
stuartjmoore / WPTextAttachment.h
Last active October 21, 2016 13:08
Creates an NSTextAttachment the takes up the entire width of the line fragment (while maintaining its aspect ratio). Instead of a simple image, any UIView (that has a (CGFloat)heightThatFits method) will work.
//
// WPTextAttachment.h
// ReadArticle
//
// Created by Moore, Stuart on 12/27/13.
// Copyright (c) 2013 The Washington Post. All rights reserved.
//
#import <UIKit/UIKit.h>
@eytanschulman
eytanschulman / gist:8521776
Created January 20, 2014 15:20
How to make UIActivityViewController not lag
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self presentViewController:activityVC animated:YES completion:^{
}];
}];
@coenjacobs
coenjacobs / wc-attribute-links.php
Created May 4, 2012 14:05
Display WooCommerce product attribute archive links on product page, right below the add to cart button.
@dhm116
dhm116 / ie.shims.js
Created February 10, 2012 15:14
IE7/8 Javascript method shims
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);