This instruction helps create multiple ssh keys for local machine to use multiple git remote repositories.
$ ssh-keygen -t rsa -C "your_email1@youremail.com"
$ ssh-keygen -t rsa -C "your_email2@youremail.com"
| <form> | |
| <label>Some label</label> | |
| <input type="number"/> | |
| <label>Some other label</label> | |
| <textarea /> | |
| <MyCustomInput {...someProps} /> | |
| </form> |
| // source: http://doublespringlabs.blogspot.com.br/2012/11/decoding-polylines-from-google-maps.html | |
| function decode(encoded){ | |
| // array that holds the points | |
| var points=[ ] | |
| var index = 0, len = encoded.length; | |
| var lat = 0, lng = 0; | |
| while (index < len) { | |
| var b, shift = 0, result = 0; |
From this answer: https://stackoverflow.com/a/17141512/6307412
git checkout my-branch
git branch -m my-branch-old # this will rename 'my-branch' to 'my-branch-old'
git checkout master
git checkout -b my-branch
git merge --squash my-branch-old
git commit -m "...your message..."
git push origin my-branch --force # add --force to rewrite history on remote if neccessary
| import flowRight from 'lodash.flowright' | |
| import {onErrorRetryHOF} from './onErrorRetryHOF' | |
| import {bypassCacheHOF} from './bypassCacheHOF' | |
| export const myAppFetch = flowRight([ | |
| onErrorRetryHOF, | |
| bypassCacheHOF, | |
| // more higher-order fetch here | |
| ])(fetch) // <--- the original fetch |
| // A higher-order fetch that bypass cache: | |
| export const bypassCacheHOF = (fetch) => (input, init) => { | |
| let bypassCacheUrl | |
| if (input.includes('?') { | |
| bypassCacheUrl = input + '&_v=' + Math.random() | |
| } else { | |
| bypassCacheUrl = input + '?_v=' + Math.random() | |
| } | |
| return fetch(bypassCacheUrl, init) |
| import Rx from "rxjs"; | |
| const MAX_RETRY = 3 | |
| const RETRY_DELAY = 500 | |
| export const onErrorRetryHOF = fetch => (input, init) => { | |
| let count = 0; | |
| return Rx.Observable.defer(() => | |
| Rx.Observable.fromPromise( | |
| fetch(input, init).then(resp => { | |
| if ((resp.status + "").startsWith("5")) throw resp; |
| // this function accepts the same input and returns the same output as window.fetch(), | |
| // plus, it adds a ramdom param into the URL to bypass cache. | |
| const bypassCacheFetch = (input, init) => { | |
| let bypassCacheUrl | |
| if (input.includes('?') { | |
| bypassCacheUrl = input + '&_v=' + Math.random() | |
| } else { | |
| bypassCacheUrl = input + '?_v=' + Math.random() | |
| } | |
Assume you are at a branch, which has 1 commit ahead of master.
You want to send that commit to your friend's machine while the git server is down.
Solution:
git format-patch master --> 0001-mybranch.patch generated.0001-mybranch.patch to your friend, at your friend's machine run git apply 0001-mybranch.patch| import React from "react"; | |
| /** | |
| * Use just as the same as React.useReducer, but state and action are logged to the console. | |
| * Example usage: | |
| * ``` | |
| * const [state, dispatch] = useDebugReducer('MyComponent', reducer, initialState) | |
| * // Console: | |
| * // MyComponent dispatch: {...} | |
| * // \t MyComponent state: {...} |