Skip to content

Instantly share code, notes, and snippets.

View redgeoff's full-sized avatar

Geoff Cox redgeoff

View GitHub Profile
@redgeoff
redgeoff / promisify.js
Last active August 29, 2015 14:09
Promisify
// This implmentation is probably very similar to Promise.promisify--it can be helpful to visualize the details separately
var promisify = function (fn, thisArg) {
return function () {
var args = Array.prototype.slice.call(arguments, 0); // convert to array
return new Promise(function (resolve, reject) {
var callback = function () {
var err = arguments[0];
@redgeoff
redgeoff / index.js
Last active August 29, 2015 14:28
DeltaDB Dream Code
// TODO: refactor so models for UI, db
'use strict';
var sites = [], db = new DeltaDB('https://websites.example.com', 'user', 'secret'),
websites = db.col('websites');
function setFormValues(site) {
document.getElementById('name').value = site.name ? site.name : '';
document.getElementById('url').value = site.url ? site.url : '';
@redgeoff
redgeoff / index.html
Last active November 10, 2015 20:20
Select2 Many Tags
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.1-rc.1/css/select2.min.css" rel="stylesheet" />
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.1-rc.1/js/select2.min.js"></script>
</head>
<body>
@redgeoff
redgeoff / index.html
Created December 7, 2015 00:34
Cannot create object stores in separate transactions
<script>
var idb = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
// Generate a unique db name as IndexedDB is very delicate and we want our test to focus on a new DB
var dbName = 'mydb' + '_' + (new Date()).getTime() + '_' + Math.round(1000000*Math.random());
var db = null;
var version = 1;
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
# Use a private network so that we don't have to worry about forwarding ports
config.vm.network "private_network", ip: "192.168.10.10"
config.vm.provider "virtualbox" do |v|
# Default of 512 MB is too little for an `npm install`
v.memory = 1024
@redgeoff
redgeoff / index.html
Created April 3, 2016 23:04
PouchDB Filtered Replication Bug
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pouchdb/5.3.1/pouchdb.js"></script>
</head>
<body>
@redgeoff
redgeoff / index.html
Last active October 18, 2018 15:57
Pinch Zoom with HammerJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<title>Pinch Zoom</title>
<style>
@redgeoff
redgeoff / index.html
Last active March 30, 2022 06:15
Pinch Zoom And Pan With HammerJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<title>Pinch Zoom</title>
</head>
<body>
@redgeoff
redgeoff / index.html
Last active September 23, 2016 13:15
Ionic Paste Image
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Todo</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.1/css/ionic.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ionic/1.3.1/js/ionic.bundle.js"></script>
@redgeoff
redgeoff / index.html
Last active December 23, 2022 16:06
Paste Image Div
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Paste Image Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.6/bluebird.min.js"></script>
</head>
<body>