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

#define THREAD_TITLE "PA Programming Thread"

1565758596062»

Posts

  • Options
    KakodaimonosKakodaimonos Code fondler Helping the 1% get richerRegistered User regular
    edited October 2010
    You can use PDFSharp and hack together some sort of Powershell script to combine the PDFs.

    PDFSharp

    Kakodaimonos on
  • Options
    autono-wally, erotibot300autono-wally, erotibot300 love machine Registered User regular
    edited October 2010
    uhm.. yet another regex/c# question:
    I have a html page and want to extract some information from it, like
    <span class="time">34 min</span>
    
    I want to extract the 34 as an int (or float or whatever it is)
    as regex for that I am using
    string timematch = "<span class =\"time\">(.*?) min</span>"
    
    shouldn't this extract the number?

    edit: strike all that, it does.. I forgot to use the proper match group!

    autono-wally, erotibot300 on
    kFJhXwE.jpgkFJhXwE.jpg
  • Options
    InfidelInfidel Heretic Registered User regular
    edited October 2010
    uhm.. yet another regex/c# question:
    I have a html page and want to extract some information from it, like
    <span class="time">34 min</span>
    
    I want to extract the 34 as an int (or float or whatever it is)
    as regex for that I am using
    string timematch = "<span class =\"time\">(.*?) min</span>"
    
    shouldn't this extract the number?

    edit: strike all that, it does.. I forgot to use the proper match group!

    I'd recommend changing the match to (\d+) if you're looking just for integers, or (\d+(\.\d*)) or such for floats, depending on what exactly is acceptable.

    A little bit of detail in your regex can save you a lot of confusion and debugging later down the road, when it unexpectedly starts gobbling up things you didn't want or ever expect it to.

    Infidel on
    OrokosPA.png
  • Options
    EtheaEthea Registered User regular
    edited October 2010
    might want to watch out for stuff like 3.5e3

    Ethea on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited October 2010
    Ethea wrote: »
    might want to watch out for stuff like 3.5e3

    In the minutes field on a webpage? :lol: But yeah, as I said, pick a format that matches what you want instead of always using .*

    Infidel on
    OrokosPA.png
  • Options
    bowenbowen How you doin'? Registered User regular
    edited October 2010
    Anyone want to shed some light why I'm getting a read access violation in a C# program that doesn't use pointers ever? I'm using a function I've used a bunch of times and it goes through, does what it's supposed to do, the program keeps going, but as soon as I pass over to a new form the app crashes with an exception. As soon as I comment out the function call (Which does nothing to the new form), it works fine.

    For example:
    this.Hide();
    
    //commenting this line causes the crash to go away
    User aUser = User.GetUserByUsername("bowen");
    int val = 3;
    
    MyForm theForm = new Form(val);
    theForm.Show();
    
    this.Close();
    
    

    that form is defined like this, which I'm thinking is part of the problem:
        //EDIT: This is for the webbrowser control on the form
        //but this part worked fine before I made that function call
    
        [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
        [System.Runtime.InteropServices.ComVisibleAttribute(true)]
        public partial class MyForm: Form { //... }
    

    I have no idea why commenting out my user function has any bearing on it whatsoever, I'm at a loss. Any ideas?

    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
    EndEnd Registered User regular
    edited October 2010
    Hey guys, guess what, leaking file descriptors is a bad idea.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    EtheaEthea Registered User regular
    edited October 2010
    Infidel wrote: »
    Ethea wrote: »
    might want to watch out for stuff like 3.5e3

    In the minutes field on a webpage? :lol: But yeah, as I said, pick a format that matches what you want instead of always using .*

    It could happen if fractions of a minute are allowed.

    Ethea on
  • Options
    EtheaEthea Registered User regular
    edited October 2010
    End wrote: »
    Hey guys, guess what, leaking file descriptors is a bad idea.

    I love this problem because it can make other programs crash!

    Ethea on
  • Options
    EndEnd Registered User regular
    edited October 2010
    Well, I was just hitting the per-process limit, so it was mostly "why the hell is my embedded python failing to import a library"?

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    Xenocide GeekXenocide Geek Registered User regular
    edited October 2010
    is anybody familiar with the gridworld/critter class assignments in introductory computer science classes?

    the idea is to create a critter class (using java) that implements an interface called Critter.

    the assignment is to create several different "critters", and define how they move, as specified by the assignment.

    for instance, a turtle critter is suppose to move 5 spaces south, 5 spaces west, 5 north, 5 east, and then repeat. the loop functionality comes from the class being accessed by another class - probably a driver class or a step below it.

    movements works by returning an integer (assigned to a direction, e.g: return NORTH, where NORTH = -11) from a function called getMove, and the program then moves the critter across the grid.

    now, i figured out what i feel is an assbackwards way of doing it, and while it works, i feel that perhaps i'm missing the entire point of the OOP aspect of this assignment. currently i just have like 9 different if statements which lets me define exactly which direction to return.

    anybody familiar with this type of work? i feel like i'm overthinking it and doing 10x more work than necessary.

    Xenocide Geek on
    i wanted love, i needed love
    most of all, most of all
    someone said true love was dead
    but i'm bound to fall
    bound to fall for you
    oh what can i do
  • Options
    bowenbowen How you doin'? Registered User regular
    edited October 2010
    No that's pretty run of the mill OOP.

    Critter is the fundamental super class. Everything derives and interfaces through the critter class. You're probably doing it exactly how it's supposed to be done.

    Edit:
    From my limited experience with Java, the OOP designs it forces on you is terrible, so, that may be the part that's ultimately confusing you.

    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
    LoneIgadzraLoneIgadzra Registered User regular
    edited October 2010
    I hate java so much.

    Just today I had to write a complicated routine that could fail at any of ten points, each point depending on the results of the previous, and in the event of failure a rollback should be attempted (which could also fail at any point).

    How the hell are you supposed to do this without goto? Fucking elitist assholes. What I ended up with was a horribly confusing rat's nest of if/else's that's way uglier than if I could have just used goto to jump out of the main path for error handling.

    I'm sure there's a nicely curly-braced way to do this that will make me feel silly.

    LoneIgadzra on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited October 2010
    I hate java so much.

    Just today I had to write a complicated routine that could fail at any of ten points, each point depending on the results of the previous, and in the event of failure a rollback should be attempted (which could also fail at any point).

    How the hell are you supposed to do this without goto? Fucking elitist assholes. What I ended up with was a horribly confusing rat's nest of if/else's that's way uglier than if I could have just used goto to jump out of the main path for error handling.

    I'm sure there's a nicely curly-braced way to do this that will make me feel silly.

    I remember my instructor back in the day told us that a switch/try/catch/throw solution works well for this.

    Now you can't move across different functions and parts of code, but, you can do it within one method at least.

    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
    urahonkyurahonky Resident FF7R hater Registered User regular
    edited October 2010
    So I'm trying to do the following:
    http://www.coreservlets.com/Apache-Tomcat-Tutorial/

    Basically get Eclipse to run Tomcat. The problem is that I have NO IDEA what the workbench is. Which is #4 on that list. Can anyone point me in the right direction?

    urahonky on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited October 2010
    The workbench is the "Eclipse" application. The server tab is only in the EE version of Eclipse I think. It should be at the bottom with the console, javadoc, etc tabs.

    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
    urahonkyurahonky Resident FF7R hater Registered User regular
    edited October 2010
    Ah. Yeah I have EE, but it wasn't there. So I had to customize my perspective and add the tab, and then it finally showed up.

    urahonky on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited October 2010
    I hate java so much.

    Just today I had to write a complicated routine that could fail at any of ten points, each point depending on the results of the previous, and in the event of failure a rollback should be attempted (which could also fail at any point).

    How the hell are you supposed to do this without goto? Fucking elitist assholes. What I ended up with was a horribly confusing rat's nest of if/else's that's way uglier than if I could have just used goto to jump out of the main path for error handling.

    I'm sure there's a nicely curly-braced way to do this that will make me feel silly.

    The manageable way is probably to organize things in try/catch blocks, remember that you can throw your own exceptions which is effectively a goto if it's all in your function scope.

    Infidel on
    OrokosPA.png
  • Options
    kedinikkedinik Captain of Industry Registered User regular
    edited October 2010
    kedinik wrote: »
    I'm not married to UML, just looking for a good way to visually organize a large-ish system of classes.

    I like UMLet - http://www.umlet.com/

    It is highly idiosyncratic but it does what I need it to do in terms of class diagrams and the like. It has a very command line feel to it despite also being drag and drop.

    Thanks, UMLet seems pretty useful.

    kedinik on
    I made a game! Hotline Maui. Requires mouse and keyboard.
  • Options
    TaminTamin Registered User regular
    edited October 2010
    kedinik wrote: »
    kedinik wrote: »
    I'm not married to UML, just looking for a good way to visually organize a large-ish system of classes.

    I like UMLet - http://www.umlet.com/

    It is highly idiosyncratic but it does what I need it to do in terms of class diagrams and the like. It has a very command line feel to it despite also being drag and drop.

    Thanks, UMLet seems pretty useful.

    It doesn't want to run for me. Keeps claiming Java isn't installed (or found); other java-based programs work, and Java is both installed and in the usual area - C:\Program Files (x86)\Java.

    Tamin on
  • Options
    urahonkyurahonky Resident FF7R hater Registered User regular
    edited October 2010
    Okay... So how the hell do I get the Server option to show up on Eclipse??? I have Eclipse EE installed. I have JRE6... Up above I got it to work on the computer labs at school, but now I can't get it to work on my computer at home.

    Fucking Eclipse.

    e: Found it. I'm an idiot......

    urahonky on
  • Options
    KyanilisKyanilis Bellevue, WARegistered User regular
    edited October 2010
    Tamin wrote: »
    kedinik wrote: »
    kedinik wrote: »
    I'm not married to UML, just looking for a good way to visually organize a large-ish system of classes.

    I like UMLet - http://www.umlet.com/

    It is highly idiosyncratic but it does what I need it to do in terms of class diagrams and the like. It has a very command line feel to it despite also being drag and drop.

    Thanks, UMLet seems pretty useful.

    It doesn't want to run for me. Keeps claiming Java isn't installed (or found); other java-based programs work, and Java is both installed and in the usual area - C:\Program Files (x86)\Java.

    Did the same thing for me, just running the .jar instead of the .exe works fine though.

    Kyanilis on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited October 2010
    Kyanilis wrote: »
    Tamin wrote: »
    kedinik wrote: »
    kedinik wrote: »
    I'm not married to UML, just looking for a good way to visually organize a large-ish system of classes.

    I like UMLet - http://www.umlet.com/

    It is highly idiosyncratic but it does what I need it to do in terms of class diagrams and the like. It has a very command line feel to it despite also being drag and drop.

    Thanks, UMLet seems pretty useful.

    It doesn't want to run for me. Keeps claiming Java isn't installed (or found); other java-based programs work, and Java is both installed and in the usual area - C:\Program Files (x86)\Java.

    Did the same thing for me, just running the .jar instead of the .exe works fine though.

    I install in C:\Java since the program files path seems to confuse some programs. It's usually either that or incorrect environment variables.

    Infidel on
    OrokosPA.png
  • Options
    HalibutHalibut Passion Fish Swimming in obscurity.Registered User regular
    edited October 2010
    I hate java so much.

    Just today I had to write a complicated routine that could fail at any of ten points, each point depending on the results of the previous, and in the event of failure a rollback should be attempted (which could also fail at any point).

    How the hell are you supposed to do this without goto? Fucking elitist assholes. What I ended up with was a horribly confusing rat's nest of if/else's that's way uglier than if I could have just used goto to jump out of the main path for error handling.

    I'm sure there's a nicely curly-braced way to do this that will make me feel silly.

    I'm sure others have answered this, but this is how you do it in Java:
    void doSomethingInATransaction(){
        Transaction tx = new Transaction();
    
        try{
            //Do stuff here. If something fails, throw an exception
           
    
            //We will only get to this point if we haven't thrown an exception
            tx.commit();    
        }
        catch(Exception ex){
            try{
                //We will only get here if an exception was thrown, so rollback the transaction
                tx.rollback();
            }
            catch(Exception ex2){
                //do something if the rollback failed
            }
        }
    
    }
    

    I haven't compiled that code, but that's the basic idea. The exception handling mechanism is analogous to goto in that it immediately stops execution at the current location and jumps to a predefined location in code (the catch block) if an exception is thrown.

    Halibut on
  • Options
    Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited October 2010
    Yeh, I can see how using switch/case and removing the typical break; from the end of the cases would be a good substitute for goto.

    But then again I haven't actually used goto since I was doing BASIC back in the 90's.

    It is telling that I now think of goto as a poor man's exception.

    Monkey Ball Warrior on
    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • Options
    LoneIgadzraLoneIgadzra Registered User regular
    edited October 2010
    I guess I sort of get what is being said, at least how exceptions relate to the basic routine where every failure point should simply end the whole thing and print an error message or something, since by using exceptions you can move as much error handling as possible out of the main path in much the same was as you would with a goto.

    However, what would you guys say if I have to call a bunch of methods that depend on each other, all of which throw the same kind of exception on failure, and I need to know exactly where the point of failure is so rollback actions may be taken? This pretty much forces exception handling or error checking on a line-by-line basis, which gets hella ugly using try catch for every little thing.

    Also, one big problem is the home-grown libraries I am working with don't report errors using exceptions, but by return value. So it forces you to very explicitly deal with the error when you write the method call.

    On the other hand, sometimes you just want to do one thing and don't give a shit if it fails and writing a whole try/catch for that is just a huge PITA, and frequently it's unclear to me how much of the routine should be in the try block.

    LoneIgadzra on
  • Options
    The AnonymousThe Anonymous Uh, uh, uhhhhhh... Uh, uh.Registered User regular
    edited October 2010
    Blah blah blah new thread blah blah. If you want to talk, do it in there.

    The Anonymous on
  • Options
    Joe KJoe K Registered User regular
    edited October 2010
    bowen wrote: »
    No that's pretty run of the mill OOP.

    Critter is the fundamental super class. Everything derives and interfaces through the critter class. You're probably doing it exactly how it's supposed to be done.

    Edit:
    From my limited experience with Java, the OOP designs it forces on you is terrible, so, that may be the part that's ultimately confusing you.

    a
    switch (1) {

    }

    then using break as your goto statement is an ugly workaround. you may have to set flags depending if its a windup/unwinding.

    Joe K on
This discussion has been closed.