This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (* | |
| Copyright (c) 2013, Richard Emile Sarkis <[email protected]> | |
| All rights reserved. | |
| Redistribution and use in source and binary forms, with or without | |
| modification, are permitted provided that the following conditions are met: | |
| 1. Redistributions of source code must retain the above copyright notice, this | |
| list of conditions and the following disclaimer. | |
| 2. Redistributions in binary form must reproduce the above copyright notice, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Quick 2-liner that sets a mail log to check, searches the log for a postfix-style mail ID (in field #6) | |
| # then uses xargs to grep that same log again to pull out all instances of that mail ID. | |
| # A great way to get context on how a particular mail log entry is behaving if you don't know its mail ID or if there are | |
| # multiple IDs to content with, but one easily searchable attribute (like a from or to address) | |
| # Warning: not intended to be scalable for very large mail logs! | |
| MAILFILE="/var/log/mail.log" | |
| grep -i "from=<[email protected]>" ${MAILFILE} | grep -v "NOQUEUE" | awk '{ print $6 }' | sed 's/://g' | xargs -I % grep % ${MAILFILE} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| if sys.version_info.major != 3 or sys.version_info.minor < 3: | |
| print("This module requires Python version 3.3 or later") | |
| sys.exit(1) | |
| import argparse | |
| import inspect | |
| class Argumentor: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pygmentize -O style=solarizeddark,fontface="Source Code Pro for Powerline:45" -l python -f rtf | pbcopy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!env python | |
| import smtplib | |
| import getpass | |
| server = smtplib.SMTP('localhost', 25) | |
| server.set_debuglevel(1) | |
| server.ehlo() | |
| server.starttls() | |
| server.ehlo() | |
| usernm = raw_input("*** Username: ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff -rupN a/MoinMoin/auth/ldap_login.py b/MoinMoin/auth/ldap_login.py | |
| --- a/MoinMoin/auth/ldap_login.py 2013-10-16 15:46:01.000000000 -0400 | |
| +++ b/MoinMoin/auth/ldap_login.py 2014-02-06 14:40:32.526635988 -0500 | |
| @@ -41,26 +41,18 @@ class LDAPAuth(BaseAuth): | |
| name = 'ldap' | |
| def __init__(self, | |
| - server_uri='ldap://localhost', # ldap / active directory server URI | |
| - # use ldaps://server:636 url for ldaps, | |
| - # use ldap://server for ldap without tls (and set start_tls to 0), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Change {0,0} to pick the relative date range to search, i.e. {3,5} searches 3-5 days ago. | |
| # Change <hostname> to be the base name used in naming your Maildir files | |
| for i in {0..0}; do find . -name \*<hostname>\* -mtime $i -exec grep -m1 -Hi "^Subject:" {} \; ; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re,collections | |
| def sort_naturally(l): | |
| """ Sort the given list in the way that humans expect. | |
| """ | |
| convert = lambda text: int(text) if text.isdigit() else text | |
| alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key[0])] | |
| l.sort( key=alphanum_key ) | |
| return l | |
| collections.OrderedDict(sort_naturally(a_dict.items())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -x | |
| trap read debug | |
| < YOUR CODE HERE > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cd { | |
| if [ -f "$1" ]; then | |
| # Sometimes I drag-n-drop files onto the terminal because it's easy | |
| # so I can 'cd <filename>' and have it cd to the parent directory of that file | |
| builtin cd "`dirname \"$1\"`" | |
| elif [ $# == 0 ]; then | |
| # If a virtualenv is activated then a no-parameter 'cd' will take you | |
| # to the virtualenv root. | |
| if [ -n $VIRTUAL_ENV ]; then | |
| builtin cd $VIRTUAL_ENV |