Skip to content

Instantly share code, notes, and snippets.

View martinusso's full-sized avatar
🏠
Working from home

Breno Martinusso martinusso

🏠
Working from home
View GitHub Profile
@martinusso
martinusso / test.ts
Created April 25, 2024 00:24
tests.ts
jest.mock('statsig-node', () => ({
default: {
initialize: jest.fn(),
checkGate: jest.fn(),
},
}));
// ...
Statsig.checkGate.mockResolvedValue(true);
export const removeAccents = (str): string =>
str.normalize('NFD').replace(/\p{Mn}/gu, '');
export function sanitize(text?: string | undefined): string {
if (!text) return '';
return removeAccents(text.toLocaleLowerCase()).split(' ').join('-');
}
export function parameterize(text?: string | undefined): string {
@martinusso
martinusso / mui.tsx
Created September 18, 2023 19:03
react components
import React from 'react';
import { Box } from '@mui/material';
type ImgProps = {
alt?: string;
src: string;
width: number;
height?: number;
};
@martinusso
martinusso / test.sql
Last active August 14, 2023 20:22
test.sql
with boletos as
(
select
to_char (ii .created_at , 'YYYY-MM' ) as mes ,
--sum(ii .amount ) as valor_total_invoices ,
--count(ii .id ) as quantidade_invoices ,
sum (ii .amount ) filter (where bb.created_at is not null) as valor_total_boletos ,
count(distinct i .account_id ) filter (where bb.created_at is not null) as total_clientes_com_boletos ,
count(bb .id ) filter (where bb .created_at is not null) as quantidade_boletos_emitidos ,
count(bb .id ) filter ( where bb.paid_at is not null) as quantidade_boletos_liquidados ,
@martinusso
martinusso / jsonb_each.sql
Created June 30, 2023 20:18
postgres jsonb
-- {"1": [{"id": 1,"name": "Max"},{"id": 11,"name": "Perez"}],"2": [{"id": 2,"name": "Leclerc"},{"id": 3,"name": "Sainz"}]}
select
j.*
from test,
jsonb_each(metadata) as j
select
jsonb_each(metadata)
@martinusso
martinusso / go.mod
Created February 4, 2022 20:23
loft dojo - bank account
module test-dojo
go 1.16
// A data structure to hold key/value pairs
type Pair struct {
Key string
Value float64
}
// A slice of pairs that implements sort.Interface to sort by values
type PairList []Pair
@martinusso
martinusso / mac.md
Created June 8, 2021 11:32
Postgres

==> postgresql@12 This formula has created a default database cluster with: initdb --locale=C -E UTF-8 /usr/local/var/postgresql@12 For more details, read: https://www.postgresql.org/docs/12/app-initdb.html

postgresql@12 is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula.

If you need to have postgresql@12 first in your PATH, run:

@martinusso
martinusso / date.go
Created April 22, 2021 18:27
Golang playground
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now().UTC()
fmt.Println("UTC")