Setting NODE_ENV=production
causes these libraries and tools to behave as follows:
npm:
install
will not install devDependenciesshrinkwrap
will not install devDependenciesprune
will remove devDependencies
yarn:
# RVM support in Rails 3 app for multiple gemsets with Passenger | |
# config/setup_load_paths.rb | |
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm') | |
begin | |
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME'])) | |
rvm_lib_path = File.join(rvm_path, 'lib') | |
$LOAD_PATH.unshift rvm_lib_path | |
require 'rvm' | |
RVM.use_from_path! File.dirname(File.dirname(__FILE__)) |
{ | |
"cmd": ["killall node >> /dev/null; node ${file}"], | |
"selector": "source.javascript", | |
"path": "/usr/bin", | |
"shell": true | |
} |
getImageSize = (image, cb) -> | |
fromHex = (hex) -> parseInt "0x#{hex}", 16 | |
req = http.request image, (res) -> | |
res.setEncoding 'hex' | |
res.on 'error', (e) -> cb "getImageSize error (#{image}): " + e, null, image | |
res.on 'data', (chunk) -> | |
m = switch res.headers['content-type'] | |
when 'image/jpeg' | |
chunk.match 'ffc0001108(....)(....)' | |
when 'image/png' |
{- | |
The comparison operators are non-associative and not composable. | |
Thus it is illegal to write: 1 < 2 < 3 | |
The input types of < (Int) does not match the output type (Bool). | |
1 < 2 < 3 can however be written in math notation, because it denotes: | |
(1 < 2) && (2 < 3) or (1 < 2) ^ (2 < 3) | |
It is however possible to create a new ternary operator that supports such a | |
notation! | |
-} |
function hangups (req, res, next){ | |
var reqd = domain.create() | |
reqd.add(req) | |
reqd.add(res) | |
reqd.on('error', function (error) { | |
if (error.code !== 'ECONNRESET') console.error(error, req.url) | |
reqd.dispose() | |
}) | |
next() | |
} |
var bases = require('bases'); | |
var crypto = require('crypto'); | |
// Returns a base-62 (alphanumeric only) string of the given length: | |
function randomStr(length) { | |
// We generate a random number in a space at least as big as 62^length, | |
// and if it's too big, we just retry. This is still statistically O(1) | |
// since repeated probabilities less than one converge to zero. Hat-tip to | |
// a Google interview for teaching me this technique! ;) |
### define function variable before block to avoid code being appended to closing part of JSDoc comment ### | |
cube = '' | |
###* | |
* Funtion to calculate cube of input | |
* @param {number} Number to operate on | |
* @return {number} Cube of input | |
### | |
cube = (x) -> x*x*x |
var bases = require('bases'); | |
var crypto = require('crypto'); | |
// Returns a base-62 (alphanumeric only) string of the given length: | |
function randomStr(length) { | |
// We generate a random number in a space at least as big as 62^length, | |
// and if it's too big, we just retry. This is still statistically O(1) | |
// since repeated probabilities less than one converge to zero. Hat-tip to | |
// a Google interview for teaching me this technique! ;) |
Setting NODE_ENV=production
causes these libraries and tools to behave as follows:
npm:
install
will not install devDependenciesshrinkwrap
will not install devDependenciesprune
will remove devDependenciesyarn:
From Meteor's documentation:
In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.
This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.
Sometimes we need to run async code in Meteor.methods
. For this we create a Future
to block until the async code has finished. This pattern can be seen all over Meteor's own codebase: