Skip to content

Instantly share code, notes, and snippets.

View ulisesantana's full-sized avatar
😍
In love with TypeScript

Ulises Santana ulisesantana

😍
In love with TypeScript
View GitHub Profile
@ulisesantana
ulisesantana / .zshrc
Last active November 17, 2019 16:09
Passing to macOS Catalina and installing zsh. Based on this https://dev.to/saltyshiomix/a-guide-for-upgrading-macos-to-catalina-and-migrating-the-default-shell-from-bash-to-zsh-4ep3 by Shiono Yoshihide
zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
fpath=(~/.zsh $fpath)
alias ..='cd ..'
alias ...='cd ../..'
alias ls='ls -GwF'
alias ll='ls -alh'
alias zshrc='code ~/.zshrc'
@ulisesantana
ulisesantana / package.json
Last active September 24, 2019 22:20
Get all the pokemons from the PokeAPI and save it to a JSON file
{
"name": "saveAllPokemons",
"version": "0.0.1",
"main": "saveAllPokemons.js",
"scripts": {
"start": "node saveAllPokemons.js"
},
"dependencies": {
"axios": "^0.19.0"
},
@ulisesantana
ulisesantana / usePokedex.ts
Last active September 22, 2019 17:24
A "Pokedex" hook for using the PokeAPI to show a list of pokemons with pagination.
import {EffectCallback, MouseEventHandler, useEffect, useState} from "react";
export interface Pokemon {
name: string,
url: string,
id: string,
img: string
}
export interface Pokedex {
@ulisesantana
ulisesantana / styleguide.config.js
Last active January 25, 2019 08:53
React Styleguidist Config for Create React App(^2.1.3) with TypeScript
module.exports = {
components: 'src/components/**/[A-Z]*.{ts,tsx}',
propsParser: require('react-docgen-typescript').parse,
webpackConfig: require('react-scripts/config/webpack.config.js')
};
@ulisesantana
ulisesantana / reduxTdd.d.ts
Created September 13, 2018 20:17
redux-tdd typing
declare module "redux-tdd" {
import { ActionsObservable } from 'redux-observable';
import { combineReducers, ReducersMapObject } from 'redux'
import { shallow, ShallowWrapper } from 'enzyme';
class ReduxTdd {
constructor(reducers: ReducersMapObject, render: Function)
getCurrentWrapper(): ShallowWrapper
it(str: string): ReduxTdd
@ulisesantana
ulisesantana / QuicksortJS.md
Last active July 21, 2018 12:25
JavaScript Quicksort algorithm implementation

QuickSort JavaScript implementation

This is my implemention of Quicksort algorithm in JavaScript. According to Wikipedia the Quicksort algorithm is:

Quicksort is a divide and conquer algorithm. Quicksort first divides a large array into two smaller sub-arrays: the low elements and the high elements. Quicksort can then recursively sort the sub-arrays.

The steps are:

  • Pick an element, called a pivot, from the array.
  • Partitioning: reorder the array so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position. This is called the partition operation.
@ulisesantana
ulisesantana / portainer-service.sh
Last active October 17, 2020 05:29
Create portainer as docker swarm service
#!/bin/bash
mkdir -p /data/portainer
docker service create \
--name portainer \
--publish 9000:9000 \
--replicas=1 \
--constraint 'node.role == manager' \
--mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
--mount type=bind,src=/data/portainer,dst=/data \
portainer/portainer-ce -H unix:///var/run/docker.sock
@ulisesantana
ulisesantana / index.js
Created July 7, 2018 12:11
Proof of concept about inheritance in JS without classes
function Animal(animalName, animalType) {
let name = animalName;
const type = animalType;
return {
getName() {
return name;
},
setName(newName) {
name = newName;
@ulisesantana
ulisesantana / fizzBuzz.js
Last active May 12, 2018 11:21
Fizz Buzz JavaScript Solution
function fizzBuzz(num) {
const isDivisibleBy = x => y => y % x === 0;
const isDivisibleBy3 = isDivisibleBy(3);
const isDivisibleBy5 = isDivisibleBy(5);
return isDivisibleBy3(num) && isDivisibleBy5(num)
? 'FizzBuzz'
: isDivisibleBy3(num)
? 'Fizz'
: isDivisibleBy5(num)
@ulisesantana
ulisesantana / docker-msyql.sh
Last active July 2, 2020 09:30
Create a MySQL docker instance for develop
#!/bin/bash
export MYSQL_ROOT_PASSWORD=root MYSQL_ROOT_HOST=%
sudo mkdir -p /data/mysql
sudo chmod -R 775 /data
docker run --name=mysql -d \
-e MYSQL_ROOT_PASSWORD \