|
Klades posted:Why in the world would you do cat | cat. It was demonstrating how easy pipes are in bash, not a code sample. Python's subprocess module is kind of garbage. I mean, it does everything you need to do, but the interface sucks. I have to double check the documentation just about every single time I need to use them again. But I'll never forget how to use a |.
|
# ? Jun 14, 2016 22:04 |
|
|
# ? May 21, 2024 02:56 |
|
xzzy posted:It was demonstrating how easy pipes are in bash, not a code sample. Fair enough. I'm not experienced enough in bash voodoo to immediately dismiss something like that but it didn't look like a thing you would actually want to do so I got confused.
|
# ? Jun 14, 2016 22:17 |
|
Klades posted:I mean I take your point, if you wanted to do something like grep | grep it would be comparatively messy in a scripting language, but then that's why you can do things like (Ruby, anyway):
|
# ? Jun 15, 2016 00:05 |
|
I saw a wordpress plugin and the wordpress plugin was generating IDs for inputs that had a space in them and it made me cry and it also made baby Jesus cry, so it's just bad all around. Why is wordpress a thing?
|
# ? Jun 15, 2016 00:22 |
|
PT6A posted:Why is wordpress a thing? Because every PHP developer who cares at all about making decent software has stopped using it, leaving only the lovely devs to make plugins. Those lovely ones happen to be the vast majority.
|
# ? Jun 15, 2016 00:29 |
|
xzzy posted:One of the cleverest (both good and bad types of clever) thing I've seen done with curly braces is in bash, where each pair of curly braces is a subshell. If you string them together with pipes you can create a parallelized event loop.. as subshells produce output the last binary in the pipe reads that and acts upon it. It's not the curl braces that makes it a subshell, it's the pipes that do. Curly braces just group commands for the purposes of redirection and the like, if you explicitly need a subshell you use parenthesis.
|
# ? Jun 15, 2016 07:14 |
|
rt4 posted:Because every PHP developer who cares at all about making decent software has stopped using it, leaving only the lovely devs to make plugins. Those lovely ones happen to be the vast majority. You're forgetting the entire industry of Wordpress plugin malware makers.
|
# ? Jun 15, 2016 08:09 |
|
JavaScript code:
|
# ? Jun 15, 2016 16:40 |
|
edit: misread
|
# ? Jun 15, 2016 17:30 |
|
I'm the //if
|
# ? Jun 15, 2016 18:40 |
|
Symbolic Butt posted:I'm the //if I'm the unnecessary variable. I'm also the inconsistent use of whitespace.
|
# ? Jun 15, 2016 19:07 |
|
Wow, you folks left it wide open for me, because I'm the function which thinks true is a Boolean but false isn't.
|
# ? Jun 15, 2016 19:29 |
|
If only javascript had a typeof operator or something, that poor ignorant coder could have avoided being shamed on the internet. At least partially. I suppose a code base where a boolean could be stored as a string would wind up in here anyways.
|
# ? Jun 15, 2016 19:30 |
|
In before everybody starts code golfing on how they'd implement isBoolean in JavaScript
|
# ? Jun 15, 2016 19:39 |
|
xzzy posted:If only javascript had a typeof operator or something, that poor ignorant coder could have avoided being shamed on the internet. I don't think typeof OR isBool are things in javascript. There's a tryparse equivalent for integers but not for Booleans. You actually do need a function similar to this if you want to do it (not that there aren't far more efficient and cleaner ways than shown here)
|
# ? Jun 15, 2016 19:39 |
|
Skyl3lazer posted:I don't think typeof OR isBool are things in javascript. There's a tryparse equivalent for integers but not for Booleans. You actually do need a function similar to this if you want to do it (not that there aren't far more efficient and cleaner ways than shown here) It actually does have typeof, but it's saddled with all the typical javascript baggage where you end up needing to pay special attention if you pass it an object.
|
# ? Jun 15, 2016 19:42 |
|
Skyl3lazer posted:I don't think typeof OR isBool are things in javascript. There's a tryparse equivalent for integers but not for Booleans. You actually do need a function similar to this if you want to do it (not that there aren't far more efficient and cleaner ways than shown here) Perhaps a small helper library such as Lodash could provide this, like _.isBoolean!
|
# ? Jun 15, 2016 20:03 |
|
With javascript I can never tell if something is badly written (beyond if (value) in this case...), or if I just don't know javascript well enough for it to be sensable. Either way it's still badly written I guess. dougdrums fucked around with this message at 20:23 on Jun 15, 2016 |
# ? Jun 15, 2016 20:18 |
|
xzzy posted:It actually does have typeof, but it's saddled with all the typical javascript baggage where you end up needing to pay special attention if you pass it an object. What do you mean? What's wrong with typeof thing === "boolean"?
|
# ? Jun 15, 2016 20:46 |
|
HappyHippo posted:What do you mean? What's wrong with typeof thing === "boolean"? I just was trying to make it clear that if it gets passed anything that is not a primitive type, it'll probably return "object" which would probably confuse newbie developers that didn't read the explanation that just about everything is an object. Like if they pass a string object versus a primitive string. code:
|
# ? Jun 15, 2016 20:58 |
HappyHippo posted:What do you mean? What's wrong with typeof thing === "boolean"? I think the type can be "object", with a class/prototype that is "Boolean". Which is sort of the same but not really.
|
|
# ? Jun 15, 2016 20:58 |
|
Right but those sorts of objects are effectively useless as primitives.code:
|
# ? Jun 15, 2016 21:14 |
|
I'm not sure what you folks are talking about considering a 'type of' operator. Java has an instanceof operator, which only works on objects, not on primitives. instanceof returns true if an object is of the given type or extends or implements the given class/interface. Its main use is to find out if you're allowed to cast an object to a subclass, so you can reach specific subclass methods. Even then, it's often better to just have the subclass method override a method declaration in the superclass/interface. instanceof does not work on primitives, but that's no problem, because if you try to send the wrong primitive type into a method you'll get a compile error. There's no supertype for primitives, so you'll always know what you're dealing with. If you try to do arithmetic with primitives, it'll automatically upcast smaller primitive types to the largest used, and integer types to a floating point type. (Also if you do any arithmetic with bytes, shorts, of chars, it'll upcast them to int automatically and you'll have to manually downcast them to the old type if you want to keep it, because the JVM cannot do arithmetic with less than 32 bits). There's no way to directly cast primitive booleans to numeric values or vice versa, booleans are completely their own thing. String primitives do not exist, String literals automatically become a String object (with as its main member a char array). At work we often use Integer wrapper objects instead of primitives, because they are allowed to be null. Carbon dioxide fucked around with this message at 06:07 on Jun 16, 2016 |
# ? Jun 16, 2016 06:04 |
|
I'm just trying to think of what has to go wrong for you to have a spot in your code where a variable could be a boolean or it could be a string representation of a boolean value.Carbon dioxide posted:I'm not sure what you folks are talking about considering a 'type of' operator. Well they're talking about JavaScript for one thing.
|
# ? Jun 16, 2016 06:33 |
|
Klades posted:I'm just trying to think of what has to go wrong for you to have a spot in your code where a variable could be a boolean or it could be a string representation of a boolean value. You're talking about JavaScript, so everything already went wrong.
|
# ? Jun 16, 2016 06:42 |
|
leper khan posted:You're talking about JavaScript, so everything already went wrong. New thread title?
|
# ? Jun 16, 2016 06:44 |
|
Just something I noticed on Stackoverflow sidebar... The struggle is real. How do I correctly pass the string “Null” (an employee's proper surname) to a SOAP web service from ActionScript 3?
|
# ? Jun 16, 2016 07:44 |
|
JavaScript code:
|
# ? Jun 16, 2016 10:28 |
|
Klades posted:I'm just trying to think of what has to go wrong for you to have a spot in your code where a variable could be a boolean or it could be a string representation of a boolean value. Best case, someone inherited a pre-existing project and was trying to make the best of a bad situation.
|
# ? Jun 16, 2016 14:22 |
|
qntm posted:Perhaps a small helper library such as Lodash could provide this, like _.isBoolean! quote:small library quote:Lodash This is why programming sucks in 2016
|
# ? Jun 16, 2016 14:37 |
|
Klades posted:I'm just trying to think of what has to go wrong for you to have a spot in your code where a variable could be a boolean or it could be a string representation of a boolean value. I think you just answered your own question
|
# ? Jun 16, 2016 17:54 |
|
code:
|
# ? Jun 16, 2016 17:55 |
|
xtal posted:This is why programming sucks in 2016 Lodash publishes individual packages for each function, actually. It's both hilarious and also useful, thanks to the stdlib not existing.
|
# ? Jun 16, 2016 18:24 |
|
Minified it's probably smaller than most JPGs before it's compressed for transit and probably already in cache if you use a common CDN URL to load it, so IDK why people think it's some terrible burden.
|
# ? Jun 16, 2016 19:02 |
The true horror is being in a situation where you need to check if something is a bool using javascript.
|
|
# ? Jun 16, 2016 19:15 |
|
The real horror is writing code.
|
# ? Jun 16, 2016 19:35 |
|
Commit message: "Removed obsolete data members"
|
# ? Jun 16, 2016 23:06 |
|
raminasi posted:Commit message: "Removed obsolete data members" lol he gets that source control is a thing obviously he just doesn't want to let it do its job.
|
# ? Jun 17, 2016 00:12 |
|
C# code:
Knyteguy fucked around with this message at 00:36 on Jun 17, 2016 |
# ? Jun 17, 2016 00:34 |
|
|
# ? May 21, 2024 02:56 |
|
Knyteguy posted:
Maybe more properties from that object used to be referenced.
|
# ? Jun 17, 2016 00:48 |