Skip to content

Instantly share code, notes, and snippets.

View feihong's full-sized avatar

Feihong Hsu feihong

View GitHub Profile
@feihong
feihong / get_favorite_songs.py
Last active October 30, 2022 07:55
Python scripts for reading metadata from iTunes
"""
List songs rated 5 stars, grouped by genre.
"""
import itunes
from collections import defaultdict
def print_(s):
@feihong
feihong / find_abnormal_gain.py
Created May 10, 2015 01:27
Set and view gain on MP3 files
"""
In the given directory, print any MP3 files whose gains should be adjusted.
"""
import sys
import os
import subprocess
import csv
from StringIO import StringIO
@feihong
feihong / douban_song_metadata.user.js
Last active August 29, 2015 14:17
Tools to help you download and process MP3 files from Douban Music
// ==UserScript==
// @name Get Douban song metadata
// @namespace https://github.com/feihong/
// @description Adds a button to the Douban player page that puts the song metadata onto the clipboard.
// @include http://music.douban.com/artists/player/*
// @version 1
// @grant GM_setClipboard
// ==/UserScript==
var playlist = unsafeWindow.__bootstrap_data['playlist'];
@feihong
feihong / process_mp4.py
Last active August 29, 2015 14:17
Script to process MP4 files downloeded from YouTube
"""
For all the .mp4 files in a given directory, do the following:
- Extract the audio out into a .m4a file.
- Adjust gain.
- Optionally trim running time.
- Add metadata (title, artist, album, artwork).
Usage: python process_mp4_files.py /path/to/mp4/files/
@feihong
feihong / main.swift
Created February 26, 2015 16:27
Using semaphore in command-line application
func main() {
let semaphore = dispatch_semaphore_create(0)
println("hello")
println("getting ready to leave now")
let threeSeconds = dispatch_time(DISPATCH_TIME_NOW, Int64(3.0 * Double(NSEC_PER_SEC)))
// Using the main queue doesn't work in a command-line application!
// let queue = dispatch_get_main_queue()
let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)
@feihong
feihong / swift_library_list.md
Last active August 29, 2015 14:14
A list of libraries and tools for Swift development

Frameworks

  • ReactiveCocoa

Networking

  • Alamofire
  • Moya

Model layer

@feihong
feihong / adjust_gain.py
Created February 5, 2015 02:13
Script to adjust the gain on all .mp4 files within a given directory
"""
Adjust the gain on all .mp4 files within the given directory.
In order to run this script, you must have aacgain installed. On Ubuntu, you
can do so by running these commands:
add-apt-repository ppa:stefanobalocco/ppa
apt-get update
apt-get install aacgain
@feihong
feihong / add_metadata.py
Created February 4, 2015 21:41
Script to add metadata to all .mp4 files within a directory
"""
Add metadata to all the .mp4 files within the given directory, based on the file
names of the input files.
Each input file should use the following format for their filename:
[album] [title] [artist]
Note that there are two spaces between each element.
@feihong
feihong / denver-cities-no-interior-rings.geojson
Created November 11, 2014 22:59
Denver and four of its suburbs, without interior rings
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@feihong
feihong / denver-cities.geojson
Last active August 29, 2015 14:09
Denver and four of its suburbs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.