Skip to content

Instantly share code, notes, and snippets.

@mjackson
mjackson / redirects-in-react-router-v6.md
Last active November 12, 2023 07:32
Notes on handling redirects in React Router v6, including a detailed explanation of how this improves on what we used to do in v4/5

Redirects in React Router v6

An important part of "routing" is handling redirects. Redirects usually happen when you want to preserve an old link and send all the traffic bound for that destination to some new URL so you don't end up with broken links.

The way we recommend handling redirects has changed in React Router v6. This document explains why.

Background

In React Router v4/5 (they have the same API, you can read about why we had to bump the major version here) we had a <Redirect> component that you could use to tell the router when to automatically redirect to another URL. You might have used it like this:

@songouyang
songouyang / .yarnrc
Created January 4, 2019 04:32
yarn 使用淘宝国内镜像
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "https://npm.taobao.org/mirrors/phantomjs/"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
registry "https://registry.npm.taobao.org"
registry=https://registry.npm.taobao.org/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
electron_mirror=https://npm.taobao.org/mirrors/electron/
@shrekuu
shrekuu / fixing-locale-error-on-ubuntu-server-14-and-16.sh
Last active July 24, 2021 11:15
fixed: manpath: can't set the locale; make sure $LC_* and $LANG are correct
# I know you've got stuck for too long ^_^Y
# Locale is not configured correct. I don't know what broke that. Maybe time did.
# I fixed it on my ubuntu 14 & 16 servers.
# Follow the steps below or run this script on your machine.
# step 1
# ensure this line in `/etc/default/locale` file and `/etc/environment` file
# LANG="en_US.UTF-8"
sudo echo '\nLANG="en_US.UTF-8"' >> /etc/default/locale && /etc/environment
@coliff
coliff / index.htm
Last active July 31, 2018 15:03
Bootstrap 4 for IE8 and IE9 CSS Polyfill
<!--[if IE 9]>
<link href="https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/css/bootstrap-ie9.min.css" rel="stylesheet">
<![endif]-->
<!--[if lte IE 8]>
<link href="https://cdn.jsdelivr.net/gh/coliff/bootstrap-ie8/css/bootstrap-ie8.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/g/html5shiv@3.7.3"></script>
<![endif]-->
@wuiler
wuiler / paginate.php
Created January 16, 2018 19:17 — forked from vluzrmos/paginate.php
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
##
## How to install mcrypt in php7.2 / php7.3
## Linux / MacOS / OSX
##
## https://lukasmestan.com/install-mcrypt-extension-in-php7-2/
#
@poul-kg
poul-kg / valet.conf
Last active April 30, 2024 14:09
CORS Rules for Laravel Valet Nginx
# To enable CORS you should add lines with CORS rules below to your valet.conf file
# Find the file /usr/local/etc/nginx/valet/valet.conf - this is Valet conf for Nginx
# of try to execute `locate valet.conf` and find the `valet.coinf` in `nginx` subdirectory
# after you edit your valet.conf do not forget to execute `valet restart`
server {
listen 80 default_server;
root /;
charset utf-8;
client_max_body_size 128M;
@andrewstobbe
andrewstobbe / MacOSXSierra:Brew+Apache+Mysql+PHPSwitcher+DNSMasq+SSL.md
Last active July 19, 2021 02:12
Mac OSX Sierra : Brew Apache + Mysql + PHP Switcher + DNSMasq + SSL

Mac OSX Sierra : Brew Apache + Mysql + PHP Switcher + DNSMasq + SSL 👍

Things I had to do using Homebrew to get my local web dev environment back up and running after migration to OSX Sierra + Xcode 8.1.

Note: I used brew reinstall because I had already installed most of this previously under Yosemite. Probably better ways to do this, but this is what worked for me.

brew doctor

brew tap homebrew/dupes
brew tap homebrew/versions
@uorat
uorat / nginx-websocket-proxy.conf
Last active February 11, 2023 16:04
Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;