Programming thread

I mean this would be less of a problem if they were capable of learning (it ain't so).
I think they are, but English ability lets them down. One of my Indian colleagues explained that you first learn a regional language depending on where you are born, then Hindi, and then English, and you pick up very bad habits speaking English amongst people who aren't native English speakers. There is also a problem with the education system which prioritises rote recital of information as opposed to free-form learning or discovery. So basically, the longer someone lives in a western country, the better they are, especially if that was from an early age.

I had a colleague once who was Indian but raised in Canada so he was fully bilingual in both English and Hindi and it totally changed the productivity of the team as we could actually tell the offshore teams precisely what they needed to do. Unfortunately I realise now that this made it seem like offshoring worked, and working there was a nightmare after he moved on, so I did so shortly after.
 
I just want to write a javascript that can detect when an embedded youtube video ends and play the next one, why is this so hard
 
There is also a problem with the education system which prioritises rote recital of information as opposed to free-form learning or discovery.
Having worked with people from Nigeria, China and India professionally (although not in IT) they all seem to have this same problem.

Cheating is also pretty rampant. The whole actual "learning stuff" thing seems to get skipped over in favor of having the piece of paper at the end that definitely proves you learned something.

There are certainly people in the west who have the same mindset but damn it's just not culturally embedded like that.
 
  • Agree
Reactions: Aidan
I think they are, but English ability lets them down.
My experience with American-born Indians begs to differ. My guess is that the culture promotes retardation and getting by on lies over merit. Like with a lot of things I thought it was overblown until experiencing it firsthand.
Exceptions exist but generally I will do a lot to avoid working with Indians.
 
Having worked with people from Nigeria, China and India professionally (although not in IT) they all seem to have this same problem.

Cheating is also pretty rampant. The whole actual "learning stuff" thing seems to get skipped over in favor of having the piece of paper at the end that definitely proves you learned something.
I somewhat disagree. I've worked with Africans who fully lied themselves into their positions but performed competently after ramping up. Indians just can't do it. There are some cute Indian women tho
 
I was watching a WPF tutorial when I realized at the end that I fucked something up and couldn’t figure out what it was. So I just deleted everything and rewatched the video and followed the tutorial more closely. How do you guys get better at troubleshooting your code?
 
I just want to write a javascript that can detect when an embedded youtube video ends and play the next one, why is this so hard
Using what? Tampermonkey?

Your primary issue is that embedded YouTube videos are embedded, and each video is isolated in its own <IFRAME> container, which makes it difficult to try to interact with, by design (the page that embeds the video isn't supposed to be able to modify the YouTube embed).

If you're using Tampermonkey, first of all you're going to have to make sure that your userscript is running in both the host page and the iframes (make sure that the userscript Settings General "Run only in top frame" isn't turned on, and make sure the userscript matches both URLs). Then you're going to have to have a way for the host page to communicate with the iframe, which can be achieved through iframe.contentWindow.postMessage(data, '*') and an accompanying window.addEventListener('message', event => { /* do something with event.data */ }) inside the iframe.

You'll need to set up bi-directional communication though, so that the iframe can let the host page know when it's done playing, and the host page can tell the next iframe to begin. So inside the iframe you'll do window.parent.postMessage(...) and you'll need a similar window.addEventListener('message', ...) in the host window to process the messages coming from the iframe.

Then you'll need to figure out some way of keeping track of which iframe is which, which I guess you could just do by indexing them (0, 1, 2, 3, etc) and sending each iframe a message telling it "you are [number]." Then you'd need another type of message that an iframe can send the host to tell it "iframe [number] just finished playing," and finally a message that the host can send to the next iframe to tell it "start playing."

Your data can be any type of object, as it'll basically be invisibly run through JSON.stringify/JSON.parse as it's passed from one window to another. E.g.
JavaScript:
data = {type: 'assign_child_index', index: 0}
data = {type: 'finished', index: 0}
data = {type: 'play'}
Then your message event handlers can just check data.type and proceed accordingly.
 
  • Informative
Reactions: MyBushDid9/11
I just want to write a javascript that can detect when an embedded youtube video ends and play the next one, why is this so hard
You're gonna need to define your problem a bit better. What do you mean by "next one"? Do you mean a page with multiple embedded youtube videos on it?

I was watching a WPF tutorial when I realized at the end that I fucked something up and couldn’t figure out what it was. So I just deleted everything and rewatched the video and followed the tutorial more closely. How do you guys get better at troubleshooting your code?
It varies greatly (besides just getting experience). Personally, I'm not a fan of codealong video tutorials, and never have been. I prefer taking a prebuilt example, sample, or toy app in what I'm trying to learn

e.g. for your case something like https://github.com/microsoft/WPF-Samples

running it and then toying around with it, changing stuff, adding/modifying stuff, etc. along with the documentation to figure out how things work. Otherwise, I'll usually just add log statements to the console or to a file if I'm trying to figure stuff out. Depending on the language there are "better" methods of debugging, but logging is something that can be done in any language and can be used in a hype specific way to solve in ways others can't, or can't do so easily.
 
I was watching a WPF tutorial when I realized at the end that I fucked something up and couldn’t figure out what it was. So I just deleted everything and rewatched the video and followed the tutorial more closely. How do you guys get better at troubleshooting your code?
Sooner or later, if you're working with a rational programming language, the errors that the compiler produces will start to make more sense to you. First you'll learn how to search out information to understand what the error means, then begin to really understand it. This would not apply if we were talking about Oracle SQL or something like that, some things are beyond human comprehension.

When I'm doing something I don't understand really well and doing it from scratch, I like to make very small changes, compile, run, test as quickly as possible. If I'm doing something I don't fully understand, I'll set breakpoints and, with Visual Studio and .net as you are, just fuck around in the immediate window until I can figure out how to do things or what's going on.

And as @Cold Root Beer says, add logging. Dumping data to the console is fine for learning, but once you start producing something that anyone else will use, it's time to get your head around something like log4net that will allow you to produce logs at various different logging levels and really go nuts adding in as much logging as possible. It's really easy to do, and it's a great feeling when you get a really worthless completely unhelpful report of a problem from a user, and you can just look at the logs and see what happened.
 
Last edited:
Not that I've tried every logger out there, but I like Serilog, if for no other reason than the configuration being less bizarre than log4net's.
Might have to give it a look. My main pain point with log4net is has always been setting things up right to write to different destinations (usually files of course but I've used UdpAppender on occasion), perhaps at different levels, from the same logger. I think I might just need to get smarter with the boilerplate config I keep around to add into config files.
 
Using what? Tampermonkey?
It's a webpage. What I'm doing now is pretty much what you put down there, but I can't seem to get it to work. I actually do have the code to modify the iframe working, and it works to select a video when the page loads but not after. I think part of the problem might actually be Brave/Ublock blocking Youtube's event signal. Eh, maybe for now I'll just have a button to press to go to the next video, see if that'll work.
 
I was watching a WPF tutorial when I realized at the end that I fucked something up and couldn’t figure out what it was. So I just deleted everything and rewatched the video and followed the tutorial more closely. How do you guys get better at troubleshooting your code?
You drink, bash your head against the wall, sleep away the pain, then get up eight hours later and stare in awe as you realize you screwed up by misplacing one piece of basic syntax.

More seriously judicious Googling of general error messages and use of logging and breakpoints helps a lot. Logging especially, and in general you will find you can never have too much of it. The only time it may prove challenging is in production code where it could reveal legally sensitive material, but that's where breakpoints come in handy.
 
I like Serilog, if for no other reason than the configuration being less bizarre than log4net's.
I like Serilog because it's god-like when investigating a problem on a service with hundreds of concurrent users generating gigabytes of logs every hour and you need to find events that match a specific pattern. You can pair it with Logstash or Cloudwatch insights to query your logs as if they were a database.
 
It's a webpage.
No shit it's a webpage. I'm asking what you are trying to use to add your script to the page.

Doing it from the dev console would be theoretically possible I guess, but you're really going to want to use an extension like Greasemonkey or Tampermonkey to just automatically run your script.
 
No shit it's a webpage. I'm asking what you are trying to use to add your script to the page.

Doing it from the dev console would be theoretically possible I guess, but you're really going to want to use an extension like Greasemonkey or Tampermonkey to just automatically run your script.
It's a webpage with a javascript script attached, I don't know what else you want from me lmao
 
Back