All posts by JamesIsIn

Sorting Lines in VSCode

Stay tuned for a more elegant version…

copy some lines then

This comes up at the top of searches still so I’ll add this latest solution. If you are running a current VS Code (and why wouldn’t you?) you can use the built-in sorter by hitting ctrl-shift-p (Mac is cmd-shift-p) and type “sort” in the subsequent search box. There are many options.


High Bitrate ISO Music to FLAC

Here is the process I used to convert some DVD-audio ISO files into proper FLAC files for inclusion in my main collection.  No compromise in channels nor in audio quality required.

These instructions are for Ubuntu but will likely work on most Linux distributions (since ffmpeg and flac are so common).  Mac?  Maybe.  Win10 with bash?  Probably.

The basics are as follows:

  • mount the ISO
  • use ffmpeg to extract audio data into wav files
  • stitch multiple wav files together using Audacity
  • split that full-album wav into individual songs
  • convert those wav songs into FLAC files
  • tag and move into the main collection

Often mounting an ISO is a matter of right-clicking and choosing Mount; regardless I leave it up to you to make that happen in whatever manner you choose.  All that matters is that we can access the files through a specific file path.

You will need to fun ffmpeg against each audio file from the mounted ISO in order to get a complete collection of wav files to conjoin.  My most recent ISO had two and this command is for the second extraction:

ffmpeg -i ~/Desktop/ISO/AUDIO_TS/ATS_01_2.AOB ~/Desktop/RW/02_end.wav 
# run this line for each file containing audio and with a unique file name (in order) 

Now open all your files in Audacity (or whatever you’d like) and past each track against the end of the previous track until you have one project containing the entire audio content.  Export that as a single wav file.

Audacity will default to exporting as a two-channel 16×44 wav file.   You can change the bitrate in the lower-left of the project window.  For multi-channel exports, you’ll need to navigate to Edit –> Preferences –> Import/Export –> When exporting tracks to an audio file –> Use custom mix (radio button).  Now you are set to wave the full wave file.

Next you get to struggle with dividing the full file into individual songs.  This can be made all the more challenging if your album is progressive rock.  Who needs gaps between so-called songs?  Anyway, I can not offer much advice though there is this handy page from Audacity that could help.

You can do it!

Converting into FLAC is really easy.  It’s probably the easiest step in the whole process.  (Splitting into individual songs is probably the least easy if you’re keeping track.)

# cd into the folder where your newly created wav files are located and run flac itself 
flac --best --channel-map=none -V *.wav 
# you only need --channel-map=none if your full-length file has more than two tracks  

Once that has finished, you can tag your music.  I use EasyTag because it’s easy.


Password Chaos

Creating a memorable password runs against most of the rules implemented for creating a strong password.  Much fine work has been done parodying this interesting fact.  That being said, the folks who implement the rules and subsequently announce those rules to the users have lost their minds.  Take a look at this description of the required rules I happened upon recently.

Required Overlap
Required Overlap

Let’s pair some of these.


Between 8 and 64 characters

Increase the length from 12-20 characters


Use both uppercase and lowercase letters.

A lowercase or uppercase letter


Not repeat any character more than 3 times in a row.

Not be a sequence of 4 characters in a row.

In each of the above pairs, the first line is all that is required to articulate the apparent rule.  The second line can be dropped as superfluous (and confusing).

In the length pair, the “increase” line is essentially unparsable.  This is to say I can formulate no meaning for that line which aligns that line with the other lines in a logically consistent fashion.  If the minimum is 8 then there would never be a reason to increase by 12.  If you are 20 away from 64 (the maximum) there is no reason to increase the length.

In the case pair, the and and the or cannot be conjoined.  If you must use both (and) then you cannot use one or the other (or).

In the repetition pair, if you cannot have three in a row you necessarily can’t have four in a row.  Further, if the minimum is 8 it must be longer than 4 regardless.

Then there is the order of the list.  Makes me wonder if that order could have been arrayed in a way that would be more confusing.  Could it?

Never mind that five lines are sentences (ending in periods) and the other three lines are not (unpunctuated).

It’s like they took a poll of the IT staff and just listed out selections from their various responses.

Just… think it through a bit.  UI/UX isn’t something that requires a specialized developer.  Think.


Renaming in Python

I needed to rename several files.  I thought perhaps using a script would make it a little faster.  Well, the renaming went faster.  Writing the script of course took much longer.  But I suppose I learned something.

The image files were individual pages from a book of about 64 pages.  They were named one number off from their actual page numbers.  You can imagine how annoying that can be.  You can’t?  Well, try harder.  It’s pretty annoying when 3 isn’t three but 4.  Three isn’t four!

That doesn’t irritate you?  Well, I wrote a script to fix it nonetheless.

You can find the script over at my GitHub.

It’s modifiable enough so perhaps it can suit your needs.  Feedback is always welcome.


Useful bash Line for Debugging

I’ve started using this little code snippet to help debug problems within a bash script. It just shouts out the line where it appears when called. This is useful when you are trying to determine where a problem is located within the various twists and turns of the function calls within a script.

# Here is a print statement useful in debugging:  
printf '%s\n' "" "${LINENO}" "" 
# Pepper a script with those to see where your having trouble line-by-line! 

Have fun with that!


A Couple Recent Conversions for Audio and Video

I’ve had to make a couple of unusual conversion of late and wanted to make note of the solutions for my future self.  Hey, future self, git with it!

First, converting dsf (and I think also dff) files into flac files I just used ffmpeg as follows:

# first cd into the directory containing the dsf files in question, then… 
ffmpeg -i 15-Penny\ Lane.dsf 15-Penny\ Lane.flac 

Then I also needed to convert an ISO into some constituent mkv files. For this I used makemkv.

# first you'll need to install it from the Snap repositories.  
snap install makemkv 
# then open the graphical application and point it at your ISO.

Both pretty handy, easy, and fool-proof. I’m the fool. I’m the proof. Good hunting.


Take Multi-Line User Input and Add that to a Variable in Bash

We are using a construct using xargs and ctrl-d for breaking.  I’m not perfectly satisfied with it, but it certainly does the job of taking multi-line user input and stuffing that into a variable (formatting intact).

(The first and third assignments add quotes around the contents of the xargs input.  You may or may not require that.  In our case the variable is the body of a message sent by mail.  It must be quoted.)

printf '%s\n' "What would you like the body of the message to contain?  " 
printf "\\033[1mWhen finished hit ctrl-d on a new line to proceed.\\033[0m  \\n\\n" 
# this will load the user's input into a variable instead of a file 
reminderBody+=$( xargs -0 ) 

This basic construct could be used for a variety of needs.

(The \033[0m‘s are used to change font colors. Again, optional.)


Go, Speed R-AI-cer!

I’d like to see a competition between autonomous driving vehicles on some sort of track.  Something like an AI-500.  Let’s see what they can do in this kind of situation.  Let’s see what that does for their autonomy.

Probably be best if a variety of manufacturers are participating in the competition.

Must have something like the flag system for signaling to the vehicles concerning course conditions.  Perhaps a course boundary that shows the various signals all around the track (a yellow boundary for a yellow flag which I believe is traditionally an accident on the course).

Cars that incorporate IR (see my previous article) may have some advantages in anticipating what the other vehicles are doing on the course.


NTP and the Delay

We were setting up a check to ensure our time servers were pointed correctly from the firewall, but the standard time query was taking six seconds for each check.  With four time servers that’s nearly thirty seconds to make a simple “are you there” sort of check.  We didn’t want to do a simple ping test since this would not ensure the machine queried was in fact an actual time server.

After some digging and testing we found that if we limited the packets to a single packet the test was instantaneous.  So we added the -p argument and called it good.  (In our case we were not concerned with checking the time status but rather only the status of the server as an available time server.)

This is the basics of the command:

time ntpdate -qp

And that’s about it.  Very much faster with the p in the mix.