⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#auth table | |
# Custom Auth table definition | |
db.define_table(auth.settings.table_user_name, | |
Field('name', length=128, default='', comment='required'), | |
Field('email', length=128, default='', unique=True), | |
Field('phone', length=64, default=''), | |
Field('homepage', requires=IS_EMPTY_OR(IS_URL())), | |
Field('bio', 'text', default=''), | |
Field('twitter'), | |
Field('facebook'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################## | |
# IMAGE METHODS | |
######################################################################## | |
class RESIZE(object): | |
def __init__(self,nx=160,ny=80,error_message=' image resize'): | |
(self.nx,self.ny,self.error_message)=(nx,ny,error_message) | |
def __call__(self,value): | |
if isinstance(value, str) and len(value)==0: | |
return (value,None) | |
from PIL import Image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################################## | |
# TWITTER IMAGE | |
######################################################################## | |
def get_twitter_image(username): | |
from urllib2 import urlopen | |
from xml.dom.minidom import parse as domparse | |
apiurl = 'http://twitter.com/users/show/%s' | |
dom = domparse(urlopen(apiurl % username)) | |
twitter_image = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def booksfeed(): | |
r = dict() | |
r['title'] = "Books Feed" | |
r['link'] = "http://google.com" | |
r['description'] = "All My books" | |
r['entries'] = [] | |
books = db().select(db.books.ALL) | |
for book in books: | |
r['entries'].append(dict(title=book.titulo, link="http://books/%s" % book.id, description=book.autor)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#soap | |
from gluon.contrib.pysimplesoap.client import SoapClient | |
client = SoapClient(wsdl="http://localhost:8000/app/default/call/soap?WSDL") | |
print client.MyFunction(a=1,b=2) | |
#{'result': 3} | |
#xmlrpc | |
from xmlrpclib import ServerProxy | |
server = ServerProxy( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# default_application, default_controller, default_function | |
# are used when the respective element is missing from the | |
# (possibly rewritten) incoming URL | |
# | |
default_application = 'init' # ordinarily set in base routes.py | |
default_controller = 'default' # ordinarily set in app-specific routes.py | |
default_function = 'index' # ordinarily set in app-specific routes.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import SimpleCV | |
import time | |
import simplejson as json | |
import sys | |
if __name__ == "__main__": | |
captureDir = '/opt/display/applications/tldisplayclient/static' | |
ofilename = '%s/webcam-original.png' % captureDir | |
dfilename = '%s/webcam-detected.png' % captureDir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dados_do_local(endereco): | |
""" | |
Dado o endereco, retorna o endereco processado, a latitude e a longitude do local. | |
Exemplo: | |
place, (lat, lng) = dados_do_local(endereco) | |
""" | |
from geopy import geocoders | |
if hasattr(settings, "EASY_MAPS_GOOGLE_KEY") and settings.EASY_MAPS_GOOGLE_KEY: | |
g = geocoders.Google(settings.EASY_MAPS_GOOGLE_KEY) | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function popup(url) { | |
newwindow=window.open(url,'name','height=400,width=600'); | |
if (window.focus) newwindow.focus(); | |
return false; | |
} | |
function collapse(id) { jQuery('#'+id).slideToggle(); } | |
function fade(id,value) { if(value>0) jQuery('#'+id).hide().fadeIn('slow'); else jQuery('#'+id).show().fadeOut('slow'); } | |
function ajax(u,s,t) { | |
query = ''; | |
if (typeof s == "string") { |