Skip to content

Instantly share code, notes, and snippets.

View feihong's full-sized avatar

Feihong Hsu feihong

View GitHub Profile
@feihong
feihong / restructuredtext-cheatsheet.rst
Last active October 24, 2015 20:47
ReStructuredText cheatsheet

Basics

  • emphasis
  • boldface
  • code samples
  • Subscript: H2O
  • Superscript: E = mc2
@feihong
feihong / imagemagick-cheatsheet.md
Last active October 24, 2015 20:47
ImageMagick cheatsheet

Resize selfie.jpg so that its width becomes 800px. Ratio is preserved.

convert selfie.jpg -resize 800 resized_selfie.jpg
@feihong
feihong / make_palette_image.py
Created October 6, 2015 21:38
Generate a palette image file
from PIL import Image, ImageDraw
length = 100
columns = 4
colors = """
whitesmoke gainsboro gray black
indianred lightpink tomato lemonchiffon
plum palegreen paleturquoise burlywood
peachpuff khaki slateblue teal
@feihong
feihong / bash-cheatsheet.md
Last active October 28, 2015 03:43
Bash cheatsheet

Find all files named .DS_Store:

find . -name '.DS_Store'

Find all files containing the string 'feihong', then replace occurrences of 'feihong.pythonanywhere' with 'chicktech.pythonanywhere'.

grep -rli 'feihong' * | xargs -i@ sed -i 's/feihong\.pythonanywhere/chicktech\.pythonanywhere/g' @
@feihong
feihong / digital_ocean_instructions.md
Last active September 29, 2015 23:05
Python script for SSH tunneling on Mac OS X

Creating and configuring a DigitalOcean droplet for SSH tunneling

Creating the droplet on DigitalOcean

  1. Click Create Droplet
  2. Name it 'tunnel'
  3. Select $5/mo
  4. Select Singapore
  5. Select Ubuntu 14.04
  6. Add your SSH key (probably already there if you've created other droplets)
@feihong
feihong / server.py
Created August 10, 2015 19:43
Very simple TinyWebDB-compliant server app for use with App Inventor
import json
from flask import Flask, request
app = Flask(__name__)
db = {}
@app.route('/')
def hello_world():
@feihong
feihong / MainViewController.swift
Created June 26, 2015 00:25
Example of using UITabBarController without using icons
import UIKit
import FontAwesome
class MainViewController: UITabBarController {
override func viewWillAppear(animated: Bool) {
addViewControllers(
("Phrases", PhrasesViewController()),
("Voices", VoicesViewController()),
@feihong
feihong / tmux-cheatsheet.md
Last active October 24, 2015 20:46
tmux cheatsheet

Reattach: tmux a

Kill session: prefix kill-session

Create window: prefix c Rename window: prefix ,

@feihong
feihong / extract_crowdin_text.py
Last active August 29, 2015 14:22
Extract text chunks from a given Crowdin page
"""
Extract source and translation texts from a given Crowdin page. The output file
generated by this script is suitable for doing translation work on a mobile
device that is occasionally offline.
This script assumes that you've created a custom Firefox profile that is
already logged into your Crowdin account, and that you've provided the path for
it below.
"""
@feihong
feihong / crowdin_phrases.user.js
Created May 21, 2015 18:40
Copy Crowdin phrases to clipboard
// ==UserScript==
// @name Copy Crowdin text to clipboard
// @namespace https://github.com/feihong/
// @description Copies the source and translation phrase to the clipboard.
// @include https://crowdin.com/translate/*
// @version 1
// @grant GM_setClipboard
// ==/UserScript==
var menu = document.querySelector('#editor-menu');