Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Tiago A. tiagoa

🏠
Working from home
  • wBuy
  • Maringá
View GitHub Profile
View gist:4039763
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 Oct 20, 2012
A CakePHP access control implementation with a User hasMany Role schema
View CakePHP access control
<?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 Oct 13, 2012
Overwrite Backbone.sync method to persist model via WebSocket
View Backbone.websocket.js
// 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(){