Skip to content

Instantly share code, notes, and snippets.

@cfirmo33
cfirmo33 / Lista das colunas de uma tabela
Last active November 24, 2017 18:22
Lista das colunas de uma tabela
select
c.relname as tableName,
a.attname as "Column",
pg_catalog.format_type(a.atttypid, a.atttypmod) as "Datatype"
from pg_catalog.pg_attribute a
inner join pg_stat_user_tables c on a.attrelid = c.relid
WHERE
a.attnum > 0
AND NOT a.attisdropped
AND c.relname like '@TABLE_NAME'
@cfirmo33
cfirmo33 / RetrofitUtils
Created April 4, 2017 18:35
RetrofitUtils
public class RetrofitUtils {
private static Retrofit retrofit;
private static OkHttpClient getUnsafeOkHttpClient() {
try {
final TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {
@cfirmo33
cfirmo33 / RetrofitException
Created April 4, 2017 18:34
Controlling erro in Retrofit
public class RetrofitException extends RuntimeException {
public static RetrofitException httpError(String url, Response response, Retrofit retrofit) {
String message = response.code() + " " + response.message();
return new RetrofitException(message, url, response, Kind.HTTP, null, retrofit);
}
public static RetrofitException networkError(IOException exception) {
return new RetrofitException(exception.getMessage(), null, null, Kind.NETWORK, exception, null);
}
public class RetrofitException extends RuntimeException {
public static RetrofitException httpError(String url, Response response, Retrofit retrofit) {
String message = response.code() + " " + response.message();
return new RetrofitException(message, url, response, Kind.HTTP, null, retrofit);
}
public static RetrofitException networkError(IOException exception) {
return new RetrofitException(exception.getMessage(), null, null, Kind.NETWORK, exception, null);
}
public class GeradorDeSets {
public static void main(String[] args) {
try {
gerarArquivoSets(Operacao.class);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
public static void gerarArquivoSets(Class<?> c) throws NoSuchFieldException{
@cfirmo33
cfirmo33 / CheckLimiteWatcher.txt
Last active January 21, 2016 15:51
CheckLimiteWatcher
public class CheckLimiteWatcher implements TextWatcher{
private Context context;
private int limite;
private int totalAnterior = -1;
public CheckLimiteWatcher( Context context, int limite ) {
this.limite = limite;
this.context = context;
}
@cfirmo33
cfirmo33 / getSSLSocket()
Created August 19, 2015 20:11
getSSLSocket
public static MySSLSocketFactory getSSLSocket(){
MySSLSocketFactory sf = null;
try {
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
sf = new MySSLSocketFactory(trustStore);
sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
}catch (Exception e) {
@cfirmo33
cfirmo33 / MySSLSocketFactory
Created August 19, 2015 20:09
My SSL Socket Factory
public class MySSLSocketFactory extends SSLSocketFactory {
SSLContext sslContext = SSLContext.getInstance("TLS");
public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
super(truststore);
TrustManager tm = new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@cfirmo33
cfirmo33 / DataPickerDialog
Last active August 29, 2015 14:23
DataPickerDialog
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fromDateEtxt = (EditText) findViewById(R.id.etxt_fromdate);
fromDateEtxt.setInputType(InputType.TYPE_NULL);
fromDateEtxt.requestFocus();
toDateEtxt = (EditText) findViewById(R.id.etxt_todate);
toDateEtxt.setInputType(InputType.TYPE_NULL);