Skip to content

Instantly share code, notes, and snippets.

@omz
omz / turtle.py
Created December 30, 2012 17:04
turtle
# turtle.py
# Basic Turtle graphics module for Pythonista
#
# When run as a script, the classic Koch snowflake is drawn as a demo.
# The module can also be used interactively or from other scripts:
# >>> from turtle import *
# >>> right(30)
# >>> forward(100)
# ...
@omz
omz / Evernote Demo.py
Created February 27, 2013 15:08
Evernote Demo
# A simple Evernote API demo script that lists all notebooks in the user's
# account and creates a simple test note in the default notebook.
#
# Before running this sample, you must fill in your Evernote developer token!
#
# This sample is part of the Evernote SDK and has been modified slightly for
# Pythonista, to take advantage of the clipboard and PIL modules.
# If there is an image in the clipboard when the script is run, it is attached
# to the sample note.
This gist contains a workflow for Editorial, an app for writing plain text and markdown on iOS.
To import the workflow, copy the *entire* text of the gist, then open Editorial and create a new workflow.
------------ BEGIN WORKFLOW ------------
{
"actions" : [
{
@omz
omz / iTC Downloader.py
Created July 29, 2013 23:35
iTC Downloader
# -*- coding: utf-8 -*-
# iTC Sales Report Downloader
# When you run this for the first time, you'll need to enter your
# iTunes Connect login and vendor ID. You can find the vendor ID
# on the iTunes Connect website by navigating to "Sales and Trends";
# it's the number next to your name (top-left).
CURRENCY = 'EUR'
RESET_LOGIN = False # Set to True to remove login from keychain
@omz
omz / Map View Demo.py
Created July 28, 2015 21:36
Map View Demo.py
# coding: utf-8
'''
NOTE: This requires the latest beta of Pythonista 1.6 (build 160022)
Demo of a custom ui.View subclass that embeds a native map view using MapKit (via objc_util). Tap and hold the map to drop a pin.
The MapView class is designed to be reusable, but it doesn't implement *everything* you might need. I hope that the existing methods give you a basic idea of how to add new capabilities though. For reference, here's Apple's documentation about the underlying MKMapView class: http://developer.apple.com/library/ios/documentation/MapKit/reference/MKMapView_Class/index.html
If you make any changes to the OMMapViewDelegate class, you need to restart the app. Because this requires creating a new Objective-C class, the code can basically only run once per session (it's not safe to delete an Objective-C class at runtime as long as instances of the class potentially exist).
'''
@omz
omz / install_xmlrpclib.py
Created November 15, 2012 01:41
install_xmlrpclib
# install missing xmlrpclib module
import requests
r = requests.get('http://hg.python.org/cpython/raw-file/7db2a27c07be/Lib/xmlrpclib.py')
with open('xmlrpclib.py', 'w') as f:
f.write(r.text)
This gist contains a workflow for Editorial, an app for
writing plain text and markdown on iOS.
To import the workflow, copy the *entire* text of the gist,
then open Editorial and create a new workflow.
------------ BEGIN WORKFLOW ------------
{
"actions" : [
{
@omz
omz / Evernote Installer.py
Created February 27, 2013 15:07
Evernote Installer
# Simple installer script for using the Evernote SDK in Pythonista
#
# This script should be run from the root directory. In order to keep things
# tidy, it installs the module and all its dependencies in a directory named
# 'evernote-sdk'. In order to be able to import it, you have to add that to
# your import path, like this:
#
# import sys
# sys.path.append('evernote-sdk')
#
@omz
omz / ShowLastPhotoMap.py
Last active March 21, 2019 16:04
ShowLastPhotoMap
# Shows the location of the last photo in the canera roll in the Maps app.
# (thanks to @HyShai for pointing out that the latitude/longitude refs are necessary)
import photos
import webbrowser
meta = photos.get_metadata(-1)
gps = meta.get('{GPS}')
if gps:
latitude = str(gps.get('Latitude', 0.0)) + gps.get('LatitudeRef', '')
@omz
omz / ImageMail.py
Created November 14, 2012 17:43
ImageMail
# Example for sending an email with an attached image using smtplib
#
# IMPORTANT: You need to enter your email login in the main() function.
# The example is prepared for GMail, but other providers
# should be possible by changing the mail server.
import smtplib
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email import encoders