Skip to content

Instantly share code, notes, and snippets.

View jgcmarins's full-sized avatar

João Marins jgcmarins

View GitHub Profile
@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.

@jgcmarins
jgcmarins / Write My Code For Me: Cheating at Developer Experience.md
Created April 4, 2019 19:48 — forked from swyxio/Write My Code For Me: Cheating at Developer Experience.md
some thoughts on adding templating/scaffolding to CLIs and how it can be done well

Write My Code For Me: Cheating at Developer Experience

this is a draft of a blogpost that i'll be posting somewhere. Feedback welcome! also feel free to ping me on twitter

I've recently been working on some CLI that involves printing out a bunch of boilerplate template code for developer convenience. I found that there were a few interesting DX angles to this and figured I should write down the rough problem areas and the stances I chose. Most of us are familiar with CLIs like https://yeoman.io/, this task is variously called "scaffolding" or "templating" or some such similar term, with varying degrees of intelligence in the task. I'll refer to it as "templating" in this essay.

Part 1: Should You?

Caramel, not just Sugar

@jgcmarins
jgcmarins / build.gradle
Last active June 5, 2019 03:20 — forked from rozPierog/build.gradle
Automated AAR build, move to folder and deJetify. Just add this to to end of your build.gradle file and run `prepareAAR` task
def manifest = new XmlSlurper().parse(file("./src/main/AndroidManifest.xml"))
def packageName = manifest.@package.text()
task copyAAR(type: Copy) {
from "$projectDir/build/outputs/aar/"
include 'android.aar'
into "$projectDir/AAR/"
rename 'android.aar', "${packageName}.aar"
doLast {
@jgcmarins
jgcmarins / react-native-upgrade.md
Last active February 17, 2021 14:19 — forked from julioxavierr/react-native-update.md
Steps to Upgrade a React Native App

React Native Upgrade Path

  1. Change React and React Native versions in package.json
  2. Run yarn install to upgrade dependencies
  3. Run yarn outdated or yarn upgrade-interactive to upgrade outdated libraries. Make sure that there's no breaking changes, check release notes (one by one).
  4. Compare your changes with the diff or use the upgrade-helper and update the native code.
  5. Open Xcode and link the binaries
  6. Run iOS
  7. Test iOS
  8. Run on Android
  9. Test Android
@jgcmarins
jgcmarins / Environment.tsx
Created November 15, 2019 17:18 — forked from AugustoCalaca/Environment.tsx
New logger event-based relay
import {
Environment,
Network,
RecordSource,
Store,
} from 'relay-runtime';
import { RelayTransactionLogger } from './RelayTransactionLogger';
// Define a function that fetches the results of an operation (query/mutation/etc)
import { useNavigationParam } from 'react-navigation-hooks';
import { graphql, usePreloadedQuery } from 'react-relay/hooks';
const query = graphql`
query TaskDetailQuery($nodeId: ID!) {
task: node(id: $nodeId) {
... on Task {
title
}
}
@jgcmarins
jgcmarins / KeyboardSpacer.tsx
Created December 13, 2019 14:28 — forked from satya164/KeyboardSpacer.tsx
Spacer component to handle keyboard show and hide
import * as React from 'react';
import { Animated, Keyboard, KeyboardEvent, Platform } from 'react-native';
type Props = {
offset?: number;
};
type State = {
keyboardHeightAnim: Animated.Value;
};
@jgcmarins
jgcmarins / Homepage.tsx
Created December 31, 2019 01:21 — forked from AndrewIngram/Homepage.tsx
Next.js serverless dynamic routing with centralised routes
// src/pages/Homepage.tsx
import React from "react";
export default function Homepage() {
return <div>Homepage/div>;
}
@jgcmarins
jgcmarins / webpack.config.js
Created February 5, 2020 17:21 — forked from sibelius/webpack.config.js
current webpack config
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const dotEnv = require('dotenv-webpack');
const HappyPack = require('happypack');
const Serve = require('webpack-plugin-serve');
const workboxPlugin = require('workbox-webpack-plugin');
const PORT = process.env.PORT;
@jgcmarins
jgcmarins / batchCursor.ts
Created February 11, 2020 15:14 — forked from sibelius/batchCursor.ts
Mongo cursor processing - let you select a strategy of how to process elements of a Cursor so you can iterate through all items
/*
* Usage
* let cursor = Test.find().sort({ name: 1 }).cursor();
const get = makeGen(cursor, 100);
let first100 = await get.next();
console.log(first100.value.length);
https://gist.github.com/lineus/3f7d826a21796129db968d6590c93faa
*/
export async function* batchCursor(c, n) {
const cursor = c;