###Pros:
- npm as CDN; no more GitHub API and rate limiting
- npm provides search & indexing
- package.json provides metadata
- handles multiple version numbers
- npm is download client; simpler tsd CLI
###Cons:
| var oboe = require('oboe'); | |
| var stream = require('stream'); | |
| var Readable = stream.Readable; | |
| var Writable = stream.Writable; | |
| var readable = new Readable(); | |
| readable._read = function() {}; | |
| readable.push('{"some": "json"}{"more": [1, 2, 3], "json": true}{"final json object": 12345}{"stream continues...'); | |
| readable.push(null); |
| module.exports = function(grunt) { | |
| // Store a reference to the template function constructor | |
| var tmpl = grunt.template.fn; | |
| grunt.initConfig({ | |
| // support running "copy:dev:blog", "copy:dev:homepage" or "copy:dev:contactForm" | |
| copy: { | |
| dev: { | |
| files: [tmpl(=> { // look ma, all Javascript! No code hiding in strings. |
###Pros:
###Cons:
| // Build configuration for libfoo | |
| { | |
| // ...... | |
| wrap: { | |
| start: | |
| ` | |
| ;(function(global, outerDefine) { | |
| var require, define; | |
| `, | |
| end: |
| // Initialize URL parameters | |
| var params = { | |
| type: 'date', | |
| levels: 3, // 2 == yes-no poll, 3 = yes-no-ifneedbe poll | |
| locale: 'en', | |
| title: 'Ultimate Pickup @ The Bubble', | |
| location: 'Harvard Bubble', | |
| description: '', | |
| name: 'Magazine Beach Pickup', | |
| eMailAddress: 'me@nosuchsite.com' // Poll admin link is emailed to this address |
Cool beans! I'm coming at this from a Windows perspective, but this should work well in Linux or Mac as well.
Install NodeJS. On Windows, you go to the website, run the installer, and click "Next" a few times. http://nodejs.org/
Install stylus using NodeJS's package manager, npm, which has been automatically installed for you. Open a terminal and run:
npm install -g stylus
Create your Stylus code and save it as something like my-styles.styl. You can probably rename your existing .css file to .styl without changing anything else.
| // Given an array of numbers, returns either the index containing that number | |
| // or `undefined` if the array doesn't contain that number. | |
| // Assumes that `list` is a non-sparse JavaScript array, that all items in the list are integers, | |
| // and that the list is sorted in ascending order (obviously) | |
| // Assumes that `value` is an integer. | |
| function binarySearch(list, value) { | |
| // Lower bound = minimum possible index | |
| var lowerBound = 0; |
| // event handlers as methods | |
| object object0 { | |
| create() { | |
| event_bind(ev_step, _ev_step); | |
| } | |
| script _ev_step() { | |
| // do stuff |
| // all-sprites.js | |
| define([ | |
| require('text!sprite1.json'), | |
| require('text!sprite2.json'), | |
| require('text!sprite3.json'), | |
| require('text!sprite4.json') | |
| ]); |
| SuperClass = function() {} | |
| SubClass = function() {} | |
| SubClass.prototype = Object.create(SuperClass.prototype); | |
| // Or, if the JS engine doesn't have Object.create... | |
| var ctor = function() {} | |
| ctor.prototype = SuperClass.prototype; |