Matt Wong

Ranch Hand
+ Follow
since Aug 18, 2017
Matt likes ...
MS IE Notepad Suse
Cows and Likes
Cows
Total received
5
In last 30 days
0
Total given
0
Likes
Total received
11
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Matt Wong

easy - try to build a string to set a numeric value in a method that require String

what happens:

"" + int + int

Java evaluates from left to right - so the first "" is a String - String + int becomes a String - then you try the arithmetic String + int - wich doesn't work.

This is an example, how you should do this:



As it looks like you're a beginner - don't even think about this crap ""+something to get a String - look in the API doc for correct methods how to create a String the right way.
2 weeks ago
throw in a few finals - up to you to see that java surely doesn't know pass by reference but all is only pass by value - in case of java non-primitive the memory address of the object the reference points to is copied and then passed to the call
3 weeks ago
Also: you prefixed one of your Interfaces with a capital I to construct a name wich tells its type.

Two hints:
1) Although it's not prohibeted, but prefixing interfaces with a capital I just isn't Java. We have our conventions, and it's adviced to use them. Espacialy if you write source as example wich is to be read by other devs.
2) Do one thing, and do it always: either prefix every interface or none at all - but don't mix different styles within the same project.

Javas conventions suggest classnames (yes, this also applies to interfaces) to be "speaking nouns" so a classname "tells" what the class does or what it is used for. IHyfuncs and dict(), as well as the package name HyFuncs (packages should be all lower case), are very poorly choosen. Sure, naming doesn't affect functionality, but it makes it harder to understand the code.

Sorry to be the grammar nazi again, but as lambdas and functional programming is advanced topic - the basics should be done right.
1 month ago

Stephan van Hulst wrote:


Java is strongly typed. Just because someone thought it would be a good idea to throw this away by adding "var" as a valid keyword (wich by the way breaks some older coder wich uses "var" as valid name for a reference) and the behaviour like its used in JavaScript - I guess that's not good code quality to teach to someone with OP level of knowledge (no offense).

Also, if you try to give someone a push into the right direction - do it all the way: saveFilePath -> getSaveFilePath
readFromFile -> loadFromFile
as "loading" a "level" does make just a bit more sense than "reading" a "level" - although the overall implication that some data are "read" from its storage is more used than some data are "loaded".
1 month ago
well, this sounds like a timeout issue
at some point in time when workload is done a timeout is reset with every action - when work is paused this timeout ... well, times out and some state is either closed or thrown away - in generell terms: the resource becomes unavailable
my 2ct are on some database or socket timeout releasing the resource from its side and the app doesn't know how to handle it
showing the app "freeze" tells me the developer of the gui hasn't decoupled the edt correctly but is waiting for loading data while in the rendering time - hence your gui shows typical "i refuse to respond to user input"
the timeout issue is most likely on your setup as you stated it started after upgrading - so there might be some default value not checked after new system gone live
1 month ago
the chosen solution is the "most wrong" (I'm not a native english speaker but I'm aware that this isn't correct grammar) one could choose from

the whole point of using TLS in the first place is to have authenticated ensurance that the remote is really the one you want to speak to - no matter if strong encryption is used
by overwriting this very basic essential check you can get away with not using TLS at all but use RSA and AES in stream-mode and javax.crypto.CipherIn/OutputStream

the right way to do TLS with your own private CA:

create a root-key and -cert
create an instance of SSLContext using it - and create end-point-certs signed by root or if you like intermediate cert

there is no need to pre-install the root-cert ahead of use - just create a TrustManager at runtime - done

Campbell Ritchie wrote:

Matt Wong wrote:. . . even the compiler would be smart enough to calculate that 2 times 10 would fit in an int, . . .

But it studiously avoids trying that sort of calculations. There is no need to know the value of the expression at this stage and the compiler iss programmed to “forget” intermediaate stages. But, as you say, it remembers the type and the expression in line 2 is of type long, so it cannot be assigned to an int.


I'm sorry to play the grammar nazi here: I only mentioned a compile could be smart enough to know that a value of 20 would fit - I didn't said it is - =P
1 month ago
make sure the correct driver is in your lib/classpath
also: make sure you use a version that can communicate with your server version

try it outside on terminal without ide
use an ide with a gui builder and let it generate it - pretty much like android: nice it's backed by xml but to complicated to write it by yourself - it simply forces you to use some auto-generator stuff
1 month ago
well, a numeric literal is what it says: a literal: "123456"
on ther hand: x isn't a literal but a reference to a long primitive - even the compiler would be smart enough to calculate that 2 times 10 would fit in an int, but as java is strongly typed arithmetics on primitives always extend to the widest one - so a arithmetic contain a long will extend all other bools, bytes, shorts, chars and ints to long so the result will be a long - and can't fit into a narrower type (even if the value would)

that's just how javas strong typed primitives designed and work
1 month ago
this because how parallel excution works, no matter if true parallel on two physical cores or pseudo parallel on one thread-scheduled core

the main reson for your output might be that the end of the loop is passed before the othere threads fully started up so your int is already 20 when print is first executed - remeber: modern cpus run at giga-hertz - thats 1.000.000.000 operations per second - your count up to 20 is done in 20 cycles - the create and start up a new thread it take couple 100 cycles

so you have to slow down your main thread

the other question: use daemon threads or use while(flag) instead of true
1 month ago
the questions is not unique defined - are you try to look for any matches or do you want all entries the same (i cant come up with a usefull case for the latter one)?

also: why get(z++).equals(get(z--))?
simple write: get(z).equals(get(z+1))

if you really want to all entries the same: for(Integer integer : list) ...
this way you make use of List.iterator() - depend on impl of list may faster
2 months ago
well, whenever someone comes up with question about some topic involving memory limitations (mostly these questions are like "I need to increase upper max memory limit") I reply mostly the same: Do you really need all of the data in memory at the same time?

Your object is no different to me: you're limited to 300kb chunks - where's the problem?

Base64 is well known: it takes in 3 8-bit bytes and returns them back as 4 6-bit bytes encoded using a defined map - or vise-versa when de-coding.

If chunked processing you can do it as little as this one step or as many as your resource limit allows/requires. Only thing you should consider is to work in multiple of whole blocks, otherwise its a bit more complicated when tryin byte- or bit-wise (that means: when encode read 3 bytes and output 4, when decode read 4 bytes and oupt 3)

Matt
2 months ago
well - don't even think about DES - it's broken and can be bruteforced by any modern system
also - even DES-ede (as it's called correctly) - or triple-DES - is supposed to use 3 different keys and so bump up to 168bits - but in real world DES-ede only uses two keys - and therefore is only 112 bits (you can read about that on wikipedia)
so - IF you want to encrypt something - use AES - and at least something secure as CBC or OFB or so - never ECB (also: wikipedia)

i still don't understand what you try to protect - the main issue here is that you allow some secret information to get outside your controlled environment - why you even allow this? this is already flawed by design

if you want to export some secret information - use PBE and always ask the user

as others said: the only time you store keys unencrypted is on a secured server wich provides security at os-level - cause when someone has access to the system - it's easy to get admin/root access - and then you lost anyway
2 months ago
the main reason i decompiled and look through your code was
1) never run code you dont know or trust
2) check to see if it does something odd
3) i already ran into some copy'n'paste trick cause someone has hidden the code outside the sites layout and i didnt noticed it in my editor
i jsut found these "wtf" lines by simple scrolling through it scanning it for some unwated lines
2 months ago