Skip to content

Instantly share code, notes, and snippets.

View cronopio's full-sized avatar

Daniel Aristizabal cronopio

  • Pereira
View GitHub Profile
@cronopio
cronopio / jslon.js
Created September 20, 2011 03:52
Testing google
/* Extremely loose JSON interpreter.
* Copyright 2011 Wa (logicplace.com)
* MIT Licensed
*/
JSLON = (function(){
var tokenize = /[\[{\]},:]|\s+|\/\*[\s\S]*\*\/|\/\/.*|"(\\.|\\(\r?\n|\n?\r)|[^"])*"|'(\\.|\\(\r?\n|\n?\r)|[^'])*'|\/(\\.|[^\/])+\/[igm]*|[$_a-zA-Z][$_a-zA-Z0-9]*|[+\-]?0x[0-9a-fA-F]+|[+\-]?[0-9]+e[+\-]?[0-9]*|[+\-]?[0-9]*\.[0-9]*|[+\-]?[0-9]+|Infinity|NaN|true|false|null|undefined/g
function usO(a,v){return String.fromCharCode(parseInt(v,8));}
function usX(a,v){return String.fromCharCode(parseInt(v,16));}
@cronopio
cronopio / test.js
Created September 20, 2011 18:19
Playing with currency converter
var request = require('request');
var csv = require('ya-csv');
var qs = require('querystring');
request('http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=USDCOP=X', function(err, res, body){
if (err) throw new Error(err);
if (!err && res.statusCode == 200){
console.log('Respuesta correcta');
var usd = body.split(',');
console.log('Un dolar vale %d pesos colombianos', usd[1]);
@cronopio
cronopio / gist:1307973
Created October 23, 2011 22:27
Testing vows-bdd
/**
* Pruebas para la creacion de un usuario en el sitio
*/
var Feature = require('vows-bdd').Feature,
http = require('http'),
assert = require('assert');
Feature('Creando un usuario', module)
@cronopio
cronopio / client.js
Created October 28, 2011 16:51 — forked from tbranyen/client.js
Synchronize yo HTML5 slides
(function(window, document) {
// The end user should be allowed to disable synchronization. This button
// is optional on the page
var syncAllow = true;
var syncButton = document.querySelector('.sync-button');
// If the sync button exists bind a click event and toggle the syncAllow
// boolean. Set the value of the button.
if(syncButton) {
@cronopio
cronopio / dns.js
Created October 30, 2011 01:41
nodejs-demos
var net = require('net'),
dns = require('dns');
function checkComando (data, socket) {
var c_raw = data.toString();
comando = c_raw.slice(0, -2).split(' ');
if (comando[0] === 'ip') {
console.log('Solicitando: ', comando[1]);
dns.resolve(comando[1], 'A', function(err, info) {
@cronopio
cronopio / index.html
Created November 25, 2011 21:16
Prueba de paso de mensajes con Socket.io
<html>
<head>
<title>Probando Socket.io</title>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io.connect();
socket.on('saludo', function(d) {
var text = prompt(d.info);
socket.emit('mensaje', text);
});
@cronopio
cronopio / .gitignore
Created December 10, 2011 02:31
My Twitter client for shell using nodejs and ntwitter
node_modules/
@cronopio
cronopio / client.js
Created June 1, 2012 04:48 — forked from dominictarr/client.js
node-http-proxy bug #70
var http = require('http')
function log (str) {
console.log('' + str)
}
http.get({host: 'localhost', port:6666, path: '/xhr'}, function (res) {
res.on('data', log)
res.on('end', log)
@cronopio
cronopio / .gitignore
Created September 26, 2012 19:13
BogotaConf.co
node_modules/
//
// Lets take as example the next Mongodb URI
// mongodb://nodejitsu:684e3def50116af8c8ab032f65230fac@alex.mongohq.com:10047/nodejitsudb54463349176
// mongodb://username:passwd@hostname:port/datababaseName
//
// So the code should looks like
var mongodb = require('mongodb');
var db = new mongodb.Db('nodejitsudb544633491762',
new mongodb.Server('alex.mongohq.com', 10047, {})
);