Categories
Batch Coding StuffBuild

Stuffbuild: All WAV to MP3 Right-click Converter for Windows

Updated 02/05/2021

Behold, Windows users:  “Convert All WAV to MP3”!

WAV TO MP3 Converter demonstration
Sorry Unix ppl

A simple, lazy script that will save you a trip to Audacity… or even possibly a simpler method. 🙃

This dead-simple script does one thing quite well: it converts all WAV files in the directory you right-click in to MP3, non-recursively. (I do mention a recursive version below, with a caveat.)

A warning before we get into this tutorial: we will be editing registries. If that doesn’t scare you, I nonetheless advise you to back them up in case something goes wrong.

Let’s dive in.

JonOfOz Splash

(If you don’t care why I made this, click here for the tutorial.)

The why

You may have read in my About page that I was in an Irish band for 7.5 years; now, I’m starting up an experimental Irish jam. You can read about it in a future article, probably! 🤞

This jam will be a fusion of live musicians and live tech. Part of this process currently involves me making a lot of tracks for a lot of tunes that

  1. need to be played back live, and
  2. need to be available for jam members on a private Drive for the sake of practice and/or reference.
The problem

I’m using FL Studio to export these tracks: as far as I’m aware, FL Studio can only export playlist tracks as WAV files, at least currently.

A brief aside: WAV files are “lossless” (more data), and as a result can quickly eat up space on the Drive. Also, because of their higher data density, they take longer times to load, the effect being particularly noticeable on poor connections, which I would rather assume most people have; MP3 files are “lossy” (less data), so they load faster and are more compact. And hey, you can upload waaaaay more MP3 tracks to a Drive than WAV files!

The solution
  • A batch script with some techno-voodoo
  • Some mucking around in the registries
  • The LAME encoder
  • A lot of tutorials / references for those three

FWIW, I had absolutely never done anything like this before, and now I feel dangerously empowered. ⚡⌨

Editing the Registries

I only needed to edit HKEY_CLASSES_ROOT\Directory\Background\shell. This is where Windows looks for context-menu items (when no items are selected).

I simply added the Convert All WAV to MP3 key, making it available instantly, and then another key within, command, which fires the batch script, which we’ll make next.

Editing the registries
The Batch Script

First, create a batch (.bat) file in a reliable place where you expect it to remain (i.e. where it is less prone to link rot). It doesn’t matter what you name it: just name it sensibly.

As you can see above, mine is located at "C:\Users\lordd\Desktop# CODE\BAT\ConvertAllWAVToMP3.bat".

Now, here’s what’s inside!

mkdir MP3Conversions
for %%I in ("*.wav") do lame "%%I" "MP3Conversions/%%~nI.mp3"
pause

Okay, so what’s going on here?

  1. We make the directory MP3Conversions.
  2. We iterate over each *.wav file in the directory in which you right-clicked, making a call to the lame encoder. (We’ll set that up later, don’t worry.) The first argument is wrapped in double quotes; the second argument is also wrapped in double quotes, but the ~n flag causes the extension to be dropped, and we just toss .mp3 onto the end. (Again, it will only convert WAV files in this directory, and none in any nested folders.)
  3. Pause, JIC you need to inspectigate; remove this line if you don’t.

Note that I chose %%I arbitrarily: you could use another single letter, upper or lower case, and get the same result. However, variables are case sensitive, so consistency matters!

If you want to do this recursively (i.e find WAV files in nested directories), then change
for %%I in
to
for /R %%I in
The one caveat here is that any files with identical names will overwrite each other. So make sure your files are named uniquely at all levels!

The Lame Encoder

I downloaded a compiled, OS + architecture appropriate version of the LAME encoder from this page at RareWares. Since I have a 64bit version of Windows 10, I downloaded the one that says “Download x64 bundle(1214kB)“. Make sure you have at least these two files: lame.exe and lame_enc.dll.

I tossed them all (plus a free doc folder) in C:\lame, but you could place them somewhere else.

Location of LAME encoder


And then I added the folder’s PATH to my environment variables.

Setting PATH variable

Bear in mind, that PATH should reflect where you placed your copy of the LAME, whether it’s in C:\lame like mine or somewhere else! Also, make sure you do not have a trailing slash ( \ ) at the end.

And that’s all there is to it! 😀 This was a fun project for me, and it’s definitely got me wondering what I can do next with little scripts like these. Hopefully this helps you do the same!

Categories
Uncategorized

Retaining Over Relearning

Updated 1/15/2021

I was born not knowing and have had only a little time to change that here and there.

Richard Feynman
Short on time?
Gotcha Matcha, here’s that trendy TL;DR Version.

I’ve been itching to write an article like this for quite some time.

In this interesting post-pandemic lockdown blues, the feeling of uselessness is strong and relatable on a global scale.

I’ve seen young buds and old guards alike, the degreed and the non-degreed, let go from companies on the basis that their position “was no longer needed”, or no longer available. I was blessed—and I do mean straight-up blessed by God Himself—to have remained employed for 5 months with my last employer after the first lockdown… working in an aerospace environment, no less! I somehow lasted longer than a 16 year veteran (albeit a contractor) of the company, and he had a B.S., while I was still sitting my college dropout butt in a cubicle of a huge building once bustling with engineers, now reduced to a few shuffling feet.
It seemed as random as a shotgun blast.

But at last, here I am! And maybe here you are too, wondering how this is all going to pan out. When we’re going to work again. It’s a bit depressing, for sure, but wouldn’t it suck if it was just that?

Let me tell you that it ain’t.
It’s a new dawn to kick ass.

JonOfOz Splash
Mood. 🌅

Hey reader:

👉Get Smarterer, Fasterer.👈

You want fastererer? Can do, Xanadu. Here’s my

TL;DR Versionionionionion:

  • If you’re unemployed, now is a great time to learn new skills!
  • Even if you’re not, it’s as good a time as any other, and there’s still valuable information here.
  • We don’t have a lot of time, so let’s use what we’ve got to learn well.
  • I demonstrate methods I use (often simultaneously) to learn efficiently:
    • The Feynman Technique, to simplify and summarize large topics for yourself and for others. Rounds out your understanding and frames a topic well.
    • Spaced Repetition, where the review period for a given concept increases exponentially-ish as you begin to master it. Illegal to mention without also mentioning…
    • Flashcards, for quizzing yourself on things you learned and don’t want to forget! It’s synapse superfood, baby.
    • The Pomodoro Technique, where periods of intense focus on a topic are followed by breaks to allow for mental diffuse. I usually go 45 minutes on and then 15 minutes off. This technique does not require a tomato. 🍅
    • The Pareto Principle, where learning the crucial 20% of a topic gets 80% of the topic figured out. A helluva great start if you choose to master the topic later.
    • Chunking, where dividing and conquering a large topic into manageable subsections, or “chunks”, helps us create little frames of knowledge within the larger topic.
  • Finally, we need to shift our mindset from the atomic goal of learning a subject to the broader goal of learning anything in a way that will turn you into an unstoppable learning machine.


I’m not here just to make you feel sparkly, but I hope you do!

There’s a silver living to be found in unemployment: there’s never been a better time, or perhaps more time, to get learning so we can come back into the workforce swinging: a little less like me when I was an average 2nd baseman in the 3rd grade, a little more like Babe Ruth.

“Wait a minute,” you say, “who are you to tell me about getting smart?”

Well, that’s the thing: I’m no one special. I’m no savant, learning wizard, or some superhuman: I’m just a guy who is really interested in the science of learning, and I’ve been fortunate enough to have picked up a bunch of tools for learning efficiently. And I absolutely want to share anything that can benefit others.

If it helps my case, allow me to admit that I still have my bouts of Imposter Syndrome to get over. I know it’s a bunch of self-imposed BS, but it’s still 100% whole, real, pasteurized BS, and I’ve got it. Maybe it’s because I’m ironically a Taurus. 🐂♉

Whether or not you share in such a malady or another, and whether or not you are employed at this time, one thing holds true: it always feels good to feel useful, or to at least feel like you’re doing something when you can.

For me, nothing beats the feeling of uselessness to a pulp like learning, and learning a lot. Bulldozing the biggest obstacle of all: self-doubt. Being able to look at a previously imposing topic, and changing your attitude from “I can’t do that”, to “I can’t do that yet“, and finally to “I’ve got this.” Learning a lot offers huge thrills.

Of course, to learn a lot, we need to relearn less. I wish I knew this earlier in life, but taking notes is a very good thing.

So, sound good?
Awesome. Get ready to learn about learning: now’s never been a better time time to get started.

Here’s the plan.

Since this time won’t last forever, we’d better learn well.
That can mean a number of things, but let’s start here:

  • Be able to summarize a topic.
  • Relearn less; best case scenario, learn once.
  • Master the basics; maybe spank yourself if you skip them.
  • Try to answer questions on your own before Googling them.
  • Stay on topic.
  • Cut out distractions.
  • Take necessary breaks.

Well that sounds great and all, but it’s not going to do anyone any good I just tell you this stuff without ever putting into practice, showing you how I go about it. So let’s dive in.

Today, I’m Learning TensorFlow.

As I write this, I currently have no idea how to use TensorFlow; that will have changed by the time I finish this article. In fact, I’m going to outright state my goals that I want to achieve by the end of my learning adventure:

  • I want to be able to summarize TensorFlow.
  • I want to begin dabbling in machine learning.
  • I want to master the basics of TensorFlow, using Python.

Also, I’m going to assume by now you’re staying for the rest of the article. Awesome! 🎉

I encourage you to pick a topic now, if you haven’t, and to state your goals. Write them down, because you and I are gonna meet them.

Got your subject? Good!

…I’m serious, have a subject. Don’t waste your time with passive learning.

Alright, good. 😁

Let’s get to the tools! And boy, do I have some I want to share with you. 😉 As we go along, we’ll be implementing them in the learning process.

Now, we can pick and choose these, but we need to understand that these individual tools are not entire systems in and of themselves. We can’t really use just one of them, for the same reason we can’t fix everything our car with just a single wrench. These all make up a system whose design is simple and straightforward: to promote efficient learning.

Alrighty!
The tools I will be using are, simultaneously,

  • The Feynman Technique
  • Spaced Repetition
  • Flashcards
  • The Pomodoro Technique
  • The Pareto Principle
  • Chunking

Here’s How I Go About This:

Flashcards.

These are not just brainwashing devices you remember from the bowels of the deeply-flawed public body of education: these puppies will completely, totally supercharge your learning.

Make flashcards your best friend. They can be paper or digital, written or typed. If you have a stylus and a tablet, consider using them, as there are benefits to writing over typing. 😉 You could just use paper + pencil or pen, if that’s all you’ve got, but keeping a lot of notes organized and centralized can get pretty messy. Whatever works best for you: the most important thing is that you start making flashcards at all.

For this venture I’m going digital.

If you decided to do the same, you could use Anki, which is a great, free flashcard app for PCs that utilizes spaced repetition to help you remember things more efficiently and effectively. I do use Anki, but my problem with it is that it’s sort of cumbersome and has a bit of a learning curve. That said, it is very powerful in the right hands.

But damn, do I love using Quizlet. It’s simple, effective, and allows for creating flashcards without hassle. It has a free and paid-for plan; I’m using free for now.

Either app means typing instead of writing, but personally, it’s a trade off I’m willing to make for prolificity. (And again, this system is so much easier to keep track of than, say, an unruly stack of German verbs written on sticky notes. 🤔)

Got your flashcards ready to be made? Good!

Now, Ask the Mandatory First Question.

When you’re learning any subject—at all—you should start with this question first, the first one a child would ask:

“What is [your subject]?”

In my case, I ask: “What is TensorFlow?”

(Probably.)

Well, this is a dull start.

“C’mon, I want to use TensorFlow, not describe it!” quoth my brain. “Why must this always be the first question???”

But it makes perfect sense, doesn’t it? This single question encapsulates everything we’re going to be learning about. It’s the summary.

We almost invariably “click” with a subject when we can see it in terms of the bigger picture, not just the isolated components. It’s why we would rather experience contiguous media from the beginning: to understand. One cannot simply watch the Lord of the Rings trilogy for the first time, knowing nothing about it, starting right in the middle. Awaiting them would be some grey creature-freak who eats fish and is obsessed with a shiny ring; there’s no way they’d infer this character played a part in the epic tale of heroism and peril witnessed by nigh all Middle Earth in the Fellowship’s quest to destroy said shiny ring and make New Zealand bank in tourist bucks.
More applicably speaking, it’s why we understand React better once we know JavaScript, pandas once we understand Python, etc.
That’s why we always ask this dull question first. 😃

Okay okay, let’s continue.

Having asked the question, “What is TensorFlow?”, I visit the TensorFlow website, where I am greeted to shades of orange that are very complementary to the constant chroma of my very blue website, and words.

(I was close.)

And I write it down accordingly.

Again, I know it’s pretty dull and maybe a little pedantic, but if someone asks you the same question, you need to be able to answer it.
Hey, that sounds like

The Feynman Technique!

“The what?”

The Feynman (like “fine men”) Technique, named after Nobel Prize-winning physicist Richard Feynman, is one of the most effective methods known for learning absolutely anything.

I didn’t quote Feynman at the beginning just to write an article in a trite but effective format! (Although I totally did, in part.) Feynman was able to explain nearly anything to anyone, from first graders to the most scholarly of individuals.

And that’s something you need to do for yourself.

Teaching anything to others is among the most effective ways of solidifying facts and concepts in your mind: it’s even more effective if you can simplify it for both others and yourself.

As it turns out, TensorFlow is a very large topic with a lot of stuff to learn about. To be honest, I’m a little overwhelmed.

But I’m going to learn it, the most crucial stuff first.
Any half-way decent tutorial on anything utilizes the Pareto principle implicitly. So that’s where I’ll start.
That’s where Chunking comes in.

Categories
Coding TheMoreYouKnow What Is - X

WHAT IS – STATIC TYPING?

Updated 11/2/2020

The Gist of Static Typing

More languages today are based around Static Typing than Dynamic Typing. There are some languages that support both, but we won’t get into that here.
While statically-typed languages usually run faster than their dynamic brethren, they’re less trendy in the realm of web development and data science, although WebAssembly has been looking to shake up that game a bit. In general, these languages are better suited for games and applications, and won’t be going away any day soon!

Statically-typed languages are typically not beginner friendly, but that doesn’t mean they aren’t worth learning. Let’s jump in.

What is Static Typing?

It’s a little like this: Static Typing is a method where all variables must have a type, and that type cannot be changed during runtime.

Before we get confused here: the values of these static variables can change! They’re not like constants, whose values can’t change (and whose data types also can’t change, but I digress).

The only caveat is, quite predictably, that any new value assigned to the variable must be of the same type as the last value.


// In C++, we define a variable myInt of type int.
int myInt = 7; 

// This reassignment to another int value is okay!
myInt = 8; 

// This reassignment to a String is no good.
myInt = "JonOfOz";

Type checking happens at compile time. The compiler first verifies that the code doesn’t break any type rules, and if not, the program runs. Else, you’ll get type errors you need to fix first. This doesn’t guarantee you won’t run into errors, but you won’t run into ones related to type.

Static Typing has a number of benefits:
  • Static Typing results in faster, leaner code, since all data types are declared and checked at compile time.
  • There is less chance of running into errors in the middle of long processes due to simple mistakes. Imagine running a process that takes two days to finish, then bam, the code fails at hour 46 due to a single line where an integer was expected, but the string version of that integer gotassigned, and everything fell apart. Ouch.
Static Typing also has drawbacks:
  • Debugging can be frustrating in and of itself; that’s even more so the case with statically typed languages. The error messages can be pretty vague, and you’re dead in the water if you can’t start your debugger until you compile your code… which can’t compile until you fix all of the bugs. (You can get around this, but it can be a pain.)
  • Static typing is like an overprotective parent. If it sees you are about to learn a harsh lesson due to a type error, it won’t have it. This sort of sounds great, but giving the developer guardrails isn’t always a win: we learn a great deal from failures. So, what happens when we fail less?

How Does Static Typing Compare to Dynamic Typing?

For variables of both statically-typed and dynamically-typed languages, one principle is the same: whatever those variables are, they are references to addresses in memory.
In the case of the statically-typed example above, it’s referencing 7— more accurately, the memory address represented by 7.

The differences lies in the variables.

Static Typing

When a variable like myInt is declared, it is bound to the int data type for the duration of the runtime. The variable calls the shots: if it starts out as an int and you try to assign it a new String value, you’ll get an error.

Dynamic Typing

When a variable like myInt is declared, it’s nothing more than a reference to some address in memory. It might represent None / null, it might be an int, a String, it doesn’t matter. As long as you don’t perform illegal operations on whatever type it is at any point in runtime, you’re good to go.

Categories
Coding TheMoreYouKnow What Is - X

WHAT IS – PYTHON?

Updated 10/20/2020

The Gist of Python

I won’t hide it: Python is my favorite programming language of all time.


No, it’s not the fastest language out there—you’re not going to find it powering Triple A games or any graphics-intensive applications any time soon—but it can basically do everything really well and in fewer lines of code than other languages. And, in terms of readability and functionality, it hits a bullseye.

We won’t go into Python’s history here: there’s Wikipedia for that. I want to briefly explain what Python is, what makes it stand apart from most languages, and where it’s being used today. Let’s jump in.

What Python Is

Python is a programming language that is dead easy to learn, beautiful to look, and widely used—hey, you might be surprised where.

For starters, have some Python code!

> def say_hi():
>     print("Hello World!")
> hi()
"Hello World!"

Obviously, we could get more complex than that. Here, we just define a function and then we run it.

I just wanted to give a simple example to demonstrate the fact: Python is simple. So much so, it’s the most popular introductory programming language taught in universities worldwide.
The aforementioned study was done in 2014, but the momentum certainly hasn’t stopped. Udemy straight up advertises Python (above Javascript no less!) in their app store description. A large number of the most popular courses on Udemy are about Python and/or prominently feature Python as the language of choice for a number of different applications.

Udemy knows what you really want.

That leads us to another point: Python is general purpose. It can be used for creating websites and web apps; it can be crammed into integrated systems; and for Pete’s sake, it can power a Raspberry Pi to water your poor houseplants as you watch indifferently. Python is also popular for API development.

Where Python really excels, however, is in the realm of science.

Powerful libraries like Pandas, NumPy, SciPy, MatplotLib, Seaborn, Tensorflow, and others make data analysis, linear algebra, spreadsheet manipulation, and machine learning accessible (and relatively easy) to the general public by combining Python’s syntatic simplicity with common functions and routines found in each discipline.

What Makes Python Unique

Arguably the most unique thing about Python—and usually a dead giveaway that you’re looking at Python code—is its strict usage of indentation. By this, Python is said to adhere to the Off-side rule, a rarity among programming languages, with less than 2% of all languages using significant indentation.

Unlike the multifarious compiled languages, Python is an interpreted language: without going into the nitty-gritty details, this means code is compiled at runtime, not before. An implication of this is that your Python code doesn’t necessarily need to be error-free before you can run it, although Python won’t execute if, say, your code indentation is incorrect. which is a luxury you won’t get in a compiled language like C / C++ or Java something Compiled languages must be free: they won’t run if there is an error anywhere in the code

Where Python is Used Today

Forthcoming lol

Categories
Coding Python Secrets TheMoreYouKnow

The Arcane Secrets Of – PYTHON

Updated 10/13/2020

What We’ll Cover

  1. Various features in Python you may not have known about!
  2. These various features in action!
  3. Russian Roulette!

What We Won’t Cover

  1. Whether or not these features are considered by best practice.
  2. These features in both Python 2 and 3 (This site only covers 3).
  3. Any expenses related to playing Russian Roulette.
  • while loops and for loops can have else statements!
# RUSSIAN ROULETTE - Let's Play!
# (Seriously, don't.)
chamber_with_bullet = random.randint(1,6)
game_rounds = 3
dead = False
while not dead:
    # Spin the chamber, Charles
    chamber = random.randint(1,6)
    if chamber == chamber_with_bullet:
        dead = True
    else:
        print(f"BLAM: CHAMBER {chamber} IS SAFE!")
        game_rounds -= 1
        if game_rounds == 0:
            # The else block is skipped: you're alive!
            print("Congrats, pardner, you're alive!")
            break
else:
    print(f"BLAM: DEAD.\nThe bullet was in chamber {chamber_with_bullet}.")