Skip to content

Instantly share code, notes, and snippets.

View alexmachina's full-sized avatar

Alex Alonso alexmachina

  • São Paulo, Brazil
View GitHub Profile
import { parseTime } from "./functions";
type IAction = {
type: string;
payload?: ITimerState;
};
const reducer = (state: ITimerState, action: IAction): ITimerState => {
switch (action.type) {
case "decrement":
@alexmachina
alexmachina / commons.d.ts
Created October 9, 2020 12:54
Timer type declarations
declare interface ITimerState {
initialTime: string;
time: string;
status: string;
ms: number;
}
declare interface ITimer extends ITimerState {
play: () => void;
pause: () => void;
@alexmachina
alexmachina / qs-record.js
Created October 2, 2020 20:41
Voa Evandrão
const querystring = require("querystring");
const arr = [
"fl=97f301",
"h=www.cloudflare.com",
"ip=2804:14c:191:9689:915a:cdf3:3cfb:cd64",
"ts=1601670488.57",
"visit_scheme=https",
"uag=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/53…ML, like Gecko) Chrome/85.0.4183.83 Safari/537.36",
"colo=GRU",
"http=http/2",
@alexmachina
alexmachina / typesampling.ts
Last active January 30, 2020 12:28
Ajuda nois
type Acquirer = {
id?: string;
name: string;
internalCode: string;
}
// QUERO DEFINIR QUE O PARAMETRO overrides É UM SUBSET DE PROPRIEDADES DO TIPO Acquirer.
// NÃO QUERO DEIXAR TUDO OPCIONAL NO tipo Acquirer
const insertFakeAcquirer = (overrides: Acquirer) => {
const fakeAcquirer = {
{
"editor.formatOnType": true,
"workbench.startupEditor": "newUntitledFile",
"workbench.useExperimentalGridLayout": true,
"editor.formatOnSave": false,
"eslint.autoFixOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
"window.zoomLevel": 0,
const fs = require("fs");
const {
cond,
T,
equals,
always,
omit,
evolve,
merge,
compose,
const bemmer = Bemmer('gdp-notifications');
<div className={bemmer('.root')}> // gdp-notifications__root
<i className={bemmer('bell-icon')} /> //gdp-notifications__root__bell-icon
<span className={bemmer('some-label') /> // gdp-notifications__root__some-label
<div className={bemmer('.cards')}> // gdp-notifications__root__cards
<button className={bemmer(('bell-icon') />} /> //gdp-notifications__root__cards__bell-icon
<span className={bemmer('time-elapsed')} /> //gdp-notifications__root__cards__time-elapsed
</div>
</div>
@alexmachina
alexmachina / csv.js
Created February 12, 2019 18:55
CSV reading with nodejs
const fs = require('fs');
function fromCSVFile (path) {
// helper funcs
const removeEmpty = a => a.length !== 0
const removeLeading = a => a !== '';
const euQuero = str => Boolean({
'mundo': true,
'regional': true,
}[str]);