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
# MAILSNAKE | |
from mailsnake import MailSnake | |
from mailsnake.exceptions import * | |
from django.conf import settings | |
ms = MailSnake(settings.MAILCHIMP_API_KEY) | |
val = ms.listSubscribe(id=settings.MAILCHIMP_LIST_ID, | |
email_address=email_address, | |
double_optin=False, |
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
class O: | |
""" | |
csv to class | |
o = O(['col_1_name','col_2_name',...]) | |
o.parse_row(row) | |
""" | |
def __init__(self, *args, **kwargs): | |
if len(args) == 1: | |
self.args = args[0] |
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
import urllib, time, os | |
from subprocess import Popen, PIPE, check_call | |
from BeautifulSoup import BeautifulSoup | |
subscribers = [ | |
'0922xxxxxxx', | |
'0999xxxxxxx', | |
'0917xxxxxxx', | |
'0915xxxxxxx', | |
] |
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 get_google_time_zone(lat, lng): | |
ret = False | |
try: | |
api_url = 'https://maps.googleapis.com/maps/api/timezone/json' | |
payload = { | |
'location': '%s,%s' % (lat, lng), | |
'timestamp': int(time.time()), | |
'sensor': 'true', | |
} | |
response = requests.get(api_url, params=payload) |
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
__author__ = "Mark Allan B. Meriales" | |
# based from http://www.pythoncentral.io/watermark-images-python-2x/ | |
# mine uses a picture as a watermark | |
from PIL import Image, ImageEnhance | |
def add_watermark(image_file, logo_file, opacity=1): | |
img = Image.open(image_file).convert('RGB') | |
logo = Image.open(logo_file) |
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
# Setup apache2 mysql php | |
$ sudo apt-get install tasksel | |
$ sudo tasksel install lamp-server | |
# python setup tools | |
$ sudo apt-get install python-setuptools | |
$ sudo apt-get install python-pip |
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
<html> | |
<head> | |
<style type="text/css"> | |
#toc .h1 { | |
font-size: 20px; | |
font-weight: bold; | |
text-indent: .25in; | |
} |
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
class OdeskView(View): | |
class LinkAccount(View): | |
def get(self, request, *args, **kwargs): | |
client = odesk.Client(settings.ODESK_API_KEY, | |
settings.ODESK_API_SECRET) | |
url = client.auth.get_authorize_url() | |
# need to store request token and request token secret | |
# so that callback url will not raise exception |
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 isEmail(email){ | |
// http://www.w3.org/TR/html-markup/input.email.html | |
var emailReg = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/ | |
return emailReg.test(email); | |
} |