Skip to content

Instantly share code, notes, and snippets.

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

Stan SARR StanSarr

🏠
Working from home
View GitHub Profile
@StanSarr
StanSarr / instagramLike.js
Last active July 1, 2020 12:52
Script for my sis to like all insta items
const Myselector = $;
function wait() {
return new Promise((res, _) => {
setTimeout(() => res(), 5000);
});
}
function getElements() {
const button = Myselector('span.fr66n button.wpO6b');
const color = Myselector('span.fr66n .wpO6b svg').getAttribute('fill');
@StanSarr
StanSarr / react-redux-firebase-firestore-example.tsx
Created March 8, 2020 17:59
Example on how to use useFirestoreConnect
import React from 'react';
import { useFirestoreConnect } from 'react-redux-firebase';
import { Table } from 'antd';
import { useSelector } from 'react-redux';
const columns = [
{
title: 'Name',
dataIndex: 'clientName',
width: '25%',
},
@StanSarr
StanSarr / .eslintrc
Created July 27, 2019 16:49 — forked from 1natsu172/.eslintrc
My airbnb based ESLint config for "typescript-eslint" with React & prettier
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": "."
},
"env": {
"browser": true,
"jest/globals": true
},
@StanSarr
StanSarr / flatten_citrusbyte.js
Created March 5, 2019 00:35
flat array of integers of a given nested array
const flatten = param => {
// check if param exist
if (param) {
//check if param is an array
if (Array.isArray(param)) {
/**
* acc: Accumulator with empty array as initial value
* currentValue: is the current value of the iteration
*/
// set initial value to []
@StanSarr
StanSarr / action.js
Created November 13, 2018 01:13
Redux action creation w/ payload
// @flow
/* eslint-disable no-unused-vars,no-redeclare,flowtype/no-weak-types */
// type $ExtractReturnType<R, F: (...any[]) => R> = R;
// type $ReturnType<F> = $ExtractReturnType<*, F>;
type $ReturnType<F> = $Call<<Args, R>((...Args) => R) => R, F>;
export type $ActionType<ActionCreator> = $ReturnType<ActionCreator>;
// TODO remove this when flow infer well
// @flow
import * as React from 'react';
import { StyleSheet } from 'react-native';
import { Input, Item, Label } from 'native-base';
/**
* Style
*/
const Style = StyleSheet.create({
@StanSarr
StanSarr / jsoncodec.js
Created November 13, 2018 01:07
Json codec middleware
// @flow
/* eslint-disable flowtype/no-weak-types */
import { type Fetch, type Request, type Response } from '../fetch';
export type JSONValue = any;
export type JSONRequest = {|
cache?: $PropertyType<Request, 'cache'>,
credentials?: $PropertyType<Request, 'credentials'>,
data: JSONValue,
@StanSarr
StanSarr / fetch.js
Created November 13, 2018 01:06
fetch with middleware compose
// @flow
/* eslint-disable flowtype/no-weak-types */
/**
* Types
*/
type AsyncFunction<Param, Return> = (param: Param) => Promise<Return>;
type CacheType = 'default' | 'no-store' | 'reload' | 'no-cache' | 'force-cache' | 'only-if-cached';
type CredentialsType = 'omit' | 'same-origin' | 'include';
type ModeType = 'cors' | 'no-cors' | 'same-origin';
@StanSarr
StanSarr / authorization.js
Created November 13, 2018 01:00
Authorisation middleware
// @flow
/*eslint-disable */
import { type Fetch } from '../fetch';
export type Token = string;
/**
* Authorization middleware configuration :
* - format: a function that takes a token and returns a [header, value] tuple
* - token: string or function or async function that returns the token
@StanSarr
StanSarr / userInfo.js
Created November 6, 2018 10:39
create our own hook
import { useState, useEffect } from "react";
import * as API from "../api";
export const useUserInfo = userId => {
const [user, setUser] = useState(false);
useEffect(() => {
const response = API.userInfo(userId);
setUser(response);
});
return user;
};