Skip to content

Instantly share code, notes, and snippets.

View sherbondy's full-sized avatar

Ethan Sherbondy sherbondy

View GitHub Profile
class post():
def __init__(self, id, url, date, caption, link_url,
photo1280, photo500, photo250, tag):
self.id = id
self.url = url
self.date = date
self.caption = caption
self.link_url = link_url
self.photo1280 = photo1280
self.photo500 = photo500
import os, re
from datetime import datetime
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import urlfetch
from django.utils import simplejson as json
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 507, in __call__
handler.get(*groups)
File "/Users/ethan/Pyapps/GAE/tooepic/main.py", line 152, in get
tumblr_object = load_tumblr("tehome")
File "/Users/ethan/Pyapps/GAE/tooepic/main.py", line 70, in load_tumblr
js_object = json.loads(content)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django/django/utils/simplejson/__init__.py", line 232, in loads
return cls(encoding=encoding, **kw).decode(s)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django/django/utils/simplejson/decoder.py", line 251, in decode
def load_tumblr(user, tries=2):
url = "http://" + user + ".tumblr.com/api/read/json?type=photo&num=20&tagged=project"
try:
result = urlfetch.fetch(url)
""" tumblr outputs the json as a javascript var, so we have to remove
junk at the beginning and the semicolon at the end."""
content = result.content.replace("var tumblr_api_read = ", "")
content = content[:-2]
// the @media stuff is for viewers on mobile devices
html {
overflow: hidden;
}
@media only screen and (max-device-width:480px) {
html {
overflow: auto;
}
tree = ET.fromstring(result.content)
redirect_url = tree.findtext("redirect-url")
self.redirect(redirect_url)
<html>
<head>
<title>A CSS Hack, For Neven</title>
<style type="text/css">
/* Have one of these for each author on your tumblelog. */
.tooepic:after {content:"Ethan Sherbondy";}
.john-appleseed:after {content:"John Appleseed";}
/* fallback only displays if css is disabled */
<html>
<head>
<title>A Javascript Hack, For Neven</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
</head>
<body>
{block:Posts}
<p>A post.</p>
from google.appengine.ext import db
q = db.GqlQuery("SELECT __key__ FROM College")
db.delete(q)
@sherbondy
sherbondy / gist:301194
Created February 11, 2010 03:49 — forked from anonymous/gist:301125
load db
appcfg.py upload_data --config_file=college_loader.py --filename=college_list.csv --kind=College --has_header --url=http://localhost:8083/remote_api /Users/ethan/Pyapps/GAE/in-yet