<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8203140</id><updated>2026-08-02T21:55:00.264-07:00</updated><category term="Linux"/><category term="Python"/><category term="Latex"/><category term="emacs"/><category term="MacOS"/><category term="概率"/><category term="C"/><category term="git"/><category term="算法"/><category term="C++"/><category term="Windows"/><category term="数学"/><category term="Firefox"/><category term="Kernel"/><category term="gdb"/><category term="CPU"/><category term="IRQ"/><category term="Javascript"/><category term="Makefile"/><category term="Object-C"/><category term="PDF"/><category term="Pylab"/><category term="Shell"/><category term="TeX"/><category term="Threading"/><category term="Thunderbird"/><category term="Ubuntu"/><category term="Yaml"/><category term="debug"/><category term="gcc"/><category term="gnuplot"/><category term="network"/><category term="performance tuning"/><category term="pthread"/><category term="rubber"/><category term="ssh"/><category term="svn"/><category term="vi"/><category term="字体"/><category term="Ansi Code"/><category term="Apache"/><category term="Asymptote"/><category term="Ballot Problem"/><category term="CJK"/><category term="Cantor Paring"/><category term="Chrome"/><category term="Cocoa"/><category term="Coupon Collector"/><category term="Currying"/><category term="Data Structure"/><category term="FUSE"/><category term="Filesystem"/><category term="Firefox Extension"/><category term="Fireofx"/><category term="Foxmail"/><category term="Golang"/><category term="Hadoop"/><category term="Indefero"/><category term="Intel"/><category term="Java"/><category term="Json"/><category term="Lambda"/><category term="Late"/><category term="Library"/><category term="ML"/><category term="Mac"/><category term="Mame"/><category term="MapReduce"/><category term="Mathematica"/><category term="MenuFont"/><category term="NUMA"/><category term="Network Measurement"/><category term="OProfile"/><category term="PXE"/><category term="Prefetch"/><category term="Probability"/><category term="Proxy Server"/><category term="PyQt"/><category term="Qt"/><category term="Quine"/><category term="SMP Affinity"/><category term="SSD"/><category term="Search"/><category term="Squid"/><category term="String"/><category term="Subprocess"/><category term="TLS"/><category term="TRIM"/><category term="Thrift"/><category term="Timeout"/><category term="Type System"/><category term="VirtualBox"/><category term="Wine"/><category term="Xetex"/><category term="Y-Combinator"/><category term="apt"/><category term="aspell"/><category term="awk"/><category term="cheating sheet"/><category term="clang"/><category term="cmd"/><category term="colordiff"/><category term="debian"/><category term="diff"/><category term="driver"/><category term="encfs"/><category term="eps"/><category term="font"/><category term="fstable"/><category term="gedit"/><category term="gmail"/><category term="gnome"/><category term="gprof"/><category term="home brew"/><category term="hugepage"/><category term="iBus"/><category term="iOS"/><category term="iPython"/><category term="lisp"/><category term="locale"/><category term="memcached"/><category term="minicom"/><category term="node.js"/><category term="perf"/><category term="port"/><category term="ppa"/><category term="raspberry pi"/><category term="rsync"/><category term="screen"/><category term="security"/><category term="sublime"/><category term="sublime text"/><category term="svn ignore"/><category term="tbb"/><category term="texmf tree"/><category term="uint64_t"/><category term="wget"/><category term="windbg"/><category term="zsh"/><category term="中文"/><category term="可变长参数"/><category term="杂"/><category term="环境变量"/><category term="硬币"/><category term="组合数学"/><category term="输入法"/><category term="随机算法"/><title type='text'>Kids Return</title><subtitle type='html'>所有内容未经说明都是原创。注明出处后欢迎转载。</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>204</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8203140.post-6030596411927065879</id><published>2016-05-28T12:35:00.001-07:00</published><updated>2016-12-23T16:09:09.805-08:00</updated><title type='text'>Hadoop 基本指令</title><content type='html'>format the namenode:

hdfs namenode -format



$ sbin/start-dfs.sh

$ sbin/stop-dfs.sh


主要配置文件

core-site.xml 

hdfs-site.xml</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/6030596411927065879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/6030596411927065879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/6030596411927065879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/6030596411927065879'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2016/05/hadoop.html' title='Hadoop 基本指令'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-3765949799466471204</id><published>2016-05-28T12:34:00.000-07:00</published><updated>2016-05-28T12:34:04.135-07:00</updated><title type='text'>使用jenv切换Java的version</title><content type='html'>

$ jenv global

$ jenv verions

$ jenv enable-plugin maven</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/3765949799466471204/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/3765949799466471204' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/3765949799466471204'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/3765949799466471204'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2016/05/jenvjavaversion.html' title='使用jenv切换Java的version'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-656382437842735309</id><published>2014-12-17T20:46:00.003-08:00</published><updated>2014-12-17T20:47:36.695-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>[Python] Class间大小比较（达到全序）</title><content type='html'>在Python 2.x中, 可以方便的使用 __cmp__ 方法来实现class object之间的大小比较.
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;class Foo:
    def __init__(self, key):
        self.key = key

    def __cmp__(self, other):
        return cmp(self.key, other.key)&lt;/pre&gt;
如此Foo类型的object间的大小比较就可以用key这个域的值来实现.&lt;br /&gt;
&lt;br /&gt;
在Python 3以后, __cmp__ 方法被移除了. 实现Foo object间的大小比较， 需要用functools.total_ordering修饰这个class以后, 实现__eq__方法以及__lt__(或者__lt__, __le__, __gt__, __ge__中的任意一个).
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;import functools

@functools.total_ordering
class Foo:
    def __init__(self, key):
        self.key = key

    def __eq__(self, other):
        return self.key == other.key

    def __lt__(self, other):
        return self.key &amp;lt; other.key&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/656382437842735309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/656382437842735309' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/656382437842735309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/656382437842735309'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/12/python-class.html' title='[Python] Class间大小比较（达到全序）'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-4018443235579836158</id><published>2014-08-11T23:53:00.001-07:00</published><updated>2014-08-11T23:53:30.343-07:00</updated><title type='text'>[iOS] Apple的Push Notification Service: APNS </title><content type='html'>官方介绍
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html&quot;&gt;Apple Push Notification Service&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
实现Push功能的例子
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Server端Php代码的例子: &lt;a href=&quot;http://learn-php-by-example.blogspot.com/2013/01/working-with-apple-push-notification.html&quot;&gt;Learn PHP by Example - Working with Apple Push Notification&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tanqisen.github.io/blog/2013/02/27/ios-push-apns/&quot;&gt;一步一步实现iOS应用PUSH功能&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Apple Push Notification Services in iOS 6 Tutorial: &lt;a href=&quot;http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1&quot;&gt;Part 1&lt;/a&gt;(APNS的设置), &lt;a href=&quot;http://www.raywenderlich.com/32963/apple-push-notification-services-in-ios-6-tutorial-part-2&quot;&gt;Part 2&lt;/a&gt;(iOS App的编程)&lt;/li&gt;
&lt;/ul&gt;
APNS notification request与response的binary格式:
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html#//apple_ref/doc/uid/TP40008194-CH101-SW1&quot;&gt;Provider Communication with Apple Push Notification Service&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://cocoaintheshell.com/2014/03/apns-binary-interface-notification-format/&quot;&gt;Changes in the APNS Binary Interface and Notification Format&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
PHP中二进制数据的处理
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://songjianyong.iteye.com/blog/1561513&quot;&gt;php pack、unpack、ord 函数使用方法（二进制流接口应用实例）&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/4018443235579836158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/4018443235579836158' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/4018443235579836158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/4018443235579836158'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/08/ios-applepush-notification-service-apns.html' title='[iOS] Apple的Push Notification Service: APNS '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-3942422279123010255</id><published>2014-08-09T21:26:00.001-07:00</published><updated>2014-08-09T21:26:45.364-07:00</updated><title type='text'>Base64 Encoding</title><content type='html'>base64 encode是一种编码方式. 这种编码方式用来将一段二进制数据变换成为&quot;方便传输&quot;的文本数据. 它的核心思想是把二进制数据按每3个字节划分为一段, 然后每一段里每6个bit映射为一个文本字符来表示. 6个bit最多只有64种可能, 所以可以用a-zA-Z0-9+/ 这64个大多数字符集里都有的文本来对应.

&lt;hr /&gt;
在Objective C中, 使用如下的方法可以在二进制数据(NSDate类型)和based64 encoded数据(保存在NSString中)相互转换.
&lt;pre class=&quot;code&quot;&gt;// From binary data to base64 encoded string
NSString string;
if ([data respondsToSelector:@selector(base64EncodedStringWithOptions:)]) {
    string = [data base64EncodedStringWithOptions:kNilOptions];  // iOS 7+
} else {
    string = [data base64Encoding];                              // pre iOS7
}

// From base64 encoded string to binary data
NSData *data;
if ([NSData instancesRespondToSelector:@selector(initWithBase64EncodedString:options:)]) {
    data = [[NSData alloc] initWithBase64EncodedString:string options:kNilOptions];  // iOS 7+
} else {
    data = [[NSData alloc] initWithBase64Encoding:string];                           // pre iOS7
}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/3942422279123010255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/3942422279123010255' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/3942422279123010255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/3942422279123010255'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/08/base64-encode.html' title='Base64 Encoding'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-7426657603090294680</id><published>2014-08-05T15:53:00.000-07:00</published><updated>2014-08-07T22:11:03.910-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="iOS"/><category scheme="http://www.blogger.com/atom/ns#" term="security"/><title type='text'>[iOS]  iOS开发涉及到的Certificate, Provisioning Profile</title><content type='html'>
&lt;h3&gt;
iOS development/distribution&lt;/h3&gt;
iOS开发最基本的证书. 其实是一个private key, Xcode使用该private key对App的code签名. 
&lt;ul&gt;
&lt;li&gt;iOS Development Certificate: 该证书用来在Xcode上开发一个iOS app&lt;/li&gt;
&lt;li&gt;iOS Distribution Certificate: 该证书用来将一个iOS使用App Store或者AdHoc方式来分发给用户&lt;/li&gt;
&lt;/ul&gt;
每一个Certificate可以对应多个App.
&lt;h3&gt;
iOS Push service&lt;/h3&gt;
一个经过Apple授权的SSL Certificate, 使得App后端的notification server可以连接到Apple的APNS服务. 
&lt;ul&gt;
&lt;li&gt;APNS Development SSL Certificate: 在开发测试期使用该证书. APNS的sandbox 服务器：gateway.sandbox.push.apple.com:2195&lt;/li&gt;
&lt;li&gt;APNS Production SSL Certificate: 在App运行期使用该证书. 并连接APNS production 服务器：gateway.push.apple.com:2195&lt;/li&gt;
&lt;/ul&gt;
每一个特定的SSL Certificate只能对应一个iOS App ID.
&lt;h3&gt;
什么是Provisioning Profile&lt;/h3&gt;
一个被Apple使用PKCS#7标准签名过的plist文件. 这个plist文件里以key-value pair的形式保存了关于这个App的一些基本属性. 比如AppIDName,证书创建和过期日期等等.
每一个Provisioning Profile需要对应
&lt;ul&gt;
&lt;li&gt;一个AppID&lt;/li&gt;
&lt;li&gt;一个development/distribution certificate&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
验证一个Provisioning Profile&lt;/h4&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;$ openssl smime -in /path/to/your/foo.mobileprovision -inform der -verify &lt;/pre&gt;
这个命令会输出该plist文件的文本内容, 以及&quot;Verification successful&quot; 如果验证成功
&lt;h3&gt;
参考&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://%3D/&quot; what-is-a-provisioning-profile-part-1=&quot;&quot; www.doubleencore.com=&quot;&quot;&gt;What is a Provisioning Profile? Part 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.doubleencore.com/2013/04/what-is-a-provisioning-profile-part-2/&quot;&gt;What is a Provisioning Profile? Part 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://tanqisen.github.io/blog/2013/02/27/ios-push-apns/&quot;&gt;一步一步实现iOS应用PUSH功能&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/7426657603090294680/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/7426657603090294680' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/7426657603090294680'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/7426657603090294680'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/08/ios-provisioning-profile.html' title='[iOS]  iOS开发涉及到的Certificate, Provisioning Profile'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-1192371697200185347</id><published>2014-07-17T19:58:00.001-07:00</published><updated>2014-07-17T19:58:31.773-07:00</updated><title type='text'>SSL certificate</title><content type='html'>记点笔记&lt;br /&gt;
什么是SSL? https协议如运作：&lt;br /&gt;
http://www.tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html&lt;br /&gt;
&lt;br /&gt;
检查你的server上的SSL certificate是否有效：&lt;br /&gt;
http://www.digicert.com/help/&lt;br /&gt;
&lt;br /&gt;
创立一个self-signed ssl certificate:&lt;br /&gt;
http://www.akadia.com/services/ssh_test_certificate.html
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/1192371697200185347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/1192371697200185347' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/1192371697200185347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/1192371697200185347'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/07/ssl-certificate.html' title='SSL certificate'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-6726481196837352102</id><published>2014-05-21T21:36:00.004-07:00</published><updated>2014-08-05T15:52:54.590-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><title type='text'>[git] 建立以及使用Git的bare repo</title><content type='html'>git repo分为bare和non-bare两种. non-bare repo最最常见, 它包括一个working tree(你提交到这个git repo里的文件和目录结构)以及一个.git文件夹(其中有各种git系统文件). 而bare repo仅仅有系统文件. 一般在git server上,所有的repo都是以bare形式存在的. 通常除了admin以外,大家是不需要和bare repo打交道的. 
&lt;br /&gt;
&lt;br /&gt;
不过事事无绝对, 我就在工作中遇到这样的一个问题需要和bare repo打交道: 我的所有源代码都放在一个远端的git的repo(比如放在github上), 可是由于某些缘故我或者不能或者不愿意在我工作环境里直接和github上的repo同步. 一个折衷的方案就是在一台自己的server上建立这个github上的repo, 然后在我的工作环境中首先和server上得 repo同步, 然后再登陆到server上把server里地repo和github上的repo同步.&lt;br /&gt;
这样造成的问题就是server上的repo必须得是bare. 如果它含有working tree, 那么就算将server上的repo里的.git目录作为upstream加入, pull的时候没有问题, 但push的时候也会有问题
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ git remote add some_remote_name ssh://apc999@myhost/home/apc999/some-repo/.git
$ git pull some_remote_name master
.. works file ...
$ git push --set-upstream ssh://apc999@myhost/home/apc999/some-repo/.git master
...
 ! [remote rejected] master -&amp;gt; master (branch is currently checked out)
error: failed to push some refs to &#39;/home/apc999/some-repo&#39;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
如何使用bare repo&lt;/h3&gt;
&lt;h4&gt;
1 建立一个bare的git repo&lt;/h4&gt;
&lt;pre class=&quot;code&quot;&gt;$ git clone --bare my_project_on_github my-project.git&lt;/pre&gt;
注意上面命令和普通git clone不一样的地方在于参数--bare. 普通的git clone命令会生成一个working tree和.git文件夹, 而--bare这样复制出来的bare repo就不包括working tree. 
&lt;br /&gt;
&lt;h4&gt;
2 bare和
non-bare repo的转换&lt;/h4&gt;
比如你的/home/apc999/my-project是一个git working tree
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ cd /home/apc999/my-project
$ git config --bool core.bare true&lt;/pre&gt;
&lt;h4&gt;
3 更新bare repo&lt;/h4&gt;
注意, 在一个bare repo里, 不能使用git pull来更新这个repo. 而需要使用git fetch</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/6726481196837352102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/6726481196837352102' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/6726481196837352102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/6726481196837352102'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/05/gitgitupstream-remotepushpull.html' title='[git] 建立以及使用Git的bare repo'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-5868718717133043158</id><published>2014-04-20T15:15:00.002-07:00</published><updated>2014-04-20T15:37:26.789-07:00</updated><title type='text'>小米盒子使用记录</title><content type='html'>新拿到小米盒子, 记录并分享一下装机和使用心得.
&lt;br /&gt;
&lt;h3&gt;
开箱照&lt;/h3&gt;
&lt;br /&gt;
简朴的可回收硬纸壳包装, 电源, 连接电视的HDMI, 遥控器. 小米盒子说白了其实就是一个跑Android的小电脑, 只是它需要使用电视作为显示器.
&lt;br /&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGiy28ugQb9XxSyf2u2Xdio_O2r7upBy5giCQc_vSWi2Rb09O9gWWM-ZqYUTF9jSw5sspz4KRVFZ1P7iavyX3efCbZNdku-xOLONSNqR3pV4RJaDTs8T2bAnYHwTJNJPZxbYAKkA/s1600/IMG_20140415_204928.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGiy28ugQb9XxSyf2u2Xdio_O2r7upBy5giCQc_vSWi2Rb09O9gWWM-ZqYUTF9jSw5sspz4KRVFZ1P7iavyX3efCbZNdku-xOLONSNqR3pV4RJaDTs8T2bAnYHwTJNJPZxbYAKkA/s200/IMG_20140415_204928.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb1Jf8Tp98Iqc1KXJ8vaFLuH41eOGY_jBw99dnsZAAf7echxfb4FqhTznS8rjBECvcieQy0xeb9WT_QNp7X9n4WZaN3N1iP4o-6CMHSmTJdxfoEqiHFm12fAQBxUj38pMTH_b_0g/s1600/IMG_20140415_205323.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjb1Jf8Tp98Iqc1KXJ8vaFLuH41eOGY_jBw99dnsZAAf7echxfb4FqhTznS8rjBECvcieQy0xeb9WT_QNp7X9n4WZaN3N1iP4o-6CMHSmTJdxfoEqiHFm12fAQBxUj38pMTH_b_0g/s200/IMG_20140415_205323.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h3&gt;
推荐App&lt;/h3&gt;
小米盒子有一个micro-USB接口. 所以接上U盘后, 就可以直接读取并安装U盘里存储的apk文件. 如下图所示:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPSs-NF_VmFBfAbD2B5xUDyGgaeo9TvjrRS-60hOE-GEcmoJivxOhC7xS13Rk4chR8X6T_xlS8dtrmLHuXeNNJyVkZLU27URjlPEZ5C2BYPdDfHEi1jIysddQd432pEyODBihGOA/s1600/IMG_20140420_110701.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPSs-NF_VmFBfAbD2B5xUDyGgaeo9TvjrRS-60hOE-GEcmoJivxOhC7xS13Rk4chR8X6T_xlS8dtrmLHuXeNNJyVkZLU27URjlPEZ5C2BYPdDfHEi1jIysddQd432pEyODBihGOA/s320/IMG_20140420_110701.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
这里是些常用的App:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href=&quot;http://wengleong1990.wordpress.com/2014/01/15/%E5%B0%8F%E7%B1%B3%E7%9B%92%E5%AD%90%E6%87%B6%E4%BA%BA%E5%8C%85%E5%90%84%E7%A8%AE%E5%BF%85%E8%A3%9D%E8%BB%9F%E4%BB%B6/&quot;&gt;小米盒子懒人包
&lt;/a&gt;这是一个网友自己组织的百度网盘, 常用装机软件的基本都有了.
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://www.togic.com/livetv&quot;&gt;泰捷视频&lt;/a&gt; 一个包括了很多电视台直播频道以及电影点播的App.
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://www.91vst.com/&quot;&gt;VST全聚合&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://www.tuziv.tv/&quot;&gt;兔子桌面&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://app.shafa.com/&quot;&gt;沙发管家&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h3&gt;
参考&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://wengleong1990.wordpress.com/2013/12/25/%E5%B0%8F%E7%B1%B3%E7%9B%92%E5%AD%90%E4%BB%8B%E7%B4%B9%E3%80%81%E8%B6%8A%E7%8D%84%E6%95%99%E5%AD%B8%E5%8F%8A%E5%BF%85%E8%A3%9D%E8%BB%9F%E4%BB%B6%E3%80%81%E6%BE%B3%E9%96%80%E5%9C%B0%E5%8D%80%E5%AF%A6/&quot;&gt;新小米盒子介紹、越獄教學及必裝軟件、澳門地區實際評測&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://steachs.com/archives/3196&quot;&gt;如何在小米盒子安裝第三方工具及 APP？讓它發揮更多作用&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.kocpc.com.tw/archives/4737&quot;&gt;新小米盒子 台灣區使用全攻略！ 安裝應用、Root、購買 三個願望一次達成！&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.rockfu.net/blog/2014/03/computer/hardware/%E5%B0%8F%E7%B1%B3%E7%9B%92%E5%AD%902%E9%A6%99%E6%B8%AF%E9%AB%94%E9%A9%97%E8%A8%98/&quot;&gt;小米盒子2香港體驗記&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/5868718717133043158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/5868718717133043158' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5868718717133043158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5868718717133043158'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/04/blog-post.html' title='小米盒子使用记录'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGiy28ugQb9XxSyf2u2Xdio_O2r7upBy5giCQc_vSWi2Rb09O9gWWM-ZqYUTF9jSw5sspz4KRVFZ1P7iavyX3efCbZNdku-xOLONSNqR3pV4RJaDTs8T2bAnYHwTJNJPZxbYAKkA/s72-c/IMG_20140415_204928.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-3296796788326257817</id><published>2014-04-19T20:33:00.003-07:00</published><updated>2014-04-20T15:22:02.002-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clang"/><category scheme="http://www.blogger.com/atom/ns#" term="MacOS"/><title type='text'>[MacOS] MacOS 10.9(Mavericks)上clang对未知参数报错的问题</title><content type='html'>在MacOS 10.9上用pip安装一个库的时候发现clang报错
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ sudo pip install mysql-python
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -Dversion_info=(1,2,5,&#39;final&#39;,1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/5.6.16/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Os -g -fno-strict-aliasing

clang: error: unknown argument: &#39;-mno-fused-madd&#39; [-Wunused-command-line-argument-hard-error-in-future]

clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: command &#39;cc&#39; failed with exit status 1&lt;/pre&gt;
&lt;h3&gt;
原因&lt;/h3&gt;
XCode 5.1 以后, XCode的默认编译器clang会对所有它不认识的命令行flag报错 
&lt;a href=&quot;http://kaspermunck.github.io/2014/03/fixing-clang-error/&quot;&gt;http://kaspermunck.github.io/2014/03/fixing-clang-error/&lt;/a&gt;&lt;br /&gt;
&lt;h3&gt;
解决方法&lt;/h3&gt;
参照这里给出的方案:
&lt;a href=&quot;http://stackoverflow.com/questions/22313407/clang-error-unknown-argument-mno-fused-madd-python-package-installation-fa&quot;&gt;http://stackoverflow.com/questions/22313407/clang-error-unknown-argument-mno-fused-madd-python-package-installation-fa&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
在运行安装命令的时候先修改CFLAGS和CPPFLAGS
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ export CFLAGS=-Qunused-arguments
$ export CPPFLAGS=-Qunused-arguments
$ sudo -E pip install mysql-python&lt;/pre&gt;
注意由于安装过程中需要sudo, 所以为了让环境变量传递过去, 需要加上-E选项
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/3296796788326257817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/3296796788326257817' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/3296796788326257817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/3296796788326257817'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/04/macos-macos-109mavericksclang.html' title='[MacOS] MacOS 10.9(Mavericks)上clang对未知参数报错的问题'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-5916950815763174571</id><published>2014-04-19T09:48:00.000-07:00</published><updated>2014-04-19T10:02:15.801-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache"/><category scheme="http://www.blogger.com/atom/ns#" term="MacOS"/><title type='text'>[MacOS] 在MacOS 10.9(Mavericks)设置Apache/PHP</title><content type='html'>本来想自己写的. 但这篇实在写的太详实太好了.
&lt;br /&gt;
&lt;a href=&quot;http://www.coolestguidesontheplanet.com/downtown/get-apache-mysql-php-and-phpmyadmin-working-osx-109-mavericks&quot;&gt;http://www.coolestguidesontheplanet.com/downtown/get-apache-mysql-php-and-phpmyadmin-working-osx-109-mavericks&lt;/a&gt;
&lt;br /&gt;
就捡几个重点的供我自己查询吧:
&lt;br /&gt;
&lt;h3&gt;
启动/关闭/重启apache server&lt;/h3&gt;
&lt;pre class=&quot;code&quot;&gt;$ sudo apachectl start
$ sudo apachectl stop
$ sudo apachectl restart&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
几个重要的文件和路径&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;设置文件
&lt;ul&gt;
&lt;li&gt;
httpd的全局设置文件:/etc/apache2/httpd.conf&lt;/li&gt;
&lt;li&gt;
用户apc999的设置文件:/etc/apache2/users/apc999.conf&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
apache的日志&lt;ul&gt;
&lt;li&gt;/var/log/apache2/error_log&lt;/li&gt;
&lt;li&gt;/var/log/apache2/access_log&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;web路径对应的本地路径
&lt;ul&gt;
&lt;li&gt;http://localhost/ 对应的本地路径 /Library/WebServer/Documents/ &lt;/li&gt;
&lt;li&gt;http://localhost/~apc999 对应本地路径 /Users/apc999/Sites &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/5916950815763174571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/5916950815763174571' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5916950815763174571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5916950815763174571'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/04/macos-macos-109mavericksapachephp.html' title='[MacOS] 在MacOS 10.9(Mavericks)设置Apache/PHP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-6077941370757628027</id><published>2014-02-17T23:20:00.005-08:00</published><updated>2014-02-17T23:23:00.886-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="emacs"/><category scheme="http://www.blogger.com/atom/ns#" term="MacOS"/><title type='text'>[Emacs] Mac OS Terminal中设置Emacs热键</title><content type='html'>由于工作条件的一些限制,我不能在MacOS中之间使用单独的Emacs App而必须要在Terminal里运行Emacs.所以我花时间设置了一下我的Emacs,使的它在Terminal中也可以像在App里一样完美运行.
&lt;br /&gt;
&lt;h3&gt;
最大的障碍来自于Terminal里对于热键的设置&lt;/h3&gt;
&lt;hr /&gt;
在Terminal里设置按键(单独的按键以及组合按键)所激发的xterm key code. 下面这张图是我的设置:
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT-EGlvxn6Fj8W_rbStaLx37CQ35qVQWxryjw4OvjdMSl1sJiTrv4W9wfNF2zQ3lbevwPj9T_w2XCle_rWqNp0Kbiz8KWcdGlDyFbe5rNpCt9M-nZcsIB2s6OdVtRsddqp4JHBFQ/s1600/Screen+Shot+2014-02-17+at+10.57.02+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT-EGlvxn6Fj8W_rbStaLx37CQ35qVQWxryjw4OvjdMSl1sJiTrv4W9wfNF2zQ3lbevwPj9T_w2XCle_rWqNp0Kbiz8KWcdGlDyFbe5rNpCt9M-nZcsIB2s6OdVtRsddqp4JHBFQ/s320/Screen+Shot+2014-02-17+at+10.57.02+PM.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
主要是关于方向键加上ctrl/shift/alt的组合.
&lt;br /&gt;
&lt;h3&gt;
关于xterm key Code:&lt;/h3&gt;
Terminal将按键事件转换成一个xterm key code并发送给当前窗口中运行的shell. 比如Shift加上方向键up被记录成一个code &quot;\033[1;2A&quot;. 这里&quot;\033&quot;其实对应的是Esc键. 
&lt;br /&gt;
关于更多的xterm key code的简介可以从这里获得:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;https://code.google.com/p/mintty/wiki/Keycodes&quot;&gt;https://code.google.com/p/mintty/wiki/Keycodes&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
更加完整的的关于xterm code的reference:&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#PC-Style%20Function%20Keys&quot;&gt;http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#PC-Style%20Function%20Keys&lt;/a&gt;
&lt;/div&gt;
总而言之, 你需要把你需要用到的组合按键设置在Terminal中, 使得Emacs可以收到&lt;br /&gt;
&lt;h3&gt;
剩下的就是对于Emacs里热键的设置&lt;/h3&gt;
&lt;hr /&gt;
Emacs的key mapping系统无比的复杂. 我使用了一种笨办法: 把每一个我关心的热键组合的xterm key code都在input-decode-map里定义成对应的组合键. 比如下面的设置. 这里&quot;\e&quot;相当于&quot;\033&quot;
&lt;br /&gt;
&lt;pre class=&quot;code lang-el&quot;&gt;(define-key input-decode-map &quot;\e[9A&quot; [(meta up)])
(define-key input-decode-map &quot;\e[9B&quot; [(meta down)])
(define-key input-decode-map &quot;\e[9C&quot; [(meta right)])
(define-key input-decode-map &quot;\e[9D&quot; [(meta left)])
(define-key input-decode-map &quot;\e[2A&quot; [(shift up)])
(define-key input-decode-map &quot;\e[2B&quot; [(shift down)])
(define-key input-decode-map &quot;\e[2C&quot; [(shift right)])
(define-key input-decode-map &quot;\e[2D&quot; [(shift left)])
(define-key input-decode-map &quot;\e[10A&quot; [(shift meta up)])
(define-key input-decode-map &quot;\e[10B&quot; [(shift meta down)])
(define-key input-decode-map &quot;\e[10C&quot; [(shift meta right)])
(define-key input-decode-map &quot;\e[10D&quot; [(shift meta left)])&lt;/pre&gt;
&lt;br/&gt;
这样Emacs才能在key stream里识别出来传进来的meta/shift/ctrl等热键. 然后再使用Emacs里的global-set-key来绑定组合到特定的function上, 比如我设置meta加up为backward-paragraph:
&lt;br /&gt;
&lt;pre class=&quot;code lang-el&quot;&gt;(global-set-key [(meta up)] &#39;backward-paragraph)
(global-set-key [(meta down)] &#39;forward-paragraph)
(global-set-key [(meta left)] &#39;backward-word)
(global-set-key [(meta right)] &#39;forward-word)&lt;/pre&gt;

</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/6077941370757628027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/6077941370757628027' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/6077941370757628027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/6077941370757628027'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/02/emacs-mac-os-terminalemacs.html' title='[Emacs] Mac OS Terminal中设置Emacs热键'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhT-EGlvxn6Fj8W_rbStaLx37CQ35qVQWxryjw4OvjdMSl1sJiTrv4W9wfNF2zQ3lbevwPj9T_w2XCle_rWqNp0Kbiz8KWcdGlDyFbe5rNpCt9M-nZcsIB2s6OdVtRsddqp4JHBFQ/s72-c/Screen+Shot+2014-02-17+at+10.57.02+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-1300268811369488456</id><published>2014-02-04T10:07:00.001-08:00</published><updated>2016-05-28T13:31:50.047-07:00</updated><title type='text'>[Linux/Mac] Terminal收到的Control Code和Escape Sequence Code</title><content type='html'>在Linux和Mac里使用Terminal的时候常常会出现按下一个组合键出来一堆奇怪字符的情况. 这通常是由于这个按键组合未被Terminal识别成功. 现在操作系统的Terminal通常已经足够强大, 比如MacOS自带的Terminal以及iTerm等都可以自己设置从按键组合到Control Code或者Escape Sequence Code的映射来传给Shell. 由于我常常被这个问题困扰, 所以写下这篇笔记. 
&lt;br /&gt;
&lt;h3&gt;
何为Ctrol Code和Escape sequence code?&lt;/h3&gt;&lt;hr/&gt;
&lt;p&gt;这里有几篇很不错的讲解&lt;a href=&quot;http://linux.about.com/od/ttl_howto/a/hwtttl08t03.htm&quot;&gt;Text-Terminals on Linux&lt;/a&gt;以及&lt;a href=&quot;http://man7.org/linux/man-pages/man4/console_codes.4.html&quot;&gt;Linux Console Codes&lt;/a&gt;&lt;/p&gt;
基本这是一套沿用多年, 对按键组合编码的方案. 简单说来, Escape Sequence Code就是讲一个按键组合变成以\033(键盘上得Esc键)打头的一串字符. 比如 
&lt;pre&gt;up     \033[A
down   \033[B
right  \033[C
left   \033[D
shift+up     \033[1;2A
shift+down   \033[1;2B
shift+right  \033[1;2C
shift+left   \033[1;2D
meta+up      \033[1;4A
meta+down    \033[1;4B
meta+right   \033[1;4C
meta+left    \033[1;4D
ctrl+up     \033[1;5A
ctrl+down   \033[1;5B
ctrl+right  \033[1;5C
ctrl+left   \033[1;5D
&lt;/pre&gt;
不难看出其中的一些个规律 (Alt: 1, Ctrl: 2, Shift: 4, ...). 更多的code可以参考:

&lt;a href=&quot;https://code.google.com/p/mintty/wiki/Keycodes&quot;&gt;Key Codes&lt;/a&gt;以及
&lt;a href=&quot;http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#PC-Style%20Function%20Keys&quot;&gt;xterm code:&lt;/a&gt;

&lt;h3&gt;
如何得到一个按键(或者按键组合)当前对应的Escape Sequence Code&lt;/h3&gt;&lt;hr/&gt;
在MacOS的terminal里可以很方便的
&lt;br /&gt;
&lt;pre&gt;Keystroke to Type Expected Output (for VT220 mapping)
ctrl-V backspace ^?
ctrl-V delete ^[[3~
ctrl-V ctrl-H ^H&lt;/pre&gt;
&lt;br /&gt;
或者使用sed命令
&lt;pre&gt;$ sed -n l
&lt;/pre&gt;

在Linux的terminal下， 运行xev， 桌面角落里会出现一个小对话框。 同时terminal里会输出当前的事件， 比如按下了哪个键，松开了哪个键， 进而可以获得这些键的code
&lt;br /&gt;
&lt;h3&gt;&lt;hr/&gt;
在Emacs里如何使用键映射(keymap)&lt;/h3&gt;
这是我写的一篇笔记&lt;a href=&quot;http://apc999.blogspot.com/2014/02/emacs-mac-os-terminalemacs.html&quot;&gt;Mac OS Terminal中设置Emacs热键&lt;/a&gt;&lt;br /&gt;
http://blog.csdn.net/joans123/article/details/7562212&lt;br /&gt;
&lt;a href=&quot;http://www.masteringemacs.org/articles/2011/02/08/mastering-key-bindings-emacs/&quot;&gt;Mastering Key Bindings In Emacs&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/1300268811369488456/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/1300268811369488456' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/1300268811369488456'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/1300268811369488456'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/02/linuxmac-terminalcontrol-codeescape.html' title='[Linux/Mac] Terminal收到的Control Code和Escape Sequence Code'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-693352238884585853</id><published>2014-01-02T10:26:00.001-08:00</published><updated>2014-01-02T15:28:22.948-08:00</updated><title type='text'>[Linux] aptitude vs. apt-get</title><content type='html'>&lt;h3&gt;
功能上的区别：&lt;/h3&gt;
http://www.debian.org/doc/manuals/debian-faq/ch-pkgtools.en.html#s-aptitude

&lt;br /&gt;
&lt;h3&gt;
彩蛋上的区别：&lt;/h3&gt;
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ apt-get moo
         (__) 
         (oo) 
   /------\/ 
  / |    ||   
 *  /\---/\ 
    ~~   ~~   
....&quot;Have you mooed today?&quot;...&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;$ aptitude moo
There are no Easter Eggs in this program.&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/693352238884585853/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/693352238884585853' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/693352238884585853'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/693352238884585853'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2014/01/linux-aptitude-vs-apt-get.html' title='[Linux] aptitude vs. apt-get'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-4037226202170870244</id><published>2013-12-10T23:30:00.001-08:00</published><updated>2014-01-12T18:00:00.051-08:00</updated><title type='text'>[C++] 纳秒(ns)级精度的计时 </title><content type='html'>在调试以及优化高性能的程序中,常需要对一小段程序计时. 普通的clock函数精度达不到ns级别.这里记录一下几种可以得到ns级高精度的计时方法. 
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
使用clock_gettime&lt;/h2&gt;
&lt;hr /&gt;
C++ 中可以使用clock_gettime, 得到
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt; 
    clock_gettime(CLOCK_REALTIME, &amp;amp;time1);
    ... your code to profile ...
    clock_gettime(CLOCK_REALTIME, &amp;amp;time2);
&lt;/pre&gt;
&lt;h2&gt;
使用rdtscp&lt;/h2&gt;
&lt;hr /&gt;
如果想得到更高精度的计时, 比如以CPU的时钟周期为单位, 
对于比较新的Intel CPU, 可以使用rdtscp指令来获得当前CPU时钟周期读数.比较前后两次读数就可以得到以时钟周期为单位的逝去时间.

&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;// rdtscp ensure serialization, supported by newer CPUs
static __inline__ uint64_t rdtscp(void)
{
    uint32_t hi, lo;
    __asm__ __volatile__ (&quot;rdtscp&quot; : &quot;=a&quot;(lo), &quot;=d&quot;(hi));
    return ((uint64_t)lo | ((uint64_t)hi &amp;lt;&amp;lt; 32);
}&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/4037226202170870244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/4037226202170870244' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/4037226202170870244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/4037226202170870244'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/12/c-ns.html' title='[C++] 纳秒(ns)级精度的计时 '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-8085878167408291607</id><published>2013-10-30T11:06:00.001-07:00</published><updated>2013-10-30T11:06:22.698-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><category scheme="http://www.blogger.com/atom/ns#" term="sublime text"/><title type='text'>Sublime Text 3 插件开发 (未完)</title><content type='html'>Sublime Text (以下简称ST)提供了一个python的API接口. 在这个接口之上,用户可以开发自己的插件. 
完整的ST3 API可以参见这里
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;http://www.sublimetext.com/docs/3/api_reference.html&quot;&gt;http://www.sublimetext.com/docs/3/api_reference.html&lt;/a&gt;
&lt;/div&gt;
如果你想仔细研究这些API的定义以及ST自带Python模块的细节, 可以在ST下找到这个python API的文件. MacOS上, 
在&lt;span class=&quot;code&quot;&gt;/Applications/Sublime Text.app/Contents/MacOS/&lt;/span&gt;目录底下, 有2个文件
&lt;span class=&quot;code&quot;&gt;sublime.py&lt;/span&gt;和&lt;span class=&quot;code&quot;&gt;sublime_plugin.py&lt;/span&gt;. 

&lt;br /&gt;
&lt;h3&gt;
从一个最简单的plugin开始&lt;/h3&gt;
&lt;hr /&gt;
&lt;pre class=&quot;code&quot;&gt;import sublime, sublime_plugin
class HelloWorldCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, 0, &quot;Hello, World!&quot;)&lt;/pre&gt;
将其命名为&quot;hello_world.py&quot;以后, 存在&lt;span class=&quot;code&quot;&gt;Packages/User&lt;/span&gt;底下. 这个plugin就只干一件事儿, 当你在ST3自带的python console里(可以通过Ctrl+`呼出)运行
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;view.run_command(&quot;hello_world&quot;)&lt;/pre&gt;
就会在你正在编辑的文件里添加一段&quot;Hellow, World!&quot;. 这里注意ST的命名习惯. 这个类的名字叫HellowWorld, console中ST会将其命名为hellow_world, 从而使用&lt;span class=&quot;code&quot;&gt;run_command(&quot;hello_world&quot;)&lt;/span&gt;来运行之.</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/8085878167408291607/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/8085878167408291607' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8085878167408291607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8085878167408291607'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/10/sublime-text-3.html' title='Sublime Text 3 插件开发 (未完)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-8314845811294911500</id><published>2013-10-13T19:58:00.000-07:00</published><updated>2013-10-13T20:31:59.381-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="emacs"/><category scheme="http://www.blogger.com/atom/ns#" term="sublime"/><title type='text'>在Sublime Text 3 中使用emacs键位</title><content type='html'>我的目标很简单: 就是把sublime text的操作折腾的和emacs 一样&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;
第一步, 安装sublemacspro.&lt;/h1&gt;
&lt;br /&gt;
参见这里: https://github.com/grundprinzip/sublemacspro&lt;br /&gt;
基本上最基本的emacs操作比如ctrl-w, alt-w, ctrl-k, ctrl-y 等就有了.
&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;
第二步, 增加一些我自己管用的keybinding&lt;/h1&gt;
我是通过定制PreferencesKey-&amp;gt;Binding-&amp;gt;User来增加以下我自己习惯的键位:
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;[
 { &quot;keys&quot;: [&quot;ctrl+f&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;pages&quot;, &quot;forward&quot;: true} },
 { &quot;keys&quot;: [&quot;ctrl+b&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;pages&quot;, &quot;forward&quot;: false} },
 { &quot;keys&quot;: [&quot;shift+ctrl+f&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;pages&quot;, &quot;forward&quot;: true, &quot;extend&quot;: true} },
 { &quot;keys&quot;: [&quot;shift+ctrl+b&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;pages&quot;, &quot;forward&quot;: false, &quot;extend&quot;: true} },

 { &quot;keys&quot;: [&quot;alt+down&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;stops&quot;, &quot;empty_line&quot;: true, &quot;forward&quot;: true} },
 { &quot;keys&quot;: [&quot;alt+up&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;stops&quot;, &quot;empty_line&quot;: true, &quot;forward&quot;: false} },
 { &quot;keys&quot;: [&quot;shift+alt+down&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;stops&quot;, &quot;empty_line&quot;: true, &quot;forward&quot;: true, &quot;extend&quot;: true} },
 { &quot;keys&quot;: [&quot;shift+alt+up&quot;], &quot;command&quot;: &quot;move&quot;, &quot;args&quot;: {&quot;by&quot;: &quot;stops&quot;, &quot;empty_line&quot;: true, &quot;forward&quot;: false, &quot;extend&quot;: true} },

 { &quot;keys&quot;: [&quot;ctrl+c&quot;, &quot;ctrl+c&quot;], &quot;command&quot;: &quot;build&quot;},
]&lt;/pre&gt;

&lt;h1&gt;参考:&lt;/h1&gt;
关于key binding 的commands&lt;br /&gt;
http://www.sublimetext.com/docs/commands&lt;br /&gt;
如何写一个plugin &lt;br /&gt;
http://sublimetext.info/docs/en/extensibility/plugins.html &lt;br /&gt;
st3的api &lt;br /&gt;
http://www.sublimetext.com/docs/3/api_reference.html&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/8314845811294911500/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/8314845811294911500' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8314845811294911500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8314845811294911500'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/10/sublime-text.html' title='在Sublime Text 3 中使用emacs键位'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-305170575818124623</id><published>2013-09-25T08:33:00.004-07:00</published><updated>2013-09-25T08:40:31.704-07:00</updated><title type='text'>[Math] 有趣的无穷数列求和</title><content type='html'>&lt;a href=&quot;http://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF&quot;&gt;1 + 2 + 3 + 4 + ... = -1/12&lt;/a&gt;&lt;br /&gt;
所有自然数之和为-1/12
&lt;br /&gt;
这个在量子物理和弦论里有应用, 据说12个维度就是这么来的&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/1_%E2%88%92_2_%2B_3_%E2%88%92_4_%2B_%C2%B7_%C2%B7_%C2%B7&quot;&gt;1 - 2 + 3 - 4 + ... = 1/4&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://en.wikipedia.org/wiki/1_%2B_2_%2B_4_%2B_8_%2B_%C2%B7_%C2%B7_%C2%B7&quot;&gt;1 + 2 + 4 + 8 + ... = -1 &lt;/a&gt;
&lt;br /&gt;
或者等价于: 所有偶数和为-2&lt;br /&gt;
其实这个可以自己推出来&lt;br /&gt;
&lt;br /&gt;
高斯他老人家就推了一堆这种神奇的结论</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/305170575818124623/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/305170575818124623' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/305170575818124623'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/305170575818124623'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/09/math.html' title='[Math] 有趣的无穷数列求和'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-5181017995414868541</id><published>2013-07-12T10:35:00.002-07:00</published><updated>2014-05-31T09:57:17.271-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><title type='text'>[git] 一些git的使用小技巧</title><content type='html'>记录一下我在平时使用git时候的一些小技巧. 关于git更全面的使用介绍(比如整个工作的流程 ), 参见我之前写的的&lt;a href=&quot;http://apc999.blogspot.com/2010/07/git.html&quot;&gt;&quot;git 笔记&quot;&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;查看my_file和之前版本的区别
&lt;pre class=&quot;code&quot;&gt;$ git diff HEAD my_file #latest version checked-in
$ git diff HEAD~1 my_file #previous of the latest version
$ git diff HEAD~2 my_file #previous ^ 2 of the latest &lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
跳过&lt;span class=&quot;code&quot;&gt;git add&lt;/span&gt;而直接commit当前修改过的文件中那些被track的
&lt;pre class=&quot;code&quot;&gt;$ git commit . -m &quot;foo&quot;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
把track的文件中所有被修改的都加入index
&lt;pre class=&quot;code&quot;&gt;$ git add -u&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
和HEAD比较, 当前工作目录下有那些具体的修改(可能跨几个文件)
&lt;pre class=&quot;code&quot;&gt;$ git diff HEAD&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
查看每次commit都改动了哪些文件
&lt;pre class=&quot;code&quot;&gt;$ git log --stat&lt;/pre&gt;
查看上一次commit有哪些文件被改动
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ git log -n 1 --stat&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
将当前branch rebase到本地的master branch上. 也就是当前branch的local commit会出现在commit log的最后
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ git rebase master&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
指定从origin/master 来更新
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ git rebase origin master&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
设置gitignore_global
建立&lt;span class=&quot;code&quot;&gt;~/.gitignore_global&lt;/span&gt;, 然后执行
&lt;pre class=&quot;code&quot;&gt;$ git config --global core.excludesfile ~/.gitignore_global&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
查看当前git的config
&lt;pre class=&quot;code&quot;&gt;$ git config -l&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
设定当前git repository的email
&lt;pre class=&quot;code&quot;&gt;$ git config user.email &quot;apc999@youremail.com&quot;&lt;/pre&gt;
查看当前git repository的email
&lt;pre class=&quot;code&quot;&gt;$ git config user.email&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/5181017995414868541/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/5181017995414868541' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5181017995414868541'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5181017995414868541'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/07/git.html' title='[git] 一些git的使用小技巧'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-2957081917368713091</id><published>2013-05-22T08:24:00.000-07:00</published><updated>2013-05-22T08:24:20.461-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><category scheme="http://www.blogger.com/atom/ns#" term="gcc"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><category scheme="http://www.blogger.com/atom/ns#" term="MacOS"/><title type='text'>查看gcc预定义的macro</title><content type='html'>在Linux或者MacOS的terminal里运行:
&lt;pre class=&quot;code&quot;&gt;$ cpp -dM /dev/null
#define __DBL_MIN_EXP__ (-1021)
#define __UINT_LEAST16_MAX__ 65535
#define __FLT_MIN__ 1.17549435082228750797e-38F
#define __UINT_LEAST8_TYPE__ unsigned char
#define __INTMAX_C(c) c ## L
#define __CHAR_BIT__ 8
#define __UINT8_MAX__ 255
#define __WINT_MAX__ 4294967295U
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __SIZE_MAX__ 18446744073709551615UL
#define __WCHAR_MAX__ 2147483647
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __DBL_DENORM_MIN__ ((double)4.94065645841246544177e-324L)
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
#define __FLT_EVAL_METHOD__ 0
#define __unix__ 1
...&lt;/pre&gt;

一般说来Linux平台上会预定义__linux__, 而MacOS会预定义__APPLE__</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/2957081917368713091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/2957081917368713091' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/2957081917368713091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/2957081917368713091'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/05/gccmacro.html' title='查看gcc预定义的macro'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-8777283722277460454</id><published>2013-04-13T09:20:00.002-07:00</published><updated>2013-04-13T09:23:04.873-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="pthread"/><category scheme="http://www.blogger.com/atom/ns#" term="TLS"/><title type='text'>[C] 线程局部存储 (thread-local storage)</title><content type='html'>GCC 支持使用线程局部存储(TLS)来方便多线程的编程.通俗来说, TLS就是一些看起来global的变量, 但是它实际上是per-thread的&lt;br /&gt;
使用TLS很简单,只需要用__thread关键字来修饰一个&quot;全局变量&quot;,比如下面例子里的tid. 它在不同的thread里被输出的时候就是输出不同的值

&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;pthread.h&amp;lt;
#define NUM_THREADS     5

&lt;span style=&quot;color: red;&quot;&gt;__thread long tid;
&lt;/span&gt;
void print_tid() {
    printf(&quot;Hello World! It&#39;s me, thread #%ld!\n&quot;, tid);
}

void *run_thread(void *threadid)
{
&lt;span style=&quot;color: red;&quot;&gt;    tid = (long)threadid;
&lt;/span&gt;    print_tid();
    pthread_exit(NULL);
}

int main (int argc, char *argv[])
{
    pthread_t threads[NUM_THREADS];
    int rc;
    long t;
    for(t=0; t&amp;lt;NUM_THREADS; t++){
        rc = pthread_create(&amp;amp;threads[t], NULL, run_thread, (void *)t);
        if (rc){
            printf(&quot;ERROR; return code from pthread_create() is %d\n&quot;, rc);
            exit(-1);
        }
    }

    /* Last thing that main() should do */
    pthread_exit(NULL);
}&lt;/pre&gt;
运行
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ gcc test_tls.c
$ ./a.out 
Hello World! It&#39;s me, thread #0!
Hello World! It&#39;s me, thread #1!
Hello World! It&#39;s me, thread #2!
Hello World! It&#39;s me, thread #3!
Hello World! It&#39;s me, thread #4!&lt;/pre&gt;
&lt;h4&gt;
参考&lt;/h4&gt;
&lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc/Thread_002dLocal.html&quot;&gt;GCC对TLS的支持&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/8777283722277460454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/8777283722277460454' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8777283722277460454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8777283722277460454'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/04/c-thread-local-storage.html' title='[C] 线程局部存储 (thread-local storage)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-8928815993655573440</id><published>2013-04-11T12:27:00.002-07:00</published><updated>2013-09-26T19:43:06.707-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="C++"/><title type='text'>[C/C++] 随机数</title><content type='html'>&lt;h4&gt;
C里的RAND&lt;/h4&gt;
&lt;hr /&gt;
&lt;pre class=&quot;code&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;    
#include &amp;lt;stdio.h&amp;gt;    

int main()    
{    
    srand(time(0));   
    printf(&quot;%d\n&quot;, rand());    
    return 0;    
}&lt;/pre&gt;
&lt;h4&gt;
使用C++11 里的Mersenne Twister随机数&lt;/h4&gt;
&lt;hr /&gt;
C++11支持的Mersenne Twister可以非常轻量级的快速生成大量随机数.适合在benchmark的时候使用
&lt;pre class=&quot;code&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;random&amp;gt;
main() {    
    std::mt19937_64 rng;
    // 使用系统时间生成随机数种子
    rng.seed(static_cast&amp;lt;unsigned int&amp;gt;(std::time(0)));

    // 生成32-bit的随机整数
    std::cout &amp;lt;&amp;lt; rng() &amp;lt;&amp;lt; std::endl;

    // 生成 1到255之间(包括1和255) 的随机数
    std::uniform_int_distribution&amp;lt;int&amp;gt; unif(1, 255);
    std::cout &amp;lt;&amp;lt; unif(rng)&amp;lt;&amp;lt; std::endl;

    // 以概率0.3生成true, 0.7生成false
    std::bernoulli_distribution bern(0.3);
    std::cout &amp;lt;&amp;lt; bern(rng) &amp;lt;&amp;lt; std::endl;

}
&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/8928815993655573440/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/8928815993655573440' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8928815993655573440'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/8928815993655573440'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/04/blog-post.html' title='[C/C++] 随机数'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-7100391207451876434</id><published>2013-03-30T07:59:00.003-07:00</published><updated>2013-03-30T08:08:07.803-07:00</updated><title type='text'>code style</title><content type='html'>&lt;h4&gt;
Python的code style&lt;/h4&gt;
Python官方约定的风格&lt;a href=&quot;http://www.python.org/dev/peps/pep-0008/&quot;&gt;PEP 8 -- Style Guide for Python Code&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
C++的code style&lt;/h4&gt;
C++并无官方约定的风格。 我一般会遵从 Google 的&lt;a href=&quot;http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml&quot;&gt;C++ style guide&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/7100391207451876434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/7100391207451876434' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/7100391207451876434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/7100391207451876434'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/03/code-style.html' title='code style'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-1293798886000812586</id><published>2013-03-27T15:00:00.005-07:00</published><updated>2013-03-30T08:06:14.824-07:00</updated><title type='text'>在MacOS和Linux上使用Ramdisk</title><content type='html'>&lt;h4&gt;
在Linux上使用Ramdisk&lt;/h4&gt;
&lt;hr /&gt;
我使用如下脚本来生成一个大小可设定的tmpfs作为ramdisk
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;#!/bin/bash

TMPFS_SIZE=12G

mkdir -p ./ramdisk
sudo umount ./ramdisk &amp;gt;&amp;amp; /dev/null
sudo mount -t tmpfs -o size=$TMPFS_SIZE,mode=0775,gid=binfan tmpfs ./ramdisk&lt;/pre&gt;
&lt;h4&gt;
在MacOS上使用Ramdisk&lt;/h4&gt;
&lt;hr /&gt;
创建一个Ramdisk
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ hdiutil attach -nomount ram://1165430
/dev/disk2                                           
$ diskutil erasevolume HFS+ &quot;ramdisk&quot; /dev/disk2
Started erase on disk2
Unmounting disk
Erasing
Initialized /dev/rdisk2 as a 569 MB HFS Plus volume
Mounting disk
Finished erase on disk2 ramdisk&lt;/pre&gt;
然后使用df就可以看见这个device了
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;$ df
Filesystem                        512-blocks      Used Available Capacity  iused    ifree %iused  Mounted on
/dev/disk0s2                       818359360 273993824 543853536    34% 34313226 67981692   34%   /
devfs                                    381       381         0   100%      660        0  100%   /dev
map -hosts                                 0         0         0   100%        0        0  100%   /net
map auto_home                              0         0         0   100%        0        0  100%   /home
/dev/disk0s4                       156733432  41530424 115203008    27%   108561 57608399    0%   /Volumes/BOOTCAMP
localhost:/AI1XeO7VNLFdFPonF9OexW  818359360 818359360         0   100%        0        0  100%   /Volumes/MobileBackups
/dev/disk1s1s2                         35040     35040         0   100%     8758        0  100%   /Volumes/HTC Sync Manager
&lt;span style=&quot;color: red;&quot;&gt;/dev/disk2                           1165424     27376   1138048     3%     3420   142256    2%   /Volumes/ramdisk&lt;/span&gt;&lt;/pre&gt;
不用的时候在Finder里面弹出这个设备就可以了.</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/1293798886000812586/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/1293798886000812586' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/1293798886000812586'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/1293798886000812586'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/03/macos-ramdisk.html' title='在MacOS和Linux上使用Ramdisk'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203140.post-5378430656073851510</id><published>2013-03-03T21:06:00.001-08:00</published><updated>2013-03-03T21:06:43.139-08:00</updated><title type='text'>Memory barrier, volatile, cache coherency</title><content type='html'>&lt;a href=&quot;http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/memory-barriers.txt?id=HEAD&quot;&gt;Linux Kernel关于memory barrier的介绍&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;volatile&lt;/span&gt;会强制在你的code里, 每次都re-read该变量值. 但是它不能控制这个值的来源---可能从memory中读入, 也可能因为你的code刚刚访问过这个变量从而从cache中读入而不是memory. 
&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/558848/can-i-force-cache-coherency-on-a-multicore-x86-cpu</content><link rel='replies' type='application/atom+xml' href='http://apc999.blogspot.com/feeds/5378430656073851510/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8203140/5378430656073851510' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5378430656073851510'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8203140/posts/default/5378430656073851510'/><link rel='alternate' type='text/html' href='http://apc999.blogspot.com/2013/03/memory-barrier-volatile-cache-coherency.html' title='Memory barrier, volatile, cache coherency'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/11341747245547226513</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>