• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:55
CET 15:55
KST 23:55
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (March 9-15): herO, Clem, ByuN win02026 KungFu Cup Announcement5BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains16Weekly Cups (March 2-8): ByuN overcomes PvT block4
StarCraft 2
General
Weekly Cups (March 9-15): herO, Clem, ByuN win Blizzard Classic Cup - Tastosis announced as captains GSL CK - New online series BGE Stara Zagora 2026 cancelled BGE Stara Zagora 2026 announced
Tourneys
2026 KungFu Cup Announcement [GSL CK] #2: Team Classic vs. Team Solar [GSL CK] #1: Team Maru vs. Team herO RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion Gypsy to Korea BSL 22 Map Contest — Submissions OPEN to March 10 Are you ready for ASL 21? Hype VIDEO
Tourneys
ASL Season 21 Qualifiers March 7-8 [Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Path of Exile Nintendo Switch Thread PC Games Sales Thread
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Mexico's Drug War Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread NASA and the Private Sector
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Tokyo Olympics 2021 Thread Formula 1 Discussion General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1578 users

The Big Programming Thread - Page 987

Forum Index > General Forum
Post a Reply
Prev 1 985 986 987 988 989 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Broetchenholer
Profile Joined March 2011
Germany1954 Posts
January 10 2019 07:43 GMT
#19721
Coming from C, i wanted to use my trusted pointer list to deal with this, but found out that jscript masks their lists as arrays. I might have used string descriptions instead of just numbers to identifie elements but this was thrown together pretty quickly and streamlining has not happened yet. In the end it looks like i won't use the array at all anyway and access every element by the id, so i can take the whole thing out in the end. It's a really strange concept for me though. But yes, i can move my function definitions to the top.
shz
Profile Blog Joined October 2010
Germany2687 Posts
January 10 2019 09:53 GMT
#19722
Just to chime in on tooling:

https://eslint.org/ - for a linter
https://prettier.io/ - for formatting (also often finds bugs)
Liquipedia
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 10 2019 17:54 GMT
#19723
selenium is incredibly awesome
even though it's a pain in the ass to use with some websites, it's still awesome since there is no good alternative
thanks acrofales
Broetchenholer
Profile Joined March 2011
Germany1954 Posts
January 11 2019 13:58 GMT
#19724
Okay, next really stupid question. I am trying to get a JSON object from a get operation using XMLHttpRequest. This is my code:

var requestURL = 'http://localhost:3000/1835/bank';
var request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
request.onload = function() {
response = request.response;
}

Now, after trying to udnerstand why i couldn't get the response out of the local function scope, i realized that i did get it out but after the rest of my code had already executed. I can't build all my code from inside the function, so i need to let my code wait for this to finish or simply get it syncronously. But after reading up on callbacks and promises and await my head is spinning. I am not gonna understand this today. I have tried to sinply use syncronous communication, but this does only give me a string. Can someone give me a short piece of code that simply waits a set amount of time so that onload can do it's thing?
Acrofales
Profile Joined August 2010
Spain18234 Posts
Last Edited: 2019-01-11 15:08:50
January 11 2019 15:01 GMT
#19725
You really don't want to do that. You should study up on callbacks and promises.<edit> not only is sleep fundamentally unsafe, but you'd have to include a library to even be able to do it, and it'd be a dirty hack</edit>. The basic concept isn't actually all that complicated. Here is a quick, understandable, tutorial: https://medium.freecodecamp.org/javascript-from-callbacks-to-async-await-1cc090ddad99
shz
Profile Blog Joined October 2010
Germany2687 Posts
Last Edited: 2019-01-11 16:06:34
January 11 2019 15:58 GMT
#19726
Also, try to look up on `fetch`: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API

I'm not sure what the scope is of what you're building, but maybe it would be worth looking into a library/framework. Check React or Vue for example. There are tons of tutorials online / on YouTube which would make you way more productive than how you're doing it currently (imo). I think some people will yell at me, but what you are doing looks really painful and outdated. JS has come a long way and I'm not sure if it is really beneficial to build web apps like it's 2005 and learn outdated JS. React at least brings a lot of vanilla (up-to-date) JavaScript with it, I'm not sure about Vue. Though Vue might be easier for you.
Liquipedia
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 11 2019 16:03 GMT
#19727
lol, so the website im trying to interact with via selenium seems to literally take anti-automation measures...
it seems that the IDs of the elements change order on a daily basis
like, yesterday and element I wanted to click swapped xpath with a different element

given how many hurdles they seem to present, im expecting this is an intentional thing.

I think I'll need to search for elements via the actual text that would be outputted on the website and then click that element? Hopefully I am able to do this or it was all for naught!
Broetchenholer
Profile Joined March 2011
Germany1954 Posts
Last Edited: 2019-01-11 16:56:19
January 11 2019 16:21 GMT
#19728
I appreciate the feedback, but i am not going to learn webprogramming with my project. I am hacking together something with a headache because my pride prevents me from just postponing this even though i won't be finished when the software would have it's use, tomorrow. My biggest problem is that i didn't start with a good understanding of the basics to begin with, therefore, tutorials are basically useless. I have looked into the linked tutorial before posting this and i don't understand the code snippets, either due to headache, stupidity or lack of basics. Probably all three.

And now that i have 3 gets to ask for different data, for some reason only the last one actually gives back information, which makes even less sense... I guess i will have to stop, admit defeat and come back when i am capable of thinking again.

Edit: Fetch seems to be able to get them all simultaneously. I still have no idea what this is doing and why it works better but i guess i'll take it. And it still does not seem to solve my first problem. Arrrgh.
Silvanel
Profile Blog Joined March 2003
Poland4742 Posts
Last Edited: 2019-01-11 16:41:10
January 11 2019 16:37 GMT
#19729
On January 12 2019 01:03 travis wrote:
lol, so the website im trying to interact with via selenium seems to literally take anti-automation measures...
it seems that the IDs of the elements change order on a daily basis
like, yesterday and element I wanted to click swapped xpath with a different element

given how many hurdles they seem to present, im expecting this is an intentional thing.

I think I'll need to search for elements via the actual text that would be outputted on the website and then click that element? Hopefully I am able to do this or it was all for naught!


This what i mentioned before when i commented on Selenium. If the element is loaded in random order [the xpath is changing] (this can be antiautomation measure but can also be caused by data being retrived from container type which doesnt care about order --->just accident). You should check if the elements do not have other distinctive capabilities (names, type, id etc.) if the site is well documented You should be able to target elements by different properties. If the properties are all the same (or no name etc. at all) it does not mean they are actively fighting automation it can be lousy programming. I have seen this before on the site that was SUPPOSED to be automated.

PS. If the number of elements isnt too high You can attempt some loop with "try-except".

PS 2.Active anti-automation usually means captcha and things like that.
Pathetic Greta hater.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 11 2019 16:54 GMT
#19730
oh shit, using try-except is genius
and yeah you are definitely right, it must be that they are loading them in a random order or something. this is probably why I am having so much trouble. there's no documentation because I doubt they want people to do this - you can have access to their API but it literally costs $1000. they would never use a captcha though, because it would drive their clients crazy.

the try-except loop is a genius idea but I don't think it will work here because what's happened is that it's like a little tree that you can click and open up, and the ID switched to a different parent on the main part of the tree. so, it won't catch an exception instead it will work but it will open up the wrong part of the tree. I've looked for other distinct identifiers but there doesn't seem to be any.


hmm but maybe I can just click by X/Y coordinate of the iframe it's in? worst case scenario
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
January 11 2019 20:43 GMT
#19731
On January 12 2019 01:54 travis wrote:

hmm but maybe I can just click by X/Y coordinate of the iframe it's in? worst case scenario


Be careful hard coding things like that because it can break with different browsers or resolutions. If you're betting real money and it does something you don't want you could end up losing a lot of money as well.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Lmui
Profile Joined November 2010
Canada6223 Posts
January 11 2019 20:51 GMT
#19732
Can I just say here that I am so glad that checksums provided with downloads are a thing where I work?

Story:
People were asked to apply a patch to fix an issue.
The patch was applied and system broke resulting in a fairly big escalation/rollback/call.
I checked the sha1sum that the patch is supposed to have vs what was used and it was different.

Cause:
A pre-release version of the patch was uploaded to content provider (Which contained a bug? or something). This was pretty much immediately taken down/reuploaded with the correct version.
Content provider somehow served the old version from a cache or something.

Solution:
Re-downloaded it, ran checksums and they matched, and applied patch from rolled back version and it's fine now.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2019-01-12 00:53:32
January 12 2019 00:51 GMT
#19733
On January 11 2019 22:58 Broetchenholer wrote:
Okay, next really stupid question. I am trying to get a JSON object from a get operation using XMLHttpRequest. This is my code:

var requestURL = 'http://localhost:3000/1835/bank';
var request = new XMLHttpRequest();
request.open('GET', requestURL);
request.responseType = 'json';
request.send();
request.onload = function() {
response = request.response;
}

Now, after trying to udnerstand why i couldn't get the response out of the local function scope, i realized that i did get it out but after the rest of my code had already executed. I can't build all my code from inside the function, so i need to let my code wait for this to finish or simply get it syncronously. But after reading up on callbacks and promises and await my head is spinning. I am not gonna understand this today. I have tried to sinply use syncronous communication, but this does only give me a string. Can someone give me a short piece of code that simply waits a set amount of time so that onload can do it's thing?


can't you do a while loop in your function, and actually read the json, and look for some sort of identifier in the json that would be the end of file? or some equivalent design

although I have to imagine there is a way to simply call another function when it's done. im unfamiliar what callbacks are, maybe that's what that is. if you can't do that then man that sounds awful
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
January 12 2019 05:03 GMT
#19734
Yes, that's what callbacks are pretty much. A function that you call at the end of something else. JS relies on them heavily. Example pseudocode:
get(something).then(print("this"));
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
SC-Shield
Profile Joined December 2018
Bulgaria837 Posts
Last Edited: 2019-01-12 07:32:08
January 12 2019 07:30 GMT
#19735
Do you guys think that C++ jobs are slightly/better paid than jobs for other languages? I think I will look for a new job but I don't think I understand market completely to negotiate my salary well enough. Advice is welcome.
Broetchenholer
Profile Joined March 2011
Germany1954 Posts
January 12 2019 10:44 GMT
#19736
I will probably, if i understand the concept somewhat correctly, cascade my fetchs now and let the last one then start the rest of the code.

Something like this:

function buildSite() {

fetch('http://localhost:3000/data1')
.then(function(response) {
return response.json();
})
.then(function() {
fetch('http://localhost:3000/data2')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
fetch('http://localhost:3000/1835/stock')
.then(function(response) {
return response.json();
})
then(function(myJson) {
doAllTheStuffWithMyData();
});
});

});
}

It seems really inconvenient to me. I am probably not grasping the merits of async connections cause all this does is make the whole data import syncronous again, but waaaay more complicated.
Acrofales
Profile Joined August 2010
Spain18234 Posts
January 12 2019 10:57 GMT
#19737
On January 12 2019 19:44 Broetchenholer wrote:
I will probably, if i understand the concept somewhat correctly, cascade my fetchs now and let the last one then start the rest of the code.

Something like this:

function buildSite() {

fetch('http://localhost:3000/data1')
.then(function(response) {
return response.json();
})
.then(function() {
fetch('http://localhost:3000/data2')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
fetch('http://localhost:3000/1835/stock')
.then(function(response) {
return response.json();
})
then(function(myJson) {
doAllTheStuffWithMyData();
});
});

});
}

It seems really inconvenient to me. I am probably not grasping the merits of async connections cause all this does is make the whole data import syncronous again, but waaaay more complicated.

You can use jQuery when.

It'd be something like:

$.when(
$.ajax('http://localhost:3000/data1'),
$.ajax('http://localhost:3000/data2'),
$.ajax('http://localhost:3000/stock'),
).done(function (d1, d2, stock) {
doAllTheStuffWithMyData();
});
Manit0u
Profile Blog Joined August 2004
Poland17694 Posts
January 12 2019 11:03 GMT
#19738
On January 12 2019 16:30 SC-Shield wrote:
Do you guys think that C++ jobs are slightly/better paid than jobs for other languages? I think I will look for a new job but I don't think I understand market completely to negotiate my salary well enough. Advice is welcome.


I don't think that. It all depends on your seniority and position you're applying for.
Time is precious. Waste it wisely.
Broetchenholer
Profile Joined March 2011
Germany1954 Posts
January 12 2019 11:22 GMT
#19739
On January 12 2019 19:57 Acrofales wrote:
Show nested quote +
On January 12 2019 19:44 Broetchenholer wrote:
I will probably, if i understand the concept somewhat correctly, cascade my fetchs now and let the last one then start the rest of the code.

Something like this:

function buildSite() {

fetch('http://localhost:3000/data1')
.then(function(response) {
return response.json();
})
.then(function() {
fetch('http://localhost:3000/data2')
.then(function(response) {
return response.json();
})
.then(function(myJson) {
fetch('http://localhost:3000/1835/stock')
.then(function(response) {
return response.json();
})
then(function(myJson) {
doAllTheStuffWithMyData();
});
});

});
}

It seems really inconvenient to me. I am probably not grasping the merits of async connections cause all this does is make the whole data import syncronous again, but waaaay more complicated.

You can use jQuery when.

It'd be something like:

$.when(
$.ajax('http://localhost:3000/data1'),
$.ajax('http://localhost:3000/data2'),
$.ajax('http://localhost:3000/stock'),
).done(function (d1, d2, stock) {
doAllTheStuffWithMyData();
});



That does look much cleaner, i will take a look into jQuery then, thanks.
SC-Shield
Profile Joined December 2018
Bulgaria837 Posts
Last Edited: 2019-01-13 10:33:10
January 13 2019 10:32 GMT
#19740
On January 12 2019 20:03 Manit0u wrote:
Show nested quote +
On January 12 2019 16:30 SC-Shield wrote:
Do you guys think that C++ jobs are slightly/better paid than jobs for other languages? I think I will look for a new job but I don't think I understand market completely to negotiate my salary well enough. Advice is welcome.


I don't think that. It all depends on your seniority and position you're applying for.


Why not? I think most of us here would agree that C++ is one of the hardest programming languages because it's low level. Why would an equivalent position of a C++ one get the same salary unless employer cares just about profit (which could be the case if that's what you mean)?
Prev 1 985 986 987 988 989 1032 Next
Please log in or register to reply.
Live Events Refresh
Wardi Open
12:00
#78
WardiTV1105
Rex127
IntoTheiNu 9
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Rex 127
RushiSC 38
StarCraft: Brood War
Horang2 8698
Sea 2662
Soma 931
Mini 663
Light 600
EffOrt 535
ZerO 470
Stork 433
Snow 368
ggaemo 237
[ Show more ]
Rush 213
hero 160
Killer 150
Mind 76
PianO 63
Sea.KH 61
sorry 60
Aegong 58
sSak 49
NotJumperer 44
[sc1f]eonzerg 44
Barracks 40
Shinee 31
GoRush 18
IntoTheRainbow 17
scan(afreeca) 15
Terrorterran 11
Noble 11
SilentControl 11
soO 9
ivOry 8
Rock 6
Britney 1
Dota 2
qojqva3459
League of Legends
JimRising 318
Counter-Strike
fl0m804
markeloff176
byalli58
adren_tv9
Super Smash Bros
Mew2King83
Heroes of the Storm
crisheroes345
Other Games
singsing2651
B2W.Neo1199
hiko744
Lowko447
Hui .235
Fuzer 166
XaKoH 141
QueenE77
ArmadaUGS68
ZerO(Twitch)13
Trikslyr11
Organizations
Dota 2
PGL Dota 2 - Main Stream645
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift2723
• Jankos1671
• TFBlade403
Upcoming Events
Monday Night Weeklies
2h 5m
WardiTV Team League
21h 5m
PiGosaur Cup
1d 9h
Kung Fu Cup
1d 20h
OSC
2 days
The PondCast
2 days
KCM Race Survival
2 days
WardiTV Team League
2 days
Replay Cast
3 days
KCM Race Survival
3 days
[ Show More ]
WardiTV Team League
3 days
Korean StarCraft League
4 days
RSL Revival
4 days
Maru vs Zoun
Cure vs ByuN
uThermal 2v2 Circuit
5 days
BSL
5 days
RSL Revival
5 days
herO vs MaxPax
Rogue vs TriGGeR
BSL
6 days
Replay Cast
6 days
Replay Cast
6 days
Afreeca Starleague
6 days
Sharp vs Scan
Rain vs Mong
Wardi Open
6 days
Liquipedia Results

Completed

Proleague 2026-03-15
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.