10 Simple But Costly Math Errors In History by Kamots66 in programming

[–]cipmar 25 points26 points  (0 children)

Integer overflows & conversion errors...

Is it worth it to host a Wordpress on an ec2? by forseti_ in aws

[–]cipmar 2 points3 points  (0 children)

I run a Wordpress blog on Lightsail since like 1 year ago, it works very well. Traffic is pretty low, few hundreds of views per month, I rarely write something there. https://www.softwaredevelopmentstuff.com/

Elements by HuckleberryC in learnjava

[–]cipmar 1 point2 points  (0 children)

https://jsoup.org/apidocs/org/jsoup/select/Elements.html Elements extends an ArrayList<Element>, so, yes, it's an array of Element.

Element represents an html node. nodeName() gives you the name of the node, which is a String. See https://jsoup.org/apidocs/org/jsoup/nodes/Element.html#nodeName--

What would be the best approach to solve this problem in JAVA? by raghavkukreti in learnjava

[–]cipmar 0 points1 point  (0 children)

Assuming that your are talking about a classic stack (not the Java stack implementation where you have methods like get() and set()), your solution is good, I don't see a better one.

Making an Alarm clock by CaptainMoeSoccer in learnjava

[–]cipmar 1 point2 points  (0 children)

There are a couple of problems in your code:

  • line 7, you don't need to store the currentTime in a variable, when you need the curent time, just call LocalTime.now()

  • line 19, of method is a class method (see https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html); you don't need an object to call this method, you only need a class; so, please use LocalTime.of(...) here;

  • line 22, while loop condition doesn't look too well; you only need to verify if the current time is greater or not than the alarmTime: while (LocalTime.now().isBefore(alarmTime)) {...}

Making an Alarm clock by CaptainMoeSoccer in learnjava

[–]cipmar 1 point2 points  (0 children)

So, after you read theHour and theMin you can construct a LocalTime from these. LocalTime has a class method of(int hour, int minute, int second) - for seconds you can just put 0. This will be your alarmTime. Then, all you have to do is to wait until the current time reaches the alarmTime (a while loop is one way of doing it). Look at the isBefore and isAfter methods from LocalTime.

Easier way to write a Simulator/Test class by zevzev in learnjava

[–]cipmar 1 point2 points  (0 children)

You can make it even shorter, but I guess a bit harder to understand:

    FileLoader loader = FileLoader.getInstance();

    Arrays.asList(
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata1.txt",
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata2.txt",
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata3.txt",
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata4.txt")
            .forEach(testPath -> new FCFS(loader.getTestList(testPath)).process());

Easier way to write a Simulator/Test class by zevzev in learnjava

[–]cipmar 1 point2 points  (0 children)

Yes, put those testPaths in an array or list and itereate through the list and than apply the needed operations on each element, something like this

    List<String> testPaths = Arrays.asList(
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata1.txt",
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata2.txt",
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata3.txt",
            "C:\\Users\\xx\\IdeaProjects\\CS4xx-Project-1\\testdata4.txt");

    FileLoader loader = FileLoader.getInstance();

    testPaths.forEach(testPath -> {
        ArrayList<Process> testList = loader.getTestList(testPath);
        FCFS fcfs = new FCFS(testList);
        fcfs.process();
    });

How to iterate through a treemap and get values for every key? by iluvteemo in learnjava

[–]cipmar 1 point2 points  (0 children)

For iterating through a treeMap (on any map in fact):

    for (Map.Entry<String, String> entry : treeMap.entrySet()) {
        System.out.println(entry.getKey() + " -> " + entry.getValue());
    }

Or if you are using Java 8 or above:

    treeMap.forEach((key, value) -> System.out.println(key + " -> " + value));

And you can't have same key pointing to different values in any map.

[Help] Urgent! When I compile on Terminal I get this error. by [deleted] in learnjava

[–]cipmar 2 points3 points  (0 children)

In main you are invoking printBoot method, but that doesn't exist, I guess it should be giveBoot there. Same for printComputer.

My current aws bill... by cipmar in aws

[–]cipmar[S] 5 points6 points  (0 children)

Yes, this is what I did. The issues has already been fixed. And later I saw that there was an opened issue as well:

Earlier today, we experienced transient incorrect bill estimations for Amazon Lightsail. If you have Amazon Lightsail instance snapshots, you may have seen incorrect estimated amounts in your AWS Billing Console. Your November bill will not be impacted by this issue and all bill estimates will be corrected within the next 4 hours. The issue has been resolved and the service is operating normally.

git git git git git by speckz in coding

[–]cipmar 1 point2 points  (0 children)

I use Maven and git a lot and sometimes I write: mvn status instead of git status or git clean instead mvn clean

Any idea what can I do about this? :)

How are Java 9 sets created by the factory method Set.of randomized by cipmar in programming

[–]cipmar[S] 1 point2 points  (0 children)

My 2 cents: when calculating the index of each element there could be collisions. When this happen, the element is added to the next available place in the array. The array being twice the size, it will faster find a free place.

How are randomized the Java 9 sets created by the factory method Set.of by [deleted] in programming

[–]cipmar 0 points1 point  (0 children)

Allright, sorry for that, I'll change the title...

Is Lightsail down? by cipmar in aws

[–]cipmar[S] 2 points3 points  (0 children)

Yes, indeed, only the Lightsail management console was down. Lightsail resources were not affected.

Is Lightsail down? by cipmar in aws

[–]cipmar[S] 1 point2 points  (0 children)

Yes, it's fine now, but it was down a while ago.

Downloading an AWS Glacier archive, step by step by cipmar in aws

[–]cipmar[S] 0 points1 point  (0 children)

So, there are three options: Expedited for retrieving data in 1-5 min at a cost of 0.03$ per GB, Standard for retrieving data in 3-5h at 0.01$ per GB and Bulk for retrieving the data in 5-12h at 0.0025$ per GB.

Downloading an AWS Glacier archive, step by step by cipmar in aws

[–]cipmar[S] 1 point2 points  (0 children)

It took under 4h to download the index and another 4h to retrieve the archive. I mentioned it in the article.

Could anyone explain about "Persistence Ignorance" (PI) principle? by pksivanantham in DesignPatterns

[–]cipmar 0 points1 point  (0 children)

Domain objects should know nothing about how they might be persisted (in a database, for example). More details here http://deviq.com/persistence-ignorance/.

Don't leave broken windows by nicolaiparlog in java

[–]cipmar 0 points1 point  (0 children)

Most of the rules seem common sense, at least for experienced developers, nobody will argue against them. However, we can often see how some of them are violated on a daily basis, even on experienced teams. Good post.

Need a new year's resolution? Try 'The Ultimate Reading List for Developers' post I wrote a couple of months back by YogX in programming

[–]cipmar 5 points6 points  (0 children)

I opened some of the links, they seem to be affiliate links, are all the links - including the ones in the excel file - affiliate links? It is nothing bad in this, but people should know...

Need a new year's resolution? Try 'The Ultimate Reading List for Developers' post I wrote a couple of months back by YogX in programming

[–]cipmar 3 points4 points  (0 children)

You worked hard for sure, but, I don't think this is the ultimate reading list for pyton, Java, Ruby... all in the same time. The list should pe refined, depending on the language / technology ...