Skip to content

Instantly share code, notes, and snippets.

View Grohden's full-sized avatar
:shipit:
*tec tec tec noises*

Gabriel Rohden Grohden

:shipit:
*tec tec tec noises*
View GitHub Profile
@Grohden
Grohden / App.js
Last active May 22, 2019 13:15
React navigation + react hooks problem with callback param
import React from 'react';
import {
createAppContainer,
createStackNavigator
} from 'react-navigation'
import TestScreen, {
testScreenOptions
} from './TestScreen'
const stack = createStackNavigator({
@Grohden
Grohden / Lightbox.tsx
Created June 24, 2019 18:17
Just saving this refactor of the lightbox
import React, {
Children,
cloneElement, FC, useRef, useState
} from 'react'
import {
Animated,
TouchableHighlight,
View,
ViewStyle
} from 'react-native'
@Grohden
Grohden / example-json-model.json
Last active June 28, 2019 15:29
Generate dart deserialization and model classes based on JSON input
{
"pageCount": 1,
"result": [
{
"page_number": 12,
"is_favorite": true,
"cover": {
"width": 40,
"height": 50,
"url": "www.test.com"
@Grohden
Grohden / deep-typename-apollo.ts
Created August 9, 2019 03:06
Fn to put deep __typename based on keys for apollo gql (apollo link rest is too verbose)
/*
* This is micro optimized, you could
* do it without mutability, but I think
* that this is to solve a very specific case (apollo
* requires __typename to be injected)
*/
function addTypeNames(
item: object,
typeNames: object
) {
@Grohden
Grohden / pick-keys-by-type.ts
Created August 9, 2019 03:58
Utility type to pick keys by type
export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
export type PickKeysDeep<T, P = any> = {
[K in keyof T]: T[K] extends object
? P extends Primitive
? PickKeysDeep<T[K], P>
: K | PickKeysDeep<T[K], P>
: P extends Primitive
? P extends T[K]
? K
@Grohden
Grohden / convert-taps.js
Last active September 23, 2019 03:46
After reading the android monkey sources, i came up with this: a way to make a monkey runner "script" by hand
// Let's suppose you have this in adb:
const adbCommands = `input tap 450 450
input tap 740 280
input tap 683 614
input tap 950 411
input tap 1188 248
input tap 915 713
input tap 1176 560
input tap 1428 358
input tap 1149 789
@Grohden
Grohden / BottomNavigator.ts
Last active September 26, 2019 18:33
Solution for react-navigation/stack/issues/237 (stack header animation is buggy on android P due to elevation animations)
import {
BottomRoutes,
NavigationDefinitionMap,
TNavigatorOptions
} from '../../lib/navigation'
import {
createBottomTabNavigator
} from 'react-navigation-tabs'
import RequestListScreen, {
requestListNavigatorOptions
@Grohden
Grohden / Areas.java
Last active September 27, 2019 16:58
example java
public class Areas {
static class Retangulo {
protected int largura;
protected int altura;
Retangulo(int largura, int altura) {
this.largura = largura;
this.altura = altura;
}
@Grohden
Grohden / android-dev-bindings.sh
Last active December 2, 2019 12:01
React native bindings for IDE (jetbrains) keyboard shortcuts
#!/usr/bin/env bash
set -e
# Use this script to bind a keyboard shortcut (I recommend alt+shift+number)
# tools > external tools
# Program: /bin/bash
# # Here is up to you, you can place it on the project or globally
# Arguments .$Projectpath$/scripts/android-dev-bindings.sh reload
# Working directory: $ProjectFileDir$
# Then save/apply/ok and go to keymap > external tools and assign your shortcuts
@Grohden
Grohden / AnimatedMock.js
Created January 30, 2020 22:30
Fixed file for react native AnimatedMock.js
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'use strict';