Skip to content

Instantly share code, notes, and snippets.

View cclauss's full-sized avatar

Christian Clauss cclauss

View GitHub Profile
@cclauss
cclauss / diagonal_line.py
Last active January 4, 2016 21:49
Use PIL to draw an image of a diagonal line and then make a Pythonista scene.Layer to display the image.
import Image, ImageDraw, scene
def diagonalLineImage(inLength = 200, inColors = ('blue', 'ivory')):
imageLength = inLength + 100 # the image can be larger than what you draw
theImage = Image.new('RGBA', (imageLength, imageLength), inColors[1])
draw = ImageDraw.Draw(theImage)
draw.line((0, 0, inLength, inLength), fill = inColors[0])
del draw
return theImage
@cclauss
cclauss / watch_pythonista_forum.py
Last active November 25, 2020 17:27
Learning how to use feedparser... recent_entries() will print out info on all posts to the Pythonista forum in the past 24 hours. watch_feed() will print out info on the last post to the Pythonista forum. Sleeps for 15 minutes then check to see if there is a newer post. If so, prints out info on it and opens its URL in the webbrowser. Repeat.
#!/usr/bin/env python
'''
recent_entries() will print out info on all posts to the Pythonista forum in the past 24 hours.
watch_feed() will print out info on the last post to the Pythonista forum.
Sleeps for 15 minutes then check to see if there is a newer post.
If so, prints out info on it and opens its URL in the webbrowser. Repeat.
'''
@cclauss
cclauss / CustomView.py
Created July 17, 2014 19:34
CustomView.py
# http://omz-forums.appspot.com/pythonista/post/5808662551461888
# change the draw() method below to draw your plot
# using the ui.Path drawing commands documented at
# http://omz-software.com/pythonista/docs/ios/ui.html#path
import ui
class PlotView(ui.View):
def __init__(self, parent = None):
self.frame = (0, 0, 255, 255)
import ui
filename = 'name.txt'
def read_username(filename=filename):
username = None
try:
with open(filename) as in_file:
for line in in_file.readlines():
username = line.strip() or username