Skip to content

Instantly share code, notes, and snippets.

# Description:
# Messing around with the curator.im API.
#
# Commands:
# hubot curator - give you random girl photo from curator.im
module.exports = (robot) ->
robot.respond /(curator|girl)/i, (msg) ->
msg.http("http://curator.im/api/stream/")
.query({
"""
Delete S3 bucket with contents, with S3 Multi-Object Delete.
This script makes you delete S3 bucket quickly.
Before using this script, please install boto
$ pip install boto
and setup ~/.boto config
#!/usr/bin/env python
"""
This script can retrieve pageviews count by month and export to a CSV file
Usage:
>> python pv.py 2013 <input.csv> <output-csv>
"""
import sys
@tzangms
tzangms / s3sqlbackup.sh
Last active August 29, 2015 14:06
Backup MySQL to S3
#!/bin/sh
export MYSQL_HOST=<your-mysql-host>
export MYSQL_USER=<your-mysql-username>
export MYSQL_PASSWORD=<your-mysql-password>
export NAME=<name-of-backup>
export DATE=`date +"%Y%m%d"`
export BACKUP_FILE=$NAME.$DATE.sql.gz
export DATABASE_SCHEMA_NAME=<database-name>
export S3_BUCKET=<s3-bucket-name>
@tzangms
tzangms / fabfile.py
Created January 14, 2015 10:49
my fabfile example
import os.path
from fabric.api import run, env, put
from fabric.context_managers import cd
from fabric.api import local
from datetime import datetime
from cuisine import *
ROOT_PATH = os.path.dirname(__file__)
@tzangms
tzangms / amazon-s3-and-cloudfront.php
Created January 21, 2015 07:00
Modify Wordpress S3 plugin to support non us region
// Find line 386, in amazon-s3-and-cloudfront/classes/amazon-s3-and-cloudfront.php
$s3client = $this->get_s3client( $region );
// Add this line below
$s3client->setRegion('ap-northeast-1');
@tzangms
tzangms / gist:621f0ce572141b8b652e
Created May 5, 2015 02:14
Nginx to S3 Reverse proxy config
location ~ ^/(.*)$ {
resolver 8.8.8.8 valid=300s;
resolver_timeout 10s;
set $s3_bucket '<bucket-name>.com.s3.amazonaws.com';
set $url_full '$1';
proxy_pass http://$s3_bucket/$url_full;
proxy_buffering off;
proxy_set_header Host $s3_bucket;
def facebook_authorization(request):
url = "https://graph.facebook.com/oauth/authorize"
params = urllib.urlencode({
'client_id': settings.FACEBOOK_APP_ID,
'redirect_uri': settings.FACEBOOK_REDIRECT_URI,
'scope': 'offline_access,read_stream,publish_stream'
})
return redirect(url + '?' + params)
class StatusDate(db.Model):
user = db.ReferenceProperty(User, collection_name='status_dates')
count = db.IntegerProperty(default=0)
tweets_count = db.IntegerProperty(default=0)
plurks_count = db.IntegerProperty(default=0)
fb_posts_count = db.IntegerProperty(default=0)
date = db.DateProperty(required=True)
@tzangms
tzangms / imagick.php
Created August 14, 2011 10:50
generate thumbnail on fly
<?php
/*
Author: tzangms
Email: tzangms@gmail.com
Apache Rewrite rules
=========================================================================================
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !=/imagick.php