Skip to content

Instantly share code, notes, and snippets.

View emerleite's full-sized avatar

Emerson Macedo emerleite

View GitHub Profile
require.paths.unshift 'express/lib'
require 'express'
http: require 'express/http'
get '/', ->
this.contentType 'html'
this.respond 200, '''
<html>
<head><title>NodeJs Example</title></head>
<body>
By Klaus Wuestefeld
1) Torne-se excelente.
Seja realmente bom em alguma coisa. Não fique só choramingando ou
querendo progredir às custas dos outros. Não pense q pq vc sentou 4
anos numa faculdade ouvindo um professor falar sobre software q vc
sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo
aula. Ele pratica. Instrumentistas geniais nao aprendem a tocar tendo
aula. Eles praticam. Pratique. Chegue em casa depois do trabalho e da
#!/bin/bash
### BEGIN INFO
# Provides: OSX BandWidth Limitator
# Author: Emerson Macedo - http://github.com/emerleite - http://codificando.com
# Description: Limit bandwidth to test player in slow situations. Tested on OSX
### END INFO
usuage() {
echo "Usuage: sudo ./limit-bandwidth.sh <action> [width]
action {add|remove}
//Parser string differences: http://stackoverflow.com/questions/3085937/safari-js-cannot-parse-yyyy-mm-dd-date-format
var EODateParser = (function(Date,undefined) {
var pad = function(s) {
return (s.toString().length === 1) ? "0" + s: s;
};
var checkerValue = function(target, func, value) {
if (typeof value !== "undefined") {
target[func](value);
if did_filetype() " filetype already set..
finish " ..don't do these checks
endif
if getline(1) =~ '^#!.*node'
setfiletype javascript
endif
@emerleite
emerleite / example.js
Created November 19, 2010 00:39 — forked from tj/example.js
app.route('/forums', function(){
app.get('/', function(){
});
app.route('/:id', function(){
app.get('/', function(){
});
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
var http = require("http")
, util = require("sys") // 0.3.x: require("util")
, fs = require("fs")
, client = http.createClient(80, "example.com")
, request = client.request("POST", "/", {"host":"example.com"})
// send body chunks
request.write("hello, world")
// pump a file through
// database.js
sys = require('sys');
var mongo = require('./lib/node-mongodb-native/lib/mongodb'),
Connection = mongo.Connection,
Server = mongo.Server,
BSON = mongo.BSONNative;
var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';
var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT'] : Connection.DEFAULT_PORT;
require 'benchmark'
n = 1_000_000
Benchmark.bmbm do |x|
x.report("Double quotes") do
n.times do
str = "A simple string"
end
end
x.report("Single quotes") do