As easy as 1, 2, 3!
Updated:
- Aug, 08, 2022 update
config
docs for npm 8+ - Jul 27, 2021 add private scopes
- Jul 22, 2021 add dist tags
- Jun 20, 2021 update for
--access=public
- Sep 07, 2020 update docs for
npm version
// | |
// Super simple base64 encoding / decoding with node.js | |
// | |
var base64 = exports = { | |
encode: function (unencoded) { | |
return new Buffer(unencoded).toString('base64'); | |
}, | |
decode: function (encoded) { | |
return new Buffer(encoded, 'base64').toString('utf8'); |
/* | |
* jQuery special events for delayedEnter, delayedLeave, and delayedHover | |
* Author: Scott Jehl, [email protected] | |
* Copyright (c) 2011 Filament Group | |
* licensed under MIT | |
* note: Each event can be used with bind or live event handling as you would use mouseenter,mouseleave, and hover | |
* events fire after 200ms timeout | |
*/ | |
(function($){ | |
//delayedEnter event |
function nestCollection(model, attributeName, nestedCollection) { | |
//setup nested references | |
for (var i = 0; i < nestedCollection.length; i++) { | |
model.attributes[attributeName][i] = nestedCollection.at(i).attributes; | |
} | |
//create empty arrays if none | |
nestedCollection.bind('add', function (initiative) { | |
if (!model.get(attributeName)) { | |
model.attributes[attributeName] = []; |
Backbone.View.extend({ | |
template: 'my-view-template', | |
render: function(){ | |
var that = this; | |
$.get("/templates/" + this.template + ".html", function(template){ | |
var html = $(template).tmpl(); | |
that.$el.html(html); | |
}); | |
return this; |
// bootstrap | |
PX.app = new PX.App(); | |
Backbone.history.start(); |
Backstory: I decided to crowdsource static site generator recommendations, so the following are actual real world suggested-to-me results. I then took those and sorted them by language/server and, just for a decent relative metric, their Github Watcher count. If you want a heap of other projects (including other languages like Haskell and Python) Nanoc has the mother of all site generator lists. If you recommend another one, by all means add a comment.
var zlib = require('zlib'); | |
var compress = function(req, res, result) { | |
var acceptEncoding = req.headers['accept-encoding']; | |
if (!acceptEncoding) { acceptEncoding = ''; } | |
if (acceptEncoding.match(/\bdeflate\b/)) { | |
zlib.deflate(result, function(err, result) { | |
if (!err) { | |
res.writeHead(200, { 'content-encoding': 'deflate' }); | |
res.send(result); |
/* Cranium MVC | |
* A minimalist MVC implementation written for | |
* demonstration purposes at my workshops | |
* http://addyosmani.com | |
* Copyright (c) 2012 Addy Osmani; Licensed MIT */ | |
var Cranium = Cranium || {}; | |
// Set DOM selection utility |
Couldn't find the text of this for a while...