Skip to content

Instantly share code, notes, and snippets.

@wxactly
wxactly / stubQueryMethod.js
Last active August 29, 2015 14:06
Sails.js: Stub Waterline query method with Sinon.js
var util = require('util');
var _ = require('lodash');
var sinon = require('sinon');
/**
* Replaces a query method on the given model object with a stub. The query
* will still operate on a callback, and allow full access to waterline's
* deferred object. However, the query will not cause any I/O and instead
* will immediately resolve to the given result.
*

Anivia

Anivia is Walmart's mobile analytics platform. It collects user-interaction metrics from mobile devices -- iPhone, iPad, Android, and mWeb. It also processes logging and other metrics from a bunch of mobile services. Anivia allows the business to have real-time insight and reporting into what is going on in the mobile business and provides vital capabilities for developers and ops folks to monitor the health of their services.

Anivia is built on Node.js, Hapi, RabbitMQ, and a multitude of downstream systems including Splunk and Omniture. Anivia is taking in 7,000 events per second on average (as of this writing), which after some fan-out and demuxing comes out to around 20,000 messages per second in flight. These rates are expected to soar leading up to and including Black Friday. The platform has grown in recent months to over 1,000 node processes spanning multiple data centers, gaining features such as link resiliency in the process.

A few of Anivia's functionalities

  • __Timestamp Correc
@rbsgn
rbsgn / blame.rb
Created May 13, 2011 14:18 — forked from soffes/blame.rb
Find the number of lines of code per person in a repository
# Put this file in the root of your git repository then run `ruby blame.rb`.
# You will need gsed. You can install gsed with `brew install gsed`.
# Crazy shell script taken from http://stackoverflow.com/questions/4589731/git-blame-statistics
input = `git ls-tree -r HEAD|gsed -re 's/^.{53}//'|while read filename; do file "$filename"; done|grep -E ': .*text'|gsed -r -e 's/: .*//'|while read filename; do git blame "$filename"; done|gsed -r -e 's/.*\\((.*)[0-9]{4}-[0-9]{2}-[0-9]{2} .*/\\1/' -e 's/ +$//'|sort|uniq -c`
aggregated = {}
input.lines.each do |line|
line.strip!
@mikermcneil
mikermcneil / bootstrap-sails-in-memory.js
Last active December 25, 2015 20:38
Programmatic usage of sails (for testing, core testing, scheduled jobs, build scripts, etc.)
// NOTE:
// you may need to grab the latest version of Sails on the v0.10 branch for some of this to work
var sails = require('sails');
// You can do a lot here, but I'll show a few important ones
var options = {
// Completely disable globals (sails, your models, your services, _, async)
globals: false,
@addyosmani
addyosmani / composition.md
Last active January 23, 2016 21:39
JS Musings

Composition

On an architectural level, the way we craft large-scale applications in JavaScript has changed in at least one fundamental way in the last four years. Once you remove the minutia of machinery bringing forth data-binding, immutable data-structures and virtual-DOM (all of which are interesting problem spaces) the one key concept that many devs seem to have organically converged on is composition. Composition is incredibly powerful, allowing us to stitch together reusable pieces of functionality to "compose" a larger application. Composition eschews in a mindset of things being good when they're modular, smaller and easier to test. Easier to reason with. Easier to distribute. Heck, just look at how well that works for Node.

Composition is one of the reasons we regularly talk about React "Components", "Ember.Component"s, Angular directives, Polymer elements and of course, straight-up Web Components. We may argue about the frameworks and libraries surrounding t

@balloob
balloob / nuclear-js-polymer-behavior-example.html
Last active March 1, 2016 05:30
Behavior to use Nuclear JS data in Polymer
<!--
Behavior to connect your NuclearJS app to Polymer.
Add key 'bindNuclear' to your property with as value a
valid NuclearJS getter.
Adapted from the NuclearJS ReactJS mix-in:
https://github.com/jordangarcia/nuclear-react-mixin
-->
<dom-module id='nuclear-example'>
@kpdecker
kpdecker / nodebf.md
Last active June 2, 2016 18:02
mobile.walmart.com #nodebf 2014

Mobile Server Side Rendering

This year marks the first year that we are doing full scale rendering of our SPA application on our mobile.walmart.com Node.js tier, which has provided a number of challenges that are very different from the mostly IO-bound load of our prior #nodebf.

The infrastructure outlined for last year is the same but our Home, Item and a few other pages are prerendered on the server using fruit-loops and hula-hoop to execute an optimized version of our client-side JavaScript and provide a SEO and first-load friendly version of the site.

To support the additional CPU load concerns as peak, which we hope will be unfounded or mitigated by our work, we have also taken a variety of steps to increase cache lifetimes of the pages that are being served in this manner. In order of their impact:

Event Loop Management

@3rd-Eden
3rd-Eden / monitrc
Created May 10, 2011 08:18
monit nodejs deployment
###############################################################################
## Includes
###############################################################################
##
## It is possible to include additional configuration parts from other files or
## directories.
#
# include /etc/monit.d/*
#
#
@tobiasstrebitzer
tobiasstrebitzer / bower.json
Created June 30, 2015 03:24
Polymer 1.0 Global Variables Behavior
{
"name": "polymer-globals-behavior",
"dependencies": {
"polymer": "Polymer/polymer#~1.0.5"
}
}
@divarvel
divarvel / continuation.js
Last active May 11, 2018 08:57
Continuation monad in JS. just run $ node continuation.js
console.log("\033[39mRunning tests…");
function assertEquals(actual, expected, description) {
if(typeof(actual) === "undefined") {
console.error("\033[31m" + description + " not implemented\033[39m");
} else {
if(actual !== expected) {
console.error("\033[31m" + description + " failed, expected " + expected + ", got " + actual + "\033[39m");
} else {
console.log(description + " \033[32m ok\033[39m");
}