Skip to content

Instantly share code, notes, and snippets.

View israel-gs's full-sized avatar
🎯
Focusing

José Israel Gutierrez Salazar israel-gs

🎯
Focusing
View GitHub Profile
@israel-gs
israel-gs / vite-testing-config.md
Last active March 5, 2024 00:20 — forked from Klerith/vite-testing-config.md
Vite + Jest + React Testing Library - Configuraciones a seguir

Instalación y configuracion de Jest + React Testing Library

En proyectos de React + Vite

  1. Instalaciones:
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react 
yarn add --dev @testing-library/react @types/jest jest-environment-jsdom
  1. Opcional: Si usamos Fetch API en el proyecto:
create schema test;
create table profesor
(
facNo char(11) not null,
facPrimerNombre varchar(30) null,
fecApellidos varchar(30) null,
facCiudad varchar(30) null,
facEstado char(2) null,
facCodigoPostal char(4) null,
@israel-gs
israel-gs / semana8.java
Created May 18, 2022 18:38
Ejercicio Semana 8 Introducción a las TICs
package semana8;
import javax.swing.JOptionPane;
public class Semana8 {
public static void main(String[] args) {
int min, max;
// request min and max
min = Integer.parseInt(JOptionPane.showInputDialog("Ingrese el limite inferior"));
@israel-gs
israel-gs / RSACipher.java
Created October 19, 2020 21:38 — forked from awesometic/RSACipher.java
RSA encryption example for android
/**
* Created by Awesometic
* It's encrypt returns Base64 encoded, and also decrypt for Base64 encoded cipher
* references: http://stackoverflow.com/questions/12471999/rsa-encryption-decryption-in-android
*/
import android.util.Base64;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
@israel-gs
israel-gs / close_session.sql
Last active May 17, 2019 20:49
Close all sessions #SQL #MSSQL
USE master
GO
SET NOCOUNT ON
DECLARE @DBName varchar(50)
DECLARE @spidstr varchar(8000)
DECLARE @ConnKilled smallint
SET @ConnKilled=0
SET @spidstr = ''
@israel-gs
israel-gs / addorupdateextendedproperty.sql
Created May 16, 2019 15:47
Add or Update Extended Property #SQL #MSSQL
CREATE PROCEDURE sp_addorupdateextendedproperty
@name_ sysname,
@value_ sql_variant = NULL,
@level0type_ varchar(128) = NULL,
@level0name_ sysname = NULL,
@level1type_ varchar(128) = NULL,
@level1name_ sysname = NULL,
@level2type_ varchar(128) = NULL,
@level2name_ sysname = NULL
AS
@israel-gs
israel-gs / HttpHelper.java
Created June 26, 2018 21:35
Get payload from request
import java.io.BufferedReader;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONObject;
public class HttpHelper {
public static JSONObject getPayloadBody(HttpServletRequest request) throws IOException {
String line;
StringBuffer json = new StringBuffer();
@israel-gs
israel-gs / CurrencyFormat.java
Created June 23, 2018 16:55
Convert double to currency format.
import java.math.BigDecimal;
import java.math.RoundingMode;
public class CurrencyFormat {
public static String getCustomCurrency(double currency) {
BigDecimal cc = new BigDecimal(currency);
return cc.setScale(2, RoundingMode.HALF_UP).toString();
}
var inBrowser = typeof window !== 'undefined';
var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
var UA = inBrowser && window.navigator.userAgent.toLowerCase();
var isIE = UA && /msie|trident/.test(UA);
var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
var isEdge = UA && UA.indexOf('edge/') > 0;
var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
@israel-gs
israel-gs / JSONRules.java
Last active March 26, 2018 16:11
Create rules and validate a JSON Object for org.json library
import org.json.JSONArray;
import org.json.JSONObject;
public class JSONRules {
private static String errorRequired = "{} is required but not found in object.";
private static String errorLength = "The value of {} exceeds the set length in rule.";
private static String errorFormat = "The value of {} does not match with the format set.";
public JSONRules() {