Skip to content

Instantly share code, notes, and snippets.

Ritchie Martori ritch

  • Fremont, California
Block or report user

Report or block ritch

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
ritch / ex.js
Last active Sep 19, 2019
What is the best way to document complex / dynamic objects as arguments to a function?
View ex.js
* Below are several examples of methods that are difficult to clearly annotate with JSDoc annotations.
* @param {Object} people An index of people keyed by a person's name
* @returns {Object} map An index of zipcodes keyed by a person's name
function find(people) {
ritch / example.js
Last active Aug 29, 2015
Micro Processes
View example.js
var MicroProcess = require('../lib/micro-process');
var loopback = require('loopback');
var app = loopback();
app.use(function(req, res, next) {
var p = new MicroProcess([req.method, req.url].join(' '));;
p.on('error', function(err) {
# setup an office supply store
# deny everything by default
$ slc lb acl --deny --model product --everyone
# allow customers to browse the products
$ slc lb acl --allow --model product --everyone --read
# only allow the store owners to modify or delete them
$ slc lb acl --allow --model product --owner --all
ritch /
Last active Dec 31, 2015
LoopBack LBUser in iOS
// UserRepository and User do not exist in the sdk
UserRepository repository = adapter.createRepository(UserRepository.class);
HashMap attributes = new HashMap<String, Object>();
attributes.put("email", "");
attributes.put("password", "secret");
User me = repository.createModel(attributes); Model.Callback() {
public void onSuccess() {
ritch / co-loopback.js
Last active Jun 8, 2016
LoopBack w/ a co-routine based API
View co-loopback.js
var co = require('co');
var thunk = require('thunkify');
var loopback = require('loopback');
var memory = loopback.memory();
var product = memory.createModel('memory');
// thunkify the loopback model
// create some products in parallel
View gist:7996908
// DAO
function create(obj, callback) {
var Model = this;
var ctx = new EventEmitter(); = obj;
ctx.callback = callback;
Model.emit('create:start', ctx);
ritch / 0-view.html
Last active Dec 28, 2015
An end to end example integrating LoopBack, Angular, and MySQL. Run the full app - View the source -
View 0-view.html
An Angular View to render a list of Restaurants
<table class="table table-hover table-striped" ng-controller="RestaurantsController">
<tr ng-repeat="restaurant in restaurants">
<a href="#/menu/{{}}">
<img class="img-rounded pull-left" ng-src="img/restaurants/{{restaurant.shortName}}.jpg">
ritch / RestaurantsController.js
Created Nov 16, 2013
Connecting Angular to MySQL through LoopBack
View RestaurantsController.js
function RestaurantsController(Restaurant) {
$scope.restaurants = Restaurant.query(filterAndSortRestaurants);
ritch / bacn.js
Last active Dec 27, 2015
BACN + LoopBack Example
View bacn.js
// ... imagine backbone boilerplate here... pointing to localhost:3000
var Product = Backbone.Model.extend({
url: '/products'
/* would be nice if I could just include this here...
Product.validatesLengthOf('name', {
min: 3,
ritch / job-queue-adapters.js
Last active Dec 26, 2015
How to implement adapter pattern inside a LoopBack connector
View job-queue-adapters.js
var adapters = {
redis: RedisJobQueue,
foo: FooJobQueue,
bar: BarJobQueue
function JobQueueConnector(settings) {
this.DataAccessObject = adapters[settings.type];
You can’t perform that action at this time.