Skip to content

Instantly share code, notes, and snippets.

View maetl's full-sized avatar

Mark Rickerby maetl

View GitHub Profile
class Picture(db.Model):
name = db.StringProperty()
ext = db.StringProperty()
mime_type = db.StringProperty()
source = db.BlobProperty()
thumb = db.BlobProperty()
default = db.BlobProperty()
caption = db.StringProperty()
updated_at = db.DateTimeProperty()
class ApiHandler(webapp.RequestHandler):
def check_uploaded_picture(self):
if not self.check_api_key():
self.error_response(401, API_ERROR_UNAUTHORIZED)
return False
if not self.request.get('picture'):
self.error_response(400, API_ERROR_MISSING)
return False
class PictureResource(ApiHandler):
def post(self, name, ext):
if not self.check_uploaded_picture():
return
picture = Picture.find(name, ext)
if not picture:
picture = Picture()
# 1.8.7 only (boo fucking hoo)
return key.shuffle!.to_s
key = key.sort_by { rand }
return key.to_s
<?php
/**
* Checks if the field is a valid email address according to RFC 2822
*
* @package repository
* @subpackage rules
*/
class ComplexEmailRule extends ValidationRule {
<div class="element element-input">
<label for="element_input">element-input</label>
<input type="text" name="element_input">
<span class="element-help">This is a short help drescription...</span>
</div>
#
# w00t!
# thanks to @pamelafox
# http://google-wave-resources.googlecode.com/svn/trunk/samples/apps/inboxchecker/oauth.py
#
import wsgiref.handlers
import logging
import pickle
import uuid
@maetl
maetl / CABLEGATE - MASTERCARD SCANDAL
Created December 9, 2010 04:33
A 'Lonely Planet' blurb about Turkey's ethnic groups causes a public relations scandal for MasterCard.
FROM: ISTANBUL, TURKEY
TO: STATE DEPARTMENT
DATE: JUNE 1, 2005
CLASSIFICATION: CONFIDENTIAL
SEE FULL CABLE
After briefly basking in the reflected glow of last week's exciting UEFA Champion's League Final in Istanbul between Milan and Liverpool, corporate sponsor Mastercard has found itself dealing with a public relations nightmare in recent days following public criticism of inclusion in its match city guide of critical commentary about both Turkey and its revered founder, Mustafa Kemal Ataturk. The offending passages, first publicized in the liberal Islamist daily "Zaman," addressed the issue of Turkish-Kurdish relations and the Armenian tragedy of 1915. Mastercard briefly closed its office following death threats against its General Manager, and has since officially apologized, noting that the offending material had not been reviewed by any company officials, but instead emanated from the "Lonely Planet," which produced the bulk of the publication. The public reaction, which has also included calls for a
@maetl
maetl / deploy.rake
Created February 12, 2011 09:33 — forked from peterc/deploy.rake
desc "Deploy site"
task :deploy do
sh %{git push origin master}
sh %{ssh server "cd /var/www/XXXXX.com;git pull;bundle check || bundle;rake db:migrate;touch tmp/restart.txt;chown -R app:app *"}
end
@maetl
maetl / gist:856144
Created March 5, 2011 05:22
Linking Git Repository to Floe Project
$ cd lib
$ git clone git@github.com:maetl/floe.git floe
$ cd floe
$ git remote add upstream git@github.com:maetl/floe.git
$ git fetch upstream