Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

David C kccheung

🎯
Focusing
View GitHub Profile
View listdict_setitem_subclass.py
from collections import OrderedDict as _OrderedDict
try:
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):
try:
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
--type-add=css=.sass,.less,.scss
--type-add=ruby=.rake,.rsel,.builder,.thor
--type-add=html=.haml,.html.erb,.html.haml
--type-add=js=.js.erb,.coffee
--type-set=cucumber=.feature
--type-set=c=.c,.cpp,.ino,.pde,.h
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=doc
View install_ffmpeg_ubuntu.sh
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# 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
Prerequisitie:
Ruby 2.0.0-p481
Rails 4.1.6
[Step 1]
- rails new wids2015
[Step 2] Add following lines to Gemfile
gem 'devise'
View commit-emoji.md
  • 🎨 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
View android_studio_shortcuts.md

Android Studio Shortcuts (Mac)

Notes:

  • 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:

View customize-save-in-django-admin-inline-form.org

Customize Save In Django Admin Inline Form

Background

This is a common case in django ORM.

from django.db import models

class Author(models.Model):
@kccheung
kccheung / reltime.py
Created Jul 19, 2016 — forked from deontologician/reltime.py
Relative datetimes in python
View reltime.py
def reltime(date, compare_to=None, at='@'):
r'''Takes a datetime and returns a relative representation of the
time.
:param date: The date to render relatively
:param compare_to: what to compare the date to. Defaults to datetime.now()
: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
kccheung / docker-log.sh
Created Aug 11, 2016 — forked from yarcowang/docker-log.sh
simple bash script to show log for a docker image
View docker-log.sh
#!/usr/bin/env bash
DOCKER=`which docker`
usage()
{
echo "Usage: $(basename $0) [-l num] IMAGE"
exit 0
}
You can’t perform that action at this time.