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
@woods
woods / git_svn_bash_prompt.sh
Created December 4, 2008 15:37 — forked from halbtuerke/gist:31934
Set color bash prompt according to git/svn branch, and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the branch/status of the current git repository
# * the branch of the current subversion repository
# * the return value of the previous command
#
# USAGE:
@ishikawa
ishikawa / gist:88599
Created April 1, 2009 07:49
Java Sample Code for Calculating HMAC-SHA1 Signatures
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.util.Formatter;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
/**
@winhamwr
winhamwr / celeryd_rotate
Created May 17, 2010 14:35
logrotate.d configuration for celery
/var/log/celery/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
copytruncate
}
@redoPop
redoPop / .gitignore
Created June 18, 2010 22:08
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@riklomas
riklomas / adding-to-user-admin-form.py
Created August 6, 2010 15:01
How to add a field to the Django Admin Add User form using UserCreationForm. Add this to a admin.py and alter to whatever fields you'd like
# How to add a field to the Django Admin Add User form
# using UserCreationForm. Add this to a admin.py and alter
# to whatever fields you'd like
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib import admin
<html>
<head>
<title>Checkbox</title>
<style>
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label
{
@monkeydom
monkeydom / applestorede.sh
Created March 24, 2011 21:02
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
@veritech
veritech / CALayer.m
Created April 12, 2011 12:24
Using CAKeyFrameAnimation to animate images in a CALayer
//Create the layer
layer = [CALayer layer];
//Configure the animation
animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
[animation setCalculationMode:kCAAnimationDiscrete];
[animation setDuration:2.0f];
[animation setRepeatCount:HUGE_VALF];
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@rajiv-singaseni
rajiv-singaseni / MainActivity.java
Created July 6, 2011 21:19
An android activity which demonstrates picking a photo from gallery and uploading it to a remote server.
package com.webile.upload;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.InputStreamReader;
import java.util.Date;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;