|
Oh dear god e: Not gonna quote it, let's start this page clean lest its predecessors taint destroy us all
|
# ? May 15, 2015 01:40 |
|
|
# ? May 23, 2024 09:34 |
|
Snapchat A Titty posted:Oh dear god Nonsense, we need more enterprise quality code in this thread. https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
|
# ? May 15, 2015 01:57 |
|
Jsor posted:Nonsense, we need more enterprise quality code in this thread. Depressingly, it's one of the most healthy repos I've seen, fork/pullrequest-wise. Lots of new stuff getting merged in. I guess at the very least it proves that bikeshedding can be a motivating factor.
|
# ? May 15, 2015 02:05 |
|
Jsor posted:Julia auto-promotes ints to floats for division, but there is a special operator for integer division. It seems to work pretty well there, but then Julia is also a scientific computing language. I imagine that style of handling division was borrowed from Python 3? Because P3 does the same thing, and Julia devs are quite aware of their main competition.
|
# ? May 15, 2015 02:10 |
|
pmchem posted:I imagine that style of handling division was borrowed from Python 3? Because P3 does the same thing, and Julia devs are quite aware of their main competition. Enough so that one of the libraries lets you write @pyimport whatever and you essentially just use the imported python library like normal. Python's biggest strength is probably its libraries so its really convenient. I wish I had more of an excuse to use it.
|
# ? May 15, 2015 02:20 |
|
Qwertycoatl posted:
That is really amazing
|
# ? May 15, 2015 02:49 |
|
canis minor posted:My next favourite thing, after JS/Java, is - "Have you programmed in MVC? How many applications have you written in MVC?" The one i always annoy agents with are when the conversation goes like this they ask "can you write J2EE, - Yes 12 years now since J2EE 1.0" Have you ever used Java - Yes 12 years now since J2EE 1.0 and Java 1.4.2 So what about javac have you any experience in that? At that point i usually explode and explain that if you use J2EE that is just a special type of java object but you are still writing java code, and javac is the compiler for java. They then go "oh, right so anything to do with java you have done" - Yes - "and so that means you know Coldfusion then " - cue Explosion 2.. I hate recruiters who don't know their subject. TheresaJayne fucked around with this message at 11:28 on May 15, 2015 |
# ? May 15, 2015 06:50 |
|
TheresaJayne posted:Queue Explosion 2.. cue...
|
# ? May 15, 2015 09:41 |
|
Pavlov posted:Is numba any good? I feel like it's trying to do something to python that python just wasn't built to do. It's basically Julia but uses Python syntax and is a lot easier to use. It has plenty of room for improvement but it's already an awesome module if you're doing computational math or science
|
# ? May 15, 2015 10:39 |
|
"Convenient proxy factory bean superclass for proxy factory beans that create only singletons." Well duh, it's right there in the name.
|
# ? May 15, 2015 16:11 |
|
zergstain posted:I love how that will overflow if n is odd. It's like a turing machine. You can't return false. You either return true or loop forever.
|
# ? May 15, 2015 20:41 |
|
Dr. Stab posted:It's like a turing machine. You can't return false. You either return true or loop forever. Huh? TMs can reject, you're thinking of Turing-recognizable (as opposed to decidable) languages. And even those can reject, they're just not guaranteed to.
|
# ? May 15, 2015 21:16 |
|
http://stackoverflow.com/questions/30262509/union-object-acts-like-a-structure
|
# ? May 15, 2015 21:35 |
|
Programmers hate unions.
|
# ? May 15, 2015 22:45 |
|
Qwertycoatl posted:
whoa, why does this work
|
# ? May 15, 2015 22:47 |
|
return0 posted:whoa, why does this work It relies on integer overflow. If you repeatedly square an even number, it will become 0 mod 2^32. If you repeatedly square an odd number, it will become 1 mod 2^32. When one of those things happens, the for loop will terminate and the answer will come out.
|
# ? May 15, 2015 22:56 |
|
Qwertycoatl posted:It relies on integer overflow. If you repeatedly square an even number, it will become 0 mod 2^32. If you repeatedly square an odd number, it will become 1 mod 2^32. :O
|
# ? May 15, 2015 23:02 |
|
Qwertycoatl posted:It relies on integer overflow. If you repeatedly square an even number, it will become 0 mod 2^32. If you repeatedly square an odd number, it will become 1 mod 2^32. When one of those things happens, the for loop will terminate and the answer will come out. It also relies on re-evaluation of x in the conditional. Otherwise it'd report false for 2.
|
# ? May 15, 2015 23:13 |
|
Jsor posted:Huh? TMs can reject, you're thinking of Turing-recognizable (as opposed to decidable) languages. And even those can reject, they're just not guaranteed to. Languages don't reject or loop or really do anything. Also, TMs can be defined to have a reject state, but typically, in my experience, aren't.
|
# ? May 15, 2015 23:56 |
|
daft punk railroad posted:http://stackoverflow.com/questions/30262509/union-object-acts-like-a-structure Holy poo poo this is amazing. What would drive someone to do such a thing?
|
# ? May 16, 2015 00:38 |
|
Rejecting states are just all the states that aren't accepting states. If the machine halts and does not accept, that's rejection.
|
# ? May 16, 2015 00:40 |
|
sarehu posted:Rejecting states are just all the states that aren't accepting states. If the machine halts and does not accept, that's rejection. Yes Dr. Stab posted:Languages don't reject or loop or really do anything. Also, TMs can be defined to have a reject state, but typically, in my experience, aren't. "(Turing-)Decidable languages" is, by definition, languages that a Turing Machine can accept or reject in finite time. Above that is recognizable (or undecidable), which contains things like the accepting or halting problem which always accept in finite time if an answer exists, but may or may not halt if one doesn't exist. In the Theory of Computation, you frequently deal with Turing Machines that don't halt, Complexity Theory is basically all about Turing Machines that accept or reject in finite time. In fact, the "witness" definition of coNP* is usually defined in terms of rejection. * L is in coNP if L can be represented as { x | forall w, M(x,w) rejects } Linear Zoetrope fucked around with this message at 02:57 on May 16, 2015 |
# ? May 16, 2015 01:30 |
|
sarehu posted:Rejecting states are just all the states that aren't accepting states. If the machine halts and does not accept, that's rejection. Sorry, what definition are you using? I'm unaware of one which specifies halting in the transition function and not the state space. Typically, turing machines that reject have explicit reject states, and halt immediately upon entering such a state. The behaviour you're describing is more in line with how lower-order automata are defined, where they check which state they are in once they reach the end of input. Jsor posted:"(Turing-)Decidable languages" is, by definition, languages that a Turing Machine can accept or reject in finite time. Above that is undecidable, which contains things like the accepting or halting problem which always accept in finite time if an answer exists, but may or may not halt if one doesn't exist. I'm not saying that there don't exist turing machines that reject. It would be like if you showed me a space complexity result that relied on multi-tape turing machines to tell me that my assertion that turing machines typically have 1 tape is wrong. Dr. Stab fucked around with this message at 02:57 on May 16, 2015 |
# ? May 16, 2015 02:54 |
|
I suppose I concede that you could have a Turing Machine with no rejection, but we usually talk about TMs in relation to decision problems, which specify determining the truth or falsity of a statement. Indeed, Turing's original paper was all about applying the automatic machine to the Entscheidungsproblem. I'd say the vast majority of the time, TMs reject, but I'll agree that it's not strictly necessary if you were solving an optimization problem.
|
# ? May 16, 2015 03:06 |
Qwertycoatl posted:
Qwertycoatl posted:It relies on integer overflow. If you repeatedly square an even number, it will become 0 mod 2^32. If you repeatedly square an odd number, it will become 1 mod 2^32. When one of those things happens, the for loop will terminate and the answer will come out. I'm still a little surprised that it works for every number less than 2^32 (although it does--I checked). The loop terminates whenever i>=x, and some numbers wrap around a bunch of times. What's to say that an even x never wraps around to a number greater than 1 but less than i?
|
|
# ? May 16, 2015 03:41 |
|
VikingofRock posted:I'm still a little surprised that it works for every number less than 2^32 (although it does--I checked). The loop terminates whenever i>=x, and some numbers wrap around a bunch of times. What's to say that an even x never wraps around to a number greater than 1 but less than i? Because every time you square a number, you're doubling the zeros at the end of the number. Like, if you take 10 and square it, the result is 100. 100 squared is 10000. So, if you start with a number ending in 0 and square it and it wraps around, the result is either 0 or greater than 3. But, if i is greater than 3, then that means that you've done at least 5 multiplications, in which case the number would have to have at least 32 trailing zeroes.
|
# ? May 16, 2015 03:54 |
|
VikingofRock posted:I'm still a little surprised that it works for every number less than 2^32 (although it does--I checked). The loop terminates whenever i>=x, and some numbers wrap around a bunch of times. What's to say that an even x never wraps around to a number greater than 1 but less than i? Unsigned multiplication can never result in a number less than the product of the lowest bits in each number unless it overflows to zero. If x starts off non-zero but even, the value of its lowest bit grows super-exponentially (x2i). Meanwhile i grows linearly. There's a similar interesting thing that happens when squaring odd numbers; consider the expansion of (a*2k+1)2.
|
# ? May 16, 2015 04:02 |
Ah okay, I'm happy with those explanations. Thanks guys!
|
|
# ? May 16, 2015 04:56 |
|
php:<? foreach($cite as $site){ $length = strpos($cite[$i], "</cite>"); $positions[$i] = substr($cite[$i], 0, $length); $post[$i] = strip_tags($positions[$i]); if(strpos($post[$i],$domain) !== false){ $link = $i; break; } $i++; } // Provide More Information to the User $overall = $link-1; $number = ($link/10)+1; $number = floor($number); $math = strlen($link); $result = substr($link, $math-1, 1); $encoded = base64_encode($information); $filename = substr($encoded, 0, 5); $file = "demos/".$filename.".txt"; file_put_contents($file, $encoded); if($overall == -1){ $number = 0; $result = 0; } ?>
|
# ? May 16, 2015 10:22 |
|
Munkeymon posted:Try that with 2147483648 (231) in JS. code:
code:
Edit: But now I can fix my even test! code:
HappyHippo fucked around with this message at 15:53 on May 16, 2015 |
# ? May 16, 2015 15:29 |
|
Vanadium posted:Programmers hate unions. Is that why most of them are single? .. or virgins ... or both
|
# ? May 18, 2015 07:26 |
|
TheresaJayne posted:Is that why most of them are single? .. or virgins ... or both also because gently caress workers rights amirite
|
# ? May 18, 2015 09:07 |
|
php:<? if (-- some long conditional here -- && false) { ... bunch of poo poo ... exit(0); } ?>
|
# ? May 18, 2015 14:52 |
|
IT BEGINS posted:
To be fair the conditional should evaluate. It's just the result will always be false right? PHP doesn't optimize out the rest I hope.
|
# ? May 18, 2015 15:29 |
|
Hughlander posted:To be fair the conditional should evaluate. It's just the result will always be false right? PHP doesn't optimize out the rest I hope. Yeah, this thing is equivalent to if (false) . If the stuff in the conditional executed something that would be fine, but this is all just one big lovely if nothing.
|
# ? May 18, 2015 16:26 |
|
IT BEGINS posted:Yeah, this thing is equivalent to if (false) . If the stuff in the conditional executed something that would be fine, but this is all just one big lovely if nothing. Err... PHP does not magic away the stuff before the && false... http://sandbox.onlinephpfunctions.com/code/4722935a6f2853756b11b31b2b60676f098d2492
|
# ? May 18, 2015 16:38 |
|
Yes, I know. I'm just saying that there's nothing in there in this particular case that does anything, just straight == comparisons between variables.
|
# ? May 18, 2015 16:40 |
|
IT BEGINS posted:Yes, I know. I'm just saying that there's nothing in there in this particular case that does anything, just straight == comparisons between variables. Gotcha.
|
# ? May 18, 2015 17:12 |
|
This was written this year. Why would you build a string in SQL then execute the string in a stored procedure? code:
|
# ? May 18, 2015 18:37 |
|
|
# ? May 23, 2024 09:34 |
|
That's pretty standard fare in enterprise apps, I frequently see that inside a gigantic SQL call instead of a stored proc though. I call it commodity coding.
|
# ? May 19, 2015 01:42 |