Skip to content

Instantly share code, notes, and snippets.

View gabrielsaints's full-sized avatar
:octocat:

Gabriel Santos gabrielsaints

:octocat:
View GitHub Profile
git_current_branch () {
local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]
then
[[ $ret == 128 ]] && return
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
@gabrielsaints
gabrielsaints / .eslintrc.json
Created March 11, 2020 15:44
eslint for react - typescript
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "react", "prettier", "babel"],
"extends": [
"airbnb/hooks",
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
@gabrielsaints
gabrielsaints / app.ts
Last active March 5, 2020 15:57
ts-api credentials
import Server from "express";
import bodyParser from "body-parser";
import cors from "cors";
import http, { HttpBase } from "http";
import https from "https";
import { readFileSync } from "fs";
import errors from "./middlewares/error";
import dotenv from "dotenv";
import { readFileSync } from "fs";
const compareKeys = (sample: object, config: object) => {
const configKeys = Object.keys(config);
return Object.keys(sample).every(key => configKeys.includes(key));
};
const loadEnv = () => {
const buffer = readFileSync(".env.example");
#include <iostream>
#include <cstdlib>
using namespace std;
int hanoi(int n)
{
if(n == 1)
return 1;
type CallbackRunnerType = (startDate?: Date) => void | Promise<void>;
export default class Runner {
private milliseconds: number;
private exit: boolean;
constructor(milliseconds: number) {
this.milliseconds = milliseconds;
this.exit = false;
}
interface GeoLocalizer {
latitude: number;
longitude: number;
}
interface DistanceCalculator {
from: GeoLocalizer;
to: GeoLocalizer;
}
@gabrielsaints
gabrielsaints / docker-compose.yml
Created February 17, 2020 14:49
Create a mongodb container with initial data using file named by import.js
version: "3"
services:
db_mongodb:
image: mongo
container_name: ze-delivery
ports:
- "27017:${MONGO_PORT}"
volumes:
- ./__data__:/data/db
@gabrielsaints
gabrielsaints / keybinds.json
Created January 10, 2020 13:52
Visual Studio Code keybinds JSON configs
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+shift+alt+f5",
"command": "workbench.action.debug.run",
"when": "!inDebugMode"
},
{
"key": "ctrl+f5",
"command": "-workbench.action.debug.run",
@gabrielsaints
gabrielsaints / Evento.js
Created October 25, 2019 11:26
Classe que deve ser extendida, afim de criar metodos de eventos.
class Evento {
constructor(eventos = []) {
// eslint-disable-next-line no-return-assign
eventos.forEach(evento => (this[evento] = []));
this.eventos = eventos;
}
addEventListener(nome, evento) {
console.log(`%c addEventListener ${nome} `, 'background: #17a2b8; color: #0c0c0c');