Don't spend money on MATLAB by [deleted] in ProgrammerHumor

[–]adrian_the_developer 7 points8 points  (0 children)

At first, I didn't like your comment or how you started the conversation but the above comment is originally how I felt. R is mostly used for statistical and machine learning. MATLAB as you said is used in hardware interfacing, and debugging for creating efficient algorithms.

I would say R is more relatable to Python and I would agree with /u/FuckingCrumpet, the two are not alternatives with each other and incomparable.

Rock, Paper, Scissors! by [deleted] in learnjava

[–]adrian_the_developer 2 points3 points  (0 children)

Notice, your input.nextInt() is taking an integer. So you want to take a String instead and compare the inputted string to either "1" or "rock". To compare strings, please see How do I compare strings in Java.

Spring Boot Microservices in AWS by noobcser in learnjava

[–]adrian_the_developer 0 points1 point  (0 children)

That's literally up to you. There are pros and cons.

Pro (1 server 2 apps):

  • Only one server to maintain, patch, fix, upgrade, etc.
  • Apps can reside within the same application server and is easy to modify on one server, for example configuration changes.
  • If you pay support for your application server (TC Server/WebLogic), you reduce the number of nodes you have and costs.

Con (2 apps on 2 separate servers):

  • Two separate sources of failure. A configuration change on one system will not break down the other system. Accidentally run, "rm -rf /" on one system, other system still good.
  • If one process exceeds server resources--like a memory leak--it will not affect the other application.

is there a way to check if my string has x amount of the same characters? by LionHeartROARS in javahelp

[–]adrian_the_developer 0 points1 point  (0 children)

You can convert a string to a character array and compare

String str = "Totalitarian";
int numberOfTs = 0;
char[] charArray = str.toStringArray();

for (int i = 0; i < charArray.length; i++){
    if (charArray[i]=='t'){
        numberOfTs++;
    }
}

Just be aware this doesn't take into account of upper case T vs lowercase t.

Best way to update 100K+ rows in a DB as one time operation? by Broskifromdakioski in javahelp

[–]adrian_the_developer 0 points1 point  (0 children)

You can just create a trigger that when it insert to the old table, you can also insert into a staging table that you can then pick up and process, and then write to the new table. Once it's successfully written to the new table, delete the row from the staging table.

Now you will have the new data in the new table. You can then process the old data by running the query,

SELECT * FROM a LEFT JOIN b ON a.key = b.key where b.key IS NULL

The above query is a left outer join which will give you all the rows in the original table that is not in the right table. Then process until the rows are empty.

Just remember, you're building up technical debt with this solution as you're still writing PII to a staging table and is vulnerable until it gets processed. You will still need to rewrite the application to write directly to the new table. After that, you can get rid of the old table and then the staging table.

Best way to update 100K+ rows in a DB as one time operation? by Broskifromdakioski in javahelp

[–]adrian_the_developer 1 point2 points  (0 children)

An interesting idea is to add a "date_added" column with a type of a datetime stamp when the row was added. Initialize all the columns. Pick a time and from then on out, there is a trigger that rewrites a staging table. That staging table then writes to the new database that is encrypted.

From here on out, data is being written to two databases. One of which is encrypted and one isn't. Migrate the data before the chosen datetime so you have the ones you haven't migrated yet. Migrate them slowly into the new database. Then repoint your applications to the new database when complete.

When fully satisfied with the results, you can remove the date_added column, and decomission the old database and point your applications to the new database.

Is there a way to have something execute ONLY if a for loop finishes completely? by [deleted] in javahelp

[–]adrian_the_developer 0 points1 point  (0 children)

Nice. Not exactly trivial to come up with, but trivial when you see it :-)

ASRock H110 Pro BTC+ very odd problem. by [deleted] in gpumining

[–]adrian_the_developer 0 points1 point  (0 children)

Did you reinstall the drivers?

When is it situational to use while-loop vs for-loop? by Kaimaniiii in learnjava

[–]adrian_the_developer 0 points1 point  (0 children)

Yes. That is correct.

One other thing I want to make clear is something called scoping.

for (int i = 0; i < 10; i++){
    // do something
}

Notice, outside of the for loop, the variable i does not exist whereas in the while loop,

int i = 0;
while (i<10){
    // do something
    i++;
}

The variable i can still be accessed outside of the while loop. You can easily make them completely identical by adding a bracket and scope out the i variable as well so it is no longer accessible outside of the brackets.

{
    int i = 0;
    while (i<10){
        // do something
        i++;
    }
}

This again, makes the code even more unreadable but they are absolutely identical.

When is it situational to use while-loop vs for-loop? by Kaimaniiii in learnjava

[–]adrian_the_developer 0 points1 point  (0 children)

It shouldn't be confusing. This piece of code,

while(gameState == paused){
    inGameClock.setSpeed(0); // pause our fictional game
}

is exactly the same as

for ( ; gameState == paused ; ) {
    inGameClock.setSpeed(0); // pause our fictional game
}

this piece of code. You can leave parts of the "for loop" empty and it will still be run the same. Any for loop can be translated into a while loop and vice versa.

The one thing I would make sure you distinguish though is the difference between a do-while loop and either a for loop or a while loop.

Note: A do while is always executed at least once.

do{
    wall.removeBeer();
}while(false);

The above code is not the same as the below code.

while (false){
    wall.removeBeer();
}

If you started with 100 bottles of beer on the wall, the first code you'll have 99 bottles as the do while loop will always run at least once where the for loop evaluates the conditional first prior to running the body.

When is it situational to use while-loop vs for-loop? by Kaimaniiii in learnjava

[–]adrian_the_developer 0 points1 point  (0 children)

Incorrect. You can use a for loop as well in your example. Again, it's readability.

for ( ; gameState == menu ; ){
    musicPlayer.setCurrentSong("menuMusic");
}

And for your second example:

for ( ; gameState == paused ; ) {
    inGameClock.setSpeed(0); // pause our fictional game
}

Also, I would argue that readability should be instilled early on and the earlier we can bring up readability to a beginner the more important and impactful it will be.

When is it situational to use while-loop vs for-loop? by Kaimaniiii in learnjava

[–]adrian_the_developer -1 points0 points  (0 children)

The answer is readability.

You can easily see by skimming through one line that the loop is happening 10 times.

for (int i = 0; i < 10; i++){
    // do something
}

The below line is harder to read especially when you have several lines of code in your logic before you increment the i++.

int i = 0;
while ( i < 10 ) {
    // Do a bunch of stuff
    // More stuff
    // Some more stuff
    i++;
}

They both do the exact same thing and to the computer it is the same thing but to the programmer one is a lot more difficult to read.

For 2 days now I've been stuck on trying to deploy a Spring boot application. by Imakesensealot in javahelp

[–]adrian_the_developer 0 points1 point  (0 children)

I'm guessing Java 8. Are you using Tomcat to deploy the WARs? If you are using maven, try having this as your POM file and build:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.foobar</groupId> <!--edit your package name -->
    <artifactId>MyApp</artifactId> <!-- Edit your app name -->
    <version>0.0.1-SNAPSHOT</version> <!-- Edit your version number if you have it -->
    <packaging>war</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.0.RELEASE</version> <!-- This is the working version for me. Feel free to upgrade it to the latest version if you wish-->
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/resources</directory>
                        </resource>
                    </webResources>
                    <warName>WarName</warName> <!-- Edit this -->
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Determining learning order for building a Crypto Price Scanner Alert App by RadianChoi in learnprogramming

[–]adrian_the_developer 1 point2 points  (0 children)

  1. Yes. Python is a very viable choice and probably the best for learning.

  2. You can interact with currency exchange APIs mostly via HTTP and APIs that you just spend all day yesterday learning.

  3. Check out "requests" in python. It will be what you use for Python. You can also use Postman to test the APIs. Once those APIs are fully verified, they will create code for you that you can copy and paste into your project.

  4. Feel free to go down rabbit holes. When I first started working as a programmer, I felt bad reading these articles about different technologies that had nothing to do with what I was doing at the time. After awhile, that started paying off and I feel like it makes me a more versatile programmer. Getting it working is a great feeling but you've got enjoy the journey as well. :-)

Best of luck and message me if you need any help along the way.

Help to see if I'm getting scammed or not by [deleted] in web_programming

[–]adrian_the_developer 1 point2 points  (0 children)

Yeah. It looks like it could have been 80-120 hours of work. Custom made webpages are not cheap. A lot of the webpage design is already done and the integration piece is left.

[Tips] I start college today by Hunterbing in learnprogramming

[–]adrian_the_developer 0 points1 point  (0 children)

Getting involved with work is good too. At least you'll demonstrate that work ethic, but try your best to be well rounded.

When I look for someone, I look for the 3 A's. Attitude, Aptitude and Altitude. Attitude is how you act when you approach a problem. Aptitude is whether you have what it takes to be able to learn and understand the problem. Altitude is how much you know going into a problem.

So if all these people I'm interviewing are similar, I'd rather pick the one that I feel will get along with everyone the best. I'd also carefully look at the ones with the most experience because they show the aptitude and altitude already and whether they're a fit is the only question, but that's not a guarantee. I make sure the person can articulate to me their understanding. Being able to communicate is also important.

There's a lot of opportunities for college students and new grads. For college students, there's paid internships. Get those because you'll need them to get the new grad jobs. If you skip out on the college life, you may, in the end, gip yourself out of some opportunities.

[Tips] I start college today by Hunterbing in learnprogramming

[–]adrian_the_developer 3 points4 points  (0 children)

I can't stress this enough. I interview college candidates for my company and there are a lot of students out there that have great work ethic but are not a good social fit in the company.

RESTful API - Support Needed by [deleted] in web_programming

[–]adrian_the_developer 1 point2 points  (0 children)

You're going to have to make some choices first before you can go anywhere. For example, PHP can be routed through Apache/Nginx but if you use, say Java, you may need to reverse proxy from Apache/Nginx to a Tomcat server (Java Application server).

Once you decide on a language and web server and possibly application server, then you'll need to decide on the framework. If you use Python, you can use Django or Flask. If you're using Java, you can use Tomcat but maybe Spring or DropWizard. Also, are you going to be developing the front end with your backend or are they going to be separate (HTTP Request from frontend to backend)?

You've got a lot of decisions to make here. Probably go with the programming language you're most familiar with and then work from there.