Skip to content

Instantly share code, notes, and snippets.

@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@natos
natos / __request
Created March 8, 2012 15:23
Multiple Requests with Request (Node.js)
var request = require('request')
/**
* Handle multiple requests at once
* @param urls [array]
* @param callback [function]
* @requires request module for node ( https://github.com/mikeal/request )
*/
var __request = function (urls, callback) {
@johntitus
johntitus / nodeWatermark.js
Created November 5, 2012 18:16
(Node.js) Watermark an image using ImageMagick from two streams.
/**
* Dependencies
*/
var fs = require('fs'),
request = require('request'),
cp = require('child_process'),
spawn = cp.spawn;
var image = request("http://medpreps.com/wp-content/uploads/2012/05/cma-practice-test.jpg");
var wm = request("https://github.com/linse/Gibberbot/diff_blob/f096f6d94b3fb745975ea5f61f5a43b47098598b/res/drawable/droid_watermark.png?raw=true");
@karthik20522
karthik20522 / img_benchmark.js
Created November 22, 2013 19:01
Image processing benchmark - NodeJS
var fs = require('fs');
var vips = require('../index');
var imagemagick = require("imagemagick");
var gm = require("gm");
var epeg = require("epeg");
var async = require("async");
var assert = require("assert");
var Benchmark = require("benchmark");
var cv = require("opencv");
@danwit
danwit / passport_node_acl_example.js
Created May 1, 2014 23:23
Authentication and authorization with passportjs + node_acl + mongo + express
/**
* Simple authentication and authorization example with passport, node_acl,
* MongoDB and expressjs
*
* The example shown here uses local userdata and sessions to remember a
* logged in user. Roles are persistent all the way and applied to user
* after logging in.
*
* Usage:
* 1. Start this as server
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@malkafly
malkafly / the80.js
Last active August 29, 2015 14:13 — forked from rodrigoalviani/the80.js
$('*').each(function () {
var colors = ['aqua', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple', 'red', 'silver', 'teal', 'yellow'];
$(this).css('background-color', colors[Math.floor(Math.random()*colors.length)]);
$(this).css('font-family', 'Comic Sans MS');
});
$('img').each(function () {
var imgs = [
'http://www.animatedgif.net/devilish/coolskul.gif',
'http://www.animatedgif.net/devilish/devildance_e0.gif',
@pedropazello
pedropazello / haskell.md
Last active July 26, 2020 00:20
Haskell: Primeiros passos e bookmarks.
@joakimbeng
joakimbeng / test_runner.js
Last active July 12, 2020 22:38
A small and simple Javascript test runner
/**
* A Javascript test runner in 20 lines of code
* From http://joakimbeng.eu01.aws.af.cm/a-javascript-test-runner-in-20-lines/
*/
(function () {
// The test queue:
var tests = [];
// Function to add tests:
this.test = function test (name, cb) {
@kolodny
kolodny / bookmarklet.js
Last active February 23, 2019 17:43
Save any form to autofill for development, supports dynamic content with {{ Math.random() }} syntax
http://kolodny.github.io/bookmarklet.html
document.body.addEventListener('click', go);
alert('click on a form element to get a bookmarklet of the saved form');
function go(event) {
var form = event.target;
while (form && form.tagName !== 'FORM') {
form = form.parentNode;
}