M Richardson

Ranch Hand
+ Follow
since Dec 28, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
2
In last 30 days
0
Total given
0
Likes
Total received
11
Received in last 30 days
0
Total given
83
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by M Richardson

I have the following code, which outputs the changes between my source JSON file, and my target JSON file. However, I'm shaky on how to build up, and append to my new JSON, which will be essentially the same as the source JSON, but with the additions, deletions, and replacements from the target JSON.

1 year ago
I'm having a workplace code review disagreement with someone.

This is the gist of my method:




The last return value is just a placeholder to satisfy the need to have a return value even though it will never run. I'm of the opinion that SOMETIMES it's not a "code smell" and changing the implementation will make the code more unreadable. I think there is a case to be made for this. What do you guys think?
1 year ago

Tim Holloway wrote:Alas, no. The only OS I've ever seen that made a totally clean path from keyboard and other HID devices into system resources was the late, lamented AmigaOS.

Windows - and even Linux - is much messier and to shove in a keyboard translator as an application would not only not be write-once/run-anywhere, it would almost inevitably require administrative privileges.

Now if you're handy with hardware, you could make a translating dongle and essentially prepend the character input stream, but no, there's no simple way in Java.



Oh wow... that hardware idea is GENIUS!! Imagine a dongle which has all of my pre-programmed keyboard shortcuts fed into it... Would never really go mainstream, but would be a godsend for many.
2 years ago
I use AutoHotKey on Windows and key mapping on Ubuntu to map the key-combo `ALT-Q` to act as `ALT-F4` (more convenient/ergonomic)
I also work for corporates where I get heavily restricted machines. As you may have guessed, I do have access to a coding environment, which means I could theoretically create something and run that JAR (as long as it doesn't demand admin privileges).

Would I be able to create a listener program which just sits there waiting for me to press ALT+Q, and it throws out ALT+F4?

I figure even if infosec "catches" me using this (unlikely), I can easily explain what I'm doing... versus me downloading a 3rd-party tool, which would be an immediate firing.


2 years ago
My basic understanding is that in the code below, there is probably reflection being used... For what purpose... I have no idea.. Also, in line #7, the whole String.class convention makes no sense to me... Can someone please break this code down for me so that I can understand it better? Thank you.

2 years ago

M Richardson wrote:Everytime I setup a new machine, I like to have things a certain way, and there are projects I work on where the machine needs to have lots of environment variables filled out.
What I would like is to simply have a configuration file which I can add/remove from.. and just run that on any machine to set it up automatically. I suppose this requires knowledge of the Windows Registry?



I found this online so far: https://stackoverflow.com/questions/2121795/programmatically-modifiy-environment-variables
I wonder if *any* of those methods can be somehow "invoked" using Java...
2 years ago
Everytime I setup a new machine, I like to have things a certain way, and there are projects I work on where the machine needs to have lots of environment variables filled out.
What I would like is to simply have a configuration file which I can add/remove from.. and just run that on any machine to set it up automatically. I suppose this requires knowledge of the Windows Registry?
2 years ago

Piet Souris wrote:I remember from a Project Euler exercise this implementation (apart from the Map.of, since that wasn't available then)


What in tarnation! lol - Okay, I see some Java Streams wizardry going on here... but the part where S maps to 4, and R maps to 9 eludes me...  I thought there were only 7 Roman numerals? Also, I didn't quite get what `replacements` represents, exactly...
2 years ago

Junilu Lacar wrote:

M Richardson wrote:
Issue #2 : I understand that a design choice to iterate backwards was used in this case to read Roman numerals. Intuitively, how is this insight gleaned from the problem? The cognition that this problem is best solved by reading it from right to left simply doesn't occur to me, and it is demoralizing.  If someone was implementing this from scratch, what is the rationale behind iterating from end to beginning?


These are insights that come to you after analyzing the problem. They may come immediately or only after you've tried other ways of solving the problem. Problem solving is hardly ever a linear process. Sometimes you have to come at the problem from different angles. It's entirely conceivable that the decision to iterate backwards only came after trying to iterate forward became too complicated.

One key is to understand the underlying mechanics of the calculation. If you can work through the calculation manually and list down the various rules you're applying, and then see the patterns in how you're applying those rules, it's easier to translate that understanding into an algorithm. Without a good understanding of how you would do the calculation manually, it's very difficult to come up with instructions for how the computer should do it.



That's solid advice. I guess I was getting caught up with this article:
https://hackernoon.com/14-patterns-to-ace-any-coding-interview-question-c5bb3357f6ed
And I was wondering if my problem has some kind of generalized advice for "You may want to iterate backwards for these types of problems."
2 years ago

Campbell Ritchie wrote:Please tell us where such code comes from.

Yep! Edited my post to include the source. Also, thank you for elucidating!

2 years ago
Consider the following code. It takes in Roman numerals and converts them to Arabic numerals. I marvel at its elegance, but certain issues with it elude me. They are outlined at the end, after the code. Thank you.

Source of code: https://stackoverflow.com/questions/9073150/converting-roman-numerals-to-decimal (3rd Answer from the top)



Issue #1 : While I understand how this code works, I am confused trying to figure out why the choice was made in the for loop's condition: i >= 0
Why not `i > 0`?  In English, I read this as: "Keep running the loop as long as `i` is more than or equal to zero." Why doesn't `i >0` work in this case?

Issue #2 : I understand that a design choice to iterate backwards was used in this case to read Roman numerals. Intuitively, how is this insight gleaned from the problem? The cognition that this problem is best solved by reading it from right to left simply doesn't occur to me, and it is demoralizing.  If someone was implementing this from scratch, what is the rationale behind iterating from end to beginning?
2 years ago
Called myself a "Java Developer" until I got to the first problem in this book and looked at the "efficient/optimized" solution:

1.1 Is Unique  - Write a method which determines if a given String is unique or not.

I got through the naive solution. I got through the solution in which I wasn't allowed to use any Java data-structures.
Then Ms. McDowell threw a magic voodoo curveball at me.



What in tarnation is this??
What does the `- 'a' ` doing?
who is `checker??`
and I can't even begin to wrap my head around what the "Bitwise OR assignment" does.

Can someone please break it down for me? Thank you!
2 years ago

Tim Holloway wrote:You should be able to add a validatorMessage attribute to the h:inputSecret tag.

You are using a lot of attributes that aren't defined for h:inputSecret. Note that JSF, like HTML, will silently ignore elements and attributes that it does not understand. Nor will JSF pass them down to the generated HTML.



I'm looking at this and inputSecret does not have a validatorMessage attribute. It only seems to exist for inputText.
https://www.tutorialspoint.com/jsf/jsf_inputsecret_tag.htm
2 years ago
JSF
I have the following code, which is throwing a "Regex Pattern not matched" message.
I need for it to show a custom message. How do I accomplish this?




2 years ago
JSF