S Fox

Ranch Hand
+ Follow
since Mar 15, 2016
S likes ...
C++ Eclipse IDE Java
Cows and Likes
Cows
Total received
3
In last 30 days
0
Total given
0
Likes
Total received
16
Received in last 30 days
0
Total given
11
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by S Fox

Hi i made a table and everything works fine but I can't click on the table-rows to select anything.

If you call "setItems" ( table.setItems(observableList); ) the rows do become selectable, but I thought you are only supposed to call that the first time you create the table.
Am I supposed to call setItems every single time I add things to the table?

Also, if you click a column-header to sort that column, magically it fixes itself, without having to call setItems again.
7 months ago
when incrementing a pointer:
does this only increment within the memory allocated to your program or does it increment through the entire system memory?
am i able to read and manipulate the contents of memory of other programs? for example, i could write nulls to the memory the os itself was using and crash it?
how would i know which program owns any given area in memory, and what the variables there are being used for?
what kind of useful things can you do with this? or can it be done at all...
9 months ago
is it bad to use a variable in another namespace? that would allow using it really far away from where it was defined, in a whole other class file.
9 months ago
i know you do code review professionally Junilu, so you will know better than anyone about all this, but here is how i think of it.

the argument against seems to always be, if the implementation changes then the type would be wrong. isn't that a good thing? now you know by looking at that code something could be amiss. obviously if you change the implementation you should of changed it everywhere, as well as the var name itself.

also i see they are saying the modern day ide can display the type so we don't need this naming convention anymore. true, but i learned to code in a simple text editor, not an ide, maybe some people still do that. and what if you are looking at a paper printout of the source?

in the classroom teachers are using strFileName, ptrFileA, ptrFileB, that's how they always did it in my classes. i don't do it in my own code because i know its not the modern accepted way. why are teachers doing this if they know its wrong?

you can see stroustrup saying he's not in favor of hungarian but likes it for untyped languages, but then he also says he likes variable_name instead of variableName, so he is not in favor of camelcase which is the most common convention today.
he also argues against long var names, but in java reallyReallyLongNamesLikeThis are the style here.

then there is the whole style debate about declaring pointers, is it int* p; or int *p;
i prefer the 2nd way since when declaring more on one line it looks like int *p, *p1; so it's more correct to me, of course stroustrup disagrees, says just don't put more onto one line so he can pretend int* is it's own special type.
wouldn't it be better to just check with k&r to see how they did it? they wrote the book on C, and all these other languages are variants of it. i am guessing they used *p but i didn't look it up to be sure.

we could then go into the curly brace style and comments styles too, many variations on that. i'm not sure what the most accepted block comment style is today and i wonder about that a lot.

stroustrup says:

Whenever something can be done in two ways, someone will be confused. Whenever something is a matter of taste, discussions can drag on forever.


yep!

so i think it really is a matter of taste, because compilers don't care about whitespace and formatting. none of this really matters to the compiler, it's all just a formatting style that we humans are trying to follow. each group of people seems to have their own way, even java ranch has a style guide page.
9 months ago
today everyone says it's bad to put the type into the variable name, such as done with hungarian notation, why is it bad? to me this would be more understandable and self-documenting since you don't have to go hunt for where it's declared.
helps to prevent using it wrong such as in C for type safety.

for my own programs i can remember what everything is, but in someone elses code i would prefer to know at a glance what a certain var is. so why is it bad, convince me!
9 months ago
what i wanted to do is not easy to answer, sorry for the long post here.

my app was attempting to do crypto analysis of simple substitution.
i already learned how to break viginere by re-writing a open source python program into java.
so i had some experience.

each language has it's own frequency, dutch and english for examples since you know these.
https://www.sttmedia.com/characterfrequency-english
https://www.sttmedia.com/characterfrequency-nederlands

using those freq tables, i can compute an approximate guess how many of each letter are in a message of any given length.
for example if the message is 20 chars long, i might expect 5 e's, 3 a's, but no n's at all in english, but those expectations will differ for dutch, and there is more chance of the n so maybe we expect 2 n's.
(i didn't really compute those numbers, so its just an example.)

you will not know what the language is beforehand, since its all just scrambled letters, so you must decode for each possible language trial and error style.
i was just finding the most common letter in the message, then re-mapping it to the letter it was most likely to be in the chosen language.

the hashmap i was creating is for replacing. fakeLetter -> realLetter
i assumed that replacing by frequency alone would be perfect, but i was wrong, it gives such a poor result that it never creates something readable.
(i didnt ever figure out how to make the hashmap using the streams, i tested it a different way.)

so my entire algorithm is a failure. my fault, i didn't look up the correct algorithm, i tried to design it myself.

at this site they say i should use a hill-climbing method and quadgrams.
http://www.practicalcryptography.com/ciphers/classical-era/simple-substitution/
http://www.practicalcryptography.com/cryptanalysis/stochastic-searching/cryptanalysis-simple-substitution-cipher/

i have asked here before and nobody at java ranch knows anything about crypto or any things related to it such as hill climbing & chi square tests.
so i am left to figure a lot out on my own, very few websites deal with this, and the practical crypto site which is the best one to consult has no forum at all.

i would have to re-tool my app now for quadgrams, i don't know if i can even find tables for those, if not i would have to gather lots of texts just to analyze and build quadgram freq tables myself.
accurate calculation of this would need tons of plain texts in various languages, 1000 pages of text or more per language i think, not sure. finding all this text would be hard.
where can you download entire books of ascii texts in all languages?

but after all that i would still have to figure out a hill climbing algorithm. so this isn't a very beginner type of project. this is why i just ask how to do certain things and not give much details about what i'm trying to do.
because you all will think i'm crazy for trying it!

and on top of that you won't understand it, which is funny since i had thought everyone here was taught to learn crypto breaking stuff like this at uni, i'm not in uni i'm just teaching myself.
i have spent a year creating this thing so far, it has charts and graphs to show observed and expected counts since i coded the ui in javaFX. i learned a lot doing it even if i can't finish it.
i would be very sad if i can't finish it though since i put so much work into it.
9 months ago
here's what I got so far:
Map chReplacementsEnglish = observedSorted.stream().collect(Collectors.toMap(Quantity::instance, Quantity::instance));

It doesn't stream both the lists into the same map at the same time, but I'm starting to understand how to use stream.
9 months ago

Knute Snortum wrote:

But I'm still not sure why using Stageable as a Type is necessary.  


Think of it this way: I have a List called controllers, containing all different classes.  I want to get the first one and call its setStage() method.  So I start typing...
But wait, what is xxx?  Let's say that the first class in the List is Controller1.  I could write
But that's not going to work for indices 1, 2, etc.  So I make an interface Stageable and implement it in all the controllers. Now I can write:



Controller1 controller = controllers.get(0); // its only index 0
Stageable controller = controllers.get(0); // also only index 0

How does this work??? I don't get it.
9 months ago
The new style is great but I can't always figure it out. Like right now I can't figure out how to use stream to get Quantity.instance out of the 2 sorted lists and put them into a new map. Not sure it's even possible, or if support has to be added somehow for it to work?

also was .collect(toList()); in the example above supposed to be .collect(Collectors.toList()); ?

9 months ago
thanks! i think he has another site, a homesteading site? it has almost the same theme as javaranch, unless someone ripped off the theme. i forgot how i ran into that other site.
9 months ago
in my example above i forgot to increment the x outside the if-statement so, infinite loop. oops. i guess he wanted 2 vars for this anyhow.
9 months ago
If he doesn't post here anymore can I have his cows? I only have one cow and it's lonely.
9 months ago
I think a while loop would be better for increment every 5, something like this?
9 months ago
Another important thing to know right away is that with some declarations in java they have made it where you don't need to write the word new.
It still is creating a new object instance, but for convenience they got rid of the requirement to write it.

Integer x = 6;
Integer y = new Integer(6);

String a = "hello";
String b = new String("hello");

Also you need to know, when you make a new object you have to assign it to a variable to keep using it, it creates a pointer from the variable to the object.
I think in java it's called a reference, not a pointer. In every other language I know of though it's called a pointer. it's pointing to the memory address where the object is stored.

new Integer(6);
this does create a new object, but you can never use it again, it's lost forever. since you didn't assign a variable.
you can "point" the same variable at a different object, by doing a new assignment.

changing the value of a variable sometimes creates a whole new object, because some objects are immutable. immutable objects aren't allowed to be modified.
that means they just throw the old object in the trash and give you a whole new one when you do try to change the value of it.

I think in java if you assign the exact same value to a String on two different variables, it will point both to the exact same address in memory, because java has a string pool.
I'm not 100% sure about this one anymore.
9 months ago
Every "thing" can be an object. If you made a class to represent a table and chairs, then when you instantiate it you have created a new object.

// creates a new instance of this object
TableAndChairs t = new TableAndChairs();

even though the class can contain methods in it, it's still considered an object.
Integer is a type, but if you instantiated one of those it becomes an object too, any time you use the keyword "new" you are making a new object.
9 months ago