Skip to content

Instantly share code, notes, and snippets.

View david-arteaga's full-sized avatar

David Arteaga david-arteaga

View GitHub Profile
@david-arteaga
david-arteaga / typescript.json
Created January 11, 2020 21:34
[Typescript VS Code snippets]
{
// Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@david-arteaga
david-arteaga / graphql.json
Created January 11, 2020 21:32
[Graphql VS Code snippets]
{
// Place your snippets for graphql here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@david-arteaga
david-arteaga / Fix.md
Last active August 28, 2019 15:48
[JSON cannot serialize cyclic structures error] #react-native #graphql #error #refetch

This error usually happens when you use the refetch function in a TouchableOpacity like this: <TouchableOpacity onPress={refetch} ... />.

The error happens because the onPress attribute of TouchableOpacity gets passed in a param, that graphql tries to use as variables but can't, since it is a cyclic structure.

Fix it by doing the following: refetch()} ... /&gt;

@david-arteaga
david-arteaga / instructions.md
Created April 14, 2019 16:57
[IntelliJ - add generated sources so IDE recognizes them]
  1. Right click on the folder
  2. Mark Directory as
  3. Generated Sources Root

If you are using gradle and the idea plugin, you can add the folder in the sources configuration in the build.gradle file and IntelliJ will pick it up too.

@david-arteaga
david-arteaga / 1. README.md
Last active March 29, 2019 16:41
Dataloader helpers for apollo server

This is a set of functions that could be used as helpers for the Dataloader (https://github.com/graphql/dataloader). The helpers are designed to handle two cases:

  1. Batching fetches when each key corresponds to a single value (think userId -> User)
  2. Batching fetches when each key corresponds to multiple values (think userId -> userPosts)

One item per key

For the first case, there is the mapKey function.

It wraps the batch loading function to make sure it always returns an array the same length as the keys array and with items in the same order as the keys.

@david-arteaga
david-arteaga / docker-compose-postgres.yml
Created March 22, 2019 13:17
[Postgres docker-compose]
version: '3.3'
services:
followme-postgres:
# image: postgres:10.7-alpine # just postgres
image: mdillon/postgis:10-alpine # with postgis
restart: always
environment:
POTSGRES_PASSWORD: postgres
POSTGRES_USER: postgres
@david-arteaga
david-arteaga / InitialNnavigator.ts
Created February 18, 2019 19:41
[React navigation modal disable gestures] #reactnative #reactnavigation
const InitialNavigator = createStackNavigator(
{
Login: LoginScreen,
Registration: {
screen: RegistrationScreen,
navigationOptions: { gesturesEnabled: false },
},
RecoverPassword: {
screen: RecoverPasswordScreen,
navigationOptions: { gesturesEnabled: false },
@david-arteaga
david-arteaga / solution.md
Last active February 17, 2019 16:07
[[!] [Xcodeproj] Generated duplicate UUIDs:] #reactnative #cocoapods #dependencies
{
// Place your snippets for typescript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",