Raspberry Pi Radio Project

Found my old Raspberry Pi Radio Project. I attempted to recreate the 1960s AM radio experience. I wrote a simple Python program that only plays random 60s era music along with ads and radio jingles from that era. I guess the keyword is “era”, because realistically some 1950s songs would also be played. I had intended to mount the Pi inside a 60+ year old yellow Admiral Model 4L28A AM Tube Radio, which I believe was 1st manufactured in 1959.

The program isn’t complex. The most tedious part of the project was gathering and sometimes clipping ads, jingles, from that era. Also found PAMS (Production Advertising Merchandising Service) from WQAM the radio station popular in my hometown of Miami in the 1960s While testing the program I found a gem that I don’t remember hearing before…Release Me. The version I most remember was from Engelbert Humperdinck however I prefer this one from Little Esther Phillips. I’m sure there are probably other hidden gems in the 340 MP3’s I have from that era. If I remember correctly, I got the bulk of the music using streamtuner2 and streamripper. Wow this music really brings me back! And unlike oldies radio stations, it doesn’t play modern ads and jingles to spoil the mood.

Rethink Django course? Consider Flask?

One of the main reasons I became interested in Django was because I’m familiar with Python and I was looking for a way to redo my site around Python instead of PHP. I use Python frequently as opposed to PHP which I use rarely. Most of my website PHP programs were written many years ago. Whenever I need/want to make a change to my website, I basically have to re-learn PHP. I thought if my website was in Python, I could more easily understand the existing code or write new code. Anywho, around 8min into lesson “41. Displaying Objects” the instructor says “So this is Django’s templating language this isn’t Python code. It’s a little bit funky”. This defeats one of my main reason to use Django. Hey we got this great Python language but let’s use another not so great language on top of that!

So maybe I should consider Flask instead. Django still has some great features, such as scalability. Also I like the automatic admin pages. However I usually just use phpMyAdmin as my admin page for my mySQL databases. That’s, where I usually update my tables. For bigger updates I just write a Python program that creates SQL modifications statements. I played with Flask last night and created a very simple program. When backed up the folder it was 717 files and 9.4MB. On the other hand my Django folder which contains 1 completed project and 1 partial project has 18,384 files and is 110.9MB. Flask is called a microframework so smaller is expected. Of course it will get larger when you start extending it with features that Django includes such as SQLAlchemy.

Setup django environment

Whenever I want to work with django, I have to do the following 6 steps to setup my environment. I probably don’t need to “conda deactivate” but I didn’t want to see “(base)” in the command line…and it isn’t necessary for this project. It becomes tedious everytime.

  • cd Mystuff/Python3/django/
  • conda deactivate
  • source bin/activate
  • cd password_generator-project/
  • code .
  • python manage.py runserver

Seemed like a easy thing for a bash script, except…

you can’t “deactivate conda” in the shell script
you can’t “source bin/activate”in the shell script
after the script finishes I’m no longer in the ‘cd’ directory

I couldn’t do it in Python either!

Perhaps there is some quirky way to do it but I wasted enough time googling and trying. For me it turns out the easiest way to do it was to put the commands in a text file then copy&paste those commands on the command line!

Django class…first challenge!

For the first challenge I’m having a little problem understanding Django links. It seems that links in Django html are referenced in urls.py first. At least that’s the way it seems in my Django infancy. A basic html link is a simple thing where you can point to an html file either in the program or the url address bar. If this html file is in a folder you would address it like …/folder/file.html if you don’t specify a html file name it looks for index.html in that folder. Anywho I created, a Django about.html file but I can’t seem to reference it by the file name, Instead I point to the file in urls.py and address it, seemingly as a folder? So the link looks like “…/about/”, however there is no about folder, only an about.html file.

Learned a little about bootstrap to prettify your site.

Django not finding base.html

While trying to follow a YouTube video on Django Templates, I was getting “..”TemplateDoesNotExist at /” so after consulting Stack Overflow I changed the following in my settings.py file

#Below ‘DIRS’: [] changed by WHB because it wasn’t finding base.html

‘DIRS’: [os.path.join(BASE_DIR, ‘generator/templates/generator/’)],

VS Code – compact folders

Why is this a thing? What a huge time sink for me. I’d rather continue learning the course than having to stop to figure out why an IDE is doing what it’s doing. I guess it’s par-for-the-course for an IDE, since it can do so much. While working on the Udemy Django I had to create a “templates” folder then a “generator” subfolder beneath that. As you can see below the subfolder displays on the same line as the parent folder. Why Whammy…why? The others folders don’t display this way!

So now I have to stop learning and look for a solution to a ridiculous IMHO problem. How do I even form my search phrase? Turns out this search “why does subfolder show on same line as parent folder in vs code” led me to a solution.

So there is a Compact Folders setting, which is supposedly useful for Java package structures. So although there are many programming languages let’s make the default be useful for Java. Couldn’t you make this decision based on file type? VS Code knows this is a Python file. As you can see below when the Compact Folders setting is unticked it displays the way I’m accustomed…the subfolder beneath the Parent folder. So why above, didn’t “__pycache__” appear on the same line as “migrations”?

I won’t remember the solution to this in a few days. I will probably remember having the problem. But thanks to the WordPress search, will I even be able to find it?

Bad WordPress search!

Mentioned this before, but didn’t have a reference. But I searched WordPress for Udemy and I got 2 pages

As you can see this is the last page of a udemy search, it’s dated 7/30/2020.

However if I search for Pandas an older post containing Udemy from June appears. As you can see Udemy is in both the Title and body of the post. It’s dated 7/19/2020. WTH?