Skip to content

Instantly share code, notes, and snippets.

View mateusfreira's full-sized avatar
🌎

Mateus Freira dos Santos mateusfreira

🌎
View GitHub Profile
import sbt._
class LiftProject(info: ProjectInfo) extends DefaultWebProject(info) {
val liftVersion = property[Version]
// uncomment the following if you want to use the snapshot repo
// val scalatoolsSnapshot = ScalaToolsSnapshots
// If you're using JRebel for Lift development, uncomment
// this line
@mateusfreira
mateusfreira / gist:2591421
Created May 4, 2012 02:17
Coffee SublimeTextBuild sample
{
"cmd": ["coffee", "$file"],
"selector" : "source.coffee",
"path" : "/usr/local/bin"
}
@mateusfreira
mateusfreira / gist:3781896
Created September 25, 2012 13:33
Dado um vetor com 'n' números distintos, calcular quantas possibilidades existem para se obter a soma 's'
def countSum(numbers: List[Int], expectedResult: Int): Int = {
countSumRecursively(numbers, 0, expectedResult);
}
def countSumRecursively(numbers: List[Int], currentResult: Int, expectedResult: Int): Int = {
if (currentResult == expectedResult)
1
else if ((currentResult > expectedResult) || (numbers.isEmpty))
0
else
@mateusfreira
mateusfreira / Number.prototype.roundup.js
Created May 19, 2013 16:53
JsNumber Arredondar sempre para cima
Number.prototype.roundup= function(dec){
if(this.toFixed(dec) < value)
return window.parseFloat(this.toFixed(dec))+(1/(Math.pow(10,dec)));
else
return window.parseFloat(this.toFixed(dec));
}
//Date Util
Date.prototype.getYearGap = function(){
var ret = new Date(this.getTime());
return this.getFullYear() - ret.getFullYear();
};
Date.prototype.getStartOfMonth = function(){
var ret = new Date(this.getTime());
ret.setDate(1)
return ret;
};
@mateusfreira
mateusfreira / Base64.java
Last active August 29, 2015 14:27
Envio de foto como base64 android
//classe Base64
public class Base64 {
/* ******** P U B L I C F I E L D S ******** */
/** No options specified. Value is zero. */
public final static int NO_OPTIONS = 0;
/** Specify encoding in first bit. Value is one. */
@mateusfreira
mateusfreira / cefet_tuma_1.js
Created December 14, 2015 13:59
cefet_tuma_1.js js
function fat(x) {
if (x == 0 || x == 1) {
return 1;
}
return fat(x - 1) * x;
}
var quadrado = function(x) {
return x * x;
};
@mateusfreira
mateusfreira / Dockerfile
Created March 27, 2016 22:22
Dockerfile Jenkins + Node
FROM jenkins
# if we want to install via apt
USER root
RUN curl -sL https://deb.nodesource.com/setup_5.x | bash -
RUN apt-get install -y nodejs
EXPOSE 8080
EXPOSE 50000
EXPOSE 9090
EXPOSE 9091
@mateusfreira
mateusfreira / UpstreamNginxSample
Created March 28, 2016 02:12
Upstream Nginx Sample
upstream yoursiteName {
server 127.0.0.1:9090 max_fails=1;
server 127.0.0.1:9091 max_fails=3 backup;
server 127.0.0.1:9090 max_fails=3 fail_timeout=600s backup;
}
server {
listen 80;
server_name www.yoursite.com.br yoursite.com.br;
access_log /var/log/yoursite.access.log main;
//Import jenkinsHelper
const jenkinsDeployerManager = require("deploy-blue-green-helper-jenkins");
//Create your jenkinsOptions configuration
const jenkinsOptions = {
debug: false,
jenkinsUrl: "http://192.168.99.100:8081/"
};
//Create your blueOptions configuration
const blueOptions = {