|
leterip posted:So (2 > 1 is True) evaluates to (2 > 1 and 1 is True) which is False. The parenthesis stop the expansion. (This one took me a while to figure out.) Here's the bit that confuses me: code:
code:
|
# ? Jan 19, 2012 21:15 |
|
|
# ? May 27, 2024 20:42 |
|
ToxicFrog posted:Here's the bit that confuses me: Yes, False == 0. I'll repeat myself from the previous page: code:
LOOK I AM A TURTLE fucked around with this message at 07:15 on Jan 20, 2012 |
# ? Jan 19, 2012 21:25 |
|
More Python 3 -nesscode:
code:
Hell, until 3+, you could assign to True and False: code:
EDIT: Looks like this was a 3.0 thing: http://docs.python.org/py3k/whatsnew/3.0.html#changed-syntax Lysidas fucked around with this message at 03:17 on Jan 20, 2012 |
# ? Jan 20, 2012 03:13 |
|
Here's one from myself (not actually a coding horror but a case of severe retardation):code:
|
# ? Jan 20, 2012 17:17 |
|
Oh god. I just found this in some code I wrote... almost exactly 4 years ago, if the date stamp in the comments is to be believed. In my defence, it was an internal application, and it had to pass auth checks before it could get near this code. That's a poor defence, but there you have it. I was young and stupid? php:<? // validate editable fields $editable_fields = array("customerid"=>"is_int", "project"=>"is_string", "fixedquote"=>"is_string", "quoteamount"=>"is_numeric", "quotehours"=>"is_int", "active"=>"is_int"); // is it an editable field? if (isset($editable_fields[$_POST['field']])) { // is the value valid? if (eval("return ".$editable_fields[$_POST['field']]."('".addslashes($_POST['value'])."');")) { /* ... do stuff ... */ } else { /* error about not being the right type of data */ } } else { /* error about not being an editable field */ } I'm going through and replacing it with this, which is still a horror in it's own right, but less of one. php:<? if (isset($editable_fields[$_POST['field']])) { $func = $editable_fields[$_POST['field']]; // is the value valid? if ($$func($_POST['value'])) { /* ... do stuff ... */ } else { /* error about not being the right type of data */ } } else { /* error about not being an editable field */ }
|
# ? Jan 20, 2012 20:07 |
|
I haven't done one of these in a while: multi-threaded FizzBuzz.code:
|
# ? Jan 21, 2012 00:34 |
|
This might be a repeat but python chat reminded me of my favourite python thing:code:
|
# ? Jan 21, 2012 11:12 |
|
The python repl is geared towards learning the language, and "exit" isn't a function call.
|
# ? Jan 21, 2012 11:15 |
|
Haha, apparently by default exit is bound to a Quitter object whose __repr__ is that 'Use exit()' message.
|
# ? Jan 21, 2012 11:52 |
|
yaoi prophet posted:Haha, apparently by default exit is bound to a Quitter object whose __repr__ is that 'Use exit()' message. Honestly when it's put like that, I gotta go with pokeyman. Python is being a dick right there. And lord knows I've typed exit so many times.
|
# ? Jan 21, 2012 13:16 |
|
I forget which but one of the calculator programs (dc or bc) is worse. It traps C-c and yells at you to use exit() instead
|
# ? Jan 21, 2012 15:42 |
|
bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. ^C (interrupt) use quit to exit.
|
# ? Jan 21, 2012 16:16 |
|
See, I figure that's because they wanted C-c to kill a long-running computation but not have mashing C-c get rid of all of your saved state.
|
# ? Jan 21, 2012 16:18 |
|
ctrl Z kill %1 You're not my dad, don't tell me what I can and cannot do
|
# ? Jan 21, 2012 17:01 |
|
yaoi prophet posted:See, I figure that's because they wanted C-c to kill a long-running computation but not have mashing C-c get rid of all of your saved state. Yeah, that's an entirely reasonable approach.
|
# ? Jan 21, 2012 17:20 |
|
vim and nethack also catch C-c, those bastards.
|
# ? Jan 21, 2012 18:25 |
|
I need a custom keyboard so that I can bind C-"NO YOU SHUT THE gently caress UP DAD" to SIGKILL
|
# ? Jan 21, 2012 18:27 |
|
Otto Skorzeny posted:I need a custom keyboard so that I can bind C-"NO YOU SHUT THE gently caress UP DAD" to SIGKILL
|
# ? Jan 21, 2012 20:07 |
|
yaoi prophet posted:Haha, apparently by default exit is bound to a Quitter object whose __repr__ is that 'Use exit()' message. Right. The reason it doesn't just quit on __repr__ is because anything that calls repr() on it will quit the program. There are quite a few tools in the stdlib that do, so using those tools on the global scope shouldn't just abort randomly.
|
# ? Jan 21, 2012 23:04 |
|
bobthecheese posted:I'm going through and replacing it with this, which is still a horror in it's own right, but less of one. You should probably just do: php:<? if(array_key_exists($_POST['field'], $editable_fields) && function_exists($editable_fields[ $_POST['field'] ])) { if($editable_fields[$_POST['field']]($_POST['value'])) { // ... } }?> It's still a coding horror, but so is PHP.
|
# ? Jan 22, 2012 05:25 |
|
Move over AES and PGP, it's time for "The most secure data cryption program in the world": KRYPTOChef! AES and PGP are public algorithms, which means that anybody can study them to learn how they work and decrypt any file. KRYPTOChef is different: KRYPTOChef posted:It will be a self-developed by me (ONLY) in KRYPTO used (OTP encryption method) is used. It even has proof of its security! Watch: KRYPTOChef posted:Proof of the Krypto security ! For those not versed in idiot, this says: "The permutation of files with 18,033 bytes is a number with over 43,424 places."
|
# ? Jan 23, 2012 01:55 |
|
Suspicious Dish posted:Move over AES and PGP, it's time for "The most secure data cryption program in the world": KRYPTOChef! In a million years, whatever humans have evolved to will have this inscribed on their buildings / on their currency: some sort of crazy posted:Who it does not know can only say there. That does not know so exactly !
|
# ? Jan 23, 2012 02:13 |
|
I can't imagine why you picked those two excerpts when this was sitting between themKRYPTOchef posted:Why are 256 bits the technically highest coding depth at all on computers possible are ?
|
# ? Jan 23, 2012 03:22 |
|
Pretty sure he's crazy. The newsletter is a rant about some judge violating his human rights, and demands 2mil EUR from the German chancellor. Also if he gets 2mil EUR in donations he'll release the program for free to everyone.
|
# ? Jan 23, 2012 04:00 |
|
Aleksei Vasiliev posted:Pretty sure he's crazy. The newsletter is a rant about some judge violating his human rights, and demands 2mil EUR from the German chancellor. Can we send him a huge rear end fake €2,000,000 note so that he publishes it or would that be illegal/immoral?
|
# ? Jan 23, 2012 05:23 |
|
McGlockenshire posted:You should probably just do: Could probably also use call_user_func_array() for slightly cleaner code. php:<? call_user_func_array($editable_fields[$_POST['field']], array($_POST['value']));?>
|
# ? Jan 23, 2012 12:34 |
|
Look Around You posted:Can we send him a huge rear end fake €2,000,000 note so that he publishes it or would that be illegal/immoral? Send him an encrypted string, say it's a swiss bank account number w/ PIN that has 2 million euro in it. Since he's a crypto genius he should be able to crack it.
|
# ? Jan 23, 2012 19:53 |
|
Here's a lightning talk about why JavaScript sucks (and a few things about Ruby, too) that sheds more light on why JavaScript is an awful, awful language.
|
# ? Jan 23, 2012 23:53 |
|
Oh, it's not an awful language. In fact, it's not a language at all.
|
# ? Jan 24, 2012 00:59 |
|
Poop Delicatessen posted:Here's a lightning talk about why JavaScript sucks (and a few things about Ruby, too) that sheds more light on why JavaScript is an awful, awful language. That was like watching an old episode of Roseanne.
|
# ? Jan 24, 2012 01:13 |
|
Poop Delicatessen posted:Here's a lightning talk about why JavaScript sucks (and a few things about Ruby, too) that sheds more light on why JavaScript is an awful, awful language. JavaScript has some rough parts, and that's why I'm becoming a huge fan of CoffeeScript. Plus, I just really like CoffeeScript's syntax over JavaScript.
|
# ? Jan 24, 2012 01:23 |
|
Doc Hawkins posted:Oh, it's not an awful language. In fact, it's not a language at all. What the gently caress is this poo poo? Like I honestly have no idea how he's saying that a turing complete language that's actually pretty powerful despite having a simple syntax isn't a language. this dumbfuck posted:Years ago I read something which explained, in my opinion, why Lisp has never achieved the mainstream adoption its passionate advocates believe it deserves. Lisp projects experience a degree of balkanization because everything is left wide open; you can use more than one object-oriented paradigm (potentially even at the same time), you write your own this, you write your own that, you write your own everything. I don't know any extremely popular languages which provide a few simple but powerful constructs. Wait, Lua is pretty widespread and it has no built in OO system. I just e: I mean lisp definitely isn't mainstream probably because it's not the most readable thing ever (and because most people aren't 100% comfortable with functional programming), but that certainly doesn't mean it's not a powerful programming language. Look Around You fucked around with this message at 03:38 on Jan 24, 2012 |
# ? Jan 24, 2012 03:35 |
|
Look Around You posted:What the gently caress is this poo poo? Like I honestly have no idea how he's saying that a turing complete language that's actually pretty powerful despite having a simple syntax isn't a language. It's even worse because he basically takes a Douglas Crockford's "Javascript is Lisp in C's clothing" and deranges it beyond reason. He then goes on to claim that Lisp is simply for AST manipulation and really isn't abstract enough to handle pragmatic programming. I haven't seen such a stupid hunk of poo poo since I watched some talk where the guy called Barbara Liskov a "dude"
|
# ? Jan 24, 2012 04:00 |
|
TRex EaterofCars posted:It's even worse because he basically takes a Douglas Crockford's "Javascript is Lisp in C's clothing" and deranges it beyond reason. He then goes on to claim that Lisp is simply for AST manipulation and really isn't abstract enough to handle pragmatic programming. Yeah I saw that and shut my brain off because I couldn't comprehend just how loving stupid this guy is. Like jesus christ. e: I mean the least insane point he has I guess is the "it lacks some built in stuff" but that doesn't really keep a language from being a language. Just loving christ that guy. Look Around You fucked around with this message at 04:33 on Jan 24, 2012 |
# ? Jan 24, 2012 04:30 |
|
Look Around You posted:I don't know any extremely popular languages which provide a few simple but powerful constructs. Wait, Lua is pretty widespread and it has no built in OO system. I just TRex EaterofCars posted:He then goes on to claim that Lisp is simply for AST manipulation and really isn't abstract enough to handle pragmatic programming. Extending this idea to Javascript is pretty dumb though, as Javascript doesn't give you any tools for creating your own language that you write your actual program in. Plorkyeran fucked around with this message at 04:35 on Jan 24, 2012 |
# ? Jan 24, 2012 04:31 |
|
Plorkyeran posted:Lua has syntax and features explicitly intended for prototype-based OOP. Yeah but I mean so does Javascript.
|
# ? Jan 24, 2012 04:33 |
|
Look Around You posted:Yeah but I mean so does Javascript. And Lisp doesn't, which is what he was talking about there. Lua also has a decent module system. It's actually sort of pathetic that there are so many high-level languages which don't have features which Lua has.
|
# ? Jan 24, 2012 04:39 |
|
Plorkyeran posted:He's basically saying the same thing as all the people who talk about how awesome Lisp is because you can easily create a DSL and then write your program in that... which is a pretty widely accepted way to use Lisp (to the extent that anything involving Lisp can be called "widely accepted"). If that's really what he is saying he chose a lovely way to say it. Cause to me it seemed like he was saying Lisp isn't pragmatic for programming anything beyond fiddling with syntax trees. In fact that's exactly what he said.
|
# ? Jan 24, 2012 04:42 |
|
Plorkyeran posted:And Lisp doesn't, which is what he was talking about there. Common Lisp also has CLOS as part of its ANSI standard. And honestly you don't absolutely need objects in a functional language.
|
# ? Jan 24, 2012 04:44 |
|
|
# ? May 27, 2024 20:42 |
|
TRex EaterofCars posted:If that's really what he is saying he chose a lovely way to say it. I dunno about that. After all, here we are, reacting to it. The line between branding and trolling can become quite thin in the celebrity-developer world.
|
# ? Jan 24, 2012 05:03 |