Skip to content

Instantly share code, notes, and snippets.

Shuen-Huei (Drake) Guan drakeguan

Block or report user

Report or block drakeguan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@drakeguan
drakeguan / rename_to_fit_flickr_upload_datetime.py
Created Feb 8, 2019
Extract upload datetime from flickr and rename it according to the datetime
View rename_to_fit_flickr_upload_datetime.py
import os
import re
from time import gmtime
# ref: https://stuvel.eu/flickrapi-doc/
import flickrapi
api_key = 'OOOOOOOOOOOOOOOOO'
api_secret = 'XXXXXXXXXXXXX'
@drakeguan
drakeguan / convert_mp4_to_caf_opus.sh
Last active Feb 5, 2019
Extract audio track, convert to CAF/Opus, and generate a RSS2 feed for personal hosting podcast!
View convert_mp4_to_caf_opus.sh
#!/bin/bash
ffmpeg -y -i "$f" -vn -c:a libfdk_aac -b:a 128k "audio/$(basename $f .mp4).m4a"
afconvert -f caff -d opus -b 8000 "audio/$(basename $f .mp4).m4a" "opus/$(basename $f .mp4).caf"
@drakeguan
drakeguan / simple-cors-http-server.py
Created Apr 13, 2017
Simple HTTP server with CORS.
View simple-cors-http-server.py
#!/usr/bin/env python
# vim: set sw=4 sts=4 ts=4 et si:
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
SimpleHTTPRequestHandler.end_headers(self)
@drakeguan
drakeguan / my_sentiment_analysis_in_google_cloud_next_17.json
Created Apr 13, 2017
Sentiment Analysis by Cloud Vision API in Google Cloud Next '17
View my_sentiment_analysis_in_google_cloud_next_17.json
{
"faceAnnotations": [
{
"rollAngle": 3.2389677,
"panAngle": -9.39832,
"tiltAngle": 1.9103807,
"detectionConfidence": 0.94434965,
"landmarkingConfidence": 0.7591174,
"joyLikelihood": "UNLIKELY",
"sorrowLikelihood": "VERY_UNLIKELY",
@drakeguan
drakeguan / convert_node_to_alias.py
Last active Feb 4, 2017
Warp up of gradually conversion of old blogs to Hugo preferred ones.
View convert_node_to_alias.py
import os
def get_url_from_node(filename):
with open(filename) as fin:
for line in fin:
if 'refresh' in line:
return line[42:-5]
#iname = 'www/node/1/index.html'
#print get_url_from_node(iname)
@drakeguan
drakeguan / Latex.sublime-build
Created Jan 30, 2016 — forked from lusentis/Latex.sublime-build
Latex (xetex) build system for Sublime Text 2
View Latex.sublime-build
// Compilation settings
// ====================
//
// The actual magic happens in the make_pdf command
// I stick to the format of standard ST2 sublime-build files
// with minor variations.
// NOTE: the viewer is NOT configured from here!
// As of 5/24/11, it cannot be changed, but I will introduce a setting later
{
@drakeguan
drakeguan / get_html_pages.sh
Created Jan 3, 2016
Happy New Year 2016 - The force is always with you.
View get_html_pages.sh
#!/bin/bash
mkdir -p html_pages
if [ ! -f html_pages/$1.html ]; then
echo 'get html page' $1
curl -s http://www.movieposterdb.com/posters/?page=$1 > html_pages/$1.html
fi
View invoke-completion.sh
#!/bin/bash
_invoke()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=$(invoke -l | tail -n+3 | awk '{ print $1 }' | tr '\n' ' ')
@drakeguan
drakeguan / bootstrap_for_encoding_server.sh
Last active Jan 12, 2017 — forked from xdamman/install_ffmpeg_ubuntu.sh
Bash script to install latest version of ffmpeg, x264 and libvpx on Ubuntu 14.04 server
View bootstrap_for_encoding_server.sh
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 14.04
# Copyright @ 2014 Shuen-Huei (Drake) Guan <drake.guan@gmail.com>
# References:
# * https://gist.github.com/xdamman/e4f713c8cd1a389a5917
# * https://blog.dlasley.net/2013/05/install-ffmpeg-from-source/
# * http://fermat-little-theorem-blog.logdown.com/posts/203069-solved-when-building-gpac-suffer-usr-local-lib-libswscalea-error-adding-symbols-bad-value
@drakeguan
drakeguan / mpd_validator.py
Last active Aug 29, 2015
poor man's MPD validator
View mpd_validator.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set hls is ai et sw=4 sts=4 ts=8 nu ft=python:
#
# Copyright © 2014 drake <drake.guan@gmail.com>
#
# Distributed under terms of the MIT license.
# Built-in modules
You can’t perform that action at this time.