Skip to content

Instantly share code, notes, and snippets.

View tiagoa's full-sized avatar
🌎
Working from LATAM

Tiago A. tiagoa

🌎
Working from LATAM
  • Mercatus
  • Maringá
  • 07:32 (UTC -03:00)
  • X @otiagoa
View GitHub Profile
var http = require('http');
var qtd = process.argv[2] || 1;
for (var i = 0; i < qtd; i++) {
http.get({host:'zonetti.jit.su', port:80, path:'/', agent:false}, function(res){
res.on('data', function(d){
}).on('end', function(){
console.log('respondeu ao cliente #'+i);
});
});
}
@tiagoa
tiagoa / CakePHP access control
Created October 20, 2012 20:13
A CakePHP access control implementation with a User hasMany Role schema
<?php
class AppController extends Controller {
public $permissions = array(
'Admin' => '*',
'Student'=>array(
array('controller'=>'pages', 'action'=>'display'),
array('controller'=>'books', 'action'=>'*')
)
);
@tiagoa
tiagoa / Backbone.websocket.js
Created October 13, 2012 23:34
Overwrite Backbone.sync method to persist model via WebSocket
// Inspired by https://github.com/logicalparadox/backbone.iobind/blob/master/lib/sync.js
// Overwrite Backbone.sync method
Backbone.sync = function(method, model, options){
// create a connection to the server
var ws = new WebSocket('ws://127.0.0.1:1234');
// send the command in url only if the connection is opened
// command attribute is used in server-side.
ws.onopen = function(){