Yep, you can't call that copy function as it is written unless you construct a new object of the class it is contained within, which I assume is a Node of some kind.
Rewriting to static should work, and if you don't want to return anything, you can make the method static void.
I tried to do static void, but then Eclipse complains about the generics. Something about "Cannot make a static reference to a non-static type"?
Yep, you can't call that copy function as it is written unless you construct a new object of the class it is contained within, which I assume is a Node of some kind.
Rewriting to static should work, and if you don't want to return anything, you can make the method static void.
I tried to do static void, but then Eclipse complains about the generics. Something about "Cannot make a static reference to a non-static type"?
Oh yeah. I don't know what that extra (first) <K,V> is in the header for clone.
That was the function header given to use for use by the lecturer, without explanation.
Or he might've explained it in a class I missed. >.>
Right now your problem has nothing to do with the generics. But it's really hard to say what the problem is without seeing all of your code, or at least knowing which lines are causing the error.
I honestly suspect it might just be that extra <K,V> in there, but maybe the latest Java versions do something with generics I don't know about. What happens if you just delete that first <K,V>?
So there's multiple issues going on here. First, static methods cannot call non-static methods. So we need to make copy a static method, but if we do that, it yells at us about the generics. We could also solve the problem by making the clone method non-static, or by providing an instance of a class to call the copy method with inside of clone.
So this is an idiosyncracy about Java generics I guess. It doesn't know what <K,V> is because it's a generic, so it needs to infer it by the return type of the method.
So you're right, you probably do need a return type of <K,V> even though you don't want to return anything, because otherwise the compiler yells at you.
So finishing up my semester and I want to do a project to pad a portfolio. At my current job we record everything in a google sheet for charging airlines for using certain gates. It was something I helped them start doing 5 years ago because we were just hand writing it and scanning those to pdfs. It is far from elegant though.
So my plan is to write a program in c# and use a sql database. I know my boss doesn't like technology particularly but he can be convinced provided there are enough backups. If he ends up not wanting to do it that won't bother me too much because it'll be some much needed experience.
I was wondering what pitfalls I should be looking out for because this will be my first full fledged project. While I know a bit of sql, it was basically an introductory class.
So there's multiple issues going on here. First, static methods cannot call non-static methods. So we need to make copy a static method, but if we do that, it yells at us about the generics. We could also solve the problem by making the clone method non-static, or by providing an instance of a class to call the copy method with inside of clone.
What? No. This works fine. Heck, main is a static method.
public class Test {
public int notStatic() {
return 10;
}
public static int isStatic(Test test) {
return test.notStatic();
}
}
As for the generic issue, I legitimately do not understand generic methods at all and am reading about them now
Parameterize your SQL queries. Don't hard code them or draw the values directly from the user somehow, then you end up with this happening:
Edit: Terminology
Haha jokes on them, my students' table is named [Student1998-99XLS] because it was imported from an old excel spreadsheet and noone has ever changed the name of it.
"Simple, real stupidity beats artificial intelligence every time." -Mustrum Ridcully in Terry Pratchett's Hogfather p. 142 (HarperPrism 1996)
Has anyone used dotCover by JetBrains? I have a problem where my code coverage apparently ignores stuff that is definitely covered. All the tests for said code are green, but it's registered as uncovered by dotCover.
So there's multiple issues going on here. First, static methods cannot call non-static methods. So we need to make copy a static method, but if we do that, it yells at us about the generics. We could also solve the problem by making the clone method non-static, or by providing an instance of a class to call the copy method with inside of clone.
So this is an idiosyncracy about Java generics I guess. It doesn't know what <K,V> is because it's a generic, so it needs to infer it by the return type of the method.
So you're right, you probably do need a return type of <K,V> even though you don't want to return anything, because otherwise the compiler yells at you.
You could also do something like this to fix it, assuming these methods are both in the AVLTree class:
public static <K,V> AVLTree<K,V> clone(AVLTree<K,V> tree) {
AVLTree<K,V> tmpTree = new AVLTree<K,V>();
// Create empty root node and add to AVLTree
AVLNode<K,V> newRoot = new AVLNode<K,V>();
tmpTree.root = newRoot;
// Recursively loop through 'tree' and add nodes to 'tmpTree'
tree.copy(tree.root, tmpTree.root);
return tmpTree;
}
Interesting!
I also found that I don't need to return a value by declaring:
private static <K,V> void copy()
which the compiler is totally happy with. Working on my print function to see if I'm correctly copying the data or not, since we have to graphically print the tree with specific shapes.
So, sort of programming, sort of sys admin question here. We are building a service running on Ubuntu 14.04 LTS but we need newer Java than 7. It appears that the only way to get OpenJDK 8 or Oracle Java 8/9 is from a 3rd party PPA. It looks like this is super common/standard, but I know fuck all about PPA's in general or this specific webupd8 team PPA?
Is this cool to do? Is installing OpenJDK 8 or possibly Oracle Java 9 from this PPA for a production environment safe to do?
Could you not just download Sun's Java and install the debian/ubuntu package? It's far easier than mucking about with apt's shit. Though you lose the update ability, which can be a curse or a blessing with Java specifically.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
So, sort of programming, sort of sys admin question here. We are building a service running on Ubuntu 14.04 LTS but we need newer Java than 7. It appears that the only way to get OpenJDK 8 or Oracle Java 8/9 is from a 3rd party PPA. It looks like this is super common/standard, but I know fuck all about PPA's in general or this specific webupd8 team PPA?
Is this cool to do? Is installing OpenJDK 8 or possibly Oracle Java 9 from this PPA for a production environment safe to do?
PPAs are safe for production, so long as you acknowledge that you're trusting an additional source and what that entails.
If a PPA goes rogue or is hacked, that's a potential vector of attack. But you can review the updates before installing them, you don't autoinstall in production right?
apt is as straightforward as anything, I just don't know anything about this PPA stuff. OpenJDK appears to be only via official apt repos based on their install page and they do not have an Ubuntu 14.04 OpenJDK 8 in the official main repo. Oracle Java 9 is a shitty download the .tar.gz, gunzip, untar, and then you just have precompiled bins and have to much with getting paths right yourself, etc. Proper apt installation is way more straightforward as long as it's not going to just suddenly disappear on me or something because it was being maintained by some 14 year old who got bored.
I just learned today that the framework that I helped write and am currently still working on pushes over 160 GB of customer day every day with a 0.02% error rate of transactions delivered.
Alright, any docker and perhaps specifically docker-cloud experts in the house? Got a multi service stack up and running just fine and dandy with a shared data volume. But if I try to start a 2nd container in a service, that one complains `ERROR: 'volumes_from' data not found for django-2`. It's on the same node as django-1, which is of course using the same `volumes_from` as are 2 other services. There are no other errors showing anywhere to give me any hints as to what the problem is.
Alright, any docker and perhaps specifically docker-cloud experts in the house? Got a multi service stack up and running just fine and dandy with a shared data volume. But if I try to start a 2nd container in a service, that one complains `ERROR: 'volumes_from' data not found for django-2`. It's on the same node as django-1, which is of course using the same `volumes_from` as are 2 other services. There are no other errors showing anywhere to give me any hints as to what the problem is.
Paging @GnomeTank , I think he's the resident Docker expert in the thread.
I'm considering just saying fuck it and not using the data only container. I think that will solve this problem at the expense of needing to maintain the configuration of remembering to mount the same host directory on every service separately.
GnomeTankWhat the what?Portland, OregonRegistered Userregular
edited April 2016
By "start a second container in a service" you mean bringing up a second instance of the same image, for scaling purposes? (Or in your case to possibly test scaling?) How are you composing your stack, docker-compose? What are you storing in your data volume? If it's like database files, there's a different way to do what you're trying to do which is to mount your database container to have a host volume and just link the db container to service containers. Are you trying to use a container as an actual shared volume store for a bunch of service containers?
Parameterize your SQL queries. Don't hard code them or draw the values directly from the user somehow, then you end up with this happening:
Edit: Terminology
Also you know, don't run your application as a user that has the ability to drop tables, or delete data that shouldn't be deleted.
Figure out what tables, views, and stored procedures they need access to, and give only the access necessary to execute the queries you're allowing in your application.
By "start a second container in a service" you mean bringing up a second instance of the same image, for scaling purposes? (Or in your case to possibly test scaling?) How are you composing your stack, docker-compose? What are you storing in your data volume? If it's like database files, there's a different way to do what you're trying to do which is to mount your database container to have a host volume and just link the db container to service containers. Are you trying to use a container as an actual shared volume store for a bunch of service containers?
We're using docker cloud (https://cloud.docker.com/) which is like 99% docker compose (just a few differences in supported features) with a gui on top and manages nodes, containers, etc. on any number of actual cloud hosting services. In our case, AWS. So you slide the little slider for number of containers on the service over to 2, hit apply, then redeploy and theoretically you get two containers.
So what we had was an nginx service, a django service, a datacontainer service. We need a shared volume so that django can write user uploaded files, create files used across multiple django instances, store static css/js/images, etc. and have nginx serve them. For now they are being hosted locally rather than using s3 or whatnot for a variety of reasons. The separate data only container was based on what all of the docker docs seemed to be recommending for a shared persistent volume like that. I could ditch the data only container and have the volume on the nginx container, but as far as "volumes_from" failing there should be no difference.
I could start the stack with the three services and one container each just fine. Flip the switch to scale the django service to 2 containers, redeploy, and get the useless error "ERROR: 'volumes_from' data not found for django-2" displayed in docker cloud's logs with no other details anywhere. As best as I can guess that means the second container there can't see the volumes from our data container, but there's no reason why that would be made clear anywhere.
For now I have gone ahead and just dropped the data only container and each service which needs the shared volume will just have to explicitly specify volume and use the same host directory source. It's a tiny bit more to maintain, but it functions properly. I think it will also actually work better if we need to run multiple nodes (separate EC2 instances) for the same stack. Using volumes_from, every container has to be on the same node (enforced automatically by docker cloud), which ties you to a single EC2 instance. By just directly mapping each one to the same host directory we could shove that on EBS and share that between multiple EC2 instances and it should keep chugging along happily.
Parameterize your SQL queries. Don't hard code them or draw the values directly from the user somehow, then you end up with this happening:
Edit: Terminology
Also you know, don't run your application as a user that has the ability to drop tables, or delete data that shouldn't be deleted.
Figure out what tables, views, and stored procedures they need access to, and give only the access necessary to execute the queries you're allowing in your application.
lol, good luck getting the system admin to give you that ability instead of just a single username that has su privileges to the database and then whine and bitch about making additional usernames.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
By "start a second container in a service" you mean bringing up a second instance of the same image, for scaling purposes? (Or in your case to possibly test scaling?) How are you composing your stack, docker-compose? What are you storing in your data volume? If it's like database files, there's a different way to do what you're trying to do which is to mount your database container to have a host volume and just link the db container to service containers. Are you trying to use a container as an actual shared volume store for a bunch of service containers?
We're using docker cloud (https://cloud.docker.com/) which is like 99% docker compose (just a few differences in supported features) with a gui on top and manages nodes, containers, etc. on any number of actual cloud hosting services. In our case, AWS. So you slide the little slider for number of containers on the service over to 2, hit apply, then redeploy and theoretically you get two containers.
So what we had was an nginx service, a django service, a datacontainer service. We need a shared volume so that django can write user uploaded files, create files used across multiple django instances, store static css/js/images, etc. and have nginx serve them. For now they are being hosted locally rather than using s3 or whatnot for a variety of reasons. The separate data only container was based on what all of the docker docs seemed to be recommending for a shared persistent volume like that. I could ditch the data only container and have the volume on the nginx container, but as far as "volumes_from" failing there should be no difference.
I could start the stack with the three services and one container each just fine. Flip the switch to scale the django service to 2 containers, redeploy, and get the useless error "ERROR: 'volumes_from' data not found for django-2" displayed in docker cloud's logs with no other details anywhere. As best as I can guess that means the second container there can't see the volumes from our data container, but there's no reason why that would be made clear anywhere.
For now I have gone ahead and just dropped the data only container and each service which needs the shared volume will just have to explicitly specify volume and use the same host directory source. It's a tiny bit more to maintain, but it functions properly. I think it will also actually work better if we need to run multiple nodes (separate EC2 instances) for the same stack. Using volumes_from, every container has to be on the same node (enforced automatically by docker cloud), which ties you to a single EC2 instance. By just directly mapping each one to the same host directory we could shove that on EBS and share that between multiple EC2 instances and it should keep chugging along happily.
Did you try chaining the volume-froms? Instead of django-1 <-> data, django-2 <-> data, do django-1 <-> data, django-2 <-> django-1. This is normally how I see data volumes used, through chaining. I'll admit I don't use volume-from a lot, so I can't be a ton of help beyond that. From reading the documentation your setup should just work with or without chaining.
Last night I had a verbal sparring match with one recruiter where he refused to accept that I wasn't going to talk with him about salary. Why would I tell you what I make at my current job? That makes no sense, I'm not an idiot dude.
Last night I had a verbal sparring match with one recruiter where he refused to accept that I wasn't going to talk with him about salary. Why would I tell you what I make at my current job? That makes no sense, I'm not an idiot dude.
Tell him what you make +35%.
not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
Last night I had a verbal sparring match with one recruiter where he refused to accept that I wasn't going to talk with him about salary. Why would I tell you what I make at my current job? That makes no sense, I'm not an idiot dude.
Mmm, but did you say what is your expected range at least?
Last night I had a verbal sparring match with one recruiter where he refused to accept that I wasn't going to talk with him about salary. Why would I tell you what I make at my current job? That makes no sense, I'm not an idiot dude.
Mmm, but did you say what is your expected range at least?
No, I don't talk about salary on the first conversation. Anything that the company offers will be more than what I currently make anyways, since I make in the bottom 25% of software developers in NYC.
I can only lose by talking about salary that early. Either I give a number that is too high and they decide to call things off right there, or I lowball myself when they would have offered me more. There is no benefit for me at this point to discuss it.
Oh, and I sure as hell am not going to tell them that I'm paid like crap right now. I want a competitive offer, and I'd rather walk away than get lowballed again.
Edit: I speak from experience here, that's how I found myself in my current situation. I was desperate for a job right after college and gave the first number, and now a few years later I'm feeling the pain. Now that I have experience and some leverage, I am not making the same mistake again.
That's ok, you clearly know your situation better. In my experience, 95% of available positions are on a budget. Interviewing out of budget, be it too high or too low (and when you go via recruiters, there are a lot of bad ones that will allow that) is a complete waste of time for both parties.
That's ok, you clearly know your situation better. In my experience, 95% of available positions are on a budget. Interviewing out of budget, be it too high or too low (and when you go via recruiters, there are a lot of bad ones that will allow that) is a complete waste of time for both parties.
Yeah, that's rough too. If they really push for a number, I'll go with Bowen's suggestion. Definitely not telling them my current salary, though.
Posts
AAAAAAH stop writing tags like that!
I tried to do static void, but then Eclipse complains about the generics. Something about "Cannot make a static reference to a non-static type"?
That was the function header given to use for use by the lecturer, without explanation.
Or he might've explained it in a class I missed. >.>
Right now your problem has nothing to do with the generics. But it's really hard to say what the problem is without seeing all of your code, or at least knowing which lines are causing the error.
I honestly suspect it might just be that extra <K,V> in there, but maybe the latest Java versions do something with generics I don't know about. What happens if you just delete that first <K,V>?
So this is an idiosyncracy about Java generics I guess. It doesn't know what <K,V> is because it's a generic, so it needs to infer it by the return type of the method.
So you're right, you probably do need a return type of <K,V> even though you don't want to return anything, because otherwise the compiler yells at you.
You could also do something like this to fix it, assuming these methods are both in the AVLTree class:
So my plan is to write a program in c# and use a sql database. I know my boss doesn't like technology particularly but he can be convinced provided there are enough backups. If he ends up not wanting to do it that won't bother me too much because it'll be some much needed experience.
I was wondering what pitfalls I should be looking out for because this will be my first full fledged project. While I know a bit of sql, it was basically an introductory class.
*word
Edit: Terminology
An example of how to do this.
http://www.entityframeworktutorial.net/
What? No. This works fine. Heck, main is a static method.
As for the generic issue, I legitimately do not understand generic methods at all and am reading about them now
Haha jokes on them, my students' table is named [Student1998-99XLS] because it was imported from an old excel spreadsheet and noone has ever changed the name of it.
Interesting!
I also found that I don't need to return a value by declaring:
private static <K,V> void copy()
which the compiler is totally happy with. Working on my print function to see if I'm correctly copying the data or not, since we have to graphically print the tree with specific shapes.
Is this cool to do? Is installing OpenJDK 8 or possibly Oracle Java 9 from this PPA for a production environment safe to do?
I just found another OpenJDK PPA at https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa which appears to be different from the webupd8 one which I usually see mentioned in everything I am reading so far.
PPAs are safe for production, so long as you acknowledge that you're trusting an additional source and what that entails.
If a PPA goes rogue or is hacked, that's a potential vector of attack. But you can review the updates before installing them, you don't autoinstall in production right?
Paging @GnomeTank , I think he's the resident Docker expert in the thread.
Also you know, don't run your application as a user that has the ability to drop tables, or delete data that shouldn't be deleted.
Figure out what tables, views, and stored procedures they need access to, and give only the access necessary to execute the queries you're allowing in your application.
We're using docker cloud (https://cloud.docker.com/) which is like 99% docker compose (just a few differences in supported features) with a gui on top and manages nodes, containers, etc. on any number of actual cloud hosting services. In our case, AWS. So you slide the little slider for number of containers on the service over to 2, hit apply, then redeploy and theoretically you get two containers.
So what we had was an nginx service, a django service, a datacontainer service. We need a shared volume so that django can write user uploaded files, create files used across multiple django instances, store static css/js/images, etc. and have nginx serve them. For now they are being hosted locally rather than using s3 or whatnot for a variety of reasons. The separate data only container was based on what all of the docker docs seemed to be recommending for a shared persistent volume like that. I could ditch the data only container and have the volume on the nginx container, but as far as "volumes_from" failing there should be no difference.
I could start the stack with the three services and one container each just fine. Flip the switch to scale the django service to 2 containers, redeploy, and get the useless error "ERROR: 'volumes_from' data not found for django-2" displayed in docker cloud's logs with no other details anywhere. As best as I can guess that means the second container there can't see the volumes from our data container, but there's no reason why that would be made clear anywhere.
For now I have gone ahead and just dropped the data only container and each service which needs the shared volume will just have to explicitly specify volume and use the same host directory source. It's a tiny bit more to maintain, but it functions properly. I think it will also actually work better if we need to run multiple nodes (separate EC2 instances) for the same stack. Using volumes_from, every container has to be on the same node (enforced automatically by docker cloud), which ties you to a single EC2 instance. By just directly mapping each one to the same host directory we could shove that on EBS and share that between multiple EC2 instances and it should keep chugging along happily.
lol, good luck getting the system admin to give you that ability instead of just a single username that has su privileges to the database and then whine and bitch about making additional usernames.
Did you try chaining the volume-froms? Instead of django-1 <-> data, django-2 <-> data, do django-1 <-> data, django-2 <-> django-1. This is normally how I see data volumes used, through chaining. I'll admit I don't use volume-from a lot, so I can't be a ton of help beyond that. From reading the documentation your setup should just work with or without chaining.
Last night I had a verbal sparring match with one recruiter where he refused to accept that I wasn't going to talk with him about salary. Why would I tell you what I make at my current job? That makes no sense, I'm not an idiot dude.
Tell him what you make +35%.
Mmm, but did you say what is your expected range at least?
No, I don't talk about salary on the first conversation. Anything that the company offers will be more than what I currently make anyways, since I make in the bottom 25% of software developers in NYC.
I can only lose by talking about salary that early. Either I give a number that is too high and they decide to call things off right there, or I lowball myself when they would have offered me more. There is no benefit for me at this point to discuss it.
Oh, and I sure as hell am not going to tell them that I'm paid like crap right now. I want a competitive offer, and I'd rather walk away than get lowballed again.
Edit: I speak from experience here, that's how I found myself in my current situation. I was desperate for a job right after college and gave the first number, and now a few years later I'm feeling the pain. Now that I have experience and some leverage, I am not making the same mistake again.
Yeah, that's rough too. If they really push for a number, I'll go with Bowen's suggestion. Definitely not telling them my current salary, though.
Because if they would normally offer Z and know you make X and X + Y% < Z then they can get away with offering less