Skip to content

Instantly share code, notes, and snippets.

Glenn Crownover bluejava

Block or report user

Report or block bluejava

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bluejava
bluejava / Example5.js
Last active Jun 27, 2019
Example 5 for Medium Post
View Example5.js
Zousan.evaluate(
{ name: "username", value: "glenn" },
{ name: "user", value: getUser, deps: [ "username" ] },
{ name: "favs", value: getFavorites, deps: [ "user" ] },
{ name: "userRenderer", value: renderUser, deps: [ "user" ] },
{ value: renderUserFavs, deps: [ "userRenderer", "favs" ] }
)
@bluejava
bluejava / Example5-vanilla.js
Last active Nov 3, 2016
Example 5 Vanilla for Medium Post
View Example5-vanilla.js
var username = "glenn"
getUser(username)
then(function(user) {
renderUser(user)
.then(function(userRenderer) {
getFavorites(user)
.then(function(favs) { renderUserFavs(userRenderer, favs) })
})
})
@bluejava
bluejava / Example4-vanilla.js
Created Nov 3, 2016
Example 4 Vanilla for Medium Post
View Example4-vanilla.js
var username = "glenn"
getUser(username)
then(function(user) {
getFavorites(user)
.then(function(favs) { renderUserFavs(user,favs) })
renderUser(user)
})
@bluejava
bluejava / Example4.js
Last active Jun 27, 2019
Example 4 for Medium Post
View Example4.js
Zousan.evaluate(
{ name: "username", value: "glenn" },
{ name: "user", value: getUser, deps: [ "username" ] },
{ name: "favs", value: getFavorites, deps: [ "user" ] },
{ value: renderUser, deps: [ "user" ] },
{ value: renderUserFavs, deps: [ "user", "favs" ] }
)
@bluejava
bluejava / Example3.js
Last active Jun 27, 2019
Example 3 for Medium Post
View Example3.js
function getUser(name) { /* returns Promise of user object */ }
function getFavorites(user) { /* returns Promise of favorites array */ }
Zousan.evaluate(
{ name: "username", value: "glenn" },
{ name: "user", value: getUser, deps: [ "username" ] },
{ name: "favs", value: getFavorites, deps: [ "user" ] }
).then(function(ob) {
renderUserFavs(ob.user, ob.favs)
})
@bluejava
bluejava / Example2.js
Last active Jun 27, 2019
Example 2 for Medium Post
View Example2.js
function getScore() { return 45 }
function double(x) { return x * 2 }
Zousan.evaluate(
{ name: "username", value: "glenn" },
{ name: "score", value: getScore },
{ name: "newScore", value: double, deps: [ "score" ] }
).then(function(ob) {
console.log("Hello " + ob.username + ". Your new score is " + ob.newScore)
})
@bluejava
bluejava / example1.js
Last active Jun 27, 2019
Example 1 for Medium post
View example1.js
Zousan.evaluate(
{ name: "username", value: "glenn" },
{ name: "score", value: 45 }
).then(function(ob) {
console.log("Hello " + ob.username + ". Your score is " + ob.score)
})
@bluejava
bluejava / Promise.eval
Created Nov 2, 2016
Adds the "eval" function to Promise (see http://www.bluejava.com/4PQ for details)
View Promise.eval
Promise.eval = function(ar)
{
// We accept either an array or items specified as individual arguments...
// ...but we convert the series into an array either way
if(!Array.isArray(ar))
ar = Array.prototype.slice.call(arguments)
var items = { } // map names to items
// This forEach is where it all happens - we evaluate each item within the eval array.
@bluejava
bluejava / PromiseTest.js
Created Apr 7, 2016
Runs some simple performance tests on Node for Native Promises, Zousan and Bluebird. (See Issue 5 : https://github.com/bluejava/zousan/issues/5)
View PromiseTest.js
var batchSize = 1000,
doBluebirdAll = true,
doZousanAll = true,
doNativeAll = true,
doBluebirdSeries = true,
doZousanSeries = true,
doNativeSeries = true
console.log(" - Batch Size: " + batchSize)
@bluejava
bluejava / Markov Text Generator
Created Feb 21, 2016
Demonstration of a Markov Text Generator to create a Sarah Palin endorsement for Donald Trump.
View Markov Text Generator
// Demonstration of a Markov Text Generator to create a Sarah Palin endorsement for Donald Trump.
// See blog post at http://www.bluejava.com/4P9/Sarah-Palin-vs-12-lines-of-JavaScript
var text = "“Thank you so much. It’s so great to be here in Iowa. We’re here just thawing out. Todd and I and a couple of our friends here from Alaska, lending our support for the next president of our great United States of America, Donald J. Trump. “Mr. Trump, you’re right, look back there in the press box. Heads are spinning, media heads are spinning. This is going to be so much fun. “Are you ready to make America great again? We all have a part in this. We all have a responsibility. Looking around at all of you, you hardworking Iowa families. You farm families, and teachers, and teamsters, and cops, and cooks. You rockin’ rollers. And holy rollers! All of you who work so hard. You full-time moms. You with the hands that rock the cradle. You all make the world go round, and now our cause is one. “When asked why I would jump
You can’t perform that action at this time.