This file contains 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
# 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) |
This file contains 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
# 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 |
This file contains 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
# 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]) |
This file contains 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
<!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> |
This file contains 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
# -*- coding: utf-8 -*- | |
# To call script from Drafts, use the follwing URLs as URL Actions: | |
# - <pythonista://insert_location.py?action=run&argv=[[draft]]&argv=address> | |
# (Will insert the address of your current location.) | |
# - <pythonista://insert_location.py?action=run&argv=[[draft]]&argv=link> | |
# (Will insert a Google Maps link to your current location.) | |
import location | |
import re |
This file contains 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
#!/bin/sh | |
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump | grep -E "^[[:space:]]*bindings:.+[a-z]+[a-z0-9.+-]*:" | sed -E "s/^[[:space:]]*bindings:[[:space:]]+//" | sort -u |
This file contains 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 notification | |
from random import randint | |
import sys | |
import urllib | |
import webbrowser | |
reminders = ["Reminder A", ["Reminder B", "url://"], "Reminder C"] | |
n = randint(0, len(reminders)-1) | |
URL = "pythonista://random_reminders.py?action=run" |
This file contains 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
do shell script "defaults write com.apple.screensaver askForPassword 1; defaults write com.apple.screensaver askForPasswordDelay 0" | |
repeat until (do shell script "defaults read com.apple.screensaver askForPassword") = "1" and (do shell script "defaults read com.apple.screensaver askForPasswordDelay") = "0" | |
delay 0.5 | |
end repeat | |
tell application "ScreenSaverEngine" to activate | |
if application "iTunes" is running then | |
tell application "iTunes" |
This file contains 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
-- You need to create a Keychain item whose name matches what you use in place | |
-- of "[keychain_item_name]" on line #7 (and whose password is identical to your | |
-- user account's password). | |
tell application "System Events" | |
if ((get name of every process) contains "ScreenSaverEngine") then | |
set pw to (do shell script "security find-generic-password -l \"[keychain_item_name]\" -w") | |
tell application "ScreenSaverEngine" to quit | |
delay 0.5 | |
keystroke pw |
This file contains 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
on truncate(a, n) | |
set a_2 to paragraph 1 of a | |
set text_item_delimiters to text item delimiters | |
set text item delimiters to space | |
set a_2_text_items to text items of a_2 | |
set text item delimiters to text_item_delimiters | |
set NO_paragraphs_in_a to count paragraphs of a | |
if (count text items of a_2_text_items) > n then | |
set text_item_delimiters to text item delimiters | |
set text item delimiters to space |
OlderNewer