Skip to content

Instantly share code, notes, and snippets.

View amadeu01's full-sized avatar
:octocat:
Working from Stockholm

Amadeu Cavalcante Filho amadeu01

:octocat:
Working from Stockholm
View GitHub Profile
import UIKit
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let url = URL(string: "http://www.google.com/")!
let task = URLSession.shared.dataTask(with: url) { data, response, error in
if let error = error {
import UIKit
import Foundation
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let endpoint = "https://api.punkapi.com/v2/beers/1"
let url = URL(string: endpoint)!
@amadeu01
amadeu01 / IntEditTextPreference.java
Created February 18, 2018 15:37
Int Edit Text Preferences
/**
* @Author Amadeu Cavalcante Filho
* @Date 29/12/2017
* @Email amadeu01@gmail.com
*/
public class IntEditTextPreference extends EditTextPreference {
public IntEditTextPreference(Context context) {
super(context);
@amadeu01
amadeu01 / correios-cli.swift
Created February 27, 2018 02:03
Swift initial implementation of correios API
import Foundation
let arguments = CommandLine.arguments
let getPrazo = "/calculador/CalcPrecoPrazo.asmx/CalcPrazo?nCdServico=string&sCepOrigem=string&sCepDestino=string"
if arguments.count != 2 {
print("Correios CLI ")
var urlComponents = URLComponents(string: "ws.correios.com.br/calculador/CalcPrecoPrazo.asmx/CalcPrazo")!
urlComponents.queryItems = [
URLQueryItem(name: "nCdServico", value: "1"),
@amadeu01
amadeu01 / my-helper.md
Last active March 1, 2018 17:15
This is me collection of small codes that have been helped me at some point in my life :D

This is my collections of helpers:

public String convert(InputStream inputStream, Charset charset) throws IOException {
 
	StringBuilder stringBuilder = new StringBuilder();
	String line = null;
	
	try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, charset))) {	
@amadeu01
amadeu01 / build.gradle
Created March 13, 2018 18:51
My example of gradle file
import java.time.*
task helloWorld {
description = 'My hello world'
doLast {
println "Hello World"
}
}
task printDate {
@amadeu01
amadeu01 / build.gradle
Created March 13, 2018 19:36
Test some gradle stuff while lern it
println 'Above all stuff'
task hello {
println 'Inside hello, before doLast'
doLast {
println "Hello World"
println 'Inside hello, Inside do doLast'
}
println 'Inside hello, after doLast'
}
@amadeu01
amadeu01 / build.gradle
Created March 15, 2018 17:12
Used to test gradle parallel tests. and `-t` argument to continues running tests.
apply plugin: "java"
group = "amadeu01.github.io"
description = "My Java Library"
version = "1.0"
repositories {
mavenCentral()
}
@amadeu01
amadeu01 / MainActivity.java
Created March 22, 2018 15:36
Crop picture
package io.github.amadeu01.cameraproportions;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="io.github.amadeu01.cameraproportions.MainActivity">
<FrameLayout