Skip to content

Instantly share code, notes, and snippets.

View jgcmarins's full-sized avatar

João Marins jgcmarins

View GitHub Profile
@jgcmarins
jgcmarins / CONTRIBUTING.md
Created June 7, 2017 12:26
A basic CONTRIBUTING.md

How to contribute

1. fork this repository

2. clone the forked version

git clone git@github.com:<your_username>/<repo_name>.git

3. install dependencies

@jgcmarins
jgcmarins / setState.js
Created June 29, 2017 15:27
When I'm not in redux, I miss logger middleware + actions
const setState = Component.prototype.setState
Component.prototype.setState = function(nextState) {
console.log(this.constructor.name, nextState)
return setState.apply(this, arguments)
}
const AnimatedTextInput = styled(Animated.createAnimatedComponent(RNTextInput))`
backgroundColor: transparent;
color: #000;
height: 48;
marginTop: 20;
paddingHorizontal: 0;
`;
//...
<AnimatedTextInput
@jgcmarins
jgcmarins / UserConnection.js
Created November 3, 2017 02:02
GraphQL UserConnection
// @flow
import { GraphQLInt } from 'graphql';
import { connectionDefinitions } from 'graphql-relay';
import UserType from '../type/user/UserType';
export default connectionDefinitions({
name: 'User',
nodeType: UserType,
connectionFields: () => ({
// @flow
import { nodeDefinitions, fromGlobalId } from 'graphql-relay';
import UserType from '../type/UserType';
const { nodeInterface, nodeField, nodesField } = nodeDefinitions(
// A method that maps from a global id to an object
async (globalId, context, options) => {
const { id, type } = fromGlobalId(globalId);

update & install

$ brew update
$ brew install postgres
import React from 'react';
import { render } from 'react-dom';
import Hello from './Hello';
const styles = {
fontFamily: 'sans-serif',
textAlign: 'center',
};
class AutoDestroy extends React.Component {
type $If<X: boolean, Then, Else = empty> = $Call<
& ((true, Then, Else) => Then)
& ((false, Then, Else) => Else),
X,
Then,
Else,
>;
type $Not<X: boolean> = $If<X, false, true>;
type $And<X: boolean, Y: boolean> = $If<X, Y, false>;
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
# Delete the remote version of the current branch
unpublish = "!git push origin :$(git branch-name)"
# Delete a branch and recreate it from master — useful if you have, say,
# a development branch and a master branch and they could conceivably go
@jgcmarins
jgcmarins / node-npm-install.md
Created July 17, 2018 19:47 — forked from rcugut/node-npm-install.md
Install node & npm on Mac OS X with Homebrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.