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/

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

134689100

Posts

  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    edited February 2012
    Nightslyr wrote:
    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.

    It's a fast, lightweight database. It doesn't support complex schemas, but what it does do it does blazing fast and efficiently.

    I don't know how you would use it for a complex database, but my current project uses it for storing user sessions server-side.

    admanb on
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited February 2012
    I'm planning on using Redis to store game state for an MMO server essentially by just storing serialized JSON in various keys

    Jasconius on
  • Jimmy KingJimmy King Registered User regular
    GnomeTank wrote:
    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 _$ + _@ = $$_() 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.

    They mean different things than in Perl, but @ symbols galore, some ampersands, colons prefixing stuff, and question marks as well. It looks very Perl-ish to me coming from a Perl background... except for those god awful VB-like "end" statements after each block. Yuck. The : and ? aren't used for anything in Perl, but it's still a Perl-ish "hey, here's a special symbol with some special meaning"

    It doesn't quite have that line noise look that Perl is famous for, but neither does most well written Perl. It does have a ton of special symbols with special meanings attached to stuff all over the place like Perl, though.
    class Tree
      attr_accessor :children, :node_name
    
      def initialize(tree = {})
        name,nodes = tree.shift
        @node_name = name
        @children = []
    
        nodes.each {|key,value|
          @children.push(Tree.new(key => value))
        }
    
      end
    
      def visit_all(&block)
        visit &block
        children.each {|c| c.visit_all &block}
      end
    
      def visit(&block)
        block.call self
      end
    end
    

  • CantidoCantido Registered User regular
    edited February 2012
    I'm relearning PHP and SQL still, I've been given access to hosting services from a mentor to save money, but I don't know the permissions (he doesn't know, he didn't make the website.)

    $dbc = mysqli_connect('localhost', 'user', 'PASSWORD UNKOWN', 'database')
    or die('Error connecting to MySQL server.');

    I know to use localhost, I have the database, but I don't know the password. The hosting service is Host Gator, it's MY database and table that I made , but I don't know the password. Where in phpMyAdmin or in Host Gator's database listing can I get this password? I used the Host Gator control panel login and that's not doing it.

    This is the PHP error
    Warning: mysqli_connect() [function.mysqli-connect]: (42000/1044): Access denied for user 'user'@'localhost' to database 'database' in [IM CENSORING DIS SHIT] on line 23
    Error connecting to MySQL server.

    Is the password even what's wrong here? Today I tried something else. I made the user and assigned him my own password and that password didn't work either.

    Cantido on
    3DS Friendcode 5413-1311-3767
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    edited February 2012
    Jimmy King wrote:
    GnomeTank wrote:
    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 _$ + _@ = $$_() 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.

    They mean different things than in Perl, but @ symbols galore, some ampersands, colons prefixing stuff, and question marks as well. It looks very Perl-ish to me coming from a Perl background... except for those god awful VB-like "end" statements after each block. Yuck. The : and ? aren't used for anything in Perl, but it's still a Perl-ish "hey, here's a special symbol with some special meaning"

    It doesn't quite have that line noise look that Perl is famous for, but neither does most well written Perl. It does have a ton of special symbols with special meanings attached to stuff all over the place like Perl, though.
    class Tree
      attr_accessor :children, :node_name
    
      def initialize(tree = {})
        name,nodes = tree.shift
        @node_name = name
        @children = []
    
        nodes.each {|key,value|
          @children.push(Tree.new(key => value))
        }
    
      end
    
      def visit_all(&block)
        visit &block
        children.each {|c| c.visit_all &block}
      end
    
      def visit(&block)
        block.call self
      end
    end
    

    There are three special symbols in that. @ for member variable, & for callable block and : for "this is a symbol". There are really no special variables there with contextual meanings, like Perl's _$. The symbols that are there have the same meaning everywhere, and can be interpreted super easy.

    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
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Jasconius wrote:
    I'm planning on using Redis to store game state for an MMO server essentially by just storing serialized JSON in various keys

    That looks really neat. Most of the time when I want to use a DB, I end up just wanting a good persistent key-value store rather than a full DB

  • Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    GnomeTank wrote:
    There are three special symbols in that. @ for member variable, & for callable block and : for "this is a symbol". There are really no special variables there with contextual meanings, like Perl's _$. The symbols that are there have the same meaning everywhere, and can be interpreted super easy.

    Hey, hey, hey, don't go ignoring those crazy || things. That's a 33% increase in crazy symbology.

    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.
  • Monkey Ball WarriorMonkey Ball Warrior A collection of mediocre hats Seattle, WARegistered User regular
    edited February 2012
    And yet curly braces is just right out. I know everyone has their own opinions about syntax, otherwise there wouldn't be so many languages, but with something as abstract as statement blocks I think {} symbols are the right answer, but "var" is much better than @ for variable declaration.
    I like python. A lot. It is, syntactically, nearly ideal. I was skeptical about meaningful whitespace but it is something I can live with, even if it still looks weird to me.
    Go is also very close, although it is, syntactically, just python with the enforced indentation replaced with traditional curly braces. I <3 the := syntax, though only because go is staticaly typed, and the panic/recover setup.
    C# is also pretty good, it suffers from semicolonitus, but I like the way it handles lambdas and inheritances and such. This might be because I was taught in Java, however.

    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
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    @ isn't for variable declaration, @ replaces this/self for instance variable declaration.

  • Jimmy KingJimmy King Registered User regular
    You're just not going to convince me that Ruby doesn't look like the bastard lovechild of Perl and VB. I know the symbols have different meanings, but it's still full of symbols you need to learn the meaning of. There are all kinds of arguments to be made about those extra symbols for whether they are good or bad, I'm not making any judgement on that (I kind of like knowing that my variable is being used as an array or hash or scalar just from looking at it right there in Perl). I'm just saying that with the extra symbols, it looks very Perl-ish.

  • Jimmy KingJimmy King Registered User regular
    And now, on a totally different note, have any of you used PyCharm and had issues with it corrupting workspace.xml all the fucking time? I don't know if the issue is PyCharm or something with my virtual machine, but it's a bit annoying.

  • DrunkMcDrunkMc Registered User regular
    Phyphor wrote:
    Jasconius wrote:
    I'm planning on using Redis to store game state for an MMO server essentially by just storing serialized JSON in various keys

    That looks really neat. Most of the time when I want to use a DB, I end up just wanting a good persistent key-value store rather than a full DB

    That does seem really neat. I made a TriTowers game for shits and giggles and been trying to think of a way to save state easily. This seems pretty interesting.

  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    Phyphor wrote:
    Jasconius wrote:
    I'm planning on using Redis to store game state for an MMO server essentially by just storing serialized JSON in various keys

    That looks really neat. Most of the time when I want to use a DB, I end up just wanting a good persistent key-value store rather than a full DB

    Redis is functionally a persistent key-value store

    You don't need schemas at all.

  • NightslyrNightslyr Registered User regular
    Now I'm curious about what kind of data StackExchange stores in Redis, since the majority of what they do is highly relational. Just sessions, or something along those lines?

  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    edited February 2012
    Well there's an article on their site about making a twitter clone, so you can still do DB-like stuff, you just have to change the data storage. You could probably make forum software and the like without too much trouble

    Phyphor on
  • Mustachio JonesMustachio Jones jerseyRegistered User regular
    So I figured I'd ask here. I'm looking into learning Java with the end goal of making a turn-based strategy game for Android. I know it's a pipe dream to jump right in like that, but I figure going into it with a goal is a good way to go about it.

    I'm hunting around for decent tutorials to get myself started. Any help or suggestions would be much appreciated.

  • bowenbowen How you doin'? Registered User regular
    That's actually one of the easier concepts to get going. Even if it's simple, the concepts around it is good.

    http://wiki.scratch.mit.edu/wiki/Main_Page
    More specifically:
    http://wiki.scratch.mit.edu/wiki/Turn-Based_RPG

    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
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Any turn based game really is a good place to start; it's once you hit realtime that things get tricky

  • CantidoCantido Registered User regular
    Cantido wrote:
    I'm relearning PHP and SQL still, I've been given access to hosting services from a mentor to save money, but I don't know the permissions (he doesn't know, he didn't make the website.)

    $dbc = mysqli_connect('localhost', 'user', 'PASSWORD UNKOWN', 'database')
    or die('Error connecting to MySQL server.');

    I know to use localhost, I have the database, but I don't know the password. The hosting service is Host Gator, it's MY database and table that I made , but I don't know the password. Where in phpMyAdmin or in Host Gator's database listing can I get this password? I used the Host Gator control panel login and that's not doing it.

    This is the PHP error
    Warning: mysqli_connect() [function.mysqli-connect]: (42000/1044): Access denied for user 'user'@'localhost' to database 'database' in [IM CENSORING DIS SHIT] on line 23
    Error connecting to MySQL server.

    Is the password even what's wrong here? Today I tried something else. I made the user and assigned him my own password and that password didn't work either.

    ...anyone? I sent Host Gator a support request and they haven't responded. Yes my question is dumb, but I haven't touched a database in five years. :(

    3DS Friendcode 5413-1311-3767
  • bowenbowen How you doin'? Registered User regular
    edited February 2012
    I missed that @cantido, sorry.

    Do you have a username/password you login with in phpMyAdmin? User should be that, and password should be the one you log in with.

    Of course you can make other users to access your database if you'd like. You may find the username is more something like : cantdio@mydomain.com instead too, just to help prevent collisions if 8 people made "test_user".

    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
  • InfidelInfidel Heretic Registered User regular
    Yeah, that's not really a programming issue Cantido. You need to find what the proper username and password and database name are. That depends on what you have in your control panel for it.

    OrokosPA.png
  • CantidoCantido Registered User regular
    Infidel wrote:
    Yeah, that's not really a programming issue Cantido. You need to find what the proper username and password and database name are. That depends on what you have in your control panel for it.

    Ugh, that did it. I'm finally interacting with my own DB. Thanks.

    And if jQuery is actually intended to make JavaScript and AJAX simpler, I think Ill give learning it another shot.

    3DS Friendcode 5413-1311-3767
  • InfidelInfidel Heretic Registered User regular
    Cantido wrote:
    Infidel wrote:
    Yeah, that's not really a programming issue Cantido. You need to find what the proper username and password and database name are. That depends on what you have in your control panel for it.

    Ugh, that did it. I'm finally interacting with my own DB. Thanks.

    And if jQuery is actually intended to make JavaScript and AJAX simpler, I think Ill give learning it another shot.

    It makes Javascript possible in the real world, because if you're doing anything non-trivial you have to consider multiple browsers, and jQuery takes care of that for you in a lot of ways.

    OrokosPA.png
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    GnomeTank wrote:
    There are three special symbols in that. @ for member variable, & for callable block and : for "this is a symbol". There are really no special variables there with contextual meanings, like Perl's _$. The symbols that are there have the same meaning everywhere, and can be interpreted super easy.

    Hey, hey, hey, don't go ignoring those crazy || things. That's a 33% increase in crazy symbology.

    Oh god not the lambda argument pipes, oh the codemanity!

    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
  • bowenbowen How you doin'? Registered User regular
    I like how perl handles associative arrays, yes I do!

    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
  • Joe KJoe K Registered User regular
    bowen wrote:
    I like how perl handles associative arrays, yes I do!

    THE way?

    There's got to be at least 5000 ways to handle associative arrays, the more that they look like line noise the better.

  • bowenbowen How you doin'? Registered User regular
    Well, some say garbage others say line noise.

    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
  • Joe KJoe K Registered User regular
    GnomeTank wrote:
    GnomeTank wrote:
    There are three special symbols in that. @ for member variable, & for callable block and : for "this is a symbol". There are really no special variables there with contextual meanings, like Perl's _$. The symbols that are there have the same meaning everywhere, and can be interpreted super easy.

    Hey, hey, hey, don't go ignoring those crazy || things. That's a 33% increase in crazy symbology.

    Oh god not the lambda argument pipes, oh the codemanity!

    every language has its own set of stupidity with regards to magic characters and keywords. Look at C, I think there are only 21 keywords. Look at Java, notice how goto is explicitly a reserved keyword, and then explicitly never implemented (GRRRR).

    Python drives me nuts with its __ThisIsASpecialMethod__ crap. Really, double underscores instead of say, a keyword?

    And thank Guido for deciding that Python needed a complete rewrite for Python 3.0, so much that its got about the same chance to be picked up as Perl7. (He changed the "print" keyword into a "print()" function. Why Guido, why mess with something that has been perfectly useable? There's a ton more of wha? changes, but its damn near a completely different language.)

  • EndEnd Registered User regular
    python3 is not that different (and it's not a complete rewrite...it's just backwards incompatible changes). python2.6 and 2.7 got most of the non-backwards incompatible bits that 3.x offers

    the biggest change is the unicode change, but I think it's a good change, for the most part

    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Joe KJoe K Registered User regular
    I think that the changes are a bit more extensive than your admitting...

    http://docs.python.org/release/3.0.1/whatsnew/3.0.html

    He changes basic list comprehension, dictionaries and a slew of other things. He's done a great job as benevolent dictator, but the amount of 2.6/2.7 code out there and packages is a gigantic hurdle to overcome to force through these types of changes...

    The language prbly should move from "Benevolent Dictator" to a committee of some sort. Hell, even IEEE. At a certain point, things need to be mashed around in committee. Guido isn't the only person with good ideas.

    and mind you, i _love_ python.

  • Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    Joe K wrote:
    I think that the changes are a bit more extensive than your admitting...

    http://docs.python.org/release/3.0.1/whatsnew/3.0.html

    He changes basic list comprehension, dictionaries and a slew of other things. He's done a great job as benevolent dictator, but the amount of 2.6/2.7 code out there and packages is a gigantic hurdle to overcome to force through these types of changes...

    These are all, extensive, tidy ups, you're not supposed to have to migrate from 2.x to 3.x, 3 is a new base to start from not a target to hit - that's why 2.6 and 2.7 exist - they were both produced after 3.0 was finalised.

    The only change I actively disliked is the removal of auto tuple unpacking in function arguments. And that's only because I do a lot of Python game programming and so do pass around a lot of Cartesian co-ordinates (I am the special case the PEP refers to!).

    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.
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    Joe K wrote:
    I think that the changes are a bit more extensive than your admitting...

    http://docs.python.org/release/3.0.1/whatsnew/3.0.html

    He changes basic list comprehension, dictionaries and a slew of other things. He's done a great job as benevolent dictator, but the amount of 2.6/2.7 code out there and packages is a gigantic hurdle to overcome to force through these types of changes...

    The language prbly should move from "Benevolent Dictator" to a committee of some sort. Hell, even IEEE. At a certain point, things need to be mashed around in committee. Guido isn't the only person with good ideas.

    and mind you, i _love_ python.

    uuuhmmm, excuse me.

    I think you mean you ._ _love_ _ python

  • EndEnd Registered User regular
    The only list comprehension change I see is the change with using a tuple, and it seems pretty minor. I don't know why it was changed, although I think I probably normally write it as the python3 way anyway (explicit parenthesis).

    For library portability, there are compatibility tools, namely 2to3/3to2 and six. Using 2to3 can take a little bit of massaging, but many of the libraries I use are ported to python3 using it.

    As for writing Python 3 code from scratch, it seems pretty straightforward and it doesn't feel too different, at least to me. (so far I've really only gotten bit by trying to compare a file read with '' instead of b'' when I'm reading in binary mode)

    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • InfidelInfidel Heretic Registered User regular
    Jasconius wrote:
    Joe K wrote:
    I think that the changes are a bit more extensive than your admitting...

    http://docs.python.org/release/3.0.1/whatsnew/3.0.html

    He changes basic list comprehension, dictionaries and a slew of other things. He's done a great job as benevolent dictator, but the amount of 2.6/2.7 code out there and packages is a gigantic hurdle to overcome to force through these types of changes...

    The language prbly should move from "Benevolent Dictator" to a committee of some sort. Hell, even IEEE. At a certain point, things need to be mashed around in committee. Guido isn't the only person with good ideas.

    and mind you, i _love_ python.

    uuuhmmm, excuse me.

    I think you mean you ._ _love_ _ python

    This gets a Programmer Thread Awesome Post report.

    (Not a real one.)

    OrokosPA.png
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    You know, I didn't even think of the magic methods in python...how can someone be offput by member variables being prefixed with @, but be totally okay with __magicmethods__ __that__ __require__ __double__ __underscores__ __on__ __both__ __sides__...that's not line noise?

    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
  • bowenbowen How you doin'? Registered User regular
    Can you guys feel that?

    That's the hate of me staring at all your avatars and hoping you die.

    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
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    Woo my bot can move! Now to make it so it doesn't try to open doors by walking into them, over and over

  • jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    I've done very little python, but double underscore does a pretty good job of getting "hey, don't touch this shit" across. Of course private functions would be better, and I don't buy the "we're all adults here" excuse because it could be used to pretty much wave off any feature request.

  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    What the hell do private functions have to do with being adults? Private functions are about hiding away pieces of encapsulation not meant for public consumption. Most private methods will have a lot less error checking and basic defensive programming, because they are generally called in ways the original programmer intended...he wrote them!

    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
  • Mike DangerMike Danger "Diane..." a place both wonderful and strangeRegistered User regular
    So, I made some changes to my state-changing box:
    <TD>
    				<select id="stateSelector#ID#" job=#ID# class="stateSelector">
    					<CFQUERY NAME = "otherColors" DATASOURCE="#dbConnection#">
    						SELECT *
    						FROM Colors
    						WHERE Color <> "#State#"
    					</CFQUERY>
    					<option value="#State#">#State#</option>
    					<cfloop query="otherColors">
    						<option value="#Color#">#Color#</option>
    					</cfloop>
    				</select>
    				<div id="#ID#"class="check"><cfoutput>#Chr(10004)#</cfoutput>
    				</div>
    			</TD>
    

    The idea is that that ✔ character gets shown once a successful change has been made to the database so that there's some feedback.

    My problem is that, for some reason, I get multiple ✔'s. (The first job has 3, the second job has 2, the last one has 1.)

    Here's the javascript:
    <script type = "text/javascript">jQuery(document).ready(function(){
      $("div.check").hide();  
      $(".stateSelector").change(function() {
      	var formval = {num: 1, IDM: $(this).val(), id: $(this).attr("job")};
      	var theID = $(this).attr("job");
        $.ajax({
         type: "POST",
         url: "request_processor.cfm",
         dataType: "json",
         data: formval,
         success: function(response){
         	$("div.check").hide();
         	$("#"+response.id+".check").show();
    	}
       });
      });
    });
    </script>
    

    Steam: Mike Danger | PSN/NNID: remadeking | 3DS: 2079-9204-4075
    oE0mva1.jpg
This discussion has been closed.