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

PA Programming Thread :: PAdev.net - Need hosting for a service of yours? Check it out.

1457910100

Posts

  • Options
    agoajagoaj Top Tier One FearRegistered User regular
    edited October 2011
    I'm setting it with
    SetEnv LD_LIBRARY_PATH /usr/local/pgsql/lib/
    in the httpd.conf file, but it still can't find it. I'd try linking it statically, but I think it would go over my filesize limit.


    Edit:
    And now it's working with passenv... thought I already tried that.

    agoaj on
    ujav5b9gwj1s.png
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    Infidel wrote:
    templewulf wrote:
    Ugh. Am I wrong in thinking there is no reason that dictionaries aren't serializable in C#?

    I'm trying to save sprite sheet metadata to XML files with XNA. Does anyone have any suggestions for how to do this now that I can't just serializer.Serialize()? I'm not married to XML either, but I'd like to just implement a ready-made solution and get on with the interesting parts.

    They aren't XML serializable out of the gate, but you can do a few things.

    One would be to do a binary serialize of the dictionary object and then stuff that as binary data into a member that then is serialized by your overall XML process.

    Another would be to implement your own SerializableDictionary from Dictionary and IXmlSerializable.

    I ended up just inheriting from Dictionary and IXmlSerializable and implementing the ReadXml / WriteXml functions myself. It wasn't quite a pre-packaged solution, but it was easier than I expected once I found a couple of articles about IXmlSerializable.

    I'm still not sure why they didn't at least implement my ~20 line solution, but I'm just happy it works now.

    <Thread disposition="Thanks!"><moodCode="<3"></Thread>

    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    zeenyzeeny Registered User regular
    agoaj wrote:
    I'm setting it with
    SetEnv LD_LIBRARY_PATH /usr/local/pgsql/lib/
    in the httpd.conf file, but it still can't find it. I'd try linking it statically, but I think it would go over my filesize limit.


    Edit:
    And now it's working with passenv... thought I already tried that.

    SetEnv wouldn't work if you are using a daemon for cgi.

  • Options
    AnteCantelopeAnteCantelope Registered User regular
    Doing some stuff with Hashmaps (in Java), and I need to be able to save them to file, and then read them back in later. I know they've got a toString() function, is there any sort of fromString() function? I mean, I could use tokenizers to pull a line apart, and parse it into a hashmap, but it'd be a lot handier if there were a way to undo a toString.

  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    toString isn't meant to give you a serializable version of the object, it's to provide a human-readable description

  • Options
    AnteCantelopeAnteCantelope Registered User regular
    Phyphor wrote:
    toString isn't meant to give you a serializable version of the object, it's to provide a human-readable description

    I know, but I was hoping since toString pulled all the useful information from my Hashmap, I could just use it. I have since realised that I can't, and written a custom toString and a parser to rebuild from that string, because serialisation was being a real bitch.

  • Options
    jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    Serialization is tricky with hashtables. Unless you have a language with only immutable types and invariant hashing across all environments there is a chance you could deserialize something that is different to what you serialized.

  • Options
    Apothe0sisApothe0sis Have you ever questioned the nature of your reality? Registered User regular
    Hooray, I have completed my first scraper using python.

    It is a beautiful thing.

    I look forward to looking back and thinking "That is ugly, ugly code, how could I?... I don't even".

  • Options
    InfidelInfidel Heretic Registered User regular
    templewulf wrote:
    Infidel wrote:
    templewulf wrote:
    Ugh. Am I wrong in thinking there is no reason that dictionaries aren't serializable in C#?

    I'm trying to save sprite sheet metadata to XML files with XNA. Does anyone have any suggestions for how to do this now that I can't just serializer.Serialize()? I'm not married to XML either, but I'd like to just implement a ready-made solution and get on with the interesting parts.

    They aren't XML serializable out of the gate, but you can do a few things.

    One would be to do a binary serialize of the dictionary object and then stuff that as binary data into a member that then is serialized by your overall XML process.

    Another would be to implement your own SerializableDictionary from Dictionary and IXmlSerializable.

    I ended up just inheriting from Dictionary and IXmlSerializable and implementing the ReadXml / WriteXml functions myself. It wasn't quite a pre-packaged solution, but it was easier than I expected once I found a couple of articles about IXmlSerializable.

    I'm still not sure why they didn't at least implement my ~20 line solution, but I'm just happy it works now.

    <Thread disposition="Thanks!"><moodCode="<3"></Thread>

    Yep, the code to do it isn't that tricky and the "right" method is to put it in IXmlSerializable form since where else are you going to put it? Might as well have it in the form consistent with everything else, that's kinda the point of interfaces!

    The reason I think why they don't have it natively is that it isn't a true serialization, some internal information is lost, which is maintained in the binary format. 98% really don't care though, I bet. But if you did, you could do the binary-stuffing approach.

    OrokosPA.png
  • Options
    Mike DangerMike Danger "Diane..." a place both wonderful and strangeRegistered User regular
    edited October 2011
    Deleted because I think I need to do more thinking.


    Mike Danger on
    Steam: Mike Danger | PSN/NNID: remadeking | 3DS: 2079-9204-4075
    oE0mva1.jpg
  • Options
    Mike DangerMike Danger "Diane..." a place both wonderful and strangeRegistered User regular
    Okay, so here's my question:

    I'm doing some work with UDP in Ruby. I'm sending packets, but how do I tell what port I am sending packets from?

    Steam: Mike Danger | PSN/NNID: remadeking | 3DS: 2079-9204-4075
    oE0mva1.jpg
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    That would probably be chosen by whatever call bind() is mapped to. If unspecified, it's random

  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    Infidel wrote:
    Yep, the code to do it isn't that tricky and the "right" method is to put it in IXmlSerializable form since where else are you going to put it? Might as well have it in the form consistent with everything else, that's kinda the point of interfaces!

    The reason I think why they don't have it natively is that it isn't a true serialization, some internal information is lost, which is maintained in the binary format. 98% really don't care though, I bet. But if you did, you could do the binary-stuffing approach.

    The biggest part is just knowing where those methods are, since the MSDN entry on XmlSerializer doesn't make this kind of customization obvious. Once you mentioned IXmlSerializable, the rest was cake.

    I really, really didn't want to binary serialize, because the dictionary members have children that also need to be serialized. At that point, why even use XML?

    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    bowenbowen How you doin'? Registered User regular
    Phyphor wrote:
    That would probably be chosen by whatever call bind() is mapped to. If unspecified, it's random

    http://ruby-doc.org/stdlib/libdoc/socket/rdoc/IPSocket.html

    Since UDPSocket inherits from IPSocket, you should be able to access .addr and index position 2 should get you the local port. If you want the remote peer's port, peeraddr at index position 2 will get you that.

    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
    StarfuckStarfuck Registered User, ClubPA regular
    Not sure how many of you have heard of or used Learn Python The Hard Way, but he has a C version that is in draft right now and I have been going through exercises. He covers stuff pretty well, but I did get confused on this exercise.
    http://c.learncodethehardway.org/book/learn-c-the-hard-waych20.html#x25-9600020
    There are various functions written as pointers and I'm not quite sure why.
    For example,
    obj.h
    line 20
    void *Object_move(void *self, Direction direction);

    ex19.h
    line 29
    void *Room_move(void *self, Direction direction);
    line 42
    void *Map_move(void *self, Direction direction);

    I've looked through the other header/c files asked to write, but only thing I can see is these functions will return an enum. So do they need to be pointer functions because of that?

    jackfaces
    "If you're going to play tiddly winks, play it with man hole covers."
    - John McCallum
  • Options
    InfidelInfidel Heretic Registered User regular
    Starfuck wrote:
    Not sure how many of you have heard of or used Learn Python The Hard Way, but he has a C version that is in draft right now and I have been going through exercises. He covers stuff pretty well, but I did get confused on this exercise.
    http://c.learncodethehardway.org/book/learn-c-the-hard-waych20.html#x25-9600020
    There are various functions written as pointers and I'm not quite sure why.
    For example,
    obj.h
    line 20
    void *Object_move(void *self, Direction direction);

    ex19.h
    line 29
    void *Room_move(void *self, Direction direction);
    line 42
    void *Map_move(void *self, Direction direction);

    I've looked through the other header/c files asked to write, but only thing I can see is these functions will return an enum. So do they need to be pointer functions because of that?

    They return void* because the move is part of the Object prototype.

    If the Object move function returned an Object*, then it wouldn't work for returning Room* or Map* right. Note that the move function casts the generic void* self to the correct type, then works with it, and then the return as a void* is just casting it back to generic.

    OrokosPA.png
  • Options
    StarfuckStarfuck Registered User, ClubPA regular
    Ok, I see it now. I was reading it wrong. I was reading it as void a pointer to this function (noob mistake). Now that I follow where the objects are being passed as arguments, it makes much more sense.
    Thanks.

    jackfaces
    "If you're going to play tiddly winks, play it with man hole covers."
    - John McCallum
  • Options
    NightslyrNightslyr Registered User regular
    Hey guys, a question about something that's been bugging me for a while:

    How do forums (like this one) tell which post I've last read in a thread? JavaScript event that sets a cookie?

  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    No, because it works cross-machine. Probably a massive database table

  • Options
    NightslyrNightslyr Registered User regular
    Phyphor wrote:
    No, because it works cross-machine. Probably a massive database table

    Ah, good point. But, still, a JavaScript event?

    I don't know a lot about all of the JavaScript events, so I'm wondering how the forum 'sees' that a post has been read. Can JavaScript determine when the bottom edge of a <div> is visible?

  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Simple. When you request a thread it just updates your last post seen for this thread to the last post it sends you. That's why if you go back and view the older pages manually the "next post" value is then screwed up

  • Options
    InfidelInfidel Heretic Registered User regular
    Nightslyr wrote:
    Phyphor wrote:
    No, because it works cross-machine. Probably a massive database table

    Ah, good point. But, still, a JavaScript event?

    I don't know a lot about all of the JavaScript events, so I'm wondering how the forum 'sees' that a post has been read. Can JavaScript determine when the bottom edge of a <div> is visible?

    Forums don't mark ones you have VISIBLY seen as read, it just marks any post that it has sent to your browser as read.

    OrokosPA.png
  • Options
    IncindiumIncindium Registered User regular
    edited October 2011
    Ajax postbacks so yeah Javascript.

    Edit:
    Actually yeah Infidel is right... each next page is a full page load so there isn't even any need for an AJAX postback to mark a post as read.

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • Options
    amnesiasoftamnesiasoft Thick Creamy Furry Registered User regular
    edited October 2011
    Nightslyr wrote:
    I don't know a lot about all of the JavaScript events, so I'm wondering how the forum 'sees' that a post has been read. Can JavaScript determine when the bottom edge of a <div> is visible?
    It doesn't know which posts you've actually seen, it just says "Okay, you loaded these posts, I'll just assume you read them."

    EDIT: Beaten :(

    amnesiasoft on
    steam_sig.png
  • Options
    IncindiumIncindium Registered User regular
    edited October 2011
    And yeah I don't know about Vanilla but PHPBB boards are generally backended with a MySql database. I know with the one I used to help maintain that everything was plain text and if you wanted to you could read anyone PM's and private posts by writing the right sql query if you have access to the MySQL db.

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • Options
    InfidelInfidel Heretic Registered User regular
    Incindium wrote:
    And yeah I don't know about Vanilla but PHPBB boards are generally backended with a MySql database. I know with the one I used to help maintain that everything was plain text and if you wanted to you could read anyone PM's and private posts by writing the right sql query if you have access to the MySQL db.

    That is all similar systems. If you have access to the database you have access to everything, including accounts.

    OrokosPA.png
  • Options
    NightslyrNightslyr Registered User regular
    But wouldn't all posts on a page be sent, then?

    I mean, when I click on the title of a thread on these Vanilla forums, it sends me back to the last visible post I viewed. If it just did it by loaded posts, then it would send me to the bottom of the screen each time.

  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    It sends you to the last post that was previously sent to you, the entire page does load. If you load a thread you've never looked at before from the index in a new tab without ever looking at it and then load it again in a new tab, the second tab will be on page 2 because as far as it knows, you've read the entire first page

  • Options
    NightslyrNightslyr Registered User regular
    Phyphor wrote:
    It sends you to the last post that was previously sent to you, the entire page does load. If you load a thread you've never looked at before from the index in a new tab without ever looking at it and then load it again in a new tab, the second tab will be on page 2 because as far as it knows, you've read the entire first page

    ... double-facepalm.jpg

    I'm an idiot (although you all probably knew that anyway :P ).

    Thanks for the help/explanation.

  • Options
    SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    Starfuck wrote:
    Ok, I see it now. I was reading it wrong. I was reading it as void a pointer to this function (noob mistake). Now that I follow where the objects are being passed as arguments, it makes much more sense.
    Thanks.

    Yeah, this threw me off all the time when I first started playing around with passing functions as parameters.

    I think C probably would've been better off in general if it had adopted the convention of placing the type modifier next to the type, rather than next to the variable name, so that a void pointer variable is always "void* var" instead of "void *var".

    borb_sig.png
  • Options
    InfidelInfidel Heretic Registered User regular
    It's not the whitespace that is the issue but how the * type identifier binds.

    OrokosPA.png
  • Options
    SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    Right, that's what I mean. I think it makes more sense for the modifier to bind to the type instead of the variable, and even if that's not how C is actually implemented, it might make more conceptual sense to arrange the whitespace in that way. But certainly there are compelling arguments for both sides.

    borb_sig.png
  • Options
    InfidelInfidel Heretic Registered User regular
    Ahh, yeah it's just the way C works. We could easily make a case for either version, but it is what it is so it's kinda moot now.

    Since it binds to the variable and not the type declaration, int *a is more gooder than int* a.

    OrokosPA.png
  • Options
    PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Yeah, basically the compiler binds the call higher than the pointer so it builds the expression so that the pointer binds to the function call instead of the name. Using parenthesis it binds the * first, making it a pointer to a function when it then attaches the call

  • Options
    GodfatherGodfather Registered User regular
    Hey guys, new kid on the block here.

    So I feel a bit sheepish for asking this, but ive decided to go down the career path of becoming a programmer professionally. Unfortunately I'll have to teach myself it for the most part, and I'd be lying if I said I wasn't more than a little terrified on where to start. I'm a level green beginner with next to zero experience with programming (outside of a few web tutorials).

    I'll be taking a third job soon that will allow me a lot of down time on my hands to experiment and hopefully learn some things.

    So where, if anywhere, should I begin? This field is so intimidating it feels like I'm trapped in a labyrinth!

  • Options
    Jimmy KingJimmy King Registered User regular
    Wow. Building programs that use ado on windows 7 but need to run on earlier stuff is a total pain in the balls. I had to download a super secret backwards comaptible version of the dll from microsoft that they link to from an msdn page, install .net 4 so that I could get regtlibv12, and then register the super secret dll... or tpb or whatever the hell it is, then change code to point at that instead of the actual ado dll.

  • Options
    CarpyCarpy Registered User regular
    Godfather wrote:
    Hey guys, new kid on the block here.

    So I feel a bit sheepish for asking this, but ive decided to go down the career path of becoming a programmer professionally. Unfortunately I'll have to teach myself it for the most part, and I'd be lying if I said I wasn't more than a little terrified on where to start. I'm a level green beginner with next to zero experience with programming (outside of a few web tutorials).

    I'll be taking a third job soon that will allow me a lot of down time on my hands to experiment and hopefully learn some things.

    So where, if anywhere, should I begin? This field is so intimidating it feels like I'm trapped in a labyrinth!

    I feel like this even though I'm taking classes to learn. I'm changing my major to CS after taking an intro programming course but reading things like this thread is rather intimidating with a ton of jargon and concepts being thrown around.

  • Options
    InfidelInfidel Heretic Registered User regular
    Don't worry about the jargon.

    Just ask yourself, am I a problem solver?

    Cause the real job is problem solving.

    Specifically, knowing how computers can solve problems and making it happen.

    I don't need coders, I can get code written for $10/hr in India.

    OrokosPA.png
  • Options
    ecco the dolphinecco the dolphin Registered User regular
    Godfather wrote:
    Hey guys, new kid on the block here.

    So I feel a bit sheepish for asking this, but ive decided to go down the career path of becoming a programmer professionally. Unfortunately I'll have to teach myself it for the most part, and I'd be lying if I said I wasn't more than a little terrified on where to start. I'm a level green beginner with next to zero experience with programming (outside of a few web tutorials).

    I'll be taking a third job soon that will allow me a lot of down time on my hands to experiment and hopefully learn some things.

    So where, if anywhere, should I begin? This field is so intimidating it feels like I'm trapped in a labyrinth!

    I think there a lot of conflicting opinions on where you might want to start.

    Some people recommend starting with a "scripting language" like Python. I think the upside to this is that it's a flatter learning curve, and you'll be able to get started quicker. However, scripting languages take care of a lot of heavy lifting for you, so it might not be for you if you're looking to get into the nuts and bolts.

    If you're looking for a steep learning curve which does let you get into the nuts and bolts of a computer, then languages like C/C++ are generally recommended. However, a common analogy is that C gives you a shotgun to shoot your own foot with, and C++ gives you two shotguns to shoot both your feet with. Compared to a lot of newer languages, they can be considered.... "unforgiving".

    C# and Java are also pretty common - think of them as doing some of the heavy lifting for you, but still allowing you enough freedom to do stuff easily. Sort of like a shotgun, but with a safety catch.

    There's also a bunch of useful theory (e.g. data structures, algorithmic complexity) and practices (e.g. design patterns) that will be really handy if you want to pursue a job as a programmer.

    It also depends on where you want to go as to where you should start! What are your goals?

    Penny Arcade Developers at PADev.net.
  • Options
    an_altan_alt Registered User regular
    Godfather wrote:
    So where, if anywhere, should I begin? This field is so intimidating it feels like I'm trapped in a labyrinth!

    If you learn the theory properly, the practice will come much, much easier.

    You won't use most languages, you won't use 99% of fameworks, and most new exciting technologies fall into the 'has-been' or 'never was' camps pretty quickly. Obviously a coder will need to use languages, technologies, and most likely a bunch of different fameworks, but those aren't the important details. They're just means to and end.

    The important part is the computer science. If you have the whats, hows, and whys of data structures and algorithms, they can be implemented in any particular language. One of the best resources I had was a book on C that I picked up because the textbook for the course I was taking was terrible and cost $80. The book turned out to be three years of comp-sci, that happened to use C. Even though I didn't use a ton of C in school and almost never used it professionally, it was the most important programming book I've ever read. It wasn't about the language, it was the deeper understanding I'd gained. After that, the rest is just coding and anyone can do it.

    Pony wrote:
    I think that the internet has been for years on the path to creating what is essentially an electronic Necronomicon: A collection of blasphemous unrealities so perverse that to even glimpse at its contents, if but for a moment, is to irrevocably forfeit a portion of your sanity.
    Xbox - PearlBlueS0ul, Steam
    If you ever need to talk to someone, feel free to message me. Yes, that includes you.
This discussion has been closed.