Live data from Hacker News

Ask HN: Can I see your cheatsheet?

news.ycombinator.com

71–80 of 173 posts

Re: Ask HN: Can I see your cheatsheet?

#71
post #62
post #58

Creating clips from tv recordings: ffmpeg -ss 01:59:00.000 -i "interlaced.ts" -ss 00:00:12.000 -t 26 -max_muxing_queue_size 1024 -c:a libopus -b:a 96k -c:v libx264 -crf 20 -vf "yadif=1" -profile:v baseline -level 3.0 -pix_fmt yuv420p -movflags +faststart -y clip.mp4 Make clip compatible with WhatsApp: ffmpeg -i in.mp4 -map 0:v:0 -map 0:a:0 -map_metadata -1 -map_chapters -1 -c:v libx264 -preset slow -tune film -crf 32…

Most streaming sites break a video into many small fragments, which are listed in a m4mu file. I have a script to download the fragments one by one using curl. To merge the video fragments back into one file, I do the following. Merge video files with ffmpeg - Make a file listing all the videos in sequence. E.g. file 'video01.ts' file 'video02.ts' file 'video03.ts' ... - Generate the file list for files in the curren…

For anyone needing this youtube-dl (and ffmpeg if you need post-dl conversion) can do this for you if it's any easier, point it at the index file and let it do its thing

Re: Ask HN: Can I see your cheatsheet?

#72
post #41

Earlier quoted context omitted.

I'm curious why history | grep and not ctrl-R?

Probably because ctrl-R doesn't present you a list in most shells. Maybe you want to scan the list visually and look at neighboring commands. ctrl-R doesn't really take advantage of human vision by showing all results next to each other.

Agreed on the value of the list. I additionally dedupe as follows:

H() { history | egrep -v '^ *[[:digit:]]+ +H +' | grep "$@" | sort -rk 2 | uniq -f 1 | sort; }

Re: Ask HN: Can I see your cheatsheet?

#73

On a related note: has anyone used a good tool for using/inserting these kinds of custom snippets? It would be neat to have a snippet manager with quick search bound to a keypress.

Honestly I just store them as files (bash scripts if you will), make them executable, chuck ~/scripts into $PATH

Bonus: it's all stored in a git repo

I do kinda live on the command line, ymmv

Re: Ask HN: Can I see your cheatsheet?

#75

Set a huuuuuuuge shell history https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf... then fzf ctrl+r bindings mean you can recall anything right where you need it. If you’re going to do this then have an escape hatch for commands you don’t want memorised https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf...

I‘ve been doing this ever since I migrated from Windows to Mac in 2015. My bash history has over 40k lines, datestamped. I can recall any command I have typed in my terminal in the past seven years. Extremely helpful whenever I need to repeat anything in the terminal.

# Edit

I sometimes add comments to commands via `# This‘ll do this and that` so that I can find the command by those keywords in the bash history.

Re: Ask HN: Can I see your cheatsheet?

#76
post #41

Earlier quoted context omitted.

I'm curious why history | grep and not ctrl-R?

Probably because ctrl-R doesn't present you a list in most shells. Maybe you want to scan the list visually and look at neighboring commands. ctrl-R doesn't really take advantage of human vision by showing all results next to each other.

That's pretty much it. I used to have to use quite a few different shells, so ` + r` wasn't always available, but `history | grep` usually was. Once I'd got in the the habit of using `history | grep` I found that I liked the extra context provided by seeing a group of commands with a few variations between the lines. So often it helps jog my memory of what parameters I'll need to change before using it.

Re: Ask HN: Can I see your cheatsheet?

#77
post #43

- Find all files modified in the last 90 minutes find . -type f -mmin -90 - Find all files and do something to each one find . -type f -mmin -90 | xargs ls -l - Find all files modified before 2 days ago find . -type f -mtime +2 - Removing files older than 7 days find . -type f -mtime +7 -name '*.gz' -exec rm {} \; - Find all files modified after last 2 days find . -type f -mtime -2 - Find all files modified at the la…

With zsh you don't need to use find, fd, or any other external tool.

zsh's built-in globbing features can be used instead.

  - Find all files modified in the last 90 minutes
    print -l **/*(mm-90)
  - Find all files and do something to each one
    print -l **/*(mm-90) | xargs ls -l
  - Find all files modified before 2 days ago
    print -l **/*(m+2)
  - Removing files older than 7 days
    zargs -- **/*(m+7) -- rm
  - Find all files modified after last 2 days
    print -l **/*(m-2)
  - Find all files modified at the last 2 day mark
    print -l **/*(m2)
In most of the above examples "print -l" is used to print the results to the terminal, but you can instead use whatever command you want (as in the "rm" example above).

Many more examples and tips can be seen here: [1]

[1] - http://www.zzapper.co.uk/zshtips.html

Re: Ask HN: Can I see your cheatsheet?

#78
post #75

Set a huuuuuuuge shell history https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf... then fzf ctrl+r bindings mean you can recall anything right where you need it. If you’re going to do this then have an escape hatch for commands you don’t want memorised https://github.com/craigjperry2/dotfiles/blob/aa77ddcbde63bf...

I‘ve been doing this ever since I migrated from Windows to Mac in 2015. My bash history has over 40k lines, datestamped. I can recall any command I have typed in my terminal in the past seven years. Extremely helpful whenever I need to repeat anything in the terminal. # Edit I sometimes add comments to commands via `# This‘ll do this and that` so that I can find the command by those keywords in the bash history.

This. I've been doing this for a couple of years now, I'm really used to it. I've been "traveling" with my history that is over 70k lines. My dot alias file has only 3 aliases (c=clear, q=exit, gti=git).

Hope there's a project out there that helps parse, rank, or do something with a file like this. There must be interesting information.

Re: Ask HN: Can I see your cheatsheet?

#79
post #43

- Find all files modified in the last 90 minutes find . -type f -mmin -90 - Find all files and do something to each one find . -type f -mmin -90 | xargs ls -l - Find all files modified before 2 days ago find . -type f -mtime +2 - Removing files older than 7 days find . -type f -mtime +7 -name '*.gz' -exec rm {} \; - Find all files modified after last 2 days find . -type f -mtime -2 - Find all files modified at the la…

Find all .txt files containing the word 'foo': find ./ -mount -type f -name "*.txt" -exec grep -iHn 'foo' {} \; (the -mount stops it traversing into mounted shares)

With zsh:

  grep -iHn 'foo' **/*.txt(.)
Though I'm not sure how to prevent zsh from descending in to other filesystems, as you can with find.
Post reply on HN