Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Just for fun, I decided to throw some functional programming into this: local fun add chars xs = foldl (fn (y,b) => (map (fn x => x^y) xs) @ b) [] chars fun perm' chars length acc n = if n > length then acc else perm' chars length (add chars acc) (n+1) in fun perm chars length = perm' (map str chars) length [""] 1 end That's the permutation function implemented in SML. I like this one better. It's more beautiful.
  2. What do you mean? You just need to escape the one you're using to delimit your string.
  3. If you want to generate all of them, you could do like this: <?php function permute($length, array $chars, array $acc = array(''), $n = 1) { if ($n > $length) { return $acc; } $a2 = array(); foreach ($chars as $c) { foreach ($acc as $s) { $a2[] = $c.$s; } } return permute($length, $chars, $a2, ++$n); } $chars = array_merge(range('a','z'),array_merge(range('A','Z'),range('0','9'))); print_r(permute(6, $chars)); It can without doubt be improved, but it was quick to write Edit: That will be all the strings, you would still have to MD5 them.
  4. PHP doesn't care how large your database is. For all it cares, it could have 1 or Googolplex (10^(10^100)) records. Are you sure it would matter? A DBMS would also be really slow without an index, and to be honest, creating an index for this would be stupid and pointless.
  5. Yeah, sorry, tera of course. Not giga. Oh yeah, and if it actually was 377,149,515,625,000,000,000 you would need 327 EiB of storage. That would be one hell of a RAID setup.
  6. How did you get that number? You have 26*2+10=62 different characters. Given that your string is always 6 characters long, the number of permutations with repeats is 62^6 = 56,800,235,584. Still a large number, but pretty much smaller than 377,149,515,625,000,000,000. At 32 B per MD5 hash, that's about 1.6 GiB assuming you're storing them consecutively with no form of separation. Am I missing something? Edit: @mikesta707: Your algorithm has a worst case running time of O(∞).
  7. You might be able to recover it if you still have the binlogs. Don't count on anything though.
  8. Hmm... Indeed the MX records are correct: daniel@daniel-laptop:~$ dig jobjar.co.uk MX ; <<>> DiG 9.6.1-P1 <<>> jobjar.co.uk MX ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48180 ;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;jobjar.co.uk. IN MX ;; ANSWER SECTION: jobjar.co.uk. 14400 IN MX 30 aspmx4.googlemail.com. jobjar.co.uk. 14400 IN MX 30 aspmx5.googlemail.com. jobjar.co.uk. 14400 IN MX 10 aspmx.l.google.com. jobjar.co.uk. 14400 IN MX 20 alt1.aspmx.l.google.com. jobjar.co.uk. 14400 IN MX 20 alt2.aspmx.l.google.com. jobjar.co.uk. 14400 IN MX 30 aspmx2.googlemail.com. jobjar.co.uk. 14400 IN MX 30 aspmx3.googlemail.com. ;; Query time: 146 msec ;; SERVER: 208.67.222.222#53(208.67.222.222) ;; WHEN: Thu Nov 5 19:47:11 2009 ;; MSG SIZE rcvd: 209 daniel@daniel-laptop:~$ I'm not sure why it wouldn't work.
  9. Well, the basic idea would be to have an infinite loop running that keeps listening for incoming connections. Each time someone connects, you fork an additional process allowing the client to do whatever your client supposed to do. Then just you exit the forked process when the client is done. I would just drop the entire "multiple ports" thing altogether.
  10. The typical solution those kind of locking problems would be concurrency/multithreading. PHP supports process forking using pcntl_fork. It only works on Unix based systems, which might be a problem for you.
  11. It seems to be working quite fine for virtually all other services...
  12. Have you considered that there are actually people who have kids as well? So now we have food, clothes and toys for the kids. Considering you're working 12 hours per day, those children also need somewhere to stay after school and until you get home if they're not very old yet. I don't know about the US, but here that would easily be an extra $300/month/child for some sort of after school care. Let's not forget that more people requires more electricity, water and space. And then we are still assuming that you are working a ridiculous amount of 12 hours per day every day. Now if we say that you work 8 hours per day and there are 30 days in a month and you actually have weekends, that would be 7.25*8*22=1276 before tax, and if tax is 15% then you're down to $1085.
  13. That's not a very good regular expression for matching phone numbers though. -.........234-.-.23.-.-23-.4-.2-.34 would be a valid phone number according to that regex.
  14. What's the domain name called? You can use dig (available in most Linux distributions) to find the DNS records for a domain name. Example for phpfreaks.com: daniel@daniel-laptop:~$ dig phpfreaks.com MX ; <<>> DiG 9.6.1-P1 <<>> phpfreaks.com MX ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11949 ;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;phpfreaks.com. IN MX ;; ANSWER SECTION: phpfreaks.com. 120 IN MX 30 ASPMX2.GOOGLEMAIL.com. phpfreaks.com. 120 IN MX 30 ASPMX5.GOOGLEMAIL.com. phpfreaks.com. 120 IN MX 30 ASPMX4.GOOGLEMAIL.com. phpfreaks.com. 120 IN MX 20 ALT2.ASPMX.L.GOOGLE.com. phpfreaks.com. 120 IN MX 20 ALT1.ASPMX.L.GOOGLE.com. phpfreaks.com. 1 IN MX 10 ASPMX.L.GOOGLE.com. phpfreaks.com. 120 IN MX 30 ASPMX3.GOOGLEMAIL.com. ;; Query time: 134 msec ;; SERVER: 208.67.222.222#53(208.67.222.222) ;; WHEN: Thu Nov 5 12:26:24 2009 ;; MSG SIZE rcvd: 207 daniel@daniel-laptop:~$ I really don't know how you would change DNS with your host/registrar though. It would be better to ask them.
  15. It's \n though, not /n.
  16. PHP outputs things exactly as you tell it to. If you want newlines, HTML line breaks, tab characters, etc. you'll have to add it yourself. If you said 'output "foo" then output "bar"', it would be incorrect if it output "foo\nbar", "foo<br />bar", "foo<br>bar" or anything different from "foobar".
  17. It's not HTML that resets the form, it's your browser that resets it. An INPUT or BUTTON element with type="reset" is per definition supposed make the browser reset all form fields in that form to the default state they were in when the page loaded. Submitting a form is different. You can easily submit the form (again, it's your browser that does this, not HTML) to any page, but unless there is something to handle it on the other end, the stuff you wrote in the form has no meaning. HTML is what you call a markup language. It's just describing what your content is, not what anyone is supposed to do with it.
  18. That's because they're manuals. A manual is just supposed to tell you how something works. You don't learn how to fly by reading a plane's manual either. Maybe if you're already really good at flying you can pick up how to fly that particular plane using its manual, but with little or no experience flying that's not going to happen. If you want to learn how to program, read a book.
  19. Did you check that it's correct according to your DNS server? Google Apps won't keep checking if your MX records are correct. Once they're correct once it assumes that you don't screw it up. I have got a couple of domains on Google Apps that I once set up MX records for. They're not configured right now, but Google Apps doesn't care anyways. It still says it's active.
  20. Why can't you just upload only the changed files?
  21. Have a look at these: http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml http://themoneyconverter.com/USD/rss.xml http://feeds.currencysource.com/USD.xml You could easily parse them to get exchange rates.
  22. More generally, AND takes higher precedence than OR. This means that the two following statements are equivalent: a OR b AND c a OR (b AND c) Both of them are also left associative (that means they're evaluated from left to right), which means that when you write: variableA = 1 OR variableA = 2 AND variableB = Z AND variableC = N OR variableC = M The implicit parentheses are like this: (variableA = 1 OR ((variableA = 2 AND variableB = Z) AND variableC = N)) OR variableC = M
  23. We would encourage everybody to introduce themselves here so we might get to know you and "old" members are very welcome to introduce themselves as well.
  24. I've got a VPS. A dedicated server would be overkill for my needs.
  25. That's quite a surprise to me. As I said, it is something I would expect from any web host. Then again, I've never purchased shared hosting.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.