Skip to content

Instantly share code, notes, and snippets.

View heymichaelp's full-sized avatar

Michael Phillips heymichaelp

View GitHub Profile
Hey, team.
Since we've adopted Node.js as a part of our technology toolkit, we have had to learn very quickly some of the quirks of the ecosystem. We've done very well, but want to make sure we learn from our lessons and keep moving forward.
The biggest painpoint we've encountered along this path is with [NPM](http://npmjs.org), Node Package Manager. Here are some things to keep in mind on projects moving forward:
## Errors during `npm install`
If you're experiencing *any* issues with running `npm install`, please perform the following checks and solutions to remediate the problem.
@heymichaelp
heymichaelp / renameProp.js
Last active August 29, 2015 14:01
Underscore.js Mixin renameProp
_.mixin({
renameProp: function( obj, originalPropName, newPropName ) {
obj[ newPropName ] = obj[ originalPropName ];
delete obj[ originalPropName ];
return obj;
}
});
var bar = "bar"
INFO [7aef7826] Running /usr/bin/env npm install --silent --production on ec2-54-198-32-220.compute-1.amazonaws.com
INFO [6cf05d2a] Running /usr/bin/env npm install --silent --production on ec2-54-198-110-86.compute-1.amazonaws.com
INFO [ce76433a] Running /usr/bin/env npm install --silent --production on ec2-54-82-125-198.compute-1.amazonaws.com
cap aborted!
SSHKit::Command::Failed: npm stdout: Nothing written
npm stderr: Nothing written
/home/ubuntu/bidkind/vendor/bundle/ruby/1.9.1/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/home/ubuntu/bidkind/vendor/bundle/ruby/1.9.1/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/home/ubuntu/bidkind/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/ubuntu/bidkind/vendor/bundle/ruby/1.9.1/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `do_request'

Auction Expiration Proposal Outline

Based on the results of the first auction closing, we recommend taking the following steps to improve the functionality, speed and accuracy of the last seconds of an auction.

Client-side

Clock calculations

Currently the computation involved in counting the clock down from the current time to the expiration time has opportunities to be more efficient. Since this operation happens every second, each one counts, and this can contribute to lag.

// determine if the boot command targets development mode
function isDevelopmentMode() {
return process.argv.indexOf( '--development' ) !== -1;
}
// if development mode is targeted, load .env config variables
if ( isDevelopmentMode() ) {
var DotEnv = require('dotenv-node');
new DotEnv();
Ron,
Becuase all client browsers and computers are different, we need a way to make sure that all clients are keeping the correct time based on the server. To achieve this, we have historically been sending down a message from the server to all clients with the current time on the server.
A few problems have occurred with this approach. One is that, since we moved from our own custome web sockets implementation to Pusher, we are now being charged based on the number of messages sent to the clients. This means that our messages to each connected client will rack up our cost, which we want to avoid. The second problem is that this can be a drain on resources for the server, especially when it is unnecessary for the auction to be updating so frequently when the auction is weeks, days, even hours, away from expiring. The client clocks do not need to be so precise during these times.
To address both of these problems, we're planning on taking the following actions:
Remove the web socket approach to keeping the
machine:
environment:
CODECLIMATE_REPO_TOKEN: &CODECLIMATE_REPO_TOKEN mytoken
NODE_ENV: ci
node:
version: 0.10.26
dependencies:
pre:
- npm install -g codeclimate-test-reporter
test:
var Value = require('../lib/utensils').Value;
var _ = require('underscore');
var Grade = Value.extend({
grades: [
{ letter: 'A', min: 0.9, passing: true },
{ letter: 'B', min: 0.8, passing: true },
{ letter: 'C', min: 0.7, passing: true },
{ letter: 'D', min: 0.6, passing: true },
describe('#scopeArguments', function() {
var Person;
var person;
before( function() {
Person = function() {
utilities.scopeArguments.call( this, this.call, arguments );
return this.call();
};