Skip to content

Instantly share code, notes, and snippets.

View jhs's full-sized avatar

Jason Smith jhs

  • McKinsey & Company
  • New York, NY
View GitHub Profile
@jhs
jhs / case.js
Last active September 28, 2015 09:58
A better case statement?
// Prettier case statement, but can also return a value since it is an expression.
//
first_condition
? first_action()
: second_condition
? second_action()
: third_condition && can && (be || compound)
? action_3()
: default_action()
@jhs
jhs / gist:1407764
Created November 30, 2011 02:50 — forked from boxxxie/gist:1406402
reduce:function(key, values, rereduce) {
function addPropertiesTogether(addTo,addFrom){
for (var prop in addFrom) {
(addTo[prop] !== undefined) ? addTo[prop] += Number(addFrom[prop]): addTo[prop] = Number(addFrom[prop]);
}
return addTo;
};
return values.reduce(addPropertiesTogether,{});
}
@jhs
jhs / admin.diff
Created September 17, 2011 00:52
CORS
commit 08b26333c44f9a86a8d9b87f4a1e6d51e9ac624c
Author: Jason Smith <[email protected]>
Date: Wed May 18 08:08:36 2011 +0700
A configuration option httpd.cors_admin to allow _admin over CORS
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index db6809b..3193855 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@jhs
jhs / Requirements.txt
Created September 12, 2011 18:34
In-progress write-only DB implementation. (Will be multiple smaller commits when I post to JIRA)
Currently, we can only grant dual read-write access in the _security
object "members" section. A user can either do both (name or role in
.members), or do neither (name and role not in .members). This
prevents a very common requirement for couch apps: sending private
information from less-privileged users to more-privileged users. There
is no (reasonable) way to make an "inbox" where anybody may create a
doc for me, but only I may read it. An inbox database allows
user-to-user, or user-to-admin private messages. (Don't think chat
messages. Think asynchronous notifications. With a per-user inbox,
think service requests and responses.)