Skip to content

Instantly share code, notes, and snippets.

View matthewhudson's full-sized avatar

Matthew Hudson matthewhudson

View GitHub Profile
@tobitailor
tobitailor / get_barcode_from_image.js
Created June 1, 2010 19:33
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
##################################
# Edit these
set :application, "example_node_app"
set :node_file, "hello_world.js"
set :host, "ec2-174-129-114-66.compute-1.amazonaws.com"
ssh_options[:keys] = [File.join(ENV["HOME"], ".ec2", "default.pem")]
set :repository, "git://gist.github.com/479007.git"
set :branch, "master"
@mumrah
mumrah / websocketserver.py
Created August 7, 2010 17:01
Simple WebSockets in Python
import time
import struct
import socket
import hashlib
import sys
from select import select
import re
import logging
from threading import Thread
import signal
var fromBase64 = function(str) {
return (new Buffer(str || "", "base64")).toString("ascii");
};
We couldn’t find that file to show.
// helper function that goes inside your socket connection
client.connectSession = function(fn) {
var cookie = client.request.headers.cookie;
var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]);
redis.get(sid, function(err, data) {
fn(err, JSON.parse(data));
});
};
// usage
@wrboyce
wrboyce / gist:786460
Created January 19, 2011 17:12
pre-commit hook to automatically minify javascript/css
#!/usr/bin/zsh
COMPRESSOR=$(whence -p yui-compressor)
[ -z $COMPRESSOR ] && exit 0;
function _compress {
local fname=$1:t
local dest_path=$1:h
local min_fname="$dest_path/${fname:r}.min.${fname:e}"
$COMPRESSOR $1 > $min_fname
@dustin
dustin / noderunner.js
Created September 8, 2011 23:58
A web pipe server.
// Run this somewhere with a command you want to pipe stuff through.
//
// On a machine that needs data processed, run this:
// curl --data-binary @/some/file http://server:port/ > output
var http = require('http');
var spawn = require('child_process').spawn;
// 0 == node, 1 == [this script]
var PORT = parseInt(process.argv[2]);
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active June 9, 2024 23:19
How to publish packages to NPM

Getting Started with NPM (as a developer)

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
@tcr
tcr / code.js
Created October 28, 2011 02:18
How do you use Twilio with Node.js on Heroku?
var TwilioClient, Twiml, app, config, express, phone, port, twilio;
express = require('express');
TwilioClient = require('./twilio').Client;
Twiml = require('./twilio').Twiml;
app = express.createServer(express.logger());
app.use(express.bodyParser());
config = {};