Skip to content

Instantly share code, notes, and snippets.


David C kccheung

View GitHub Profile
from collections import OrderedDict as _OrderedDict
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
class ListDict(_OrderedDict):
def __init__(self, *args, **kwds):
View NSAttributedString+format.m
// NSAttributedString+format.m
// Chatterbox
// Created by Brent Royal-Gordon on 2/7/14.
// Copyright (c) 2014 Architechies. All rights reserved.
#import "NSAttributedString+format.h"
View .ackrc
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
View WIDS 2015 - Intro to Rails for mobile apps
Ruby 2.0.0-p481
Rails 4.1.6
[Step 1]
- rails new wids2015
[Step 2] Add following lines to Gemfile
gem 'devise'
  • 🎨 when improving the format/structure of the code
  • 🚀 when improving performance
  • ✏️ when writing docs
  • 💡 new idea
  • 🚧 work in progress
  • when adding feature
  • when removing feature
  • 🔈 when adding logging
  • 🔇 when reducing logging
  • 🐛 when fixing a bug

Android Studio Shortcuts (Mac)


  • Two of the most useful shortcuts utilize the Fn (function) keys. It is therefore recommended that you enable the "Use all F1, F2, etc. keys as standard function keys" option [System Preferences > Keyboard].
  • Be sure to enable the Mac OS X 10.5+ keymap in Android Studio [Preferences > Keymap].
  • A fairly complete shortcut list can be found here.

Useful symbols:


Customize Save In Django Admin Inline Form


This is a common case in django ORM.

from django.db import models

class Author(models.Model):
kccheung /
Created Jul 19, 2016 — forked from deontologician/
Relative datetimes in python
def reltime(date, compare_to=None, at='@'):
r'''Takes a datetime and returns a relative representation of the
:param date: The date to render relatively
:param compare_to: what to compare the date to. Defaults to
:param at: date/time separator. defaults to "@". "at" is also reasonable.
>>> from datetime import datetime, timedelta
>>> today = datetime(2050, 9, 2, 15, 00)
>>> earlier = datetime(2050, 9, 2, 12)
kccheung /
Created Aug 11, 2016 — forked from yarcowang/
simple bash script to show log for a docker image
#!/usr/bin/env bash
DOCKER=`which docker`
echo "Usage: $(basename $0) [-l num] IMAGE"
exit 0
You can’t perform that action at this time.