Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / index.html
Last active August 26, 2015 21:33
Basic PouchDB authentication test site
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link rel="stylesheet" href="./mocha.css" />
<script src="./mocha.js"></script>
<script>
mocha.setup('bdd');
</script>
@nolanlawson
nolanlawson / test.md
Last active August 28, 2015 22:10
Test results
  • MacBook Pro (Retina, 15-inch, Late 2013)
  • Yosemite 10.10.5
  • basic-updates 200 iterations
  • 243758c51f6ee906af0d4821fe891577058cab6b vs 4.0.0

safari 9.0

before: 24867ms after: 17232ms

@nolanlawson
nolanlawson / xhr_obfuscation.md
Created February 7, 2014 19:20
XHR obfuscation for web games

XHR obfuscation for web games

This is just a Gist to remind myself to start implementing this at some point. This would be a cool library.

@nolanlawson
nolanlawson / tests.broken.js
Created February 11, 2014 17:24
Deliberately broken test.basics.js test
it('update_seq persists', function(start) {
var name = testHelpers.name;
testUtils.initTestDB(name, function(err, db) {
db.post({test:"somestuff"}, function (err, info) {
new PouchDB(name, function(err, db) {
db.info(function(err, info) {
equal(info.doc_count, 2, 'Doc Count persists'); // should be 1
start();
});
});
@nolanlawson
nolanlawson / print_pouchdb_size.py
Created April 9, 2014 18:46
print_pouchdb_size.py
#!/usr/bin/env python
#
# Prints the pouchdb.min.js and gzipped file sizes for
# all PouchDB builds in the past several months.
#
import requests, zlib
def main():
print 'Commit','GitHub link','Date','pouchdb.min.js size','gzipped size'
@nolanlawson
nolanlawson / size_diffs.md
Last active August 29, 2015 13:58
Top 20 most size-increasing and size-reducing pouchdb commits
@nolanlawson
nolanlawson / inconsistent_results_couchdb_reduce_error.js
Created April 10, 2014 02:56
inconsistent_results_couchdb_reduce_error.js
it('should handle user errors in reduce functions', function () {
return new Pouch(dbName).then(function (db) {
function getKey(row) {return row.key; }
db.on('error', function () { /* noop */ });
return createView(db, {
map : function (doc) {
emit(doc.name, doc.data);
},
reduce : function (keys, values) {
return values[0].foo.bar;
@nolanlawson
nolanlawson / pouchdb_index_api.md
Last active August 29, 2015 14:00
PouchDB 2.3.0 index API proposal

PouchDB 2.3.0 index API proposal

Wherein we hack up our dream map/reduce API, slated to be introduced in PouchDB 2.3.0.

Basic

new PouchDB('mydb', {indexes: ['title']});
var start = document.getElementById('start');
var stuff = document.getElementById('stuff');
var remote = new PouchDB('http://registry.npmjs.org/', {cache: true});
var local = new PouchDB('npm');
start.addEventListener('click', function (){
remote.info().then(function (a) {
return a.doc_count;
}).then(function (count) {
remote.replicate.to(local, {
batch_size: 100
@nolanlawson
nolanlawson / websql_example.js
Created April 26, 2014 16:13
websql_example.js
openDatabase('mydatabase', 1, 'mydatabase', 5000000, function (db) {
function onTransactionSuccess() {
console.log('yay, transaction succeeded!');
}
function onTransactionError() {
console.log('boo, transaction failed!');
}
db.transaction(function (tx) {