Skip to content

Instantly share code, notes, and snippets.

@Siedrix
Siedrix / Gruntfile.js
Created November 21, 2013 01:20
Grunt configuration for automated testing.
module.exports = function(grunt) {
grunt.initConfig({
watch: {
scripts: {
files: ['test/*.js', 'lib/*.js'],
tasks: ['mochaTest'],
options: {
spawn: true,
}
}
@Siedrix
Siedrix / 01-simple-leveldb.js
Created November 15, 2013 17:22
LevelDb examples for ChelaJs #2
var level = require('level');
var db = level('./chelajs-demo');
db.put("foo", "bar", function () {
console.log("foo has been saved");
});
@Siedrix
Siedrix / app.js
Created November 12, 2013 23:18
Basic hello world
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Express.js Hello world');
});
app.listen(8000);
var Grid = function(columns, rows) {
columns = columns || 20;
rows = rows || 20;
var self = {};
self.element = $('<table class="grid"></table>');
for(var r = 0; r < rows; r++) {
var row = $('<tr></tr>');
for(var c = 0; c < columns; c++) {
@Siedrix
Siedrix / gist:6903346
Created October 9, 2013 15:45
Simple web server
var express = require('express.io');
var server = express();
var mensajes = [];
var respuestas = []; // <---------
server.get('/', function (req, res) {
res.send('Hello World');
});
{
"name": "curso",
"version": "0.0.1",
"dependencies": {
"express.io": "~1.1.13"
}
}
this.httpServer.get('/files/download/:organization/course/:course/class/:class', function(req, res){
var zip = zipstream.createZip({ level: 1 });
res.setHeader('Content-disposition', 'attachment; filename=' + req.params.course);
zip.on('data', function(data){
res.write(data);
});
Files.find({
@Siedrix
Siedrix / log
Created May 21, 2013 20:35
Jitsu deploy log
siedrixs-MacBook-Pro:bdpn-node siedrix$ jitsu deploy --debug
info: Welcome to Nodejitsu siedrix6
info: jitsu v0.11.4, node v0.8.14
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in app.js
debug: { method: 'GET',
debug: uri: 'https://api.nodejitsu.com/apps/siedrix6/bdpn',
debug: headers:
debug: { Authorization: '*********************************',
var socket = io.connect('http://192.168.1.118:3500');
console.log('jump', io, socket);
socket.on('jump', function(data){
window.location = 'http://192.168.1.118:3500/?page=' + data.url;
});
//dentro del folder de public
@Siedrix
Siedrix / server.js
Created March 1, 2013 15:13
Socket io stress test. Needs more work.
npm install
node server.js
node swarm [usersSpawnPerSecond] [MessagesSendPerUserPerSecond]