Skip to content

Instantly share code, notes, and snippets.

View rthomazel's full-sized avatar
:octocat:
hi

R Thomazella rthomazel

:octocat:
hi
View GitHub Profile
@rthomazel
rthomazel / machine.js
Last active January 19, 2021 00:25
state machine
const someMachine = Machine({
id: "actionPlan",
initial: "view",
type: "parallel",
context: {
goals: [],
canEditCarePlan: false,
canEditActionPlan: false,
draftGoal: {},
},
@rthomazel
rthomazel / c4p-draft.md
Created August 5, 2020 04:24
rconf 2020 c4p

Assunto: Palestrante 2020

Raphael "Tom" Thomazella

Florianópolis - Santa Catarina

Fullstack Javascript Engineer - Freelancer

Tema: State Machines (24 👍 nos temas 2020)

@rthomazel
rthomazel / image-upload
Created July 29, 2020 05:32
image upload
foo
@rthomazel
rthomazel / owasp-notes.md
Last active July 17, 2020 07:32
security notes

SQL injection, injection in general

happens when user provided data is poorly or not validated at all. happens when the client is manipulated to send unexpected params to the backend. backend must avoid at all cost to use data in db requests or other operations if needed, data should be filtered and validated on the server side, better yet parametrized, or at the bare minimum, escaped properly

headers and env vars are possible vectors of attack

@rthomazel
rthomazel / typescripting-twitter-snippets-part1.ts
Last active July 13, 2020 20:54
Typescripting Twitter snippets part 1
/*************************************************************
* https://twitter.com/marcelcruz/status/1282005231065341953 *
*************************************************************/
/**
* original js
*/
const capitalize = ([firstLetter, ...rest]) => {
return firstLetter.toUpperCase() + rest.join('')
}
@rthomazel
rthomazel / dicas-mei-ir.js
Created June 29, 2020 17:34
Dicas para mei com imposto de renda
const totalYear = /* total de ganhos no ano */;
const SERVICES_TAX_ASSUMPTION = 0.32;
const EXEMPT_AMOUNT = 28.559.70 /* valor para 2020 */;
const nonTaxable = totalYear * SERVICES_TAX_ASSUMPTION;
const taxableByPj = totalYear - nonTaxable;
const shouldSubmitIR = taxableByPj > EXEMPT_AMOUNT;
console.log({ shouldSubmitIR, taxableByPj, nonTaxable, totalYear });
/**
https://www.msn.com/pt-br/dinheiro/other/mei-precisa-declarar-imposto-de-renda/ar-BB10w1xg
@rthomazel
rthomazel / ts-repl.ts
Last active July 8, 2020 19:05
Awesome Typescript REPL
import decache from 'decache'
import { watch, FSWatcher } from 'fs'
import REPL from 'repl'
type ReloadConfig = { newline?: boolean }
type JSObject<Value = any> = Record<string, Value>
const AUTO_RELOAD = true
/**
* path to the modules you'll be developing and reloading.
real vs dolar 2020
https://twitter.com/thom_is_coding/status/1253373908650205185
@rthomazel
rthomazel / async-await-react-native-3.js
Last active April 20, 2020 18:41
async-await react-native 3
/**
* react-native
* React.FC
* loading state used for UI feedback only
* async handle attached to button with 3 awaits
* apollo mutation
* promisified calls
*/
const EmailConfirmation: React.FC<Props> = ({ navigation, dispatch, ...props }) => {
const [loading, setLoading] = useState(false)
@rthomazel
rthomazel / gist:e84632fa2f5affb6111f8457779a14b7
Last active April 20, 2020 18:15
async-await react-native 2
/**
* react-native project
*/
class HeartButton extends Component<Props, State> {
handlePress = async e => {
const { data } = await apolloMutation1({
variables
})
navigation.navigate('ChatScreen', { conversationId: data.conversation.id })