Skip to content

Instantly share code, notes, and snippets.

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

Kay Gosho acro5piano

🏠
Working from home
View GitHub Profile
@acro5piano
acro5piano / test.tsx
Created April 28, 2021 11:20
react re-render test for children prop
import { memo, useState, useMemo } from 'react'
const MODE = 'memo'
function MiddleRaw({ children }) {
console.log('middle')
return <div>{children}</div>
}
const Middle = memo(MiddleRaw)
@acro5piano
acro5piano / urqlClient.ts
Last active December 4, 2023 13:56
URQL + Firebase authentication
import {
Exchange,
cacheExchange,
createClient,
dedupExchange,
fetchExchange,
subscriptionExchange,
} from 'urql'
import { delay, empty, fromPromise, map, mergeMap, pipe, tap } from 'wonka'
import firebase from 'firebase' // NOTE: This is old Firebase version
@acro5piano
acro5piano / MyComponent.tsx
Last active April 10, 2021 07:29
A react hook to handle keyboard show/hide
const { inputting } = useInputting()
<div style={{ height: inputting ? '50vh' : '100vh' }}>
...
@acro5piano
acro5piano / main.md
Created March 16, 2021 09:13
Many to many relationship + Dataloader

Assuming

users:
  - id 
  - name
post_user:
  - post_id
  - user_id
posts:
@acro5piano
acro5piano / navigations.ts
Created June 12, 2020 09:51
conditionally changes screen gestures in React Navigation
const Screens = {
Home: 'Home',
Settings: 'Settings',
}
const Navigation = createStackNavigator(
{
[Screens['Home']]: Home,
[Screens['Settings']]: Settings,
},
@acro5piano
acro5piano / README.md
Created April 7, 2020 06:30
Get Heroku all env vars
  1. Open https://dashboard.heroku.com/apps/YOUR_APP/settings
  2. Click "Reveal Config Vars"
  3. Open JS console and paste the following code
[...document.getElementsByClassName('config-var-item')]
    .map(e => `${e.getElementsByTagName('input')[0].value}=${e.getElementsByTagName('textarea')[0].value}`)
    .join('\n')
@acro5piano
acro5piano / elixir.js
Last active March 27, 2020 13:14
pattern match in js
// https://elixir-lang.org/getting-started/case-cond-and-if.html#case
function elixir(...conds) {
function arrayEqualsCond(a, b) {
if (a.length !== b.length) {
return false;
}
let eq = true;
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i] && !(b[i] instanceof Matcher)) {
@acro5piano
acro5piano / demo.md
Created November 25, 2019 12:14
Vue.js Image Rotator

image

* What went wrong:
Could not determine the dependencies of task ':app:mergeReleaseAssets'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve io.repro:repro-android-sdk:+.
Required by:
project :app > project :react-native-repro
> Failed to list versions for io.repro:repro-android-sdk.
> Could not list versions using M2 pattern 'https://jitpack.io/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])'.
> Could not get resource 'https://jitpack.io/io/repro/repro-android-sdk/'.
> Could not GET 'https://jitpack.io/io/repro/repro-android-sdk/'. Received status code 522 from server: Origin Connection Time-out