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

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

100 Days of Coding – Day 21

My 100 Days of Code Repository * My FantasyGrounds XML to PDF converter Repo * My freeCodeCamp account page link * https://codepen.io/MusicalCoder/pen/jwGYgg

21 Days Down… 79 More to go… With that said…

Today I’ve worked on more freeCodeCamp, starting Challenge 119, which is building a tribute page on codepen.io. I have this started, and mostly done. I’ll do a few more items on it, and then be ready to say i’ve completed it.

I’ve also completed issue #3 on my Fantasy Grounds XML to PDF converter. But also found another bug and logged it!

I plan on adding some additional exercises in for working on python work, mainly from CodeWars, CheckIO, CodeEval, and ProjectEuler… I’ve sort of become very disappointed with HackerRank, as a) they haven’t updated a lot of their python stuff from legacy python, and b) some of their puzzles aren’t explained well.

Until tomorrow…

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Code – Day 20

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

So – I’ve completed 20% of this challenge. Unfortunately, as I’ve noted in my 100 Days of Code repo, Saturdays are horrible for me to code, as my time commitments on Saturdays are basically full all waking hours. So until I have some decent free time on Saturdays (more than 15-20 minutes at a time), I’ll be exempting Saturdays from my 100 Days commitment.

With that said…

Today I’ve worked on more freeCodeCamp, completing the intro to jQuery section, and now have 117 challenges completed. I’ve also started tracking ‘bugs’ and ‘feature requests’ for my FantasyGrounds XML to PDF converter, and today completed issue #2, and posted that.

Feel accomplished.

I plan on adding some additional exercises in for working on python work, mainly from CodeWars, CheckIO, CodeEval, and ProjectEuler… I’ve sort of become very disappointed with HackerRank, as a) they haven’t updated a lot of their python stuff from legacy python, and some of their puzzles aren’t explained well.

Until tomorrow…

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Code – Day 19

My 100 Days of Code Repository

Today I worked on both open projects. I worked on the Free Code Camp challenges. Completed the Bootstrap section, which brings me up to 99 Challenges completed. While this seems quick – I also take into account that I’m pretty familiar with most of this stuff as is.

I also modified the Fantasy Grounds XML Converter. I set it so that it automatically pulls the xml files from my FG directory into a temp directory, and then have it loop through all the xml files it copies and process them. I also modified the directory structure to put things under my Documents folder under a new subfolder to keep everything separate.

Not a bad day 19.

Until tomorrow…

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 18

I wanted to switch things up just a bit – so I jumped into Free Code Camp. I wanted to brush up on my Full Stack Web Design – and since I especially have no Node.js experience, this is going to give me a certificate and some skills in several technologies.

Now don’t get me wrong, I’m not stopping my python learning… this will be going in addition to it…

Today I ripped through the entire HTML/CSS course – but admittedly, I knew it already – so it was just me going through it to mark it off… but on the same token – it helped typing it in and getting it to stick a little more in the front of my mind.

My next bit will be working for a bit in freeCodeCamp, and also working on finishing the Fantasy Grounds XML > PDF program. What I’m going to do with that is add some functionality to:

  1. copy the xml files from my linux wine folder to a temp folder
  2. get the list of xml files
  3. run each file through the converter for pdfs

But this also means I’ll have to spend some time actually putting the characters into fantasy grounds… so that will also be part of the process… gonna do 1 character a day, starting tomorrow (well technically today, since it’s after midnight… but after I wake up and go to work!)

In honor of Adam West
Tune in next time…
Same Bat Time…
Same Bat Channel!!
Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 16/17

My 100 Days of Code Repository

I’m combining the post for Days 16 & 17 as they were both more of the same! Me finishing up the standard D&D 5E character sheet as an export option for the Fantasy Grounds XML export.

So the sheet itself is finished (my gosh were spells a pain in the rear due to a hideous naming sequence on the spell page). Next up will be changing the hard coding of a single sheet to be able to accept input as to which character you can print out.

So, until tommorow!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 15

My 100 Days of Code Repository

First off – I had to take 2 days off…

Saturday, which would have been day 15, was just chock full of business! I completely over-booked my day, and ended up basically being out of the house from 7am to 3am Sunday morning… Between a morning meeting, setting up my Saturday night Karaoke gig (which a good friend filled in for me) and my band played a cancer benefit about 7pm, but was there at 3pm to set up…

Sunday was a recovery day, and also Father’s day and did some family stuff!! My step-sons completely surprised me (both are out of the house) so it was a nice Father’s day for me…

But today it’s back to the grind… worked more on the layout for the 2nd sheet. Have some ideas for what I’m working on for the next portion of 100 Days!

So, until tommorow!

Never B Flat, Sometimes B Sharp, Always B Natural

100 Days of Coding – Day 14

My 100 Days of Code Repository

Today once again continued with the redesign (or restructure if you will) of the Fantasy Grounds XML to PDF Project I’m working on. Yesterday, I finished the Advanced Sheet.

Today I started the layout for the standard PHB DnD 5e Character sheet. Tomorrow may have to be skipped – I have a band gig that is a long cancer benefit – that takes me for over 12 hours – so I may have to push day 15 to Sunday.

Until tomorrow!

Never B Flat, Sometimes B Sharp, Always B Natural