Open ~/.bash_profile in your favorite editor and add the following content to the bottom.
# Git branch in prompt.
parse_git_branch() {| //old: productReviews.js - lines 121 - 125 | |
| async function productReviewsByProductAllGet(request, response) { | |
| try { | |
| const { productId } = request.params; | |
| // get all reviews for a product id | |
| const reviews = await productReviewsQuery.selectAllByProductId(productId); | |
| const result = []; | |
| // Loop from beginning of reviews array to reviews | |
| for(let i = 0; i < reviews.length; i++) { |
| const waitFor = (ms) => new Promise(r => setTimeout(r, ms)) | |
| const asyncForEach = async (array, callback) => { | |
| for (let index = 0; index < array.length; index++) { | |
| await callback(array[index], index, array) | |
| } | |
| } | |
| const start = async () => { | |
| await asyncForEach([1, 2, 3], async (num) => { | |
| await waitFor(50) |
| var colorArray = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99', '#00B3E6', | |
| '#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D', | |
| '#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A', | |
| '#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC', | |
| '#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC', | |
| '#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399', | |
| '#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680', | |
| '#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933', | |
| '#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3', | |
| '#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF']; |
| var mongoose = require('mongoose'); | |
| var Schema = mongoose.Schema; | |
| //Database connection | |
| var uristring = 'mongodb://localhost/test'; | |
| var mongoOptions = { }; | |
| mongoose.connect(uristring, mongoOptions, function (err, res) { | |
| if (err) { | |
| console.log('Error when connecting to: ' + uristring + '. ' + err); |
| export class EnumSymbol { | |
| sym = Symbol.for(name); | |
| value: number; | |
| description: string; | |
| constructor(name: string, {value, description}) { | |
| if(!Object.is(value, undefined)) this.value = value; | |
| if(description) this.description = description; |
Fast prototyping of apps using Sketch and d3.js, please refer to the the explanatory post.
| // Change font (ctrl a) | |
| var doc = context.document, | |
| selection = context.selection, | |
| font_name = [doc askForUserInput:"Font name:" initialValue:"Arial"]; | |
| function check_layer(layer){ | |
| log(layer) | |
| var className = layer.className() | |
| log("Checking layer " + layer + " of klass: " + className) | |
| if (className == "MSTextLayer") { |
I've been hacking away recently at a JVM framework for doing asynchronous, non-blocking applications using a variation of the venerable Reactor pattern. The core of the framework is currently in Java. I started with Scala then went with Java and am now considering Scala again for the core. What can I say: I'm a grass-is-greener waffler! :) But it understands how to invoke Groovy Closures, Scala anonymous functions, and Clojure functions, so you can use the framework directly without needing wrappers.
I've been continually micro-benchmarking this framework because I feel that the JVM is a better foundation on which to build highly-concurrent, highly-scalable, C100K applications than V8 or Ruby. The problem has been, so far, no good tools exist for JVM developers to leverage the excellent performance and manageability of the JVM. This yet-to-be-publicly-released framework is an effort to give Java, Groovy, Scala, [X JVM language] developers access to an easy-to-use programming model that removes the necessity