This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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));} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // 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, {}) | |
| ); |