Skip to content

Instantly share code, notes, and snippets.

View gorrotowi's full-sized avatar
🏠
Working from home

sebastian tellez gorrotowi

🏠
Working from home
View GitHub Profile
class OPHandleError {
fun getError(code: Int): Throwable {
val messageError: Throwable
when (code) {
//OpenPay General Errors
1000 -> messageError = Throwable("Error interno del servidor")
1001 -> messageError = Throwable("Error al identificar usuario, intenta nuevamente")
1002 -> messageError = Throwable("Error al identificar usuario, intenta nuevamente")
1003 -> messageError = Throwable("La operación no se pudo completar por que el valor de uno o más de los parametros no es correcto")
@gorrotowi
gorrotowi / build_apk.bash
Last active February 23, 2017 22:25
Commands to build a signed APK in terminal for react_native project
#start react-native in port 8088
$ react-native start --port=8088
#download the bundle of android know bug in react-native
$ curl http://localhost:8088/index.android.bundle?platform=android
#inside react-native's android project build the assembleRelease flavor
$ ./gradlew assembleRelease
#go to the apk's android folder
@gorrotowi
gorrotowi / adbwifi.bash
Created December 24, 2016 19:21
With this commands you can deploy your Android project in a physic device with out usb cable
#ADB enable:
adb tcpip 5555
adb connect device-ip:5555
#ADB to disable:
adb -s device-ip:5555 usb
@gorrotowi
gorrotowi / UtilsExtensions.java
Created November 29, 2016 18:27
Methods to get current and past Months and name of them
public static int getCurrentYear() {
return Calendar.getInstance().get(Calendar.YEAR);
}
public static int[] getMonthsPos() {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, 0);
int month1 = new Timestamp(calendar.getTime().getTime()).getMonth();
@gorrotowi
gorrotowi / startnewstackactivity.java
Created August 22, 2016 13:15
How to clear activity stack
Intent intent = new Intent(theContextClass.this, YourClass.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
@gorrotowi
gorrotowi / encodexzing.java
Created August 19, 2016 02:11
Encode data with Android XZing
//Global Objects and variables
ImageView imgBarcode;
private static final int WHITE = 0xFFFFFFFF;
private static final int BLACK = 0xFF000000;
Bitmap bmp;
//Implementation
bmp = encodeAsBitmap("1234567890", BarcodeFormat.CODE_128, 800, 200);
imgBarcode.setImageBitmap(bmp);
@gorrotowi
gorrotowi / index.html
Created July 26, 2016 06:03
No sidebar
<!DOCTYPE html>
<html>
<head>
<title>Cumpleaños</title>
<link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" integrity="sha384-XXXXXXXX" crossorigin="anonymous">
<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js" integrity="sha384-XXXXXXXX" crossorigin="anonymous"></script>
<link href="assets/css/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="assets/css/estilo.css" >
<meta charset="UTF-8">
@gorrotowi
gorrotowi / uppercaseString.swift
Created July 12, 2016 18:26
This script converts all the first letter of a string to capitalized
func _Dash(text:String) -> String {
var modifiedText = ""
let textArr = text.componentsSeparatedByString(" ")
var repleacetxt = ""
for word in textArr {
if word != "" {
let character = word[word.startIndex]
let scalar = String(character).unicodeScalars
let unicode = scalar[scalar.startIndex].value
if unicode >= 97 && unicode <= 122 {
package com.gorrotowi.btsendreceive;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
@gorrotowi
gorrotowi / validations.java
Last active November 24, 2015 22:40
Validation mail in java
private final static Pattern EMAIL_ADDRESS_PATTERN = Pattern
.compile(/*"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@"
+ "((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
+ "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\."
+ "([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?"
+ "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
+ "([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$"*/
"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,6}");
public static boolean isMail(String email) {