Skip to content

Instantly share code, notes, and snippets.

View titoaesj's full-sized avatar
🇧🇷

Tito Albino Evangelista da Silva Junior titoaesj

🇧🇷
View GitHub Profile
class CircleTransform : Transformation {
override fun transform(source: Bitmap): Bitmap {
val size = Math.min(source.width, source.height)
val x = (source.width - size) / 2
val y = (source.height - size) / 2
val squaredBitmap = Bitmap.createBitmap(source, x, y, size, size)
if (squaredBitmap != source) {
[
(uf: "AC", name: "Acre"),
(uf: "AL", name: "Alagoas"),
(uf: "AP", name: "Amapá"),
(uf: "AM", name: "Amazonas"),
(uf: "BA", name: "Bahia"),
(uf: "CE", name: "Ceará"),
(uf: "DF", name: "Distrito Federal"),
(uf: "ES", name: "Espírito Santo"),
(uf: "GO", name: "Goiás"),
@titoaesj
titoaesj / cpf_cnpj_validator
Last active December 20, 2018 22:40 — forked from igorcosta/cpf_cnpj_validator
Regex para validar CPF e CNPJ
Para CPF
/^\d{3}\.\d{3}\.\d{3}\-\d{2}$/
fun main(args: Array<String>) {
if (Regex("^\\d{3}\\.\\d{3}\\.\\d{3}\\-\\d{2}$").matches("000.000.000-00")) {
println("sim")
} else {
println("não")
}
brew install php71-intl
brew tap kyslik/homebrew-php
brew install kyslik/php/php71-intl
brew install phplint (o que esta funcionando)
class CustomDisableSwapViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) {
var enabled: Boolean?
init {
this.enabled = false
}
override fun onTouchEvent(event: MotionEvent): Boolean {
return if (this.enabled!!) {
# Stop all constainers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@titoaesj
titoaesj / .swift
Created October 16, 2017 13:21
Sempre que a segue de destino for uma UINavigationController usar o seguinte trecho de código.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "meu_identificador" {
if let destinationNavigationController = segue.destination as? UINavigationController,
let targetController = destinationNavigationController.topViewController as? meu_controller {
...
}
}
}
@titoaesj
titoaesj / .kt
Last active October 16, 2017 13:22
Kotlin com Dagger2
kapt {
generateStubs = true
}
dependencies {
...
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.google.dagger:dagger:2.0.2'
kapt 'com.google.dagger:dagger-compiler:2.0.2'
...
@titoaesj
titoaesj / .swift
Last active October 16, 2017 13:26
Criando animação nas células da UITableView - iOS
override func viewWillAppear(animated: Bool) {
animateTable()
}
func animateTable() {
tableView.reloadData()
let cells = tableView.visibleCells()
let tableHeight: CGFloat = tableView.bounds.size.height
@titoaesj
titoaesj / .kt
Last active March 17, 2024 22:22
Android convert int to dp
OBS: O var_number_int é a varável que recebera o valor a ser convertido em DP
(int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, var_number_int, getResources().getDisplayMetrics())
##KOTLIN
val Int.dp: Int
get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt()
val Float.dp: Int