Skip to content

Instantly share code, notes, and snippets.

View kccheung's full-sized avatar
🎯
Focusing

David C kccheung

🎯
Focusing
  • Hong Kong SAR China
View GitHub Profile
@kccheung
kccheung / mbp.py
Created August 13, 2016 15:11 — forked from drx/mbp.py
Tiny script to scrape Apple Online Store every second and check for changes in MacBook availability
import urllib2
import re
import time
import pycurl
import StringIO
#url = "http://78.10.81.103:19100/mbp.html"
url = "http://store.apple.com/pl/browse/home/shop_mac/family/macbook_pro/select"
prev_delivery = (None, None)
@kccheung
kccheung / applestorede.sh
Created August 13, 2016 14:58 — forked from monkeydom/applestorede.sh
Apple store is down script
#!/bin/bash
WaitForDown=true
while true; do
StoreUp=`curl -s http://store.apple.com/de | grep "Mac kaufen" | wc -l`
if [ $StoreUp -eq 0 ]; then
if $WaitForDown; then
@kccheung
kccheung / docker-log.sh
Created August 11, 2016 04:08 — forked from yarcowang/docker-log.sh
simple bash script to show log for a docker image
#!/usr/bin/env bash
DOCKER=`which docker`
usage()
{
echo "Usage: $(basename $0) [-l num] IMAGE"
exit 0
}
@kccheung
kccheung / reltime.py
Created July 19, 2016 13:34 — forked from deontologician/reltime.py
Relative datetimes in python
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)

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 / android_studio_shortcuts.md
Created March 12, 2016 08:56 — forked from stkent/android_studio_shortcuts.md
Android Studio Shortcuts (Mac)

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:

  • 🎨 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
Prerequisitie:
Ruby 2.0.0-p481
Rails 4.1.6
[Step 1]
- rails new wids2015
[Step 2] Add following lines to Gemfile
gem 'devise'
#!/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
@kccheung
kccheung / .ackrc
Last active August 29, 2015 14:06 — forked from theaboutbox/.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