Skip to content

Instantly share code, notes, and snippets.

View mschwartz's full-sized avatar

Michael Schwartz mschwartz

  • Southwestern USA
View GitHub Profile
@grgur
grgur / async-generator.js
Last active September 12, 2015 22:11
Demo of async/await with ES6 generators
function makeRequest(url) {
fetch(url)
.then(response => response.json())
.then(json => it.next(json))
.catch(error => console.error('Somthing shit the bed', error));
}
function *syncRequests() {
const redditUrl = 'https://www.reddit.com/controversial.json?count=1&limit=2';
const page1 = yield makeRequest(redditUrl);
var myObject = {
"foo": true,
"author": "simon",
"env": 123
}
var myProxy = new JavaAdapter(org.mozilla.javascript.NativeObject, {
// The "start" argument is here for setters and getters living
// on a prototype, so they know what to use as "this"-object.
put: function(name, start, value) {
@oberhamsi
oberhamsi / proxytest.js
Created November 7, 2012 13:21
js Proxy in rhino
var myObject = {
"foo": true,
"author": "simon",
"env": 123
}
var myProxy = new JavaAdapter(org.mozilla.javascript.NativeObject, {
// The "start" argument is here for setters and getters living
// on a prototype, so they know what to use as "this"-object.
put: function(name, start, value) {
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');