Skip to content

Instantly share code, notes, and snippets.

import React from 'react';
import LoadingWrapper from '../components/LoadingWrapper';
import * as Auth from '../services/auth';
import * as User from '../services/user';
import { BroadcastChannel } from 'broadcast-channel';
import { isSafari, isMobileSafari } from 'react-device-detect';
import { useAsync, StateType } from '../utils/hooks';
/** REMOVE DUPLICATES */
// BigO = n^2
// function removeDuplicates(str) {
// const words = str.split(' ');
// const filteredWords = words.filter((word, i, list) => list.indexOf(word) === i)
// return filteredWords.join(' ');
// }
// BigO = n
// function removeDuplicates(str) {
@johanquiroga
johanquiroga / utilities.js
Created February 21, 2020 16:26
Utilities to handle common reducer actions when dealing with normalized data
import set from 'lodash/fp/set';
import get from 'lodash/fp/get';
import omit from 'lodash/fp/omit';
import pipe from 'lodash/fp/pipe';
const removeFromArray = (array, target) => array.filter(n => n !== target);
export const addEntity = (state, entity, id) => {
return pipe(
set(['entities', id], entity),
@johanquiroga
johanquiroga / Fastfile
Created February 21, 2020 01:57
fastlane android
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
@johanquiroga
johanquiroga / Fastfile
Last active February 21, 2020 02:10
fastlane ios
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
@johanquiroga
johanquiroga / useUndoReducer.js
Last active December 14, 2023 08:52
Undo/Redo capability for any reducer using react hook `useReducer`
import { useReducer } from 'react';
const useUndoReducer = (reducer, initialState) => {
const undoState = {
past: [],
present: initialState,
future: []
};
const undoReducer = (state, action) => {
@johanquiroga
johanquiroga / emails-from-xml.sh
Last active February 2, 2018 01:28
Small script to extract valid emails from a list of students in XML format
#!/bin/bash
if [ $# -eq 0 ];then
echo "Escribe el path completo al archivo xml (o arrastralo hasta aquí)"
read file;
echo "Escribe el nombre del archivo de salida (con extensión)"
read outputFile;
else
if [ "$1" ];then
file=$1
@johanquiroga
johanquiroga / borrar.sh
Created November 1, 2017 17:37
Script con menú para copiado y borrado de archivos.
#!/bin/bash
if (test $# -ne 1)
then
echo "Faltan/Sobran argumentos..."
echo "Forma de uso borrar <origen>"
elif (test -f $1)
then
if (test ! -d $HOME/Papelera)
then
@johanquiroga
johanquiroga / ejercicio-asi.sh
Created November 1, 2017 00:46
Script solución para ejercicio planteado acerca de la organización de carpetas (Cuerpo humano)
#!/bin/bash
root=CUERPO
declare -A directories
createData()
{
directories[cabeza]=$root
directories[extremidades]=$root