100 Days of Code – Hour 5

Github Tracking

Hour 5 is final main push on the song lyric site. Again – it was just adding songs. However, its one of those things you learn with programming is that sometimes its not all fun and games. Sometimes you have to slog through work, even the very boring stuff. A lot of these songs, once I got the templates up, were just copying the lyrics in and formatting them so they fit on my screen properly (tablet), and then updating the index.html to show that song option.

There are more things I’ll eventually want to do with this. But I believe now that this is 1.0 is done, so to speak, I only have to add new songs as the band adds new songs (which are only a few a month if that). I may want to add some set list capabilities (where I can go in and list each set’s songs, and then have a button that would take me to all unlisted songs). But that is a future option (although since the idea just sort of popped in my head, I’ll pause for a minute to go log it to git hub… be right back…)

There, I’m back… relatively painless!!!

So anyways, I’ve added the following songs:
Basket Case * Don’t Stop Believin’ * Feel Like Makin’ Love * Hang On Sloopy * In My Dreams * Learn To Fly * The One I Love * Turn Me Loose * You Took The Words Right Out Of My Mouth

My next project is programmatically going through my collection of Karaoke and getting it cleaned and organized!

TTG Lyrics Site

Until next time…

Never B Flat, Sometimes B Sharp, Always B Natural

100 Hours of Code – Hour 4

Github Tracking

Hour 4 is a continuation of working on the song lyric site. This was just some song updates. However, this was an odd one, as I wasn’t using my home computer to do this – I was coding using notepad++ on my DJ computer (during a long day of DJing where I didn’t have to do much other than keep the playlist playing!)

Added the following songs:
All Summer Long * Centerfold * Footloose * Blue Ain’t Your Color * Fat Bottomed Girls * Hurt So Good * Love Shack * ROCK in the USA * Rocky Mountain Way * Taking Care of Business * Tennessee Whiskey

I should get some time later today to add more songs and do Hour 5 (that’s the goal) – I still have at least 18 more songs to do!

TTG Lyrics Site

Until next time…

Never B Flat, Sometimes B Sharp, Always B Natural

100 Hours of Code – Hour 3

Github Tracking

Hour 3 came and I continued to work on the song lyric site. This time added a few songs (see below) but more importantly, modified the blank song template for spacing, then created a new variable.js file that holds the blank song template bit, so that I would only have to change these settings in one location in the future (instead of having to go back and touch each song). But of course, it required me to go and touch each song this first time to get them configured using this new variable template.

Added the following songs:
The More I Drink * Some Kind Of Wonderful * Margaritaville * Seven Bridges Road

I should get some time tomorrow to add more work and do Hour 4 (that’s the goal) – I still have at least 25 more songs to do!

TTG Lyrics Site

Until next time…

Never B Flat, Sometimes B Sharp, Always B Natural

100 Hours of Code – Hour 2

Github Tracking

So – for hour 2 I added 10 more songs to the site, plus fixed some CSS as short titles caused the buttons to look different. It’s an internal site (so no public facing) – it’s mainly used for my tablet for live shows… Sometimes we’ll pull a song we didn’t practice or we’ve modified, but have to do the original, so having quick easy access to lyrics is very convenient!

Added the following songs:
Billie Jean * Faith * Get Over It * Honkytonk Woman * Jessie’s Girl * Long Train Running * Shut Up and Dance * Tie Your Mother Down * Turning Japanese * What I Like About You

The other thing was did this in PyCharm – working more in my IDE of choice for Python. I also spent some time watching the PyCharm training course from TalkPython! I really like the way Michael Kennedy does these videos! It’s a quality training.

Hopefully I’ll get some time tomorrow to add more work and do Hour 3 (that’s the goal) – but because I have a gig, that may not be possible. If not, Sunday I will have time to do more on this project. Off the top of my head, I still have at least 28 more songs to do!

TTG Lyrics Site

Until next time…

Never B Flat, Sometimes B Sharp, Always B Natural

Where does the time go…

So I wanted to start doing the 100 days of code challenge. The concept, is to spend at least 1 solid hour a day for 100 days straight coding. Love the idea, but I run into a real time issue. My problem isn’t that I don’t have an hour a day to work on code, I don’t have a solid hour. I have 10 minutes here, or 15 minutes there, that over the course of the day add up to an easy hour or two, but not good solid coding time (and if you’ve ever seriously coded, you can’t get much done in 10/15 minutes, as if you’ve been away from it for any decent (several minutes) length of time, it almost takes you that long to get back into where you were at and what you were doing.)

But I wanted to verify that I’m not making this up on my part, and make myself a bit accountable to this. So I decided to layout my day. I try to sleep from 1130-Midnight-ish to 7am. So let’s say Midnight to 7am – so there is 7 hours to sleep. I then have an hour to do my daily ablutions (shower, walk the dogs, etc) and get to work (so we are at 8 hours), then 8 1/2 hours for work, plus the drive home, basically is 9 hours. I have 2 little dogs, so I get home and have to take them for a walk (I have to walk them, as a) I don’t have a yard I can just let them wander in and b) I keep them kenneled while I’m not home for any significant (3+ hours), so I need to walk them for a good 10 minutes to let them stretch out from their kennel and do their business). By the time I get that done, we are at 530. Take a half our for dinner, and that puts me at 6pm. So at this point, I have 6 hours left. Now out of that leisure time, I’ll have to walk the dogs at least twice, if not thrice. So for convenience sake, we’ll call it a half hour.

So with 5.5 hours of remaining – here’s what I’ve got…

Mondays – Running D&D for my son and his friends. This is between 4 – 5 hours. I promised my son I’d do this, and I get a lot of fun and stress relief out of it, plus I can honestly say I love being the kids’ first Dungeon Master. Plus, a lot of projects I want to program are due to gaming stuff, so giving this up erases my need to do a lot of the projects on my list, and I really do want to do these projects!

Tuesdays – I’m a Mason, and this year I’m Master of the Lodge, so I’m required to be at the Lodge for every meeting, plus the off Tuesdays we practice. This takes me 4 hours from leaving to getting home. Some times a little less, sometimes a bit more. But this basically makes Tuesdays a wash.

Wednesdays – Normally free night number one. Here is a night I can admittedly program for the challenge, but I also have to temper it with normal domestic house stuff. (The house doesn’t clean itself, and I don’t want to pay someone to clean it for me). I’m now DJing on Wednesday Nights (although I’ll admit that it probably won’t be for too much longer)

Thursdays – Band Rehearsal. I am in a band (hence the Musical part of Musical Coder), and this is our practice night. This is also about a 4 hour endeavour between actual rehearsal and drive time. Plus Friday morning is trash day, so then I have to gather up all the trash and clean the cat litter boxes, and take the trash out, which basically washes this night.

Fridays – Again normally a free night, although monthly I have a masonic obligation on a Friday night. I also occasionally have a band gig (a few times a year on Friday), but usually, this night is also available for coding.

Weekend Nights – I’m going to break my Saturdays and Sundays into Days and Nights. Saturday nights are either taken with Band Gigs or DJing. Band gigs are more brutal as it basically takes me from 4-6 PM thru the wee hours of Sunday morning (depending on the location of the gig – but the gig, including drive time is usually 8+ hours [4 hours of performance, 2 set up, 1 tear down, and roughly an hour drive there and back]). So that cuts a bit into Saturday Days… Sunday nights is my relax and unwind night, and where I go PLAY D&D with my friends. I had given it up for several years, but I found I truly missed it, and my life is much happier that i’ve been playing it for the last year, so I won’t give it up. But that takes care of my Sunday Nights.

Weekend Days – So Saturday is available, and depending I can either get 3-4 hours or 5-6 hours in, so my plan is there. Sundays is NOT the same thing. Sundays is time spent paying my bills and updating my budget, going grocery shopping, and whatever other house chores need done. So Sunday is a wash.

So this basically only leaves me 3 days a week to do decent chunks of code. So I decided to break it into hour to hour and a half chunks. Since the idea was to code 1 hour a day, your still only talking about 100 hours of code for the challenge (minimum), so I figure I’ll break my time into 90 minute increments and call that a day. And then maybe get 2 days at a time. Which would give me the equivalent of 6 days a week (7 if I really push a Friday or Saturday when available).

So that is my new plan, and technically I started Yesterday. Yesterday was the day, because, while it was a Thursday, we had an anomaly this week where Band Rehearsal was switched to Wednesday. So Thursday was my free night.

So I spent my first 2 days working on a lyric project in html/css/javascript to put on my tablet, that is basically a landing page with buttons to all of my song lyrics that I may need for a show (not necessarily to sing from, but for a quick glance to remind me for songs we haven’t done in a while on what verse is when, etc.) I couldn’t just use regular pages, as my tablet only has wifi, and not cellular, so there are lots of gig locations where I wouldn’t have internet access. So having it statically on my tablet makes things work beautifully for me. Plus because all the pages are on the tablet, it’s super speedy.

There are a few more songs I need to add to it, but for now, it’s basically ready for my next gig, so I’ll add songs to it throughout my time here and there (as it only takes a few minutes to add a new song lyric into it).

I’ll also post it on GitHub so you can see my progress on it. Once I push it up to GitHub, I’ll post on what I did, and how I changed it, etc. (as you can say I’ve already done a revamp to it).

But for now, there is day one! Day 2 will be this projects 1.0 release, if you will, and the changes I made to get it there.

Until next time – remember…

Never B Flat, Sometimes B Sharp, Always B Natural

So here comes 2018!

So – lots of goals for 2018, and I feel like I’ve let 2017 slip away a bit. One of the first things I plan on doing is restarting the 100 Days of Code – but focusing on Python. I have several python projects I want to work on, and plan on incorporating these into the 100 days of code!

    Some of the projects I want to work on are:

  1. Karaoke / Music Tracking DB
  2. Comic Book / Magic Card Website
  3. Money/Budget Tracker
  4. D&D DM Management System

I am sure this list will expand as I start working on things more and more, and as I complete some of these projects…

I also plan on visiting all of my training sites (HackerRank / CheckIO / CodeWars / CodeEval / ProjectEuler) and revisit and do more updates on these!

My true goal is to actually get past 100 Days, and just keep at it!!!

I’ll post more on New Year’s Day!

Until Then…

Never B Flat, Sometimes B Sharp, Always B Natural

TIL: Algorithm for Random Numbers that sum to a value.

So I was on Reddit today, and someone had posted in the learning python subreddit about his random number function was running slow…

Specifically, he was creating a list of 9 random numbers between 0 and 100 (inclusive) where the sum of those 9 numbers totaled 100. I’ve never had a situation that called for that before, and the code he gave was a simple while statement saying that while the sum of the list didn’t equal 100, empty the list, and generate 9 numbers between 0 and 100 and add them to the list, and keep going until you got a total of 100…

So I commented that of course that would take ages, as the loop probably had to run tens of thousands of times to randomly get 9 different numbers between 0 and 100 whose sum totaled 100.

My original suggestion had been to get your first number, then generate a second number between 0 and 100 – first number, and then keep doing that…

When someone else posted the following quite elegant solution… I asked where he learned it from, and he couldn’t remember where, but after further investigating, its one of those quaint mathematical formulae that always works!!!

So, in our example, we need 9 numbers between 0 and 100 (inclusive), so we take 0, and 100, and then 8 random numbers between 0 and 100, and then sort them all, so we end up with 0, 8 numbers from smallest to largest, 100…

Then you simply take the difference between each set…

So for example, let’s say our 8 random numbers were 85, 24, 58, 5, 31, 46, 94, and 7. We then take those 8 numbers, add 0 and 100 as well, and then sort them, giving us:
[0, 5, 7, 24, 31, 46, 58, 85, 94, 100]

We then simply calculate the difference between each number (5-0, 7-5, 24-7, 31-24, etc) which, by doing so would give us:
[5, 2, 17, 7, 15, 12, 27, 9, 6]

Which, in turn, sum up to 100!!

I was like… HOLY CRAP!!! I’m keeping that one in my back pocket!!!

Never B Flat, Sometimes B Sharp, Always B Natural

New Storage/Work Drive

So I have a new computer that I never brought up (I’ve had it about 6 months, but again, never posted the new specs here – I’ll be doing that soon as well!) and I’ve got 2 SSDs in it (smallish for me – 240GB each) which one is root, and the other is home… But I’ve recently installed a 3TB 7200RPM Hard drive to use for storage and work space (I’ll keep downloads and other files on it so as not to waste space on the SSD)…

I wanted to write down how I did it for future reference, and to let anyone else know how it was done!

So first, we format the drive! I opened my terminal and did the following:
lsblk – which showed me I have a sda1/2 (swap and root), sdb1 (home) and sdc with nothing (unmounted).

So from there, I did the following:

sudo parted -s -a optimal /dev/sdc mklabel gpt
sudo parted -s -a optimal /dev/sdc mkpart primary 0% 100%
sudo mkfs.xfs /dev/sdc1

The first line configured my new hard drive to use GPT (since it’s 3TB, and msdos label won’t work).
The second line then made the partition as a primary partition, and then used the full amount of the hard drive.
The third link then formatted it as an XFS file system.

The next thing we’ll want to do is set it so that it auto mounts up on booting up (just like root and home do) so to do that, we’ll need to modify fstab – but before doing that, we’ll want to use the uuid of the hard drive – so that the system will ALWAYS mount just this hard drive to the specific location (which I should probably create as well).

sudo blkid
sudo mkdir /mnt/storage
sudo vim /etc/fstab

And then I simply added
UUID=[blkid] /mnt/storage xfs defaults 0 0
to my fstab file.

After rebooting, I now had my storage drive… Then I just need to do the following:

sudo mkdir /mnt/data/musicalcoder
sudo chown musicalcoder:musicalcoder /mnt/data/musicalcoder
sudo chmod 700 /mnt/data/musicalcoder

Then I can simply copy which folders I want from my home directory to my new storage drive, and then create a symbolic link to the new location in my home directory… I’ll use Downloads as an example…

mv -v ~/Downloads /mnt/data/musicalcoder/
ln -s /mnt/data/musicalcoder/Downloads ~/Downloads

Simply do that for each of the folders I wish to have on the storage drive (which for me were Downloads, Music, Videos, and Work), and voila!!!

Never B Flat, Sometimes B Sharp, Always B Natural

Back – and better than ever!

So I sort of stopped my ‘summer of code’ and 100 Days of coding, as I was having problems staying into it, and I realized that I wasn’t enjoying it, as I was working on things I wasn’t interested in and felt like I was forcing myself into it… so I stepped back…

Things are slightly tumultuous at work, so I decided it was time to write again, on stuff I wanted to write about, and on projects I want to work on!

I’m going to try to keep each post separate and worth reading on a single topic… so I’m going to sign off on this one for now!

More Soon!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Code – Day 27/28

My 100 Days of Code Repository * My FantasyGrounds XML to PDF converter Repo * My freeCodeCamp account page link * My CodePen.io Link

Day 27 saw me complete my Angular IO tutorial, and modify said tutorial to demo tabs for our Proof of Concept at work. I think next on this front is doing the same thing in ReactJS.

Day 28 I worked on more of the freeCodeCamp ‘Portfolio Page’ working out the footer section and adding all the said links I wanted to use. Next on this front will actually be handling the 3 sections (About, Portfolio, and Contact) and making it a little snazzy!

I also worked on a ‘special project’ that I won’t talk about unless it comes to fruition, but it’s basically seeing someone I respect have a need for my skills, and putting myself out there and offering to aid them in a unique-ish way (I hope).

Until tomorrow!

Never B Flat, Sometimes B Sharp, Always B Natural