Skip to content

Instantly share code, notes, and snippets.

@ermouth
ermouth / gist:61cab64ffc7cb5578238
Created May 16, 2015 10:11
Polish notation expression eval
var polish = (function () {
var ops = ['*','/','+','-']
.reduce( function(a, b){
a[b] = Function ( 'x', 'return x[0]=x.shift()' + b + 'x[0], x' );
return a;
}, {});
Object.getOwnPropertyNames(Math)
.forEach( function(b){
var l = Math[b].length, f = '';
if (l === void 0) f = 'x.unshift(Math.' + b + '), x';
@ermouth
ermouth / gist:53692ee474abc3b301fc
Last active August 29, 2015 14:23
$.my Master-detail
({
"params": {
"delay": 30,
"recalcDepth": 1
},
"require": [{
// You may need to insert you own data source since CORS limitations could apply
"this.List": "http://s3-eu-west-1.amazonaws.com/ermouth/rockstar-deaths.json"
}],
"data": {
@ermouth
ermouth / rewrites.js
Last active September 4, 2015 18:21
Rewrites for Inliner
([
// Root
{from:"/:db/_inliner", to:"../../../:db/_design/inliner27/index.html"},
// Resources
{from:"/:db/js/*", to:"../../../:db/_design/inliner27/js/*"},
{from:"/:db/css/*", to:"../../../:db/_design/inliner27/css/*"},
{from:"/:db/i/*", to:"../../../:db/_design/inliner27/i/*"},
{from:"/:db/inliner-templates.json", to:"../../../:db/_design/inliner27/inliner-templates.json"},
{from:"/:db/inliner-widgets.json", to:"../../../:db/_design/inliner27/inliner-widgets.json"},
@ermouth
ermouth / manloader.js
Last active September 3, 2015 06:45
External manifest loader
({
require:[
{
"this.App":{
url:"http://your.domain/someExternalManifest.json",
dataType:"json",
cache:false
}
}
],
@ermouth
ermouth / ToDo.js
Created September 7, 2015 16:00
Sample plugin manifest for Inliner
{
"id": "in.ToDo",
name:"Todo list",
"data": {
"cmd": "",
"filter": ["All"],
"editor": {
"_id": "",
"name": "",
"type": "todo",
@ermouth
ermouth / expenseReportDemo.js
Last active September 20, 2015 22:40
Sample expense repor widget
({
// name must be present for widgets,
// and it must be unique
name:"Expense report demo",
id:"in.ExpenseReportDemo",
// Default data
data:{
ERROR:false, // holds overall error state, true if form has errors
title:"",
@ermouth
ermouth / couch-rewrite-fn-penalties.js
Last active September 25, 2015 07:03
CouchDB query server js call penalties
// Tests process switching penalties for calling
// CouchDB query server js functions.
// Requires jQuery
var passes = 50, host="https://cloudwall.cloudant.com/testr/";
function go (msg, url) {
var pi = $.Deferred(),
ctr = passes,
@ermouth
ermouth / b010.log
Created October 10, 2015 20:49
Barrel 010 build log
===> Cleaning out couch...
===> Cleaning out couch_changes...
===> Cleaning out couch_dbupdates...
===> Cleaning out couch_httpd...
===> Cleaning out couch_index...
===> Cleaning out couch_mrview...
===> Cleaning out couch_randomdoc...
===> Cleaning out couch_replicator...
===> Cleaning out geocouch...
===> Verifying dependencies...
@ermouth
ermouth / treematch.js
Last active November 16, 2015 05:03
Recursive pattern matcher for CouchDB
(function () {
// matches.js
// ----------
// Powerful pattern matching for Javascript
//
// version : 0.5.1
// author : Nathan Faubion <nathan@n-son.com>
// repo : https://github.com/natefaubion/matches.js
// license : MIT
@ermouth
ermouth / rewrites.rst
Last active December 5, 2015 15:22
CouchDB js rewrites - I
.. Licensed under the Apache License, Version 2.0 (the "License"); you may not
.. use this file except in compliance with the License. You may obtain a copy of
.. the License at
..
.. http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing, software
.. distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
.. WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
.. License for the specific language governing permissions and limitations under