Skip to content

Instantly share code, notes, and snippets.

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

Jorge Zapata Jmzp

🏠
Working from home
  • frubana.com
  • Colombia
View GitHub Profile
@Jmzp
Jmzp / AndroidBackHandlerWrapper.js
Last active January 25, 2021 15:27
HOC to manage the back android button behaviour
import React, { useCallback } from 'react';
import { BackHandler } from 'react-native';
import PropTypes from 'prop-types';
import { useFocusEffect } from '@react-navigation/native';
const AndroidBackHandlerWrapper = (props) => {
useFocusEffect(
useCallback(() => {
const { onBackPress } = props;
BackHandler.addEventListener('hardwareBackPress', onBackPress);
@Jmzp
Jmzp / tasks.js
Created July 11, 2019 19:49
Tutorial of Koa
router.get('/task/:id', async (ctx) => {
await Task.findOne({
where: {
id: ctx.params.id
}
})
.then(tasks => {
if (tasks === null){
Object.assign(ctx, { status: 404, body: { errors: [{ msg: 'Task does not exist' }] } });
}
@Jmzp
Jmzp / PresetDateRangePicker.js
Created March 22, 2019 16:39
Preset Data Range Picker with react-dates
import React from 'react';
import PropTypes from 'prop-types';
import momentPropTypes from 'react-moment-proptypes';
import moment from 'moment';
import omit from 'lodash/omit';
import 'react-dates/initialize';
import 'react-dates/lib/css/_datepicker.css';
import { withStyles, withStylesPropTypes, css } from 'react-with-styles';
import DateRangePickerShape from 'react-dates/src/shapes/DateRangePickerShape';
const MapIsoToCountryAndIoc = {
AF: ['Afghanistan', 'AFG'],
AL: ['Albania', 'ALB'],
DZ: ['Algeria', 'ALG'],
AS: ['American Samoa', 'ASA'],
AD: ['Andorra', 'AND'],
AO: ['Angola', 'ANG'],
AG: ['Antigua and Barbuda', 'ANT'],
AR: ['Argentina', 'ARG'],
AM: ['Armenia', 'ARM'],
if transaction.entity.present?
entity = transaction.entity
if entity.type == 4
data_link[:datos_adicionales] = { 'Oferta' => entity.name, 'Descripción' => entity.description }
else
data_link[:datos_adicionales] = { 'Descripción' => Pay::PaymentezAdapter.format_charge_description(customer) }
end
data_link
else
data_link[:datos_adicionales] = { 'Descripción' => Pay::PaymentezAdapter.format_charge_description(customer) }
@Jmzp
Jmzp / aes_crypto.rb
Last active November 23, 2018 21:06
class AESCrypto
# @!attribute cipher
# @return [OpenSSL::Cipher] the cipher object used to encrypt and decrypt
# @!attribute iv
# @return [String] the initialization vector used for the cipher object
# @!attribute key
# @return [String] the key used for the cipher object
require 'openssl'
require 'base64'