Iconv Multiple Files

find . -type f -name '*.txt' -exec sh -c 'iconv -f gb18030 -t utf8 {} > {}.red54tmp && mv {}.red54tmp {}' \;

2015-07-23 09:3322Commands

Adapter Pattern

道教徒者,得法无量天尊。

佛教徒者,得法阿弥陀佛。

今有佛寺,行法阿弥陀佛。

适配器者,阿弥转无量也。

Object Adapter Pattern:

Ruby Code:

class T道教徒

def initialize 名字

@名字 = 名字

end

def 无量天尊

puts "无量天尊,贫道乃#{@名字}。"

end

end

class B佛教徒

def initialize 名字

......

Linux Driver: "ndo_set_mac_address" Function

int (*ndo_set_mac_address)(struct net_device *dev, void *addr);

This function is called when the Media Access Control address needs to be changed.

If this interface is not defined, the mac address can not be changed.

Header:

include/linux/netdevi......

2015-06-02 01:1625DriverLinux

OS X: Set Node.js Path

export NODE_PATH=/usr/local/lib/node_modules

2015-06-02 01:077Node.jsOS XCommands

Git: Find Submodules

git ls-files --stage | grep 160000

2015-05-13 18:2917CommandsGit

Metaprogramming: ORM

元编程:对象关系映射(Object-relational mapping)

Ruby code:

require 'sqlite3'

Database = SQLite3::Database.new ':memory:'

class Entity

def initialize(table, ident)

@table = table

@ident = ident

Database.execute "CREATE TABL......

Metaprogramming: Introspection

元编程:内省(xǐng)

Ruby code:

class Greeting

def initialize text

@text = text

end

def welcome

@text

end

end

my_object = Greeting.new "Hello"

puts my_object.welcome

puts

puts my_object.class

puts

puts my_object.class.instance_m......