|
Zemyla posted:fputs(fp, buf)
|
# ? Apr 20, 2014 23:11 |
|
|
# ? May 17, 2024 02:01 |
|
ExcessBLarg! posted:Only if you don't check the return value of snprintf for truncation or error. Actually I should qualify that a bit since there's not universal agreement on best practice. Thanks! That's really good info and I will start using it that way for sure. I generally don't test for truncation because whenever I use popen it's from a known size of buffer such as the output of ps. I generally stay away from user input programs, but good coding habits are universal. ExcessBLarg! posted:fread shouldn't return short (except error or EOF) so you don't need to call it in a loop. Except, apparently there are cases where fread has returned short as result of libc bugs. Furthermore, fread doesn't need to scan for linebreaks like fgets does. Also thanks for the help! The last time I used fgets was for some string handling functions where I needed to know the line count, so I was using the fgets loop to increment a index when \n was reached. But again, good habits is something I would rather have than lovely habits that work but not for the right reasons.
|
# ? Apr 21, 2014 03:23 |
|
code:
Ran into this when trying to demonstrate that # is foiled by gaps in keys (since "nil" isn't kept as a table entry). I guess it's deserved for playing around with nils in tables, but still.
|
# ? Apr 22, 2014 06:04 |
|
Zamujasa posted:
Yeah, that looks like a bug. It looks like it's setting the internal length attribute on table construction time, since it can easily know the capacity of the fixed list, but then after you set a new key, it has to recalculate and is foiled by the nil.
|
# ? Apr 22, 2014 08:43 |
|
code:
code:
|
# ? Apr 22, 2014 23:38 |
|
Finally someone takes a principled stand against wasting vertical space with that brace style.
|
# ? Apr 22, 2014 23:40 |
|
eithedog posted:
Aw yeah, ASI horrors. That gift keeps on giving.
|
# ? Apr 23, 2014 00:01 |
|
Edison was a dick posted:Yeah, that looks like a bug. If by "a bug" you mean "behaviour that is explicitly documented as undefined in the language specification", then yes: quote:Unless a __len metamethod is given, the length of a table t is only defined if the table is a sequence, that is, the set of its positive numeric keys is equal to {1..n} for some integer n. In that case, n is its length. Note that a table like
|
# ? Apr 23, 2014 00:51 |
|
Working on a client application against a server being developed by the guys paying us to write the client. I'm 6 hours into waiting on a deployment that they didn't notify or schedule with us. Naturally, they have failed to deploy all of their environments at the same time. Is this the megathread for software deployment procedure horrors? How do you even deal with this, house an SLA in the contract?
|
# ? Apr 23, 2014 01:02 |
|
I once billed a client for 10 hours of "waiting for the server to work" and had it paid without complaint. When possible, just find other stuff to work. Server downtime is a great time to write more unit tests for poo poo, make your build system less of a barely working pile of garbage, etc.
|
# ? Apr 23, 2014 01:26 |
|
All of the horrors http://www.tedunangst.com/flak/post/worst-common-denominator-programmingquote:The common way to approach software portability is to establish a baseline and then program to that least common denominator. The portability layers in OpenSSL, however, go way beyond least. This is a fully realized experiment in worst common denominator programming.
|
# ? Apr 23, 2014 10:58 |
eithedog posted:> object Languages that automatically insert semicolons, the true horror.
|
|
# ? Apr 23, 2014 17:31 |
|
Plorkyeran posted:When possible, just find other stuff to work. I wasted the entire day yesterday because ClearCase decided to stop working on my machine. It got gradually worse, to the point that I could not even open a new terminal window or log in remotely. Only good thing is that I got a workstation upgrade out of it. We're planning to transition to Git Real Soon Now. I can't decide whether to wish for it or be terrified about it. I'm sure I'll have plenty of horrors for this thread when it happens.
|
# ? Apr 23, 2014 17:55 |
|
Git is amazing as long as you don't have coworkers that read HackerNews 24/7 and get distracted by every shiny new thing and come up with ridiculously outlandish branching and merging processes. Then you end up with things that belong in this thread.
|
# ? Apr 23, 2014 18:26 |
|
Manslaughter posted:Languages that automatically insert semicolons, the true horror. Zopotantor posted:I wasted the entire day yesterday because ClearCase
|
# ? Apr 23, 2014 18:34 |
|
Soricidus posted:There's more than one? I've never looked at it but I'ma guess ActionScript will insert semicolons without you asking.
|
# ? Apr 23, 2014 21:05 |
|
Golang has (significantly less-retarded) ASI as well.
|
# ? Apr 23, 2014 21:36 |
|
Zopotantor posted:ClearCase When we transitioned to Mercurial from ClearCase, some of the groups estimated it would take months to get it to replace everything. Our project adopted it withing a week and the others with a couple of weeks. Haven't looked back since. Can't recommend getting away from ClearCase enough.
|
# ? Apr 23, 2014 22:21 |
|
We used to use clearcase and had a dedicated support team except their response to every problem was pretty much "idk it's hosed I guess". Some teams are still on it which should be making somebody nervous. At least we're on svn though so it's a step up. Edit: I found 1.6gb of possibly confidential pdf files checked into svn last week the dev responsible said "yeah sounds like something I'd do"
|
# ? Apr 23, 2014 22:33 |
|
Deus Rex posted:Golang has (significantly less-retarded) ASI as well. Effective Go posted:The rule is this. If the last token before a newline is an identifier (which includes words like int and float64), a basic literal such as a number or string constant, or one of the tokens
|
# ? Apr 23, 2014 22:47 |
|
Soricidus posted:There's more than one? Haskell also inserts semicolons (and curly braces) by itself. That's because the Haskell syntax is nominally indentation-based (like Python), but it's internally reduced to a braces-and-semicolon syntax, which is what the grammar proper is defined in terms of. For example: code:
code:
explicit notation, except if they have to generate Haskell code for some reason
|
# ? Apr 23, 2014 23:13 |
|
I interviewed with a big games company back in ~2005 and at the time they used SourceSafe for everything (on the team I was going to work with, at least, which was building an MMO). This was especially great for the server guys who were developing for Linux, and had to do Samba copy-over bullshit every time they updated or wanted to commit. One guy said they *routinely* lost changes and had to chase bugs because of it for weeks at a time, but when I asked the lead about it after he interviewed me, his answer was basically " I have some batch files". That's not why I didn't take the job, and it's probably not why the game was cancelled (leaving the company's MMORPG/MMOFPS/MMORTS trinity incomplete!), but I'm sure it contributed to both.
|
# ? Apr 23, 2014 23:19 |
|
Similarly, Lua permits semicolons as statement separators, but it's not really "ASI" -- the grammar is unambiguous with or without them, and inserting a semicolon anywhere that wasn't already parsed as being between statements is a syntax error. They are permitted primarily to let you semicolon-separate one-liners for readability.
|
# ? Apr 23, 2014 23:20 |
|
Athas posted:Or something like that - most Haskell programmers never use the explicit notation, except if they have to generate Haskell code for some reason Some people use the explicit notation exclusively. Back when I was writing Haskell regularly, I did use the implicit notation, and my experience was that the algorithm generally worked quite well, but:
Go's design is admirably simple, but it does force some style decisions that I'm not thrilled about, like always putting binary operators on the end of the line instead of the beginning of the next.
|
# ? Apr 23, 2014 23:56 |
|
Subjunctive posted:I interviewed with a big games company back in ~2005 and at the time they used SourceSafe for everything (on the team I was going to work with, at least, which was building an MMO). This was especially great for the server guys who were developing for Linux, and had to do Samba copy-over bullshit every time they updated or wanted to commit. One guy said they *routinely* lost changes and had to chase bugs because of it for weeks at a time, but when I asked the lead about it after he interviewed me, his answer was basically " I have some batch files". why would anybody build an MMO
|
# ? Apr 24, 2014 00:11 |
|
Suspicious Dish posted:why would anybody build an MMO Because they had made money off EQ, and thought lightning would strike them twice, I assume. Edit: unless you mean "why would someone take a job doing that" in which case I'm not sure, but I do take a sympathetic position on mental illness in general. Subjunctive fucked around with this message at 00:20 on Apr 24, 2014 |
# ? Apr 24, 2014 00:18 |
|
ToxicFrog posted:Similarly, Lua permits semicolons as statement separators, but it's not really "ASI" -- the grammar is unambiguous with or without them, and inserting a semicolon anywhere that wasn't already parsed as being between statements is a syntax error. They are permitted primarily to let you semicolon-separate one-liners for readability. Lua does have a single case where you need a semicolon: Lua code:
I've never actually encountered this problem in real code.
|
# ? Apr 24, 2014 00:27 |
|
Plorkyeran posted:Lua does have a single case where you need a semicolon: Yet people still whine about semicolons.
|
# ? Apr 24, 2014 01:01 |
|
Plorkyeran posted:Lua does have a single case where you need a semicolon: That was a parse error in 5.1 precisely because of that ambiguity. I had no idea they'd dropped that restriction.
|
# ? Apr 24, 2014 01:38 |
|
rjmccall posted:Some people use the explicit notation exclusively. Back when I was writing Haskell regularly, I did use the implicit notation, and my experience was that the algorithm generally worked quite well, but: I began using the explicit notation because that made it super-easy for Emacs to indent the code by hitting tab exactly once.
|
# ? Apr 24, 2014 01:39 |
|
revmoo posted:Git is amazing as long as you don't have coworkers that read HackerNews 24/7 and get distracted by every shiny new thing and come up with ridiculously outlandish branching and merging processes. Then you end up with things that belong in this thread.
|
# ? Apr 24, 2014 06:20 |
|
revmoo posted:coworkers that read HackerNews 24/7 This is the real horror, no need to blame a perfectly fine DVCS.
|
# ? Apr 24, 2014 07:17 |
|
Hey, as long as it's implemented in NodeJS (2011), Clojure (2012), Scala (2013) or Go (2014) I don't think anyone in HN will disagree.
|
# ? Apr 24, 2014 10:33 |
I only code in languages that haven't been invented yet.
|
|
# ? Apr 24, 2014 11:45 |
|
Sulla-Marius 88 posted:I only code in languages that haven't been invented yet. And so do your colleagues, from what you've been telling us.
|
# ? Apr 24, 2014 12:52 |
Westie posted:And so do your colleagues, from what you've been telling us. The latest bit of fun has been trying to explain (for the 2nd or 3rd time) how to protect against SQL injection. Not even what it is, just "take as a given that data from the user is dangerous, here's this function you need to use that someone has already coded for you". I don't have the energy to get stuck into "also you have to assume that data already in your database is dangerous too". I'm just.. so help me god I'm just not paid enough for that.
|
|
# ? Apr 24, 2014 13:14 |
|
Strong Sauce posted:Yet people still whine about semicolons. Nobody in this thread is claiming that intentionally writing Lua like that is somehow virtuous or worthwhile. I will happily join you (?) in condemning that misfeature of Lua's grammar/parser.
|
# ? Apr 24, 2014 13:47 |
|
Sulla-Marius 88 posted:
I know that any place that doesn't understand SQL injection won't have code reviews, but this is exactly why you do code reviews.
|
# ? Apr 24, 2014 19:08 |
|
I remember running from a place that asked if I did Dynamic SQL and biz logic in sprocs
|
# ? Apr 24, 2014 19:12 |
|
|
# ? May 17, 2024 02:01 |
|
Just remembered an old coding horror, complements of a colleague. He got a ticket to add the current time, with seconds, to a page in an app. So he wrote js/php to query the server every second and get the current time. Nobody ever noticed until I happened to be looking at the code for the page in question months later.
|
# ? Apr 24, 2014 19:14 |