• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:36
CEST 15:36
KST 22:36
  • 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
Weekly Cups (June 30 - July 6): Classic Doubles1[BSL20] Non-Korean Championship 4x BSL + 4x China7Flash Announces Hiatus From ASL64Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Weekly Cups (June 23-29): Reynor in world title form?
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
SC uni coach streams logging into betting site BGH Auto Balance -> http://bghmmr.eu/ ASL20 Preliminary Maps Flash Announces Hiatus From ASL Player “Jedi” cheat on CSL
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [BSL20] Non-Korean Championship 4x BSL + 4x China CSL Xiamen International Invitational The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread 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 Russo-Ukrainian War Thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024! Summer Games Done Quick 2025!
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
The Automated Ban List
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: 726 users

The Big Programming Thread - Page 662

Forum Index > General Forum
Post a Reply
Prev 1 660 661 662 663 664 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.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
September 05 2015 11:55 GMT
#13221
On September 03 2015 20:42 Manit0u wrote:
I'm no good with trigonometry. Could you help me out with Haversine formula a bit?

I have this query to get locations in select radius range from target location. Could it be made simpler? It works but it looks horrible...


$query = $queryBuilder
->select('CAST((2 * ATAN2(SQRT(POW(SIN(RADIANS(latitude - '
.$latitude
.') / 2) , 2) + POW(SIN(RADIANS(longitude - '
.$longitude
.') / 2) , 2) * COS(RADIANS('
.$latitude
.')) * COS(RADIANS(latitude))), SQRT(1 - POW(SIN(RADIANS(latitude - '
.$latitude
.') / 2) , 2) + POW(SIN(RADIANS(longitude - '
.$longitude
.') / 2) , 2) * COS(RADIANS('
.$latitude
.')) * COS(RADIANS(latitude)))) * 6371) AS DECIMAL(65,10)) AS d')
->having($expr->lte('d', ':radius'))
->setParameter('radius', $radius)
->getQuery();


You consider using MySQL gis functions? I've never personally used it by they're meant for this stuff and if you using not ancient MySQL you aren't even stuck with myisam to use.
RIP GOMTV. RIP PROLEAGUE.
polyestersqueeze
Profile Joined January 2012
2 Posts
Last Edited: 2015-09-06 00:58:16
September 05 2015 23:06 GMT
#13222
This may be more a GIS question, but I have a set of lat/long coordinates, and I want to find something like a mean point from these. So my plan is to get Cartesian Coordinates from the lat/long pairs, and then I think I'll just need to sum them all and normalize the vector.

Anywho, I can't even get a lat/lon pair to convert to a vector and back. Any help/advice would be awesome.
Here's my code:

<code>def convert_to_dec_degrees(deg, minutes, sec, direction):
dec = deg + minutes/60 + sec/3600
if direction == 'S' or direction == 'W':
dec *= -1
return dec


def convert_to_vector(r, lat, long):
lat = 90 - lat
x = r*math.sin(lat)*math.cos(long)
y = r*math.sin(lat)*math.sin(long)
z = r*math.cos(lat)
return x, y, z


def convert_to_lat_long(x, y, z):
r = math.sqrt(math.pow(x, 2)+math.pow(y, 2)+math.pow(z, 2))
lat = math.acos(z/r)*180/math.pi
long = math.atan2(x, y)*180/math.pi
return lat, long</code>
One if by land, Two if by sea - Bilb Ono
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
September 06 2015 07:01 GMT
#13223
Wow

So I've been using Java for a web application and I've still been learning, but I just found out that EL in jsp will automatically convert your class statements so if you want to use a class function such as user.getName() you'd have to type it out as user.name and you can't call the function directly. Confusing as hell
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
September 06 2015 07:25 GMT
#13224
For some reason that sounds really normal, which feels weird to say...
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
September 06 2015 15:42 GMT
#13225
On September 06 2015 16:01 Itsmedudeman wrote:
Wow

So I've been using Java for a web application and I've still been learning, but I just found out that EL in jsp will automatically convert your class statements so if you want to use a class function such as user.getName() you'd have to type it out as user.name and you can't call the function directly. Confusing as hell


I kind of like that. You type it as you'd like to access a property and it automatically looks for a getter for it.
Time is precious. Waste it wisely.
rebdomine
Profile Blog Joined October 2010
6040 Posts
September 07 2015 08:14 GMT
#13226
On September 06 2015 16:01 Itsmedudeman wrote:
Wow

So I've been using Java for a web application and I've still been learning, but I just found out that EL in jsp will automatically convert your class statements so if you want to use a class function such as user.getName() you'd have to type it out as user.name and you can't call the function directly. Confusing as hell


I remember being confused about this same thing a few years ago too.

Gotten used to it by now though.
"Just because you are correct doesn't mean you are right!"
Housemd
Profile Joined March 2010
United States1407 Posts
Last Edited: 2015-09-09 02:14:53
September 09 2015 02:14 GMT
#13227
Hey Guys. I have a newbie question.

I just downloaded Eclipse Mars for C++ coding (windows 64 bit computer for me)

Whenever I run the simplest of code, I get the following message: Launch failed. Binary not found.

Any help?

EDIT: Saw some online threads already, didn't help much :/
Fantasy is a beast
meatpudding
Profile Joined March 2011
Australia520 Posts
September 09 2015 02:40 GMT
#13228
On September 09 2015 11:14 Housemd wrote:
Hey Guys. I have a newbie question.

I just downloaded Eclipse Mars for C++ coding (windows 64 bit computer for me)

Whenever I run the simplest of code, I get the following message: Launch failed. Binary not found.

Any help?

EDIT: Saw some online threads already, didn't help much :/


You might need to set the working directory of the project (to the directory that the executable is built to).

Alternatively, you might need to set the startup project, if you have an example with lots of projects.

(Source: I have never used Eclipse)
Be excellent to each other.
Housemd
Profile Joined March 2010
United States1407 Posts
September 09 2015 03:16 GMT
#13229
On September 09 2015 11:40 meatpudding wrote:
Show nested quote +
On September 09 2015 11:14 Housemd wrote:
Hey Guys. I have a newbie question.

I just downloaded Eclipse Mars for C++ coding (windows 64 bit computer for me)

Whenever I run the simplest of code, I get the following message: Launch failed. Binary not found.

Any help?

EDIT: Saw some online threads already, didn't help much :/


You might need to set the working directory of the project (to the directory that the executable is built to).

Alternatively, you might need to set the startup project, if you have an example with lots of projects.

(Source: I have never used Eclipse)


Yea, unfortunately I'm such a newb that without a step by step procedure or something of that like, I will most likely mess my computer up

If anyone could do that, it would be great. If not, I'll ask my professor tomorrow.
Fantasy is a beast
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
September 09 2015 08:58 GMT
#13230
--- Nuked ---
Khalum
Profile Joined September 2010
Austria831 Posts
September 09 2015 09:23 GMT
#13231
But why Eclipse...?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
September 09 2015 10:58 GMT
#13232
--- Nuked ---
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-09-10 05:23:28
September 10 2015 05:19 GMT
#13233
So I'm trying to learn how to code properly and I was wondering if I have a function that wants to update or retrieve an entity based on name should I connect and close connections to the database within that function? Or should I make it simpler and just update the object itself and rely on the user to open and close connections while passing the proper parameters to the function? I'd imagine that opening and closing connections could be pretty repetitive and inefficient after awhile. For example in my application I want to check to see if a value exists and then add the object if it doesn't. With 2 separate functions for checking existence and adding this would require 2 separate connections to the database.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2015-09-10 08:56:03
September 10 2015 08:55 GMT
#13234
--- Nuked ---
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
September 10 2015 10:22 GMT
#13235
On September 10 2015 14:19 Itsmedudeman wrote:
So I'm trying to learn how to code properly and I was wondering if I have a function that wants to update or retrieve an entity based on name should I connect and close connections to the database within that function? Or should I make it simpler and just update the object itself and rely on the user to open and close connections while passing the proper parameters to the function? I'd imagine that opening and closing connections could be pretty repetitive and inefficient after awhile. For example in my application I want to check to see if a value exists and then add the object if it doesn't. With 2 separate functions for checking existence and adding this would require 2 separate connections to the database.

A function should do 1 thing and 1 thing only, it cocern should not be checking for connections, it should be given a proper connection or something else that handles all of that. so that the function only has the be concernd with creating the correct query.
The harder it becomes, the more you should focus on the basics.
Housemd
Profile Joined March 2010
United States1407 Posts
Last Edited: 2015-09-11 02:56:20
September 11 2015 02:50 GMT
#13236
Hey guys, another stupid simple question that I can't seem to figure out.

int a = 10;
int b = 5;
int c = a+b:
if (a+b) = 189
{
cout << "I'm the best"<<end1;
}
else
{
cout << "I suck at programming"<<end1;
}

so basically, i don't get one thing. obviously a+b doesn't equal 189 but i keep getting only the former boolean condition. Meaning it keeps printing "I'm the best." Can someone guide me through this issue?

EDIT: This is c++. Just using an online compiler.

EDIT: NVM I'm stupid. supposed to be if (a+b) == 189.
Fantasy is a beast
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
September 11 2015 11:49 GMT
#13237
You should really fix this code...


if (c == 189) { //note the parentheses around expression
//code
}


On another note, a nice piece of reading I've found:


NoSQL is Hard

So should Stack Overflow have scaled out instead of up, just in case?

What some don't realize is NoSQL is hard. Relational databases have many many faults, but they make a lot of common tasks simple while hiding both the cost and complexity. If you want to know how many black Prius cars are in inventory, for example, then that's pretty easy to do.

Not so with most NoSQL databases (I'll speak generally here, some NoSQL databases have more features than others). You would have program a counter of black Prius cars yourself, up front, in code. There are no aggregate operators. You must maintain secondary indexes. There's no searching. There are no distributed queries across partitions. There's no Group By or Order By. There are no cursors for easy paging through result sets. Returning even 100 large records at time may timeout. There may be quotas that are very restrictive because they must limit the amount of IO for any one operation. Query languages may lack expressive power.

The biggest problem of all is that transactions can not span arbitrary boundaries. There are no ACID guarantees beyond a single record or small entity group. Once you wrap your head around what this means for the programmer it's not a pleasant prospect at all. References must be manually maintained. Relationships must be manually maintained. There are no cascading deletes that act correctly during a failure. Every copy of denormalized data must be manually tracked and updated taking into account the possibility of partial failures and externally visible inconsistency.

All this functionality must be written manually by you in your code. While flexibility to write your own code is great in an OLAP/map-reduce situation, declarative approaches still cover a lot of ground and make for much less brittle code.

What you gain is the ability to write huge quantities of data. What you lose is complacency. The programmer must be very aware at all times that they are dealing with a system where it costs a lot to perform distribute operations and failure can occur at anytime.

All this may be the price of building a truly scalable and distributed system, but is this really the price you want to pay?


Source: http://highscalability.com/stack-overflow-architecture
Time is precious. Waste it wisely.
Acrofales
Profile Joined August 2010
Spain17971 Posts
Last Edited: 2015-09-11 12:09:21
September 11 2015 12:08 GMT
#13238
On September 11 2015 11:50 Housemd wrote:
Hey guys, another stupid simple question that I can't seem to figure out.

int a = 10;
int b = 5;
int c = a+b:
if (a+b) = 189
{
cout << "I'm the best"<<end1;
}
else
{
cout << "I suck at programming"<<end1;
}

so basically, i don't get one thing. obviously a+b doesn't equal 189 but i keep getting only the former boolean condition. Meaning it keeps printing "I'm the best." Can someone guide me through this issue?

EDIT: This is c++. Just using an online compiler.

EDIT: NVM I'm stupid. supposed to be if (a+b) == 189.

I amactually quite surprised that that doesn't just give a syntax error. What compiler are you using?

manit0u corrected your code, but the problem is basically this:
if (a+b)=189


This has two major problems: the first is that = is an assignment operator in C++, so your code there is trying to assign 189 to (a+b), which is jibberish and should give a syntax error all on its own.
Your second problem is that the condition of an if statement should be surrounded by parentheses in C++. Now it has been a while since I did much in C++, so it interprets (a+b) as the condition, and then the parser should, once again give a syntax error, because what follows is jibberish.

So... your online compiler seems pretty bad. Please download an ANSI C++ compiler, because what you have, definitely isn't.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
September 13 2015 20:03 GMT
#13239
lol I thought he was coding in another language because there's no way that could compile...
There is no one like you in the universe.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
September 13 2015 20:35 GMT
#13240
On September 14 2015 05:03 Blisse wrote:
lol I thought he was coding in another language because there's no way that could compile...


Apart from assignment/expression problem, there's also "end1" instead of "endl"
Time is precious. Waste it wisely.
Prev 1 660 661 662 663 664 1031 Next
Please log in or register to reply.
Live Events Refresh
Wardi Open
11:00
#43
WardiTV1322
OGKoka 522
Harstem420
Rex169
IndyStarCraft 165
CranKy Ducklings122
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
OGKoka 522
Harstem 427
Hui .184
IndyStarCraft 169
Rex 167
StarCraft: Brood War
Bisu 2963
Flash 2112
Jaedong 1818
Hyuk 1166
firebathero 688
EffOrt 645
ZerO 538
Larva 508
actioN 436
Soulkey 387
[ Show more ]
Stork 378
Snow 308
Soma 275
GuemChi 168
Mind 132
sSak 113
Pusan 111
Light 98
PianO 80
hero 77
Sharp 74
JulyZerg 72
TY 55
Barracks 46
Sea.KH 44
Yoon 38
Aegong 35
sorry 32
Free 30
GoRush 26
soO 24
zelot 23
Movie 22
JYJ20
HiyA 20
yabsab 19
IntoTheRainbow 11
Terrorterran 10
Shine 8
ivOry 4
Dota 2
qojqva3148
Gorgc2576
XaKoH 621
XcaliburYe297
syndereN293
League of Legends
singsing2548
Counter-Strike
byalli263
markeloff128
Super Smash Bros
Mew2King169
Other Games
hiko1144
B2W.Neo1138
crisheroes383
Beastyqt345
Lowko310
ArmadaUGS128
Liquid`VortiX84
ZerO(Twitch)24
Organizations
Other Games
gamesdonequick37693
StarCraft: Brood War
UltimateBattle 889
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2960
• WagamamaTV335
League of Legends
• Nemesis5594
Upcoming Events
RotterdaM Event
2h 24m
Replay Cast
10h 24m
Sparkling Tuna Cup
20h 24m
WardiTV European League
1d 2h
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 10h
The PondCast
1d 20h
WardiTV European League
1d 22h
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
2 days
Replay Cast
2 days
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
[ Show More ]
Replay Cast
3 days
RSL Revival
3 days
Classic vs Cure
FEL
4 days
RSL Revival
4 days
FEL
4 days
FEL
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
6 days
BSL20 Non-Korean Champi…
6 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
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
CSL Xiamen Invitational
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.