Stash current changes
- git > Stash > Stash (Include Untracked)
Create stash as patch
git stash show "stash@{0}" -p > changes.patchApply patch
| import merge from "lodash/merge" | |
| import * as z from "zod" | |
| const recursiveError = (arr: Array<string | number>, lastError: string[] | object): any => { | |
| if (!arr || arr.length === 0) { | |
| return lastError | |
| } | |
| const [currPath, ...iss] = arr | |
| let newErr | |
| if (typeof currPath === "string") { |
| const highlight = (fuseSearchResult: any, highlightClassName: string = 'highlight') => { | |
| const set = (obj: object, path: string, value: any) => { | |
| const pathValue = path.split('.'); | |
| let i; | |
| for (i = 0; i < pathValue.length - 1; i++) { | |
| obj = obj[pathValue[i]]; | |
| } | |
| obj[pathValue[i]] = value; |
| import React from 'react'; | |
| import PropTypes from 'prop-types'; | |
| import moment from 'moment'; | |
| import { connect } from 'react-redux'; | |
| import * as actions from 'actions/cards'; | |
| import { activateCardStep1Validate, activateCardStep2Validate } from 'utils/validate'; | |
| import { API_BIRTHDATE_FORMAT } from 'utils/constants'; | |
| import Modal, { ModalContent } from 'components/Modal'; | |
| import Wizard from 'components/Wizard'; |
Short (72 chars or less) summary
More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).
Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
| Iteration(s): 0 | |
| ================================== | |
| Object.create: 0 | |
| Object.setPrototypeOf: 0 | |
| Iteration(s): 1 | |
| ================================== | |
| Object.create: 0 | |
| Object.setPrototypeOf: 0.04 |
| # force HTTPS and www. | |
| RewriteEngine On | |
| RewriteCond %{HTTP_HOST} (?!^www\.)^(.+)$ [OR] | |
| RewriteCond %{HTTPS} off | |
| RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L] | |
| # alternative way | |
| RewriteCond %{HTTP_HOST} !^$ | |
| RewriteCond %{HTTP_HOST} !^www\. [NC] |
| var a = 123, b = 'hello'; | |
| function test(x, y) { | |
| console.log(this); | |
| return a + x + b + y; | |
| } | |
| // Serialize a function *with its captured environment* | |
| var sf = serialize(test, { a: a, b: b }); | |
| // Deserialize with captured environment |