• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 02:47
CET 08:47
KST 16:47
  • 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
RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13
Community News
RSL Season 3: RO16 results & RO8 bracket0Weekly Cups (Nov 10-16): Reynor, Solar lead Zerg surge1[TLMC] Fall/Winter 2025 Ladder Map Rotation14Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA9
StarCraft 2
General
GM / Master map hacker and general hacking and cheating thread RSL Season 3: RO16 results & RO8 bracket Mech is the composition that needs teleportation t SC: Evo Complete - Ranked Ladder OPEN ALPHA RotterdaM "Serral is the GOAT, and it's not close"
Tourneys
Constellation Cup - Main Event - Stellar Fest 2025 RSL Offline Finals Dates + Ticket Sales! $5,000+ WardiTV 2025 Championship RSL Revival: Season 3 Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 500 Fright night Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle What happened to TvZ on Retro? BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review BW General Discussion
Tourneys
[BSL21] GosuLeague T1 Ro16 - Tue & Thu 22:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO32 Group D - Sunday 21:00 CET
Strategy
Current Meta How to stay on top of macro? PvZ map balance Simple Questions, Simple Answers
Other Games
General Games
Clair Obscur - Expedition 33 Beyond All Reason Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
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
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI About SC2SEA.COM
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2322 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
Bisutopia19299 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
Poland17440 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
4060 Posts
April 16 2016 19:44 GMT
#14373
<3 good times

+ Show Spoiler +
Life - forever the Legend in my heart
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
3174 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
Spain18125 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
Next event in 2h 13m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech127
SortOf 114
Trikslyr31
StarCraft: Brood War
Sea 3931
Free 553
BeSt 385
Zeus 241
Killer 237
EffOrt 138
Sharp 44
Shinee 27
NotJumperer 19
Hm[arnc] 11
Dota 2
monkeys_forever690
League of Legends
JimRising 557
Reynor97
Counter-Strike
Coldzera 1454
Other Games
summit1g11921
C9.Mang0208
Happy92
Fuzer 41
rGuardiaN36
Dewaltoss15
Organizations
Dota 2
PGL Dota 2 - Main Stream1180
Other Games
gamesdonequick602
StarCraft: Brood War
UltimateBattle 106
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Berry_CruncH59
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Rush1878
Upcoming Events
The PondCast
2h 13m
Replay Cast
15h 13m
RSL Revival
23h 43m
herO vs Zoun
Classic vs Reynor
Maru vs SHIN
MaxPax vs TriGGeR
BSL: GosuLeague
1d 13h
RSL Revival
1d 23h
WardiTV Korean Royale
2 days
RSL Revival
2 days
WardiTV Korean Royale
3 days
IPSL
3 days
Julia vs Artosis
JDConan vs DragOn
RSL Revival
3 days
[ Show More ]
Wardi Open
4 days
IPSL
4 days
StRyKeR vs OldBoy
Sziky vs Tarson
Replay Cast
4 days
Monday Night Weeklies
5 days
Replay Cast
5 days
Wardi Open
6 days
Liquipedia Results

Completed

Proleague 2025-11-16
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
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 © 2025 TLnet. All Rights Reserved.