Skip to content

Instantly share code, notes, and snippets.

View mateusfreira's full-sized avatar
🌎

Mateus Freira dos Santos mateusfreira

🌎
View GitHub Profile
@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. */
//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 / 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));
}
@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 / gist:2591421
Created May 4, 2012 02:17
Coffee SublimeTextBuild sample
{
"cmd": ["coffee", "$file"],
"selector" : "source.coffee",
"path" : "/usr/local/bin"
}
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