DO NOT DEAL WITH THIS MEMBER
Sep 8, 2019 05:58 PM
(This post was last modified: Sep 8, 2019 06:01 PM by Nemo2478.)
Hello everyone,
the class in Java is called DH Tools and has the following options:
. Make a GET request and save the content.
. Make a POST request and save the content.
. Create or write files.
. Read files.
. Execute commands and read their answer.
. HTTP FingerPrinting.
. Read the response code of an URL.
. Delete repeated in an ArrayList.
. Short the URLs in an ArrayList from the query.
. Homemade split xD.
. Download files.
. Capture the file from an URL.
. URI Split
. MD5 Encode
. MD5 File
. Get IP
The class code: [Java] [Java] Class DH Tools 0.2 - Pastebin.com
Usage examples: [Java] [Java] Class DH Tools 0.2 - Usage examples - Pastebin.com
That would be all.
Author: Doddy Hackman
Regards
PS.: I didn't post the code here because I always get the following error:
There has been an error due to your post data being empty. Possible cause is a browser page refresh or direct access to this page. We recommend you press your browser back button and begin again.
Sep 10, 2019 12:27 PM
(This post was last modified: Sep 11, 2019 12:58 AM by MavenGradle.)
Let's not handle exceptions properly, again, eh. These empty catch blocks are everywhere in your code. So much for good coding practice. Great start, let's continue.
Code try {
URL url = new URL(link);
URLConnection navi = url.openConnection();
navi.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
BufferedReader reading = new BufferedReader(
new InputStreamReader(navi.getInputStream()));
while ((re = reading.readLine()) != null) {
conte.append(re);
}
reading.close();
} catch (Exception e) {
//
}
Very nice way to name your methods. Awesome.
Code public String take(String link) {
Code public String taKe(String site, String data) {
Please use primitive types for this. Abysmal.
Code public Boolean download(String url, File savefile) {
This looks so good, I wonder why you decided to NOT use a switch or state for this:
Code if (choice == "protocol") {
result = url.getProtocol();
} else if (choice == "authority") {
result = url.getAuthority();
} else if (choice == "host") {
result = url.getHost();
} else if (choice == "port") {
result = String.valueOf(url.getPort());
} else if (choice == "path") {
result = url.getPath();
} else if (choice == "query") {
result = url.getQuery();
} else if (choice == "filename") {
result = url.getFile();
} else if (choice == "ref") {
result = url.getRef();
} else {
result = "Error";
}
Another great job producing trash code. Well done! You're really going backwards in your skills.
(Sep 10, 2019 12:27 PM)MavenGradle Wrote: Let's not handle exceptions properly, again, eh. These empty catch blocks are everywhere in your code. So much for good coding practice. Great start, let's continue.
Code try {
URL url = new URL(link);
URLConnection navi = url.openConnection();
navi.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0");
BufferedReader reading = new BufferedReader(
new InputStreamReader(navi.getInputStream()));
while ((re = reading.readLine()) != null) {
conte.append(re);
}
reading.close();
} catch (Exception e) {
//
}
Very nice way to name your methods. Awesome.
Code public String take(String link) {
Code public String taKe(String site, String data) {
Please use primitive types for this. Abysmal.
Code public Boolean download(String url, File savefile) {
This looks so good, I wonder why you decided to NOT use a switch for this:
Code if (choice == "protocol") {
result = url.getProtocol();
} else if (choice == "authority") {
result = url.getAuthority();
} else if (choice == "host") {
result = url.getHost();
} else if (choice == "port") {
result = String.valueOf(url.getPort());
} else if (choice == "path") {
result = url.getPath();
} else if (choice == "query") {
result = url.getQuery();
} else if (choice == "filename") {
result = url.getFile();
} else if (choice == "ref") {
result = url.getRef();
} else {
result = "Error";
}
Another great job producing trash code. Well done! You're really going backwards in your skills.
If this even compiles I'll eat my fucking hat.
Code public ArrayList short(ArrayList array) {
...
//that function name kek
}
This has got to be a troll.
The poor remain poor by acting rich.
Sep 10, 2019 10:55 PM
(This post was last modified: Sep 10, 2019 10:57 PM by GenericSkid.)
I like how when I saw this thread I knew MavenGradle would be here to call it out 🤣
PHP Code
<?php public String take(String link) { String re; StringBuffer conte = new StringBuffer(40);
In most contexts, use StringBuilder, not StringBuffer.
PHP Code
<?php public String taKe(String site, String data) { // Credits : Function based in http://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/
The code in the credits is clearer and commented.
PHP Code
<?php public void savefile(String path, String text) { FileWriter write = null; File file = null;
Why are these variables scoped for the entire method? That's unnecessary.
Also savefile vs read_file, stick to ONE naming convention please. You have no consistency.
PHP Code
<?php // read_file Scanner reading = new Scanner(new FileReader(path));
This scanner is never closed.
PHP Code
<?php Runtime.getRuntime().exec("cmd /c " + command);
This code is windows only. Try to keep your Java multiplatform.
PHP Code
<?php public String httpfinger(String target)
Honestly, why would you ever need this as a String return type? A map of header keys to their values would be much more useful.
PHP Code
<?php public ArrayList repes(ArrayList array)
Bruh, so many better ways to remove duplicates.
PHP Code
<?php public ArrayList short(ArrayList array)
Ok you have to be trolling. This shit doesn't compile.
PHP Code
<?php public String md5_file(String file)
This doesn't compile either. You have a duplicate variable name.
PHP Code
<?php public String regex(String code, String fromhere, String uphere)
Again, retarded scoping. Literally declared on the next line, why even initialize to null? The hell?
DO NOT DEAL WITH THIS MEMBER
Hello MavenGradle, XMR and GenericSkid,
you are not assisted by the right to use terms that humiliate or denigrate me.
A lot less if your intentions are to help me, correcting my mistakes, so that I learn.
Actually one question if your intentions are to help me (altruism), or to denigrate me (human misery), through your faults, extolling, in the process, the intellectual "superiority" of you.
It is a pity that knowledge does not come in communion with that humility that indicates greatness, and yes with the remaining oblivion that we all, in our beginnings, had failures that we could sadly name.
Regards
(Sep 18, 2019 04:27 PM)Nemo2478 Wrote: bla bla bla
Let me be clear, being new and not knowing what qualifies as good coding practices is more than fine. You are correct in that regard, everyone starts out not knowing what to do. With this in mind not all of your posts are like this one. For example your thread on the twitter4j library. It's not like this thread, but more on that later. In the twitter thread you have decently formatted your examples and explained some features of the library. This is OK but there's a lot of room for improvement and its generally an unremarkable thread. This is the kind of post that newcomers would be expected to make. There's no links to the project, and the library does much more than what you've listed. There's no reason why somebody should view your thread over the twitter4j documentation/ examples. Another ok thread you have is about taking webcam pics. Most of the same points I just covered apply to that thread too.
Recently you made a thread about random number generation. Same thing, but this time MavenGradle went through the specifics of the code you shared and described how to improve even minor details. You can argue that it was overkill to point this much out for somebody new, but that's a whole other argument that I could write a whole thread on. Something MavenGradle and I both took note of in that thread was your request to have your post put in the Java tutorial sticky thread. I'm of the mind that such a list should not include code that encourages poor programming practices like those present in your threads. If I were maintaining the list I wouldn't add anything you've posted so far. An overwhelming majority of the threads listed in the sticky are significantly higher quality than most of the other threads in this section and cover topics in manners that make them just as viable if not more than reading pure documentation. In short, the authors put in a lot of effort to make good tutorial that were informative and easy to grasp. That's why they're on the list.
Then you have threads like this one. None of the points in your back-and-forward discussion with MavenGradle from the last thread were addressed in this thread. You didn't even put in the effort to make sure this code compiles. This code is just flat out bad.
And no, you can't be an admin.
Sep 19, 2019 06:30 PM
(This post was last modified: Sep 23, 2019 06:45 PM by MavenGradle.)
Sometimes it seems like you have a couple of different personalities. Your one personality copies and pastes random code, the other seems to know what he's doing. Right now, your faulty personality has taken over full-time. All the people here already pointed out many things that are wrong with your code to the point where it doesn't even compile yet the response you come up with is to provide us with a psychological profile and why it's inappropriate of us to provide you with better ways to do things.
I don't know but maybe you should have become a psychiatrist instead of a programmer when you're coming up with replies like that instead of fixing the things that are wrong. But tell me, how does that make you feel, though?
In all seriousness, instead of pulling psychological tricks in here, let's go through this once again:
You provide faulty code, we suggest you to fix it by pointing out a LOT of mistakes that you made. You fail to fix your code, like you failed to do last time we went into a discussion like this. There's absolutely no point in discussing intellectual superiority if you don't even fix code that is absolutely broken. If you feel like you are being mentally assaulted, you're not. Programming is about a certain logic, things can either be 0 or 1. Your code is a 0. Again, fix it. There is no point in discussing this any further with you and any programmer who is willing to help will continue to point out your mistakes so that you may learn from them. Mistakes in programming are not exclusively yours, we all make them but that's why it's good to have other people looking over your code. If you don't want other people to look over your code, please don't post it online and advertise it as some kind of wonderful perfect thing to get certain things done, because it's not.
DO NOT DEAL WITH THIS MEMBER
Oct 19, 2019 12:42 PM
(This post was last modified: Oct 19, 2019 12:44 PM by Nemo2478.)
Hello MavenGradle,
what I have referred to has been that there is no need to "humiliate" anyone using terms that, if you are honest and put yourself in the opposite place, you would understand.
Knowledge deficiencies, their observations and corrections are valid. If not, it would make no sense to exchange and expose the works.
But instead, the method used for this purpose, go pointing or correcting (knowledge itself) and using word terms that could offend the user (way of expressing), is not positive.
I have only referred to your hardness of denominations and terms (projection) that are neither polite or pedagogical. Completely unnecessary.
That all.
The psychological games on my part or mental aggressions on your side... there is plenty.
I regret that I interpret it that way, and not be able to see the detail of education, respect and chivalry, of someone, of how you dominates a knowledge and want that another learn from their mistakes, without feeling embarrassed, inferior, or regretful of trusting that they will be tolerant and gentle helping him, by correcting his faults.
It is about the human aspect and not about knowledge. It is about being sensitive, above the cold logic that mistakes reveal.
I only speak of professional courtesy in teaching someone else something, highlighting these faults, as your loved ones, teachers and friends taught you.
You are good professionals, I have no doubt ... and you will be even better people if you can understand what I am telling you.
My best wishes.
Oct 19, 2019 04:17 PM
(This post was last modified: Oct 19, 2019 04:42 PM by MavenGradle.)
I agree. Meanwhile after we've all had a beer and had great makeup sex, your code is still broken. Here's something new for you, just introduced in JDK 13:
Code String result = switch (choice) {
case "protocol" -> url.getProtocol();
case "authority" -> url.getAuthority();
case "host" -> url.getHost();
case "port" -> String.valueOf(url.getPort());
case "path" -> url.getPath();
...
default -> throw new IllegalArgumentException("Unsupported choice!");
};
Switch expressions. Doesn't that look nice? Notice how no one here has called you any names yet besides troll?
Oct 20, 2019 01:28 AM
(This post was last modified: Oct 20, 2019 01:29 AM by Aussie.)
Aside from the other issues listed above, please stick to camelCasing method names like `extractFileByUrl` instead of `extract_file_by_url`.
|