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
@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() {
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
#get root access
$su -
$ cd /tmp
#Remove old Ruby
$ yum remove ruby
# Install dependencies
$ yum groupinstall "Development Tools"
$ yum install zlib zlib-devel
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
module.exports = function(r, logger) {
return function * create_database(next) {
yield r.dbDrop("aidax");
yield r.dbCreate("aidax");
yield[
r.tableCreate("clients"),
r.tableCreate("errors"),
r.tableCreate("forms"),
r.tableCreate("hits"),
r.tableCreate("interactions"),
@thelinuxlich
thelinuxlich / query.js
Created July 31, 2014 18:41
query hell
// Getting all sessions by secondary index on client_id field, but excluding one client_id, so I return every client id from the clients table but the one not desired
r.db("aidax").table("sessions").getAll(
r.args(
r.db("aidax").table("clients")
.filter(
function(client) {
return client("id").ne("0f338aa9-0d16-4e00-8301-f5ddabf313de")
}
).map(function(client) {
@thelinuxlich
thelinuxlich / query.js
Created August 27, 2014 19:45
query with between
r.table("errors").between(
["Uncaught Error: Error calling method on NPObject.", "1", r.now().sub(24 * 60 * 60)], ["Uncaught Error: Error calling method on NPObject.", "1", r.now()], {
index: "message_id_created_at"
}
)