Skip to content

Instantly share code, notes, and snippets.

View mrkschan's full-sized avatar
😀

KS Chan mrkschan

😀
View GitHub Profile
@mrkschan
mrkschan / gist:1223583
Created September 17, 2011 03:07
Sample Amazon SES bounce notification (Email sent from CiviMail)
Delivered-To: [email protected]
Received: by 10.220.159.20 with SMTP id h20cs25679vcx;
Fri, 16 Sep 2011 03:52:22 -0700 (PDT)
Received: by 10.52.174.84 with SMTP id bq20mr613772vdc.3.1316170342554;
Fri, 16 Sep 2011 03:52:22 -0700 (PDT)
Return-Path: <>
Received: from a192-92.smtp-out.amazonses.com (a192-92.smtp-out.amazonses.com [199.255.192.92])
by mx.google.com with ESMTP id r8si2177380vcv.204.2011.09.16.03.52.22;
Fri, 16 Sep 2011 03:52:22 -0700 (PDT)
Received-SPF: pass (google.com: best guess record for domain of a192-92.smtp-out.amazonses.com designates 199.255.192.92 as permitted sender) client-ip=199.255.192.92;
@mrkschan
mrkschan / gist:1223622
Created September 17, 2011 04:23
originally a forum post to CiviCRM, but the forum keeps saying ... "Sorry, you are not allowed to post external links.". WTF.
[b]NOTE: This is not a perfect solution and I just checked the bounce case for non-existing email address.[/b]
Dude, here is a workaround to let CiviCRM uses Amazon SES . A patch can be found here -
[url]https://gist.github.com/1223565[/url]. Let me explain the intention of the patch first.
Amazon SES has a set of restricted email headers
(see [url]http://docs.amazonwebservices.com/ses/2010-12-01/DeveloperGuide/index.html?AppendixHeaders.html[/url]),
thus the "Precedence" header has to be removed. And, Amazon SES may rewrite the envelope From, Bounces-To, and
Return-Path headers. As a result, the Return-Path header is no longer reliable for bounce checking in
EmailProcessor (see sample bounce notification from Amazon [url]https://gist.github.com/1223583[/url]).
@mrkschan
mrkschan / gist:1341335
Created November 5, 2011 09:52
Make ~/.bash_completion.d/ activated
# Put this snippets to .bash_rc :)
# enable bash completion in interactive shells
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# Include ~/.bash_completion.d/
BASH_COMPLETION_COMPAT_DIR=~/.bash_completion.d
. /etc/bash_completion
fi
@mrkschan
mrkschan / gist:1647409
Created January 20, 2012 13:39
Sample `git diff -p`
diff --git a/git_fix_whitespace.py b/git_fix_whitespace.py
index 39f6807..0c72f5f 100755
--- a/git_fix_whitespace.py
+++ b/git_fix_whitespace.py
@@ -15,7 +15,7 @@ def sanitize_line(line):
return line
-def sanitize_diff(git_diff):
+def sanitize_diff(git_diff, git_root):
@mrkschan
mrkschan / tz.sh
Created April 11, 2012 09:01
a shortcut program to convert timezone
#!/bin/bash
# Usage: tz.sh from-timezone to-timezone time
# Example: tz.sh America/Los_Angeles America/New_York '2000-01-01 00:01:02'
from=$1
to=$2
if [[ "$3" == "" ]]; then
time=`date -R`
else
time=$3
@mrkschan
mrkschan / urldecode.py
Created August 21, 2012 07:13
a shortcut program to decode URL
#!/usr/bin/env python
# Usage: urldecode.py url
import urllib
import sys
print urllib.unquote_plus(sys.argv[1])
@mrkschan
mrkschan / gist:3522031
Last active October 9, 2015 14:27
bash completion for git, with files and directory
#!bash
#
# Enable file/directory completion for git.
#
# bashref - http://is.gd/PHQRX1
# bashlib - http://code.google.com/p/bash-completion-lib/
have git && {
_git_completion()
{
@mrkschan
mrkschan / fakesmtp
Created October 3, 2012 09:22
A fake SMTP server (smtp-sink shortcut)
#!/usr/bin/env bash
sudo smtp-sink -R /tmp -u root -d "mail.%Y-%m-%dT%H%M." 127.0.0.1:25 1024
@mrkschan
mrkschan / gist:4077171
Created November 15, 2012 07:15
vim smartindent config for Python
" Smart indenting for Python
autocmd FileType python set smartindent
autocmd FileType python set cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python set tabstop=4
autocmd FileType python set shiftwidth=4
autocmd FileType python set expandtab
# Fuck off httplib2 reporting failed SSL cert verification.
import httplib2
import certifi
httplib2.CA_CERTS = certifi.where()