• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 02:46
CET 08:46
KST 16:46
  • 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 Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
SC2 All-Star Invitational: Jan 17-1815Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises2Weekly Cups (Dec 15-21): Classic wins big, MaxPax & Clem take weeklies3ComeBackTV's documentary on Byun's Career !11Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win4
StarCraft 2
General
SC2 All-Star Invitational: Jan 17-18 Weekly Cups (Dec 22-28): Classic & MaxPax win, Percival surprises Chinese SC2 server to reopen; live all-star event in Hangzhou Starcraft 2 Zerg Coach ComeBackTV's documentary on Byun's Career !
Tourneys
OSC Season 13 World Championship $5,000+ WardiTV 2025 Championship $100 Prize Pool - Winter Warp Gate Masters Showdow Sparkling Tuna Cup - Weekly Open Tournament Winter Warp Gate Amateur Showdown #1
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes Mutation # 504 Retribution Mutation # 503 Fowl Play
Brood War
General
I would like to say something about StarCraft (UMS) SWITCHEROO *New* /Destination Edit/ BGH Auto Balance -> http://bghmmr.eu/ What monitor do you use for playing Remastered? BW General Discussion
Tourneys
[BSL21] Grand Finals - Sunday 21:00 CET SLON Grand Finals – Season 2 [Megathread] Daily Proleagues [BSL21] LB SemiFinals - Saturday 21:00 CET
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Game Theory for Starcraft Current Meta
Other Games
General Games
Nintendo Switch Thread Awesome Games Done Quick 2026! Stormgate/Frost Giant Megathread Mechabellum 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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia
Community
General
US Politics Mega-thread Canadian Politics Mega-thread The Games Industry And ATVI Russo-Ukrainian War Thread 12 Days of Starcraft
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced Where to ask questions and add stream?
Blogs
National Diversity: A Challe…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1503 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
Poland17554 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
Poland17554 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
Poland17554 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
Poland17554 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
Poland17554 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
Hyrule19185 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
Poland17554 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
Next event in 1d 5h
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
trigger 0
StarCraft: Brood War
actioN 336
PianO 171
ZergMaN 153
Shuttle 144
Hyun 110
Nal_rA 49
Noble 25
Dota 2
febbydoto155
NeuroSwarm129
League of Legends
C9.Mang0632
Other Games
Mew2King34
Organizations
Other Games
gamesdonequick890
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH165
• practicex 46
• Adnapsc2 1
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 57
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• HappyZerGling137
Upcoming Events
OSC
1d 5h
Korean StarCraft League
1d 19h
OSC
2 days
IPSL
2 days
Dewalt vs Bonyth
OSC
2 days
OSC
3 days
uThermal 2v2 Circuit
3 days
Replay Cast
4 days
Patches Events
4 days
Liquipedia Results

Completed

C-Race Season 1
WardiTV 2025
META Madness #9

Ongoing

IPSL Winter 2025-26
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 2
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025

Upcoming

Escore Tournament S1: W2
CSL 2025 WINTER (S19)
Escore Tournament S1: W3
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Thunderfire SC2 All-star 2025
Big Gabe Cup #3
OSC Championship Season 13
Nations Cup 2026
Underdog Cup #3
NA Kuram Kup
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.