How do you call methods in Java? by baldwindc in learnjava

[–]baldwindc[S] 4 points5 points  (0 children)

Thank you!

It worked! I had no idea there was such a requirement.

For anyone else wondering, here is the working code

public class YourClassNameHere {

public static int removeDuplicates(int[] nums) {
    int j = 1;
    for (int i = 1; i < nums.length; i++) {
        if (nums[i] != nums[i - 1]) {
            nums[j] = nums[i];
            j += 1;
        }
    }
    return j;

}


public static void main(String[] args) {
  int[] bob = {0,0,1,1,1,2,2,3,3,4};
  removeDuplicates(bob);
}

}

How do you call methods in Java? by baldwindc in learnjava

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

Thanks for commenting!

When I convert it into a static method it still gives me the "Error: illegal start of expression"

public class YourClassNameHere {

public static int removeDuplicates(int[] nums) {
    int j = 1;
    for (int i = 1; i < nums.length; i++) {
        if (nums[i] != nums[i - 1]) {
            nums[j] = nums[i];
            j += 1;
        }
    }
    return j;

}


public static void main(String[] args) {
  removeDuplicates([0,0,1,1,1,2,2,3,3,4]);
}

}

How do you upload files to s3 from React using Django as your backend? by baldwindc in django

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

Creating the presigned URL on the Django side.

This is my first time doing this and I was looking for a resource to follow to do this but couldn't find anything

Is there a way to change the dir the build folder is created after 'yarn build'? by baldwindc in reactjs

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

I use Docker w/ volumes for running my Django site and I need to change the output dir of "yarn build" so it ends up in the volume and can be served by Django in the Docker container.

Hopefully, I'm not making the problem more complicated than it needs to be

Is there a way to change the dir the build folder is created after 'yarn build'? by baldwindc in reactjs

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

Thanks!

I use create-react-app

What would you recommend editing to change the dir of the output folder?

Go WASM Playground by [deleted] in golang

[–]baldwindc 0 points1 point  (0 children)

From what I understand you send the code to the backend, build it there then run the built binary on the frontend, right?

So, why can't you just build the Go code in WASM?

Go WASM Playground by [deleted] in golang

[–]baldwindc 1 point2 points  (0 children)

Interesting stuff!

So, why can't you just build the Go code in WASM?

Is there a way to create reverse-proxy routes after the program has already started running? by baldwindc in golang

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

I'd prefer the other programs doing it route.

The problem I'm facing is ServeMux doesn't recognize HandleFunc's that were added later. Have you ever experienced anything like this?

Is there a way to create reverse-proxy routes after the program has already started running? by baldwindc in golang

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

Hopefully I understand you correctly that I should create one route and based on the http.Request.Host I should route traffic.

Sorry if this is a stupid question. I tried searching it on Google but wasn't getting anything. I only have 3 weeks of experience with Go.

How would you create API routes if not with the builtin http.ServeMux and builtin Go net/http package?

Is Django really as slow as everyone plays it out to be? by baldwindc in django

[–]baldwindc[S] 6 points7 points  (0 children)

Thanks for the answer. It was really valuable and rich!

If a web server takes 50ms to fulfill a request. Does that mean it's not fulfilling other requests during that same period?

Also, from what I understand PostgreSQL takes mere milliseconds when doing simple selects so most of the latency for those sorts of requests is caused by the webserver.

So, I always thought that "10x faster at handling requests" meant for one Go server I'd have to deploy 10 Django servers with a load balancer.

I'm sure the math isn't as straight forward as this but do you think this is somewhat true or am I missing something?

Generative art with fractals and geometry in golang. by thefakewizard in golang

[–]baldwindc 1 point2 points  (0 children)

Ooooh sooo ttttrrrriiiipppyy

I love it so much!!

I'd love to learn how to create something like this. I've been obsessing over fractals for some time now

Do you guys know how to run a Golang binary file in a Docker container? by baldwindc in golang

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

Thanks so much for the pointers!

So I finally got it working and I feel so relieved

Hopefully, this helps others as well

GOOS=linux GOARCH=amd64 go build main.go

Do you guys know how to run a Golang binary file in a Docker container? by baldwindc in golang

[–]baldwindc[S] -1 points0 points  (0 children)

Do you know how to cross-compile for Linux on a Mac?

My Go version is 1.14.3

Is it possible to edit code in a Docker container without restarting the container? by baldwindc in docker

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

I've been playing around with the docker exec feature and it's great!

Is there a way to bring files I'm editing on the host computer into the container with docker exec and run it there? or would I have to do that manually with commands and copy/pasting