Skip to content

Instantly share code, notes, and snippets.

View DTrejo's full-sized avatar

David Trejo DTrejo

View GitHub Profile
@bfncs
bfncs / mouse.js
Created March 12, 2012 09:41
Read Linux mouse(s) in node.js
/**
* Read Linux mouse(s) in node.js
* Author: Marc Loehe ([email protected])
*
* Adapted from Tim Caswell's nice solution to read a linux joystick
* http://nodebits.org/linux-joystick
* https://github.com/nodebits/linux-joystick
*/
var fs = require('fs'),
@mikeal
mikeal / gist:1840641
Created February 16, 2012 01:33
get a new/clean port with node.js
var portrange = 45032
function getPort (cb) {
var port = portrange
portrange += 1
var server = net.createServer()
server.listen(port, function (err) {
server.once('close', function () {
cb(port)
@mmalecki
mmalecki / analyze.js
Created January 7, 2012 23:57
A little script to analyze how many packages in `npm` have GitHub repositories
var registry = require('./registry');
console.log('Analyzing ' + registry.total_rows + ' rows');
var haveGithub = 0;
registry.rows.forEach(function (row) {
var doc = row.doc;
if (!doc['dist-tags'] || !doc['dist-tags'].latest) {
return console.error(doc.name + ' has no dist-tags');
anonymous
anonymous / server.js
Created January 5, 2012 08:34
var http = require('http');
var fs = require('fs');
var ip = '127.0.0.1';
var port = 2000;
var www = process.cwd();
var mimetypes = {'html': 'text/html', 'js': 'text/javascript', 'css': 'text/css', 'png': 'image/png', 'svg': 'image/svg'};
http.createServer(function (req, res) {
fs.realpath(www+req.url, function(err, realpath){
if (err || realpath.substr(0, www.length+1) != www+'/')
@rauchg
rauchg / ms.md
Created December 21, 2011 00:25
Milliseconds conversion utility.
@max-mapper
max-mapper / server.js
Created December 10, 2011 03:52
foursquare irc bridge thingy
var crypto = require('crypto'),
fs = require("fs"),
https = require('https'),
http = require("http"),
sys = require('sys'),
request = require('request'),
url = require('url'),
querystring = require('querystring'),
tako = require('./tako'),
qs = require('querystring'),
#!/bin/sh
# Figure out what we are comparing to.
if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=2ca2a592640b979a4092c19daa1938f9dd1baa46
fi
@tj
tj / routes.js
Created October 15, 2011 00:23
Express routes
var app = require('../app');
console.log();
app.routes.all().forEach(function(route){
console.log(' \033[90m%s \033[36m%s\033[0m', route.method.toUpperCase(), route.path);
});
console.log();
process.exit();
@aemkei
aemkei / LICENSE.txt
Created October 5, 2011 17:06 — forked from 140bytes/LICENSE.txt
JS ASCII Logo - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@dscape
dscape / nodemailer-to-postmark.js
Created August 3, 2011 16:16
Make the postmark api look like node_mailer
var request = require('request')
, _ = require('underscore');
function send_mail(message, callback) {
if(typeof exports.SMTP.api_key !== "string") {
console.log(exports.SMTP)
callback(new Error("No API Key was given"));
return;
}
if(typeof exports.SMTP !== "object") {