Skip to content

Instantly share code, notes, and snippets.

View victorcrbt's full-sized avatar
🏠
Staying home!

Victor Batalha victorcrbt

🏠
Staying home!
View GitHub Profile
@victorcrbt
victorcrbt / Client.ts
Last active September 27, 2024 19:33
TypeORM ManyToMany relation with custom pivot table and column names.
import { Entity, PrimaryGeneratedColumn, Column, ManyToMany, JoinTable } from 'typeorm';
import Company from './Company';
@Entity('clients')
export default class Client {
@PrimaryGeneratedColumn()
id: number;
@Column()
@victorcrbt
victorcrbt / .gitlab-ci.yml
Created May 4, 2020 13:50
Increase GitLab CI PostgreSQL service max connections
test:
services:
- name: postgres:latest
alias: postgres
command:
- --max_connections=200
@victorcrbt
victorcrbt / function.sql
Last active May 1, 2020 17:17
Conditional PosgreSQL not null column based on value of another table.
CREATE OR REPLACE FUNCTION checkClientType(int) RETURNS varchar as $$
DECLARE
type varchar;
BEGIN
SELECT client_type INTO type FROM clients WHERE id = $1;
RETURN type;
END;
$$ LANGUAGE plpgsql;
@victorcrbt
victorcrbt / table.sql
Last active May 1, 2020 17:18
Conditional PostgreSQL not null column.
CREATE TABLE clients (
id SERIAL UNIQUE,
name varchar(255) NOT NULL,
client_type client_type NOT NULL,
cpf varchar(11),
cnpj varchar(14),
CHECK(CASE WHEN client_type = 'F' THEN cpf IS NOT NULL END),
CHECK(CASE WHEN client_type = 'J' THEN cnpj IS NOT NULL END)
);
@victorcrbt
victorcrbt / jest.config.js
Created April 8, 2020 17:03
Jest with TypeScript aliases
module.exports = {
globals: {
'ts-jest': {
compiler: 'ttypescript',
},
},
bail: 1,
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: ['./src/app/**/*.(ts|js)', './src/lib/Mail.ts'],
@victorcrbt
victorcrbt / App.tsx
Created February 19, 2020 17:57
Root Import Finalizado
import React from 'react';
import './App.css';
import User from '~/components/User';
function App() {
return (
<User />
);
}
@victorcrbt
victorcrbt / .eslintrc.js
Created February 19, 2020 17:52
eslintrc Root Import TypeScript
module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'airbnb',
'plugin:import/typescript',
@victorcrbt
victorcrbt / paths.json
Last active February 19, 2020 17:38
tsconfig for Root Import
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"~/*": ["*"],
"#redux/*": ["store/modules/*"]
}
}
}
@victorcrbt
victorcrbt / config-overrides.js
Last active February 19, 2020 17:30
Config Overrides for Root Import
const { override, addBabelPlugin } = require('customize-cra');
// Exportamos a função 'override' para sobreescrever algumas funcionalidades do webpack
module.exports = override(
// Utilizamos a função 'addBabelPlugin' para adicionar um novo plugin
addBabelPlugin([
// Informamos o nome do plugin na primeira posição do array
'babel-plugin-root-import',
// E as configurações na segunda posição
{
@victorcrbt
victorcrbt / .eslintrc.js
Last active February 19, 2020 17:04
Root import on React with TypeScript
module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'airbnb',
'plugin:import/typescript',