Skip to content

Instantly share code, notes, and snippets.

View mauriciord's full-sized avatar

Maurício R Duarte mauriciord

View GitHub Profile
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@mauriciord
mauriciord / gh-pages-deploy.md
Last active May 29, 2017 19:45 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the public directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@mauriciord
mauriciord / .eslintrc
Created February 28, 2018 14:12 — forked from radiovisual/.eslintrc
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
@mauriciord
mauriciord / comment.md
Created November 7, 2019 14:41 — forked from staltz/comment.md
Nested Pick<T, K> in TypeScript 2.2

TypeScript supports Pick to allow you to get a "subset" object type of a given type, but there is no built-in Pick for deeper nested fields.

If you have a function that takes a large object as argument, but you don't use all of its fields, you can use Pick, Pick2, Pick3, etc to narrow down the input type to be only just what you need. This will make it easier to test your function, because when mocking the input object, you don't need to pass all fields of the "large" object.

@mauriciord
mauriciord / useExpoResources.js
Created February 27, 2020 13:03 — forked from julioxavierr/useExpoResources.js
React hook to abstract loading resources from expo and showing splash screen until completion
import { useEffect, useState } from 'react';
import * as Font from 'expo-font';
import { SplashScreen } from 'expo';
/**
* Load and use resources that need to be loaded async by Expo SDK
*/
const useExpoResources = () => {
const [isLoading, setIsLoading] = useState(true);
@mauriciord
mauriciord / _middleware.ts
Created January 24, 2024 17:08 — forked from f1729/_middleware.ts
Add password protection to any Vercel website, save $150/month.
import { addYears } from 'date-fns'
import { NextRequest, NextResponse } from 'next/server'
function middleware(req: NextRequest) {
if (req.nextUrl.pathname.startsWith('/api')) {
return NextResponse.next()
}
if (process.env.VERCEL_ENV !== 'preview') {
return NextResponse.next()