• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:58
CEST 16:58
KST 23:58
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence6Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
Weekly Cups (Sept 8-14): herO & MaxPax split cups3WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia7Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29LiuLi Cup - September 2025 Tournaments3
StarCraft 2
General
#1: Maru - Greatest Players of All Time Team Liquid Map Contest #21 - Presented by Monster Energy Weekly Cups (Sept 8-14): herO & MaxPax split cups SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament WardiTV TL Team Map Contest #5 Tournaments Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series SC4ALL $6,000 Open LAN in Philadelphia
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ro16 Preview Pt2: Turbulence Diplomacy, Cosmonarchy Edition BW General Discussion ASL20 General Discussion
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread General RTS Discussion Thread Nintendo Switch Thread Borderlands 3
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread The Big Programming Thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1435 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
Poland17341 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
Poland17341 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
Poland17341 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
Poland17341 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
Poland17341 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
Hyrule19086 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
Poland17341 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
OSC
13:00
King of the Hill #225
iHatsuTV 23
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Creator 273
ProTech85
Codebar 26
StarCraft: Brood War
Calm 9585
Rain 4305
Hyuk 3296
Bisu 3116
GuemChi 2584
Flash 2154
Zeus 1592
Horang2 1540
PianO 1341
EffOrt 903
[ Show more ]
Mini 627
BeSt 554
ZerO 221
Soulkey 165
Snow 129
hero 128
Aegong 115
Backho 106
ggaemo 105
Hyun 103
Mong 77
Mind 75
Rush 70
Sea.KH 60
Movie 57
JYJ47
soO 40
sorry 32
sas.Sziky 24
Free 23
Yoon 22
Sacsri 17
ajuk12(nOOB) 14
IntoTheRainbow 11
HiyA 10
Noble 7
SilentControl 7
Terrorterran 6
Hm[arnc] 5
Dota 2
Gorgc6678
singsing4436
qojqva2830
Dendi1634
Fuzer 256
XcaliburYe141
Counter-Strike
zeus691
markeloff152
oskar144
edward26
Other Games
hiko1546
B2W.Neo958
Hui .360
crisheroes329
Lowko312
Happy198
RotterdaM133
QueenE94
FunKaTv 51
NeuroSwarm49
Trikslyr37
ToD17
ZerO(Twitch)4
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• Michael_bg 6
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3015
• WagamamaTV477
League of Legends
• Nemesis5955
• TFBlade567
Upcoming Events
OSC
8h 2m
PiGosaur Monday
9h 2m
LiuLi Cup
20h 2m
OSC
1d 4h
RSL Revival
1d 19h
Maru vs Reynor
Cure vs TriGGeR
The PondCast
1d 22h
RSL Revival
2 days
Zoun vs Classic
Korean StarCraft League
3 days
BSL Open LAN 2025 - War…
3 days
RSL Revival
3 days
[ Show More ]
BSL Open LAN 2025 - War…
4 days
RSL Revival
4 days
Online Event
5 days
Wardi Open
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
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

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 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.