SELECT * FROM posts WHERE tid = 'PA PROGRAMMING THREAD'

12357100

Posts

  • iTunesIsEviliTunesIsEvil Registered User regular
    I shall then, I shall.

  • Joe KJoe K Registered User regular
    GnomeTank wrote:
    It's a damn shame I hate Python, and won't touch it. There needs to be a Ruby equivalent.

    Also, here is my Frankenstein reference type...behold, a FlexReference!

    Shame. Good craftsmen use all the tools on their workbench.

  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    Nightslyr wrote:
    RE REST: Isn't it really just using HTTP verbs the way they're supposed to be used? GET for retrieving data, DELETE for removing it, etc? Are there any frameworks that actually deal with PUT or DELETE? In my (limited) experience, frameworks like ASP.NET MVC and Symfony2 only recognize GET and POST.

    Support for PUT and DELETE is getting fairly common.
    Quick question about Ruby syntax. I've been reading the official documentation, but some of it is a bit confusing as it never shows a completed class entirely written. So, is something like the following correct?
    def Person
      attr_reader :name, :age
    
      def initialization(name, age)
        @name = name
        @age = age
      end
    
      def to_s
        "{#name}, {#age}"
      end
    end
    

    That's correct.

  • bowenbowen How you doin'? Registered User regular
    Joe K wrote:
    GnomeTank wrote:
    It's a damn shame I hate Python, and won't touch it. There needs to be a Ruby equivalent.

    Also, here is my Frankenstein reference type...behold, a FlexReference!

    Shame. Good craftsmen use all the tools on their workbench.

    Indeed, though I wouldn't take a router to a bunch of nails.

    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
  • GnomeTankGnomeTank Registered User regular
    Joe K wrote:
    GnomeTank wrote:
    It's a damn shame I hate Python, and won't touch it. There needs to be a Ruby equivalent.

    Also, here is my Frankenstein reference type...behold, a FlexReference!

    Shame. Good craftsmen use all the tools on their workbench.

    But every craftsman has their favorite tools, and ones they aren't as fond of. I never said I couldn't do Python, I said I didn't like it. I'd rather use Ruby, which is an equivalent tool, just with a different handle that I prefer more.

    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
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    Yah. I certainly wouldn't turn down a good Python job offer, but I would never choose Python over Ruby.

  • jackaljackal Registered User regular
    Get your hands off me you damn dynamic hippies!

    *pans to pieces of C# and Java strewn across the landscape*

    You Maniacs! You blew it up!

  • GnomeTankGnomeTank Registered User regular
    Yeah, if someone offered me more money than I am making doing C# to do Python, I'd take it...that said, if someone offered me just slightly less to do Ruby, I'd probably take that over the Python job. Quality of Life > Money, even though making good money is nice.

    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
  • Joe KJoe K Registered User regular
    Cantido wrote:
    I'm not understanding jQuery. I'm thinking of just doing my databasery with just plain PHP and (my)SQL

    jQuery will be a no-brainer once you figure it out. The main concept is that its based around "functional programming", and while it's taught first at the big schools such as MIT, most people concentrate on Structured or OOP. Functional is a different way of looking at things.

    Say you had a DIV that you wanted to collapse (jquery-ui functions)

    You would
    $('.collapseAll').click(function() {
    				toggleAll(false);
    			})
    

    The Selector ('.collapseAll') grabs all elements that match the class "collapseAll".

    It takes the .click() event, and attaches a function to it, to toggle all the class styles to false, so it won't display.

    If its an input field, you can easily get the values from it.

    In functional programming, the data drives the program, it looks for a list of rules on what to do when encountered with that data (Hey, its a collapseAll class!).

    It's also a much, much simpler way of gaining cross-browser compat.

    For more than you ever wanted to learn about functional programming:
    http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/

  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    jackal wrote:
    Get your hands off me you damn dynamic hippies!

    *pans to pieces of C# and Java strewn across the landscape*

    You Maniacs! You blew it up!

    Now suffer with our elegant, readable, and powerful languages!

  • bowenbowen How you doin'? Registered User regular
    Fuck that I'd take the money.

    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
  • GnomeTankGnomeTank Registered User regular
    bowen wrote:
    Fuck that I'd take the money.

    I already make more than enough money to be comfortable. I'd rather go to a job I like every day, than a job I hate to make an extra 100-200 bucks a paycheck.

    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
  • InfidelInfidel Heretic Registered User regular
    edited February 2012
    I hope I haven't asked this before, but...

    Could someone point me toward a good resource on session-management in PHP/JS? I've got a straight PHP site right now, and I'm basically just relying on PHP to expire stuff in $_SESSION at a certain point in time, but it doesn't feel right at all. I keep thinking there must be a better way to invalidate a user's session, and to keep track of some of their data for said session. This isn't live yet or anything, so I've got plenty of time to do it (hopefully) the right way.

    I use pear for this stuff, specifically HTTP_Session2. I also use MDB2 package and so I use that as the container for the session.

    It's what I use for Orokos and other sites, I have my own base classes that handle the setup that I just copy site to site. (Minimal framework for user/session/db support.)

    Infidel on
    OrokosPA.png
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • zeenyzeeny Registered User regular
    I have my own base classes that handle the setup that I just copy site to site. (Minimal framework for user/session/db support.)

  • bowenbowen How you doin'? Registered User regular
    It's good to know I'm not the only one that has my own session/user/db classes that I reuse over and over.

    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
  • InfidelInfidel Heretic Registered User regular
    To be clear, they are wrappers and extensions around those PEAR packages I mentioned, cause no I'm not going to waste time writing my own database layers.

    Just my interface to them!

    If you need any help getting something setup @iTunesIsEvil let me know.

    OrokosPA.png
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • bowenbowen How you doin'? Registered User regular
    I have my own DB class that lets me switch between common engines. My BowenSQL lets me pick between mssql,mysql,sqlite.

    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
  • zeenyzeeny Registered User regular
    On a javascript sidenote, Jquery binds on an ajax page with dynamic content sections is easy top 3 for me in "Things I don't want to debug.".

  • InfidelInfidel Heretic Registered User regular
    zeeny wrote:
    On a javascript sidenote, Jquery binds on an ajax page with dynamic content sections is easy top 3 for me in "Things I don't want to debug.".

    Debugging the actual ajax messages and responses?

    When I was working on my webgame I had a textarea that would only be setup for my IP, so that I could watch a stream of data sent and received. Helped a lot with debugging the actions, script and JSON. Really simple shit but most useful.

    OrokosPA.png
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • zeenyzeeny Registered User regular
    edited February 2012
    Infidel wrote:
    zeeny wrote:
    On a javascript sidenote, Jquery binds on an ajax page with dynamic content sections is easy top 3 for me in "Things I don't want to debug.".

    Debugging the actual ajax messages and responses?

    When I was working on my webgame I had a textarea that would only be setup for my IP, so that I could watch a stream of data sent and received. Helped a lot with debugging the actions, script and JSON. Really simple shit but most useful.

    No, the whole system with on/live/one event delegation is a bit of a mess, which means that if you add content dynamically it's very easy to have an event binding more than once to a specific element which can lead to multiple execution(say, a filter is called twice in quick succession, so you get the expected result and assume A-OK if you don't check the logs) etc. I love JQuery for dom manipulation, but the moment you have to delegate dynamic content you have to be extra careful.

    Edit: The actual ajax calls are absolutely lovely and the new success/failure chaining syntax is <3<3<3!
    Edit2: I have a small jquery lib for doing ajax with event binding callbacks that I use when I deal with delegation on dynamic content to avoid tear inducing bugs.

    zeeny on
  • Joe KJoe K Registered User regular
    zeeny wrote:
    Infidel wrote:
    zeeny wrote:
    On a javascript sidenote, Jquery binds on an ajax page with dynamic content sections is easy top 3 for me in "Things I don't want to debug.".

    Debugging the actual ajax messages and responses?

    When I was working on my webgame I had a textarea that would only be setup for my IP, so that I could watch a stream of data sent and received. Helped a lot with debugging the actions, script and JSON. Really simple shit but most useful.

    No, the whole system with on/live/one event delegation is a bit of a mess, which means that if you add content dynamically it's very easy to have an event binding more than once to a specific element which can lead to multiple execution(say, a filter is called twice in quick succession, so you get the expected result and assume A-OK if you don't check the logs) etc. I love JQuery for dom manipulation, but the moment you have to delegate dynamic content you have to be extra careful.

    Edit: The actual ajax calls are absolutely lovely and the new success/failure chaining syntax is <3<3<3!
    Edit2: I have a small jquery lib for doing ajax with event binding callbacks that I use when I deal with delegation on dynamic content to avoid tear inducing bugs.

    .on()

    http://api.jquery.com/on/

  • zeenyzeeny Registered User regular
    Yes, and?

  • Joe KJoe K Registered User regular
    zeeny wrote:
    Yes, and?

    deals with elements that were added to the DOM through post-renderring activity. No muss, no fuss. Used to be .live() but apparently not now.

  • zeenyzeeny Registered User regular
    edited February 2012
    Joe K wrote:
    zeeny wrote:
    Yes, and?

    deals with elements that were added to the DOM through post-renderring activity. No muss, no fuss. Used to be .live() but apparently not now.

    Nope, still attaches N-th time depending on the selector.

    Edit: Direct quote, in case you have doubts:
    Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to .on().

    zeeny on
  • Joe KJoe K Registered User regular
    zeeny wrote:
    Joe K wrote:
    zeeny wrote:
    Yes, and?

    deals with elements that were added to the DOM through post-renderring activity. No muss, no fuss. Used to be .live() but apparently not now.

    Nope, still attaches N-th time depending on the selector.

    we're probably talking about two different things here. It is known that you might add items to the DOM after it's ready. Previously, you would specify .live() on the selectors to note that this functionality needs to be added if the DOM is manipulated post-initial loading. You now have to use .on().

    Unless I'm missing something completely.

  • zeenyzeeny Registered User regular
    edited February 2012
    Joe K wrote:
    zeeny wrote:
    Joe K wrote:
    zeeny wrote:
    Yes, and?

    deals with elements that were added to the DOM through post-renderring activity. No muss, no fuss. Used to be .live() but apparently not now.

    Nope, still attaches N-th time depending on the selector.

    we're probably talking about two different things here. It is known that you might add items to the DOM after it's ready. Previously, you would specify .live() on the selectors to note that this functionality needs to be added if the DOM is manipulated post-initial loading. You now have to use .on().

    Unless I'm missing something completely.

    Maybe. Say you have a class .trigr1 and you use it for a specific dialog pop up. If you add content from different sources, it means that several trigr's can coexist on the same page while being added/removed at will. Jquery delegation stacks. Say, if you do .on("click", blabla) N times on the same objet, blabla will get called N times on event, which makes it very easy to fuck up code unless you are very careful with the selector scope on your callbacks(not always easy to do).

    zeeny on
  • zeenyzeeny Registered User regular
    edited February 2012
    If you add another row through AJAX, and make sure its class is "toggleSpam", then this functionality gets applied.

    Nope. I'll do a test to illustrate the problem when I have the time as I believe I"m not explaining it properly.

    zeeny on
  • Joe KJoe K Registered User regular
    zeeny wrote:
    Joe K wrote:
    zeeny wrote:
    Joe K wrote:
    zeeny wrote:
    Yes, and?

    deals with elements that were added to the DOM through post-renderring activity. No muss, no fuss. Used to be .live() but apparently not now.

    Nope, still attaches N-th time depending on the selector.

    we're probably talking about two different things here. It is known that you might add items to the DOM after it's ready. Previously, you would specify .live() on the selectors to note that this functionality needs to be added if the DOM is manipulated post-initial loading. You now have to use .on().

    Unless I'm missing something completely.

    Maybe. Say you have a class .trigr1 and you use it for a specific dialog pop up. If you add content from different sources, it means that several trigr's can coexist on the same page while being added/removed at will. Jquery delegation stacks. Say, if you do .on("click", blabla) N times on the same objet, blabla will get called N times on event, which makes it very easy to fuck up code unless you are very careful with the selector scope on your callbacks(not always easy to do).

    i don't think that that's how it works.

    If you have a table ID "spamTable". Each row is classed "toggleSpam".

    $("#spamTable tbody tr.toggleSpam").on("click", function(event){
    alert($(this).text());
    });

    That will alert all the text (including markup) inside the TR that was clicked. It only applies to the TR that was clicked.

    If you add another row through AJAX, and make sure its class is "toggleSpam", then this functionality gets applied.

    I'm sure I'm missing something here.

  • InfidelInfidel Heretic Registered User regular
    Call .on("click", func) again and you'll get multiple calls.

    It is not hard to have extra bindings inadvertently accumulate on elements when you're doing heavy manipulation of the DOM.

    My dumbass textarea debugging actually caught some of those for me.

    OrokosPA.png
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • Jimmy KingJimmy King Registered User regular
    Man, I'm busy all day working and I pop in after dinner to find all this Python hate. Why you gotta hate? I did Perl full time for several years and almost 6 months ago landed a full time Python/Django job (aside from maintaining the legacy c++/vbscript classic asp/php on windows nightmare on the side) and love it.

    I played with Ruby a little and I don't hate it, but didn't love it, either. It had some very cool features for sure, but the syntax felt like some sort of terrible joke where someone merged Perl and VB just to be an asshole.

  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    I have to admit, I find the do/end crap to be really horrible. But there's a lot of good stuff in ruby, from what I can tell.

    "I resent the entire notion of a body as an ante and then raise you a generalized dissatisfaction with physicality itself" -- Tycho
  • Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    edited February 2012
    Jimmy King wrote:
    I played with Ruby a little and I don't hate it, but didn't love it, either. It had some very cool features for sure, but the syntax felt like some sort of terrible joke where someone merged Perl and VB just to be an asshole.

    The creator of Ruby loved Perl and thought that, like Perl, line noise makes a programming language more readable.

    Alistair Hutton on
    I have a thoughtful and infrequently updated blog about games http://whatithinkaboutwhenithinkaboutgames.wordpress.com/

    I made a game, it has penguins in it. It's pay what you like on Gumroad.

    Currently Ebaying Nothing at all but I might do in the future.
  • CantidoCantido Registered User regular
    edited February 2012
    I'm learning how to Prolog. Can you help me learn how to Prolog?

    This is my first Prolog program, edited in notepad and to be read by SWI-prolog.

    man(peter).
    man(harvey).
    man(arthur).
    woman(marie).
    father(peter,harvey).
    father(peter,arthur).
    father(peter,marie).
    child(harvey,peter).
    child(arthur,peter).
    child(marie,peter).
    son(X,Y):-child(X,Y),man(X).
    daughter(X,Y):-child(X,Y),woman(X).
    sibling(X,Y):-child(X,Z),child(Y,Z).
    brother(X,Y):-child(X,Z),child(Y,Z), man(X),man(Y).
    sister(X,Y):-child(X,Z),child(Y,Z), woman(X),woman(Y).

    It says son(harvey). is false (asking if harvey is a son in any way.) And if I enter
    father(peter,X).

    which asks "who is peter a father of," it only responds with harvey, and none of the other children. Am I entering something wrong?

    In fact, using Notepad is kinda lame. Notepad++ has a prolog style sheet somewhere but I can't find it. Has anyone used it before?

    Cantido on
    3DS Friendcode 5413-1311-3767
  • SeolSeol Registered User regular
    Hrmm, IIRC (it's been a couple of years since I Prolog'd) it should return one answer on the first query. Type a semi-colon, and it'll give you additional matches until it runs out. As for the son thing, there's no son/1 rule, so it'll return false: you'll need son(harvey, _) for the same effect. You could always define a son/1 rule as son(X) :- son(X, _).

  • ecco the dolphinecco the dolphin Registered User regular
    Bwahahaha

    Next time I do a hack, I'm tempted to put these in comments next to it.

    Apparently, I lack the correct fonts to display these vital characters, but one day... one day.

    Penny Arcade Developers at PADev.net.
  • Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    God damn I love beautifulsoup so much.

    I have a thoughtful and infrequently updated blog about games http://whatithinkaboutwhenithinkaboutgames.wordpress.com/

    I made a game, it has penguins in it. It's pay what you like on Gumroad.

    Currently Ebaying Nothing at all but I might do in the future.
  • LindenLinden Registered User regular
    Cantido wrote:
    I'm learning how to Prolog. Can you help me learn how to Prolog?

    Seol's comments mesh with my experience. Prolog can be a little temperamental at times (my peers loathed it, but my peers didn't understand the phrase "f : N^2 -> N", so hey), but findall/3 might be handy here:
    findall(_X,father(peter,_X),Z)
    
    should give what you want, if memory serves.

    For Prolog, remember that its logic isn't quite what most people are expecting - and come to terms with how to use cuts and negation (which is "I cannot find an instance")

    What if this weren't a rhetorical question?
  • SeolSeol Registered User regular
    Actually, I'd say that if you want to find all of the people Peter's a father of, you want
    father(peter, X)
    
    And get used to the way that Prolog handles nondeterminism, and queries with multiple results.

    Lists have their place in Prolog, sure. That's when you have some sort of sequential data. For representing sets of responses, though, do it the Prolog way.

  • NightslyrNightslyr Registered User regular
    So I was reading this (http://blog.stackoverflow.com/2012/02/stack-exchange-open-source-projects/), and was a bit confused as to the point behind something like Redis. Is it an intermediary layer between an ORM and DB? Some sort of app-code repository? The rest of the stuff in that blog post makes sense (I've actually used MarkdownSharp and PageDown), but the Booksleeve/Redis part confused me.

    PSN/XBL/Nintendo/Origin/Steam: Nightslyr 3DS: 1607-1682-2948
    Switch: SW-3515-0057-3813 FF XIV: Q'vehn Tia
  • GnomeTankGnomeTank Registered User regular
    Jimmy King wrote:
    I played with Ruby a little and I don't hate it, but didn't love it, either. It had some very cool features for sure, but the syntax felt like some sort of terrible joke where someone merged Perl and VB just to be an asshole.

    The creator of Ruby loved Perl and thought that, like Perl, line noise makes a programming language more readable.

    W-hut? Ruby has an incredibly clean syntax, nothing at all like the _$ + [email protected] = $$_() crap of Perl. Matz liked perl regular expressions, not Perl per se. He liked the way regex integrated well in to Perl, but there was plenty about Perl he hated.

    This is why Ruby regex is implemented using PCRE, and it has the /*/ match operator.

    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
This discussion has been closed.