Skip to content

Instantly share code, notes, and snippets.

View henvic's full-sized avatar

Henrique Vicente henvic

View GitHub Profile
@henvic
henvic / CancellablePromise.js
Last active August 29, 2015 14:16 — forked from eduardolundgren/CancellablePromise.js
CancellablePromise.all
/**
* Cancellable promise.
*
* @class CancellablePromise
* @constructor
* @extends {Promise}
* @param {Function} fn A function where to insert the logic that resolves this
* promise. Receives `fulfill` and `reject` functions as parameters. This
* function is called synchronously.
* @param {Function} opt_errorCallback Optional error callback to be fired
CancellablePromise.sequence = function(values) {
var children = [];
return new A.CancellablePromise(
function(resolve, reject) {
if (!A.Lang.isArray(values)) {
reject(new TypeError('CancellablePromise.sequence expects an array of values or promises'));
return;
}
@henvic
henvic / plato-history-importer.sh
Created April 2, 2015 19:39
Plato history importer
#!/bin/bash
TITLE="Project Name"
REPORT_DIR="reports/complexity"
FILES="lib test bin tasks gulpfile.js"
BACK=$1
JSHINTRC=$2
OFFSET=$3
STEPS=$4
@henvic
henvic / build.go
Last active August 29, 2015 14:20
go build script from git-lfs
// Mostly https://github.com/github/git-lfs/blob/320a2c66aa84c1f9716cebdc53cca0e25373b57d/script/build.go
// Using https://gobuilder.me/ instead
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/henvic/picel/"
#!/bin/bash
#
# Cloud Hooks: code-deploy, code-update, db-copy, web-activate
# Essentially any time code or db changes are made.
#
# Purges Varnish cache for all .com domains assigned to the environment in Acquia Cloud.
site="$1"
target_env="$2"
drush_alias=$site'.'$target_env
#!/bin/bash
#
# Cloud Hooks: code-deploy, code-update, db-copy, web-activate
# Essentially any time code or db changes are made.
#
# Purges Varnish cache for all .com domains assigned to the environment in Acquia Cloud.
site="$1"
target_env="$2"
drush_alias=$site'.'$target_env
@henvic
henvic / main.cpp
Created July 11, 2015 01:53
Tic-tac-toe
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include <math.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
@henvic
henvic / Configuration.md
Last active September 30, 2015 03:46
Settings for nginx reverse proxy with https.

server.crt and server.key should be the paths to your certificate and your private key, respectively.

X-Real-IP is the IP of the client connected to the proxy. It is important to use it when you need to retrieve the IP of the connected client, otherwise you will end up with the IP of the proxy. You should check your application server API on how to set it (desirable) or retrieve it from the request headers.

You MUST use CA signed certificates on production environment.

Let's Encrypt is a new project that will be launched on 2015 Q4 that promises to allow you to get trustworthy certificates for free.

From now, rely on commercial ones like DigiCert, Comodo, or GoDaddy.

@henvic
henvic / pig
Created October 1, 2015 02:56
pig
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . ' - ( - ' . _ . . . . _ ........__ . . . _ . . .. __
. . . . . . . ' - ( - ' . . .' . . . . . . . . '. . .| . \ _ / _ |
. . . . . . . . . . ` ' - / . . . . . . . . . . . . \ / . . . . . . \
. . . . . . . . . . . . .|. . . . . . . . . . . . . . ` . . . 6 . 6.|_
. . . . . . . . . . . . .|. . . . . . . . . . . . . . . . . . . . . / .. ..\
. . . . . . . . . . . . . \ . . . . . . .| .. . . . . . . . . . , _\_ _ /
. . . . . . . . . . . . . . / . . . . . / . . . . . /.. . _ _ _ .--'
. . . . . . . . . . . . . < . . . . - ;`- - - -`. .\ . . \ . \
. . . . . . . . . . . . . . \ . . \ . \ . . . . . . . . \ . . \ . \
@henvic
henvic / random-example.txt
Created November 21, 2015 20:04
Math.random tests
1000000 iterations. Array is reset after first duplicate value.
length: 79775; duplicate: 14631346333771944
length: 45242; duplicate: 16620092559605836
length: 55295; duplicate: 9427159884944558
length: 123993; duplicate: 7038418645970523
length: 15575; duplicate: 8662485890090466
length: 96884; duplicate: 5140431500039995
length: 106546; duplicate: 40411726920865470
length: 54615; duplicate: 9114022604189812
length: 31491; duplicate: 9443272105418146