Skip to content

Instantly share code, notes, and snippets.

@tzangms
tzangms / plupload.js
Created November 21, 2022 08:50
plupload example
$(function() {
var uploader = new plupload.Uploader({
runtimes : 'flash,html5,silverlight,html4',
url : plupload_url,
browse_button : 'pickfiles',
container : 'plupload_container',
max_file_size : '150mb',
chunk_size: '1mb',
multipart: true,
unique_names : true,
@tzangms
tzangms / feed.html
Created July 30, 2019 15:05
podcast feed
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
{% if podcast.new_feed_url %}<itunes:new-feed-url>{{ podcast.new_feed_url }}</itunes:new-feed-url>{% endif %}
<atom:link href="http://{{ request.get_host }}{{ podcast.get_absolute_url }}rss/" rel="self" type="application/rss+xml" />
<title><![CDATA[{{ podcast.title|striptags|fix_ampersands }}]]></title>
<link>http://{{ request.get_host }}{{ podcast.get_absolute_url }}</link>
<description><![CDATA[{{ podcast.description|striptags|fix_ampersands }}]]></description>
<language>zh-TW</language>

Keybase proof

I hereby claim:

  • I am tzangms on github.
  • I am tzangms (https://keybase.io/tzangms) on keybase.
  • I have a public key whose fingerprint is 599D 62E0 EF68 B7EA DA68 4C9D 0CCB 4456 9C3B BCF1

To claim this, I am signing this object:

@tzangms
tzangms / drf_pagination_example.py
Created January 7, 2016 07:06
DRF pagination example
@detail_route()
def posts(self, request, pk=None):
"""
Photos of current user
"""
user = self.get_object()
photos = Photo.objects.filter(user=user)
queryset = self.paginate_queryset(photos)
@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;
@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 / 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 / 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 / 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:
#!/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