Skip to content

Instantly share code, notes, and snippets.

@sibelius
sibelius / _usage.tsx
Created July 11, 2019 11:15
NavigationPersistence snippet to save navigation state
<AppRouter
ref={stackNavigatorRef => NavigatorService.setContainer(stackNavigatorRef)}
screenProps={{
t,
theme,
}}
{...getPersistenceFunctions(navigationPersistenceKey)}
/>
@lucianomlima
lucianomlima / adb_connect.sh
Created June 5, 2019 17:57
Connect to Android devices with ADB through wi-fi
function adb_connect {
# PORT used to connect. Default: 5555
PORT=${1:-5555}
# IP address from current device connected
IP_ADDRESS=`adb shell ip route | awk '{print $9}'`
echo "ADB connect to $IP_ADDRESS on port $PORT"
# Change connection from usb to tcpip using $PORT
@srikanthsunkari
srikanthsunkari / [Updated]webpack.config.js
Last active June 26, 2023 12:16
react native web with webpack configuration
// web/webpack.config.js
const path = require('path');
const webpack = require('webpack');
const appDirectory = path.resolve(__dirname, '../');
// This is needed for webpack to compile JavaScript.
// Many OSS React Native packages are not compiled to ES5 before being
// published. If you depend on uncompiled packages they may cause webpack build
@sibelius
sibelius / metro.config.js
Created May 7, 2019 14:38
Metro config that works well with monorepo
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
const path = require('path');
const { FileStore } = require('metro-cache');
@sibelius
sibelius / authenticatedMidldeware.tsx
Created February 15, 2019 12:16
Auth middleware to use with RR4
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import { isLoggedIn } from '../../security/authentication';
import routeTo from '../utils/routeTo';
const authenticatedMiddleware = Component => {
class AuthenticatedMiddleware extends React.PureComponent {
componentDidMount() {
this.redirectIfNotAuthenticated();
@melloc01
melloc01 / cloudSettings
Last active September 24, 2021 14:43
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-12-19T18:25:14.965Z","extensionVersion":"v3.2.4"}
@elijahmanor
elijahmanor / index-0-non-debounced.js
Last active December 20, 2022 21:14
React Debouncing Events
import React, { Component } from "react";
import { render } from "react-dom";
import "./index.css";
class Widget extends Component {
state = { text: "" };
handleChange = (e) => {
this.setState({ text: e.target.value });
};
render() {
@hagemann
hagemann / slugify.js
Last active October 30, 2023 09:10
Slugify makes a string URI-friendly
function slugify(string) {
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
const p = new RegExp(a.split('').join('|'), 'g')
return string.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
.replace(/&/g, '-and-') // Replace & with 'and'
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 19, 2024 23:35
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example