Snippets are one of my favorite parts of programming. The shear endless depth of command line tricks and customizations is so exciting! Here is a collection I maintain for myself to comeback to.

Also navigable by list of snippet types here.


uploadable ffmpeg screen casts -- 11.01.2020 %

I prefer tools like https://asciinema.org/ when I want to show terminal tricks and cli tools I build, but sometimes you need to show something that breaks out of the terminal. In this case I record a .mov screen cast using quicktime then do several transformations using ffmpeg to get a small uploaded web friendly .webm file.

  1. cut down the video if need be
$ ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 cut.mp4
  1. scale down the .mov file to something more web friendly
$ ffmpeg -i vim_dic.mov -filter:v scale=512:-1 -c:a copy vim_dic_small.mov
  1. convert the .mov to .webm
$ ffmpeg -i vim_dic_small.mov -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis vim_dic.webm

If you don’t have ffmpeg is available via brew

source:

\- [ ffmpeg, media ]

vim dictionary lookup command -- 11.01.2020 %

As I author all my blog posts, including this text, as markdown documents with vim sometime I come across a word I’d like to lookup. Today I’ve added a vim command to do just this.

snippet from .vimrc or .nvimrc

function! LookUpDef(word)
    silent !clear
    execute "!open https://www.wordnik.com/words/" . a:word
endfunction
command! -nargs=* Dic call LookUpDef(<f-args>)

Then an example vim workflow

  1. navigating to word, ex “faucet”, then yank inner word with yiw

  2. open command prompt enter command :Dic

  3. then paste yanked txt into command prompt with <C-R>"

:Dic faucet
  1. press enter and watch default browser pop up with the word searched via wordnik.com

screen recording

\- [ vim, search ]

configure more gitlab runners -- 11.01.2020 %

$ docker run --rm -t -i -v /home/travis/runner:/etc/gitlab-runner --name gitlab-runner-hypert-web gitlab/gitlab-runner register

Gitlab’s ci pipelines are superpowerful and not hard to setup but you do have to get runners going. For me running gitlab in out of a docker container this is how I add runners to a new project

source:

gitlab docs

\- [ gitlab, docker ]

who last edited a file -- 11.01.2020 %

$ git log -1 -- alice/alice/public/themes/core/views/layouts/src/css/main.scss

Sometimes you just need to know how to blame

source:

git docs

\- [ git ]

search git logs with grep -- 11.01.2020 %

$ git log --grep=NUTS-5288 --since=3.month

Have I already made commits for this Jira ticket?

source:

gitster blog

\- [ git, search ]

revert an entire feature branch -- 11.01.2020 %

$ git revert -m 1 59e36575c691a05d33d34f403f5a831891df61b2

Yeah that whole feature was just a bad idea…

source:

git docs

\- [ git ]

i need a file off my server but i don't want to set up ftp -- 11.01.2020 %

$ scp -i ~/.ssh/privkey travis@199.199.19.199:/home/travis/example.txt ./

Yeah sometimes you just need to move files around. Any server you have ssh access to you can use that same key to send files over ssh.

source:

man page

\- [ scp ]

find that lost folder -- 11.01.2020 %

$ find . -name php-e\*

Where the hell did that /php-extras folder go that I donloaded for my emacs?? On there you are! also ag -g ‘php-e’ would work if you want to stick with silver searcher

source:

man page

\- [ find, search ]

better git add -- 11.01.2020 %

$ git add -p

I tend to use magit in emacs to stange and unstage files/hunks but in a pinch -p or git add -i + selecting patch works great. You can choose exactly which hunks you want to stage leading to cleaner incrimental commits. The bonus to using magit is you can easily edit the file during the process.

source:

git docs

\- [ git ]

move branch -- 11.01.2020 %

$ git rebase source-commit --onto target-branch

Sometimes you need to start a new feature branch but the place you need to base the branch is not ready yet, say coworker has merged his changes to a stage branch but not master. With this work flow you simply start your branch off stage then move to master later. git branch -m new-name also comes in handy to rename the branch after you’ve moved it if need be.

source:

makandracards

w3docs

\- [ git ]