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>
@tzangms
tzangms / PutIOUpload.py
Created November 21, 2012 02:59
put.io upload
import sys
import requests
import urllib
PUTIO_ACCESS_TOKEN = '<token>'
PUTIO_API_URL = 'https://api.put.io/v2/files/upload'
url = sys.argv[1]
@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 / 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)

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 / 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!"
@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:
import requests
import urllib
import json
import logging
logger = logging.getLogger(__name__)
class FacebookLike(object):
def __init__(self, access_token, user_id):
@tzangms
tzangms / cfsign.py
Created November 26, 2012 03:30
Private content signing for CloudFront in python
import Crypto.Hash.SHA
import Crypto.PublicKey.RSA
import Crypto.Signature.PKCS1_v1_5
import base64
import time
KEY_PAIR_ID = "your_key_pair_id"
PRIV_KEY_FILE = "pk-xxxxxxxxxx.pem"