Skip to content

Instantly share code, notes, and snippets.

View huacnlee's full-sized avatar

Jason Lee huacnlee

View GitHub Profile
@Sija
Sija / NSArray-Blocks.h
Created November 15, 2009 05:22
Making NSArray more ruby-ish
//
// NSArray-Blocks.h
// Handy codebits
//
// If you want to keep block definitions terse, simple and dynamic, have no
// problems with the incompatible block pointer types and you don't mind
// compiler warnings about sending a message without matching signature,
// DO NOT IMPORT THIS FILE, seriously.
//
// Created by Sijawusz Pur Rahnama on 15/11/09.
@huacnlee
huacnlee / gist:505642
Last active September 5, 2015 14:34
MySQL 常用命令
- MySQL 创建超级用户 创建用户,并有localhost下所有数据库的超级权限
mysql> grant all on *.* to monster@localhost identified by "123456";
mysql> flush privileges;
- 删除用户
mysql> use mysql;
mysql> delete from user where user = 'monster';
- 创建 Repl 的用户
@huacnlee
huacnlee / .vimrc
Last active September 5, 2015 14:34
Vim 配置文件 for Bash
"Vim 配置文件 for Bash
filetype indent on
syntax on
set paste
set sw=2
set ts=2
set history=100
set iskeyword+=_,$,@,%,#,-
set backspace=2
set autoindent
@huacnlee
huacnlee / gist:505669
Created August 3, 2010 01:22
CentOS 下面安装 PHP
# CentOS install php from souces
sudo yum install gcc-c++ httpd httpd-devel apr-devel libxml2-devel zlib zlib-devel mysql-devel openssl-devel
wget http://cn2.php.net/get/php-5.3.1.tar.gz/from/cn.php.net/mirror
tar -zxf php-5.3.1.tar.gz
cd php-5.3.1
./configure --with-configure-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-mysql --with-mysqli --with-zlib --enable-so --with-apxs2
sudo make && sudo make install
sudo cp php.ini-production /etc/php.ini
sudo vim /etc/php.ini
# 找到 include_path 设置为: include_path = "/usr/local/lib/php/"
@huacnlee
huacnlee / Nginx 编译参数
Created August 28, 2010 18:09
Nginx 源代码编译参数
--with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-file-aio
@huacnlee
huacnlee / thread_pool.rb
Created November 15, 2010 08:36
Ruby 线程池类,用于控制同时最大允许多少个线程执行,并加入列队
require 'thread'
class ThreadPool
class Worker
def initialize
@mutex = Mutex.new
@thread = Thread.new do
while true
sleep 0.001
block = get_block
@huacnlee
huacnlee / install-php.sh
Created March 8, 2011 03:13
Ubuntu 10.10 install PHP Apache2 from source
sudo apt-get install libjpeg8-dev libmysqlclient-dev
curl -O http://www.php.net/get/php-5.3.5.tar.gz/from/a/mirror
curl -O http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.17.tar.gz
tar zxf httpd-2.2.17.tar.gz
cd httpd-2.2.17
./configure --prefix=/etc/apache2 --enable-so --enable-cgi --enable-info --enable-rewrite \
--enable-speling --enable-usertrack --enable-deflate --enable-ssl --enable-mime-magic \
--enable-dav --enable-vhost-alias --enable-proxy --enable-expires --enable-headers
make && sudo make install
@vinioliveira
vinioliveira / Additional Commands
Created June 30, 2011 00:04
Init.d Juggernaut2 script for Ubuntu
$ sudo adduser --system --no-create-home --disabled-login --disabled-password --group juggernaut
$ sudo mv ~/juggernaut2-for-init.d-startup.sh /etc/init.d/juggernaut
$ sudo chmod +x /etc/init.d/juggernaut
$ sudo update-rc.d -f juggernaut defaults
@quietcricket
quietcricket / gist:1593632
Created January 11, 2012 07:58
Fuzzy string match objective-c (Levenshtein Distance Algorithm)
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString
{
// Normalize strings
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
originalString = [originalString lowercaseString];
comparisonString = [comparisonString lowercaseString];
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm)
@huacnlee
huacnlee / rails_template_for_mongoid.rb
Created March 23, 2012 07:34
A custom Rails template for Mongoid.
# coding: utf-8
# This is a Rails init template with MongoDB projects
#
# Mongoid, Devise, Bootstrap, jQuery, Redis, Cells, will_paginate, Carrierwave, simple_form, Settingslogic, Thin
#
# Usage
#
# $ rails new app_name -m https://raw.github.com/gist/2168014
#