• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:25
CEST 16:25
KST 23:25
  • 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 Tall8HomeStory 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
Flash Announces Hiatus From ASL44Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster How does the number of casters affect your enjoyment of esports? Weekly Cups (June 23-29): Reynor in world title form?
Tourneys
RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Help: rep cant save Flash Announces Hiatus From ASL BW General Discussion [ASL19] Finals Recap: Standing Tall
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile 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 Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
Game Sound vs. Music: The Im…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 564 users

The Big Programming Thread - Page 718

Forum Index > General Forum
Post a Reply
Prev 1 716 717 718 719 720 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.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-11 21:49:28
April 11 2016 21:21 GMT
#14341
Requesting help with some sql. I have to use Oracle for this which has been a complete and utter nightmare

+ Show Spoiler [code] +
CREATE TRIGGER update_available_insert
BEFORE INSERT ON loans
BEGIN
UPDATE available A
SET A.amount=(
SELECT (A2.amount - 1)
FROM available A2
WHERE A2.lid = :new.lid
)
WHERE :new.lid=A.lid;
END update_available_insert;


I'm trying to create this trigger, but the syntax doesn't work. The terminal doesn't execute the command and no error is thrown about where or what syntax is wrong. I've never written triggers before so I'm not really sure what is going wrong. I can provide some more context on the tables if needed.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-04-11 21:44:19
April 11 2016 21:43 GMT
#14342
--- Nuked ---
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-11 21:55:51
April 11 2016 21:52 GMT
#14343
I fixed the code paste. I think this is just gonna be implemented in Java instead, but it'd be nice if the triggers worked instead.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Acrofales
Profile Joined August 2010
Spain17969 Posts
Last Edited: 2016-04-11 22:13:14
April 11 2016 22:12 GMT
#14344
Not too hot on Oracle, but isn't that inner query needlessly complex? Doesn't:


UPDATE available A
SET A.amount= A.amount - 1
WHERE A.lid = :new.lid;


work?

Not that that should be your problem; your query seems valid, just needlessly complex.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2016-04-12 01:08:08
April 12 2016 01:03 GMT
#14345
I'm not a fan of moving your logic to the database. It should stay in the application.

Speaking of DB queries and all... Do you think it would be possible to turn this into a query (PostgreSQL)?


$string = 'AB.6740.D.336.2011.AP';
$regex = '/\.(\D)\./';
$alphabet = range('a', 'z');

preg_match($regex, $string, $matches);

if (!empty($matches)) {
$letter = strtolower($matches[1]);
$num = array_search($letter, $alphabet) + 1;

$string = preg_replace($regex, sprintf('.%d.', $num), $string);
}

echo $string;


This would have to update all the rows of course. The things I have to deal with...

I know that you can do WHERE field *~ '\.(\D)\.', but I'm not sure you can do replaces with regex.
Time is precious. Waste it wisely.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2016-04-12 01:43:52
April 12 2016 01:32 GMT
#14346
On April 12 2016 10:03 Manit0u wrote:
I'm not a fan of moving your logic to the database. It should stay in the application.


It's not really moving logic to the database though. I'm keeping an inventory so I want a count of those items. Having the logic in the application just means that I'd be querying the database and then updating the database. Placing that logic into the database instead means that when I insert or update a record the database triggers that update automatically. In this context I feel like the logic being in the database makes more sense.

I can't figure out how to get this trigger working and I'm not going to spend hours debugging some syntax bullshit when I can just implement it in the java in ten minutes though. One day I might fix it if I can figure out the trigger syntax, but without an error message I'm not sure I'd ever be able to figure it out. I'm pretty sure it's missing a comma/semicolon somewhere, but I don't know how to figure out where.
I'll always be your shadow and veil your eyes from states of ain soph aur.
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2016-04-12 18:34:05
April 12 2016 18:33 GMT
#14347
On April 12 2016 10:32 Blitzkrieg0 wrote:
Show nested quote +
On April 12 2016 10:03 Manit0u wrote:
I'm not a fan of moving your logic to the database. It should stay in the application.


It's not really moving logic to the database though. I'm keeping an inventory so I want a count of those items. Having the logic in the application just means that I'd be querying the database and then updating the database. Placing that logic into the database instead means that when I insert or update a record the database triggers that update automatically. In this context I feel like the logic being in the database makes more sense.

I can't figure out how to get this trigger working and I'm not going to spend hours debugging some syntax bullshit when I can just implement it in the java in ten minutes though. One day I might fix it if I can figure out the trigger syntax, but without an error message I'm not sure I'd ever be able to figure it out. I'm pretty sure it's missing a comma/semicolon somewhere, but I don't know how to figure out where.


The thing is, with this approach you're tying your system to this specific database. I'm sure there are some lifecycleCallbacks or something in Hibernate or whatever you're using to do this for you automatically when you update your db. I know for certain that in PHP you can add pre-persist and post-persist triggers within your application. Since Java is more mature and advanced I think it should have something similar (it's not that different from adding created_at, updated_at, created_by, updated_by etc. fields and triggers).
Time is precious. Waste it wisely.
supereddie
Profile Joined March 2011
Netherlands151 Posts
April 13 2016 07:20 GMT
#14348
On April 12 2016 10:03 Manit0u wrote:

Speaking of DB queries and all... Do you think it would be possible to turn this into a query (PostgreSQL)?


$string = 'AB.6740.D.336.2011.AP';
$regex = '/\.(\D)\./';
$alphabet = range('a', 'z');

preg_match($regex, $string, $matches);

if (!empty($matches)) {
$letter = strtolower($matches[1]);
$num = array_search($letter, $alphabet) + 1;

$string = preg_replace($regex, sprintf('.%d.', $num), $string);
}

echo $string;


This would have to update all the rows of course. The things I have to deal with...

I know that you can do WHERE field *~ '\.(\D)\.', but I'm not sure you can do replaces with regex.

Well, if it is a one-time thing you can just write out the update and do 26 replaces...
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2016-04-14 22:46:42
April 14 2016 08:14 GMT
#14349
probably a simple error (java) i've been stuck on for a while. its confusing for me since this is code from what my teacher gave as reference and I don't spot any glaring errors.
+ Show Spoiler +

 
public void actionPerformed(ActionEvent event) {
String menuName;
menuName = event.getActionCommand();
if (menuName.equals("Open"))
openFile( ); //NullPE <-------------------
else if (menuName.equals("Quit"))
System.exit(0);
} //actionPerformed
private void openFile( ) {
JFileChooser chooser;
int status;
chooser = new JFileChooser();
status = chooser.showOpenDialog(null);
if (status == JFileChooser.APPROVE_OPTION)
readSource(chooser.getSelectedFile()); //NullPE error <-------------
else
JOptionPane.showMessageDialog(null, "Open File dialog canceled");
} //openFile
//...and so on

basically a snippet of part of my code to let my GUI read in a textfile and then append some words in it to text areas.
the textfile is named "test.txt" and it is in the same folder as my src folder (next to it not inside src). I get the errors when I try to open the file with my GUI.


http://stackoverflow.com/questions/29982188/getting-a-exception-java-lang-nullpointerexception-cant-figure-out-why/29982222

a guy with pretty much the same exact code/problem as me (most likely same teacher, different problem) and it doesn't seem like he got it resolved there. tried the suggestions there to no avail. any help is appreciated. let me know if I didn't give enough information, didn't want to slab on too many lines of code.


edit:
On April 14 2016 17:19 solidbebe wrote:
*never mind I missed a line*

Looks like getSelectedFile returns null. Have a look at that method, see what it does.


It returns the selected file+ Show Spoiler +
https://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html#getSelectedFile%28%29
, which should be fine since my readSource method uses File as a parameter.

edit2:
thanks guys, slept on it and figured it out when I got back from school. turns out there was something wrong with my readSource method.
TL/SKT
solidbebe
Profile Blog Joined November 2010
Netherlands4921 Posts
Last Edited: 2016-04-14 08:24:04
April 14 2016 08:19 GMT
#14350
*never mind I missed a line*

Looks like getSelectedFile returns null. Have a look at that method, see what it does.
That's the 2nd time in a week I've seen someone sig a quote from this GD and I have never witnessed a sig quote happen in my TL history ever before. -Najda
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
Last Edited: 2016-04-14 08:52:27
April 14 2016 08:48 GMT
#14351
What is the full stack trace of the exception in your case?

EDIT: And the code of readSource()
solidbebe
Profile Blog Joined November 2010
Netherlands4921 Posts
April 14 2016 08:55 GMT
#14352
So are you setting the file somewhere? Seems to be the selectedFile field is uninitialized.
That's the 2nd time in a week I've seen someone sig a quote from this GD and I have never witnessed a sig quote happen in my TL history ever before. -Najda
Acrofales
Profile Joined August 2010
Spain17969 Posts
Last Edited: 2016-04-14 11:18:28
April 14 2016 11:07 GMT
#14353
That can't be the top of your stack trace. Chooser is guaranteed to be non-null there, so the only place your nullpointerexception can originate is from somewhere inside readSource.

getSelectedFile() is allowed to return null on that line, but you clearly don't want it to be, so why not add a test for that? In general, when you run into problems debugging your code, you have more tools available than just the stack trace. Use the Java debugger, junit tests and good old fashioned logging to figure out what is breaking. Don’t assume something is non-null, test that.
zatic
Profile Blog Joined September 2007
Zurich15325 Posts
April 14 2016 12:16 GMT
#14354
So I have dabbled a bit with HTML5 with oData models to various backends. I finally feel like I am living in the future. Wish I hadn't neglected my JS for like 5 years, this is so much fun.
ModeratorI know Teamliquid is known as a massive building
shz
Profile Blog Joined October 2010
Germany2687 Posts
April 14 2016 21:51 GMT
#14355
Does anyone have any experience with auth0 + s3 on Android? Or at least experience with S3 when authenticating users by token on Android?
Liquipedia
Acrofales
Profile Joined August 2010
Spain17969 Posts
April 14 2016 21:56 GMT
#14356
I fucking hate javascript. Somebody please explain to me why it has a for .. in loop with the syntax exactly as if it will iterate over an Array, but if you actually use it to iterate over your array it fucks shit up (like not guaranteeing to iterate in order and other such stupid shit).
Manit0u
Profile Blog Joined August 2004
Poland17243 Posts
Last Edited: 2016-04-14 22:31:40
April 14 2016 22:31 GMT
#14357
On April 13 2016 16:20 supereddie wrote:
Show nested quote +
On April 12 2016 10:03 Manit0u wrote:

Speaking of DB queries and all... Do you think it would be possible to turn this into a query (PostgreSQL)?


$string = 'AB.6740.D.336.2011.AP';
$regex = '/\.(\D)\./';
$alphabet = range('a', 'z');

preg_match($regex, $string, $matches);

if (!empty($matches)) {
$letter = strtolower($matches[1]);
$num = array_search($letter, $alphabet) + 1;

$string = preg_replace($regex, sprintf('.%d.', $num), $string);
}

echo $string;


This would have to update all the rows of course. The things I have to deal with...

I know that you can do WHERE field *~ '\.(\D)\.', but I'm not sure you can do replaces with regex.

Well, if it is a one-time thing you can just write out the update and do 26 replaces...


The thing is, I need to update over 120k rows in the db, replacing all .[LETTER]. patterns with the corresponding number.
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
April 14 2016 22:56 GMT
#14358
On April 15 2016 06:56 Acrofales wrote:
I fucking hate javascript. Somebody please explain to me why it has a for .. in loop with the syntax exactly as if it will iterate over an Array, but if you actually use it to iterate over your array it fucks shit up (like not guaranteeing to iterate in order and other such stupid shit).


It's not meant to iterate over the array. It's used to iterate over the properties of an object. It just happens that the element at each index of an array is stored as a property, and array[] index based access is the same as property access in Javascript.
There is no one like you in the universe.
Acrofales
Profile Joined August 2010
Spain17969 Posts
April 15 2016 01:09 GMT
#14359
On April 15 2016 07:56 Blisse wrote:
Show nested quote +
On April 15 2016 06:56 Acrofales wrote:
I fucking hate javascript. Somebody please explain to me why it has a for .. in loop with the syntax exactly as if it will iterate over an Array, but if you actually use it to iterate over your array it fucks shit up (like not guaranteeing to iterate in order and other such stupid shit).


It's not meant to iterate over the array. It's used to iterate over the properties of an object. It just happens that the element at each index of an array is stored as a property, and array[] index based access is the same as property access in Javascript.

I understand that. Took me quite a bit of debugging to realize what was wrong in that code, though... because most languages that have for .. in loops (e.g. Java, Python, C#) simply enumerate the values in your array. And this isn't the only quirk of JS coopting common syntax and doing something completely different (== vs === for instance). It's very frustrating (to people like me who have to dabble in JS every now and then), and hence my reinforced putrid hatred of JS every time I have to work with it.
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
April 15 2016 05:33 GMT
#14360
On April 15 2016 10:09 Acrofales wrote:
Show nested quote +
On April 15 2016 07:56 Blisse wrote:
On April 15 2016 06:56 Acrofales wrote:
I fucking hate javascript. Somebody please explain to me why it has a for .. in loop with the syntax exactly as if it will iterate over an Array, but if you actually use it to iterate over your array it fucks shit up (like not guaranteeing to iterate in order and other such stupid shit).


It's not meant to iterate over the array. It's used to iterate over the properties of an object. It just happens that the element at each index of an array is stored as a property, and array[] index based access is the same as property access in Javascript.

I understand that. Took me quite a bit of debugging to realize what was wrong in that code, though... because most languages that have for .. in loops (e.g. Java, Python, C#) simply enumerate the values in your array. And this isn't the only quirk of JS coopting common syntax and doing something completely different (== vs === for instance). It's very frustrating (to people like me who have to dabble in JS every now and then), and hence my reinforced putrid hatred of JS every time I have to work with it.


https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

JavaScript has foreach, so why not use that?
Prev 1 716 717 718 719 720 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 35m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 545
Lowko422
ProTech66
StarCraft: Brood War
Britney 47569
Rain 5500
Sea 3484
Jaedong 1870
EffOrt 1197
BeSt 457
Stork 407
actioN 293
ZerO 283
ToSsGirL 272
[ Show more ]
Snow 205
Light 158
hero 102
Mong 74
Sharp 72
Shinee 61
Pusan 53
Mind 47
Sea.KH 46
Rush 40
sSak 36
PianO 28
Terrorterran 24
Nal_rA 22
Noble 18
GoRush 13
ajuk12(nOOB) 12
Sacsri 11
yabsab 11
sorry 10
soO 8
SilentControl 8
IntoTheRainbow 7
JulyZerg 7
zelot 3
scan(afreeca) 2
Dota 2
qojqva3530
XcaliburYe496
Counter-Strike
byalli250
markeloff218
edward68
kRYSTAL_26
Super Smash Bros
Mew2King140
Other Games
hiko1148
B2W.Neo938
DeMusliM758
crisheroes344
Happy256
ArmadaUGS108
KnowMe54
QueenE38
ZerO(Twitch)24
Organizations
StarCraft: Brood War
Kim Chul Min (afreeca) 6
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 71
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• blackmanpl 3
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis7512
• TFBlade765
Upcoming Events
WardiTV European League
1h 35m
ByuN vs NightPhoenix
HeRoMaRinE vs HiGhDrA
Krystianer vs sebesdes
MaxPax vs Babymarine
SKillous vs Mixu
ShoWTimE vs MaNa
Replay Cast
9h 35m
RSL Revival
19h 35m
herO vs SHIN
Reynor vs Cure
OSC
22h 35m
WardiTV European League
1d 1h
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
1d 1h
Korean StarCraft League
1d 12h
CranKy Ducklings
1d 19h
RSL Revival
1d 19h
FEL
2 days
[ Show More ]
Sparkling Tuna Cup
2 days
RSL Revival
2 days
FEL
2 days
BSL: ProLeague
3 days
Dewalt vs Bonyth
Replay Cast
4 days
Replay Cast
4 days
The PondCast
5 days
Replay Cast
6 days
RSL Revival
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
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
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
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.