Skip to content

Instantly share code, notes, and snippets.

@hiilppp
hiilppp / redirect_to_pythonista.html
Created January 4, 2014 14:23
HTML file that opens Pythonista, where a specified script is executed, while the browser window closes in the background. This serves as workaround for IFTTT's lack of support for custom URL schemes in the URL parameter of Pushover's Channel.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; pythonista://foo.py&action=run&argv=bar"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script language="JavaScript">
setTimeout("self.close()", 500);
</script>
</head>
@hiilppp
hiilppp / list.py
Created December 10, 2013 01:11
Python script to manipulate text in Pythonista in the following manner and send the result (back) to Drafts: Sort lines, remove blank and duplicate lines, and prepend a hyphen to lines which don't start with one.
# To call script from Drafts, use the follwing URL as URL Action:
# <pythonista://list.py?action=run&argv=[[draft]]>
import os
import re
import sys
import urllib
import webbrowser
a = re.sub(r"(?m)^[*-] ", "", sys.argv[1])
@hiilppp
hiilppp / calculate.py
Created December 6, 2013 11:42
Python script to calculate arithmetic expressions in Pythonista and send them, along with their results, (back) to Drafts.
# To call script from Drafts, use the follwing URL as URL Action:
# <pythonista://calculate.py?action=run&argv=[[draft]]>
# Except for the last ten lines, this script was written by Erez Shinan, see <http://erezsh.wordpress.com/2013/02/24/how-to-write-a-calculator-in-70-python-lines-by-writing-a-recursive-descent-parser/>.
'''A Calculator Implemented With A Top-Down, Recursive-Descent Parser'''
# Author: Erez Shinan, Dec 2012
import re, collections, sys
from operator import add,sub,mul,div
@hiilppp
hiilppp / sort.py
Last active February 8, 2019 13:02
Python script to sort lines of text in Pythonista and send them (back) to Drafts.
# To call script from Drafts, use the follwing URL as URL Action:
# <pythonista://sort?action=run&argv=[[draft]]>
import sys
import urllib
import webbrowser
a = sys.argv[1].split("\n")
a.sort(key=str.lower)
a = "\n".join(a)