Skip to content

Instantly share code, notes, and snippets.

View thelinuxlich's full-sized avatar
🐉
Here be dragons

Alisson Cavalcante Agiani thelinuxlich

🐉
Here be dragons
View GitHub Profile
<?php
class RoleController extends BaseController {
public function getIndex()
{
return Response::json(Role::all());
}
public function postCreate()
{
// knockout 2.2.1
ko.utils.arrayFilter = function (array, predicate) { /* .. */ }
ko.utils.arrayFirst = function (array, predicate, predicateOwner) { /* .. */ }
ko.utils.arrayForEach = function (array, action) { /* .. */ }
ko.utils.arrayGetDistinctValues = function (array) { /* .. */ }
var rabbitConnection = amqp.createConnection(config.amqp,{reconnect: false}),rabbitExchange,rabbitActiveHost = config.amqp.host,rabbit_config = JSON.parse(JSON.stringify(config.amqp));
rabbitConnection.on('error', function (err) {
winston.error('Connection to rabbit failed:' + config.amqp.host);
if(!!config.secondary_amqp_host) {
rabbitActiveHost = (rabbitActiveHost == config.amqp.host ? config.secondary_amqp_host : config.amqp.host);
rabbit_config.host = rabbitActiveHost;
winston.log("info","Closing actual connection");
rabbitConnection.end();
}
@thelinuxlich
thelinuxlich / heranca.js
Created November 11, 2013 19:17
Herança em JS do jeito certo
function Animal(name) {
this.name = name;
};
Animal.prototype.move = function(meters) {
console.log(this.name+" moved "+meters+"m.");
};
function Snake() {
Animal.apply(this, Array.prototype.slice.call(arguments));
dynamo.batchRead({
'interaction_links': [['internal_tests','146a0297335486e05ac53e8532c18dde3ac375e5']],
'action_history': [['myerp:jonathan.huesca@biodiagnosticos.com','1383088503200']]
},function(err,data){
if(!!err) {
self.log("ERROR on batch reading: "+err);
} else {
self.log(JSON.stringify(data));
}
});
@thelinuxlich
thelinuxlich / naive_benchmark
Created December 18, 2013 20:56
Result of a simple benchmark using Express.js and Partial.js(latest versions of both)
Express.js:
Transactions: 1500 hits
Availability: 100.00 %
Elapsed time: 6.10 secs
Data transferred: 0.24 MB
Response time: 0.06 secs
Transaction rate: 245.90 trans/sec
Throughput: 0.04 MB/sec
Concurrency: 14.90
@thelinuxlich
thelinuxlich / jshint_flags.md
Last active August 29, 2015 13:56
JSHint possible flags for Nextuser Code Style

##bitwise This option prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others. Bitwise operators are very rare in JavaScript programs and quite often & is simply a mistyped &&.

##camelcase This option allows you to force all variable names to use either camelCase style or UPPER_CASE with underscores.

##curly This option requires you to always put curly braces around blocks in loops and conditionals. JavaScript allows you to omit curly braces when the block consists of only one statement, for example:

@thelinuxlich
thelinuxlich / jscs_flags.md
Last active August 29, 2015 13:56
JSCS flags

####requireSpaceAfterKeywords

Requires space after keyword.

####requireSpacesInFunctionExpression

Requires space before () or {} in function declarations.

####requireSpacesInAnonymousFunctionExpression

var throttler = function(fn, maxExecutions) {
var counter = 0,
queue = [];
return function() {
var self = this,
args = arguments,
old_callback = args[args.length - 1];
args[args.length - 1] = function() {