As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

[Programming] Mirror, mirror, on the wall, show the git diff for them all

18687899192100

Posts

  • Options
    hippofanthippofant ティンク Registered User regular
    Oh yeah. I don't know what that extra (first) <K,V> is in the header for clone.

  • Options
    EchoEcho ski-bap ba-dapModerator mod
    ReactDOM.render( < Search / > ,
    

    AAAAAAH stop writing tags like that!

  • Options
    urahonkyurahonky Registered User regular
    You mean with the spacing?

  • Options
    bowenbowen How you doin'? Registered User regular
    edited April 2016
    < Hopefully / >

    bowen on
    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
  • Options
    CokebotleCokebotle 穴掘りの 電車内Registered User regular
    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"?
    hippofant wrote: »
    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. >.>

    工事中
  • Options
    hippofanthippofant ティンク Registered User regular
    Cokebotle wrote: »
    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"?
    hippofant wrote: »
    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>?

  • Options
    CokebotleCokebotle 穴掘りの 電車内Registered User regular
    If I delete it, then every instance of K/V in that function returns an error with "Cannot make a static reference to the non-static type".

    工事中
  • Options
    SpawnbrokerSpawnbroker Registered User regular
    edited April 2016
    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.
    private static <K,V> copy(Position<Entry<K,V>> oldNode, Position<Entry<K,V>> newNode) {
    

    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;
    }
    

    Spawnbroker on
    Steam: Spawnbroker
  • Options
    PhasenPhasen Hell WorldRegistered User regular
    edited April 2016
    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.

    *word

    Phasen on
    psn: PhasenWeeple
  • Options
    bowenbowen How you doin'? Registered User regular
    Error checking and simultaneous access to data are the biggest.

    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
  • Options
    SpawnbrokerSpawnbroker Registered User regular
    edited April 2016
    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:

    exploits_of_a_mom.png

    Edit: Terminology

    Spawnbroker on
    Steam: Spawnbroker
  • Options
    bowenbowen How you doin'? Registered User regular
    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
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    If you end up using EF this is a neat resource.

    http://www.entityframeworktutorial.net/

  • Options
    hippofanthippofant ティンク Registered User regular
    edited April 2016
    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 :confused:

    hippofant on
  • Options
    bowenbowen How you doin'? Registered User regular
    You need to instantiate the class to call it, is what he's saying. Static cannot access non static methods without an instance.

    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
  • Options
    DisruptedCapitalistDisruptedCapitalist I swear! Registered User regular
    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:

    exploits_of_a_mom.png

    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)
  • Options
    EchoEcho ski-bap ba-dapModerator mod
    edited April 2016
    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.

    Echo on
  • Options
    CokebotleCokebotle 穴掘りの 電車内Registered User regular
    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.
    private static <K,V> copy(Position<Entry<K,V>> oldNode, Position<Entry<K,V>> newNode) {
    

    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.

    工事中
  • Options
    Jimmy KingJimmy King Registered User regular
    edited April 2016
    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?

    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.

    Jimmy King on
  • Options
    bowenbowen How you doin'? Registered User regular
    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
  • Options
    InfidelInfidel Heretic Registered User regular
    Jimmy King wrote: »
    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?

    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?

    OrokosPA.png
  • Options
    Jimmy KingJimmy King Registered User regular
    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.

  • Options
    KolosusKolosus Registered User regular
    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.

  • Options
    Jimmy KingJimmy King Registered User regular
    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.

  • Options
    SpawnbrokerSpawnbroker Registered User regular
    Jimmy King wrote: »
    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.

    Steam: Spawnbroker
  • Options
    Jimmy KingJimmy King Registered User regular
    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.

  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    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?

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    TofystedethTofystedeth Registered User regular
    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:

    exploits_of_a_mom.png

    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.

    steam_sig.png
  • Options
    Jimmy KingJimmy King Registered User regular
    GnomeTank wrote: »
    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.

  • Options
    bowenbowen How you doin'? Registered User regular
    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:

    exploits_of_a_mom.png

    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
  • Options
    TofystedethTofystedeth Registered User regular
    I must have good DBAs then.

    steam_sig.png
  • Options
    GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited April 2016
    Jimmy King wrote: »
    GnomeTank wrote: »
    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.

    GnomeTank on
    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Options
    SpawnbrokerSpawnbroker Registered User regular
    Man, I hate talking to recruiters.

    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.

    Steam: Spawnbroker
  • Options
    bowenbowen How you doin'? Registered User regular
    Man, I hate talking to recruiters.

    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
  • Options
    zeenyzeeny Registered User regular
    Man, I hate talking to recruiters.

    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?

  • Options
    SpawnbrokerSpawnbroker Registered User regular
    edited April 2016
    zeeny wrote: »
    Man, I hate talking to recruiters.

    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.

    Spawnbroker on
    Steam: Spawnbroker
  • Options
    zeenyzeeny Registered User regular
    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.

  • Options
    hippofanthippofant ティンク Registered User regular
    edited April 2016
    It's about the disparity in power. Why doesn't the recruiter start with an offer first?

    hippofant on
  • Options
    SpawnbrokerSpawnbroker Registered User regular
    zeeny wrote: »
    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.

    Steam: Spawnbroker
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    hippofant wrote: »
    It's about the disparity in power. Why doesn't the recruiter start with an offer first?

    Because if they would normally offer Z and know you make X and X + Y% < Z then they can get away with offering less

This discussion has been closed.