- Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
- pathname - The "file/directory" portion of the URL, like
invoices/123
- search - The stuff after
?
in a URL like/assignments?showGrades=1
. - query - A parsed version of search, usually an object but not a standard browser feature.
- hash - The
#
portion of the URL. This is not available to servers inrequest.url
so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things. - state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
- pathname - The "file/directory" portion of the URL, like
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { persist, PersistOptions } from "zustand/middleware" | |
import { StateCreator, StoreApi, StoreMutatorIdentifier } from "zustand/vanilla" | |
type DeferredPersistOptions<S extends object> = PersistOptions<S> & { | |
hydrateOnResolve?: Promise<void> | |
} | |
const DEFAULT_GET_STORAGE = () => localStorage | |
export default function deferredPersist< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git_current_branch () { | |
local ref | |
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) | |
local ret=$? | |
if [[ $ret != 0 ]] | |
then | |
[[ $ret == 128 ]] && return | |
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return | |
fi | |
echo ${ref#refs/heads/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {useCallback, useEffect, useReducer, useRef} = require('react'); | |
let effectCapture = null; | |
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) { | |
let updateCounter = useRef(0); | |
let wrappedReducer = useCallback(function(oldWrappedState, action) { | |
effectCapture = []; | |
try { | |
let newState = reducer(oldWrappedState.state, action.action); |
Set which editor git should use.
This is the program that will open during a commit
with no -m
flag, a merge, a rebase, etc...
Select from any installed editor. Examples:
- emacs:
emacs
- vi:
vi
orvim
Many people struggle with this question. Some just try to make as much as a full-time employee makes (and ignore that they won't be able to bill as many days). Others follow tips on startup related websites that suggest to ask for 20% to 50% more than an salary would yield (and ignore the additional risk and expenses they have).
Below you will find some numbers to help you calculate how high your hourly or daily rate should be.
- You take more risk than full time employees, phases without income are likely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for send function to select input | |
function dispatch(target, eventType, char) { | |
var evt = document.createEvent("TextEvent"); | |
evt.initTextEvent (eventType, true, true, window, char, 0, "en-US"); | |
target.focus(); | |
target.dispatchEvent(evt); | |
} | |
// enters input and clicks button | |
function send(msg){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: | |
// string.format({key: replacement}) | |
// | |
// example: | |
// 'Hello {name}, how are you doing? I am doing {mood}.'.format({name: 'Mike', mood: 'fine'}); | |
String.prototype.format = function() { | |
var formatted = this; | |
if (arguments.length && typeof arguments[0] == 'object') { | |
var vars = arguments[0]; | |
for (v in vars) { |