Skip to content

Instantly share code, notes, and snippets.

View diogojhony's full-sized avatar
:octocat:
Ready for launch

Diogo Jhony diogojhony

:octocat:
Ready for launch
View GitHub Profile
@diogojhony
diogojhony / ErrorBoundary.tsx
Created July 5, 2023 18:38
React ErrorBoundary with TypeScript
import React, { ErrorInfo, ReactNode } from 'react';
type Props = {
children?: ReactNode;
};
type State = {
hasError: boolean;
};
import User from '../models/User';
class UserController {
async index(req, res) {
const users = User.findAll();
return res.json(users);
}
async show(req, res) {
@diogojhony
diogojhony / ordering_test.md
Created October 3, 2019 20:56
Ordering test execution in JavaScript
•
├── index.test.js
├── test1.js
├── test2.js
└── test3.js
// index.test.js
@diogojhony
diogojhony / terminal-git-branch-name.md
Last active August 24, 2019 15:24
Add Git Branch Name to Terminal Prompt (Mac) Raw

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@diogojhony
diogojhony / git_config.md
Last active August 24, 2019 13:19
Basic config of git in macOS terminal

enable colors for all git commands:

git config --global color.ui true

@diogojhony
diogojhony / .vimrc
Created August 24, 2019 13:14
Turn on VI syntax highlighting in Mac OS X
set nocompatible
syntax on
body {
background-color: #282c34;
white-space: pre;
font-family: monospace;
color: #abb2bf;
}
.property {
color: #e06c75;
font-weight: bold;
@diogojhony
diogojhony / notification.md
Last active April 18, 2019 11:38
Utilizando Notification do browser
if (!('Notification' in window)) {
    console.log('Esse browser não suporta notificações desktop');
} else if (Notification.permission === 'granted') {
    const notification = new Notification('Título', {
        body: 'Conteúdo da notificação',
    });    
} else if (Notification.permission !== 'denied') {
    // pede permição ao usuário para utilizar a Notificação Desktop
 await Notification.requestPermission();
@diogojhony
diogojhony / Uninstall-pkg.md
Created July 20, 2018 02:45 — forked from githubutilities/Uninstall-pkg.md
Uninstall pkg manually in OS X

Mac Uninstall pkg Manually

  • using pkgutil
# list all your installed packages
pkgutil --pkgs

# show your package info
pkgutil --pkg-info 
@diogojhony
diogojhony / install-git-completion.sh
Last active February 17, 2018 15:40 — forked from johngibb/install-git-completion.sh
Mac OS X - Install Git Completion
URL="https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash"
PROFILE="$HOME/.bash_profile"
echo "Downloading git-completion..."
if ! curl "$URL" --silent --output "$HOME/.git-completion.bash"; then
echo "ERROR: Couldn't download completion script. Make sure you have a working internet connection." && exit 1
fi