Navigation Menu

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 / LICENSE.txt
Created May 23, 2011 02:14 — forked from 140bytes/LICENSE.txt
Return the ordinal suffix for a number.
Copyright (c) 2011 Dave Furfero, http://furf.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
const config: CodegenConfig = {
// @ts-ignore TypeScript describes this as a string, but it also supports a
// function.
schema: {
[CONTENTFUL_URI]: {
customFetch: initCustomFetch({
accessToken: CONTENTFUL_MANAGEMENT_ACCESS_TOKEN,
spaceId: CONTENTFUL_SPACE_ID,
environmentId: CONTENTFUL_ENVIRONMENT,
}),
@furf
furf / mongoose-find-by-reference-field.js
Last active April 4, 2023 19:14
Finding a thing by reference using a non ID field.
var mongoose = require('mongoose'),
// Load User model
User = mongoose.model('User'),
// Create Thing schema
thingSchema = new mongoose.Schema({
_user: {
type: ObjectId,
@furf
furf / sleep.html
Created September 2, 2020 16:52
Detect system sleep and wake events in browser.
<html>
<head>
<title>sleep.js</title>
</head>
<body>
<h1>sleep.js</h1>
<script src="sleep.js"></script>
@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.
@furf
furf / 1-tmpl.js
Created October 26, 2010 05:04
JavaScript Micro Templating
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
// @see http://ejohn.org/blog/javascript-micro-templating/
(function(){
var cache = {};
this.tmpl = function tmpl(str, data){
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
@furf
furf / _.deep.js
Created July 30, 2012 17:06
underscore.js mixin for plucking nested properties
_.mixin({
// Get/set the value of a nested property
deep: function (obj, key, value) {
var keys = key.replace(/\[(["']?)([^\1]+?)\1?\]/g, '.$2').replace(/^\./, '').split('.'),
root,
i = 0,
n = keys.length;
@furf
furf / makeChange.js
Last active June 17, 2021 13:12
Given a set of coin denominators, find the minimum number of coins to give a certain amount of change.
function makeChange (amount) {
var change = {},
i = 0,
coins = makeChange.COINS,
coin;
while (amount && (coin = coins[i++])) {
if (amount >= coin) {
change[coin] = ~~(amount / coin);
@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;
<rmp-mock-video-controller>
<rmp-muted-toggle ?muted=${boolean('muted', true)}>
<rmp-mute-button id="story.mute" slot="mute-button">
<icon-mute fill></icon-mute>
</rmp-mute-button>
<rmp-unmute-button id="story.unmute" slot="unmute-button">
<icon-volume fill></icon-volume>
</rmp-unmute-button>
</rmp-muted-toggle>
</rmp-mock-video-controller>