<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>刘氏</title>
 <link href="http://jks-liu.github.io/" rel="self"/>
 <link href="http://jks-liu.github.io"/>
 <updated>2021-12-06T14:49:28+00:00</updated>
 <id>http://jks-liu.github.io</id>
 <author>
   <name>Jks Liu</name>
   <email>chinatianma@gmail.com</email>
 </author>

 
 <entry>
   <title>C99中的_Bool类型</title>
   <link href="http://jks-liu.github.io/_bool-type-in-c99"/>
   <updated>2015-03-21T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/_bool-type-in-c99</id>
   <content type="html">
&lt;p&gt;在读&lt;em&gt;SDCC Compiler User Guide&lt;/em&gt;的时候读到下面一段：&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bit&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sbit&lt;/code&gt; types now consistently behave like the C99 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_Bool&lt;/code&gt; type with respect to type conversion. The most
common incompatibility resulting from this change is related to bit toggling idioms, e.g.:&lt;/p&gt;

  &lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;bit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/* equivalent to b=1 instead of toggling b */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;cm&quot;&gt;/* toggles b */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;  &lt;/div&gt;

  &lt;p&gt;In previous versions, both forms would have toggled the bit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;一直不明白说的什么意思，今天终于茅塞顿开。&lt;/p&gt;

&lt;p&gt;首先，我们需要知道以下事实：&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;任何非零的值赋值给&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_Bool&lt;/code&gt;类型的变量&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;都会得到值1，而不会像其它&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unsigned&lt;/code&gt;类型的变量一样截取；&lt;/li&gt;
  &lt;li&gt;一元操作符&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~&lt;/code&gt;会对其操作数进行整数提升。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;所以，即使&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;的值是1，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~b&lt;/code&gt;首先会对&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;进行整数提升，再取反，结果肯定是一个非零值，在赋值给&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;，最终&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;的值还是1。&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>阅读笔记，2015年01月</title>
   <link href="http://jks-liu.github.io/reading-notes-jan-2015"/>
   <updated>2015-01-10T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/reading-notes-jan-2015</id>
   <content type="html">
&lt;h2 id=&quot;目录-&quot;&gt;目录 &lt;!-- CONTENTS --&gt;&lt;/h2&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#目录-&quot; id=&quot;markdown-toc-目录-&quot;&gt;目录 &lt;!-- CONTENTS --&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#jan10&quot; id=&quot;markdown-toc-jan10&quot;&gt;10 Jan&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#putty-configuration&quot; id=&quot;markdown-toc-putty-configuration&quot;&gt;I. 配置PuTTY&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;jan10&quot;&gt;10 Jan&lt;/h2&gt;

&lt;h3 id=&quot;putty-configuration&quot;&gt;I. 配置PuTTY&lt;/h3&gt;

&lt;p&gt;原文：&lt;a href=&quot;http://blog.sanctum.geek.nz/putty-configuration/&quot;&gt;PuTTY configuration&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;由于历史的原因，PuTTY的默认配置不是很好用。上文提到了了几个最重要的配置，并介绍了其原理以及修改方法。&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Emacs正则表达式中的换行</title>
   <link href="http://jks-liu.github.io/new-line-in-regular-expression-of-emacs"/>
   <updated>2015-01-10T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/new-line-in-regular-expression-of-emacs</id>
   <content type="html">
&lt;p&gt;在Emacs中，当时用正则表达式匹配换行的时候，发现输入&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\n&lt;/code&gt;是不行的，上网查了下，可以直接输入&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C-j&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;参考网址：&lt;a href=&quot;http://www.linuxsir.org/bbs/thread108556.html&quot;&gt;http://www.linuxsir.org/bbs/thread108556.html&lt;/a&gt;。&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>利用Ripple网络进行小额信用卡套现</title>
   <link href="http://jks-liu.github.io/credit-card-kiting-with-ripple"/>
   <updated>2014-12-01T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/credit-card-kiting-with-ripple</id>
   <content type="html">
&lt;p&gt;警告：实际操作前请仔细阅读你和发卡行签订的协议，笔者不为其背书。&lt;/p&gt;

&lt;p&gt;本文有时效性（2014年12月）。&lt;/p&gt;

&lt;h2 id=&quot;方法&quot;&gt;方法&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;在淘宝用信用卡向Ripple账户充值CNY；&lt;/li&gt;
  &lt;li&gt;从Ripple账户提现。&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;限额&quot;&gt;限额&lt;/h2&gt;

&lt;p&gt;500CNY/信用卡/月&lt;/p&gt;

&lt;h2 id=&quot;总手续费&quot;&gt;总手续费&lt;/h2&gt;

&lt;p&gt;小于1%&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Windows 64位配置Apache HTTPS服务器</title>
   <link href="http://jks-liu.github.io/apache-in-win64-with-ssl"/>
   <updated>2014-11-23T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/apache-in-win64-with-ssl</id>
   <content type="html">
&lt;p&gt;系统信息：Windows8.1 64位，Apache2.2。&lt;/p&gt;

&lt;p&gt;Apache的配置文件写得还是很规范的，所以一开始改的时候就是跟着感觉走。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conf/httpd.conf&lt;/code&gt;文件中分别找到下面两行，移除注释：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-config highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#LoadModule ssl_module modules/mod_ssl.so
#Include conf/extra/httpd-ssl.conf
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;如下面的示例所示，修改&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conf/extra/httpd-ssl.conf&lt;/code&gt;：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-config highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;DocumentRoot&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;C:/Users/Jinchen/projects/github/ripple-client/build/bundle/web&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ServerName&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;ripple&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;443&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ServerAdmin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jks&lt;/span&gt;@&lt;span class=&quot;n&quot;&gt;mrliu&lt;/span&gt;.&lt;span class=&quot;n&quot;&gt;org&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;SSLCertificateFile&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/server.crt&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;SSLCertificateKeyFile&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/server.key&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这一步注意两点：&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentRoot&lt;/code&gt;配置的路径要和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;httpd.conf&lt;/code&gt;文件中的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentRoot&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;Directory&amp;gt;&lt;/code&gt;一样；&lt;/li&gt;
  &lt;li&gt;默认配置下&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SSLcertificateKeyfile&lt;/code&gt;对应的文件是应该是未加密的。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;如果使用加密的key，会出现类似如下的错误：&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-log&quot;&gt;[Sun Nov 23 13:37:28 2014] [error] Init: SSLPassPhraseDialog builtin is not supported on Win32 (key file C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/server.key)
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
  &lt;li&gt;还是&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;httpd-ssl.conf&lt;/code&gt;：将&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-config highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#SSLSessionCache         &quot;dbm:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache&quot;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SSLSessionCache&lt;/span&gt;        &lt;span class=&quot;s2&quot;&gt;&quot;shmcb:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache(512000)&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;改为：&lt;/p&gt;

&lt;div class=&quot;language-config highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;SSLSessionCache&lt;/span&gt;         &lt;span class=&quot;s2&quot;&gt;&quot;dbm:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache&quot;&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#SSLSessionCache        &quot;shmcb:C:/Program Files (x86)/Apache Software Foundation/Apache2.2/logs/ssl_scache(512000)&quot;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;据说这是只有在64位机器上才需要的。如果不这样修改的话，Apache Service Monitor会显示如下错误：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;The requested operation has failed!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;直接运行httpd会出现类似如下的错误：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Syntax error on line 62 of C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/extra/httpd-ssl.conf:
SSLSessionCache: Invalid argument: size has to be &amp;gt;= 8192 bytes
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>使用Goagent CA给你的证书签名</title>
   <link href="http://jks-liu.github.io/signing-certificate-with-goagent-ca"/>
   <updated>2014-11-08T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/signing-certificate-with-goagent-ca</id>
   <content type="html">
&lt;p&gt;&lt;a href=&quot;https://github.com/goagent/goagent/commit/77c8e7f131f9eb7d857cded9c0bc2f662e80b78a&quot;&gt;直到2014年10月18号，GoAgent一直默认使用公开私钥的根证书&lt;/a&gt;。由于GoAgent的广泛使用，估计其还会广泛地存在很长一段时间。如果你能无障碍访问&lt;a href=&quot;https://goagent-cert-test.bamsoftware.com/&quot;&gt;https://goagent-cert-test.bamsoftware.com/&lt;/a&gt;，请立即删除默认的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CA.crt&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;本文教你如何使用这个证书给你的网站颁发证书。例子中我会使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pi.mrliu.org&lt;/code&gt;这个域名。&lt;/p&gt;

&lt;h2 id=&quot;我的系统信息&quot;&gt;我的系统信息&lt;/h2&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;uname&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt;
Linux raspberrypi 3.12.31+ &lt;span class=&quot;c&quot;&gt;#720 PREEMPT Sat Nov 1 13:15:06 GMT 2014 armv6l GNU/Linux&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl version
OpenSSL 1.0.1e 11 Feb 2013 &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;Library: OpenSSL 1.0.1j 15 Oct 2014&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;python &lt;span class=&quot;nt&quot;&gt;--version&lt;/span&gt;
Python 2.7.8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;步骤&quot;&gt;步骤&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;进入任意目录，并将&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CA.crt&lt;/code&gt;文件复制到这个目录。示例中，我用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/openssl/path/&lt;/code&gt;代替这个目录。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;为你的服务器生成密钥&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.key&lt;/code&gt;：&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl genrsa &lt;span class=&quot;nt&quot;&gt;-des3&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.key 2048
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;生成签名请求文件&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.csr&lt;/code&gt;：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl req &lt;span class=&quot;nt&quot;&gt;-new&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-key&lt;/span&gt; server.key &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.csr
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;填写信息时要注意Common Name这一项填你的域名，比如&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*.mrliu.org&lt;/code&gt;，&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt;是通配符，表示签发给&lt;a href=&quot;https://mrliu.org&quot;&gt;mrliu.org&lt;/a&gt;的所有子域名。还有你的邮件地址至少看上去合法。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;生成一个序列号文件：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;01 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; serial.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;利用GoAgent CA为你的证书生成签名文件&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.crt&lt;/code&gt;：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl x509 &lt;span class=&quot;nt&quot;&gt;-req&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-days&lt;/span&gt; 1234 &lt;span class=&quot;nt&quot;&gt;-in&lt;/span&gt; server.csr &lt;span class=&quot;nt&quot;&gt;-CA&lt;/span&gt; CA.crt &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.crt &lt;span class=&quot;nt&quot;&gt;-CAserial&lt;/span&gt; serial.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;将签名文件和私钥合并到一个&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.pem&lt;/code&gt;文件中：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat &lt;/span&gt;server.crt server.key &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; server.pem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;测试&quot;&gt;测试&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;新建文件&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https-server.py&lt;/code&gt;，并写入如下内容：&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/env python
## Jks Liu, https://mrliu.org/signing-certificate-with-goagent-ca/
## Take from https://gist.github.com/dergachev/7028596
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## Change certfile path to yours.
## Root is required for port 443.
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;BaseHTTPServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SimpleHTTPServer&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;ssl&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;httpd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BaseHTTPServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HTTPServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;''&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;443&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SimpleHTTPServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SimpleHTTPRequestHandler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;httpd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wrap_socket&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;httpd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;socket&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;certfile&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'/openssl/path/server.pem'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;server_side&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;httpd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;serve_forever&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;注意修改其中的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.pem&lt;/code&gt;的地址。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;运行测试服务器&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;python https-server.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;修改你的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hosts&lt;/code&gt;文件&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;注意是你客户端上的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hosts&lt;/code&gt;文件。当然，客户端可以和你的服务器在同一个机器上。假设你服务器的ip为192.168.1.111。&lt;/p&gt;

&lt;p&gt;在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hosts&lt;/code&gt;中添加如下行：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;192.168.1.111   pi.mrliu.org
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;打开你客户端的浏览器：&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;浏览：&lt;a href=&quot;https://pi.mrliu.org&quot;&gt;https://pi.mrliu.org&lt;/a&gt;。&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>阅读笔记，2014年11月</title>
   <link href="http://jks-liu.github.io/reading-notes-nov-2014"/>
   <updated>2014-11-05T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/reading-notes-nov-2014</id>
   <content type="html">
&lt;h2 id=&quot;目录-&quot;&gt;目录 &lt;!-- CONTENTS --&gt;&lt;/h2&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#目录-&quot; id=&quot;markdown-toc-目录-&quot;&gt;目录 &lt;!-- CONTENTS --&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#nov05&quot; id=&quot;markdown-toc-nov05&quot;&gt;05 Nov&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#Install-CTAN-Manually&quot; id=&quot;markdown-toc-Install-CTAN-Manually&quot;&gt;I. 手工安装CTAN的宏包&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#nov06&quot; id=&quot;markdown-toc-nov06&quot;&gt;06 Nov&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#ii-在树莓派上wheezy上安装gcc-48&quot; id=&quot;markdown-toc-ii-在树莓派上wheezy上安装gcc-48&quot;&gt;II. 在树莓派上WHEEZY上安装GCC 4.8&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#nov09&quot; id=&quot;markdown-toc-nov09&quot;&gt;09 Nov&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#a-successful-git-branching-model&quot; id=&quot;markdown-toc-a-successful-git-branching-model&quot;&gt;III. 一个成功的Git分支模型&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;nov05&quot;&gt;05 Nov&lt;/h2&gt;

&lt;h3 id=&quot;Install-CTAN-Manually&quot;&gt;I. 手工安装CTAN的宏包&lt;/h3&gt;
&lt;p&gt;参考文献：&lt;a href=&quot;http://tex.stackexchange.com/a/73017/65422&quot;&gt;http://tex.stackexchange.com/a/73017/65422&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;我在使用Raspberry Pi的时候发现TeX Live的CTAN宏包版本都比较旧，并且软件源中也没有tlmgr工具，所以使用有些宏包时需要手动安装。&lt;/p&gt;

&lt;p&gt;安装目录：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;所有用户：使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kpsewhich -var-value TEXMFLOCAL&lt;/code&gt;可以得到为整个系统安装的路径，一般为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/local/share/texmf&lt;/code&gt;。&lt;/li&gt;
  &lt;li&gt;当前用户，使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kpsewhich -var-value TEXMFHOME&lt;/code&gt;可以得到为当前用户安装的路径，一般为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/texmf&lt;/code&gt;。&lt;/li&gt;
  &lt;li&gt;上面的路径我们称为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;base dir&amp;gt;&lt;/code&gt;。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;将下载的宏包解压到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;base dir&amp;gt;/tex/latex/&lt;/code&gt;目录中，此时在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;base dir&amp;gt;/tex/latex/&amp;lt;package name&amp;gt;&lt;/code&gt;目录中应该是相应的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.sty&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.cls&lt;/code&gt;文件；可选地，文档解压到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;base dir&amp;gt;/doc/latex/&lt;/code&gt;。然后执行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mktexlsr&lt;/code&gt;，为所有用户安装时需要&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo&lt;/code&gt;权限。&lt;/p&gt;

&lt;h2 id=&quot;nov06&quot;&gt;06 Nov&lt;/h2&gt;

&lt;h3 id=&quot;ii-在树莓派上wheezy上安装gcc-48&quot;&gt;II. 在树莓派上WHEEZY上安装GCC 4.8&lt;/h3&gt;
&lt;p&gt;原文：&lt;a href=&quot;http://somewideopenspace.wordpress.com/2014/02/28/gcc-4-8-on-raspberry-pi-wheezy/&quot;&gt;GCC 4.8 ON RASPBERRY PI WHEEZY&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;树莓派当前源中的软件一般都比较旧，所以如果要使用较新版本的软件的话需要从测试版仓库中安装。目前，稳定版仓库代号叫WHEEZY，测试版仓库代号是JESSIE。我们可以将&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/sources.list&lt;/code&gt;中的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wheezy&lt;/code&gt;全部改为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jessie&lt;/code&gt;；也可以同时保留两个，然后再安装的时候选择。如保留两个，大致流程如下：&lt;/p&gt;

&lt;p&gt;编辑&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/sources.list&lt;/code&gt;：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
# Source repository to add
deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
deb http://archive.raspbian.org/raspbian jessie main contrib non-free rpi
# Source repository to add
deb-src http://archive.raspbian.org/raspbian jessie main contrib non-free rpi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;编辑（新建）&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/preferences&lt;/code&gt;：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Package: *
Pin: release n=wheezy
Pin-Priority: 900
Package: *
Pin: release n=jessie
Pin-Priority: 300
Package: *
Pin: release o=Raspbian
Pin-Priority: -10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后执行：&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;以安装GCC 4.8 为例，执行：&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; jessie gcc-4.8 g++-4.8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装完了之后默认的gcc版本并不是新安装的这个，所以还需执行如下命令以添加alternative configuration：&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--install&lt;/span&gt; /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--install&lt;/span&gt; /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--install&lt;/span&gt; /usr/bin/g++ g++ /usr/bin/g++-4.6 20
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--install&lt;/span&gt; /usr/bin/g++ g++ /usr/bin/g++-4.8 50
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;如果你的gcc/g++已经有了alternative configuration（默认是没有的），在执行上面的命令之前应当先删除：&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--remove-all&lt;/span&gt; gcc 
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--remove-all&lt;/span&gt; g++
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;执行如下如下命令可以修改当前alternative configuration：&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt; gcc
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;update-alternatives &lt;span class=&quot;nt&quot;&gt;--config&lt;/span&gt; g++
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;nov09&quot;&gt;09 Nov&lt;/h2&gt;

&lt;h3 id=&quot;a-successful-git-branching-model&quot;&gt;III. 一个成功的Git分支模型&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;原文：&lt;a href=&quot;http://nvie.com/posts/a-successful-git-branching-model/&quot;&gt;A successful Git branching model&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;作者：&lt;a href=&quot;http://nvie.com/about/&quot;&gt;Vincent Driessen&lt;/a&gt;，on Tuesday, January 05, 2010&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;本文介绍的版本控制系统Git的一种使用流程，值得一读。本文有多个中文翻译版本。&lt;/p&gt;

&lt;p&gt;本文建议在开发中使用如下分支：master，develop，release，feature-xxx，hotfix。同时介绍了Bump Version脚本，以及在merge时使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--no-ff&lt;/code&gt;选项。&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>阅读笔记，2014年10月</title>
   <link href="http://jks-liu.github.io/reading-notes-oct-2014"/>
   <updated>2014-10-16T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/reading-notes-oct-2014</id>
   <content type="html">
&lt;h2 id=&quot;目录-&quot;&gt;目录 &lt;!-- CONTENTS --&gt;&lt;/h2&gt;

&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#目录-&quot; id=&quot;markdown-toc-目录-&quot;&gt;目录 &lt;!-- CONTENTS --&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#oct16&quot; id=&quot;markdown-toc-oct16&quot;&gt;16 Oct&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#Reflections-on-Trusting-Trust&quot; id=&quot;markdown-toc-Reflections-on-Trusting-Trust&quot;&gt;I. 什么样的软件值得信任&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#oct17&quot; id=&quot;markdown-toc-oct17&quot;&gt;17 Oct&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#The-Twelve-Factor-App&quot; id=&quot;markdown-toc-The-Twelve-Factor-App&quot;&gt;II. 构建Web应用&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#oct28&quot; id=&quot;markdown-toc-oct28&quot;&gt;28 Oct&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#web-application-development-with-clojure&quot; id=&quot;markdown-toc-web-application-development-with-clojure&quot;&gt;使用Clojure写Web应用&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;oct16&quot;&gt;16 Oct&lt;/h2&gt;

&lt;h3 id=&quot;Reflections-on-Trusting-Trust&quot;&gt;I. 什么样的软件值得信任&lt;/h3&gt;
&lt;p&gt;原文：&lt;a href=&quot;http://cm.bell-labs.com/who/ken/trust.html&quot;&gt;Reflections on Trusting Trust&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;作者：Ken Thomps&lt;/p&gt;

&lt;p&gt;本文通过self-reproducing程序引出编译器中的一种bug，通过某种方式可以让这个bug一直留在编译器中，即使我们在源代码中已经修改了这个错误。&lt;/p&gt;

&lt;p&gt;所以，某个程序即使开放了源代码，也不应该完全信任它。除非其完全由你自己从头创建，包括其所有的构建工具，以及构建工具的构建工具，而在现实中这几乎是不可能的。&lt;/p&gt;

&lt;h2 id=&quot;oct17&quot;&gt;17 Oct&lt;/h2&gt;

&lt;h3 id=&quot;The-Twelve-Factor-App&quot;&gt;II. 构建Web应用&lt;/h3&gt;
&lt;p&gt;原文：&lt;a href=&quot;http://12factor.net/&quot;&gt;The Twelve-Factor App&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The twelve-factor app是一个构建SaaS（即Web应用）的方法论。&lt;/p&gt;

&lt;p&gt;本文从1. 代码库，2. 依赖，3. 软件配置，4. 后端服务（如数据库），5. 构建，发布，运行，6. 进程，7. 端口绑定，8. 并发，9. 可处理性（稳健，快速运行，优雅地关闭），10. 开发与产品的等价，11. 日志，12. 管理过程，等十二个方面全面描述了构建SaaS的过程中应当注意的事项。&lt;/p&gt;

&lt;p&gt;其主要有以下几个原则:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;使用一个VCS&lt;/li&gt;
  &lt;li&gt;不用隐含地依赖一个系统的包（或库）&lt;/li&gt;
  &lt;li&gt;将配置储存在环境变量中&lt;/li&gt;
  &lt;li&gt;不管是使用本地服务还是第三方服务（如数据库），代码应该是一样的&lt;/li&gt;
  &lt;li&gt;严格分离构建，发布和运行&lt;/li&gt;
  &lt;li&gt;进程应该是无状态的，且不分享任何东西&lt;/li&gt;
  &lt;li&gt;应用应当是自包含的&lt;/li&gt;
  &lt;li&gt;应用以绑定到端口的服务导出HTTP&lt;/li&gt;
  &lt;li&gt;进程是一等公民&lt;/li&gt;
  &lt;li&gt;进程可以随时的开启和关闭&lt;/li&gt;
  &lt;li&gt;进程的开启时间应该尽量的短&lt;/li&gt;
  &lt;li&gt;进程应当在接受到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SIGTERM&lt;/code&gt;时应该优雅地关闭&lt;/li&gt;
  &lt;li&gt;进程应当是健壮的，并努力避免突然的关闭&lt;/li&gt;
  &lt;li&gt;开发和产品之间的差距应尽可能地小，以使得应用是可持续部署的&lt;/li&gt;
  &lt;li&gt;反对在开发和产品中使用不同的后端服务&lt;/li&gt;
  &lt;li&gt;应用不该关心其Log存储形式&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;oct28&quot;&gt;28 Oct&lt;/h2&gt;

&lt;h3 id=&quot;web-application-development-with-clojure&quot;&gt;使用Clojure写Web应用&lt;/h3&gt;
&lt;p&gt;原文：&lt;a href=&quot;http://vijaykiran.com/2012/01/web-application-development-with-clojure-part-1/&quot;&gt;Web Application Development with Clojure&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;作者：Vijay Kiran&lt;/p&gt;

&lt;p&gt;全文分为5个部分：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://vijaykiran.com/2012/01/web-application-development-with-clojure-part-1/&quot;&gt;第一部分&lt;/a&gt;讲解了如何建立新的工程。&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://vijaykiran.com/2012/01/web-application-development-with-clojure-part-2/&quot;&gt;第二部分&lt;/a&gt;介绍了数据库层。包括使用Lobos库莱建立数据库的Schema和Migrations。以及使用Korma来建立数据库的入口。&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://vijaykiran.com/2012/01/web-application-development-with-clojure-part-3/&quot;&gt;第三部分&lt;/a&gt;介绍了使用Fixture来建立数据库的测试数据，以及使用Enlive来建立Html模板。&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://vijaykiran.com/2012/02/web-application-development-with-clojure-part-4/&quot;&gt;第四部分&lt;/a&gt;结束了CSS的使用以及静态文件的部署。并结束了一个简单的认证逻辑。&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://vijaykiran.com/2012/02/web-application-development-with-clojure-part-5/&quot;&gt;第五部分&lt;/a&gt;简单介绍了管理员区域以及Session的使用。&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>单片机软件构架</title>
   <link href="http://jks-liu.github.io/scm-software-architecture"/>
   <updated>2014-06-21T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/scm-software-architecture</id>
   <content type="html">
&lt;p&gt;单片机程序相比于普通的程序有以下几个方面的不同。&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;中断程序&lt;/li&gt;
  &lt;li&gt;驱动程序&lt;/li&gt;
  &lt;li&gt;多任务&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;C语言发展至今已相当成熟，所以本文以C语言为基础，尽量避免汇编。&lt;/p&gt;

&lt;h2 id=&quot;基本结构&quot;&gt;基本结构&lt;/h2&gt;
&lt;p&gt;大部分人学习单片机是从51开始的，并且好多人除了51也不会其他的单片机。&lt;/p&gt;

&lt;p&gt;下面是一个单片机程序的基本结构。&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Initialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;DoSomething&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;驱动程序&quot;&gt;驱动程序&lt;/h2&gt;
&lt;p&gt;由于单片机资源有限，所以在编写单片机驱动的时候不可能像Linux设备驱动那样考虑十分周全。面对具体的场景（Scenario），有时我们需要不同的决策。&lt;/p&gt;

&lt;h3 id=&quot;可移植性&quot;&gt;可移植性&lt;/h3&gt;
&lt;p&gt;大部分的普通程序员都有一定的完美主义者倾向，这方面单片机程序员稍微好一点。&lt;/p&gt;

&lt;p&gt;可移植性是一个大问题，单片机程序的可移植性更加是个问题。&lt;/p&gt;

&lt;p&gt;当编写可移植程序的时候，你需要决定你的程序有多少的可移植性。有人看到这可能会觉得有些奇怪，程序要么可移植，要么不可移植，何来多少。但当你考虑到以下这些问题时候，你就可以明白我为什么要这么说。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;你的驱动程序是只用在同一类单片机内可移植，还是要在不同的单片机之间可以移植？&lt;/li&gt;
  &lt;li&gt;你的驱动程序是只支持某一个特定的编译器还是想要支持所有的主流编译器？&lt;/li&gt;
  &lt;li&gt;你的驱动程序是否需要支持多任务操作系统？&lt;/li&gt;
  &lt;li&gt;你的驱动程序如何处理样硬件中断？&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;当你考虑到这些问题的时候，问题已经变得很复杂了。而这些，都是你在写之前需要决策的。当然，很少有人注意到这些问题，大部分人觉得不用汇编就不错了，C语言写得脏就脏一点，能跑起来就行。&lt;/p&gt;

&lt;h3 id=&quot;如何使用&quot;&gt;如何使用&lt;/h3&gt;
&lt;p&gt;既然我们是在谈写好一个驱动程序，当然是希望一次编写，多次使用了。但当你的驱动程序用在不同的地方的时候，你是希望无需修改，通过正确的配置就可以直接使用，还是希望简单一点，把配置硬编码到代码中，每次使用都根据具体的应用修改？&lt;/p&gt;

&lt;p&gt;不用修改直接使用当然是最好的，但有时我们会发现这几乎是不可能的。&lt;/p&gt;

&lt;h3 id=&quot;多实例&quot;&gt;多实例&lt;/h3&gt;
&lt;p&gt;你本来精心编写了一个驱动程序，并且运行得很好。但是突然出现了新的需求：在系统中添加一个相同的设备。然而这时你悲剧地发现，你的配置（比如引脚配置）是硬编码在程序中的。&lt;/p&gt;

&lt;p&gt;这时，要么重写所有的驱动，要么把原来的代码复制粘贴一份，再将里面所有的全局函数和变量重命名。不管是哪种方法，都会让人感到沮丧。&lt;/p&gt;

&lt;h3 id=&quot;多余的功能&quot;&gt;多余的功能&lt;/h3&gt;
&lt;p&gt;由于单片机的资源往往是有限的，你准备如何处理不使用的功能。&lt;/p&gt;

&lt;h3 id=&quot;说了这么多还是动手实践吧&quot;&gt;说了这么多，还是动手实践吧。&lt;/h3&gt;
&lt;p&gt;所有程序都经过测试（实物或Proteus）。&lt;/p&gt;

&lt;p&gt;比如我们现在要写一个LCD1602的程序，首先，我们来进行上面的决策。既然是说明，那我就挑选最难的。&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;支持多个编译器&lt;/li&gt;
  &lt;li&gt;支持多种体系结构&lt;/li&gt;
  &lt;li&gt;支持多实例&lt;/li&gt;
  &lt;li&gt;无需修改库程序，配置后直接使用&lt;/li&gt;
  &lt;li&gt;支持屏蔽多余的功能&lt;/li&gt;
  &lt;li&gt;支持多线程&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;你可以在&lt;a href=&quot;https://github.com/jks-liu/LCD1602&quot; title=&quot;LCD1602&quot;&gt;LCD1602@GitHub&lt;/a&gt;下载完整的驱动程序代码；软件框架可以在&lt;a href=&quot;https://github.com/jks-liu/SCM-Software-Architecture&quot; title=&quot;SCM Software Architecture&quot;&gt;SCM Software Architecture@GitHub&lt;/a&gt;下载。&lt;/p&gt;

&lt;p&gt;首先新建两个文件：&lt;a href=&quot;https://github.com/jks-liu/LCD1602/blob/master/LCD1602.c&quot; title=&quot;LCD1602.c&quot;&gt;LCD1602.c&lt;/a&gt;和&lt;a href=&quot;https://github.com/jks-liu/LCD1602/blob/master/LCD1602.h&quot; title=&quot;LCD1602.h&quot;&gt;LCD1602.h&lt;/a&gt;（点击查看完整内容）。&lt;/p&gt;

&lt;p&gt;在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LCD1602.h&lt;/code&gt;中，首先找到下面这一句：&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-c&quot; data-lang=&quot;c&quot;&gt;&lt;span class=&quot;cp&quot;&gt;#include &quot;software-config.h&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;由于我们要让这个驱动库在所有的硬件框架下可用，所以我们没有包含特定于任何芯片的头文件，比如&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reg51.h&lt;/code&gt;。我们包含了一个&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;software-config.h&lt;/code&gt;，库的使用者有责任创建这个头文件，我们把这当作库的作者和使用者的一个约定就好。&lt;/p&gt;

&lt;p&gt;但是，让用户去实现这个&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;software-config.h&lt;/code&gt;，就相当于把复杂性强加给了用户，所以我们在上面提供了一个框架代码。这个框架为常见的单片机提供模板，以使编写&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;software-config.h&lt;/code&gt;更加容易。&lt;/p&gt;

&lt;p&gt;一般来说和硬件有关的配置是将某一个GPIO置位或复位，对于不同的单片机，语法一般是不一样的。对于驱动的编写者，我们可以为每一个单片机都编写一遍代码，也可以将这个问题抛给用户，用户只需对其特定的单片机编写代码。从用户方便的角度来讲，驱动的作者完成所有的工作当然是最好的，但这几乎是不现实的，因为驱动作者不可能熟悉每中单片机，更何况每种单片机在不同的编译器下语法也是不一样的。所以，只给常见单片机和和常见编译器编写算是一个折中。&lt;/p&gt;

&lt;p&gt;LCD1602液晶显示器一般使用HD44780驱动芯片，此芯片支持8位和4位数据总线。所以我们的驱动程序也支持这两种模式。使用何种模式在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;software-config.h&lt;/code&gt;中配置。对于这种二选一的配置，一般有两种方法。&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;两个define二选一
要求在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;software-config.h&lt;/code&gt;中在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#define HD44780_USE_8BIT&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#define HD44780_USE_8BIT&lt;/code&gt;这两个宏定义中二选一。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;有一个默认值
当什么都没有定义的时候，默认使用8位模式。如果定义了&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HD44780_USE_4BIT&lt;/code&gt;，则使用4位的总线模式。&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;这两种方法各有优缺点，方法2相对来说比较简单，&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>SDCC 101</title>
   <link href="http://jks-liu.github.io/sdcc-101-chinese"/>
   <updated>2013-05-09T00:00:00+00:00</updated>
   <id>http://jks-liu.github.io/sdcc-101-chinese</id>
   <content type="html">
&lt;h1 id=&quot;前言&quot;&gt;前言&lt;/h1&gt;
&lt;p&gt;一般国内的51教科书讲的都是keil, 但是， keil是一个商业软件， 于是便写了这样一个教程。&lt;/p&gt;

&lt;h1 id=&quot;预备知识&quot;&gt;预备知识&lt;/h1&gt;
&lt;p&gt;假设你会C语言的基本语法和一些电学的基础知识。既然这是51的教程， 自然假设你对51一点都不了解。&lt;/p&gt;

&lt;h1 id=&quot;内容提要&quot;&gt;内容提要&lt;/h1&gt;
&lt;p&gt;先讲解单片机的基础知识，再讲解一个简单C语言的例子。简单讲讲协议和标准。
然后讲sdcc的安装和使用。再讲讲中断和串口。
接着是code::blocks和eclipse的使用。
可能我还会讲讲模拟器， 可能的话我会讲讲程序的下载。&lt;/p&gt;

&lt;h1 id=&quot;基础知识&quot;&gt;基础知识&lt;/h1&gt;
&lt;h2 id=&quot;如何点亮一个灯&quot;&gt;如何点亮一个灯&lt;/h2&gt;

&lt;h2 id=&quot;三态逻辑&quot;&gt;三态逻辑&lt;/h2&gt;

</content>
 </entry>
 
 
</feed>

