Skip to content

Instantly share code, notes, and snippets.

View coreh's full-sized avatar

Marco Buono coreh

View GitHub Profile
var sys = require('sys');
var path = require('path');
var http = require('http');
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!\n');
console.log('servi');
}).listen(1337, "localhost");
@coreh
coreh / wtf.js
Created November 2, 2010 00:18
It should "loop" but it only runs twice.
var sys = require('sys');
this.hey = function() {
sys.puts('hey');
setTimeout(this.hey, 2000);
};
this.hey();
@coreh
coreh / gist:810637
Created February 4, 2011 02:15
foda-se deliciosamente
|
|
_______|_______
verbo / / \
/ objeto \
/ / \ modo
/ / \
V V V
apertar o botão do foda-se deliciosamente
\_________^
// Ele tirava todos os caracteres que não fossem alfa e aspas
$_q = preg_replace('/[^A-Za-z\']/i', '', $_REQUEST['query']);
// Agora ele tira todos que não forem alfa ou espaços, e corta os espaços do começo e do final.
// Preciso lidar com os acentos e tals ainda
$_q = preg_replace('/[^A-Za-z\'\s]/i', '', trim($_REQUEST['query']));
@coreh
coreh / person.json
Created February 6, 2012 02:43
OpenAnything person example
{ "_": "oa:person",
, "first": "John"
, "last": "Appleseed"
, "birthday": { "$": "oa:date"
, "value": '2012-02-06T00:00:00.000Z'
}
, "gender": "male"
, "address": { "_": "oa:location"
, "street": "Ariel Apletiroa"
, "city": "Belo Horizonte"
@coreh
coreh / gist:1873125
Created February 21, 2012 02:32
what
if ((!$.browser.msie) && (!($.browser.mozilla && $.browser.version.indexOf("1.8.") == 0)))
{
document.domain = document.domain; // for comet
}
@coreh
coreh / query.sql
Created May 3, 2012 20:56
Top 1000 github users
SELECT count(*) as activity, actor_attributes_login FROM publicdata:samples.github_timeline WHERE actor_attributes_login != '' GROUP BY actor_attributes_login ORDER BY activity DESC LIMIT 1000;
@coreh
coreh / bind2.js
Created August 2, 2012 01:31
bind2
/**
* This function is similar to bind, but the received value of "this"
* gets passed as the first function argument.
*/
function bind2 (fn, _this) {
return function() {
var args = [].slice.call(arguments);
args.unshift(this);
fn.apply(_this, args);
}

Arquivo em branco

Código Fonte

(arquivo em branco)

Saída

statement list

@coreh
coreh / gist:4980837
Created February 18, 2013 21:18
How to calculate sprite coordinates by index in a sprite-sheet with fixed-sized sprites.
// These are known beforehand
int imageWidth = 640;
int imageHeight = 480;
int tileWidth = 32;
int tileHeight = 32;
int tilesPerRow = imageWidth / tileWidth;
int index = 5;