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 / 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 / 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 / .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 / generateMock.script.js
Created December 18, 2019 16:50
Mock generator
const { address, company, random } = require('faker');
const fs = require('fs');
const path = require('path');
fs.writeFile(
path.resolve('companies.mock.json'),
JSON.stringify(
[...new Array(60)].map(() => ({
id: random.number(),
name: company.companyName(),
@ulisesantana
ulisesantana / git_shortcuts.sh
Created January 21, 2020 21:35
Shortcuts for git
alias gitstats='git-stats'
alias gits='git status -s'
alias gita='git add -A && git status -s'
alias gitcom='git commit -am'
alias gitacom='git add -A && git commit -am'
alias gitc='git checkout'
alias gitcm='git checkout master'
alias gitcd='git checkout development'
alias gitcgh='git checkout gh-pages'
alias gitb='git branch'
@ulisesantana
ulisesantana / fizzBuzz.test.ts
Created May 15, 2020 22:04
Fizz Buzz TDD with Deno
import fizzBuzz, { FIZZ, BUZZ, FIZZ_BUZZ } from "./fizzBuzz.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
Deno.test(
"FizzBuzz should return the same number given if is not divisible by 3 or 5",
() => {
assertEquals(fizzBuzz(1), 1);
},
);
Deno.test(
@ulisesantana
ulisesantana / new-post.sh
Created May 2, 2021 09:48
Generate a file with current day as file name based on template. Will create a folder based on current month and save the file inside.
#!/usr/bin/env bash
check() {
test "$@" && echo true || echo false
}
show_help() {
echo -e "Generate a file with current day as file name based on template. Will create a folder based on current month and save the file inside.\n"
echo -e "Usage: new-post.sh template_path output_parent_directory.\n"
echo -e "Example: ./new-post.sh ./template.md ./posts
@ulisesantana
ulisesantana / init.vim
Created July 12, 2021 16:46
Neovim plugins config
" Based on this post https://stsewd.dev/es/posts/neovim-plugins/
call plug#begin('~/.local/share/nvim/plugged')
Plug 'yashguptaz/calvera-dark.nvim'
Plug 'scrooloose/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes' " Temas para airline
@ulisesantana
ulisesantana / .zshrc
Last active January 10, 2023 10:30
Raspberry Pi init script
# Prevent from using the custom alias on 3rd party scripts. Must be at the top of the file
[ -z "$PS1" ] && return
# alias
alias blog='cd ~/projects/blog'
alias blog-posts='cd ~/projects/blog/content/blog'
alias .zshrc='nvim ~/.zshrc'
alias gitlog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias wifi='nmcli device show wlan0'
function cd {
@ulisesantana
ulisesantana / algebraicTypes.ts
Created October 19, 2021 16:26
Ejemplo de tipos algebraicos en TypeScript
enum DiscountKind {
NoDiscount,
Special,
Resident,
Family,
Business
}
interface Discount {
kind: DiscountKind;