• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 19:31
CET 01:31
KST 09:31
  • 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
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Dark completes military service, returns to SC211[BSL23] RO16 Group Stage20Weekly Cups (Nov 2-8): herO back on top?2Weekly Cups (Oct 26 - Nov 1): MaxPax, herO, Solar win0Weekly Cups (October 19-25): Clem triples first in 5.0.175
StarCraft 2
General
No more SC2 streamers on team liquid? Dark completes military service, returns to SC2 Greetings.. Serral's getting trashed by New Catsle's Mind Weekly Cups (Nov 2-8): herO back on top?
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Sea Duckling Open (Global, Bronze-Diamond) Dark returns! GSL CK #7 4v4 Team Battle (Nov 19) soO & FanTaSy return! SC2 Kevin Scrim 4v4 (Nov 16) RSL goes to London! 2026 Offline Finals Nov 21-22
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
[G] How to playtest arcade maps Starcraft 2 Advance [D] the control group Simple Questions/Answers
External Content
Mutation # 552 Secret Storm The PondCast: SC2 News & Results Mutation # 551 Robotic Revival Mutation # 550 Graveyard Shift
Brood War
General
Top Players of October 2026 (EBPD Rankings) Starcraft:Brood War Discord Servers [BSL23] RO16 Group Stage New 40-minute movie with Jaedong JyJ SnOw List of top players active on ShieldBattery
Tourneys
[BSL23] Ro16 Group C - Sunday 21:00 CET [$1250] International ShieldBattery League [Megathread] Daily Proleagues [BSL23] Ro16 Group A - Saturday 21:00 CET
Strategy
Pluto's TvP 5Marine 2Medic Push Simple Questions, Simple Answers Infested Terran strategies in 2026 Nuke strategy worked in K-League 2026-11-09
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Free Space RTS Game, optimised f. Phone/Tablet etc List of Game Threads The PlayStation 5
Dota 2
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Artificial Intelligence Thread Trading/Investing Thread European Politico-economics QA Mega-thread
Fan Clubs
Fan Club Resource Thread Reynor Fan Club The Flash Fan Club
Media & Entertainment
Movie Discussion! Anime Discussion Thread [Manga] One Piece
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The time I organised my…
AssyrianKing
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 11759 users

The Big Programming Thread - Page 719

Forum Index > General Forum
Post a Reply
Prev 1 717 718 719 720 721 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.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-04-15 07:12:38
April 15 2016 07:09 GMT
#14361
idk, I used to think exactly like that until I realized that's a stupid way of thinking about it. Just because the language looks similar shouldn't imply that previous ideas from other languages should map onto the new language. If it does, then yay, if it doesn't then sure, it's not the same language, what should I actually be doing? Just remember the first time you learned a language. You knew nothing and made assumptions and had them proven true or false. Now you know stuff that may or may not be relevant to the language, just because some of your assumptions work doesn't mean that they all will.

Essentially it's really our fault when we make implicit assumptions about a language's api calls based off of our own models of what api calls should look like from other languages.

I thought like you did too and circle jerked around Javascript being shitty until I actually used it more than in passing. Eh, it's just like any other language's idiosyncrasies.
There is no one like you in the universe.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 15 2016 08:25 GMT
#14362
On April 15 2016 16:09 Blisse wrote:
idk, I used to think exactly like that until I realized that's a stupid way of thinking about it. Just because the language looks similar shouldn't imply that previous ideas from other languages should map onto the new language. If it does, then yay, if it doesn't then sure, it's not the same language, what should I actually be doing? Just remember the first time you learned a language. You knew nothing and made assumptions and had them proven true or false. Now you know stuff that may or may not be relevant to the language, just because some of your assumptions work doesn't mean that they all will.

Essentially it's really our fault when we make implicit assumptions about a language's api calls based off of our own models of what api calls should look like from other languages.

I thought like you did too and circle jerked around Javascript being shitty until I actually used it more than in passing. Eh, it's just like any other language's idiosyncrasies.


Pretty much that.

JavaScript isn't actually terrible. It has a terrible reputation because of different browser implementations and such, but as a language it's actually pretty nice, just very different. It's much closer to languages like Perl or even Lisp than to "classic" languages like C++.

I used to hate JavaScript with a passion, but the more I accepted it as a language that just requires a different mindset, the more I saw some of the advantages it had. Of course there are still some things I don't like about it, every language has it's problems, but by now I prefer it to PHP by a large margin.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-04-15 08:36:46
April 15 2016 08:35 GMT
#14363
--- Nuked ---
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 15 2016 09:24 GMT
#14364
On April 15 2016 17:35 Nesserev wrote:
There are some things that I like about JavaScript, but there are a lot more things that I hate about it... it really is a shitty language as a whole, but it's a necessary evil if you ever wanna touch a browser, and you can circumvent most shitty things. The worst things that you constantly have to watch out for, are:
- hoisting
- implicit global variables
- only function-scope, no block-scope

There's also the lack of const'ness outside of declaring constant variables, but this is a problem for a lot of languages. Outside of those few things, it's actually an okay language in my opinion.


The first two are the result of poor programming, the function scope is true, though it's not really a problem imho since you'll want to make heavy use of functions and lambdas anyways, e.g. you don't use a for loop but a forEach method that executes a function on each element, so blocks aren't really that relevant.

For global variables you'll want to use the module pattern, which is essentially just

(function(){
// code here
})();

(function(globalVar){
// code using globalVar here
})(globalVar);

// common use:
(function($){
// $ is now always jQuery with no conflict with other libraries using the $ variable
})(jQuery);


That way all variables are scoped inside the module and don't affect the outside unless you use global variables that were defined outside the module.

The one thing that is annoying about JavaScript and even more Node.JS is the potential for callback hell, though there are also methods to avoid or at least reduce that.
BisuDagger
Profile Blog Joined October 2009
Bisutopia19400 Posts
April 15 2016 11:59 GMT
#14365
Are the any unity guys out there who have successful used multiple displays for a game? I need display 1 to be on one monitor and display two on another monitor. I have extensively researched for answers on this and found none.
ModeratorFormer Afreeca Starleague Caster: http://afreeca.tv/ASL2ENG2
Cyx.
Profile Joined November 2010
Canada806 Posts
Last Edited: 2016-04-15 14:34:56
April 15 2016 14:33 GMT
#14366
On April 15 2016 17:35 Nesserev wrote:
There are some things that I like about JavaScript, but there are a lot more things that I hate about it... it really is a shitty language as a whole, but it's a necessary evil if you ever wanna touch a browser, and you can circumvent most shitty things. The worst things that you constantly have to watch out for, are:
- hoisting
- implicit global variables
- only function-scope, no block-scope

There's also the lack of const'ness outside of declaring constant variables, but this is a problem for a lot of languages. Outside of those few things, it's actually an okay language in my opinion.

Well at least ES6 makes two of those problems go away :D and implicit globals aren't possible with 'use strict' either.

edit:
On April 15 2016 18:24 Morfildur wrote:
The first two are the result of poor programming

Disagree strongly that implicit globals hurt you because of 'poor programming' - if you consider 'making typos' to be 'poor programming' I don't think I want to work with you
supereddie
Profile Joined March 2011
Netherlands151 Posts
April 15 2016 16:17 GMT
#14367
On April 15 2016 07:31 Manit0u wrote:
Show nested quote +
On April 13 2016 16:20 supereddie wrote:
On April 12 2016 10:03 Manit0u wrote:

Speaking of DB queries and all... Do you think it would be possible to turn this into a query (PostgreSQL)?


$string = 'AB.6740.D.336.2011.AP';
$regex = '/\.(\D)\./';
$alphabet = range('a', 'z');

preg_match($regex, $string, $matches);

if (!empty($matches)) {
$letter = strtolower($matches[1]);
$num = array_search($letter, $alphabet) + 1;

$string = preg_replace($regex, sprintf('.%d.', $num), $string);
}

echo $string;


This would have to update all the rows of course. The things I have to deal with...

I know that you can do WHERE field *~ '\.(\D)\.', but I'm not sure you can do replaces with regex.

Well, if it is a one-time thing you can just write out the update and do 26 replaces...


The thing is, I need to update over 120k rows in the db, replacing all .[LETTER]. patterns with the corresponding number.

Well, if the pattern is consistent and you're really desperate:

update table set column = left(column, 4) +
case charAt(column, 5)
when '0' then 'A'
when '1' then 'B'
when '2' then 'C'
when '3' then 'D'
...
end +
case charAt(column, 6)
when '0' then 'A'
when '1' then 'B'
when '2' then 'C'
when '3' then 'D'
...
end + ... + ...

I am unfamiliar with PostgreSQL syntax, but this is doable in MS SQL
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
Manit0u
Profile Blog Joined August 2004
Poland17875 Posts
April 15 2016 17:27 GMT
#14368
On April 16 2016 01:17 supereddie wrote:
Show nested quote +
On April 15 2016 07:31 Manit0u wrote:
On April 13 2016 16:20 supereddie wrote:
On April 12 2016 10:03 Manit0u wrote:

Speaking of DB queries and all... Do you think it would be possible to turn this into a query (PostgreSQL)?


$string = 'AB.6740.D.336.2011.AP';
$regex = '/\.(\D)\./';
$alphabet = range('a', 'z');

preg_match($regex, $string, $matches);

if (!empty($matches)) {
$letter = strtolower($matches[1];
$num = array_search($letter, $alphabet) + 1;

$string = preg_replace($regex, sprintf('.%d.', $num), $string);
}

echo $string;


This would have to update all the rows of course. The things I have to deal with...

I know that you can do WHERE field *~ '\.(\D)\.', but I'm not sure you can do replaces with regex.

Well, if it is a one-time thing you can just write out the update and do 26 replaces...


The thing is, I need to update over 120k rows in the db, replacing all .[LETTER]. patterns with the corresponding number.

Well, if the pattern is consistent and you're really desperate:

update table set column = left(column, 4) +
case charAt(column, 5)
when '0' then 'A'
when '1' then 'B'
when '2' then 'C'
when '3' then 'D'
...
end +
case charAt(column, 6)
when '0' then 'A'
when '1' then 'B'
when '2' then 'C'
when '3' then 'D'
...
end + ... + ...

I am unfamiliar with PostgreSQL syntax, but this is doable in MS SQL


The pattern is consistent but the ".A." stuff won't be at the same spot all the time since everything inbetween the dots is variable and depends on gazillion things.
Time is precious. Waste it wisely.
Erasme
Profile Blog Joined February 2011
Bahamas15899 Posts
Last Edited: 2016-04-16 02:53:22
April 16 2016 02:31 GMT
#14369
i am sure i will figure eveyrthing out
its pretty basic
https://www.youtube.com/watch?v=d7lxwFEB6FI “‘Drain the swamp’? Stupid saying, means nothing, but you guys loved it so I kept saying it.”
lilwisper
Profile Joined April 2010
United States2515 Posts
Last Edited: 2016-04-16 02:47:26
April 16 2016 02:42 GMT
#14370
Okay I am 99% through this bit of a batch file for changing the default folders in Sketchup 2016. The batch file changes several registry values. For sake of focus I am just placing the 1% that I am having trouble with in the following code block:



set key="HKCU\Software\Sketchup\Sketchup 2016\File Locations"

set sketchpart1=%USERPROFILE%

set sketchpart1=%sketchpart1:\=\\%

set sketchloc2="\"%sketchpart1%\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\""

reg add %key% /v Classifications /d %sketchloc2% /f



Now if you run this in a batch, it changes the key just fine, no syntax errors or such. However if you open Sketchup 2016, you get an error saying that there is trouble with one of the default paths. After you go to the place it points to, you see one of the paths surrounded in red. Inspection of the offending path shows as:

"C_\users\lilwisper\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications\

I know I have to change the set sketchloc2 portion of my code, I just can't think of the way to change it to make it appear properly inside of Sketchup 2016.
Ropid
Profile Joined March 2009
Germany3557 Posts
Last Edited: 2016-04-16 12:17:44
April 16 2016 09:44 GMT
#14371
In what you see, I don't know where the "_" comes from instead of ":". The text it builds should be this:

\"C:\\user\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\"


The question I have is, is this correct with all those \" and \\ instead of just " and \?

You can play with all of this on the command line prompt. Like, you can do this here:

> echo %USERPROFILE%
C:\users\lilwisper

> echo %USERPROFILE:\=\\%
C:\\users\\lilwisper

> echo "%USERPROFILE%"
"C:\users\lilwisper"

> echo "\"%USERPROFILE:\=\\%\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\""
"\"C:\\users\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\""


What I wonder is, are you sure you don't want just this here:

> echo "%USERPROFILE%\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications"               
"C:\users\lilwisper\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications"


You could also take a look at what 'reg query' outputs after you have manually set up the path in SketchUp's menus, to compare with what you are trying to do in your batch file. I think it would be this:

> set key="HKCU\Software\Sketchup\Sketchup 2016\File Locations"

> reg query %key% /v Classifications
"My goal is to replace my soul with coffee and become immortal."
lilwisper
Profile Joined April 2010
United States2515 Posts
April 16 2016 11:15 GMT
#14372
On April 16 2016 18:44 Ropid wrote:
In what you see, I don't know where the "_" comes from instead of ":". The text it builds should be this:

\"C:\\user\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\"


The question I have is, is this correct with all those \" and \\ instead of just " and \?

You can play with all of this on the command line prompt. Like, you can do this here:

> echo %USERPROFILE%
C:\users\lilwisper

> echo %USERPROFILE:\=\\%
C:\\users\\lilwisper


> echo "%USERPROFILE%"
"C:\users\lilwisper"

> echo "\"%USERPROFILE:\=\\%\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\""
"\"C:\\users\\lilwisper\\AppData\\Roaming\\SketchUp\\SketchUp 2016\\SketchUp\\Classifications\""

What I wonder is, are you sure you don't want just this here:

> echo "%USERPROFILE%\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications"               
"C:\users\lilwisper\AppData\Roaming\SketchUp\SketchUp 2016\SketchUp\Classifications"


You could also take a look at what 'reg query' outputs after you have manually set up the path in SketchUp's menus, to compare with what you are trying to do in your batch file. I think it would be this:

> set key="HKCU\Software\Sketchup\Sketchup 2016\File Locations"

> reg query %key% /v Classifications
[/code]

As far as I read online, the string the current code builds is the one needed to have it pass the reg command correctly. It is due to the space in the path. The slashes and quotes all need to be escaped so that the string builds properly.
xtorn
Profile Blog Joined December 2013
4067 Posts
April 16 2016 19:44 GMT
#14373
<3 good times

+ Show Spoiler +
<3 things - Life | Kane | Innovation | Scarlett | Solar | MMA
waffelz
Profile Blog Joined June 2012
Germany711 Posts
Last Edited: 2016-04-17 20:36:16
April 17 2016 20:32 GMT
#14374
...Here I sit, explaining a 4.th semester computer science student why

Classname1.doSomethingWhichAccessesAttributes();

doesn't work, only to get asked by the same student just a bit later why

Classname1 myClass = Classname2.doSomethingWhichAccessesAttributes();

doesn’t work...

I am not a big fan of java myself, but at least it saves me from always answering the same questions regarding pointers and references... and this particularly mistake has nothing to do with any of javas quirks.
RIP "The big travis CS degree thread", taken from us too soon | Honourable forum princess, defended by Rebs-approved white knights
solidbebe
Profile Blog Joined November 2010
Netherlands4921 Posts
April 17 2016 20:40 GMT
#14375
Hmm, if for some reason your programme doesnt really teach any OOP I can get why a student would into static vs instance confusion. If you do get OOP stuff then that guy is one of those few students who arent capable of anything but still manage to stick around somehow .
That's the 2nd time in a week I've seen someone sig a quote from this GD and I have never witnessed a sig quote happen in my TL history ever before. -Najda
waffelz
Profile Blog Joined June 2012
Germany711 Posts
April 17 2016 20:45 GMT
#14376
He had OOP since the very first semester
RIP "The big travis CS degree thread", taken from us too soon | Honourable forum princess, defended by Rebs-approved white knights
Wrath
Profile Blog Joined July 2014
3176 Posts
April 17 2016 20:49 GMT
#14377
On April 18 2016 05:40 solidbebe wrote:
Hmm, if for some reason your programme doesnt really teach any OOP I can get why a student would into static vs instance confusion. If you do get OOP stuff then that guy is one of those few students who arent capable of anything but still manage to stick around somehow .


... I was like him one day... But now I get it...
Acrofales
Profile Joined August 2010
Spain18501 Posts
April 18 2016 01:17 GMT
#14378
On April 18 2016 05:45 waffelz wrote:
He had OOP since the very first semester

Hit him over the head with an object and tell him you couldn't do that if you were static
lilwisper
Profile Joined April 2010
United States2515 Posts
April 18 2016 02:31 GMT
#14379
On April 18 2016 10:17 Acrofales wrote:
Show nested quote +
On April 18 2016 05:45 waffelz wrote:
He had OOP since the very first semester

Hit him over the head with an object and tell him you couldn't do that if you were static


I have to laugh at this one. Good example. Lol
waffelz
Profile Blog Joined June 2012
Germany711 Posts
April 18 2016 07:35 GMT
#14380
On April 18 2016 10:17 Acrofales wrote:
Show nested quote +
On April 18 2016 05:45 waffelz wrote:
He had OOP since the very first semester

Hit him over the head with an object and tell him you couldn't do that if you were static


Already did that to a fellow student of his. Doesn’t really help them with understanding the problem but it helps myself a lot… Can highly recommend this to keep your insanity to normal levels while tutoring/lecturing.
RIP "The big travis CS degree thread", taken from us too soon | Honourable forum princess, defended by Rebs-approved white knights
Prev 1 717 718 719 720 721 1032 Next
Please log in or register to reply.
Live Events Refresh
BSL
05:00
S23 - Ro16 Group C
TBD vs Dewalt
Ret vs Tech
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Rain 1716
GuemChi 1678
Artosis 693
Dewaltoss 102
Dota 2
monkeys_forever232
NeuroSwarm151
Super Smash Bros
C9.Mang0624
AZ_Axe91
ArmadaUGS87
Mew2King39
Other Games
summit1g10523
tarik_tv5248
Liquid`RaSZi2544
JimRising 507
PiGStarcraft307
syndereN181
ViBE51
Organizations
Other Games
gamesdonequick2780
BasetradeTV142
[ Show 14 non-featured ]
StarCraft 2
• Hupsaiya 102
• RyuSc2 60
• musti20045 42
• davetesta28
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• imaqtpie958
• Shiphtur300
Upcoming Events
SOOP
9h 29m
soO vs FanTaSy
WardiTV Weekly
11h 29m
Replay Cast
22h 29m
Monday Night Weeklies
1d 16h
PiGosaur Cup
2 days
The PondCast
2 days
GSL
3 days
Replay Cast
3 days
KCM Race Survival
4 days
RSL Revival
5 days
[ Show More ]
BSL
5 days
eOnzErG vs StRyKeR
Cross vs JDConan
RSL Revival
6 days
BSL
6 days
Bonyth vs Doodle
Kyrie vs Jimin
Replay Cast
6 days
Liquipedia Results

Completed

Individual League
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
YSL S4
Calamity Cup Div. A Season 8
Underdog Cup 2026 Div 2-3
BLAST Rivals Fall 2026
IEM Beijing 2026
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026

Upcoming

Sector 591
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
StarCraft2 Weekly Open Tournament 2026 Grand Finals
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
IEM Kraków 2027
PGL Bucharest 2027
BLAST Bounty Winter 2027
PGL Major Singapore 2026
Stake Ranked Episode 6
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.