Skip to content

Instantly share code, notes, and snippets.

View trfiladelfo's full-sized avatar

Thiago Filadelfo trfiladelfo

View GitHub Profile
@trfiladelfo
trfiladelfo / CommonExtensions.kt
Created May 4, 2018 15:58 — forked from adavis/CommonExtensions.kt
Common Android Extensions in Kotlin
fun View.visible() {
visibility = View.VISIBLE
}
fun View.invisible() {
visibility = View.INVISIBLE
}
fun View.gone() {
visibility = View.GONE
@trfiladelfo
trfiladelfo / ForceCacheOrNetwork.java
Created April 23, 2018 21:18 — forked from Tetr4/ForceCacheOrNetwork.java
How to force a cached or network response on Android with Retrofit + OkHttp
OkHttpClient okHttpClient = new OkHttpClient();
try {
int cacheSize = 10 * 1024 * 1024 // 10 MiB
Cache cache = new Cache(getCacheDir(), cacheSize);
okHttpClient.setCache(cache);
} catch (IOException e) {
Log.e(TAG, "Could not set cache", e);
}
// Forces cache. Used for cache connection
@trfiladelfo
trfiladelfo / add local aar file.md
Created April 1, 2018 19:00 — forked from shau-lok/add local aar file.md
Android Studio add local .aar reference

Add local .aar file

  1. basic build.gradle directory using flatDir
repositories {
    mavenCentral()
    flatDir {
 dirs 'libs'
@trfiladelfo
trfiladelfo / ScrollViewExample+TextField.swift
Created January 15, 2018 10:26 — forked from Erkened/ScrollViewExample+TextField.swift
UIScrollView example, with a textfield that's not covered when the keyboard appears, fully programmatic with AutoLayout. Swift 4.0
//
// ViewController.swift
// Repnote
//
// Created by John Neumann on 05/07/2017.
// Copyright © 2017 Audioy. All rights reserved.
//
import UIKit
@trfiladelfo
trfiladelfo / gist:e81e11749a5ec19adbf77860ecb49621
Created November 12, 2017 20:43 — forked from simonw/gist:7000493
How to use custom Python JSON serializers and deserializers to automatically roundtrip complex types.
import json, datetime
class RoundTripEncoder(json.JSONEncoder):
DATE_FORMAT = "%Y-%m-%d"
TIME_FORMAT = "%H:%M:%S"
def default(self, obj):
if isinstance(obj, datetime.datetime):
return {
"_type": "datetime",
"value": obj.strftime("%s %s" % (
@trfiladelfo
trfiladelfo / __main__.py
Created October 11, 2017 03:38 — forked from anonymous/__main__.py
SOAP, zeep
from zeep import Client, helpers
client = Client('https://apps.correios.com.br/SigepMasterJPA/AtendeClienteService/AtendeCliente?wsdl')
resp = client.service.consultaCEP('06694720')
resp = helpers.serialize_object(resp)
resp = {k: resp[k] for k in resp}
print(resp)
client = Client('http://www.webservicex.com/globalweather.asmx?wsdl')
resp = client.service.GetCitiesByCountry('New York')
@trfiladelfo
trfiladelfo / aes-ecb.py
Created October 10, 2017 20:12 — forked from lopes/aes-ecb.py
Simple Python example of AES in ECB mode.
from hashlib import md5
from base64 import b64decode
from base64 import b64encode
from Crypto.Cipher import AES
# Padding for the input string --not
# related to encryption itself.
BLOCK_SIZE = 16 # Bytes
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * \
@trfiladelfo
trfiladelfo / aes_example_in_python.py
Created October 10, 2017 20:04 — forked from dokenzy/aes_example_in_python.py
AES Encrytion Example in Python
#-*- coding: utf-8 -*-
# Python 3.4
# author: http://blog.dokenzy.com/
# date: 2015. 4. 8
# References
# http://www.imcore.net/encrypt-decrypt-aes256-c-objective-ios-iphone-ipad-php-java-android-perl-javascript/
# http://stackoverflow.com/questions/12562021/aes-decryption-padding-with-pkcs5-python
# http://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256
@trfiladelfo
trfiladelfo / aes-cbc.py
Created October 10, 2017 20:04 — forked from lopes/aes-cbc.py
Simple Python example of AES in CBC mode.
from hashlib import md5
from base64 import b64decode
from base64 import b64encode
from Crypto import Random
from Crypto.Cipher import AES
# Padding for the input string --not
# related to encryption itself.
BLOCK_SIZE = 16 # Bytes
@trfiladelfo
trfiladelfo / git.css
Created August 20, 2016 23:09 — forked from neilgee/git.css
Git Command Line Reference - Notes and reminders on set up and commands
/*
* Set up your Git configuration
*/
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git config --global core.editor "nano"