Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
"""
Copyright (c) 2009 Simeon Franklin
MIT Licensed: see http://www.opensource.org/licenses/mit-license.php
pydelatt.py - Strips attachments from maildir format mail
files. Sample usage:
$ find ./Maildir -mtime +120 -size +3M | xargs -ix pydelatt.py -v 'x'
>>> def outer():
... x = 1
... def inner():
... print x
... return inner # inner hasn't run yet
>>> f = outer() # f is inner now, but no print statement has run
>>> f()
1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simeonf
simeonf / pex.md
Last active July 5, 2024 06:19
Creating a PEX from a python script

So you want to create a pex that packages your script and its dependencies?

Ok - first to make our script! Call it foo.py:

import requests

if __name__ == '__main__':
  req = requests.get("https://raw.githubusercontent.com/pantsbuild/pex/master/README.rst")
  print req.text.split("\n")[0]
@simeonf
simeonf / snippet.py
Created May 9, 2016 18:08
First cell in my IPython Notebook to add hidden cells with a "Show" button.
# hideme
import IPython.core.display as di
di.display_html("""<script>$(function() {
$("div.code_cell:contains('hideme')").hide();
$("div.code_cell:contains('showme')").hide();
$(".showme").remove();
$("div.code_cell:contains('showme')").before('<button class="showme">Show Answer</button>');
$(".showme").click(function(){$(this).next().show();});
"""
Open a .csv of article listings and print a .csv of article listings including url.
Sample .csv content:
"Slain with Ax and Pistol", San Francisco Call, May 28, 1896, 1.
Sample run:
$ python3 article.py article.csv