Public Gists by kgaughan

Gravatar
Wed Nov 11 09:48:49 -0800 2009
1
2
3
#!/usr/bin/env python
#
# find-duplicates
Gravatar
Wed Sep 23 03:07:35 -0700 2009
1
2
3
import types
 
def flatten_dict(to_flatten, separator='_'):
Gravatar
Wed Apr 22 03:23:03 -0700 2009
1
2
3
<?php
class LogoutHandler extends AFK_HandlerBase {
 
Gravatar
Thu Mar 12 05:16:19 -0700 2009
1
2
3
import smtpd
import asyncore
 
Gravatar
Tue Feb 17 08:18:44 -0800 2009
1
2
3
<?php
function php_is_so_broken() {
    // Note: This appears to have been fixed somewhere in the 5.1 series,
Gravatar
Wed Jan 07 09:49:02 -0800 2009
1
2
3
<?php
/*
 * Two annoying omissions from PHP are the lack of array_all() and array_any(), which check if
Gravatar
Sat Dec 27 01:13:40 -0800 2008
1
2
3
from itertools import count
 
def sieve():
Gravatar
Thu Dec 18 12:06:44 -0800 2008
1
2
3
#!/usr/bin/env python
#
# pipedarg
Gravatar
Mon Dec 01 10:45:19 -0800 2008
1
2
3
if (!is_well_formed_email_address($email)) {
    echo "Email address is not well-formed.\n";
} else {
Gravatar
Mon Dec 01 10:31:53 -0800 2008
1
2
3
function is_valid_local_part($local) {
    // I'm not entirely sure about this regex, but it seems to fit was RFC2822 specifies.
    return preg_match("@^[-a-z0-9!#\$%&'*+/=?^_`{|}~]+(\.[-a-z0-9!#\$%&'*+/=?^_`{|}~]+)*\$@", $local);
Gravatar
Mon Dec 01 10:17:18 -0800 2008
1
2
3
function is_well_formed_hostname($host) {
    return preg_match('~^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z](?:[a-z0-9-]*[a-z0-9])$~', $host);
}
Gravatar
Mon Dec 01 09:43:00 -0800 2008
1
2
3
function can_host_receive_mail($host) {
    if (checkdnsrr($host, 'MX')) {
        return true;
Gravatar
Mon Dec 01 09:39:40 -0800 2008
1
~^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)*[a-z](?:[a-z0-9-]*[a-z0-9])$~