Skip to content

Instantly share code, notes, and snippets.

View taverasmisael's full-sized avatar
:shipit:
Focusing

Misael Taveras taverasmisael

:shipit:
Focusing
View GitHub Profile
@taverasmisael
taverasmisael / roman-to-decimal.ts
Last active June 30, 2023 19:52
A simple gist to convert roman numbers to decimal using reduceRight
const VALUES = {
I: 1,
V: 5,
X: 10,
L: 50,
C: 100,
D: 500,
M: 1000,
}
const INIT = { value: 0, prev: 0 }
@taverasmisael
taverasmisael / rename-index-to-dirname.ts
Created November 12, 2022 14:09
Simple and non-recursive way to rename index files on a directory to have the same name as the directory it is in
import path from 'path'
import fs from 'fs'
const cwd = path.resolve('[YOUR DIR]')
const dirs = fs.readdirSync(cwd)
const isFile = (baseDir: string) => (dir: string) =>
fs.lstatSync(path.join(baseDir, dir)).isFile()
const and =
@taverasmisael
taverasmisael / change-commits-email.sh
Created October 9, 2021 13:25
Run this on your terminal to change old commits user.email
# Taken from -> https://www.git-tower.com/learn/git/faq/change-author-name-email/
git filter-branch --env-filter '
WRONG_EMAIL="THE_BAD@EMAIL.COM"
NEW_NAME="YOUR GOOD NAME"
NEW_EMAIL="THE_GOOD@EMAIL.COM"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
exports [`REDUCER should set the right state on" DO_REQUEST "1`] =`
Object {
"data": Array [],
"error": "",
"isLoading": true,
}
`
import reduce from './reducer'
describe ('REDUCER', () => {
it ('should set the right state on "DO_REQUEST"', () => {
const newState = reducer(undefined, {type: 'DO_REQUEST'})
// The `toMatchSnapshot` matcher does not receive any parameters
// In the next section we will see why
expect (newState).toMatchSnapshot()
})
})
import reduce from './reducer'
// Use `describe` to group similar tests
describe ('REDUCER', () => {
// The `it` blocks represent one test and although they can
// have several expects it is recommended that you only have one
// or that at least all the expects blocks are related, as in this case.
it ('should set the right state on "DO_REQUEST"', () => {
const newState = reducer(undefined, {type: 'DO_REQUEST'})
expect (newState.error).toBe('')
import {render, simulate} from 'test-library-for-react'
import Component from './Component'
describe ('my obscure test', () => {
// This test does not add any value even though it passes
// and probably meet the code coverage requirement.
it ('should work', () => {
const component = render(<Component />)
simulate.click(component.find('button'))
// Waaat! No idea what the click was supposed to do

Keybase proof

I hereby claim:

  • I am taverasmisael on github.
  • I am misaeltaveras (https://keybase.io/misaeltaveras) on keybase.
  • I have a public key ASBYtUwwv3wLaV7lElGTfa2SnlqDFOM_ch9nV1KTmerymgo

To claim this, I am signing this object:

@taverasmisael
taverasmisael / reset.css
Created March 20, 2019 21:43
A complete yet basic but powerful CSS reset by Zell
/*
*
* Made a gist from amazing article by Zell
* @url: https://zellwk.com/blog/css-reset/
*
*/
html {
box-sizing: border-box;
@taverasmisael
taverasmisael / keybindings.json
Created December 27, 2018 04:16
Custom VS Code Keybindings
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+cmd+alt+shift+s",
"command": "editor.saveAll"
},
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},