# Daniel0

Staff Alumni

11,885

1. ## how is a random number generated?

It isn't random. It's pseudorandom. Given the same seed, you'll always get the same number. PRNGs generate numbers that are difficult to predict without the seed so they look random.

1+i
3. ## What IDE/editor themes do you use?

This one for vim: https://github.com/tomasr/molokai
4. ## PHP 6(or 5.5) Wishlist

I'm not sure it's worth adding one more example in a new language. Any Turing-complete language will be able to express the Y combinator (though some prettier than others). LOL. I know what kind of face I'd be getting if I said that to my colleagues because I named all my functions y(\$x) x(\$y). Well, if you know what the Y combinator is, then you'll understand the naming convention of \$f and \$g. If you don't, giving them other names wouldn't help you at all
5. ## PHP 6(or 5.5) Wishlist

It's the Y combinator, so it's called "Y" on purpose. It computes the fixpoint in (untyped) λ-calculus. \$f and \$g are just functions, so they're properly named as well by standard mathematical conventions. Given to Y is a function that given a "partial" Fibonacci function returns a new function that can compute one more recursive step of the Fibonacci function, so to speak (that is, if it can compute f(n), then the new function can compute f(n+1)). The fixpoint of this function is the "full" Fibonacci function. The Y combinator allows you to express any recursive computation without using recursion.
6. ## PHP 6(or 5.5) Wishlist

Nah... a perfect script should stick as close to λ-calculus and functional programming as possible. For instance, clearly this is the most elegant way to print the first 10 Fibonacci numbers: <?php function Y(\$f) { \$ff = function(\$f) { return \$f(\$f); }; // PHP doesn't allow function call chaining return \$ff( function (\$g) use (\$f) { return \$f(function() use (\$g) { return call_user_func_array(\$g(\$g), func_get_args()); }); } ); } \$fib = Y(function(\$fib) { return function(\$n) use (\$fib) { return \$n === 0 ? 0 : (\$n === 1 ? 1 : \$fib(\$n-1) + \$fib(\$n-2)); }; }); function tabulate(\$n, \$f) { \$g = Y(function(\$a) use (\$n, \$f) { return function(\$l, \$m) use (\$n, \$a, \$f) { return \$n === \$m ? \$l : \$a(array_merge([\$f(\$m)], \$l), \$m + 1); }; }); return \$g([], 0); } \$disp = function(\$f, \$n) { printf("f(%d) = %d\n", \$n, \$f(\$n)); }; tabulate(10, function(\$n) use (\$fib, \$disp) { \$disp(\$fib, \$n); }); Output: f(0) = 0 f(1) = 1 f(2) = 1 f(3) = 2 f(4) = 3 f(5) = 5 f(6) = 8 f(7) = 13 f( = 21 f(9) = 34

Done.

You don't need to understand the first part of my post to become a PHP programmer. I only touched the tip of the iceberg. If you find it interesting and you'd like to learn about compiler theory, I would recommend you to read a book or take a course on compilers (the latter would likely include the former as well though). I'm a computer science student, so compiler and formal language theory are some of the subjects I deal with, but you don't need to become a computer scientist to become a web developer. I don't expect you to understand all of it at this point, but there should be enough keywords for you to research should you decide to look at it further. An understanding of the HTTP protocol is pretty essential if you want to become a web developer though, even if you at first only have a rudimentary understanding of it.

11. ## I Agree Button

Actually, speed is a factor on StackOverflow. If you're late to the party, your chance of getting many upvotes is diminished.
12. ## I Agree Button

Sure, it's always good getting multiple points of views on an issue.
13. ## I Agree Button

Hmm... but majority vote isn't necessarily a measure of quality or correctness. I'm not convinced that this is the solution. Hypothetical scenario: User A asks a question, user B responds with a half-decent answer and gets 5 votes for that. Now user C provides a much better answer (let's just for the sake of argument suppose that we by some objective standard can determine that). User A returns to his post and observes that user B has 5 votes and user C has 0, indicating that the answer provided by user B is better, contrary to reality. Now what?
14. ## signature change

I'm sure the person responsible will feel god's wrath and burn in hell.
15. ## Modified PHP fork based on PHP 5.3.6

Can't blame him. Whether your stuff gets implemented is dependent on that there is not some idiot on the top who vetos because it's against some stupid axiom he made for that special occasion. There may be a million votes for the proposol, and none against, but that doesn't matter if someone decides that his personal vision is more important than a community decision. That certainly does happen, but if you never even attempted to submit the patches, it's guaranteed that they won't be accepted. I was basing my rant on particular encounters with certain members of the PHP Group. I can't be bothered going into details, but as a result I ultimately decided that I no longer wanted to contribute. Of course there needs to be leadership, but there is a such thing as bad leadership.
16. ## Modified PHP fork based on PHP 5.3.6

Can't blame him. Whether your stuff gets implemented is dependent on that there is not some idiot on the top who vetos because it's against some stupid axiom he made for that special occasion. There may be a million votes for the proposol, and none against, but that doesn't matter if someone decides that his personal vision is more important than a community decision.
17. ## Best way to perform pentest

Sure it is. Just ask Sony
18. ## Using wget and cron

Right. Then just save the file to /dev/null

That's false though. The implication of this would be that noone could learn to understand recursion. You're like a real-life Sheldon, you know that right? right? Hmm... didn't catch that reference

That's false though. The implication of this would be that noone could learn to understand recursion.
21. ## Domain Masking and SSL Encryption

I'm not really sure I understand the (potential) attack vector you're worried about. Are you saying that requests made to resource A (no SSL) will result in a 301 response redirecting to resource B using SSL? You only have a security issue if the user makes a request with confidential information to resource A. Example 1: User sends a GET request to http://www.example.com/ and gets redirected to https://www.example.com/. User fills a form that submits via POST to https://www.example.com/login.php. This is no problem. The login credentials are protected by the SSL layer. Example 2: User sends a POST request to http://www.example.com/login.php with login information, and gets redirected to https://www.example.com/login.php submitting the same data via POST (note that RFC 2616 actually prohibits automatic redirection in this case, but no (or very few) browsers actually honors this). This is a problem, because the first time the information was transmitted, it was unencrypted. If none of those examples describe your scenario, try using a packet sniffer to look at what data is being transmitted when you make the requests.
22. ## Using wget and cron

0 * * * * wget "http://mysite.com/test-cron.php" -O /dev/null If it's on the same server, just run it directly though: 0 * * * * php /path/to/test-cron.php

The brawler gets a defence boost when on low health. Defence was the secondary stat to check when determining who goes first.