Skip to content

Instantly share code, notes, and snippets.

@safecat
safecat / gist:c5686a9978f844a75034
Last active August 29, 2015 14:06
Install php5-redis for ubuntu 12.04
sudo -s
cd /opt
git clone https://github.com/nicolasff/phpredis.git
cd phpredis
phpize
./configure #--enable-redis-igbinary
make && make install
Add following towards bottom
```
### IMPROVE SYSTEM MEMORY MANAGEMENT ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
@safecat
safecat / gist:2be1248ea09277189a3c
Last active August 29, 2015 14:19
Tengine Installation
# Update aptitude
sudo -s
apt-get update
apt-get install libpcre3-dev libssl-dev # openssl
# Download Tengine
wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
tar zxvf tengine-2.1.0.tar.gz
cd tengine-2.1.0
@safecat
safecat / gist:f450ce5ed5a51b3b6f32
Last active October 28, 2025 22:42
ApacheBench for Mac
# ATTENTION PLEASE!
# NOTE BY @riwazp7
# Note for future visitors of this gist: Mac OS has Apache Benchmark by default ab --help
curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
tar -xzf libtool-2.4.2.tar.gz
cd libtool-2.4.2
./configure && make && sudo make install
# brew install 'https://raw.github.com/simonair/homebrew-dupes/e5177ef4fc82ae5246842e5a544124722c9e975b/ab.rb'
@safecat
safecat / gist:e7bee1345085cecd5ca3
Last active August 29, 2015 14:24
从mysqldump导出的sql文件中移除一些数据库
# 第一步,找出所有库所在的行号
cat all_databases.sql |grep -n "Current Database"
#返回
422:-- Current Database: `data_platform`
8094:-- Current Database: `mysql`
13013:-- Current Database: `test`
13045:-- Current Database: `test_insert`
13085:-- Current Database: `test_l5`
# 第二步,确认要移除的库:mysql
@safecat
safecat / func.swift
Last active August 29, 2015 14:24
Swift 函数学习
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
// 函数和返回值
func getUserName(id: Int) -> String {
return "xxy";
}
@safecat
safecat / closure.swift
Created July 7, 2015 02:01
Swift 闭包学习
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
var names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]
// 普通函数
func desc(s1 : String, s2 : String) -> Bool {
@safecat
safecat / enum.swift
Created July 7, 2015 02:51
Swift 枚举类型
//: Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
// Enum 类型的名称和成员值都应当以大写开头
enum status{
case ok
@safecat
safecat / NSJSONSerialization.swift
Created July 10, 2015 10:02
NSJSONSerialization
//: Playground - noun: a place where people can play
import UIKit
// NSJSONSerialization(iOS5新增) 类似的第三方库有:SBJSON、TouchJSON、YAJL、JSONKit、NextiveJson。
// 可以将JSON数据转为Foundation对象,一般是 NSDictionary 或者 NSArray,或者将Foundation对象转换为JSON数据
// NSJSONReadingOptions
// MutableContainers:转换的来的 NSArray 或 NSDictionary 是 mutable 的
// MutableLeaves:转换来的对象中,叶子节点的 NSString 是 mutable 的
@safecat
safecat / NSLayoutFormatOptions.md
Created July 15, 2015 05:51
NSLayoutFormatOptions

#NSLayoutFormatOptions 翻译自:http://iosdevelopmentjournal.com/blog/2013/04/22/alignment-options-in-auto-laytout/

Options 的作用

constraintsWithVisualFormat:options:metrics:views: 函数中, options 参数是一个 bitmask,它指定了VFL中的元素如何对齐。举个例子,"V:[first][second][third]" 这一句VFL只告诉你了三个元素应该纵向堆叠在一起,但是没有说当它们宽度不同时该怎么办。

你可以再增加一些横向的 constraints,但是这些知识无聊的体力劳动。其实你可以传入一个 option,将它们的相对位置告诉排版引擎。

Options参数