Skip to content

Instantly share code, notes, and snippets.

View dcai's full-sized avatar
🥃
need a drink

dcai

🥃
need a drink
View GitHub Profile
@dcai
dcai / index.md
Last active May 5, 2024 23:54
gist index
@dcai
dcai / gitolite.sh
Created July 4, 2011 08:56 — forked from masnick/gitolite_hn.bash
Setting up gitolite for archlinux
# First, get you id_rsa.pub onto the server as /tmp/YourName.pub
scp ~/ssh/id_rsa.pub [email protected]:/tmp/dongsheng.pub
# Then, as root:
cd $HOME
yaourt -S gitolite-git
su git
@dcai
dcai / cvs-moodle.bash
Last active September 10, 2023 03:51
cvs helper for moodle repository
ct (){
if [ $# -eq 0 ]; then
echo "CVS TAG: No arguments entered.";
return 1
else
echo "Tagging [MOODLE_$1_MERGED]";
echo "File(s) ${@:2}";
echo "Tagging ...";
cvs tag -RF MOODLE_$1_MERGED ${@:2}
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method
@dcai
dcai / .gitolite.pl
Last active August 10, 2016 23:43
.gitolite.rc
# paths and configuration variables for gitolite
$GL_PACKAGE_CONF="/etc/gitolite";
$GL_PACKAGE_HOOKS="/usr/share/gitolite/hooks";
# please read comments before editing
# this file is meant to be pulled into a perl program using "do" or "require".
# You do NOT need to know perl to edit the paths; it should be fairly
@dcai
dcai / Preferences.sublime-settings.json
Last active April 25, 2020 14:13
sublime text config
{
"spell_check": true,
"always_show_minimap_viewport": false,
"auto_find_in_selection": true,
"bold_folder_labels": false,
"caret_style": "wide",
"close_windows_when_empty": false,
"copy_with_empty_selection": false,
"create_window_at_startup": false,
"detect_indentation": true,
@dcai
dcai / gist:1186444
Created September 1, 2011 15:41
Bluk unrar xvid files
find . -name '*.part01.rar' -exec unrar -y x {} \;
@dcai
dcai / trim-trailing-spaces.bash
Last active August 10, 2016 23:44
Removing Trailing Whitespace
# -i ".bak" will create backup files
find . -type f -name '*.[m|h]' -print0|xargs -0 sed -i "" -E "s/[[:space:]]*$//"
@dcai
dcai / setup-macos.bash
Last active June 4, 2024 04:56
Resize image
#!/bin/bash
# essentials
/opt/homebrew/bin/brew install fish iterm2
echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/fish
# dev must have
@dcai
dcai / gist:1278207
Created October 11, 2011 14:22
shrinkImage
static UIImage *shrinkImage(UIImage *original, CGSize size) {
CGFloat scale = [UIScreen mainScreen].scale;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, size.width * scale,
size.height * scale, 8, 0, colorSpace, kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context,
CGRectMake(0, 0, size.width * scale, size.height * scale),
original.CGImage);
CGImageRef shrunken = CGBitmapContextCreateImage(context);