Skip to content

Instantly share code, notes, and snippets.

View furf's full-sized avatar
🎯
Focusing

Dave Furfero furf

🎯
Focusing
View GitHub Profile
@furf
furf / gist:09b115e96d7dc8498b3136db3760e507
Created December 22, 2017 22:07 — forked from remy/gist:350433
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@furf
furf / Parallax.js
Last active May 26, 2017 21:52
React components for parallax scrolling.
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames/bind';
const now = Date.now();
const PERSPECTIVE_KEY = `__perspective--${now}__`;
const DISABLED_KEY = `__perspective--${now}--disabled__`;
/**

Keybase proof

I hereby claim:

  • I am furf on github.
  • I am furf (https://keybase.io/furf) on keybase.
  • I have a public key ASBc1_hHJft8h6eTvM9D7Y8NxDFW56ds5T0DrMLhp4eFhAo

To claim this, I am signing this object:

@furf
furf / README.md
Created July 15, 2016 01:04 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@furf
furf / fu.js
Last active January 26, 2021 05:25
furf’s functional funpack
/**
* Introducing fu: furf's functional funpack.
* "Putting the F-U back in JS!"
*
* fu.Array.map([1, 2, 3], a => a * 2) => [2, 4, 6]
* fu.String.repeat('fu ', 3) => "fu fu fu"
*/
this.fu = (function() {
const call = Function.prototype.call;
@furf
furf / fib-dyna-in-place.js
Created June 2, 2016 17:40
Comparison of recursive, memoized recursive and dynamic programming approaches to calculating the Fibonacci series.
function fibDynaInPlace(n) {
let dp = [0, 1];
for (let i = 2; i <= n; ++i) {
dp = [dp[1], dp[1] + dp[0]];
}
return dp[1];
}
try {
/* Paste your entire codebase here */
} catch (e) {
window.open('http://stackoverflow.com/search?q=[js]+' + e.message, '_blank');
}
@furf
furf / reverseLinkedList.js
Last active April 29, 2016 16:10
Reverse a linked list. Or something.
const Node = {
value: null,
next: null,
};
function createNode(value) {
return Object.assign(Object.create(Node), { value });
}
function isNode(node) {
@furf
furf / clamp.js
Last active March 31, 2016 16:48
a more sophisticated clamp
/**
* Restrict a value to within specified boundaries.
* - If only the `value` is specified, the boundaries are 0 and 1.
* - If only the `value` and boundary `a` are specified, the boundaries
* are 0 and `a`.
* - If the value and both boundaries `a` and `b` are specified, the
* boundaries are `a` and `b`.
* Clamp does not enforce the proper ordering of the boundaries.
* Therefore, clamp(2, 1, 3) and clamp(2, 3, 1) will return the same
* result.
@furf
furf / how-to.md
Last active June 27, 2022 01:57
Slack invite integration for Google Forms
  1. Create a Google Form with a field to collect email addresses. Pro-tip: use Data Validation to validate string is valid email.
  2. Click View Responses to view form responses in Google Spreadsheets.
  3. Open menu Tools > Script editor...
  4. Paste in Google App Script below and make the following changes:
    • Create a Slack API token and replace the value of SLACK_API_TOKEN.
    • Replace "YOUR_TEAM_NAME" with your team's name in the value for SLACK_API_INVITE_URL.
    • Make sure EMAIL_FIELD_NAME corresponds to the header text of your Google Spreadsheet's email column.
  5. Open menu Resources > Current project's triggers and add a new trigger: onFormSubmit, From spreadsheet, On form submit. Click Save and accept the authorization request to use the script.
  6. You can optionally configure notifications to receive error messages by email.