• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 04:33
CET 10:33
KST 18:33
  • 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
TL.net Map Contest #21: Winners11Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation4Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
[TLMC] Fall/Winter 2025 Ladder Map Rotation Mech is the composition that needs teleportation t Weekly Cups (Nov 3-9): Clem Conquers in Canada Craziest Micro Moments Of All Time? SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $5,000+ WardiTV 2025 Championship Merivale 8 Open - LAN - Stellar Fest
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
Rapidtags: The Ultimate Tool for Hashtag and Keywo Terran 1:35 12 Gas Optimization FlaSh on: Biggest Problem With SnOw's Playstyle BW General Discussion BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET [ASL20] Grand Finals [Megathread] Daily Proleagues
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Should offensive tower rushing be viable in RTS games? Path of Exile Dawn of War IV
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
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread The Games Industry And ATVI
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
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
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
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: 1201 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
Poland17428 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
Poland17428 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
Poland17428 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
Poland17428 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
Poland17428 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
Hyrule19151 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
Poland17428 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
09:00
WardiTV Mondays #59
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 299
StarCraft: Brood War
Britney 49000
Rain 2987
Hyuk 2893
Soma 360
Backho 327
Rush 213
Pusan 117
JulyZerg 53
sSak 31
zelot 14
[ Show more ]
NaDa 12
Noble 11
ZerO 10
Hm[arnc] 8
Terrorterran 6
Dota 2
XaKoH 419
XcaliburYe147
Counter-Strike
fl0m1798
olofmeister656
shoxiejesuss411
oskar63
Super Smash Bros
Mew2King237
Other Games
ceh9502
Happy284
Pyrionflax116
ZerO(Twitch)4
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH250
• LUISG 22
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Rush1347
• Stunt515
Upcoming Events
OSC
1h 57m
Kung Fu Cup
2h 27m
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
13h 27m
The PondCast
1d
RSL Revival
1d
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
1d 2h
WardiTV Korean Royale
1d 2h
PiGosaur Monday
1d 15h
RSL Revival
2 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
2 days
[ Show More ]
CranKy Ducklings
3 days
RSL Revival
3 days
herO vs Gerald
ByuN vs SHIN
Kung Fu Cup
3 days
IPSL
3 days
ZZZero vs rasowy
Napoleon vs KameZerg
BSL 21
3 days
Tarson vs Julia
Doodle vs OldBoy
eOnzErG vs WolFix
StRyKeR vs Aeternum
Sparkling Tuna Cup
4 days
RSL Revival
4 days
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
4 days
WardiTV Korean Royale
4 days
BSL 21
4 days
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
4 days
Dewalt vs WolFix
eOnzErG vs Bonyth
Wardi Open
5 days
Monday Night Weeklies
5 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

Proleague 2025-11-07
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
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
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
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.