As I mentioned in a previous post of mine, Radio + Me = ❤, I was doing a radio show for over 2 years. During those 2 years, I kept a blog on which I would post the playlist of each show, so that people could find the artist and title of a song they liked, and discover new artists and songs. Just putting the names up is an easy task, but I wanted something more. So I made a Python script that would automatically link the artist’s name to their Last.FM page, and the title to a search on YouTube for that song. That way, discovering more information about the artists, and listening to the song again was easy for the users, and easy for me to maintain.
from Tkinter import Tk
stime = raw_input("Time: ")
f = open("list.txt", "w")
while stime != "":
artist = raw_input("Artist: ")
title = raw_input("Title: ")
artist_y = str.replace(artist, "&", "%26")
title_y = str.replace(title, "&", "%26")
msg = stime + r' | <a href="http://last.fm/music/' + artist_y + r'">' + artist + r'</a> - <a href="http://www.youtube.com/results?search_query=' + artist_y + " " + title_y + r'&search_type=&aq=f">' + title + '</a><br />'
f.write(msg + '\n')
stime = raw_input("\nTime: ")
The str.replace(…) commands are there because YouTube doesn’t like “&”or
in the URL, but uses “%26” to represent the ampersand, which works for Last.FM as well. If you try to use the artist and title variables in the URLs, you’ll see that YouTube stops at the first “&” character in the search query, and ignores the rest.
The result is saved in a “list.txt” file in the same folder as the script, and pasting it into a Blogger or WordPress blog post should give you a result like this.
P.S. This script is now in a GitHub repo I’ve created so that I can upload any small scripts that don’t need a repository of their own.
Since my early elementary school years, I was really envious of the radio DJs and producers. Those guys had access to so much music, and to so many people. I was determined to have my own radio show at some point.
Back then, internet access in Greece was really sparse. And radio on the web was not something anyone was familiar with. Growing up, once I reached junior high, my music collection started growing. I bought CDs from artists I loved, and downloaded (-cough cough-) mostly everything else. Internet speeds were also growing, and I got my hands on some mixing software. That’s when I started experimenting with making mix CDs that had beat-matched crossfades and effects and my own remixes of tracks. That grew into some pretty elementary live DJing, without me ever getting around to trying out the hardware all the DJs I was dreaming of becoming one day had.
And then, during my first years in University, I finally got my chance.
There’s definitely something wrong with me.
Whenever an assignment comes up and I’m going through it, or whenever I’m doing some programming on something I love (e.g. my thesis), there’s nothing else going on in the world or around me. I forget to sleep, working late into the night, even after my brain has stopped working, even after the code before my eyes is as understandable as the data waterfalls from The Matrix. I forget to eat, sometimes filling up a plate for dinner and bringing it with me to the desk, only to take another look at my code and then set the plate aside, until it’s cold and needs reheating (probably for the 8th time that night). Even when I sleep, I tend to keep a notepad on the nightstand (a huge, very fluffy stuffed bear serves as that, next to my bed), so that I don’t forget any ideas that hit me right in my sleep when the morning comes.
I guess that’s made me really punctual with my assignments, and it’s bound to make my future employers very happy, as well as any future wife of mine really, really unhappy.
So, continuing my Q&A with the user from the NLSC forums, he asked me two things. One, it was his first time that he saw someone access a class property directly, like so:
instance.property = newValue
And of course it hit me, that the proper way is for properties in classes to be private, and to provide get/set methods to the users if need be. Getting used to the automatic properties and fields of C# makes you forget about stuff like that. And that can only help emphasize my point about not learning a “modern” programming language first.
Regarding the first part, you can use instance.property = something (e.g. mycar.Make = “Volvo”) as long as you set the property to public. The “correct” programming practice says that you set all properties to private, and only give access to them IF YOU WANT to the user through methods, like so:
Continuing my last post, that user from the NLSC forums said he didn’t understand the “this” keyword the way it was explained through the video tutorials. Although I’m 100% sure there’s many people out there, way more experienced than I am, explaining this particular keyword, I thought I’d write an answer of my own. Why? Well, if I say I want to be a teacher, I should be able to explain any programming concept that comes up in words that a person that’s beginning programming would understand. (And if I don’t know a concept, I should not be afraid to say so, read up on it, and come up with a good explanation. A teacher that admits he/she doesn’t know everything is way more useful to their students and their approach to programming, than one that makes up bullshit on the spot to cover-up what he/she doesn’t know, and ends up filling their brains with false knowledge.)
So, here’s my explanation on the very first things one should know about the “this” keyword.
So, someone from the NLSC forums realized I’m a CS (actually, CE) student, and asked me for tips on how to go around becoming a “good programmer”. Here’s what I had to say, coming from my own experience. Full disclosure, when I began my CE studies, I was already familiar with some programming concepts, since I had been using Visual Basic since grade school, and had started my own project at 2003. But, I still think what I write below could act as some tips even for a person who’s just getting to know programming.
There’s no particular language that will get you to be a good programmer. All the languages you’ve mentioned have one thing in common, they’re object-oriented. Which means, they’re based around classes (objects) and their properties and what you can do to manipulate those objects.
There’s many steps to becoming a good programmer, but the most important one is practice, and exploring programming outside the limits of the assignments that were given to you, when you have the time.