Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
nolanlawson / index.html
Last active Aug 22, 2020 — forked from bemson/index.html
Web Worker via blob URL
View index.html
<!doctype html>
<html lang="en">
<body>
<span id="output"></span>
</body>
<script>
(function () {
var workerBlob = new Blob(
[workerRunner.toString().replace(/^function .+\{?|\}$/g, '')],
{ type:'text/javascript' }
View example.js
let companyWebsites = await* companiesJSON.map(company => getWebsite(company))
let companies = companyWebsites.map((website, i) => {
let company = companiesJSON[i]
company.website = website
return company
})
@nolanlawson
nolanlawson / index.html
Last active Aug 29, 2015 — forked from joshongit/index.html
Sample Pouch db example with collate
View index.html
<html>
<body>
<input type="text" id="keyVal"><button onclick="getResult()">Filter</button><button onclick="getAllDocs()">Show available doc</button><button onclick="generateDoc()">Generate Doc</button><button onclick="destroyDB()">Destroy DB & Reload</button>
<div id="result"></div>
<script src="//cdn.jsdelivr.net/pouchdb/latest/pouchdb.min.js"></script>
<script src="https://rawgit.com/pouchdb/collate/master/dist/pouchdb-collate.js"></script>
<script src="init.js"></script>
</body>
</html>
View index.html
<!DOCTYPE html>
<html>
<head>
<title>PouchDB #2342</title>
<script src="pouch.js"></script>
<script src="main.js"></script>
</head>
<body>
</body>
View angular-1.3.0b7.min.js
/**
* @license AngularJS v1.3.0-beta.7
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, document, undefined) {'use strict';
/**
* @description
*
View index.js
var expressPouchDB = require('express-pouchdb');
expressPouchDB.setBackend(require('memdown'));
app.use(expressPouchDB);
var pouch = expressPouchDB.getPouchDB('dbname');
View gist:cf4815aef7c7fcbda93f
var dbname = "dbtemp" + randomName();
var docname = "doc" + randomName();
var remote = 'http://localhost:5984/'+ dbname + ~~(Math.random() * 1000000)
var PouchDB = require('pouchdb');
var pouch = new PouchDB(dbname);
pouch.put({_id: docname}).then(function() {
pouch.put({_id: docname}).then(function() {
pouch.replicate.to(remote).on('error', function(err) {
console.log('error');
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//cdn.jsdelivr.net/pouchdb/2.2.0/pouchdb.js"></script>
<script type="text/javascript">
var db;
function setupDb() {
try {
db = new PouchDB('testdb');
View index.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//cdn.jsdelivr.net/pouchdb/2.2.0/pouchdb.js"></script>
<script type="text/javascript">
var db;
function setupDb() {
try {
db = new PouchDB('testdb');
View ascript.js
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