Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Max Rogério max10rogerio

🎯
Focusing
  • Maringá, Paraná - Brasil
View GitHub Profile
@max10rogerio
max10rogerio / Auth.ts
Created Nov 5, 2019
Problem with Context and directives (Auth)
View Auth.ts
/* eslint-disable no-underscore-dangle */
// This is a example of my|problem
import { SchemaDirectiveVisitor } from 'graphql-tools'
import { GraphQLField, defaultFieldResolver, GraphQLResolveInfo } from 'graphql'
export interface UserToken {
id: number
instituicao?: number
View .releaserc.json
{
"branch": "master",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"releaseRules": [
{
"type": "refactor",
"release": "patch"
@max10rogerio
max10rogerio / fix-node-gyp-vs-2019.ps1
Created Mar 6, 2020
Fix node-gyp visual studio 2019
View fix-node-gyp-vs-2019.ps1
<#
This is a workaround for "node-gyp is unable to find msbuild if VS2019 is installed"
https://github.com/nodejs/node-gyp/issues/1663
It create a shim EXE as "MSBuild\15.0\Bin\MSBuild.exe" to target "MSBuild\Current\Bin\MSBuild.exe"
By noseratio - MIT license - use at your own risk!
It requires admin mode, I use wsudo/wsudox (https://chocolatey.org/packages/wsudo) for that:
wsudo powershell -f make-msbuild-shim.ps1
#>
#Requires -RunAsAdministrator
@max10rogerio
max10rogerio / launch.json
Created Mar 20, 2020
Running nodemon with debug and auto-restart
View launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "nodemon",
// path to nodemon inside your project
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/nodemon",
// script to initialize the server
@max10rogerio
max10rogerio / useMedia.js
Created Mar 26, 2020
Hook to verify size screen by param
View useMedia.js
import { useEffect, useState } from 'react';
/**
* Exemple of sizes:
* mobile: '(min-width: 425px)'
* tablet: '(min-width: 768px)'
* laptop: '(min-width: 1024px)'
* @param {String} size
* @returns {boolean}
*/
View mimes.json
{
"aac": "audio/aac",
"abw": "application/x-abiword",
"arc": "application/x-freearc",
"avi": "video/x-msvideo",
"azw": "application/vnd.amazon.ebook",
"bin": "application/octet-stream",
"bmp": "image/bmp",
"bz": "application/x-bzip",
"bz2": "application/x-bzip2",
@max10rogerio
max10rogerio / clipboard.ts
Last active Jul 13, 2020
Example Copy to Clipboard with Typescript
View clipboard.ts
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
/**
* Interface CopyToClipboard params
*/
interface ICopyToClipboard {
/** HTML reference identifier ```<div id="foo"></div>``` */
target?: string;
/** String value */
value?: string;
@max10rogerio
max10rogerio / columns-to-annotations.sql
Created Jan 21, 2021
Simple map column to annotations typeorm
View columns-to-annotations.sql
SELECT
E'@Column({ name: \'' || column_name || E'\', type: \'' || data_type || E'\'})'
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'yourtable'
AND TABLE_SCHEMA = 'your schema if necessary';
View template-literal-type.ts
interface Example {
first_name: string,
last_name: string,
home_town: string,
}
type CamelizeString<T extends PropertyKey> = T extends string ? string extends T ? string :
T extends `${infer F}_${infer R}` ? `${F}${Capitalize<CamelizeString<R>>}` : T : T;
type Camelize<T> = { [K in keyof T as CamelizeString<K>]: T[K] }
@max10rogerio
max10rogerio / basic-clean-example.ts
Created Mar 24, 2021
Exemplo mostrando em como padronizar a resposta de uma api para camelCase e separar as resposabilidades
View basic-clean-example.ts
interface Api {
post: <R = any, P = any>(params: P) => Promise<R>
}
/*
A api espera user_login, user_password
E response user_name, user_age, user_status
*/
type ApiResponse = {
user_name: string