• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 02:30
CET 08:30
KST 16:30
  • 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 ZvT28Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (Feb 16-22): MaxPax doubles0Weekly Cups (Feb 9-15): herO doubles up2ACS replaced by "ASL Season Open" - Starts 21/0258LiuLi Cup: 2025 Grand Finals (Feb 10-16)46Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2
StarCraft 2
General
Terran AddOns placement How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Nexon's StarCraft game could be FPS, led by UMS maker ByuL: The Forgotten Master of ZvT Oliveira Would Have Returned If EWC Continued
Tourneys
PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) SEL Doubles (SC Evo Bimonthly) WardiTV Team League Season 10 RSL Season 4 announced for March-April The Dave Testa Open #11
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
Mutation # 514 Ulnar New Year The PondCast: SC2 News & Results Mutation # 513 Attrition Warfare Mutation # 512 Overclocked
Brood War
General
TvZ is the most complete match up BGH Auto Balance -> http://bghmmr.eu/ Soma Explains: JD's Unrelenting Aggro vs FlaSh ACS replaced by "ASL Season Open" - Starts 21/02 BW General Discussion
Tourneys
[Megathread] Daily Proleagues [LIVE] [S:21] ASL Season Open Day 1 ASL Season 21 Qualifiers March 7-8 Small VOD Thread 2.0
Strategy
Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Simple Questions, Simple Answers Zealot bombing is no longer popular?
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Path of Exile Beyond All Reason New broswer game : STG-World
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
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine UK Politics Mega-thread YouTube Thread Mexico's Drug War
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion TL MMA Pick'em Pool 2013
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
YOUTUBE VIDEO
XenOsky
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Inside the Communication of …
TrAiDoS
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2451 users

The Big Programming Thread - Page 656

Forum Index > General Forum
Post a Reply
Prev 1 654 655 656 657 658 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.
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
Poland17677 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
Poland17677 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
Poland17677 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
Poland17677 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
Poland17677 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
Hyrule19193 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
Poland17677 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 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
LiuLi Cup Grand Finals Group B
LiquipediaDiscussion
AI Arena Tournament
20:00
RO8
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft621
SortOf 118
StarCraft: Brood War
GuemChi 3199
ggaemo 258
firebathero 227
ToSsGirL 76
Larva 51
NaDa 16
Dota 2
NeuroSwarm162
League of Legends
JimRising 538
Reynor100
Counter-Strike
Stewie2K1076
Other Games
Mew2King113
Livibee47
RuFF_SC230
Organizations
Other Games
gamesdonequick718
Counter-Strike
PGL318
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• StrangeGG 79
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo1605
Upcoming Events
PiG Sty Festival
1h 30m
Clem vs Serral
Maru vs ShoWTimE
Sparkling Tuna Cup
2h 30m
uThermal 2v2 Circuit
7h 30m
Replay Cast
1d 1h
Wardi Open
1d 4h
Monday Night Weeklies
1d 9h
Replay Cast
1d 16h
Replay Cast
3 days
Replay Cast
3 days
The PondCast
4 days
[ Show More ]
KCM Race Survival
4 days
Replay Cast
4 days
Replay Cast
5 days
CranKy Ducklings
6 days
Replay Cast
6 days
Liquipedia Results

Completed

[S:21] ASL SEASON OPEN 2nd Round
LiuLi Cup: 2025 Grand Finals
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Acropolis #4 - TS5
Jeongseon Sooper Cup
Spring Cup 2026
WardiTV Winter 2026
PiG Sty Festival 7.0
Nations Cup 2026
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025

Upcoming

ASL Season 21: Qualifier #1
ASL Season 21: Qualifier #2
ASL Season 21
Acropolis #4 - TS6
Acropolis #4
IPSL Spring 2026
CSLAN 4
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
NationLESS Cup
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
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.