Skip to content

Instantly share code, notes, and snippets.

View cclauss's full-sized avatar

Christian Clauss cclauss

View GitHub Profile
@cclauss
cclauss / imageCongaLine.py
Last active December 22, 2015 04:08
Conga line formed out of .png images inside Pythonista.app
# imageCongaLine.py
# A Conga line formed out of .png images inside Pythonista.app
import os, scene
imageWidth = 32
#print(os.getcwd())
os.chdir('../Pythonista.app') # Look at files inside the app
#print(os.listdir('.'))
@cclauss
cclauss / sounder.py
Last active December 26, 2021 18:33
Play each .caf sound inside of Pythonista.app
# sounder.py
# play each of the .caf sounds inside the Pythonista.app
import os, os.path, scene, sound
framesPerSound = 60
pythonistaDir = os.path.expanduser('~/Pythonista.app')
#print(os.listdir(pythonistaDir))
soundFileExtention = '.caf'
wallpaperAppIcon = ('/AppIcon76x76@2x~ipad.png', '/AppIcon60x60@2x.png')
@cclauss
cclauss / fontCongaLine.py
Last active December 22, 2015 21:19
Conga line formed out of all available fonts in Pythonista.
import scene, os
colorLightBlue = scene.Color(.3, .3, 1)
colorWhite = scene.Color( 1, 1, 1)
fontBlackList = ('AcademyEngraved', 'AppleColorEmoji@2x',
'ArialHB', 'Bodoni72', 'ChalkboardSE',
'CourierNew', 'DB_LCD_Temp-Black',
'EuphemiaCAS', 'Fallback', 'HoeflerText',
'LastResort', 'KGPW3UI', 'LockClock',
@cclauss
cclauss / gpsForPythonista.py
Last active December 23, 2015 04:19
The GPS issue was fixed quite elegantly with the **location module** added in Pythonista v1.4. The code below is not longer required for Pythonista. gpsForPythonista using BaseHTTPServer and XMLHttpRequest Thanks to 'Hvmhvm' of Pythonisa fourm for working code Thanks to 'Anton2' of Pythonisa fourm for XMLHttpRequest
# The GPS issue was fixed quite elegantly with the location module
# added in Pythonista v1.4. The code below is not longer required.
# gpsForPythonista using BaseHTTPServer and XMLHttpRequest
# Source at https://gist.github.com/cclauss/6578926
# Thanks to 'Hvmhvm' of Pythonisa fourm for working code
# Thanks to 'Anton2' of Pythonisa fourm for XMLHttpRequest
# http://omz-software.com/pythonista/forums/discussion/92/gps-access-solved
# usage: from gpsForPythonista import getGPS; print(getGPS())
@cclauss
cclauss / textFullScreen.py
Last active December 23, 2015 13:29
Display the clipboard text at full screen resolution... Show a message to your friends... Show the taxi driver your desired address... Have fun.
# Display the current clipboard text in full screen mode
import clipboard, console, scene
clipText = clipboard.get()
if not clipText:
clipText = """Hang up your cellphone and drive your car!!!"""
zclipText = """Please take me home..."""
class MyScene(scene.Scene):
def setup(self):
(imageName, imageSize) = self.getImageNameAndSize()
@cclauss
cclauss / soupFromURL.py
Last active December 23, 2015 14:29
Create a BeautifulSoup by reading in a webpage.
#!/usr/bin/env python
# create a BeautifulSoup by reading in a webpage
# Current varsion at https://gist.github.com/cclauss/6648735
# usage:
# from soupFromURL import soupFromURL
# theSoup = soupFromURL('http://www.python.org')
import bs4
useRequests = False # "Python HTTP: When in doubt, or when
try: # not in doubt, use Requests. Beautiful,
@cclauss
cclauss / listApp.py
Last active December 23, 2015 15:39
Simple app that read in a list from a file and allows the user add to, remove from, and view the list. viewList() is fairly redundant and could be removed.
# Current version at https://gist.github.com/cclauss/6656495
import console
addPrompt = """Item to be added to the list?
or [M] to return to the main menu:"""
removePrompt = """Item to be removed from the list?
or [M] to return to the main menu:"""
def writeListToFile(inFileName, inList):
@cclauss
cclauss / helloBarcode.py
Last active September 15, 2017 07:50
ZBar delivers barcode data to Pythonista.
# helloBarcode - ZBar delivers barcode data to Pythonista
programName = sys.argv[0].rpartition('/')[2]
theBarcode = sys.argv[1] if len(sys.argv) > 1 else None
fmt = '{} was launched with barcode: {}'
print(fmt.format(programName, theBarcode))
# Save this file in Pythonista as 'helloBarcode'.
# Download free app ZBar from the iTunes App Store.
# Launch ZBar on your device.
# Scan the barcode on a book, coke can, whatever.
@cclauss
cclauss / beazleyCodeDownload.py
Last active December 24, 2015 20:29
David Beazley is one of the best trainers on Python topics. This script downloads several code bases from David's website (http://www.dabeaz.com) to a local directory.
# beazleyCodeDownload.py
#
# copy source code from http://www.dabeaz.com
# into local directory David_Beazley
import bs4, os, requests
codeBases = ('coroutines', 'generators', 'pydata',
'python3io', 'usenix2009/concurrent')
baseURLFmt = 'http://www.dabeaz.com/{}/'
@cclauss
cclauss / backgroundSwap.py
Last active December 26, 2015 09:49
Create three background images in scene.setup() then in scene.draw() use the x coordinate of the user's drag location to determine which background image to display
'''
create three background images in scene.setup() then in
scene.draw() use the x coordinate of the user's drag
location to determine which background image to display
'''
import scene
from PIL import Image, ImageDraw, ImageFont
theMessage = 'Drag the grey circle left and right to switch between the background images.'