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
function! GitCheckoutBranch(branch) | |
" branch can look like this: "/remotes/origin/master [hash] info" or this: "master [hash] info" | |
let l:name = split(split(trim(a:branch), "", 1)[0], "/", 1)[-1] | |
" just show what is happening | |
echo "checking out ".l:name."\n" | |
" you can use !git, instead of Git, if you don't have Fugitive | |
execute "Git checkout ".l:name | |
endfunction |
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 { useState, useEffect } from 'react'; | |
// pass a query like `(min-width: 768px)` | |
export function useMatchMedia(query: string) { | |
const [matches, setMatches] = useState(() => matchMedia(query).matches); | |
useEffect(() => { | |
const mediaQueryList = matchMedia(query); | |
const onChange = (event: MediaQueryListEvent) => setMatches(event.matches); |
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
# First, we need to find our device. BEFORE inserting your USB drive, run the | |
# following: | |
diskutil list | |
# This will output a bunch of info about all of the disk drives connected to | |
# your Mac. Each entry will have a header in the form "/dev/diskX", where X is | |
# some number starting at 0. Now, insert your USB drive and run the command | |
# again. You should see a new entry. Make note of the name (ie, /dev/diskX). | |
diskutil list |
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
/* | |
See: http://2ality.com/2017/12/functions-reasonml.html#operators | |
*/ | |
module MapOps { | |
module HashMap = Belt.HashMap.String; | |
let ( @@ ) = (map, key) => { | |
map | |
|> HashMap.get(_, key) | |
|> Belt.Option.getExn |
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
/** | |
* Making promises | |
*/ | |
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok")); | |
/* Simpler promise creation for static values */ | |
Js.Promise.resolve("easy"); | |
Js.Promise.reject(Invalid_argument("too easy")); |
If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.
Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.
If in doubt about what git is doing when you run these commands, just
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
# put this in your .bash_profile | |
pull_request() { | |
to_branch=$1 | |
if [ -z $to_branch ]; then | |
to_branch="master" | |
fi | |
# try the upstream branch if possible, otherwise origin will do | |
upstream=$(git config --get remote.upstream.url) | |
origin=$(git config --get remote.origin.url) |