Skip to content

Instantly share code, notes, and snippets.

@omz
omz / FileBrowser.py
Created November 10, 2012 17:25
FileBrowser
import SimpleHTTPServer
import SocketServer
import webbrowser
import os
os.chdir('/')
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", 0), Handler)
port = httpd.server_address[1]
webbrowser.open('http://localhost:' + str(port), stop_when_done=True)
httpd.serve_forever()
@omz
omz / MultiScene.py
Created November 12, 2012 12:18
MultiScene
# Quick-and-dirty demo of how to run multiple scenes
# in Pythonista; The MultiScene class is basically a
# wrapper for another scene and forwards all events
# to the currently-active scene, which can be changed
# with the switch_scene method.
#
# In this example, the first scene simply draws a red
# background and switches to the second scene when a
# touch is detected. The second scene draws a green
# background and plays a beep sound on touch.
@omz
omz / Shell.py
Created November 13, 2012 16:13
Shell
# Based on https://gist.github.com/4063716
#
# Provides a simple shell with basic
# commands for dealing with files and
# directories.
#
# This script will try and prevent
# unsafe file operations outside of
# Documents directory.
#
@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
@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)
@omz
omz / New from Gist.py
Created November 15, 2012 04:52
New from Gist
### Based on: https://gist.github.com/b0644f5ed1d94bd32805
### This version strips unicode characters from the downloaded script
### to work around the currently limited unicode support of the editor
### module.
# This script downloads and opens a Gist from a URL in the clipboard.
# It's meant to be put in the editor's actions menu.
#
# It works with "raw" and "web" gist URLs, but not with gists that
# contain multiple files or non-Python files.
@omz
omz / Untitled 1.py
Created November 30, 2012 17:34
Untitled 1
#coding: utf-8
# Original script by Federico Viticci:
# http://www.macstories.net/reviews/fantastical-for-iphone-review/
# Modified to work better with international characters
import webbrowser
import clipboard
import urllib
import console
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 / Add from Gist.wkflw
Created December 16, 2012 04:25
Imports a workflow or script from a Gist URL in the clipboard into the commands menu.
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 / 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)
# ...