• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics with the tag "shell". Back to normal view
    1. How to build a quick and dirty subtitle player

      On my desk I have two screens -- one off to the side for movies, TV, etc and my main in front. Sometimes I find myself wanting subtitles on my main screen. The main issue I've found, at least with...

      On my desk I have two screens -- one off to the side for movies, TV, etc and my main in front. Sometimes I find myself wanting subtitles on my main screen. The main issue I've found, at least with macOS, is that the SRT players suck.

      I figured, why not just generate a tiny black video with embedded subtitles?

      ffmpeg -i subs.srt -t 3:00:00 -s 40x10 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero subs.mpeg
      

      Set the ratio to be super small without being too small. This video is 40px by 10px and the video only takes a few seconds to generate. For me, this generated at ~850x speed.

      From there, jack up the subtitle font size and shift it up a little bit so nothing gets cut off. This also works really well with tiling window managers.

      Screenshot

      11 votes
    2. Typesetting Markdown Blog: What Next?

      Some of you have read the Typesetting Markdown blog series (https://dave.autonoma.ca/blog/). The plan was to finish the last two parts with Annotated Text (basically markup for Markdown) and...

      Some of you have read the Typesetting Markdown blog series (https://dave.autonoma.ca/blog/). The plan was to finish the last two parts with Annotated Text (basically markup for Markdown) and Figure Drawing (MetaPost); however, people have asked for a post on Markdown to EPUB, others have asked for high-quality PDF theme templates using ConTeXt, and some have requested rendering Markdown into HTML.

      Within the realm of Markdown, digital documentation, typesetting with ConTeXt, R, externalized interpolated strings, and bash scripting, what would interest you for the next post in the series?

      (Please flip through the blog series to see the topics that have been covered.)

      3 votes
    3. Challenge: defuse this fork bomb

      On lobste.rs I found link to an article from Vidar Holen, the author of shellcheck. He made a fork bomb that is really interesting. Here's the bomb: DO NOT RUN THIS. eval $(echo...

      On lobste.rs I found link to an article from Vidar Holen, the author of shellcheck. He made a fork bomb that is really interesting. Here's the bomb:

      DO NOT RUN THIS.

      eval $(echo "I<RA('1E<W3t`rYWdl&r()(Y29j&r{,3Rl7Ig}&r{,T31wo});r`26<F]F;==" | uudecode)
      

      This may look pretty obvious, but it's harder than you think. I fell for it. twice. Can you find out how this bomb works?

      Warning: executing the bomb will slow down your computer and will force you to restart.
      You can limit impact of the fork bomb by setting FUNCNEST.

      export FUNCNEST=3
      

      Have fun!

      12 votes
    4. Share your useful shell scripts!

      Disclaimer: Don't run scripts offered to you by randos unless you trust them or review it yourself I use this constantly, it just plays music by file name, specifically matching *NAME* with...

      Disclaimer: Don't run scripts offered to you by randos unless you trust them or review it yourself

      I use this constantly, it just plays music by file name, specifically matching *NAME* with case-insensitivity. Requires bash 4.something.

      # play -ln SONGS ...
      # -l don't shuffle
      # -n dry run
      mpv_args="--no-audio-display --no-resume-playback \
                --msg-level=all=status --term-osd-bar"
      shopt -s globstar nullglob nocaseglob
      
      shuffle=true
      dry=false
      while [[ "$1" == -* ]]; do
          if [[ "$1" == "-l" ]]; then 
              shuffle=false
          elif [[ "$1" == "-n" ]]; then
              dry=true
          fi
      
          shift 1
      done
      
      if [[ "$shuffle" == true ]]; then
          mpv_args="--shuffle $mpv_args"
      fi
      
      songs=()
      while [[ "$#" != 0 ]]; do
          songs+=( ~/music/**/**/*"$1"*.* ) # change this to match your music directory layout
          shift 1                                               # could probably use find instead
      done
      
      if [[ "$dry" == true ]]; then
          if [[ "$shuffle" == true ]]; then
              printf "Shuffle mode is on\n"
          fi
      
          for song in "${songs[@]}"; do
              printf "$song\n"
          done
        
          exit
      fi
      
      if [[ ${#songs[@]} != 0 ]]; then
          mpv $mpv_args "${songs[@]}"
      fi
      

      I make no claims to the quality of this but it works!

      36 votes