Skip to content

Instantly share code, notes, and snippets.

View jibbo's full-sized avatar

Giovanni De Francesco jibbo

View GitHub Profile
@jibbo
jibbo / convertTest.kt
Last active November 23, 2021 15:16
Convert date in Kotlin
@Test
fun `convert Timezone`() {
val serverTimeInUTC = "2021-11-19 09:50:36" // Friday 19 Nov 2021 at 9:50
val utcFormatter = SimpleDateFormat(DateUtils.TIMESTAMP_FORMAT)
utcFormatter.timeZone = TimeZone.getTimeZone("UTC")
val utcDate = utcFormatter.parse(serverTimeInUTC)
val utcDateString = utcFormatter.format(utcDate)
val otherFormatter = SimpleDateFormat(DateUtils.TIMESTAMP_FORMAT)
@jibbo
jibbo / gradle.properties
Last active August 3, 2021 13:40
Gradle properties for 16gb of ram, makes compilling faster
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true
org.gradle.unsafe.configuration-cache=true
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseParallelGC -Dfile.encoding=UTF-8
// Activity
@OnClick(R.id.continue_btn)
fun checkEmail() {
val email = UiUtils.getText(emailView)
presenter.checkEmail(email)
}
// Presenter
var degrees2meters = function(lon,lat) {
var x = lon * 20037508.34 / 180;
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
return [x, y]
}
lon= -77.035974
lat = 38.898717
@jibbo
jibbo / BitmapUtils.java
Created June 12, 2018 13:16
[Android] Save JPEG with lesser quality the bigger it is, especially useful to reduce image upload time.
private static final int MB = 1000000; // 1MB in bytes
private static final int MIN_SIZE = 3; // in MB
private static final int MAX_SIZE = 20; // in MB
private static final int MAX_QUALITY = 100;
private static final int MIN_QUALITY = 10;
private static final int NORMAL_QUALITY = 90;
/**
* Gets a bitmap and saves it as jpeg.
*
@jibbo
jibbo / bob.rb
Last active August 29, 2015 14:18 — forked from tcgeophysics/bob.rb
Formula for installing Bob (Bob is a free signal-processing and machine learning toolbox)
require "formula"
#be sure to have the repo homebrew-dupes and homebrew-science
#if not add it with: brew tap Homebrew/homebrew-dupes && brew tap Homebrew/homebrew-science
#after installing brew-pip you have to run pip install all the dependencies listed in the python section
class Bob < Formula
homepage "http://www.idiap.ch/software/bob/docs/releases/last/sphinx/html/index.html"
url "http://www.idiap.ch/software/bob/packages/bob-1.2.2.tar.gz"
sha1 "c557712996ae8a6a1e161026f539d1f1fd108fb0"
@jibbo
jibbo / PaintEraser
Created October 30, 2014 14:02
How to set a Painter to erase content on a canvas.
Paint e = new Paint();
e.setColor(Color.TRANSPARENT);
e.setAlpha(0);
e.setAntiAlias(true);
e.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));