• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:10
CEST 20:10
KST 03:10
  • 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 ASL50Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation The GOAT ranking of GOAT rankings How does the number of casters affect your enjoyment of esports? Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster
Tourneys
Master Swan Open (Global Bronze-Master 2) RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event
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
BGH Auto Balance -> http://bghmmr.eu/ Player “Jedi” cheat on CSL Unit and Spell Similarities Help: rep cant save Flash Announces Hiatus From ASL
Tourneys
[Megathread] Daily Proleagues [BSL20] Grand Finals - Sunday 20:00 CET 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
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile 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 Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread 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
Formula 1 Discussion 2024 - 2025 Football Thread 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: 764 users

The Big Programming Thread - Page 656

Forum Index > General Forum
Post a Reply
Prev 1 654 655 656 657 658 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.
bangsholt
Profile Joined June 2011
Denmark138 Posts
August 03 2015 14:56 GMT
#13101
If you want to do web development with C#, go look at Web API / ASP.NET MVC (Which is now merged into the same) - learn how the Razor Views work (it's a simple templating language), look at Nancy to get a different idea of how to do web in C#.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
August 04 2015 18:15 GMT
#13102
Guys how are you even supposed to print that?


#include <iostream>
#include <io.h>
#include <fcntl.h>

int wmain(int argc, wchar_t* argv[])
{
_setmode(_fileno(stdout), _O_U16TEXT);
std::wcout << L"Testing unicode -- English -- Ελληνικά -- Español." << std::endl;
}


It doesn't work at all even if it's wcout. Could it be because of my Windows font? If yes, isn't there a more cross-platform solution? I don't know how C# does it but no problems with its encoding at all.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2015-08-04 19:35:36
August 04 2015 19:28 GMT
#13103
On August 05 2015 03:15 darkness wrote:
Guys how are you even supposed to print that?


#include <iostream>
#include <io.h>
#include <fcntl.h>

int wmain(int argc, wchar_t* argv[])
{
_setmode(_fileno(stdout), _O_U16TEXT);
std::wcout << L"Testing unicode -- English -- Ελληνικά -- Español." << std::endl;
}


It doesn't work at all even if it's wcout. Could it be because of my Windows font? If yes, isn't there a more cross-platform solution? I don't know how C# does it but no problems with its encoding at all.


Are you doing this in Windows terminal? This might help. Or possibly this.

Also, I wouldn't use U16TEXT for that, U8TEXT (which should be standard cout since it's utf-8 by default, at least on Linux) or WTEXT should do the trick for you.

Edit:

Getting cyrillic to work according to MSDN.


// crt_setmodeunicode.c
// This program uses _setmode to change
// stdout to Unicode. Cyrillic and Ideographic
// characters will appear on the console (if
// your console font supports those character sets).

#include <fcntl.h>
#include <io.h>
#include <stdio.h>

int main(void) {
_setmode(_fileno(stdout), _O_U16TEXT);
wprintf(L"\x043a\x043e\x0448\x043a\x0430 \x65e5\x672c\x56fd\n");
return 0;
}
Time is precious. Waste it wisely.
Ropid
Profile Joined March 2009
Germany3557 Posts
Last Edited: 2015-08-05 14:33:57
August 05 2015 01:16 GMT
#13104
On Linux, just this works because UTF-8 is char*:

#include <iostream>

int main (char argc, char** argv)
{
std::cout << "Testing unicode -- English -- Ελληνικά -- Español." << std::endl;
return 0;
}


The terminal treats text as UTF-8 for most people nowadays, so it will display correctly.

Again, I only know this for Linux:

Wide-char needs configuration before it works right. The thing with wide-char strings is that they need to be converted to char* for output. You need to configure a locale for this to work right. The default locale is "C" and can only do ASCII and the special characters from the wide-char string will get dropped. To make the program use the user's real locale is this:

#include <iostream>
#include <locale>

int main(int argc, char** argv)
{
using namespace std;
locale::global(locale(""));
wcout << L"Testing unicode -- English -- Ελληνικά -- Español." << endl;
return 0;
}


You can't mix cout and wcout use. It leads to undefined behavior and the wchar stuff won't work (at least that's what happens here for me).

I think this is POSIX, so it might be the same rules on Windows?
"My goal is to replace my soul with coffee and become immortal."
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
August 05 2015 11:20 GMT
#13105
--- Nuked ---
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
August 06 2015 07:00 GMT
#13106
Can anyone tell me some other sites like DZone?
"windows bash is a steaming heap of shit" tofucake
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
August 06 2015 07:48 GMT
#13107
On August 06 2015 16:00 Djagulingu wrote:
Can anyone tell me some other sites like DZone?


It doesn't seem like a very good site... Have you tried slashdot yet?
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
August 08 2015 12:42 GMT
#13108
I just got out of a php programming interview where I got 3 questions out of 4. And i don't know shit about php. I fucking nailed it.
"windows bash is a steaming heap of shit" tofucake
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
August 08 2015 17:05 GMT
#13109
On August 08 2015 21:42 Djagulingu wrote:
I just got out of a php programming interview where I got 3 questions out of 4. And i don't know shit about php. I fucking nailed it.


Do you remember the questions?
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
August 09 2015 00:13 GMT
#13110
On August 09 2015 02:05 Manit0u wrote:
Show nested quote +
On August 08 2015 21:42 Djagulingu wrote:
I just got out of a php programming interview where I got 3 questions out of 4. And i don't know shit about php. I fucking nailed it.


Do you remember the questions?

They gave me this huge fucking ass project and asked me to:

1- Fix a table which is just plain html table as a string in php code, elements are obtained from a sql query, table is generated in a method using a fucking awful lot of for each-es. That was the question I couldn't solve.

2- Remove autocomplete from an element of a search form. Element was given autocomplete off as seen in "inspect element" and autocomplete exception in the php code. I removed the exception.

3- Add another field in the search form in #2. Copy-paste another field and change the name of the field. Easy.

4- There is a table in which you can select multiple rows, table showing sales totals, there is a button called SUM, takes the sales amount in usd, sums it and adds it in the table. Question is to implement another button, doing exactly what SUM button does, but without converting to usd. Table has sales amount, sales amount in usd columns seperately. Button makes an ajax call to another php page, I go there, copy the code, paste it right below, do some edits and BA-BAM.
"windows bash is a steaming heap of shit" tofucake
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
August 09 2015 02:31 GMT
#13111
On August 09 2015 09:13 Djagulingu wrote:
1- Fix a table which is just plain html table as a string in php code, elements are obtained from a sql query, table is generated in a method using a fucking awful lot of for each-es. That was the question I couldn't solve.


When I see HTML being constructed as a string inside of PHP I want to murder people
Time is precious. Waste it wisely.
Mindcrime
Profile Joined July 2004
United States6899 Posts
August 09 2015 03:21 GMT
#13112
On August 09 2015 11:31 Manit0u wrote:
Show nested quote +
On August 09 2015 09:13 Djagulingu wrote:
1- Fix a table which is just plain html table as a string in php code, elements are obtained from a sql query, table is generated in a method using a fucking awful lot of for each-es. That was the question I couldn't solve.


When I see HTML being constructed as a string inside of PHP I want to murder people


What about when you see it done outside of PHP?

I'm responsible for an automated report that goes out to multiple business analysts daily that does basically this... but with VB.NET. Maintaining it definitely makes me want to murder people.
That wasn't any act of God. That was an act of pure human fuckery.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
August 09 2015 09:20 GMT
#13113
On August 09 2015 11:31 Manit0u wrote:
Show nested quote +
On August 09 2015 09:13 Djagulingu wrote:
1- Fix a table which is just plain html table as a string in php code, elements are obtained from a sql query, table is generated in a method using a fucking awful lot of for each-es. That was the question I couldn't solve.


When I see HTML being constructed as a string inside of PHP I want to murder people

The dude, who happens to be the boss of the 25-people startup I went to the quiz for, said before the start of the quiz these exact words: "As you would guess, nobody ever constructs html tables as a string inside php, but this code is written this way just to see how good the attendant's debugging skills are".

Well, facing a huge fuckin ass string of tds, trs and shit with no debugging tools besides echo and console.log. I wanted to kill the guy and rape his corpse just to show my frustration.
"windows bash is a steaming heap of shit" tofucake
Birdie
Profile Blog Joined August 2007
New Zealand4438 Posts
August 09 2015 09:23 GMT
#13114
On August 09 2015 11:31 Manit0u wrote:
Show nested quote +
On August 09 2015 09:13 Djagulingu wrote:
1- Fix a table which is just plain html table as a string in php code, elements are obtained from a sql query, table is generated in a method using a fucking awful lot of for each-es. That was the question I couldn't solve.


When I see HTML being constructed as a string inside of PHP I want to murder people

As someone who has only dabbled in PHP and HTML (and have formed HTML using echos) how should you construct tables and so on in a PHP view without using PHP to construct the HTML in a string?
Red classic | A butterfly dreamed he was Zhuangzi | 4.5k, heading to 5k as support!
Nerchio
Profile Joined October 2009
Poland2633 Posts
August 09 2015 10:47 GMT
#13115
Any suggestions considering I'd like to play around some AI in one of the languages since I know enough in all of them to do something simple - Java/ C# or C++/ maybe Python. Mostly basics at first like movement alghoritms(A and others). What would be the best way to go around that? I'd prefer it to be a way to learn 2D games.
Progamer"I am the best" - Nerchio , 2017.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2015-08-09 12:21:24
August 09 2015 12:14 GMT
#13116
On August 09 2015 18:23 Birdie wrote:
Show nested quote +
On August 09 2015 11:31 Manit0u wrote:
On August 09 2015 09:13 Djagulingu wrote:
1- Fix a table which is just plain html table as a string in php code, elements are obtained from a sql query, table is generated in a method using a fucking awful lot of for each-es. That was the question I couldn't solve.


When I see HTML being constructed as a string inside of PHP I want to murder people

As someone who has only dabbled in PHP and HTML (and have formed HTML using echos) how should you construct tables and so on in a PHP view without using PHP to construct the HTML in a string?


You mean something like that?


<table>
<thead>
<tr>
<?php
foreach ($table['headers'] as $header) {
echo sprintf('<th>%s</th>', $header);
}
?>
</tr>
</thead>
<tbody>
<?php
foreach ($table['rows'] as $row) {
echo '<tr>';
foreach ($row as $column) {
echo sprintf('<td>%s</td>', $column);
}
echo '</tr>';
}
?>
</tbody>
</table>


Or constructing the entire table as a string inside of backend php code and then echoing the entire table?

Above stuff would be acceptable if not for the existence of templating engines which keep your views free of PHP (you can read up on Twig or Blade if you want). Nowadays you do it so that your pages are html, not php (even though you write in php).

I'm not even sure I wrote a working code above... All I write now is stuff like that (same thing as above, but using modern standards and Twig):


<table>
<thead>
<tr>
{% for header in headers %}
<th>{{ header }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
{% for column in row.columns %}
<td>{{ column }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>


It's much easier to work with for the front-end people too.

You can check out more here
Time is precious. Waste it wisely.
Sufficiency
Profile Blog Joined October 2010
Canada23833 Posts
August 09 2015 13:56 GMT
#13117
Suppose there is an existing program that runs on the command line and gives one line of output every second. I want to write a Python script which intercepts the output from the first program line by line, analyze/modify it, then output something slightly different. How should I approach this problem? I only need this to work on Linux.
https://twitter.com/SufficientStats
tofucake
Profile Blog Joined October 2009
Hyrule19030 Posts
August 09 2015 14:20 GMT
#13118
firstprogram > script.py

that'll dump the output from firstprogram into your script, then your script can do whatever it does and output its own thing
Liquipediaasante sana squash banana
Sufficiency
Profile Blog Joined October 2010
Canada23833 Posts
August 09 2015 14:27 GMT
#13119
On August 09 2015 23:20 tofucake wrote:
firstprogram > script.py

that'll dump the output from firstprogram into your script, then your script can do whatever it does and output its own thing


That will just overwrite my script

The best I can think of right now is:


firstprogram | xargs -I {} python script.py -i {}


This works. But for some strange reason, the following doesn't work too well because there are considerable lags:


firstprogram | grep 123 | xargs -I {} python script.py -i {}
https://twitter.com/SufficientStats
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
August 09 2015 14:43 GMT
#13120
On August 09 2015 23:27 Sufficiency wrote:
Show nested quote +
On August 09 2015 23:20 tofucake wrote:
firstprogram > script.py

that'll dump the output from firstprogram into your script, then your script can do whatever it does and output its own thing


That will just overwrite my script

The best I can think of right now is:


firstprogram | xargs -I {} python script.py -i {}


This works. But for some strange reason, the following doesn't work too well because there are considerable lags:


firstprogram | grep 123 | xargs -I {} python script.py -i {}


https://docs.python.org/2/library/subprocess.html
Time is precious. Waste it wisely.
Prev 1 654 655 656 657 658 1031 Next
Please log in or register to reply.
Live Events Refresh
Big Brain Bouts
16:00
#97
RotterdaM696
Liquipedia
FEL
16:00
Polish Championship: Qualifier
IndyStarCraft 227
CranKy Ducklings77
Liquipedia
WardiTV European League
16:00
Swiss Groups Day 2
YoungYakov vs ShamelessLIVE!
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
WardiTV851
TKL 253
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 696
TKL 253
IndyStarCraft 227
Hui .187
UpATreeSC 75
StarCraft: Brood War
Britney 30653
Calm 3783
Rain 2340
Horang2 881
Larva 458
BeSt 232
Mind 182
Movie 82
Mong 70
sas.Sziky 48
[ Show more ]
Barracks 47
Shinee 33
yabsab 32
soO 20
Free 19
Shine 13
Dewaltoss 9
Stormgate
NightEnD11
Dota 2
Gorgc12841
qojqva3066
League of Legends
Grubby3721
singsing2104
Counter-Strike
ScreaM2894
fl0m1629
Foxcn349
Other Games
FrodaN1291
Beastyqt605
Fuzer 255
Trikslyr62
ZombieGrub22
Nathanias14
Organizations
Other Games
BasetradeTV24
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV532
League of Legends
• Nemesis5061
• Jankos1520
• TFBlade1080
Other Games
• imaqtpie893
• Shiphtur384
Upcoming Events
Korean StarCraft League
8h 50m
CranKy Ducklings
15h 50m
RSL Revival
15h 50m
ByuN vs Cham
herO vs Reynor
FEL
21h 50m
RSL Revival
1d 15h
Clem vs Classic
SHIN vs Cure
FEL
1d 17h
BSL: ProLeague
1d 23h
Dewalt vs Bonyth
Replay Cast
3 days
Sparkling Tuna Cup
3 days
The PondCast
4 days
[ Show More ]
Replay Cast
5 days
RSL Revival
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
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.