• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 02:59
CEST 08:59
KST 15:59
  • 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
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL61Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event20Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Statistics for vetoed/disliked maps Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series Korean Starcraft League Week 77 Master Swan Open (Global Bronze-Master 2) [GSL 2025] Code S: Season 2 - Semi Finals & Finals
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Flash Announces Hiatus From ASL Player “Jedi” cheat on CSL ASL20 Preliminary Maps SC uni coach streams logging into betting site BGH Mineral Boosts Tutorial Video
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Trading/Investing Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 534 users

The Big Programming Thread - Page 719

Forum Index > General Forum
Post a Reply
Prev 1 717 718 719 720 721 1031 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
Bisutopia19229 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
Poland17243 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
Spain17970 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 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 3h 1m
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Leta 594
Larva 324
Barracks 53
Dota 2
XaKoH 608
League of Legends
JimRising 745
Counter-Strike
Stewie2K1027
Heroes of the Storm
Khaldor237
Other Games
WinterStarcraft650
SortOf103
kaitlyn77
ProTech53
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• Berry_CruncH367
• Hupsaiya 91
• Sammyuel 42
• Kozan
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• lizZardDota2175
League of Legends
• Lourlo1363
• masondota2816
• Stunt507
Upcoming Events
RSL Revival
3h 1m
Clem vs Classic
SHIN vs Cure
FEL
5h 1m
WardiTV European League
5h 1m
BSL: ProLeague
11h 1m
Dewalt vs Bonyth
Replay Cast
1d 17h
Sparkling Tuna Cup
2 days
WardiTV European League
2 days
The PondCast
3 days
Replay Cast
3 days
RSL Revival
4 days
[ Show More ]
Replay Cast
4 days
RSL Revival
5 days
FEL
5 days
RSL Revival
6 days
FEL
6 days
FEL
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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.