Skip to content

Instantly share code, notes, and snippets.

@DamonOehlman
Last active November 6, 2022 09:34
Show Gist options
  • Save DamonOehlman/f0aa2ab08379231c18fb85cec8999f0f to your computer and use it in GitHub Desktop.
Save DamonOehlman/f0aa2ab08379231c18fb85cec8999f0f to your computer and use it in GitHub Desktop.

Revisions

  1. DamonOehlman revised this gist Jul 30, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions AWESOME-ONE-LINERS.md
    Original file line number Diff line number Diff line change
    @@ -162,6 +162,8 @@ git diff --name-only master | sed -E 's:packages/([A-Za-z0-9_\-]+)\/.*:\1:' | un

    ### imagemagick

    Convert a series of images into an MPEG file:

    ```
    MAGICK_THREAD_LIMIT=2 MAGICK_MEMORY_LIMIT=2G convert -delay 5 -quality 100 *.JPG out.mpeg
    ```
  2. DamonOehlman revised this gist Jul 30, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions AWESOME-ONE-LINERS.md
    Original file line number Diff line number Diff line change
    @@ -158,4 +158,10 @@ Compiling the yarn workspaces that have changed since master:

    ```
    git diff --name-only master | sed -E 's:packages/([A-Za-z0-9_\-]+)\/.*:\1:' | uniq | xargs -I {} yarn workspace {} compile
    ```

    ### imagemagick

    ```
    MAGICK_THREAD_LIMIT=2 MAGICK_MEMORY_LIMIT=2G convert -delay 5 -quality 100 *.JPG out.mpeg
    ```
  3. DamonOehlman revised this gist Jul 30, 2021. 2 changed files with 160 additions and 161 deletions.
    161 changes: 0 additions & 161 deletions ONE-LINERS.md → AWESOME-ONE-LINERS.md
    Original file line number Diff line number Diff line change
    @@ -74,167 +74,6 @@ Find the commits I have made on the current branch:
    git log --author='Damon Oehlman' --format='%H %s'
    ```

    ## git log formatting help

    The format:<string> format allows you to specify which information you want to
    show. It works a little bit like printf format, with the notable exception that
    you get a newline with %n instead of \n.

    E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n" would show
    something like this:

    The author of fe6e0ee was Junio C Hamano, 23 hours ago
    The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<

    The placeholders are:

    o %H: commit hash

    o %h: abbreviated commit hash

    o %T: tree hash

    o %t: abbreviated tree hash

    o %P: parent hashes

    o %p: abbreviated parent hashes

    o %an: author name

    o %P: parent hashes

    o %p: abbreviated parent hashes

    o %an: author name

    o %aN: author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))

    o %ae: author email

    o %aE: author email (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))

    o %ad: author date (format respects --date= option)

    o %aD: author date, RFC2822 style

    o %ar: author date, relative

    o %at: author date, UNIX timestamp

    o %ai: author date, ISO 8601-like format

    o %aI: author date, strict ISO 8601 format

    o %cn: committer name

    o %cN: committer name (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))

    o %ce: committer email

    o %cE: committer email (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))

    o %cd: committer date (format respects --date= option)

    o %cD: committer date, RFC2822 style

    o %cr: committer date, relative

    o %ct: committer date, UNIX timestamp

    o %ci: committer date, ISO 8601-like format

    o %cI: committer date, strict ISO 8601 format

    o %d: ref names, like the --decorate option of git-log(1)

    o %D: ref names without the " (", ")" wrapping.

    o %e: encoding

    o %s: subject

    o %f: sanitized subject line, suitable for a filename

    o %b: body

    o %B: raw body (unwrapped subject and body)

    o %N: commit notes

    o %GG: raw verification message from GPG for a signed commit

    o %G?: show "G" for a Good signature, "B" for a Bad signature, "U" for a
    good, untrusted signature and "N" for no signature

    o %GS: show the name of the signer for a signed commit

    o %GK: show the key used to sign a signed commit

    o %gD: reflog selector, e.g., refs/stash@{1}

    o %gd: shortened reflog selector, e.g., stash@{1}

    o %gn: reflog identity name

    o %gN: reflog identity name (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))

    o %ge: reflog identity email

    o %gE: reflog identity email (respecting .mailmap, see git-shortlog(1) or
    git-blame(1))

    o %gs: reflog subject

    o %Cred: switch color to red

    o %Cgreen: switch color to green

    o %Cblue: switch color to blue

    o %Creset: reset color

    o %C(...): color specification, as described in color.branch.* config option;
    adding auto, at the beginning will emit color only when colors are enabled
    for log output (by color.diff, color.ui, or --color, and respecting the
    auto settings of the former if we are going to a terminal). auto alone
    (i.e. %C(auto)) will turn on auto coloring on the next placeholders until
    the color is switched again.

    o %m: left, right or boundary mark

    o %n: newline

    o %%: a raw %

    o %x00: print a byte from a hex code

    o %w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w option of git-
    shortlog(1).

    o %<(<N>[,trunc|ltrunc|mtrunc]): make the next placeholder take at least N
    columns, padding spaces on the right if necessary. Optionally truncate at
    the beginning (ltrunc), the middle (mtrunc) or the end (trunc) if the
    output is longer than N columns. Note that truncating only works correctly
    with N >= 2.

    o %<|(<N>): make the next placeholder take at least until Nth columns,
    padding spaces on the right if necessary

    o %>(<N>), %>|(<N>): similar to %<(<N>), %<|(<N>) respectively, but padding
    spaces on the left

    o %>>(<N>), %>>|(<N>): similar to %>(<N>), %>|(<N>) respectively, except that
    if the next placeholder takes more spaces than given and there are spaces
    on its left, use those spaces

    o %><(<N>), %><|(<N>): similar to % <(<N>), %<|(<N>) respectively, but
    padding both sides (i.e. the text is centered)

    ### shell

    Find CRLF files in a directory.
    160 changes: 160 additions & 0 deletions GIT-LOG-FORMATTING.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,160 @@
    The format:<string> format allows you to specify which information you want to
    show. It works a little bit like printf format, with the notable exception that
    you get a newline with %n instead of \n.

    E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n" would show
    something like this:

    The author of fe6e0ee was Junio C Hamano, 23 hours ago
    The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<

    The placeholders are:

    ```
    o %H: commit hash
    o %h: abbreviated commit hash
    o %T: tree hash
    o %t: abbreviated tree hash
    o %P: parent hashes
    o %p: abbreviated parent hashes
    o %an: author name
    o %P: parent hashes
    o %p: abbreviated parent hashes
    o %an: author name
    o %aN: author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
    o %ae: author email
    o %aE: author email (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))
    o %ad: author date (format respects --date= option)
    o %aD: author date, RFC2822 style
    o %ar: author date, relative
    o %at: author date, UNIX timestamp
    o %ai: author date, ISO 8601-like format
    o %aI: author date, strict ISO 8601 format
    o %cn: committer name
    o %cN: committer name (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))
    o %ce: committer email
    o %cE: committer email (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))
    o %cd: committer date (format respects --date= option)
    o %cD: committer date, RFC2822 style
    o %cr: committer date, relative
    o %ct: committer date, UNIX timestamp
    o %ci: committer date, ISO 8601-like format
    o %cI: committer date, strict ISO 8601 format
    o %d: ref names, like the --decorate option of git-log(1)
    o %D: ref names without the " (", ")" wrapping.
    o %e: encoding
    o %s: subject
    o %f: sanitized subject line, suitable for a filename
    o %b: body
    o %B: raw body (unwrapped subject and body)
    o %N: commit notes
    o %GG: raw verification message from GPG for a signed commit
    o %G?: show "G" for a Good signature, "B" for a Bad signature, "U" for a
    good, untrusted signature and "N" for no signature
    o %GS: show the name of the signer for a signed commit
    o %GK: show the key used to sign a signed commit
    o %gD: reflog selector, e.g., refs/stash@{1}
    o %gd: shortened reflog selector, e.g., stash@{1}
    o %gn: reflog identity name
    o %gN: reflog identity name (respecting .mailmap, see git-shortlog(1) or git-
    blame(1))
    o %ge: reflog identity email
    o %gE: reflog identity email (respecting .mailmap, see git-shortlog(1) or
    git-blame(1))
    o %gs: reflog subject
    o %Cred: switch color to red
    o %Cgreen: switch color to green
    o %Cblue: switch color to blue
    o %Creset: reset color
    o %C(...): color specification, as described in color.branch.* config option;
    adding auto, at the beginning will emit color only when colors are enabled
    for log output (by color.diff, color.ui, or --color, and respecting the
    auto settings of the former if we are going to a terminal). auto alone
    (i.e. %C(auto)) will turn on auto coloring on the next placeholders until
    the color is switched again.
    o %m: left, right or boundary mark
    o %n: newline
    o %%: a raw %
    o %x00: print a byte from a hex code
    o %w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w option of git-
    shortlog(1).
    o %<(<N>[,trunc|ltrunc|mtrunc]): make the next placeholder take at least N
    columns, padding spaces on the right if necessary. Optionally truncate at
    the beginning (ltrunc), the middle (mtrunc) or the end (trunc) if the
    output is longer than N columns. Note that truncating only works correctly
    with N >= 2.
    o %<|(<N>): make the next placeholder take at least until Nth columns,
    padding spaces on the right if necessary
    o %>(<N>), %>|(<N>): similar to %<(<N>), %<|(<N>) respectively, but padding
    spaces on the left
    o %>>(<N>), %>>|(<N>): similar to %>(<N>), %>|(<N>) respectively, except that
    if the next placeholder takes more spaces than given and there are spaces
    on its left, use those spaces
    o %><(<N>), %><|(<N>): similar to % <(<N>), %<|(<N>) respectively, but
    padding both sides (i.e. the text is centered)
    ```
  4. DamonOehlman revised this gist Jul 30, 2021. 1 changed file with 30 additions and 0 deletions.
    30 changes: 30 additions & 0 deletions ONE-LINERS.md
    Original file line number Diff line number Diff line change
    @@ -255,12 +255,42 @@ Using the command above, you may find that some `.d.ts` file have slipped in (no
    git diff --name-only | grep -E "\.d.ts$" | xargs git checkout --
    ```

    ### jq

    Getting all the resolved paths from an `npm-shrinkwrap.json` file:

    ```
    jq ".. | objects | select(.resolved) | { resolved: .resolved }" < npm-shrinkwrap.json
    ```

    General black magic for finding the most recent versions of a packages when something like `yarn outdated` won't work (can't generate lock file for instance):

    ```
    jq ".dependencies | keys | @tsv" -r < package.json | xargs -I "{}" -d '\t' yarn info --silent --json {} | jq "[.data.name, .data.version]"
    ```

    Downloading all the files referenced in the npm-shrinkwrap file:

    ```
    jq -r ".. | objects | select(.resolved) | .resolved" < /path/to/npm-shrinkwrap.json | grep -e "^http" | xargs -L1 -P50 wget -nc --no-verbose
    ```

    Apparently achievable with the following also:

    ```
    grep resolved < /path/to/npm-shrinkwrap.json | grep -E '\"https?' | cut -d\" -f4 | xargs -L1 -P50 wget -nc --no-verbose
    ```

    Get some useful info out of the github pull requests API:

    ```
    curl -s -X GET \
    -H "Accept: application/vnd.github.cerberus-preview" \
    -H "Authorization: token f333fdf73f1316116981f5b2394505aabdff3ca5" \
    "https://api.github.com/repos/canva/canva/issues?labels=bugathon&state=all&sort=updated&direction=desc&base=master&per_page=250" \
    | jq '.[] | { title: .title, user: .user.login, state: .state, assignees: [ .assignees[] | .login ], closed_at: .closed_at }'
    ```

    ### docker

    Run the interactive command prompt on a particular container:
  5. DamonOehlman revised this gist Jul 30, 2021. 5 changed files with 0 additions and 0 deletions.
    Empty file removed docker.md
    Empty file.
    Empty file removed elm.md
    Empty file.
    Empty file removed git.md
    Empty file.
    Empty file removed shell.md
    Empty file.
    Empty file removed yarn.md
    Empty file.
  6. DamonOehlman revised this gist Jul 30, 2021. 5 changed files with 0 additions and 0 deletions.
    Empty file added docker.md
    Empty file.
    Empty file added elm.md
    Empty file.
    Empty file added git.md
    Empty file.
    Empty file added shell.md
    Empty file.
    Empty file added yarn.md
    Empty file.
  7. DamonOehlman revised this gist Jul 30, 2021. 5 changed files with 61 additions and 56 deletions.
    62 changes: 61 additions & 1 deletion git.md → ONE-LINERS.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    A collection of useful commands for dealing with various systems.

    ### git

    List all (local) branches and report date and sort in descending order:

    ```
    @@ -229,4 +233,60 @@ git log --author='Damon Oehlman' --format='%H %s'
    on its left, use those spaces

    o %><(<N>), %><|(<N>): similar to % <(<N>), %<|(<N>) respectively, but
    padding both sides (i.e. the text is centered)
    padding both sides (i.e. the text is centered)

    ### shell

    Find CRLF files in a directory.

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    ```

    Find all files matching a particular pattern and exec a command on each of them. In the example below we are looking for all `.ts` and `.tsx` files and running [prettier](https://github.com/prettier/prettier) over them in place.

    ```
    find <path> -regextype posix-extended -regex ".*\.tsx?$" -exec $(yarn bin)/prettier --write {} \;
    ```

    Using the command above, you may find that some `.d.ts` file have slipped in (no way around this AFAIK due to not being able to negative look behind in the regex), so you will want to unstage those:

    ```
    git diff --name-only | grep -E "\.d.ts$" | xargs git checkout --
    ```

    General black magic for finding the most recent versions of a packages when something like `yarn outdated` won't work (can't generate lock file for instance):

    ```
    jq ".dependencies | keys | @tsv" -r < package.json | xargs -I "{}" -d '\t' yarn info --silent --json {} | jq "[.data.name, .data.version]"
    ```

    ### docker

    Run the interactive command prompt on a particular container:

    ```
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin/bash
    ```

    Remove ALL registered containers:

    ```
    docker container ls -a --format="{{.ID}}" | xargs docker container rm
    ```

    Remove ALL images:

    ```
    docker image ls -a --format="{{.ID}}" | xargs docker image rm
    ```

    (you'll need to remove containers that might be attached to the images first)

    ### yarn

    Compiling the yarn workspaces that have changed since master:

    ```
    git diff --name-only master | sed -E 's:packages/([A-Za-z0-9_\-]+)\/.*:\1:' | uniq | xargs -I {} yarn workspace {} compile
    ```
    19 changes: 0 additions & 19 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +0,0 @@
    Run the interactive command prompt on a particular container:

    ```
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin/bash
    ```

    Remove ALL registered containers:

    ```
    docker container ls -a --format="{{.ID}}" | xargs docker container rm
    ```

    Remove ALL images:

    ```
    docker image ls -a --format="{{.ID}}" | xargs docker image rm
    ```

    (you'll need to remove containers that might be attached to the images first)
    8 changes: 0 additions & 8 deletions elm.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    I'm sure there's probably a more efficient way to do this, but before CampJS I'm pretty keen to bring down all the elm packages that are available from the elm package repository.

    This seems to do the trick :)

    curl -s http://package.elm-lang.org/all-packages \
    | jq -r ".[].name" \
    | xargs -L 1 -I{} bash -c "[[ ! -d {} ]] && git clone 'git://github.com/{}.git' '{}' || true"
    Requires the use of the excellent jq command-line tool.
    23 changes: 0 additions & 23 deletions shell.md
    Original file line number Diff line number Diff line change
    @@ -1,23 +0,0 @@
    Find CRLF files in a directory.

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    ```

    Find all files matching a particular pattern and exec a command on each of them. In the example below we are looking for all `.ts` and `.tsx` files and running [prettier](https://github.com/prettier/prettier) over them in place.

    ```
    find <path> -regextype posix-extended -regex ".*\.tsx?$" -exec $(yarn bin)/prettier --write {} \;
    ```

    Using the command above, you may find that some `.d.ts` file have slipped in (no way around this AFAIK due to not being able to negative look behind in the regex), so you will want to unstage those:

    ```
    git diff --name-only | grep -E "\.d.ts$" | xargs git checkout --
    ```

    General black magic for finding the most recent versions of a packages when something like `yarn outdated` won't work (can't generate lock file for instance):

    ```
    jq ".dependencies | keys | @tsv" -r < package.json | xargs -I "{}" -d '\t' yarn info --silent --json {} | jq "[.data.name, .data.version]"
    ```
    5 changes: 0 additions & 5 deletions yarn.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    Compiling the yarn workspaces that have changed since master:

    ```
    git diff --name-only master | sed -E 's:packages/([A-Za-z0-9_\-]+)\/.*:\1:' | uniq | xargs -I {} yarn workspace {} compile
    ```
  8. DamonOehlman revised this gist Jun 18, 2020. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions elm.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    I'm sure there's probably a more efficient way to do this, but before CampJS I'm pretty keen to bring down all the elm packages that are available from the elm package repository.

    This seems to do the trick :)

    curl -s http://package.elm-lang.org/all-packages \
    | jq -r ".[].name" \
    | xargs -L 1 -I{} bash -c "[[ ! -d {} ]] && git clone 'git://github.com/{}.git' '{}' || true"
    Requires the use of the excellent jq command-line tool.
  9. DamonOehlman revised this gist Jun 18, 2020. 2 changed files with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -46,6 +46,12 @@ List all local branches that aren't tracked with a remote branch:
    git branch -vv | cut -c 3- | awk '$3 !~/\[/ { print $1 }'
    ```

    Create tags for a list of `release-` branches on remote (note the `-n-2` for how many "active" branches you want to leave):

    ```
    git branch -r | grep release- | head -n-2 | cut -f2 -d'/' | xargs -I '{}' git tag {} origin/{}
    ```

    Move forward in a git history:

    ```
    File renamed without changes.
  10. DamonOehlman revised this gist Sep 18, 2019. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion shell.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,12 @@ find <path> -regextype posix-extended -regex ".*\.tsx?$" -exec $(yarn bin)/pret

    Using the command above, you may find that some `.d.ts` file have slipped in (no way around this AFAIK due to not being able to negative look behind in the regex), so you will want to unstage those:

    ``
    ```
    git diff --name-only | grep -E "\.d.ts$" | xargs git checkout --
    ```

    General black magic for finding the most recent versions of a packages when something like `yarn outdated` won't work (can't generate lock file for instance):

    ```
    jq ".dependencies | keys | @tsv" -r < package.json | xargs -I "{}" -d '\t' yarn info --silent --json {} | jq "[.data.name, .data.version]"
    ```
  11. DamonOehlman revised this gist Jul 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ git status --porcelain=2 | grep -E "^\?{1}" | cut -c3- | xargs rm -rf
    Checking that you haven't "soiled" a local branch with a bad rebase (replace `master` with the base branch as required):

    ```
    git diff --name-only master | xargs git diff origin/$(git status -b | head -n1 | cut -f3 -d' ')
    git diff --name-only $(git merge-base --fork-point master) | xargs git diff origin/$(git status -b | head -n1 | cut -f3 -d' ')
    ```

    Getting a list of commits (in a relatively useful short form) since a branch diverged from `master`:
  12. DamonOehlman revised this gist May 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ayvri.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    Compiling the yarn workspaces that have changed since master:

    ```
    git diff --name-only $(git merge-base --fork-point master) | sed -E 's:packages/([A-Za-z0-9_\-]+)\/.*:\1:' | uniq | xargs -I {} yarn workspace {} compile
    git diff --name-only master | sed -E 's:packages/([A-Za-z0-9_\-]+)\/.*:\1:' | uniq | xargs -I {} yarn workspace {} compile
    ```
  13. DamonOehlman revised this gist May 6, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions ayvri.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Compiling the yarn workspaces that have changed since master:

    ```
    git diff --name-only $(git merge-base --fork-point master) | sed -E 's:packages/([A-Za-z0-9_\-]+)\/.*:\1:' | uniq | xargs -I {} yarn workspace {} compile
    ```
  14. DamonOehlman revised this gist Apr 2, 2019. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    List all (local) branches and report date and sort in descending order:

    ```
    git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
    ```

    Remove all untracked files:

    ```
  15. DamonOehlman revised this gist Feb 15, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Remove all untracked files:

    ```
    git status --porcelain=2 | grep -E "^\?{1}" | cut -c3- | xargs rm
    git status --porcelain=2 | grep -E "^\?{1}" | cut -c3- | xargs rm -rf
    ```

    Checking that you haven't "soiled" a local branch with a bad rebase (replace `master` with the base branch as required):
  16. DamonOehlman revised this gist Dec 19, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions shell.md
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,10 @@ Find all files matching a particular pattern and exec a command on each of them.

    ```
    find <path> -regextype posix-extended -regex ".*\.tsx?$" -exec $(yarn bin)/prettier --write {} \;
    ```

    Using the command above, you may find that some `.d.ts` file have slipped in (no way around this AFAIK due to not being able to negative look behind in the regex), so you will want to unstage those:

    ``
    git diff --name-only | grep -E "\.d.ts$" | xargs git checkout --
    ```
  17. DamonOehlman revised this gist Dec 19, 2018. 2 changed files with 11 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions bash.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    Find CRLF files in a directory.

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    ```
    11 changes: 11 additions & 0 deletions shell.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    Find CRLF files in a directory.

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    ```

    Find all files matching a particular pattern and exec a command on each of them. In the example below we are looking for all `.ts` and `.tsx` files and running [prettier](https://github.com/prettier/prettier) over them in place.

    ```
    find <path> -regextype posix-extended -regex ".*\.tsx?$" -exec $(yarn bin)/prettier --write {} \;
    ```
  18. DamonOehlman revised this gist Dec 10, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    Remove all untracked files:

    ```
    git ls-files --others --exclude-standard | xargs rm
    git status --porcelain=2 | grep -E "^\?{1}" | cut -c3- | xargs rm
    ```

    Checking that you haven't "soiled" a local branch with a bad rebase (replace `master` with the base branch as required):
  19. DamonOehlman revised this gist Dec 7, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    Remove all untracked files:

    ```
    git ls-files --others --exclude-standard | xargs rm
    ```

    Checking that you haven't "soiled" a local branch with a bad rebase (replace `master` with the base branch as required):

    ```
  20. DamonOehlman revised this gist Dec 5, 2018. 3 changed files with 26 additions and 30 deletions.
    5 changes: 5 additions & 0 deletions bash.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Find CRLF files in a directory.

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    ```
    19 changes: 19 additions & 0 deletions docker.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    Run the interactive command prompt on a particular container:

    ```
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin/bash
    ```

    Remove ALL registered containers:

    ```
    docker container ls -a --format="{{.ID}}" | xargs docker container rm
    ```

    Remove ALL images:

    ```
    docker image ls -a --format="{{.ID}}" | xargs docker image rm
    ```

    (you'll need to remove containers that might be attached to the images first)
    32 changes: 2 additions & 30 deletions README.md → git.md
    Original file line number Diff line number Diff line change
    @@ -1,37 +1,9 @@
    # one liners

    ## bash

    Find CRLF files in a directory.
    Checking that you haven't "soiled" a local branch with a bad rebase (replace `master` with the base branch as required):

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    git diff --name-only master | xargs git diff origin/$(git status -b | head -n1 | cut -f3 -d' ')
    ```

    ## docker

    Run the interactive command prompt on a particular container:

    ```
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin/bash
    ```

    Remove ALL registered containers:

    ```
    docker container ls -a --format="{{.ID}}" | xargs docker container rm
    ```

    Remove ALL images:

    ```
    docker image ls -a --format="{{.ID}}" | xargs docker image rm
    ```

    (you'll need to remove containers that might be attached to the images first)

    ## git

    Getting a list of commits (in a relatively useful short form) since a branch diverged from `master`:

    ```
  21. DamonOehlman revised this gist Nov 21, 2018. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,14 @@ Remove ALL registered containers:
    docker container ls -a --format="{{.ID}}" | xargs docker container rm
    ```

    Remove ALL images:

    ```
    docker image ls -a --format="{{.ID}}" | xargs docker image rm
    ```

    (you'll need to remove containers that might be attached to the images first)

    ## git

    Getting a list of commits (in a relatively useful short form) since a branch diverged from `master`:
  22. DamonOehlman revised this gist Nov 21, 2018. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # one liners

    ## `bash`
    ## bash

    Find CRLF files in a directory.

    @@ -16,7 +16,13 @@ Run the interactive command prompt on a particular container:
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin/bash
    ```

    ## `git`
    Remove ALL registered containers:

    ```
    docker container ls -a --format="{{.ID}}" | xargs docker container rm
    ```

    ## git

    Getting a list of commits (in a relatively useful short form) since a branch diverged from `master`:

  23. DamonOehlman revised this gist Nov 21, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -13,8 +13,7 @@ grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    Run the interactive command prompt on a particular container:

    ```
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin
    /bash
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin/bash
    ```

    ## `git`
  24. DamonOehlman revised this gist Nov 21, 2018. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,15 @@ Find CRLF files in a directory.
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    ```

    ## docker

    Run the interactive command prompt on a particular container:

    ```
    docker exec -it $(docker ps --filter "name=mysql*" --format "{{.ID}}") /bin
    /bash
    ```

    ## `git`

    Getting a list of commits (in a relatively useful short form) since a branch diverged from `master`:
  25. DamonOehlman revised this gist Nov 15, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    # one liners

    ## bash
    ## `bash`

    Find CRLF files in a directory.

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git | wc -l
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git
    ```

    ## `git`
  26. DamonOehlman revised this gist Nov 15, 2018. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,14 @@
    ## one liners
    # one liners

    ## bash

    Find CRLF files in a directory.

    ```
    grep -IUlr $'\r' --exclude-dir=node_modules --exclude-dir=.git | wc -l
    ```

    ## `git`

    Getting a list of commits (in a relatively useful short form) since a branch diverged from `master`:

  27. Damon Oehlman revised this gist Jul 19, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Getting a list of commits (in a relatively useful short form) since a branch div
    git log --format="%h %an: %s" $(git merge-base release-name master)..
    ```

    All the modified files on the current branch since forking from master.
    All the modified files on the current branch since forking from master. To see the content of the changes, remove the `--name-only` flag.

    ```
    git diff --name-only $(git merge-base --fork-point master)
  28. Damon Oehlman revised this gist Jul 19, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,12 @@ List all the remote branches for a particular prefix:
    git branch -a --list *damon-* --color=never | cut -c3- | grep -E '^remotes\/.*\/damon-' | cut -f3 -d'/'
    ```

    List all local branches that aren't tracked with a remote branch:

    ```
    git branch -vv | cut -c 3- | awk '$3 !~/\[/ { print $1 }'
    ```

    Move forward in a git history:

    ```
  29. DamonOehlman revised this gist Apr 4, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,12 @@ Getting a list of commits (in a relatively useful short form) since a branch div
    git log --format="%h %an: %s" $(git merge-base release-name master)..
    ```

    All the modified files on the current branch since forking from master.

    ```
    git diff --name-only $(git merge-base --fork-point master)
    ```

    Reset a feature branch to the latest commit on master (after a `git rebase master`):

    ```
  30. DamonOehlman revised this gist Mar 28, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,12 @@ Find all the files that are in the current branch that also exist in an another
    comm -23 <(git diff --name-only master..) <(git diff --name-only damon-user-reactivation-facebook..)
    ```

    Find the commits I have made on the current branch:

    ```
    git log --author='Damon Oehlman' --format='%H %s'
    ```

    ## git log formatting help

    The format:<string> format allows you to specify which information you want to