Skip to content

Instantly share code, notes, and snippets.

View vit0rr's full-sized avatar

vitor vit0rr

View GitHub Profile
@wojteklu
wojteklu / clean_code.md
Last active July 8, 2024 21:46
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@sibelius
sibelius / FormUseFormik.tsx
Last active April 13, 2023 20:09
Example showing how to useFormik and FormikProvider
type Props = {
};
const FormUseFormik = (props: Props) => {
const { enqueueSnackbar } = useSnackbar();
const onSubmit = (values) => {
enqueueSnackbar(`submit: ${JSON.stringify(values)}`, {
preventDuplicate: true,
persist: false,
});
@jsjain
jsjain / isEqual.js
Last active February 14, 2024 16:17
basic native implementation for isEqual lodash
const isEqual = (first: any, second: any): boolean => {
if (first === second) {
return true;
}
if ((first === undefined || second === undefined || first === null || second === null)
&& (first || second)) {
return false;
}
const firstType = first?.constructor.name;
const secondType = second?.constructor.name;
@IanColdwater
IanColdwater / twittermute.txt
Last active July 2, 2024 02:25
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@jgcmarins
jgcmarins / babel.config.js
Created April 24, 2020 23:37
Webpack configs for Node.js backends to run both locally and on AWS Lambda
module.exports = {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
type NatModule<Nat> = {
zero: Nat;
one: Nat;
add: (x: Nat, y: Nat) => Nat;
};
const NatModule = <A>(cb: <Nat>(Nat: NatModule<Nat>) => A) => {
const zero = 0;
const one = 1;
@onlime
onlime / .eslintrc.js
Last active May 7, 2024 08:54
ESLint/Prettier config for Vue 3 in VS Code
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
'prettier'
// based on https://github.com/vit0rr/jogo-da-adivinhacao
//extern crate rand;
//use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn read_guess() -> u32 {
return loop {
let mut guess = String::new();
@Grubba27
Grubba27 / fizzbuzz.ts
Created April 20, 2022 01:13
FizzBuzz made in typelevel
type Reverse<A> =
`${A}` extends `${infer AH}${infer AT}`
? `${Reverse<AT>}${AH}` : A
type Digs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
type DigsNext<I = Digs, R = {}> =
I extends [infer Head, infer Next, ...infer Tail]
@Grubba27
Grubba27 / calculator.ts
Created May 5, 2022 21:10
Simple calculator made in ts
type Reverse<A> =
`${A}` extends `${infer AH}${infer AT}`
? `${Reverse<AT>}${AH}` : A
type Digs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
type DigsNext<I = Digs, R = {}> =
I extends [infer Head, infer Next, ...infer Tail]
? DigsNext<[Next, ...Tail], R & Record<Head, Next>>
: { [K in keyof R]: R[K] }