Skip to content

Instantly share code, notes, and snippets.

View makmac213's full-sized avatar

Mark Allan B. Meriales makmac213

View GitHub Profile
@makmac213
makmac213 / Mailchimp subscription
Last active December 25, 2015 06:19
Mailchimp subscribe to list
# 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,
@makmac213
makmac213 / class O
Last active December 26, 2015 12:09
csv to class obj
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]
@makmac213
makmac213 / mtgsalvation.py
Created January 16, 2014 13:38
Check for new spoilers and send sms alert to subscribers
import urllib, time, os
from subprocess import Popen, PIPE, check_call
from BeautifulSoup import BeautifulSoup
subscribers = [
'0922xxxxxxx',
'0999xxxxxxx',
'0917xxxxxxx',
'0915xxxxxxx',
]
@makmac213
makmac213 / gist:10852009
Created April 16, 2014 10:54
get_google_time_zone
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)
__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)
@makmac213
makmac213 / AWS Instance Setup Guide
Last active October 27, 2017 08:14
AWS Instance Setup Guide
# 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
@makmac213
makmac213 / .footer
Last active August 29, 2015 14:06
Keep you feet always on the ground.
@makmac213
makmac213 / toc.html
Created October 6, 2014 15:57
TOC generator based from https://github.com/matthewkastor/html-table-of-contents. Only changed function to accept a string id of the element to be parsed.
<html>
<head>
<style type="text/css">
#toc .h1 {
font-size: 20px;
font-weight: bold;
text-indent: .25in;
}
@makmac213
makmac213 / Odesk Api Callback URL Workaround (Django)
Last active August 29, 2015 14:20
Odesk Api Callback URL Workaround (Django)
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
@makmac213
makmac213 / isEmail.js
Created July 29, 2015 09:18
Check if string is an email.
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);
}