Skip to content

Instantly share code, notes, and snippets.

View tzangms's full-sized avatar

tzangms tzangms

View GitHub Profile
@tzangms
tzangms / octo2wp.py
Last active December 18, 2015 03:38
I wrote this script to convert my octopress posts back into wordpress, by using xmlrpc.
"""
Requirements:
* A Wordpress Blog
* Python Packages: Markdown, PyYAML, python-wordpress-xmlrpc
>>> pip install Markdown python-wordpress-xmlrpc PyYAML
WARNING:
@tzangms
tzangms / positive.coffee
Created July 10, 2013 05:34
Positive plugin for Hubot
# Description:
# Positive plugin, it just anwsers you "超充實der!"
#
module.exports = (robot) ->
robot.respond /今天.*|How's going/i, (msg) ->
msg.send "超充實der!"
# 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 / ghost2wp.py
Last active May 1, 2017 03:13
Migrate Ghost to Wordpress
"""
Requirements:
* A Wordpress Blog
* Ghost export file (json).
* Python Packages: python-wordpress-xmlrpc
>>> pip install python-wordpress-xmlrpc
WARNING:
@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;