Skip to content

Instantly share code, notes, and snippets.

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

Rodolfo Silva RodolfoSilva

🏠
Working from home
View GitHub Profile
@brentjanderson
brentjanderson / README.md
Created June 14, 2022 15:53
Elixir runtime-controlled supervision tree using feature flags (circuit breaker)

These snippets provide a foundation for starting and stopping supervision trees at runtime using feature flags (e.g. Launch Darkly).

Some things to note when adapting these snippets:

  1. application.ex needs to be adapted into an existing application. The important part is that each child spec provided is compliant, and that there is a feature flag (ld_key) specified.
  2. As written, if a feature flag fails for some reason, it defaults to starting all children. There is room for adaptation here as needed.
  3. This implementation will still require a FeatureFlags module to be available that implements is_on?/2. Adjust as needed to accomodate your own feature flag setup.
@fdaciuk
fdaciuk / Live Node.js + TS com Programação Funcional.md
Last active November 23, 2023 14:29
Live Node.js + TS com Programação Funcional
@trungvose
trungvose / nx-structure-angular-nestjs.md
Last active December 16, 2023 21:41
Nx workspace structure for NestJS and Angular

Nx

https://nx.dev/

Nx is a suite of powerful, extensible dev tools to help you architect, test, and build at any scale — integrating seamlessly with modern technologies and libraries while providing a robust CLI, caching, dependency management, and more.

It has first-class support for many frontend and backend technologies, so its documentation comes in multiple flavours.

Principles

@baumandm
baumandm / Chakra-UI x React-datepicker.md
Last active March 4, 2023 20:56
Chakra-UI x React-datepicker

⚠️ I'd recommend using this fork by @igoro00 which has better theme support.


Tiny wrapper component for React-Datepicker to stylistically fit with Chakra-UI 1.x.

<DatePicker selectedDate={myDate} onChange={(d) => console.log(d)} />
@joshsalverda
joshsalverda / useFieldArray.js
Last active May 22, 2023 09:49
Custom useFieldArray hook for formik using immutability-helper
import {useCallback, useRef, useEffect} from 'react'
import {useField, useFormikContext} from 'formik'
import update from 'immutability-helper'
const useFieldArray = props => {
const [field, meta] = useField(props)
const fieldArray = useRef(field.value)
const {setFieldValue} = useFormikContext()
useEffect(() => {
@andre-bahia
andre-bahia / CurrencyPtBrInputFormatter.dart
Last active December 5, 2023 18:13
Flutter TextInputFormatter Currency pt_BR
import 'package:flutter/services.dart';
import 'package:intl/intl.dart';
class CurrencyPtBrInputFormatter extends TextInputFormatter {
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
if(newValue.selection.baseOffset == 0){
return newValue;
}
@bvaughn
bvaughn / LICENSE.md
Last active November 9, 2023 07:13
Advanced example for manually managing subscriptions in an async-safe way using hooks

The MIT License (MIT)

Copyright © <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

create or replace function add_on_update_trigger
(schema_name text, table_name text, column_name text)
returns void AS $body$
declare
target_table text =
quote_ident(schema_name) || '.' || quote_ident(table_name);
trig_name text =
quote_ident(
'update_' || schema_name || '_' || table_name || '_' || column_name
);
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Font
:set guifont=Source\ Code\ Pro:h14
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Hide pointless junk at the bottom, doesn't work in .vimrc for some reason?
:set laststatus=0
:set noshowmode "don't show --INSERT--
:set noruler "don't show line numbers/column/% junk
@beginor
beginor / snowflake-id.sql
Last active March 18, 2024 13:16
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;