Skip to content

Instantly share code, notes, and snippets.

@dcai
dcai / .editorconfig
Last active May 6, 2025 07:57
git config gitconfig
root = true
[*]
indent_style = tab
"""""""""""""""""""""""""""""""""""""""
" __ _ "
" ____/ /________ _(_) "
" / __ / ___/ __ `/ / "
" / /_/ / /__/ /_/ / / "
" \__,_/\___/\__,_/_/ "
" "
" Dongsheng Cai <[email protected]> "
" "
"""""""""""""""""""""""""""""""""""""""
@dcai
dcai / configure-cli.sh
Created March 6, 2012 05:55
php 5.3.10 for OS X Lion
'./configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/private/etc' '--with-config-file-path=/etc' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--enable-dba' '--with-ndbm=/usr' '--enable-exif' '--enable-ftp' '--with-gd' '--with-freetype-dir=/usr/X11' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/X11' '--enable-gd-native-ttf' '--with-iodbc=/usr' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--with-libedit=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-readline=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sqlite-utf8' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-wddx' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr' '--enable-zend-multibyte'
@dcai
dcai / configure-cli.sh
Created March 5, 2012 14:37
confgiure of php 5.4 for OS X 10.7 Lion
'./configure' '--prefix=/usr' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--sysconfdir=/private/etc' '--with-config-file-path=/etc' '--with-libxml-dir=/usr' '--with-openssl=/usr' '--with-kerberos=/usr' '--with-zlib=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--with-curl=/usr' '--enable-dba' '--with-ndbm=/usr' '--enable-exif' '--enable-ftp' '--with-gd' '--with-freetype-dir=/usr/X11/' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/X11/' '--enable-gd-native-ttf' '--with-icu-dir=/usr' '--with-iodbc=/usr' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--with-libedit=/usr' '--enable-mbstring' '--enable-mbregex' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--without-pear' '--with-pdo-mysql=mysqlnd' '--with-mysql-sock=/var/mysql/mysql.sock' '--with-readline=/usr' '--enable-shmop' '--with-snmp=/usr' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--enable-wddx' '--with-xmlrpc' '--with-iconv-dir=/usr' '--with-xsl=/usr' '--enabl
@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);
@dcai
dcai / setup-macos.bash
Last active May 6, 2025 07:58
macos setup script
#!/bin/bash
# essentials
/opt/homebrew/bin/brew install fish
echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/fish
echo "# must have casks"
@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 / gist:1186444
Created September 1, 2011 15:41
Bluk unrar xvid files
find . -name '*.part01.rar' -exec unrar -y x {} \;
@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 / cg
Last active May 6, 2025 07:57
cgvg: code grep, vim grepped
#!/bin/bash
#
# Inspired by uzix's cgvg https://uzix.org/cgvg.html
#
# cg: code grep
# vg: vim grepped
#
INDEX_FILE="$XDG_STATE_HOME/cgvg.index"
export GRAY="\033[37m"