Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
sarehu
Apr 20, 2007

(call/cc call/cc)

return0 posted:

if( ((num-1) & (num)) == 0 ) is not a test for evenness, it's checking for if num is a power of two.

It is however slightly incorrect in that zero is incorrectly considered to be a power of two,

But zero is a power of two.

2**64 = 0.

Adbot
ADBOT LOVES YOU

sarehu
Apr 20, 2007

(call/cc call/cc)

BattleMaster posted:

God drat, I wrote something in Python that was under 200 lines that could do the same thing, except it went from 0 to 999,999. And it sure as hell didn't take me 6 hours!

I wrote one in XSLT :(

sarehu
Apr 20, 2007

(call/cc call/cc)

N.Z.'s Champion posted:

How did you do that? Wouldn't the nesting of call-templates cause a stack overflow?

Or did you <xsl:for-each select="//node()[position() &lt; 999999]"><xsl:value-of select="position()"/></xsl:for-each> or something?

I want to see this abomination

There really aren't that many levels of recursion needed, I don't know what kind of crazy algorithm you're thinking of.

sarehu fucked around with this message at 04:27 on Jul 14, 2008

sarehu
Apr 20, 2007

(call/cc call/cc)
I saw

code:
for (int loop = 0; loop < 1; loop++) {
...
}
recently. It wasn't the kind of thing that should ever be a loop, too.

sarehu
Apr 20, 2007

(call/cc call/cc)

HappyHippo posted:

For 11,000 lines. This is in C#. Ignoring problems with the program's structure, I was able to turn this into about 5 lines of code with reflection.

Then you better start posting your own code too, bub.

sarehu
Apr 20, 2007

(call/cc call/cc)
That is bogus, because how easy something to internalize is depends on how complicated it is. Multi-threaded problems vs. single-threaded problems is one example, but really in general, the ability to understand something is related more closely to the size of the state space and not how many lines of code it takes.

sarehu
Apr 20, 2007

(call/cc call/cc)

Soricidus posted:

On my PC? Not such an obvious choice.

If you would be screwed by a lost password then you'd also be screwed by a hard drive failure.

sarehu
Apr 20, 2007

(call/cc call/cc)
Or some random Joe stealing your laptop or PC and then having to change all your passwords, and hoping you've remembered to cleanse your browsing history of those "furry rave" youtube history, or having them upload your gf's pictures to a revenge porn website. It's pretty hard to forget a disk encryption password, and if it is not, just write it down somewhere.

sarehu
Apr 20, 2007

(call/cc call/cc)

KaneTW posted:

I don't really know where else to post this but let's say you have a function

f: Z x N -> Bool

Taking a mask m in Z and checking if some property n in N is set. A simple implementation would be f(m,n) = m & (2<<n).


Now think of a really inefficient but always halting implementation. I was thinking of doing something with a power tower or Ackerman's function.

I think you mean f(m,n) = m & (1<<n).

sarehu
Apr 20, 2007

(call/cc call/cc)
foo, bar, baaz, khan, quux, bah, blah, are mine. Sometimes I use aa, bb, cc, etc.

sarehu
Apr 20, 2007

(call/cc call/cc)

ratbert90 posted:

The real horror is using strcmp instead of strncmp.

There's nothing wrong with using strcmp and it's the right thing to use here because you've got two null-terminated strings you're comparing.

(Just because strncpy is better than strcpy, that doesn't mean every C string function should use the "n" version.)

sarehu
Apr 20, 2007

(call/cc call/cc)

Subjunctive posted:

strncpy is definitely not better than strcpy,

Oh right. Oh god no. Well, I wouldn't know because I don't use them!

sarehu
Apr 20, 2007

(call/cc call/cc)
Doesn't that violate aliasing or something? Use a union.

sarehu
Apr 20, 2007

(call/cc call/cc)
Honestly Java without an IDE is fine. It's better than Python or Ruby (or any dynamically typed language) without an IDE.

sarehu
Apr 20, 2007

(call/cc call/cc)
Python is your basic dynamically typed language. Are there any real flaws, other than that and whitespace sensitivity, that isn't just really petty spergation? Like, flaws that really affect work?

sarehu
Apr 20, 2007

(call/cc call/cc)
Why would you guess C++?

sarehu
Apr 20, 2007

(call/cc call/cc)

TheresaJayne posted:

I saw the maddest thing yesterday, a friend's son is learning python at school...

his homework consisted of ticking boxes to say if he understood what the word syntax and the word Recursion etc. meant. -- WTF!!!!!!

How is that anything to do with Computer science? isn't that ENGLISH!!!!

I'm shocked, shocked that the public school system has a mediocre CS class.

I, in 2003, got taught BASIC based on an understanding of the language formed in 1979, and I had to number all my lines when using QBASIC.

sarehu
Apr 20, 2007

(call/cc call/cc)
If I have debug print statements I want to leave around, I make a new macro that expands to do { } while (0) for that specific file or that specific set of debug print statements, so that they can all be turned on easily.

I've also commented them out, which is fine, but suboptimal. With a debug printf line, it's immediately obvious what the purpose of that code was -- it's not like it's some bit-rotting function.

sarehu
Apr 20, 2007

(call/cc call/cc)

Blotto Skorzany posted:

2-byte floats?!

For what it's worth in the past I've considered using 1-nibble floats with 3 bits of exponent and 1 bit of mantissa.

sarehu
Apr 20, 2007

(call/cc call/cc)

Dr. Stab posted:

Did you include infinity, zero and NaN?

No. No sign bit either. Also the only operation was "convert from int to the nearest float" (and back).

sarehu
Apr 20, 2007

(call/cc call/cc)

return0 posted:

Don't see what's special about crypto.

Try looking.

sarehu
Apr 20, 2007

(call/cc call/cc)

apseudonym posted:

There have been instances of the NSA both helping (S boxes) and hurting (Dual_EC_DRBG) crypto with their advice

Those were different eras.

sarehu
Apr 20, 2007

(call/cc call/cc)

return0 posted:

Obviously don't write your own crypto lib, but only in the same way you don't write your own database engine, programming language or operating system (i.e., it shouldn't be special)

"Don't do your own crypto" does not mean don't write your own crypto lib, it means don't use a crypto lib directly.

And it's not the same thing as writing your own database engine at all.

Source: My coworkers that I was making a database engine and programming language with tried to do their own crypto.

Also, there's nothing wrong with making operating systems. What are you, some pussyfooted little human being that's afraid to dip down into ring zero? The real rule is "don't write your own web server." Possibly the one thing that's worse than using a crypto lib directly.

Source: That database engine I was talking about? It has its own widdle bespoke web server. Making a page cache or filesystem isn't really that hard, compared to having a web server that isn't a buggy insecure piece of poo poo.

sarehu
Apr 20, 2007

(call/cc call/cc)
Uh no, people don't deploy their own custom OS or compiler because that's a lot of effort. Deploying your own custom crypto is very little effort.

sarehu
Apr 20, 2007

(call/cc call/cc)
Use a library that does what your actual goal is. For example, if you want to do password hashing, use a password hashing library. If you want to communicate securely over bytestreams, use a secure bytestream communication library.

sarehu
Apr 20, 2007

(call/cc call/cc)

Suspicious Dish posted:

Freeing data on the heap doesn't necessarily meaning freeing pages. I actually don't know what happens if you access free'd heap memory that's within a still-mapped page.

Nothing happens. Maybe you corrupt the heap, if an allocation happened between the free and the write. Or eventually something gets allocated on top of what you wrote.

Valgrind would catch the error though.

sarehu
Apr 20, 2007

(call/cc call/cc)
Yes, see http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html and then http://www.daemonology.net/blog/2014-09-06-zeroing-buffers-is-insufficient.html. I wouldn't be able to tell you how far those posts descend into spergatory, or if they enter it at all.

sarehu
Apr 20, 2007

(call/cc call/cc)
TDD isn't "testing," it's orthogonal to the question of whether you have tests.

For UI stuff it'd be real annoying because you'd be writing UI tests before writing the UI, and that just slows down the UI design iteration process down because the tight loop 99% of the time should be around quality of user interaction.

sarehu fucked around with this message at 15:14 on Dec 31, 2014

sarehu
Apr 20, 2007

(call/cc call/cc)
Generally speaking, I have found mocking most useful for:

  • abstracting the interface to the system so that tests run faster / not poo poo all over some directory,
  • bringing in deterministic behavior in components which would, due to concurrency or other reasons, behave non-deterministically. In particular so that edge cases aren't missed.
  • sitting between the real components and observing their behaviors, instead of replacing them entirely, so that the cause of a failure is properly isolated. (This is a reason you'd ostensibly replace the component entirely, but you get stronger tests if you still run the real component.)

I can also think of some cases where I wanted to be able to test "was pow called" in a test. For example, sometimes I wanted to make sure my unit tests overflows some memory buffer that causes stuff to need to get pushed to disk. So I wanted to be able to have the test see that such an overflow really happened, otherwise the disk-touching code isn't going to get tested.

Edit: Really I just found myself wanting the regular code to spit out a log of everything it does, and then have the unit test inspect it after the fact.

sarehu fucked around with this message at 11:32 on Jan 2, 2015

sarehu
Apr 20, 2007

(call/cc call/cc)
My only group project in CS was in a class where we were all told to find some people to team up with after people proposed certain projects in the software design and documentation class, and bam, the five of us that didn't find our own team got put together. I think all five of us were all thinking, man, I don't want to get stuck with those bozos (the other teams and proposed projects) and we ended up making a video game.

Also had no problem with groupmates in some kewl philosophy class, even the stoner-type wasn't a slacker-stoner. The worst was chemistry 101, doing labs, because man do some people (my inferiors ofc.) have issues following instructions at high speed.

sarehu
Apr 20, 2007

(call/cc call/cc)
I'm glad people are still putting in a space between the <br and the />, because they don't want to give up Netscape 4 compatibility.

sarehu
Apr 20, 2007

(call/cc call/cc)
They forgot 57.

sarehu
Apr 20, 2007

(call/cc call/cc)

Suspicious Dish posted:

Linus is really terrible. He has some bad idea about something, and then thinks anybody who doesn't agree with his interpretation of complex issues, and I quote, "should be retroactively aborted. Who the f*ck does idiotic things like that? How did they noty die as babies, considering that they were likely too stupid to find a tit to suck on?"

Or maybe you could just not be a pissy little pussy.

:)

sarehu
Apr 20, 2007

(call/cc call/cc)

Suspicious Dish posted:

My former coworker was Jerome Glisse, not Rik. He's going to continue working on HMM, but he expressed frustration when trying to convey his ideas to Linus. He's not overly abusive in that thread, no, but he was wrong.

He's more abusive here: https://lkml.org/lkml/2014/11/10/649

He's expressing confusion and openly stating he might not understand things in that email and the follow up. You're also using the word "abusive" in a new recently-made-popular way to describe comments made online that doesn't actually correspond to anything known as "abuse." Linus is not abusing the recipient of his email, nor is he abusing the email system. So his email is not abusive. Unless you really think having and sharing beliefs about code being bad is a way to abuse somebody and also think having that having and sharing uncertain beliefs while going out of your way to point out that you might be wrong is a way to abuse somebody. (It seems to me you just like to try hard to hate people for no reality-based reason. See for example you calling me a racist because of a post that Skuto made.)

sarehu
Apr 20, 2007

(call/cc call/cc)

Look Around You posted:

I'm pretty sure he's not saying the criticism itself is abusive, but rather the manner in which it's delivered is. There's way more professional and tactful ways to express disagreement/misunderstanding than literally saying "WHAT? \n NONE OF WHAT YOU SAY MAKES ANY SENSE." and other very vitriolic poo poo ("you should be retroactively aborted", etc). Talking to someone that way (esp. in a semiprofessional environment) honestly is abusive.
You have to be emotionally retarded to interpret that retroactive abortion comment as vitriolic.* When I read comments like that I think, yes, I have felt that way and written like that, and I know how he feels, and it doesn't turn me off at all. So I think if other people are turned off then they are wrong to be so and their reasons or mere feelings are invalid. Also you are overlooking all the benefits of the tone he has. You'll see that sort of thing at other check-your-ego-at-the-door type environments.

*For example you'd have to be emotionally retarded to view that sentence as vitriolic too. And I mean materially vitriolic, with actual vitriol behind it.

sarehu
Apr 20, 2007

(call/cc call/cc)

Look Around You posted:

Also in what loving world do you live in where repeatedly posting/sending death threats to "express disagreement" to someone online is not abusive? Or having multiple people do it? How about posting their address and threatening to rape and murder them? How is any of that not abusive? Like do you honestly think that the #gamergate bullshit is actually about "ethics in video game journalism" and not a way to further disempower and subjugate women to push them further away from their sacred loving video games or whatever the gently caress their goal is now?

Like I honestly want to know how any of that poo poo is not abusive. Please justify it to me, I'd love to hear an explanation.

e: (that is not directly related to the linus style stuff, but to explain my reasoning, judging by how you framed your post talking about essentially fake abuse online, it definitely leads me to believe that you view that poo poo in the same way)

e2: ((and along the lines of the linus stuff, in what world is it not abusive to talk to someone like that? It's like the very definition of abusive language))

What.

sarehu
Apr 20, 2007

(call/cc call/cc)
In "the real world" it's not abusive to make statements of the form Linus made either. That is, saying "people that read bytes one at a time deserve to be retroactively aborted" is not abusive. It's hyperbolic nonsense and meant to be taken that way. The same goes for saying somebody likes seeing their name on "acked-by" lines, in the context that it was in.

I have no idea why you're talking about people saying other people should be raped, Linus is not doing that. People that find the word abusive useful for being unspecific and non-falsifiable have begun using it to talk about Linus. And other people repeat it word by word like the good little followers they are.

sarehu
Apr 20, 2007

(call/cc call/cc)

Snapchat A Titty posted:

I'm pretty sure the majority of people would find it hostile if someone said they should be retroactively aborted.

You're not responding to a post that was talking about whether something should be considered hostile. That does not mean the same thing as the word abusive.

sarehu
Apr 20, 2007

(call/cc call/cc)

it is posted:

I won't take advice from you, because you're an idiot.

, says the 2011 regdate.

Enjoy your arbitrary rules not based on a sensible theory of harm.

Adbot
ADBOT LOVES YOU

sarehu
Apr 20, 2007

(call/cc call/cc)
If only we had 12 fingers so that we could have 144x engineers.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply