Programming Frustrations

For general computer discussion & help, come here

Moderators: Bakhtosh, EvilHomer3k

Post Reply
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Programming Frustrations

Post by Kasey Chang »

I am getting ready for class starting on Monday, and one of the pre-class projects was to create a Javascript game. We're giving 3 choices: easy, medium, or hard. Hard would be to create a shmup. I said, how hard can it be? Turns out, it's tremendously hard, given current browser security models in the browsers.

I found a nice short JS game lib called WADE I can adapt pretty easily. shmup was already written as an example. Just need to change a few things, like sprites, and some game logic.

Nope, didn't work. And I was going by the sample code!

Open up Developer Tools in Chrome... CORS policy has blocked access to local javascript files. WTF?!?!

Basically, I had to have a local WEBSERVER to run these. LOCAL includes won't work. Spent almost 2 hours trying various CORS bypass with ZERO success.

Simple CSS and JS includes are fine. BIG js and complex js includes... not allowed. ARGH.

So I pretty much have to write it from scratch.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
hitbyambulance
Posts: 10233
Joined: Wed Oct 13, 2004 3:51 am
Location: Map Ref 47.6°N 122.35°W
Contact:

Re: Programming Frustrations

Post by hitbyambulance »

wrote an art program in Python tonight that really went south - locked up the Python process, which also locked the Task Manager process. so I rebooted and the laptop just hung at the BIOS boot screen! lol so i had to power down longer, at which point it booted normally. it was either coincidental or i really did end up overheating the CPU... this work computer does not have low-end specs, so i dunno.
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Found someone else's shmup that I can modify (and learned quite a bit), actually, probably not best practices, but seems to work for now.

https://kschang77.github.io/Cat-Defender/ <--- playable link

And yes, source code is available, and credit for fork is given.

Had been stuck for a while before realizing the original guy left some stuff in CSS as "relative" which messed my code up because I've pivoted the axes and that requires absolute instead of relative.

I know collision detection sucks. I'm kinda working on that. But I have a couple more modules of pre-work to do.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

hitbyambulance wrote: Sun Mar 08, 2020 2:39 am wrote an art program in Python tonight that really went south - locked up the Python process, which also locked the Task Manager process. so I rebooted and the laptop just hung at the BIOS boot screen! lol so i had to power down longer, at which point it booted normally. it was either coincidental or i really did end up overheating the CPU... this work computer does not have low-end specs, so i dunno.
Chances are your power button just hibernated the OS... maybe. Wasn't there. :)
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Actually had a productive few days so far. First few weeks are on pretty easy stuff. Right now we're still on HTML and CSS positioning, and I seem to be ahead of everybody except maybe the teacher and the TA's. Though I'm so old school, I never heard of "bootstrap". Guess I have to mess with it a bit more tonight.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Bootstrap stuff is all done. I should score at least 90% IMHO on the homework.

The next homework is due Thursday, but I finished in two hours (or less), as it's just pretty simple Javascript. I know regular programming, so Javascript is easy for me. But I'm sure I'll be stumped when it's time to play with Node.js or React.js
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Okay, the DOM / Javascript is really f***ing dense. I know the general concepts, but going through a bunch of examples and only have 10-15 minutes to "try it yourself" is just not quite enough time in class.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Isgrimnur
Posts: 82085
Joined: Sun Oct 15, 2006 12:29 am
Location: Chookity pok
Contact:

Re: Programming Frustrations

Post by Isgrimnur »

Never is. The DOM is an 800-lb gorilla.
It's almost as if people are the problem.
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

I may be overextending myself a bit, but I did manage to finish the Javascript homework 48 hour ahead of schedule (it's due Tuesday midnight), while advancing (somewhat) in the other two Coursera courses I'm trying to finish up. Got the program to work as specified, so I'm not going to worry about minor differences from the specifications or to make things prettier.

I have 4 Python projects I need to finish up via SSH login. It's pretty simple stuff for the "IT automation with Python" class. Just finished 1 in 60 minutes, 3 more to go. Then that certificate is done.

On the IBM Applied AI certificate, There are six courses, one of which I've already taken for the IBM Data Science Pro certificate. And I just finished the third course (Building Chatbots with Watson AI w/o programming) out of five remaining. And I can see the remaining two will be tougher... "Building AI apps with Watson APIs", and "Intro to Computer Vision with Watson and OpenCV". They do look interesting though, more fun than these Javascript stuff I'm writing for bootcamp.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Spent a FULL HOUR trying to debug an issue that shouldn't be an issue... JSON and Python.

JSON requires double quotes, but somehow, when I dumped a dictionary to JSON file using json.dumps() built-in function, I get SINGLE QUOTES out. It made absolutely no sense, yet it did. At first I thought I had single quotes in the data (as apostrophes), so I filtered them out. Tried again, nothing. Still ERROR 500. Then I decided to do a global replace single quotes with double quotes in the string. Now I get error 400 WTF?!

Then was told that I was "doing it wrong". I don't need to use json.dumps at all, because I can specify json output within requests module itself. WTF?!?!?!

Somehow, that worked. Now I get 201. Okay...

Except the assignment won't validate now, probably because I manually inserted a couple entries as test to see if my string was formatted correctly.

At least I "saved" my work, and won't have to spend an hour "debugging" this.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Got that stupid assignment validated (finally), I'm stuck on the NEXT one. And that's why I hate Qwiklabs... They don't run "secret validations"... like how you'd validate solutions of a programming puzzle... Where they give you the first 4 validations, but keep 10 hidden. They want to check your intermediate steps, but they don't tell you what they check for, so if you approach it in a slightly different way, or they made a typo in their descriptions, your results won't validate, and you tear your hair out wondering why it's failing when it *should* have worked.

Spent 30 minutes trying minor variations in formating, and ran out of time (you only have 90 minutes of lab, and you have to struggle with a non-GUI editor... nano on Linux). Now I get to do it all over again.

EDIT: Finally got it done. Turns out, the OUTPUT FILE has been renamed. The example they gave was report.py generated report.pdf. They didn't really say what output is cars.py is supposed to generate. Turns out, at the very end, they refer to cars.pdf, and most people missed that. That's why it won't validate... There is no cars.pdf, it's still report.pdf. That, and minor issues, like some parts wanted <BR> tags between lines, other parts wanted \n linefeeds. But that's done.

Decided to push through tonight and finish that Python thing once and for all, even though I already paid for another month (forgot Coursera's deadline)... Just get it over with.

Except the final is a doozy... Had to do like 3-4 separate things, and again, lab time of 90 minutes. Had to "pre-process" a lot of the stuff by writing it offline and only start the lab in the last minute.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

The "final assignment" turned out to be FIVE things, all done inside 90 minutes. Except they gave conflicting and unclear instructions, and probably copied something from one section to another without editing it resulting in a total mess of instructions. That someone managed to "complete" all five parts I consider a f***ing miracle.

But the idea that we shall generate a PDF report from scratch by calling reportlabs library when previously all we did was copy a single call to a pre-written report generator (which presumably called reportlabs), is idiotic in itself, esp. when we can't see the source code of what we called earlier so we at least have an idea what we're looking at. I am tempted to go back to that lab and read the source code of what we called so I can copy it.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
tiny ogre
Posts: 3198
Joined: Sun Oct 17, 2004 12:26 am
Location: Irvine, CA
Contact:

Re: Programming Frustrations

Post by tiny ogre »

I did a browser game for Ludum Dare 45 last fall. It's only sort of a Javascript game, I really used Typescript. Javascript is a bad language. Typescript is Microsoft's attempt to make it better, and it's pretty popular.

The game is built on Pixi.js. Source code here It wasn't a horrible experience. I disliked some things about Typescript (this was the first time I'd used it), but all of those things are due to Javascript.

Setting up a node.js/typescript environment for this is certainly a bit of a learning curve, but it does take care of all the "have to have a web server" kind of issues. I was able to have a normal debugger inside VSCode while running the game in Chrome, for example. But there's a much simpler way to deal with "have to have a local web server" if you're writing plain old Javascript. You can run a web server that serves a local directory with a single python command, not even a script, just a command:

Code: Select all

cd wherever/your/html/is/
python -m http.server
(For python 3, slightly different for python 2)

Then you would go to http://127.0.0.1/index.html

Javascript files will load fine that way.
Twitter: joerumz
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Oh, I did finish that final assignment... By finishing only FOUR out of FIVE activities (pass is 80%). I went back to previous assignment and they gave the source code which helps me to write something for this one. I studied it and "pre-wrote" the required bits. And I basically pre-wrote EVERYTHING (took a couple hours) so I can have everything ready to paste when I started the 90 minute lab.

And even then, the stuff I thought would work "as is'" required quite a few modifications. Like trying to get file and ext separately in Python? Whatever I used (I think it was the os.path.split os.path.splitext) didn't work for some reason, and I need to research a different one fast, and ended up using string.split (on period). I could have done the 5th one as I have time left, but I just said f*** that. and finished the lab and got the passing grade, and thus the course and certificate.
Last edited by Kasey Chang on Sun Mar 29, 2020 1:00 pm, edited 1 time in total.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
RunningMn9
Posts: 24461
Joined: Tue Oct 12, 2004 11:55 pm
Location: The Sword Coast
Contact:

Re: Programming Frustrations

Post by RunningMn9 »

My son is in college now, studying Computer Science and is neck deep in his Computer Architecture and Assembly Language class. I had forget the level of tedium that exists when programming in assembler.
And in banks across the world
Christians, Moslems, Hindus, Jews
And every other race, creed, colour, tint or hue
Get down on their knees and pray
The raccoon and the groundhog neatly
Make up bags of change
But the monkey in the corner
Well he's slowly drifting out of range
User avatar
tiny ogre
Posts: 3198
Joined: Sun Oct 17, 2004 12:26 am
Location: Irvine, CA
Contact:

Re: Programming Frustrations

Post by tiny ogre »

os.path.split would split the path into separate components for each directory. Like /usr/data/example/data.txt would give you an array ['usr', 'data', 'example', 'data.txt']

You wanted os.path.splitext

Code: Select all

filename, file_extension = os.path.splitext('/usr/data/example/data.txt')
Which would give you 'data' in filename and '.txt' in file_extension.

How do I know this? Googled it and found it on stack overflow right away. The class that teaches you how to google and read stack overflow should frankly be a prerequisite for any programming class in 2020 :D
Twitter: joerumz
User avatar
RunningMn9
Posts: 24461
Joined: Tue Oct 12, 2004 11:55 pm
Location: The Sword Coast
Contact:

Re: Programming Frustrations

Post by RunningMn9 »

tiny ogre wrote: Sun Mar 29, 2020 8:56 amThe class that teaches you how to google and read stack overflow should frankly be a prerequisite for any programming class in 2020 :D
Nothing in the world would get done without stack overflow.
And in banks across the world
Christians, Moslems, Hindus, Jews
And every other race, creed, colour, tint or hue
Get down on their knees and pray
The raccoon and the groundhog neatly
Make up bags of change
But the monkey in the corner
Well he's slowly drifting out of range
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

The really weird part is I'm SSH'ed into one of Google's Linux servers, and when I used splitext on filename.ext, I got filename.ext and "". I know, makes NO SENSE AT ALL. It worked well before. I found that Stack Overflow article month(s) ago when I was taking Python courses. But in this case, it refused to work. And I don't have time to mess with it. So I just rewrote it the brute force way.

Code: Select all

    if filename.endswith(".txt"):
        fname,fext=filename.split(".")
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
coopasonic
Posts: 20969
Joined: Fri Mar 04, 2005 11:43 pm
Location: Dallas-ish

Re: Programming Frustrations

Post by coopasonic »

RunningMn9 wrote: Sun Mar 29, 2020 9:48 am
tiny ogre wrote: Sun Mar 29, 2020 8:56 amThe class that teaches you how to google and read stack overflow should frankly be a prerequisite for any programming class in 2020 :D
Nothing in the world would get done without stack overflow.
My twenty-something coworkers are amazed that we used to write working code before google. RTFM has been replaced with LMGTFY.
-Coop
Black Lives Matter
User avatar
RunningMn9
Posts: 24461
Joined: Tue Oct 12, 2004 11:55 pm
Location: The Sword Coast
Contact:

Re: Programming Frustrations

Post by RunningMn9 »

You CAN write code without google and stack overflow I guess, but it would take forever. :)
And in banks across the world
Christians, Moslems, Hindus, Jews
And every other race, creed, colour, tint or hue
Get down on their knees and pray
The raccoon and the groundhog neatly
Make up bags of change
But the monkey in the corner
Well he's slowly drifting out of range
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

I can't believe how like 90-95% of the so-called "Chinese Zodiac" calculator is technically wrong. Seems most just converts your regular birth year into lunar year, ignoring the 2 month (or so) difference between solar and lunar year. Guess they are going for the "restaurant place mat" version of the sign rather than the real one. :-P

I ended up writing a different one... using moment.js and moment-lunar.js to convert the birthdate properly into lunar year, THEN calculate the Chinese zodiac from that.

Ten Percent of You In the West May have the wrong Chinese Zodiac
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

The danger of trusting your teammate to do the right thing is you had to clean up after him.

Got partnered with two folks for 'Project One' in my bootcamp. One's perfectly fine. The other was... Extremely hard to work with. Let's call him T. We had already chosen one idea but scrapped it because he claimed he wasn't there to contribute and pick the idea. So we went through the idea list again. He liked the idea of building a dashboard. So I went off searching what APIs and stuff we can display in the dashboard. That was last Monday night.

Tuesday we basically traded links to APIs but none were really usable. But it felt like I and the other member were doing all the work and T's involvement was limited to googling something. He wanted to do the UI, and the other member went off with him. I did the research on API.

By Wednesday at noon, there is STILL no front-end design. In fact, we were STILL discussing what data we need from the user. At 8:30PM I thought I saw some elements to play with, only to be told that those are NOT the actual frontend elements but placeholders.

Thursday, STILL no front-end to integrate, then github crashed at about 1:30PM PDT. The rest of the day basically means the I can't do anything because the front-end is still not finalized... It's on TWO SEPARATE HTML pages, and I can't read variables from one to the other unless it's passed or saved in LocalStorage. And what he created is NOT a dashboard at all. But it's too large to pivot again.

Finally, at Thursday 6PM, I got word that he combined the two into a single homepage (index.html). But I still have no code to integrate as he's not done yet.

Oh, and the project is due Friday noon.

I told him I'm going to sleep and wake up at Friday 3AM to do integration with what he got.

And that's what I did. I finished the app, fixed the features he claimed he added (but never got working), plus all the buttons and stuff he created connected to the APIs I got working.

I delivered a working app. We as a team presented this "dashboard that's not really a dashboard". And I honestly wrote 80-90% of it, and 100% of the actual functions.

Now the lecturer didn't like my tone and attitude toward T, which I never said in public. Lecturer claims I "lack empathy".

WTF.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
RunningMn9
Posts: 24461
Joined: Tue Oct 12, 2004 11:55 pm
Location: The Sword Coast
Contact:

Re: Programming Frustrations

Post by RunningMn9 »

In my office, the team is basically divided into two groups. There’s one group that does basically all the work, and the other group we affectionately refer to as the mynocks, that try to burn everything down as fast as we fix it.

No matter how much progress we make, there the mynocks are, chewing away at our cables and electronic.

This was an important lesson for you to learn. :)
And in banks across the world
Christians, Moslems, Hindus, Jews
And every other race, creed, colour, tint or hue
Get down on their knees and pray
The raccoon and the groundhog neatly
Make up bags of change
But the monkey in the corner
Well he's slowly drifting out of range
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Right now, having a bit of a fight with IBM Watson image recognition system.

You can train it to recognize a LOT of stuff. And the final assignment was to train it to recognize bed, chair, and table.

Right now, I have 34 pictures of beds, 56 pictures of chairs, and 111 pictures of tables. for it to "train" with. And it takes minutes for it to train.

After it's trained, I'm supposed to stick it with random pictures to see if my training "worked".

It's fine identifying beds and chairs, even beds it'd never seen before, like a hospital bed. But table? Where only the table surface was shown? It identified it as a chair. WTF?! Watson! Bad Watson!

EDIT: And here's the REALLY frustrating part. You can't go back and unselect some of the pictures you used as table's training set. You had to delete the entire "table' set and start over. So I'm stuck uploading another 15-20 pictures as tables and hope that improves the table ID accuracy. THEN wait another 15 -20 minutes for the model to retrain.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
hitbyambulance
Posts: 10233
Joined: Wed Oct 13, 2004 3:51 am
Location: Map Ref 47.6°N 122.35°W
Contact:

Re: Programming Frustrations

Post by hitbyambulance »

Kasey Chang wrote: Wed Apr 08, 2020 9:51 am Right now, having a bit of a fight with IBM Watson image recognition system.

You can train it to recognize a LOT of stuff. And the final assignment was to train it to recognize bed, chair, and table.

Right now, I have 34 pictures of beds, 56 pictures of chairs, and 111 pictures of tables. for it to "train" with. And it takes minutes for it to train.

After it's trained, I'm supposed to stick it with random pictures to see if my training "worked".

It's fine identifying beds and chairs, even beds it'd never seen before, like a hospital bed. But table? Where only the table surface was shown? It identified it as a chair. WTF?! Watson! Bad Watson!

EDIT: And here's the REALLY frustrating part. You can't go back and unselect some of the pictures you used as table's training set. You had to delete the entire "table' set and start over. So I'm stuck uploading another 15-20 pictures as tables and hope that improves the table ID accuracy. THEN wait another 15 -20 minutes for the model to retrain.
seems like the data set is on the (very) small side? what if you got and trained it on 5-10k photos of each type of furniture...
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

The lab was expecting about 20-25 images per set. I actually overdid it as my table set has like 135 images now. :D

Any way, it has some problems identifying a table out of a clutter of furniture. It often misidentified it as a chair or something like that. But I decided to deploy it anyway. It's done.

You can give it a try here: give it any picture of chair, table, or bed, and see how it does.

https://kasey-chang-computer-vision-app.mybluemix.net/

I've submitted the assignment, so now it just awaits someone else grading it, and I need to grade someone else, and that's it for this course and certificate.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
stessier
Posts: 29816
Joined: Tue Dec 21, 2004 12:30 pm
Location: SC

Re: Programming Frustrations

Post by stessier »

Kasey Chang wrote: Wed Apr 08, 2020 10:17 pm The lab was expecting about 20-25 images per set. I actually overdid it as my table set has like 135 images now. :D

Any way, it has some problems identifying a table out of a clutter of furniture. It often misidentified it as a chair or something like that. But I decided to deploy it anyway. It's done.

You can give it a try here: give it any picture of chair, table, or bed, and see how it does.

https://kasey-chang-computer-vision-app.mybluemix.net/

I've submitted the assignment, so now it just awaits someone else grading it, and I need to grade someone else, and that's it for this course and certificate.
I'm not sure what to make of the results for my image.

Enlarge Image

Code: Select all

Class Labels	Class Scores
table	          0.757
chair	          0.39
bed	          0.115
I require a reminder as to why raining arcane destruction is not an appropriate response to all of life's indignities. - Vaarsuvius
Global Steam Wishmaslist Tracking
Running____2014: 1300.55 miles____2015: 2036.13 miles____2016: 1012.75 miles____2017: 1105.82 miles____2018: 1318.91 miles__2019: 2000.00 miles
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Applied AI is done. Woohoo!

I guess I'm really a masochist, as I was determined to use my PI Day special and enrolled yet ANOTHER certificate: Modern Big Data Analysis with SQL through Coursera/Cloudera.

Had to put it off for like 2 weeks, and it was complaining I didn't do the quiz fast enough. :D Just blew through week 1 and week 2. I'm learning SOMETHING, as my SQL education was mostly informal through desktop and simple server RDBMS like Borland Paradox and MS SQL Server. I am not sure can I finish this before my 30 day 3.14 special is up, but it's a good refreshing while I slog through my Bootcamp.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Right now my brain is fried on async/await in Node.js. I *think* I finally got the hang of it, then I run into this problem.

Can't get the "nest" prompts to work

TL/DR version: program is supposed to menu 1) a) Enter new b) Quit. If "Enter New" go to Menu 2) Enter X,Y,Z, or Stop? If Stop, it's supposed to go back to Menu 1). And for X Y Z it'll do something else. Right now, I got menu 1 and 2 working fine. Menu 1 will transition to Menu 2. menu 2 will take X Y Z. But when I chose Stop from Menu 2, the display messes up, as if both Menu 2 and Menu 1 were called, but Menu 1 responded, and if I chose 2nd choice blindly, it will quit.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Decided to rewrite that portion from scratch so there is only ONE prompt loop.

So that program works fine now.

------

I may have mentioned that I'm taking another Coursera class, as I was determined to take advantage of their Pi-day promo for $3.14 for one certificate. And I picked "Big Data Analysis with SQL" by Cloudera/Coursera. I'm actually doing pretty well, as I know SQL was way back when... need a bit of refresher, but not too bad. There are three courses, and I'm already through one course and half way done with second. But it's obvious they'll be rather more difficult from here on out.

Then I ran into what may be a bug in the quiz. :think:

It's a multiple-choice (select ANY OR ALL that are correct) Basically, they are asking for the right command line to generate a certain output. I already picked one from the first group of choices (the questions are about Impala and Beeline, BTW. I got the one about Beeline) There are four choices. Two of them are outright wrong. Out of the remaining two... NEITHER would generate the specified output. So I didn't select either, figure it's a trick question.

When the quiz got graded, I got ZERO for that question because "You didn't select all the right choices". WTF... Went back to study the manual... AFAICT, I am right, they are wrong. So I wrote them a long explanation on why they're wrong on the message board. We'll see if they write back.

-----

In the meanwhile, my Bootcamp class has moved onto writing servers using Node.js and Express. Yeah...
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Okay, *mea culpa*... Apparently impala shell DEFAULTS to tab-delimited output if delimited is specified. So what I *thought* would be the right answer they were aiming for is correct. I just started with a false assumption. :-P
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Bootcamp has glossed over Express/node.js for writing a mini-server, and has gone onto SQL. I know they're just covering stuff so we can start using SQL with Express, but still...

I underestimated the SQL lessons again. I'm on week 5 of 6 of course 2 (out of 3). *sigh*. But the good news is I have 15 more days to finish it all. So I'm a little ahead of schedule.

----

Finished the Node.js / Express server homework ahead of time. Started Using "Postman" to test APIs, and deploy to Heroku for stuff that requires a server. It's... interesting so far.

Now I need to get some time alone to finish the SQL stuff before the next homework. :D
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Today just shows that I learn something new everyday... I had not encountered "counting sort" before.

It's a hackerrank problem. Basically, it's a "rolling window" median evaluation. I thought I had it solved when I optimized all the divide by 2 logic with bit shift. Median logic has no more optimization possible. I was doing O(1) logic where I sort the INITIAL window, then as the window moved, I drop the item that scrolled out, then insert the new element in the right place with binary search. So this should be log (n). Should be BLINDING fast.

And when it passed the simple tests, I say okay. I submit...

Then having it "timed out" on 5 out of 8 tests. WTF... With a bit more tweaking, I got it to pass 3 more, but two of the remaining ones won't pass no matter what. So I checked the test cases... a window of 20000 item. WTF?! Out of 100000. ACK! No wonder this won't pass. Clearly, I'm doing it the wrong way.

So I admit defeat and checked the discussion area... and they mentioned "counting sort".

And I checked it in Wikipedia. Turns out, Counting Sort is like Radix sort... I only need the RANGE, and turns out the input is limited between 1 and 200. So for Counting Sort, I only need to declare and traverse array of 200 items, even for arbitrarily huge arrays. And I can still use the rolling window technique.

So now I need to rewrite the solution almost from scratch.

EDIT: median takes almost no calculation. And insert into the right place also takes almost no time (binary search should take log(n) ). But inserting a value into the counting sort array (size of 200) ought to be a lot faster than trying to slice a 20000 item array... And I guess that's where the performance comes in...
Last edited by Kasey Chang on Sun Jul 19, 2020 1:01 pm, edited 1 time in total.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Isgrimnur
Posts: 82085
Joined: Sun Oct 15, 2006 12:29 am
Location: Chookity pok
Contact:

Re: Programming Frustrations

Post by Isgrimnur »

Kasey Chang wrote: Sun Jul 19, 2020 4:17 am So now I need to rewrite the solution almost from scratch.
That does happen.
It's almost as if people are the problem.
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Rewrote it, got the speed, as it's failing now with the "wrong answer" message, instead of "timed out" message. So now, onto debug mode!
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
User avatar
Kasey Chang
Posts: 20750
Joined: Sat Oct 30, 2004 4:20 pm
Location: San Francisco, CA
Contact:

Re: Programming Frustrations

Post by Kasey Chang »

Kasey Chang wrote: Sun Jul 19, 2020 5:55 pm Rewrote it, got the speed, as it's failing now with the "wrong answer" message, instead of "timed out" message. So now, onto debug mode!
The problem with a HUGE dataset in a "contest" type site is you don't get to see all the debug messages you put in... Because putting those in slows down the app, and that would make the output fail. This makes debugging impossible as you don't get any feedback. The only thing you can do is play with a LIMITED dataset to make sure your algorithm is okay, and hope you spot the mistakes.
My game FAQs | Playing: She Will Punish Them, Sunrider: Mask of Arcadius, The Outer Worlds
Post Reply