Skip to content

Instantly share code, notes, and snippets.

Chris Adams acdha

Block or report user

Report or block acdha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@acdha
acdha / send_mail_using_jndi.py
Created Jan 14, 2009
Jython example which uses JNDI to query DNS for MX hosts
View send_mail_using_jndi.py
sender = "Chris Adams <chris@improbable.org>"
recipients = [ "Chris Adams <chris@improbable.org>", ]
msg = "test message"
smtp = smtplib.SMTP()
# To avoid hard-coding our SMTP server list we'll query the
# MX records for yale.edu using the Java JNDI API:
from javax.naming.directory import InitialDirContext
jndi_ctx = InitialDirContext()
mx_hosts = jndi_ctx.getAttributes("dns:///example.edu", ["MX"]).get("MX")
View yui-nested-menu-demo.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>YUI Nested Menus</title>
<!-- YUI Configurator: http://developer.yahoo.com/yui/articles/hosting/?menu&yuiloader&MIN -->
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.6.0/build/base/base-min.css&amp;2.6.0/build/menu/assets/skins/sam/menu.css">
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.6.0/build/yahoo-dom-event/yahoo-dom-event.js&amp;2.6.0/build/container/container_core-min.js&amp;2.6.0/build/menu/menu-min.js"></script>
<script type="text/javascript" charset="utf-8">
@acdha
acdha / pam_ldap_bug366.patch
Created Mar 6, 2009
Changes pam_ldap to retrieve only the attributes it needs, avoiding things like jpegPhoto which can be huge. See http://bugzilla.padl.com/show_bug.cgi?id=366 and http://improbable.org/chris/index.php?ID=201
View pam_ldap_bug366.patch
--- ../libpam-ldap-180/pam_ldap.c 2008-04-17 10:26:14.000000000 -0400
+++ pam_ldap.c 2008-04-17 10:16:34.000000000 -0400
@@ -2484,6 +2484,19 @@
_get_user_info (pam_ldap_session_t * session, const char *user)
{
char filter[LDAP_FILT_MAXSIZ], escapedUser[LDAP_FILT_MAXSIZ];
+ char *test_attrs[] = {
+ "host",
+ "authorizedService",
+ "shadowExpire",
@acdha
acdha / pam_ldap_bug365.patch
Created Mar 6, 2009
Adds more informative syslog support to pam_ldap for troubleshooting - see http://bugzilla.padl.com/attachment.cgi?id=225 and http://improbable.org/chris/index.php?id=201 for details
View pam_ldap_bug365.patch
--- ../libpam-ldap-minimal/pam_ldap.c 2008-04-15 14:44:58.000000000 -0400
+++ pam_ldap.c 2008-04-02 18:40:02.000000000 -0400
@@ -1228,10 +1228,14 @@
int rc = ldapssl_client_init (session->conf->sslpath, NULL);
if (rc != LDAP_SUCCESS)
{
- syslog (LOG_ERR, "pam_ldap: ldapssl_client_init %s",
+ syslog (LOG_ERR, "pam_ldap: _open_session() failed with PAM_SERVICE_ERR: ldapssl_client_init failed: %s",
ldap_err2string (rc));
return PAM_SERVICE_ERR;
@acdha
acdha / rename-authors.sh
Created Mar 7, 2009
Renaming author history in git
View rename-authors.sh
#!/bin/sh
git filter-branch -d `mktemp -d -u -t git-filter` --env-filter \
'
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL;
GIT_AUTHOR_NAME=`echo $GIT_AUTHOR_NAME | sed -e "s/adamsc/Chris Adams/g"`;
GIT_AUTHOR_EMAIL=`echo $GIT_AUTHOR_EMAIL | sed -e "s/adamsc@.*/chris@improbable.org/g"`;
GIT_COMMITTER_NAME=`echo $GIT_COMMITTER_NAME | sed -e "s/adamsc/Chris Adams/g"`;
GIT_COMMITTER_EMAIL=`echo $GIT_COMMITTER_EMAIL | sed -e "s/adamsc@.*/chris@improbable.org/g"`;
' HEAD
View enable-vmware-timesync.sh
#!/bin/sh
vmware-guestd --cmd "vmx.set_option synctime 0 1"
vmware-guestd --cmd "vmx.set_option time.synchronize.tools.startup 0 1"
View delete-certificate.py
#!/usr/bin/env python2.5
import ctypes
Security = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/Security.framework/Versions/Current/Security')
class SecKeychainAttribute(ctypes.Structure):
_fields_ = [('tag', ctypes.c_char_p),
('length', ctypes.c_int32),
('data', ctypes.c_char_p)]
View Keychain.py
#!/usr/bin/env python
# encoding: utf-8
"""
Wrapper for the core Keychain API:
http://developer.apple.com/documentation/Security/Reference/keychainservices/Reference/reference.html#//apple_ref/doc/uid/TP30000898-CH1-SW1
Created by Chris Adams on 2009-01-06.
"""
@acdha
acdha / yui-multiformat-editor.html
Created Mar 16, 2009
Demonstration side-by-side HTML and plain-text editor using the YUI Rich Editor control
View yui-multiformat-editor.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Multi-Format Editor Example</title>
<!--
Normal:
http://developer.yahoo.com/yui/articles/hosting/?animation&base&button&container&editor&element&fonts&layout&logger&menu&reset&reset-fonts&resize&selector&tabview&MIN
@acdha
acdha / .python_startup
Created Mar 19, 2009
How to get tab-completion in Python on the default OS X install
View .python_startup
try:
import readline
except ImportError:
print "Module readline not available."
else:
import rlcompleter
readline.parse_and_bind("bind ^I rl_complete")
You can’t perform that action at this time.