diff --git a/.gitignore b/.gitignore index 0c3e5ab..5a4c672 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ _site/ .sass-cache/ +.idea/ +*.iml +wechat/content/* diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..2a8fcc7 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +blogtest.codeboy.me diff --git a/README.md b/README.md index bc420f7..3823058 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,123 @@ -# CodeboyBlog -http://codeboy.me +CodeboyBlog +--- + +**[codeboy.me](https://www.codeboy.me)的网站模板** + +其中搜索模块可以单独安装,地址如下 + +- jekyll-search [https://github.com/androiddevelop/jekyll-search](https://github.com/androiddevelop/jekyll-search) +- hexo-search [https://github.com/androiddevelop/hexo-search](https://github.com/androiddevelop/hexo-search) + +![网站截图](codeboy.me.png) + +本工程实时预览地址 [blogtest.codeboy.me](http://blogtest.codeboy.me) + +博客可以简单的搭配微信小程序查看, 具体查看 [https://github.com/androiddevelop/WechatBlog](https://github.com/androiddevelop/WechatBlog) + +## 安装方式: + +1. 安装jeykll + + ``` + gem install jekyll + gem install jekyll-paginate + ``` +2. 将CodeboyBlog复制到服务器(部署到github.io的方式自行搜索)。 +3. 运行命令生成网站即可(经常改变配置的话不建议增量更新)。 + + ``` + jekyll serve --watch & + jekyll serve --watch --incremental & ##增量更新 + ``` +为了能够更好的生成网站,我们可以写一个脚本: + + ``` + #!/bin/bash + ps aux |grep jekyll |awk '{print $2}' | xargs kill -9 + cd /path/to/blog + jekyll serve --watch & + ``` + +> ps开头的命令是关闭所有jekyll的进程 +> +> cd到网站的根目录 +> +> 启动jekyll服务 + +## 需要配置的内容: + +1. 修改_config.yml中的信息(知乎等帐号,特别需要注意的是畅言配置(changyan_appid和changyan_appid)必须更换,否则您将不能查看到博客的评论)。 畅言的申请地址 [http://changyan.kuaizhan.com/](http://changyan.kuaizhan.com/) +2. 修改about/index.html中个人信息(如果不需要个人简介,可以在步骤3中去除对应标签)。 +3. 修改_include/nav.html,选择自己需要的导航标签(主页, 应用, 标签, 关于等) +4. 如果博客底部的github,知乎等需要修改,请编辑_includes/footer.html中分享的信息。 +5. 去除CNAME文件,或者CNAME文件中的域名更换为您的博客域名。 + +## 更新内容: + +#### 2018-05-03 + +- 评论组件调整为畅言。 + +#### 2017-12-19 + +- 代码显示行号。(/css/syntax.css) + +#### 2017-11-17 + +- 添加初版微信小程序支持,可以便捷创建专属于自己博客的小程序。 + +#### 2017-04-05 + +- 调整_config部分配置。 +- 由于多说即将关闭,评论组件调整为网易云跟贴。 + +#### 2017-02-19 + +- 修正文章双滚动条 + +### 2016-11-22 + +- 升级jekyll-search(v1.0.1), 兼容firefox。 (/search/js/cb-search.js) +- 修正移动端宽度展示。(/_layouts/page.html) + +### 2016-06-12 + +- 修正jekyll版本升级至3.1.0+后tags页面的显示问题。 +- 将jquery、bootstrap等引用改为cdn,减少站内流量消耗。 + +### 2015-12-20 + +- 多说id移动至_config.xml文件中,集中配置。 + +### 2015-12-09 + +- 更新_config.yml配置,适配jekyll 3.0+版本。 +- 更新博客中相关链接,便于博客转向https站点。 +- 去除anchor,标题前面不再显示 `#` 号。 + +#### 2015-10-10 + +- 在Clean Blog的基础上修改,同时加入黄玄在CleanBlog上添加的云标签。 +- 加入文章搜索功能,pc上可以双击ctrl触发。 +- 优化界面,更好的适配手机。 + + +## License + +``` +Copyright 2016 Yuedong.li + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + +> 有任何问题,欢迎发送邮件到app@codeboy.me交流. diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..9255197 --- /dev/null +++ b/_config.yml @@ -0,0 +1,90 @@ +######################站点全局信息,需要部分修改######################### +# Site settings +title: "小胖轩" +header-img: "img/home-bg.jpg" +email: "app@codeboy.me" +url: "http://127.0.0.1" +description: "编码生涯的点点滴滴" +github_username: "androiddevelop" +zhihu_username: "codeboy" + +changyan_appid: "'changyan_appid'" +changyan_conf: "'changyan_conf'" +##########################上述信息需要您修改,changyan_appid、changyan_conf############################ + + +# Where things are +source: . +destination: ./_site +plugins_dir: ./_plugins +layouts_dir: ./_layouts +data_dir: ./_data +includes_dir: ./_includes +posts_dir: ./_posts +#collections: null + +# Handling Reading +safe: false +include: [".htaccess"] +exclude: ["less","node_modules","Gruntfile.js","package.json","README.md","tmp","unless"] +keep_files: [".git", ".svn"] +encoding: "utf-8" +markdown_ext: "markdown,mkdown,mkdn,mkd,md" + +# Filtering Content +show_drafts: null +limit_posts: 0 +future: false +unpublished: false + +# Plugins +whitelist: [] +plugins: ["jekyll-paginate"] +#gems: [] + +# Conversion +markdown: kramdown +highlighter: pygments +lsi: false +excerpt_separator: "\n\n" +incremental: false + +# Serving +detach: false +port: 4000 +host: 127.0.0.1 +baseurl: "" # does not include hostname + +# Outputting +permalink: pretty +paginate: 16 +paginate_path: /page/:num +timezone: Asia/Shanghai + +quiet: false +defaults: [] + +# Markdown Processors +rdiscount: + extensions: [] + +redcarpet: + extensions: [] + +# Markdown Processors +kramdown: + auto_ids: true + footnote_nr: 1 + entity_output: as_char + toc_levels: 1..6 + smart_quotes: lsquo,rsquo,ldquo,rdquo + syntax_highlighter: true + input: GFM + + syntax_highlighter_opts: + wrap: div + line_numbers: inline + line_number_start: 1 + tab_width: 4 + bold_every: 10 + css: style diff --git a/_includes/footer.html b/_includes/footer.html new file mode 100644 index 0000000..0b22e66 --- /dev/null +++ b/_includes/footer.html @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+ +
diff --git a/_includes/head.html b/_includes/head.html new file mode 100644 index 0000000..3044d90 --- /dev/null +++ b/_includes/head.html @@ -0,0 +1,42 @@ + + + + + + + + + {% if page.title %}{{ page.title }} - {{ site.title }}{% else %}{{ site.title }}{% endif %} + + + + + + + + + + + + + + + + + + + + + + diff --git a/_includes/nav.html b/_includes/nav.html new file mode 100644 index 0000000..80152a8 --- /dev/null +++ b/_includes/nav.html @@ -0,0 +1,49 @@ + + diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 0000000..882c57d --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,16 @@ + + + +{% include head.html %} + + + + {% include nav.html %} + + {{ content }} + + {% include footer.html %} + + + + diff --git a/_layouts/page.html b/_layouts/page.html new file mode 100644 index 0000000..c46563d --- /dev/null +++ b/_layouts/page.html @@ -0,0 +1,29 @@ +--- +layout: default +--- + + +
+
+
+
+
+

{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}

+
+ {{ page.description }} +
+
+
+
+
+ + +
+
+
+
+ {{ content }} +
+
+
+
\ No newline at end of file diff --git a/_layouts/post.html b/_layouts/post.html new file mode 100644 index 0000000..b102d29 --- /dev/null +++ b/_layouts/post.html @@ -0,0 +1,53 @@ +--- +layout: default +--- + + +
+
+
+
+
+
+ {% for tag in page.tags %} + {{ tag }} + {% endfor %} +
+

{{ page.title }}

+ {% comment %} + always create a h2 for keeping the margin + {% endcomment %} + {% comment %} if page.subtitle {% endcomment %} +

{{ page.subtitle }}

+ {% comment %} endif {% endcomment %} + Posted by {% if page.author %}{{ page.author }}{% else %}{{ site.title }}{% endif %} on {{ page.date | date: "%B %-d, %Y" }} +
+
+
+
+
+ + +
+
+
+
+ + {{ content }} + +
+
+ + +
+ + +
+
+
diff --git a/_posts/2014-11-06-java-trick-1.md b/_posts/2014-11-06-java-trick-1.md new file mode 100644 index 0000000..15e5257 --- /dev/null +++ b/_posts/2014-11-06-java-trick-1.md @@ -0,0 +1,59 @@ +--- +layout: post +title: '不劳而获' +date: '2014-11-06' +header-img: "img/home-bg.jpg" +tags: + - java +author: 'Codeboy' +--- + + +下面的程序将打印一个单词,其首字母有一个随机生成器选择,请描述改程序的行为: + + import java.util.Random; + + public class Main { + private static Random rnd = new Random(); + + public static void main(String[] args) { + StringBuffer word = null; + switch (rnd.nextInt(2)) { + case 1: + word = new StringBuffer('P'); + case 2: + word = new StringBuffer('G'); + default: + word = new StringBuffer('M'); + } + word.append('a'); + word.append('i'); + word.append('n'); + System.out.println(word); + } + +咋一看这个程序可能会在一次又一次的运行中以相等概率的输出Pain, Gain, Main.是这样吗? + +聪明的您可能发现问题了, Random.nextInt(int n)的范围是在0-n之间,含0不含n,所以整体上Random.nextInt(2)只会产生0或者1,所以程序是不会打印出Gain的,应该是等概率的输出Main与Pain。(**栅栏柱错误**) + +看起来似乎正确了,但是哪里还是有些问题。看到了,是switch循环后面没有加上break,这样的话,Random.nextInt(2)产生1时会将3个case语句全部执行,也即相当于执行default里的语句;Random.nextInt(2)产生0时也是执行default里的语句,这样下来最终的结果只能有一个,那就是Main了。(**switch-case-break错误**) + +复制代码,运行一下,发现结果是ain,不管运行多少次,结果都是一样的,为什么没有打印出M呢,下面我们来看一下StringBuffer,StringBuffer类没有对应的字符构造函数,在eclipse中可以将鼠标放在case中的构造器中,提示了一下内容: + + java.lang.StringBuffer.StringBuffer(int capacity) + + Constructs a string buffer with no characters in it and the specified initial capacity. + + Parameters: + capacity the initial capacity. + Throws: + NegativeArraySizeException - if the capacity argument is less than 0. + +这下明白了,原来StringBuffer('M')在构造的时候,是构造了一个容量为'M'对应ascii值大小的初始容量,之后再附加字符之前,都没有任何内容,所以最终的结果始终是Main。(**非常规方法使用错误**) + +上面的3处错误或者问题是经常出现的,希望大家都能够多注意。 + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2014-11-16-apache-user-authorized.md b/_posts/2014-11-16-apache-user-authorized.md new file mode 100644 index 0000000..650cba6 --- /dev/null +++ b/_posts/2014-11-16-apache-user-authorized.md @@ -0,0 +1,40 @@ +--- +layout: post +title: 'Apache下配置认证用户' +date: '2014-11-16' +header-img: "img/post-bg-unix.jpg" +tags: + - server +author: 'Codeboy' +--- + + +有时候我们需要给我apache服务器下制定的目录加上用户认证,方便一些而用户进行文件的浏览。配置如下: + +1 设置用户 +---- + htpasswd -c file_path user_name + +回车之后输入密码即可,请确保命令中的file _path有其他用户读的权限。 + +2 设置apache +---- +在/etc/apache2/apache2.conf或/etc/httpd/conf/httpd.conf中添加以下内容 + + + AuthName "Important Directory" #登录时提示的内容 + AuthType Basic #认证方式 + IndexOptions Charset=GB2312 #网页编码 + Options Indexes FollowSymLinks MultiViews #以目录形式展示 + AuthUserFile /opt/.apache_user #用户文件,1中file_path + Require valid-user + + +若要隐藏服务器标示,请在配置文件中加入以下信息: + + ServerSignature Off + ServerTokens Prod + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2014-11-26-android-viewpager.md b/_posts/2014-11-26-android-viewpager.md new file mode 100644 index 0000000..d48e42a --- /dev/null +++ b/_posts/2014-11-26-android-viewpager.md @@ -0,0 +1,62 @@ +--- +layout: post +title: 'ViewPager自适应高度' +date: '2014-11-26' +header-img: "img/post-bg-android.jpg" +tags: + - android +author: 'Codeboy' +--- + +在使用ViewPager的时候发现不能自适应高度,可以重写ViewPager的onMeasure来解决,代码如下: + + import android.content.Context; + import android.support.v4.view.ViewPager; + import android.util.AttributeSet; + import android.view.View; + + /** + * 自定义viewPager,实现ViewPager自定义高度 + * + * @author Yuedong Li + * + */ + public class CBViewPager extends ViewPager { + + public CBViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public CBViewPager(Context context) { + super(context); + } + + /** + * 将child高度传递给父类构造函数 + */ + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + + int height = 0; + // 下面遍历所有child的高度 + for (int i = 0; i < getChildCount(); i++) { + View child = getChildAt(i); + child.measure(widthMeasureSpec, + MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); + int h = child.getMeasuredHeight(); + if (h > height) // 采用最大的view的高度。 + height = h; + } + + heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, + MeasureSpec.EXACTLY); + + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + } + +直接使用CBViewPager就可以了。 + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-01-06-ftp-no-download.md b/_posts/2015-01-06-ftp-no-download.md new file mode 100644 index 0000000..49837b5 --- /dev/null +++ b/_posts/2015-01-06-ftp-no-download.md @@ -0,0 +1,73 @@ +--- +layout: post +title: '配置ftp服务器只能上传不能进行其他操作' +date: '2015-01-06' +header-img: "img/post-bg-unix.jpg" +tags: + - server + - web +author: 'Codeboy' +--- + +又到期末考试了,今年当了数据挖掘助教,课程有一道编程大作业,需要搭建ftp服务器,实现文件上传,但是禁止下载重命名。 + +服务器系统是ubuntu12.04 server,使用的ftp服务器也是linux下大名鼎鼎的vsftpd,配置如下: + +**1. 创建用户dm,将其登录终端设置为/bin/false,防止用户ssh登录** + + useradd -m -s /bin/false dm + +**2. 将/bin/false加入/etc/shells中,使其可以使用dm用户进行ftp登录** + + echo "/bin/bash">>/etc/shells + +**3. 配置vsftpd.conf,禁止用户访问上层目录.自行创建/etc/vsftpd.chroot_list,不添加任何用户,在vsftpd.chroot_list中得用户可以切换到上层目录,我们这里需要禁止dm用户。主要配置如下:** + + chroot_local_user=YES + chroot_list_enable=YES + chroot_list_file=/etc/vsftpd.chroot_list + +**4. 添加相应权限,防止用户下载重命名** + +使用cmds_allows命令配置,将不允许的命令(重命名,下载,删除,创建文件夹)除去即可: + + cmds_allowed=FEAT,REST,CWD,LIST,MDTM,NLST,PASS,PASV,PORT,PWD,QUIT,RMD,SIZE,STOR,TYPE,USER,ACCT,APPE,CDUP,HELP,MODE,NOOP,REIN,STAT,STOU,STRU,SYST + + +主要命令解释如下: + + MKD - make a remote directory 新建文件夹 + NLST - name list of remote directory + PWD - print working directory 显示当前工作目录 + RETR - retrieve a remote file 下载文件 + STOR - store a file on the remote host 上传文件 + DELE - delete a remote file 删除文件 + RMD - remove a remote directory 删除目录 + RNFR - rename from 重命名 + RNTO - rename to 重命名 + ABOR - abort a file transfer 取消文件传输 + CWD - change working directory 更改目录 + DELE - delete a remote file 删除文件 + LIST - list remote files 列目录 + MDTM - return the modification time of a file 返回文件的更新时间 + MKD - make a remote directory 新建文件夹 + NLST - name list of remote directory + PASS - send password + PASV - enter passive mode + PORT - open a data port 打开一个传输端口 + PWD - print working directory 显示当前工作目录 + QUIT - terminate the connection 退出 + RETR - retrieve a remote file 下载文件 + RMD - remove a remote directory + RNFR - rename from + RNTO - rename to + SITE - site-specific commands + SIZE - return the size of a file 返回文件大小 + STOR - store a file on the remote host 上传文件 + TYPE - set transfer type + USER - send username + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-04-29-java-hashmap-trick.md b/_posts/2015-04-29-java-hashmap-trick.md new file mode 100644 index 0000000..4c6650a --- /dev/null +++ b/_posts/2015-04-29-java-hashmap-trick.md @@ -0,0 +1,75 @@ +--- +layout: post +title: 'HashMap的小优化' +date: '2015-04-29' +header-img: "img/home-bg.jpg" +tags: + - java +author: 'Codeboy' +--- + +HashMap是我们平日内用的非常多的集合框架,网上介绍有很多的实现原理,在存放数据数量已知的情况下,我们可以在构建hashmap的时候指定其容量,减少扩展空间时消耗的时间。下面看一个例子: + + import java.util.HashMap; + import java.util.Map; + + /** + * HashMap测试 + * + * @author YD + * + */ + public class MapTest { + public static void main(String[] args) { + int num = 10000; //数据容量 + Map map1 = new HashMap(); + Map map2 = new HashMap(num); + Map map3 = new HashMap(num * 2); + + long time1 = System.currentTimeMillis(); + for (int i = 0; i < num; i++) + map1.put(i, "haha"); + long time2 = System.currentTimeMillis(); + for (int i = 0; i < num; i++) + map2.put(i, "haha"); + long time3 = System.currentTimeMillis(); + for (int i = 0; i < num; i++) + map3.put(i, "haha"); + long time4 = System.currentTimeMillis(); + System.out.println("map1 time: " + (time2 - time1) + "ms"); + System.out.println("map2 time: " + (time3 - time2) + "ms"); + System.out.println("map3 time: " + (time4 - time3) + "ms"); + } + } + + +在数据量为10000的时候,多次测试,得出的较多的结果是 + + map1 time: 14ms + map2 time: 9ms + map3 time: 4ms + +在数据量为100000的时候,结果如下 + + map1 time: 31ms + map2 time: 16ms + map3 time: 9ms + +如果数据量更大的时候,升值1000000(一百万)时,结果如下 + + map1 time: 119ms + map2 time: 47ms + map3 time: 59ms + +数据量再增加10倍后(一千万),结果如下 + + map1 time: 7718ms + map2 time: 1035ms + map3 time: 2156ms + +可以看出,当我们预先知道数据量的时候,在构建hashmap的时候指定数据容量,可以在数据量大的时候减少消耗时间。指定数据容量时,不应该过多的分配空间。 + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-05-04-android-ndk.md b/_posts/2015-05-04-android-ndk.md new file mode 100644 index 0000000..df0a9d8 --- /dev/null +++ b/_posts/2015-05-04-android-ndk.md @@ -0,0 +1,243 @@ +--- +layout: post +title: 'Android Ndk的应用' +date: '2015-05-04' +header-img: "img/post-bg-android.jpg" +tags: + - android +author: 'Codeboy' +--- + +做android开发,或多或少应该对ndk有些了解。大家都知道,开发android应用很多部分是使用java完成的,但是java语言使用起来虽然简单,但是也比较容易进行反编译,尽管现在网络上有很多的加密工具。那怎么保护应用的一些隐私逻辑模块(加解密)的,ndk是一个很好的选择。 + +ndk使用c或者cpp完成代码的编写,使用c或者cpp可以将一些模块编译为链接库(so文件),这些文件反编译起来则非常的困难,同时使用c和cpp写出的代码在执行效率上会有所提升。本文将展示使用ndk技术将字符串的简单加解密方法写进so文件中。 + +考虑到编码等的原因,本文中的加密解密算法方式为:java中将字符串转为为byte数组,然后通过jni调用c语言加解密函数,同时将byte数据传递给c(中间有一部类型转化,将byte数组转化为char数组),c语言对char数组进行加解密后返回。有关ndk的一些简单使用,大家可以看一些麦子学院的[教程](http://www.maiziedu.com/lesson/3805/),本文中只对使用的一些例子进行解释。对于字符串的加解密,按照本文的方式加解密应该是一种不错的方式,使用中您可能需要修改一下c语言中的加解密函数即可。 + +本文中c语言对char数组的加解密很简单,对每一个char进行拆分,char占8位,高4位与低4位拆成2个数值,然后根据数值从一个长度为16的钥匙串中拿出对应字符,这些字符对应的数组记为加密后的字符串。反向解密原理相似,只需要将字符数组中每2个字符抽取,计算出加密前的数值即可。下面看一下整体ndk的使用。 + +使用ndk前,需要从android官网上下载ndk组件,解压后大概3G左右,建议一个新项目(AndroidNDK),将新项目目录指定在ndk解压后的根目录(这样比较方便,不这样做也可以),我们需要在新项目中额外添加的只有一个jni目录,jni目录与src,res等是同一层的。目录内需要含有的文件如下所示: + + mac:AndroidNDK YD$ tree jni + jni + ├── Android.mk + ├── Application.mk + └── encrypt.c + +其中encrypt.c即是我们的加解密函数所在的位置,Android.mk与Application.mk为配置文件,内容很固定。可以看下各个文件的内容: + +**Application.mk** + + APP_ABI := armeabi,armeabi-v7a + + +Application.mk中还有其他的一些配置,大家可以去官网或者google一下,常用的配置是App_ABI,指定生成对应cpu架构的库文件。 + +**Android.mk** + + LOCAL_PATH := $(call my-dir) + include $(CLEAR_VARS) + LOCAL_MODULE := codeboy_encrypt + LOCAL_SRC_FILES := encrypt.c + LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog + include $(BUILD_SHARED_LIBRARY) + +Android.mk中需要修改的内容只有LOCAL_MODULE和LOCAL_SRC_FILES,前者指定生成的连接库名称,后者指定要编译的c语言或者cpp的文件名字,其他的保持不变即可。 + +**encrypt.c** + + #include + #include + #include + + //宏定义打印函数,使用方法 LOGI("hello") 或者 LOGI("money %d",15) + #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "native", __VA_ARGS__)) + #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "native", __VA_ARGS__)) + + const char key[] = "abcdefghijklmnop"; //16个字符 + int len = 0; + + //计算字符对应的byte值 + unsigned char getByteNumber(unsigned char first, unsigned char end) { + int firstPosition = 0, endPosition = 0; + int position = 0; + for (; position < 16; position++) { + if (key[position] == first) { + firstPosition = position; + } + if (key[position] == end) { + endPosition = position; + } + } + return (firstPosition << 4) | (endPosition); + } + + //加密函数 + void encrypt(unsigned char p[], unsigned char res[]) { + int i = 0; + for (; i < len; i++) { + res[2 * i] = key[p[i] / 16]; + res[2 * i + 1] = key[p[i] % 16]; + } + } + + //解密函数 + void decrypt(unsigned char p[], char res[]) { + int i; + for (i = 0; i < len; i++) { + res[i] = getByteNumber(p[i * 2], p[i * 2 + 1]); + } + } + + //java中生命的native函数,函数名称格式Java_包名(点换下划线)_类名_函数名 + //前两个参数JNIEnv *env, jclass this比较固定,其中第二个参数jclass代表方法是静态的,仅仅是个表示,如果方法不是静态的话,jclass换成jobject + //后续的参数是函数要传进来的参数 + //java中的byte数组对应jni中的jbyteArray,jni中的jbyteArray可以通过jni中的函数转换为char数组 + jstring Java_me_codeboy_encrypt_EncryptUtil_encrypt(JNIEnv *env, jclass this, + jbyteArray src) { + unsigned char *buff = (char*) (*env)->GetByteArrayElements(env, src, NULL); + len = (*env)->GetArrayLength(env, src); + //加密后长度变为原先的2倍 + unsigned char res[len * 2]; + encrypt(buff, res); + //此步骤很重要,标志结束 + res[len * 2] = '\0'; + + //使用完毕释放src数组,因为src数组的存在jvm中 + (*env)->ReleaseByteArrayElements(env, src, buff, 0); + + //jni中函数将char数组转变为字符串,jni中字符串为jstring,对应java中的String + jstring resStr = (*env)->NewStringUTF(env, res); + return resStr; + } + + //和加密类似 + jstring Java_me_codeboy_encrypt_EncryptUtil_decrypt(JNIEnv *env, jclass this, + jbyteArray src) { + unsigned char *buff = (char*) (*env)->GetByteArrayElements(env, src, NULL); + len = (*env)->GetArrayLength(env, src); + //解密后长度变为原先的1/2 + len = len / 2; + signed char res[len]; + decrypt(buff, res); + //此步骤很重要,标志结束 + res[len] = '\0'; + + //使用完毕释放src数组,因为src数组的存在jvm中 + (*env)->ReleaseByteArrayElements(env, src, buff, 0); + + jstring resStr = (*env)->NewStringUTF(env, res); + return resStr; + } + +这样我们的ndk相关的文件就写好了,下面在终端下切换到AndroidNDK目录下,运行命令即可: + + ../ndk-build + +运行结果如下: + + mac:AndroidNDK YD$ ../ndk-build + Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 14 in ./AndroidManifest.xml + [armeabi] Compile thumb : codeboy_encrypt <= encrypt.c + [armeabi] SharedLibrary : libcodeboy_encrypt.so + [armeabi] Install : libcodeboy_encrypt.so => libs/armeabi/libcodeboy_encrypt.so + [armeabi-v7a] Compile thumb : codeboy_encrypt <= encrypt.c + [armeabi-v7a] SharedLibrary : libcodeboy_encrypt.so + [armeabi-v7a] Install : libcodeboy_encrypt.so => libs/armeabi-v7a/libcodeboy_encrypt.so + +执行完成后,我们可以看一下libs文件夹,多了一些so文件,如下: + + mac:AndroidNDK YD$ tree libs + libs + ├── android-support-v4.jar + ├── armeabi + │ └── libcodeboy_encrypt.so + └── armeabi-v7a + └── libcodeboy_encrypt.so + + 2 directories, 3 files + + +下面我们就开始写对应的java代码了,将调用c函数的加解密函数抽象到一个类中即可 + +**EncryptUtil.java** + + package me.codeboy.encrypt; + + public class EncryptUtil { + public native static String encrypt(byte[] src); // 加密函数 + + public native static String decrypt(byte[] src); // 解密函数 + + static { + System.loadLibrary("codeboy_encrypt"); + } + + /** + * 加密函数 + * + * @param src + * @return + */ + public static String encrypt(String src) { + return encrypt(src.getBytes()); + } + + /** + * 解密函数 + * + * @param src + * @return + */ + public static String decrypt(String src) { + return decrypt(src.getBytes()); + } + } + +注意C语言中的函数名称中的包名类名函数名要与该类统一,还有对应的链接库名称。 + +做好了这些以后,我们就可以使用了。在我们的Activity中简单的定义一个按钮,点击后对一个字符串进行加密打印,之后进行解密打印,Activity中的代码如下: + + package me.codeboy.ndk.ui; + + import me.codeboy.encrypt.EncryptUtil; + import me.codeboy.ndk.R; + import android.app.Activity; + import android.os.Bundle; + import android.view.View; + import android.view.View.OnClickListener; + import android.widget.Button; + + public class MainActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + setContentView(R.layout.main_ui); + super.onCreate(savedInstanceState); + + Button btn = (Button) findViewById(R.id.btn); + btn.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + String src = "我是玄恒,欢迎访问我的网站codeboy.me"; + String res = EncryptUtil.encrypt(src); + System.out.println("------>" + res); + res = EncryptUtil.decrypt(res); + System.out.println("--->" + res); + } + }); + } + } + + +点击按钮后可以看到点击button打印的结果: + + --->ogiijbogjikpohioieogibjcoplmimogkmkcoilpiooikolpojjhkoogiijbohjkieohlnjbohkljjgdgpgegfgcgphjcogngf + --->我是玄恒,欢迎访问我的网站codeboy.me + +这样下来我们就完成了简单的加解密操作,也对ndk有了一个初步的了解。 + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-05-08-js-rorate-image.md b/_posts/2015-05-08-js-rorate-image.md new file mode 100644 index 0000000..2ad33f0 --- /dev/null +++ b/_posts/2015-05-08-js-rorate-image.md @@ -0,0 +1,49 @@ +--- +layout: post +title: ' Js实现旋转的图片' +date: '2015-05-08' +header-img: "img/post-bg-web.jpg" +tags: + - web +author: 'Codeboy' +--- + +gif可以实现旋转的图片,但是怎么使用js实现的。自己想了一下,打算实现一下,整体思路也很简单,每隔一段时间,旋转一下图片,看起来就像在一直旋转一样。[实例地址](http://example.codeboy.me/rotate/) + +旋转rotate.js的代码如下: + + /** + * Created by YD on 5/7/15. + * Base on Jquery + */ + var ele ; + + //自定义函数 + $.fn.extend({ + rotate: function () { + ele = this ; + setInterval('singleRotate()',20); + } + }); + + //初始角度 + var degree = 0; + + //单次旋转 + function singleRotate() { + //一次增加50度 + degree = degree + 50 * Math.PI / 180; + ele.css("transform","rotate("+degree+"deg)"); + } + +代码中只需引用一下js就行了,我将其封装后放在了服务器上,大家可以直接引用 + +引用前记得引用jquery,最后在自己的代码中调用rotate方法即可: + + $(element).rotate(); + + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-06-28-android-context.md b/_posts/2015-06-28-android-context.md new file mode 100644 index 0000000..2185759 --- /dev/null +++ b/_posts/2015-06-28-android-context.md @@ -0,0 +1,124 @@ +--- +layout: post +title: 'Context, What Context?' +date: '2015-06-28' +header-img: "img/post-bg-android.jpg" +tags: + - android +author: 'Codeboy' +--- +Android中有各种各样的context,不同context有不同的用途,不仅仅生命周期不同,同时能够实现的操作也不相同,下面看一篇外国朋友总结的文章: + +**Context is probably the most used element in Android application, it may also be the most misused.** + +Context objects are so common, and get passed around so frequently, it can be easy to create a situation you didn’t intend. Loading resources, launching a new Activity, obtaining a system service, getting internal file paths, and creating views all require a Context (and that’s not even getting started on the full list!) to accomplish the task. What I’d like to do is provide for you some insights on how Context works alongside some tips that will (hopefully) allow you to leverage it more effectively in your applications. + +Context Types +---- +Not all Context instances are created equal. Depending on the Android application component, the Contextyou have access to varies slightly: + +**Application** – is a singleton instance running in your application process. It can be accessed via methods like getApplication() from an Activity or Service, and getApplicationContext() from any other object that inherits from Context. Regardless of where or how it is accessed, you will always receive the same instance from within your process. + +**Activity/Service** – inherit from ContextWrapper which implements the same API, but proxies all of its method calls to a hidden internal Context instance, also known as its base context. Whenever the framework creates a new Activity or Service instance, it also creates a new ContextImpl instance to do all of the heavy lifting that either component will wrap. Each Activity or Service, and their corresponding base context, are unique per-instance. + +**BroadcastReceiver** – is not a Context in and of itself, but the framework passes a Context to it in onReceive() each time a new broadcast event comes in. This instance is a ReceiverRestrictedContext with two main functions disabled; calling registerReceiver() and bindService(). These two functions are not allowed from within an existing BroadcastReceiver.onReceive(). Each time a receiver processes a broadcast, the Contexthanded to it is a new instance. + +**ContentProvider** – is also not a Context but is given one when created that can be accessed via getContext(). If the ContentProvider is running local to the caller (i.e. same application process), then this will actually return the same Application singleton. However, if the two are in separate processes, this will be a newly created instance representing the package the provider is running in. + +Saved References +---- +The first issue we need to address comes from saving a reference to a Context in an object or class that has a lifecycle that extends beyond that of the instance you saved. For example, creating a custom singleton that requires a Context to load resources or access a ContentProvider, and saving a reference to the current Activity or Service in that singleton. + +**Bad Singleton** + + public class CustomManager { + private static CustomManager sInstance; + + public static CustomManager getInstance(Context context) { + if (sInstance == null) { + sInstance = new CustomManager(context); + } + + return sInstance; + } + + private Context mContext; + + private CustomManager(Context context) { + mContext = context; + } + } + +The problem here is we don’t know where that Context came from, and it is not safe to hold a reference to the object if it ends up being an Activity or a Service. This is a problem because a singleton is managed by a single static reference inside the enclosing class. This means that our object, and ALL the other objects referenced by it, will never be garbage collected. If this Context were an Activity, we would effectively hold hostage in memory all the views and other potentially large objects associated with it; creating a leak. + +To protect against this, we modify the singleton to always reference the application context: + +**Better Singleton** + + public class CustomManager { + private static CustomManager sInstance; + + public static CustomManager getInstance(Context context) { + if (sInstance == null) { + //Always pass in the Application Context + sInstance = new CustomManager(context.getApplicationContext()); + } + + return sInstance; + } + + private Context mContext; + + private CustomManager(Context context) { + mContext = context; + } + } + +Now it doesn’t matter where our Context came from, because the reference we are holding is safe. The application context is itself a singleton, so we aren’t leaking anything by creating another static reference to it. Another great example of places where this can crop up is saving references to a Context from inside a running background thread or a pending Handler. + +So why can’t we always just reference the application context? Take the middleman out of the equation, as it were, and never have to worry about creating leaks? The answer, as I alluded to in the introduction, is because one Context is not equal to another. + +Context Capabilities +---- +The common actions you can safely take with a given Context object depends on where it came from originally. Below is a table of the common places an application will receive a Context, and in each case what it is useful for: + + FUNCTION |APPLICATION |ACTIVITY| SERVICE| CONTENTPROVIDER| BROADCASTRECEIVER +---|---|---|---|---|--- +Show a Dialog| NO| YES |NO| NO| NO +Start an Activity| NO①| YES |NO①| NO①| NO① +Layout Inflation| NO②| YES| NO②| NO②| NO② +Start a Service| YES| YES| YES| YES| YES +Bind to a Service| YES |YES| YES| YES| NO +Send a Broadcast| YES |YES| YES |YES |YES +Register BroadcastReceiver| YES |YES| YES| YES| NO③ +Load Resource Values| YES |YES| YES| YES| YES + +> ① An application CAN start an Activity from here, but it requires that a new task be created. This may fit specific use cases, but can create non-standard back stack behaviors in your application and is generally not recommended or considered good practice. +> +> ② This is legal, but inflation will be done with the default theme for the system on which you are running, not what’s defined in your application. +> +> ③ Allowed if the receiver is null, which is used for obtaining the current value of a sticky broadcast, on Android 4.2 and above. + +User Interface +---- +You can see from looking at the previous table that there are a number of functions the application context is not properly suited to handle; all of them related to working with the UI. In fact, the only implementation equipped to handle all tasks associated with the UI is Activity; the other instances fare pretty much the same in all categories. + + Luckily, these three actions are things an application doesn’t really have any place doing outside the scope of an Activity; it’s almost like the framework was designed that way on purpose. Attempting to show a Dialogthat was created with a reference to the application context, or starting an Activity from the application context will throw an exception and crash your application…a strong indicator something has gone wrong. + +The less obvious issue is inflating layouts. If you read my last piece on layout inflation, you already know that it can be a slightly mysterious process with some hidden behaviors; using the right Context is linked to another one of those behaviors. While the framework will not complain and will return a perfectly good view hierarchy from a LayoutInflater created with the application context, the themes and styles from your app will not be considered in the process. This is because Activity is the only Context on which the themes defined in your manifest are actually attached. Any other instance will use the system default theme to inflate your views, leading to a display output you probably didn’t expect. + +The Intersection of these Rules +----- + +Invariably, someone will arrive at the conclusion that these two rules conflict. There is a case in the application’s current design where a long-term reference must be saved and we must save an Activity because the tasks we want to accomplish include manipulation of the UI. If that is the case, I would urge you to reconsider your design, as this would be a textbook instance of fighting the framework. + +The Rule of Thumb +---- +In most cases, use the Context directly available to you from the enclosing component you’re working within. You can safely hold a reference to it as long as that reference does not extend beyond the lifecycle of that component. As soon as you need to save a reference to a Context from an object that lives beyond your Activity or Service, even temporarily, switch that reference you save over to the application context. + +*转自: https://possiblemobile.com/2013/06/context/* + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-06-28-android-unleak-hander.md b/_posts/2015-06-28-android-unleak-hander.md new file mode 100644 index 0000000..46eccb7 --- /dev/null +++ b/_posts/2015-06-28-android-unleak-hander.md @@ -0,0 +1,92 @@ +--- +layout: post +title: 'Android Handler如何避免内存泄露' +date: '2015-06-28' +author: 'Codeboy' +header-img: 'img/post-bg-android.jpg' +tags: + - android +--- +在使用Android Handler的时候,可能会遇到编译器给我们这样的警告: + + This Handler class should be static or leaks might occur + +造成这个警告的原因是handler持有外层类(Activity等)的引用,同时消息队列中的Message对handler也持有引用,这样就造成一些资源不能回,从而可能造成内存泄露。 + +解决这个警告的办法即让handler不持有外部类的引用,怎么做到这一点呢,即将Handler设置为静态内部类就行了,将外部类(Activity等)传递给Handler,在Handler中建立弱引用(WeakReference)。 + +为了能够使以后更好的使用Handler-Message机制,我这里对其进行了封装,使用方法见下。先看一下代码。 + +### CBHandler.java + package me.codeboy.android.common.component; + + import android.os.Handler; + import android.os.Message; + + import java.lang.ref.WeakReference; + + import me.codeboy.android.common.app.CBActivity; + + /** + * Created by yuedong.lyd on 6/7/15. + *

; + * 构建防止内存泄露的handler + *

+ */ + public class CBHandler { + /** + * 防止handler对activity有隐式引用,匿名内部类不会对外部类有引用 + */ + public static class UnleakHandler extends Handler { + private final WeakReference activity; + + public UnleakHandler(CBActivity activity) { + this.activity = new WeakReference<CBActivity>(activity); + } + + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + if(activity.get() == null) { + return; + } + activity.get().processMessage(msg); + } + } + } + + +### CBActivity + + package me.codeboy.android.common.app; + + import android.app.Activity; + import android.os.Bundle; + import android.os.Message; + + import me.codeboy.android.common.component.CBHandler; + + /** + * Created by yuedong.lyd on 6/8/15. + */ + public abstract class CBActivity extends Activity{ + public CBHandler.UnleakHandler handler ; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + handler = new CBHandler.UnleakHandler(this); + } + + /** + * 处理消息 + * @param msg + */ + public abstract void processMessage(Message msg); + } + +在使用中,我们只需自己的Activity继承CBActivity即可,在onCreate时自动创建UnleakHandler的实例handler,从CBHandler的代码中我们也可以看出来,UnleakHandler自动将收到的消息交给CBActivity中的processMessage进行处理。我们只需要在发送消息的时候使用handler变量发送即可,处理在processHandler中处理即可。 + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-07-02-image-gray.md b/_posts/2015-07-02-image-gray.md new file mode 100644 index 0000000..dbcfd83 --- /dev/null +++ b/_posts/2015-07-02-image-gray.md @@ -0,0 +1,72 @@ +--- +layout: post +title: '图片灰度化' +date: '2015-07-02' +tags: + - java + - discover +author: 'Codeboy' +--- +怎么将图片灰度化,看到一个黑白滤镜的实现,黑白滤镜原理十分简单,是根据各种颜色在人眼中的亮度响应将rgb三通道的像素转换成单通道的灰度像素.而对于彩色转灰度,有一个很著名的心理学公式: + + Gray = R*0.299 + G*0.587 + B*0.114 + +下面看一下具体怎么使用,怎么讲一张彩色照片转变为黑白照片。看一段java代码: + + package me.codeboy.lyd.image; + + import javax.imageio.ImageIO; + import java.awt.*; + import java.awt.image.BufferedImage; + import java.io.File; + import java.io.IOException; + + /** + * Created by yuedong on 7/2/15. + */ + public class GrayImage { + public static void main(String[] args) throws IOException { + File file = new File("src.png"); + File out = new File("out.png"); + BufferedImage image = ImageIO.read(file); + int width = image.getWidth(); + int height = image.getHeight(); + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + int rgb = image.getRGB(i, j); + int r = rgb & 0x00ff0000 >> 16; + int g = rgb & 0x0000ff00 >> 8; + int b = rgb & 0x000000ff; + + //根据公式计算 + int color = (int) (r * 0.299 + g * 0.587 + b * 0.114); + image.setRGB(i, j, new Color(color, color, color).getRGB()); + } + } + ImageIO.write(image, "PNG", out); + + //rgb相同下产生的图片 + BufferedImage colorImage = new BufferedImage(256, 256 * 3, BufferedImage.TYPE_3BYTE_BGR); + for (int i = 0; i < 256; i++) { + for (int j = 0; j < 256 * 3; j++) { + int k = j/3; + colorImage.setRGB(i,j,new Color(k,k,k).getRGB()); + } + } + + File colorFile = new File("color.png"); + ImageIO.write(colorImage, "PNG", colorFile); + } + } + +代码进行了2个操作,一个讲图片进行灰度化,怎么进行灰度化呢,可以看出,仅仅是获取每一个点的rgb值,按照公式计算出灰度值,然后设置新的rgb值,每一个r,g,b的值都是这个灰度值。处理前后的照片如下: +![img](/img/image-src.png) +![img](/img/image-gray.png) + +为什么呢?因为r=g=b时,获取的颜色的区间就是由黑到白,紧接着的代码就是将r=g=b的颜色绘制出来,图片如下(最上面的是r=g=b=0,最下面的是r=g=b=255): +![img](/img/image-rgb.png) + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-07-10-java-operate.md b/_posts/2015-07-10-java-operate.md new file mode 100644 index 0000000..7e9f81d --- /dev/null +++ b/_posts/2015-07-10-java-operate.md @@ -0,0 +1,61 @@ +--- +layout: post +title: 'a+=b 等价于 a=a+b ?' +date: '2015-07-10' +header-img: "img/home-bg.jpg" +tags: + - java +author: 'Codeboy' +--- + +**a += b**和**a = a + b**完全等价么(java)?可能很多人以为是一样的,其实并非等价的,下面看一下证据吧。 + + public class Test { + public static void main(String[] args) { + int a = 0; + float c = 2.0f; + a += c; + a = a + c; //① + } + } + +上面的代码有问题么? 能够通过编译么? 答案是**否定的**。 + + $ javac Test.java + Test.java:6: error: possible loss of precision + a = a + c; + ^ + required: int + found: float + 1 error + +出现的问题是编译错误, 但是**a += c**却不会出现编译错误,能够正常通过编译。 + +**为什么为这样呢?** + +我们将**①**处代码去除后,顺利编译,可以使用jd-gui等工具看一下**a += c**的反编译后的代码: + + public class Test + { + public static void main(String[] paramArrayOfString) + { + int i = 0; + float f = 2.0F; + i = (int)(i + f); + } + } + +看一下以下这句: + + i = (int)(i + f); + +可以看出**a += c**在编译的时候做了强制类型转换。 + + 结论: + 对于 a += c + 如果a的类型可以兼容b,则 (a += c) 等价于 (a = a + c) + 否则,则会在a与c做完加法后进行强制转换。 + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-07-11-jekyll-search.md b/_posts/2015-07-11-jekyll-search.md new file mode 100644 index 0000000..8779de4 --- /dev/null +++ b/_posts/2015-07-11-jekyll-search.md @@ -0,0 +1,71 @@ +--- +layout: post +title: '给jekyll添加炫酷简洁的搜索' +date: '2015-07-11' +header-img: "img/post-bg-web.jpg" +tags: + - web +author: 'Codeboy' +--- + +试试**双击Ctrl键**看看,或者点击**右下角搜索图标** + +博客从wordpress的jekyll,jekyll的核心思想: + + 将纯文本转化为静态网站和博客 + +jekyll是一个简单的免费的Blog生成工具,类似WordPress。但是和WordPress又有很大的不同,原因是jekyll只是一个生成静态网页的工具,不需要数据库支持。但是可以配合第三方服务,例如Disqus。最关键的是jekyll可以免费部署在Github上,而且可以绑定自己的域名。 + +jekyll没有数据库支持,默认没有搜索功能,那么怎么添加炫酷简洁的搜索的功能呢?google一下,大部分都是使用插件之类的,起始我们可以直接在服务端产生索引,之后利用索引进行搜索。 + +受到spotlight的简洁启发,在目前小胖轩导航栏上已经没有空间了,于是打算做出一个类似于spotlight的搜索。下面先看一下操作步骤: + + ① 服务端生成文章索引 + ② 浏览器获取文章索引 + ③ 页面交互以及按键控制 + +### 服务器生成文章索引 + + --- + layout: null + --- + { + "code" : 0 , + "data" : [ + {\% for post in site.posts \%} + { + "title" : "{{ post.title }} - {\% for tag in post.tags \%}{\% if forloop.rindex != 1 \%}{{ tag }}_{\% else \%}{{ tag }}{\% endif \%}{\% endfor \%}", + "url" : "{{ post.url }}" + } + {\% if forloop.rindex != 1 \%} + , + {\% endif \%} + {\% endfor \%} + ] + } + +> 1. 由于文章中的动态代码会被解析,所以做了替换,代码中%被替换成\%,使用中请去除%前面的转义符 +> 2. liquid语言对行敏感,如果需要把2个字符串拼接一起,那么字符串必须在同一行,否则字符串间将加入回车符 + +这段代码是一个双层循环,将文章的标题与标签组合,同时和url一起组合为json字符串,方便后续ajax调用。 + +### 浏览器获取文章索引 + +此处也即一个ajax调用,使用$.ajax或者$.getJson都可以,此处可以参考一下ajax的异步请求。 + +### 页面交互以及按键控制 + +为了能够有一个更好的交互,对搜索进行了很多的按键的操作: + +- PC下双击Ctrl键打开或者关闭搜索框 +- 搜索框展示时按下Esc键关闭搜索框 + +按键的检测在js中也是很容易进行,此处也不在列代码了。 + +为了移动端也可以很好的搜索,在页面的右下角加入搜索悬浮按钮,点击后打开搜索页面,而在搜索页面,右上角提供关闭按钮,这样整体下来就完美的实现了搜索。 + + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-07-17-android-webview-optimize.md b/_posts/2015-07-17-android-webview-optimize.md new file mode 100644 index 0000000..101bc6b --- /dev/null +++ b/_posts/2015-07-17-android-webview-optimize.md @@ -0,0 +1,100 @@ +--- +layout: post +title: 'Android WebView页面加载优化' +date: '2015-07-17' +header-img: "img/post-bg-android.jpg" +tags: + - android + - network +author: 'Codeboy' +--- + +目前webapp越来越多,体验也越来越好,为了能够更好的使用WebView展示出流畅的的页面,可以从以下几点做优化: + +- **WebView缓存** +- **资源文件本地存储** +- **减少耗时操作** +- **客户端UI优化** + +可能有人会说了,为什么不做成native的呢,这样就不用那么的麻烦了。如果我需要加载的内容都是静态的,当然做成native的是最好的,为什么我们要使用WebView呢,因为它可以加载一些容易改变的内容,同时也方便制作多平台应用。 + +WebView可以优化的哪些地方呢? + +### WebView缓存 + +开启WebView的缓存功能可以减少对服务器资源的请求,一般使用默认缓存策略就可以了。 + + //设置 缓存模式 + webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); + // 开启 DOM storage API 功能 + webView.getSettings().setDomStorageEnabled(true); + +### 资源文件本地存储 + +资源等文件(不需要更新)本地存储,在需要的时候直接从本地获取。哪些资源需要我们去存储在本地呢,当然是一些不会被更新的资源,例如图片文件,js文件,css文件,替换的方法也很简单,重写WebView的方法即可。 + + { + try { + if (url.endsWith("icon.png")) { + InputStream is = appRm.getInputStream(R.drawable.icon); + WebResourceResponse response = new WebResourceResponse("image/png", + "utf-8", is); + return response; + } else if (url.endsWith("jquery.min.js")) { + InputStream is = appRm.getInputStream(R.raw.jquery_min_js); + WebResourceResponse response = new WebResourceResponse("text/javascript", + "utf-8", is); + return response; + } + } catch (IOException e) { + e.printStackTrace(); + } + return super.shouldInterceptRequest(view, url); + } + + +> 1. appRm为app资源管理器,读取drawable,assets,raw下的资源,都是android系统的一些很简单的函数调用。 +> +> 2. getInputStream的参数代表资源具体位置 +> +> 3. WebResourceResponse后的资源类型需要写正确 + +有些时候我们会为我们的网站加入一些统计代码,这些也可以精简掉(自己使用的CNZZ的大概占的有10k左右),可以使用Charles对客户端进行抓包查看。 + +### 减少耗时操作 + +准确的说,是减少同步操作的操作时间,尽量使用异步操作替代同步操作。如果服务端存在读取数据库和计算耗时的操作,尽量使用异步(ajax)进行操作,把原本的时间花在异步操作上。 + +举个例子,A页面到B页面,A页面实现登录功能,B页面展示主功能页面,如果让B页面去进行用户登录信息验证的话,B页面加载时间会加长(数据库查询等操作),同时客户端可能需要提供一个等待框(或进度条等)给用户,那看看在A页面使用异步操作的优势吧: + +- 可以提供统一的js等待框,多平台保持一致性,减少客户端代码工作量。 +- 加载页面的时间变短。B页面由于减少了耗时的操作,加载时间变短,用户等待时间也变短。 +- 可以方便加入一些验证后的控制逻辑,不需要进行页面跳转。A页面可以根据异步操作进行结果判断,做出相应的处理。 + + +### 客户端UI优化 + +怎么让用户看不到WebView加载前的白色页面呢?首次加载后页面的跳转可以用上面的步骤进行优化,可以提供给用户一个很好的体验,那加载的第一页呢?我们需要WebView预加载页面,这个该怎么做到的呢?下面提供两种方法: + +- ViewPager,将欢迎页面与WebView页面一起放进ViewPager中,设置预加载页面个数,使WebView所在页面可以预加载,在加载完毕的时候切换到WebView所在页面。 +- FrameLayout,将欢迎页面与WebView页面的布局合在一起,显示在一个页面内,起始隐藏WebView布局,待WebView加载完毕,隐藏欢迎布局,显示WebView布局。 + +使用FrameLayout简单一些,两种方法都是需要对WebChromeClient的onProgressChanged进行监听,加载完毕进行页面切换,如下: + + webView.setWebChromeClient(new WebChromeClient() { + @Override + public void onProgressChanged(WebView view, int newProgress) { + super.onProgressChanged(view, newProgress); + if (newProgress >= 100) { + // 切换页面 + } + } + }); + + +经过以上几步的优化,一个流畅的webapp生成了。 + + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-07-20-get-max-from-every-group.md b/_posts/2015-07-20-get-max-from-every-group.md new file mode 100644 index 0000000..3f1ec18 --- /dev/null +++ b/_posts/2015-07-20-get-max-from-every-group.md @@ -0,0 +1,79 @@ +--- +layout: post +title: '获取所有分组中某列最大的行' +date: '2015-07-20' +header-img: "img/home-bg.jpg" +tags: + - database +author: 'Codeboy' +--- + +**怎么获取所有分组中某列最大的行?**下面用一个例子来说明下: + +一共公司有若干员工,每个员工有各自的id, group_id(部门), salary(工资).现在的问题转变为 + + 求公司各部门最高工资的员工 + +首先明确一个问题,一个部门的若干个员工可能同时拥有最高的工资,需要都列举出来。 + +看一下员工的数据库表结构(只包含有用的列): + + +| Field | Type | Null | Key | Default | Extra | +|----------|---------|------|-----|---------|-------| +| id | int(11) | NO | PRI | NULL | | +| group_id | int(11) | YES | | NULL | | +| salary | int(11) | YES | | NULL | | + +添加的测试数据如下: + +| id | group_id | salary | +|----|----------|--------| +| 1 | 1 | 100 | +| 2 | 1 | 200 | +| 3 | 1 | 200 | +| 4 | 2 | 200 | +| 5 | 2 | 300 | + +我们需要做的步骤如下: + +- 1. 获取各个部门最高的工资 +- 2. 查找各个部门工资等于最高工资的员工 + +#### 获取各个部门最高的工资 + + select group_id, max(salary) as max_salary from employee group by group_id ; + +执行后的结果: + +| group_id | max_salary | +|----------|------------| +| 1 | 200 | +| 2 | 300 | + +#### 查找各个部门工资等于最高工资的员工 + + select a.id, a.group_id, a.salary from employee as a, b where a.group_id=b.group_id and a.salary=b.max_salary ; + +>假设第一执行后的数据存在表b中。 + +这样就得到了最终的结果: + +| id | group_id | salary | +|----|----------|--------| +| 2 | 1 | 200 | +| 3 | 1 | 200 | +| 5 | 2 | 300 | + +我们可以简单的将**获取各个部门最高的工资**的代码替换b即可,组合后的语句如下: + + select a.id, a.group_id, a.salary from employee as a, (select group_id, max(salary) as max_salary from employee group by group_id) as b where a.group_id=b.group_id and a.salary=b.max_salary ; + +执行后的结果相同。 + +#### 总结 + 我们首先按照部门进行分组,获取每组最大的工资(表b); 之后将表a(原表)与表b做一下笛卡尔积,筛选出我们需要的数据即可。 + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/_posts/2015-07-28-android-trick.md b/_posts/2015-07-28-android-trick.md new file mode 100644 index 0000000..bfe56be --- /dev/null +++ b/_posts/2015-07-28-android-trick.md @@ -0,0 +1,70 @@ +--- +layout: post +title: 'Android开发及使用技巧' +date: '2015-07-28' +header-img: "img/post-bg-android.jpg" +tags: + - android +author: 'Codeboy' +--- + +### 1. 查看wifi密码 + +查询连接的wifi密码,没问题,前提是手机已经root了,可以查看系统文件,android的wifi密码明文保存在一下文件中,使用root explorer查看即可。 + + /data/misc/wifi/wpa_supplicant.conf + + +### 2. 查看activity堆栈情况 + + adb shell dumpsys activity ---------------查看ActvityManagerService 所有信息 + adb shell dumpsys activity activities ----------查看Activity组件信息 + adb shell dumpsys activity services -----------查看Service组件信息 + adb shell dumpsys activity providers ----------产看ContentProvider组件信息 + adb shell dumpsys activity broadcasts --------查看BraodcastReceiver信息 + adb shell dumpsys activity intents --------------查看Intent信息 + adb shell dumpsys activity processes ---------查看进程信息 + + +### 3. 查看apk中的AndroidManifest.xml文件 + +可以使用apktool对apk进行反编译,不过现在很多的apk都进行了加固,可以防止apktool进行反编译,我们可以使用google提供的aapt(Android Asset Packaging Tool)进行查看: + + aapt dump xmltree target.apk AndroidManifest.xml + +>其中target.apk为需要查看AndroidManifest.xml的apk包。 + + +### 4. 查看android的log + + adb logcat + + "-s"选项 : 设置输出日志的标签, 只显示该标签的日志; + + "-f"选项 : 将日志输出到文件, 默认输出到标准输出流中, -f 参数执行不成功; + + "-r"选项 : 按照每千字节输出日志, 需要 -f 参数, 不过这个命令没有执行成功; + + "-n"选项 : 设置日志输出的最大数目, 需要 -r 参数, 这个执行 感觉 跟 adb logcat 效果一样; + + "-v"选项 : 设置日志的输出格式, 注意只能设置一项; + + "-c"选项 : 清空所有的日志缓存信息; + + "-d"选项 : 将缓存的日志输出到屏幕上, 并且不会阻塞; + + "-t"选项 : 输出最近的几行日志, 输出完退出, 不阻塞; + + "-g"选项 : 查看日志缓冲区信息; + + "-b"选项 : 加载一个日志缓冲区, 默认是 main, 下面详解; + + "-B"选项 : 以二进制形式输出日志; + + + +持续更新... + +> 如有任何知识产权、版权问题或理论错误,还请指正。 +> +> 转载请注明原作者及以上信息。 diff --git a/about/css/component.css b/about/css/component.css new file mode 100755 index 0000000..f183fc6 --- /dev/null +++ b/about/css/component.css @@ -0,0 +1,202 @@ +@font-face { + font-family: 'ecoico'; + src:url('../fonts/timelineicons/ecoico.eot'); + src:url('../fonts/timelineicons/ecoico.eot?#iefix') format('embedded-opentype'), + url('../fonts/timelineicons/ecoico.woff') format('woff'), + url('../fonts/timelineicons/ecoico.ttf') format('truetype'), + url('../fonts/timelineicons/ecoico.svg#ecoico') format('svg'); + font-weight: normal; + font-style: normal; +} /* Made with http://icomoon.io/ */ + +.cbp_tmtimeline { + margin: 30px 0 0 0; + padding: 0; + list-style: none; + position: relative; +} + +/* The line */ +.cbp_tmtimeline:before { + content: ''; + position: absolute; + top: 0; + bottom: 0; + width: 10px; + background: #afdcf8; + left: 20%; + margin-left: -10px; +} + +.cbp_tmtimeline > li { + position: relative; +} + +/* The date/time */ +.cbp_tmtimeline > li .cbp_tmtime { + display: block; + width: 26.5%; + padding-right: 110px; + position: absolute; + top: -10px; +} + +.cbp_tmtimeline > li .cbp_tmtime span { + display: block; + text-align: right; +} + +.cbp_tmtimeline > li .cbp_tmtime span:first-child { + font-size: 1.2em; + color: #bdd0db; +} + +.cbp_tmtimeline > li .cbp_tmtime span:last-child { + font-size: 2.2em; + color: #3594cb; +} + +cbp_tmtimeline > li:nth-child(odd) .cbp_tmtime span:last-child { + /*color: #6cbfee;*/ +} + +/* Right content */ +.cbp_tmtimeline > li .cbp_tmlabel { + margin: 0 0 15px 25%; + background: #3594cb; + color: #fff; + padding: 2em; + font-size: 1.2em; + font-weight: 300; + line-height: 1.4; + position: relative; + border-radius: 5px; +} + +.cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel { + /*background: #6cbfee; */ +} + +.cbp_tmtimeline > li .cbp_tmlabel h2 { + margin-top: 0px; + padding: 0 0 10px 0; + border-bottom: 1px solid rgba(255,255,255,0.4); +} + +/* The triangle */ +.cbp_tmtimeline > li .cbp_tmlabel:after { + right: 100%; + border: solid transparent; + content: " "; + height: 0; + width: 0; + position: absolute; + pointer-events: none; + border-right-color: #3594cb; + border-width: 10px; + top: 10px; +} + +.cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel:after { + /* border-right-color: #6cbfee; */ +} + +/* The icons */ +.cbp_tmtimeline > li .cbp_tmicon { + width: 40px; + height: 40px; + font-family: 'ecoico'; + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + font-size: 1.4em; + line-height: 40px; + -webkit-font-smoothing: antialiased; + position: absolute; + color: #fff; + background: #46a4da; + border-radius: 50%; + box-shadow: 0 0 0 8px #afdcf8; + text-align: center; + left: 20%; + top: 0; + margin: 0 0 0 -25px; +} + +.cbp_tmicon-phone:before { + content: "\e000"; +} + +.cbp_tmicon-screen:before { + content: "\e001"; +} + +.cbp_tmicon-mail:before { + content: "\e002"; +} + +.cbp_tmicon-earth:before { + content: "\e003"; +} + +/* Example Media Queries */ +@media screen and (max-width: 65.375em) { + + .cbp_tmtimeline > li .cbp_tmtime span:last-child { + font-size: 1.5em; + } + + +.cbp_tmtimeline > li .cbp_tmtime { + position: absolute; + top: 0px; +} + +} + +@media screen and (max-width: 47.2em) { + .cbp_tmtimeline:before { + display: none; + } + + .cbp_tmtimeline > li .cbp_tmtime { + width: 100%; + position: relative; + padding: 0 0 20px 0; + } + + .cbp_tmtimeline > li .cbp_tmtime span { + text-align: left; + } + + .cbp_tmtimeline > li .cbp_tmlabel { + margin: 0 0 30px 0; + padding: 1em; + font-weight: 400; + font-size: 95%; + } + + .cbp_tmtimeline > li .cbp_tmlabel:after { + right: auto; + left: 20px; + border-right-color: transparent; + border-bottom-color: #3594cb; + top: -20px; + } + + .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel:after { + border-right-color: transparent; + border-bottom-color: #6cbfee; + } + + .cbp_tmtimeline > li .cbp_tmicon { + position: relative; + float: right; + left: auto; + margin: -65px 5px 0 0px; + } +} + + diff --git a/about/css/default.css b/about/css/default.css new file mode 100755 index 0000000..265344d --- /dev/null +++ b/about/css/default.css @@ -0,0 +1,184 @@ +/* General Blueprint Style */ +@import url(https://fonts.googleapis.com/css?family=Lato:300,400,700); +@font-face { + font-family: 'bpicons'; + src:url('../fonts/bpicons/bpicons.eot'); + src:url('../fonts/bpicons/bpicons.eot?#iefix') format('embedded-opentype'), + url('../fonts/bpicons/bpicons.woff') format('woff'), + url('../fonts/bpicons/bpicons.ttf') format('truetype'), + url('../fonts/bpicons/bpicons.svg#bpicons') format('svg'); + font-weight: normal; + font-style: normal; +} /* Made with http://icomoon.io/ */ + +*, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } +body, html { font-size: 100%; padding: 0; margin: 0;} + +/* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */ +.clearfix:before, .clearfix:after { content: " "; display: table; } +.clearfix:after { clear: both; } + +body { + font-family: 'Lato', Calibri, Arial, sans-serif; + color: #47a3da; +} + +a { + text-decoration: none; +} + +.main, +.about-container > header { + width: 100%; + max-width: 69em; + margin: 0 auto; + padding: 0 1.875em 3.125em 1.875em; +} + +.about-container > header { + padding: 2.875em 1.875em 1.875em; +} + +.about-container > header h1 { + font-size: 2.125em; + line-height: 1.3; + margin: 0 0 0.6em 0; + float: left; + font-weight: 400; +} + +.about-container > header > span { + display: block; + position: relative; + z-index: 9999; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.5em; + padding: 0 0 0.6em 0.1em; +} + +.about-container > header > span span:after { + width: 30px; + height: 30px; + left: -12px; + font-size: 50%; + top: -8px; + font-size: 75%; + position: relative; +} + +.about-container > header > span span:hover:before { + content: attr(data-content); + text-transform: none; + text-indent: 0; + letter-spacing: 0; + font-weight: 300; + font-size: 110%; + padding: 0.8em 1em; + line-height: 1.2; + text-align: left; + left: auto; + margin-left: 4px; + position: absolute; + color: #fff; + background: #47a3da; +} + +.about-container > header nav { + float: right; + text-align: center; +} + +.about-container > header nav a { + display: inline-block; + position: relative; + text-align: left; + width: 2.5em; + height: 2.5em; + background: #fff; + border-radius: 50%; + margin: 0 0.1em; + border: 4px solid #47a3da; +} + +.about-container > header nav a > span { + display: none; +} + +.about-container > header nav a:hover:before { + content: attr(data-info); + color: #47a3da; + position: absolute; + width: 600%; + top: 120%; + text-align: right; + right: 0; + pointer-events: none; +} + +.about-container > header nav a:hover { + background: #47a3da; +} + +.bp-icon:after { + font-family: 'bpicons'; + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + text-align: center; + color: #47a3da; + -webkit-font-smoothing: antialiased; +} + +.about-container > header nav .bp-icon:after { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + line-height: 2; + text-indent: 0; +} + +.about-container > header nav a:hover:after { + color: #fff; +} + +.bp-icon-next:after { + content: "\e000"; +} +.bp-icon-drop:after { + content: "\e001"; +} +.bp-icon-archive:after { + content: "\e002"; +} +.bp-icon-about:after { + content: "\e003"; +} +.bp-icon-prev:after { + content: "\e004"; +} + +@media screen and (max-width: 55em) { + + .about-container > header h1, + .about-container > header nav { + float: none; + } + + .about-container > header > span, + .about-container > header h1 { + text-align: center; + } + + .about-container > header nav { + margin: 0 auto; + } + + .about-container > header > span { + text-indent: 30px; + } +} diff --git a/about/fonts/fontawesome.eot b/about/fonts/fontawesome.eot new file mode 100755 index 0000000..06c34f7 Binary files /dev/null and b/about/fonts/fontawesome.eot differ diff --git a/about/fonts/fontawesome.svg b/about/fonts/fontawesome.svg new file mode 100755 index 0000000..930927e --- /dev/null +++ b/about/fonts/fontawesome.svg @@ -0,0 +1,16 @@ + + + + +This is a custom SVG font generated by IcoMoon. + + + + + + + + + + + \ No newline at end of file diff --git a/about/fonts/fontawesome.ttf b/about/fonts/fontawesome.ttf new file mode 100755 index 0000000..47c8cea Binary files /dev/null and b/about/fonts/fontawesome.ttf differ diff --git a/about/fonts/fontawesome.woff b/about/fonts/fontawesome.woff new file mode 100755 index 0000000..b5bb6f1 Binary files /dev/null and b/about/fonts/fontawesome.woff differ diff --git a/about/fonts/timelineicons/ecoico.dev.svg b/about/fonts/timelineicons/ecoico.dev.svg new file mode 100755 index 0000000..0e845a2 --- /dev/null +++ b/about/fonts/timelineicons/ecoico.dev.svg @@ -0,0 +1,31 @@ + + + + +This is a custom SVG font generated by IcoMoon. + + + + + + + + + + + + + \ No newline at end of file diff --git a/about/fonts/timelineicons/ecoico.eot b/about/fonts/timelineicons/ecoico.eot new file mode 100755 index 0000000..e9c5006 Binary files /dev/null and b/about/fonts/timelineicons/ecoico.eot differ diff --git a/about/fonts/timelineicons/ecoico.svg b/about/fonts/timelineicons/ecoico.svg new file mode 100755 index 0000000..221d26e --- /dev/null +++ b/about/fonts/timelineicons/ecoico.svg @@ -0,0 +1,31 @@ + + + + +This is a custom SVG font generated by IcoMoon. + + + + + + + + + + + + + \ No newline at end of file diff --git a/about/fonts/timelineicons/ecoico.ttf b/about/fonts/timelineicons/ecoico.ttf new file mode 100755 index 0000000..dd1213b Binary files /dev/null and b/about/fonts/timelineicons/ecoico.ttf differ diff --git a/about/fonts/timelineicons/ecoico.woff b/about/fonts/timelineicons/ecoico.woff new file mode 100755 index 0000000..9aae29c Binary files /dev/null and b/about/fonts/timelineicons/ecoico.woff differ diff --git a/about/img/alipay.jpg b/about/img/alipay.jpg new file mode 100644 index 0000000..968cb0c Binary files /dev/null and b/about/img/alipay.jpg differ diff --git a/about/img/lyd.jpg b/about/img/lyd.jpg new file mode 100644 index 0000000..b007f7e Binary files /dev/null and b/about/img/lyd.jpg differ diff --git a/about/img/tmall.png b/about/img/tmall.png new file mode 100644 index 0000000..782a544 Binary files /dev/null and b/about/img/tmall.png differ diff --git a/about/index.html b/about/index.html new file mode 100644 index 0000000..b466606 --- /dev/null +++ b/about/index.html @@ -0,0 +1,114 @@ +--- +layout: page +title: "About" +description: "简单 执着 勤奋 疯狂" +header-img: "img/about-bg.jpg" +--- + + + + +
+
+
    +
  • + +
    +
    +

    个人介绍

    +
      +
    • 李跃东(玄恒)
    • +
    • 喜欢Android, Web, Server等一些技术
    • +
    • 可以通过app@codeboy.me联系我哦
    • +
    +
    +
  • +
  • + +
    +
    +

    天猫实习生

    + +
      +
    • 客户端开发工程师
    • +
    • 参与几个模块的开发
    • +
    +
    +
  • + +
  • + +
    +
    +

    科大小秘书

    + 科大小秘书是一款为科大研究生设计的安卓软件。小秘书可以帮您跳过验证码的输入,方便实用。小秘书的功能有:查询成绩,查看个人课表,查询所有研究生选修课的时间地点老师,查询助研资金,查询epc预约课程信息等. +
    +
  • + + +
  • + +
    +
    +

    中国科学技术大学

    +
      +
    • 计算机学院
    • +
    • 安徽省合肥市金寨路96号
    • +
    +
    +
  • + + +
  • + +
    +
    +

    郑大小秘书

    + 郑大小秘书是一款专门为郑大学子设计的安卓软件。您通过它可以查询个人教务信息,新闻招聘信息,图书馆馆藏书目;可以方便的登陆ZzuWlan,可以和同学相互发送私信,对自己感兴趣的内容加以收藏等。 +
    +
  • + + +
  • + +
    +
    +

    短信邮箱

    + 短信邮箱是一款便捷的短信同步软件,它会将您发送和收到的短信发送至您的邮箱,您可以设置过滤器(号码或关键字)来取消同步含有这些特性的短信。 +
    +
  • + + +
  • + +
    +
    +

    郑州大学

    +
      +
    • 信息工程学院
    • +
    • 河南省郑州市高新技术开发区科学大道100号
    • +
    +
    +
  • + +
  • + +
    +
    +

    爱心捐助

    + +
    +
  • +
+
+
diff --git a/about/js/modernizr.custom.js b/about/js/modernizr.custom.js new file mode 100755 index 0000000..c5c71ef --- /dev/null +++ b/about/js/modernizr.custom.js @@ -0,0 +1,4 @@ +/* Modernizr 2.6.2 (Custom Build) | MIT & BSD + * Build: http://modernizr.com/download/#-shiv-cssclasses-load + */ +;window.Modernizr=function(a,b,c){function u(a){j.cssText=a}function v(a,b){return u(prefixes.join(a+";")+(b||""))}function w(a,b){return typeof a===b}function x(a,b){return!!~(""+a).indexOf(b)}function y(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:w(f,"function")?f.bind(d||b):f}return!1}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m={},n={},o={},p=[],q=p.slice,r,s={}.hasOwnProperty,t;!w(s,"undefined")&&!w(s.call,"undefined")?t=function(a,b){return s.call(a,b)}:t=function(a,b){return b in a&&w(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=q.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(q.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(q.call(arguments)))};return e});for(var z in m)t(m,z)&&(r=z.toLowerCase(),e[r]=m[z](),p.push((e[r]?"":"no-")+r));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)t(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},u(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+p.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f + + @media screen and (min-width: 768px){ + .element { + display: table-cell; + vertical-align: middle; + float: none !important; + } + } + + @media screen and (max-width: 767px){ + .row { + position: relative; + top: -20px; + margin-bottom: 10px; + } + + hr{ + margin-top: 0px ; + } + + .cb-title-top{ + margin-top: 40px; + } + } + + + + +
+ +
+ +
+ + +
+ + + +
+
diff --git a/codeboy.me.png b/codeboy.me.png new file mode 100644 index 0000000..61bca59 Binary files /dev/null and b/codeboy.me.png differ diff --git a/css/codeboy.css b/css/codeboy.css new file mode 100644 index 0000000..532cd0b --- /dev/null +++ b/css/codeboy.css @@ -0,0 +1,677 @@ +body { + font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; + line-height: 1.7; + font-size: 16px; + color: #404040; + overflow-x: hidden; +} +p { + margin: 30px 0; +} +h1, +h2, +h3, +h4, +h5, +h6 { + font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; + line-height: 1.7; + line-height: 1.1; + font-weight: 800; +} +h1 { + font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; +} +h4 { + font-size: 20px; +} +a { + color: #404040; +} +a:hover, +a:focus { + color: #0085a1; +} +a img:hover, +a img:focus { + cursor: zoom-in; +} +article { + overflow-x: hidden; +} +blockquote { + color: #808080; + font-style: italic; + font-size: 0.95em; + margin: 20px 0 20px; +} +blockquote p { + margin: 0; +} +.table th, +.table td { + border: 1px solid #eee !important; +} +hr.small { + max-width: 100px; + margin: 15px auto; + border-width: 4px; + border-color: white; +} +@media screen and (max-width: 500px) { + pre code { + display: block; + width: 500px; + } +} +.post-container a { + color: #337ab7; +} +.post-container a:hover, +.post-container a:focus { + color: #0085a1; +} +.post-container ul, +.post-container ol { + margin-bottom: 40px; +} +.post-container ol ol, +.post-container ol ul, +.post-container ul ol, +.post-container ul ul { + margin-bottom: 5px; +} +.post-container li p { + margin: 0; + margin-bottom: 5px; +} +.post-container li h1, +.post-container li h2, +.post-container li h3, +.post-container li h4, +.post-container li h5, +.post-container li h6 { + line-height: 2; + margin-top: 20px; +} +.navbar-custom { + background: white; + position: absolute; + top: 0; + left: 0; + width: 100%; + z-index: 3; + font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; + line-height: 1.7; +} +.navbar-custom .navbar-brand { + font-weight: 800; +} +.navbar-custom .nav li a { + text-transform: uppercase; + font-size: 16px; + font-weight: 800; + letter-spacing: 1px; +} +@media only screen and (min-width: 768px) { + .navbar-custom { + background: transparent; + border-bottom: 1px solid transparent; + } + .navbar-custom body { + font-size: 20px; + } + .navbar-custom .navbar-brand { + color: white; + padding: 20px; + } + .navbar-custom .navbar-brand:hover, + .navbar-custom .navbar-brand:focus { + color: rgba(255, 255, 255, 0.8); + } + .navbar-custom .nav li a { + font-size:18px; + color: white; + padding: 20px; + } + .navbar-custom .nav li a:hover, + .navbar-custom .nav li a:focus { + color: rgba(255, 255, 255, 0.8); + } +} +@media only screen and (min-width: 1170px) { + .navbar-custom { + -webkit-transition: background-color 0.3s; + -moz-transition: background-color 0.3s; + transition: background-color 0.3s; + /* Force Hardware Acceleration in WebKit */ + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + -ms-transform: translate3d(0, 0, 0); + -o-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + } + .navbar-custom.is-fixed { + /* when the user scrolls down, we hide the header right above the viewport */ + position: fixed; + top: -61px; + background-color: rgba(255, 255, 255, 0.9); + border-bottom: 1px solid #f2f2f2; + -webkit-transition: -webkit-transform 0.3s; + -moz-transition: -moz-transform 0.3s; + transition: transform 0.3s; + } + .navbar-custom.is-fixed .navbar-brand { + color: #404040; + } + .navbar-custom.is-fixed .navbar-brand:hover, + .navbar-custom.is-fixed .navbar-brand:focus { + color: #0085a1; + } + .navbar-custom.is-fixed .nav li a { + color: #404040; + } + .navbar-custom.is-fixed .nav li a:hover, + .navbar-custom.is-fixed .nav li a:focus { + color: #0085a1; + } + .navbar-custom.is-visible { + /* if the user changes the scrolling direction, we show the header */ + -webkit-transform: translate3d(0, 100%, 0); + -moz-transform: translate3d(0, 100%, 0); + -ms-transform: translate3d(0, 100%, 0); + -o-transform: translate3d(0, 100%, 0); + transform: translate3d(0, 100%, 0); + } +} +.intro-header { + background: no-repeat center center; + background-color: #808080; + background-attachment: scroll; + -webkit-background-size: cover; + -moz-background-size: cover; + background-size: cover; + -o-background-size: cover; + margin-bottom: 0px; + /* 0 on mobile */ +} +@media only screen and (min-width: 768px) { + .intro-header { + margin-bottom: 20px; + /* response on desktop */ + } +} +.intro-header .site-heading, +.intro-header .post-heading, +.intro-header .page-heading { + padding: 100px 0 50px; + color: white; +} +@media only screen and (min-width: 768px) { + .intro-header .site-heading, + .intro-header .post-heading, + .intro-header .page-heading { + padding: 150px 0; + } +} +.intro-header .site-heading, +.intro-header .page-heading { + text-align: center; +} +.intro-header .site-heading h1, +.intro-header .page-heading h1 { + margin-top: 0; + font-size: 50px; +} +.intro-header .site-heading .subheading, +.intro-header .page-heading .subheading { + font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; + line-height: 1.7; + font-size: 20px; + line-height: 1.1; + display: block; + font-weight: 300; + margin: 10px 0 0; +} +@media only screen and (min-width: 768px) { + .intro-header .site-heading h1, + .intro-header .page-heading h1 { + font-size: 80px; + } +} +.intro-header .post-heading h1 { + font-size: 30px; +} +.intro-header .post-heading .subheading, +.intro-header .post-heading .meta { + line-height: 1.1; + display: block; +} +.intro-header .post-heading .subheading { + font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; + line-height: 1.7; + font-size: 17px; + font-weight: normal; + margin: 10px 0 30px; + margin-top: -5px; +} +.intro-header .post-heading .meta { + font-family: 'Lora', 'Times New Roman', serif; + font-style: italic; + font-weight: 300; + font-size: 18px; +} +.intro-header .post-heading .meta a { + color: white; +} +@media only screen and (min-width: 768px) { + .intro-header .post-heading h1 { + font-size: 55px; + } + .intro-header .post-heading .subheading { + font-size: 30px; + } + .intro-header .post-heading .meta { + font-size: 20px; + } +} +.post-preview > a { + color: #404040; +} +.post-preview > a:hover, +.post-preview > a:focus { + text-decoration: none; + color: #0085a1; +} +.post-preview > a > .post-title { + font-size: 21px; + line-height: 1.3; + margin-top: 30px; + margin-bottom: 8px; +} +.post-preview > a > .post-subtitle { + font-size: 15px; + margin: 0; + font-weight: 300; + margin-bottom: 10px; +} +.post-preview > .post-meta { + font-family: 'Lora', 'Times New Roman', serif; + color: #808080; + font-size: 16px; + font-style: italic; + margin-top: 0; +} +.post-preview > .post-meta > a { + text-decoration: none; + color: #404040; +} +.post-preview > .post-meta > a:hover, +.post-preview > .post-meta > a:focus { + color: #0085a1; + text-decoration: underline; +} +@media only screen and (min-width: 768px) { + .post-preview > a > .post-title { + font-size: 26px; + line-height: 1.3; + margin-bottom: 10px; + } + .post-preview > a > .post-subtitle { + font-size: 16px; + } + .post-preview .post-meta { + font-size: 18px; + } +} +.post-content-preview { + font-size: 16px; + color: #a3a3a3; +} +.post-content-preview:hover { + color: #0085a1; +} +@media only screen and (min-width: 768px) { + .post-content-preview { + font-size: 18px; + } +} +.section-heading { + font-size: 36px; + margin-top: 60px; + font-weight: 700; +} +.caption { + text-align: center; + font-size: 14px; + padding: 10px; + font-style: italic; + margin: 0; + display: block; + border-bottom-right-radius: 5px; + border-bottom-left-radius: 5px; +} +footer { + font-size: 20px; + padding: 50px 0 65px; +} +footer .list-inline { + margin: 0; + padding: 0; +} +footer .copyright { + font-size: 14px; + text-align: center; + margin-bottom: 0; +} +.floating-label-form-group { + font-size: 14px; + position: relative; + margin-bottom: 0; + padding-bottom: 0.5em; + border-bottom: 1px solid #eeeeee; +} +.floating-label-form-group input, +.floating-label-form-group textarea { + z-index: 1; + position: relative; + padding-right: 0; + padding-left: 0; + border: none; + border-radius: 0; + font-size: 1.5em; + background: none; + box-shadow: none !important; + resize: none; +} +.floating-label-form-group label { + display: block; + z-index: 0; + position: relative; + top: 2em; + margin: 0; + font-size: 0.85em; + line-height: 1.764705882em; + vertical-align: middle; + vertical-align: baseline; + opacity: 0; + -webkit-transition: top 0.3s ease,opacity 0.3s ease; + -moz-transition: top 0.3s ease,opacity 0.3s ease; + -ms-transition: top 0.3s ease,opacity 0.3s ease; + transition: top 0.3s ease,opacity 0.3s ease; +} +.floating-label-form-group::not(:first-child) { + padding-left: 14px; + border-left: 1px solid #eeeeee; +} +.floating-label-form-group-with-value label { + top: 0; + opacity: 1; +} +.floating-label-form-group-with-focus label { + color: #0085a1; +} +form .row:first-child .floating-label-form-group { + border-top: 1px solid #eeeeee; +} +.btn { + font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; + line-height: 1.7; + text-transform: uppercase; + font-size: 14px; + font-weight: 800; + letter-spacing: 1px; + border-radius: 0; + padding: 15px 25px; +} +.btn-lg { + font-size: 16px; + padding: 25px 35px; +} +.btn-default:hover, +.btn-default:focus { + background-color: #0085a1; + border: 1px solid #0085a1; + color: white; +} +.pager { + margin: 20px 0 0; +} +.pager li > a, +.pager li > span { + font-family: "Helvetica Neue", Arial, "Hiragino Sans GB", "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif; + line-height: 1.7; + text-transform: uppercase; + font-size: 14px; + font-weight: 800; + letter-spacing: 1px; + padding: 10px 5px; + background-color: white; + border-radius: 0; +} +@media only screen and (min-width: 768px) { + .pager li > a, + .pager li > span { + font-size: 14px; + padding: 15px 25px; + } +} +.pager li > a { + color: #404040; +} +.pager li > a:hover, +.pager li > a:focus { + color: white; + background-color: #0085a1; + border: 1px solid #0085a1; +} +.pager .disabled > a, +.pager .disabled > a:hover, +.pager .disabled > a:focus, +.pager .disabled > span { + color: #808080; + background-color: #404040; + cursor: not-allowed; +} +::-moz-selection { + color: white; + text-shadow: none; + background: #0085a1; +} +::selection { + color: white; + text-shadow: none; + background: #0085a1; +} +img::selection { + color: white; + background: transparent; +} +img::-moz-selection { + color: white; + background: transparent; +} +body { + webkit-tap-highlight-color: #0085a1; +} +/* add tags support */ +.tags { + margin-bottom: -5px; +} +.tags a, +.tags .tag { + display: inline-block; + border: 1px solid rgba(255, 255, 255, 0.8); + border-radius: 999em; + padding: 0 10px; + color: #ffffff; + line-height: 24px; + font-size: 12px; + text-decoration: none; + margin: 0 1px; + margin-bottom: 6px; +} +.tags a:hover, +.tags .tag:hover, +.tags a:active, +.tags .tag:active { + color: white; + border-color: white; + background-color: rgba(255, 255, 255, 0.4); + text-decoration: none; +} +@media only screen and (min-width: 768px) { + .tags a, + .tags .tag { + margin-right: 5px; + } +} +@media only screen and (min-width: 768px) { + #tag-heading { + padding: 50px 0; + } +} +#tag_cloud { + margin: 20px 0 15px 0; +} +#tag_cloud a, +#tag_cloud .tag { + font-size: 14px; + border: none; + line-height: 28px; + margin: 0 2px; + margin-bottom: 8px; +} +#tag_cloud a:hover, +#tag_cloud .tag:hover, +#tag_cloud a:active, +#tag_cloud .tag:active { + background-color: #0085a1 !important; +} +@media only screen and (min-width: 768px) { + #tag_cloud { + margin-bottom: 25px; + } +} +.tag-comments { + font-size: 12px; +} +@media only screen and (min-width: 768px) { + .tag-comments { + font-size: 14px; + } +} +.one-tag-list:first-child { + margin-top: 0px; +} +.listing-seperator { + color: #0085a1; + font-size: 17px !important; +} +.listing-seperator::before { + margin-right: 5px; +} +@media only screen and (min-width: 768px) { + .listing-seperator { + font-size: 20px !important; + line-height: 1.5 !important; + margin-top: 5px; + } +} +.one-tag-list .post-preview { + position: relative; +} +.one-tag-list .post-preview > a .post-title { + font-size: 15px; + margin-top: 20px; +} +.one-tag-list .post-preview > a .post-subtitle { + font-size: 12px; +} +.one-tag-list .post-preview > .post-meta { + position: absolute; + right: 5px; + bottom: 0px; + margin: 0px; + font-size: 12px; + line-height: 12px; +} +@media only screen and (min-width: 768px) { + .one-tag-list .post-preview { + margin-left: 20px; + } + .one-tag-list .post-preview > a > .post-title { + font-size: 18px; + line-height: 1.3; + } + .one-tag-list .post-preview > a > .post-subtitle { + font-size: 14px; + } + .one-tag-list .post-preview .post-meta { + font-size: 18px; + } +} +/* Tags support End*/ +/* make all img responsible in post-container */ +.post-container img { + display: block; + max-width: 100%; + height: auto; + margin: 1.5em auto 1.6em auto; +} +.post-container img.shadow { + box-shadow: rgba(0, 0, 0, 0.258824) 0px 2px 5px 0px; +} +/* Optimize UserExperience */ +.navbar-default .navbar-toggle:focus, +.navbar-default .navbar-toggle:hover { + background-color: inherit; +} +.navbar-default .navbar-toggle:active { + background-color: #ddd; +} +/* customize Style for navBar button */ +.navbar-default .navbar-toggle { + border-color: transparent; + padding: 14px 11px; + margin-top: 4px; + margin-right: 10px; + margin-bottom: 4px; + border-radius: 50%; +} +.navbar-default .navbar-toggle .icon-bar { + width: 18px; + border-radius: 0px; +} +.navbar-default .navbar-toggle .icon-bar + .icon-bar { + margin-top: 3px; +} +/* customize Style for Duoshuo */ +.comment #ds-thread { + margin-top: 20px; +} +.comment #ds-thread #ds-reset a.ds-like-thread-button { + border: 1px solid #ddd; + border-radius: 0px; + background: white; + box-shadow: none; + text-shadow: none; +} +.comment #ds-thread #ds-reset li.ds-tab a.ds-current { + border: 1px solid #ddd; + border-radius: 0px; + background: white; + box-shadow: none; + text-shadow: none; +} +.comment #ds-thread #ds-reset .ds-textarea-wrapper { + background: none; +} +.comment #ds-thread #ds-reset .ds-gradient-bg { + background: none; +} +#ds-smilies-tooltip ul.ds-smilies-tabs li a { + background: white !important; +} diff --git a/css/codeboy.min.css b/css/codeboy.min.css new file mode 100644 index 0000000..2e8de29 --- /dev/null +++ b/css/codeboy.min.css @@ -0,0 +1 @@ +body{font-family:"Helvetica Neue",Arial,"Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;font-size:16px;color:#404040;overflow-x:hidden}p{margin:30px 0}h1,h2,h3,h4,h5,h6{font-family:"Helvetica Neue",Arial,"Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;line-height:1.1;font-weight:800}h1{font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif}h4{font-size:20px}a{color:#404040}a:hover,a:focus{color:#0085a1}a img:hover,a img:focus{cursor:zoom-in}article{overflow-x:hidden}blockquote{color:gray;font-style:italic;font-size:.95em;margin:20px 0 20px}blockquote p{margin:0}.table th,.table td{border:1px solid #eee !important}hr.small{max-width:100px;margin:15px auto;border-width:4px;border-color:white}@media screen and (max-width:500px){pre code{display:block;width:500px}}.post-container a{color:#337ab7}.post-container a:hover,.post-container a:focus{color:#0085a1}.post-container ul,.post-container ol{margin-bottom:40px}.post-container ol ol,.post-container ol ul,.post-container ul ol,.post-container ul ul{margin-bottom:5px}.post-container li p{margin:0;margin-bottom:5px}.post-container li h1,.post-container li h2,.post-container li h3,.post-container li h4,.post-container li h5,.post-container li h6{line-height:2;margin-top:20px}.navbar-custom{background:white;position:absolute;top:0;left:0;width:100%;z-index:3;font-family:"Helvetica Neue",Arial,"Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7}.navbar-custom .navbar-brand{font-weight:800}.navbar-custom .nav li a{text-transform:uppercase;font-size:16px;font-weight:800;letter-spacing:1px}@media only screen and (min-width:768px){.navbar-custom{background:transparent;border-bottom:1px solid transparent}.navbar-custom body{font-size:20px}.navbar-custom .navbar-brand{color:white;padding:20px}.navbar-custom .navbar-brand:hover,.navbar-custom .navbar-brand:focus{color:rgba(255,255,255,0.8)}.navbar-custom .nav li a{font-size:18px;color:white;padding:20px}.navbar-custom .nav li a:hover,.navbar-custom .nav li a:focus{color:rgba(255,255,255,0.8)}}@media only screen and (min-width:1170px){.navbar-custom{-webkit-transition:background-color .3s;-moz-transition:background-color .3s;transition:background-color .3s;-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);-o-transform:translate3d(0,0,0);transform:translate3d(0,0,0);-webkit-backface-visibility:hidden;backface-visibility:hidden}.navbar-custom.is-fixed{position:fixed;top:-61px;background-color:rgba(255,255,255,0.9);border-bottom:1px solid #f2f2f2;-webkit-transition:-webkit-transform .3s;-moz-transition:-moz-transform .3s;transition:transform .3s}.navbar-custom.is-fixed .navbar-brand{color:#404040}.navbar-custom.is-fixed .navbar-brand:hover,.navbar-custom.is-fixed .navbar-brand:focus{color:#0085a1}.navbar-custom.is-fixed .nav li a{color:#404040}.navbar-custom.is-fixed .nav li a:hover,.navbar-custom.is-fixed .nav li a:focus{color:#0085a1}.navbar-custom.is-visible{-webkit-transform:translate3d(0,100%,0);-moz-transform:translate3d(0,100%,0);-ms-transform:translate3d(0,100%,0);-o-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}}.intro-header{background:no-repeat center center;background-color:gray;background-attachment:scroll;-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;-o-background-size:cover;margin-bottom:0}@media only screen and (min-width:768px){.intro-header{margin-bottom:20px}}.intro-header .site-heading,.intro-header .post-heading,.intro-header .page-heading{padding:100px 0 50px;color:white}@media only screen and (min-width:768px){.intro-header .site-heading,.intro-header .post-heading,.intro-header .page-heading{padding:150px 0}}.intro-header .site-heading,.intro-header .page-heading{text-align:center}.intro-header .site-heading h1,.intro-header .page-heading h1{margin-top:0;font-size:50px}.intro-header .site-heading .subheading,.intro-header .page-heading .subheading{font-family:"Helvetica Neue",Arial,"Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;font-size:20px;line-height:1.1;display:block;font-weight:300;margin:10px 0 0}@media only screen and (min-width:768px){.intro-header .site-heading h1,.intro-header .page-heading h1{font-size:80px}}.intro-header .post-heading h1{font-size:30px}.intro-header .post-heading .subheading,.intro-header .post-heading .meta{line-height:1.1;display:block}.intro-header .post-heading .subheading{font-family:"Helvetica Neue",Arial,"Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;font-size:17px;font-weight:normal;margin:10px 0 30px;margin-top:-5px}.intro-header .post-heading .meta{font-family:'Lora','Times New Roman',serif;font-style:italic;font-weight:300;font-size:18px}.intro-header .post-heading .meta a{color:white}@media only screen and (min-width:768px){.intro-header .post-heading h1{font-size:55px}.intro-header .post-heading .subheading{font-size:30px}.intro-header .post-heading .meta{font-size:20px}}.post-preview>a{color:#404040}.post-preview>a:hover,.post-preview>a:focus{text-decoration:none;color:#0085a1}.post-preview>a>.post-title{font-size:21px;line-height:1.3;margin-top:30px;margin-bottom:8px}.post-preview>a>.post-subtitle{font-size:15px;margin:0;font-weight:300;margin-bottom:10px}.post-preview>.post-meta{font-family:'Lora','Times New Roman',serif;color:gray;font-size:16px;font-style:italic;margin-top:0}.post-preview>.post-meta>a{text-decoration:none;color:#404040}.post-preview>.post-meta>a:hover,.post-preview>.post-meta>a:focus{color:#0085a1;text-decoration:underline}@media only screen and (min-width:768px){.post-preview>a>.post-title{font-size:26px;line-height:1.3;margin-bottom:10px}.post-preview>a>.post-subtitle{font-size:16px}.post-preview .post-meta{font-size:18px}}.post-content-preview{font-size:16px;color:#a3a3a3}.post-content-preview:hover{color:#0085a1}@media only screen and (min-width:768px){.post-content-preview{font-size:18px}}.section-heading{font-size:36px;margin-top:60px;font-weight:700}.caption{text-align:center;font-size:14px;padding:10px;font-style:italic;margin:0;display:block;border-bottom-right-radius:5px;border-bottom-left-radius:5px}footer{font-size:20px;padding:50px 0 65px}footer .list-inline{margin:0;padding:0}footer .copyright{font-size:14px;text-align:center;margin-bottom:0}.floating-label-form-group{font-size:14px;position:relative;margin-bottom:0;padding-bottom:.5em;border-bottom:1px solid #eee}.floating-label-form-group input,.floating-label-form-group textarea{z-index:1;position:relative;padding-right:0;padding-left:0;border:0;border-radius:0;font-size:1.5em;background:0;box-shadow:none !important;resize:none}.floating-label-form-group label{display:block;z-index:0;position:relative;top:2em;margin:0;font-size:.85em;line-height:1.764705882em;vertical-align:middle;vertical-align:baseline;opacity:0;-webkit-transition:top .3s ease,opacity .3s ease;-moz-transition:top .3s ease,opacity .3s ease;-ms-transition:top .3s ease,opacity .3s ease;transition:top .3s ease,opacity .3s ease}.floating-label-form-group::not(:first-child){padding-left:14px;border-left:1px solid #eee}.floating-label-form-group-with-value label{top:0;opacity:1}.floating-label-form-group-with-focus label{color:#0085a1}form .row:first-child .floating-label-form-group{border-top:1px solid #eee}.btn{font-family:"Helvetica Neue",Arial,"Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;text-transform:uppercase;font-size:14px;font-weight:800;letter-spacing:1px;border-radius:0;padding:15px 25px}.btn-lg{font-size:16px;padding:25px 35px}.btn-default:hover,.btn-default:focus{background-color:#0085a1;border:1px solid #0085a1;color:white}.pager{margin:20px 0 0}.pager li>a,.pager li>span{font-family:"Helvetica Neue",Arial,"Hiragino Sans GB","STHeiti","Microsoft YaHei","WenQuanYi Micro Hei",SimSun,sans-serif;line-height:1.7;text-transform:uppercase;font-size:14px;font-weight:800;letter-spacing:1px;padding:10px 5px;background-color:white;border-radius:0}@media only screen and (min-width:768px){.pager li>a,.pager li>span{font-size:14px;padding:15px 25px}}.pager li>a{color:#404040}.pager li>a:hover,.pager li>a:focus{color:white;background-color:#0085a1;border:1px solid #0085a1}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:gray;background-color:#404040;cursor:not-allowed}::-moz-selection{color:white;text-shadow:none;background:#0085a1}::selection{color:white;text-shadow:none;background:#0085a1}img::selection{color:white;background:transparent}img::-moz-selection{color:white;background:transparent}body{webkit-tap-highlight-color:#0085a1}.tags{margin-bottom:-5px}.tags a,.tags .tag{display:inline-block;border:1px solid rgba(255,255,255,0.8);border-radius:999em;padding:0 10px;color:#fff;line-height:24px;font-size:12px;text-decoration:none;margin:0 1px;margin-bottom:6px}.tags a:hover,.tags .tag:hover,.tags a:active,.tags .tag:active{color:white;border-color:white;background-color:rgba(255,255,255,0.4);text-decoration:none}@media only screen and (min-width:768px){.tags a,.tags .tag{margin-right:5px}}@media only screen and (min-width:768px){#tag-heading{padding:50px 0}}#tag_cloud{margin:20px 0 15px 0}#tag_cloud a,#tag_cloud .tag{font-size:14px;border:0;line-height:28px;margin:0 2px;margin-bottom:8px}#tag_cloud a:hover,#tag_cloud .tag:hover,#tag_cloud a:active,#tag_cloud .tag:active{background-color:#0085a1 !important}@media only screen and (min-width:768px){#tag_cloud{margin-bottom:25px}}.tag-comments{font-size:12px}@media only screen and (min-width:768px){.tag-comments{font-size:14px}}.one-tag-list:first-child{margin-top:0}.listing-seperator{color:#0085a1;font-size:17px !important}.listing-seperator::before{margin-right:5px}@media only screen and (min-width:768px){.listing-seperator{font-size:20px !important;line-height:1.5 !important;margin-top:5px}}.one-tag-list .post-preview{position:relative}.one-tag-list .post-preview>a .post-title{font-size:15px;margin-top:20px}.one-tag-list .post-preview>a .post-subtitle{font-size:12px}.one-tag-list .post-preview>.post-meta{position:absolute;right:5px;bottom:0;margin:0;font-size:12px;line-height:12px}@media only screen and (min-width:768px){.one-tag-list .post-preview{margin-left:20px}.one-tag-list .post-preview>a>.post-title{font-size:18px;line-height:1.3}.one-tag-list .post-preview>a>.post-subtitle{font-size:14px}.one-tag-list .post-preview .post-meta{font-size:18px}}.post-container img{display:block;max-width:100%;height:auto;margin:1.5em auto 1.6em auto}.post-container img.shadow{box-shadow:rgba(0,0,0,0.258824) 0 2px 5px 0}.navbar-default .navbar-toggle:focus,.navbar-default .navbar-toggle:hover{background-color:inherit}.navbar-default .navbar-toggle:active{background-color:#ddd}.navbar-default .navbar-toggle{border-color:transparent;padding:14px 11px;margin-top:4px;margin-right:10px;margin-bottom:4px;border-radius:50%}.navbar-default .navbar-toggle .icon-bar{width:18px;border-radius:0}.navbar-default .navbar-toggle .icon-bar+.icon-bar{margin-top:3px}.comment #ds-thread{margin-top:20px}.comment #ds-thread #ds-reset a.ds-like-thread-button{border:1px solid #ddd;border-radius:0;background:white;box-shadow:none;text-shadow:none}.comment #ds-thread #ds-reset li.ds-tab a.ds-current{border:1px solid #ddd;border-radius:0;background:white;box-shadow:none;text-shadow:none}.comment #ds-thread #ds-reset .ds-textarea-wrapper{background:0}.comment #ds-thread #ds-reset .ds-gradient-bg{background:0}#ds-smilies-tooltip ul.ds-smilies-tabs li a{background:white !important} \ No newline at end of file diff --git a/css/syntax.css b/css/syntax.css new file mode 100644 index 0000000..f668cb7 --- /dev/null +++ b/css/syntax.css @@ -0,0 +1,119 @@ +/* to make lines scroll instead of wrap */ +/* from http://stackoverflow.com/a/23393920 */ + +.highlight pre code * { + white-space: nowrap; // this sets all children inside to nowrap +} + +.highlight pre { + overflow-x: auto; // this sets the scrolling in x +} + +.highlight pre code { + white-space: pre; // forces to respect
 formatting
+}
+
+
+/*
+ * GitHub style for Pygments syntax highlighter, for use with Jekyll
+ * Courtesy of GitHub.com
+ */
+
+.highlight pre, pre, .highlight .hll { background-color: #f8f8f8; border: 1px solid #ccc; padding: 6px 10px; border-radius: 3px; }
+.highlight .c { color: #999988; font-style: italic; }
+.highlight .err { color: #a61717; background-color: #e3d2d2; }
+.highlight .k { font-weight: bold; }
+.highlight .o { font-weight: bold; }
+.highlight .cm { color: #999988; font-style: italic; }
+.highlight .cp { color: #999999; font-weight: bold; }
+.highlight .c1 { color: #999988; font-style: italic; }
+.highlight .cs { color: #999999; font-weight: bold; font-style: italic; }
+.highlight .gd { color: #000000; background-color: #ffdddd; }
+.highlight .gd .x { color: #000000; background-color: #ffaaaa; }
+.highlight .ge { font-style: italic; }
+.highlight .gr { color: #aa0000; }
+.highlight .gh { color: #999999; }
+.highlight .gi { color: #000000; background-color: #ddffdd; }
+.highlight .gi .x { color: #000000; background-color: #aaffaa; }
+.highlight .go { color: #888888; }
+.highlight .gp { color: #555555; }
+.highlight .gs { font-weight: bold; }
+.highlight .gu { color: #800080; font-weight: bold; }
+.highlight .gt { color: #aa0000; }
+.highlight .kc { font-weight: bold; }
+.highlight .kd { font-weight: bold; }
+.highlight .kn { font-weight: bold; }
+.highlight .kp { font-weight: bold; }
+.highlight .kr { font-weight: bold; }
+.highlight .kt { color: #445588; font-weight: bold; }
+.highlight .m { color: #009999; }
+.highlight .s { color: #dd1144; }
+.highlight .n { color: #333333; }
+.highlight .na { color: teal; }
+.highlight .nb { color: #0086b3; }
+.highlight .nc { color: #445588; font-weight: bold; }
+.highlight .no { color: teal; }
+.highlight .ni { color: purple; }
+.highlight .ne { color: #990000; font-weight: bold; }
+.highlight .nf { color: #990000; font-weight: bold; }
+.highlight .nn { color: #555555; }
+.highlight .nt { color: navy; }
+.highlight .nv { color: teal; }
+.highlight .ow { font-weight: bold; }
+.highlight .w { color: #bbbbbb; }
+.highlight .mf { color: #009999; }
+.highlight .mh { color: #009999; }
+.highlight .mi { color: #009999; }
+.highlight .mo { color: #009999; }
+.highlight .sb { color: #dd1144; }
+.highlight .sc { color: #dd1144; }
+.highlight .sd { color: #dd1144; }
+.highlight .s2 { color: #dd1144; }
+.highlight .se { color: #dd1144; }
+.highlight .sh { color: #dd1144; }
+.highlight .si { color: #dd1144; }
+.highlight .sx { color: #dd1144; }
+.highlight .sr { color: #009926; }
+.highlight .s1 { color: #dd1144; }
+.highlight .ss { color: #990073; }
+.highlight .bp { color: #999999; }
+.highlight .vc { color: teal; }
+.highlight .vg { color: teal; }
+.highlight .vi { color: teal; }
+.highlight .il { color: #009999; }
+.highlight .gc { color: #999; background-color: #EAF2F5; }
+
+.hljs {
+	border: 0;
+	font-family: "Consulas", "Courier New", Courier, mono, serif;
+	font-size: 14px;
+	/*background: #f8f8f8 !important;*/
+	display: block;
+	padding: 1px;
+	margin: 0;
+	width: 100%;
+	font-weight: 200;
+	color: #333;
+	white-space: pre-wrap
+}
+.hljs ul {
+	list-style: decimal;
+	/*background-color: #f8f8f8;*/
+	margin: 0px 0px 0 36px !important;
+	padding: 0px;
+  right: -14px;
+}
+.hljs ul li {
+	list-style: decimal-leading-zero;
+	border-left: 1px solid #ccc !important;
+	/*background: #fff;*/
+  padding: 1px 5px 1px 10px !important;
+	margin: 0 !important;
+	/*line-height: 14px;*/
+	word-break: break-all;
+	word-wrap: break-word;
+}
+.hljs ul li:nth-of-type(even) {
+	/*background-color: #f8f8f8;*/
+	/*color: inherit;*/
+}
diff --git a/feed.xml b/feed.xml
new file mode 100644
index 0000000..022378b
--- /dev/null
+++ b/feed.xml
@@ -0,0 +1,30 @@
+---
+layout: null
+---
+
+
+  
+    {{ site.title | xml_escape }}
+    {{ site.description | xml_escape }}
+    {{ site.url }}{{ site.baseurl }}/
+    
+    {{ site.time | date_to_rfc822 }}
+    {{ site.time | date_to_rfc822 }}
+    Jekyll v{{ jekyll.version }}
+    {% for post in site.posts limit:10 %}
+      
+        {{ post.title | xml_escape }}
+        {{ post.content | xml_escape }}
+        {{ post.date | date_to_rfc822 }}
+        {{ post.url | prepend: site.baseurl | prepend: site.url }}
+        {{ post.url | prepend: site.baseurl | prepend: site.url }}
+        {% for tag in post.tags %}
+        {{ tag | xml_escape }}
+        {% endfor %}
+        {% for cat in post.categories %}
+        {{ cat | xml_escape }}
+        {% endfor %}
+      
+    {% endfor %}
+  
+
diff --git a/img/about-bg.jpg b/img/about-bg.jpg
new file mode 100644
index 0000000..af6d4d5
Binary files /dev/null and b/img/about-bg.jpg differ
diff --git a/img/close.png b/img/close.png
new file mode 100644
index 0000000..f45d924
Binary files /dev/null and b/img/close.png differ
diff --git a/img/contact-bg.jpg b/img/contact-bg.jpg
new file mode 100644
index 0000000..9bf21a4
Binary files /dev/null and b/img/contact-bg.jpg differ
diff --git a/img/favicon.ico b/img/favicon.ico
new file mode 100644
index 0000000..c1076aa
Binary files /dev/null and b/img/favicon.ico differ
diff --git a/img/ftp_server.png b/img/ftp_server.png
new file mode 100644
index 0000000..63b40e1
Binary files /dev/null and b/img/ftp_server.png differ
diff --git a/img/github.png b/img/github.png
new file mode 100644
index 0000000..316c05e
Binary files /dev/null and b/img/github.png differ
diff --git a/img/home-bg.jpg b/img/home-bg.jpg
new file mode 100644
index 0000000..f67fb3a
Binary files /dev/null and b/img/home-bg.jpg differ
diff --git a/img/image-gray.png b/img/image-gray.png
new file mode 100644
index 0000000..673e57b
Binary files /dev/null and b/img/image-gray.png differ
diff --git a/img/image-rgb.png b/img/image-rgb.png
new file mode 100644
index 0000000..86a121e
Binary files /dev/null and b/img/image-rgb.png differ
diff --git a/img/image-src.png b/img/image-src.png
new file mode 100644
index 0000000..b7687b8
Binary files /dev/null and b/img/image-src.png differ
diff --git a/img/ios-restrict-app.png b/img/ios-restrict-app.png
new file mode 100644
index 0000000..083d11b
Binary files /dev/null and b/img/ios-restrict-app.png differ
diff --git a/img/message_to_mail.png b/img/message_to_mail.png
new file mode 100644
index 0000000..0b4f2cc
Binary files /dev/null and b/img/message_to_mail.png differ
diff --git a/img/open-bg.jpg b/img/open-bg.jpg
new file mode 100644
index 0000000..778a553
Binary files /dev/null and b/img/open-bg.jpg differ
diff --git a/img/post-bg-android.jpg b/img/post-bg-android.jpg
new file mode 100644
index 0000000..0e5a261
Binary files /dev/null and b/img/post-bg-android.jpg differ
diff --git a/img/post-bg-iphone.jpg b/img/post-bg-iphone.jpg
new file mode 100644
index 0000000..9cca4fb
Binary files /dev/null and b/img/post-bg-iphone.jpg differ
diff --git a/img/post-bg-java.jpg b/img/post-bg-java.jpg
new file mode 100644
index 0000000..21d19b9
Binary files /dev/null and b/img/post-bg-java.jpg differ
diff --git a/img/post-bg-theory.jpg b/img/post-bg-theory.jpg
new file mode 100644
index 0000000..1b4ca62
Binary files /dev/null and b/img/post-bg-theory.jpg differ
diff --git a/img/post-bg-tranquil.jpg b/img/post-bg-tranquil.jpg
new file mode 100644
index 0000000..c838ad2
Binary files /dev/null and b/img/post-bg-tranquil.jpg differ
diff --git a/img/post-bg-unix.jpg b/img/post-bg-unix.jpg
new file mode 100644
index 0000000..fe06f60
Binary files /dev/null and b/img/post-bg-unix.jpg differ
diff --git a/img/post-bg-web.jpg b/img/post-bg-web.jpg
new file mode 100644
index 0000000..726547c
Binary files /dev/null and b/img/post-bg-web.jpg differ
diff --git a/img/search.png b/img/search.png
new file mode 100644
index 0000000..998e5d2
Binary files /dev/null and b/img/search.png differ
diff --git a/img/tags-bg.jpg b/img/tags-bg.jpg
new file mode 100644
index 0000000..a4d2108
Binary files /dev/null and b/img/tags-bg.jpg differ
diff --git a/img/ustc_client.png b/img/ustc_client.png
new file mode 100644
index 0000000..3809f5d
Binary files /dev/null and b/img/ustc_client.png differ
diff --git a/img/zzu_client.png b/img/zzu_client.png
new file mode 100644
index 0000000..f78acff
Binary files /dev/null and b/img/zzu_client.png differ
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..8a0f385
--- /dev/null
+++ b/index.html
@@ -0,0 +1,40 @@
+---
+layout: page
+description: "编码生涯的点点滴滴"
+---
+
+{% for post in paginator.posts %}
+
+ +

{{ post.title }} +

+ {% if post.subtitle %} +

+ {{ post.subtitle }} +

+ {% endif %} +
+ {{ post.content | strip_html | truncate:200 }} +
+
+ + +
+
+{% endfor %} + + +{% if paginator.total_pages > 1 %} + +{% endif %} diff --git a/js/codeboy.js b/js/codeboy.js new file mode 100644 index 0000000..8e5c4e1 --- /dev/null +++ b/js/codeboy.js @@ -0,0 +1,63 @@ +/*! + * Clean Blog v1.0.0 (http://startbootstrap.com) + * Copyright 2015 Start Bootstrap + * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE) + */ + +// Tooltip Init +$(function() { + $("[data-toggle='tooltip']").tooltip(); +}); + +// make all images responsive +/* + * actually only Portfolio-Pages can't use it and only post-img need it. + * so I modify the _layout/post and CSS to make post-img responsive! + */ +// $(function() { +// $("img").addClass("img-responsive"); +// }); + +// responsive tables +$(document).ready(function() { + $("table").wrap("
"); + $("table").addClass("table"); +}); + +// responsive embed videos +$(document).ready(function () { + $('iframe[src*="youku.com"]').wrap('
'); + $('iframe[src*="youku.com"]').addClass('embed-responsive-item'); + $('iframe[src*="vimeo.com"]').wrap('
'); + $('iframe[src*="vimeo.com"]').addClass('embed-responsive-item'); +}); + +// Navigation Scripts to Show Header on Scroll-Up +jQuery(document).ready(function($) { + var MQL = 1170; + + //primary navigation slide-in effect + if ($(window).width() > MQL) { + var headerHeight = $('.navbar-custom').height(); + $(window).on('scroll', { + previousTop: 0 + }, + function() { + var currentTop = $(window).scrollTop(); + //check if user is scrolling up + if (currentTop < this.previousTop) { + //if scrolling up... + if (currentTop > 0 && $('.navbar-custom').hasClass('is-fixed')) { + $('.navbar-custom').addClass('is-visible'); + } else { + $('.navbar-custom').removeClass('is-visible is-fixed'); + } + } else { + //if scrolling down... + $('.navbar-custom').removeClass('is-visible'); + if (currentTop > headerHeight && !$('.navbar-custom').hasClass('is-fixed')) $('.navbar-custom').addClass('is-fixed'); + } + this.previousTop = currentTop; + }); + } +}); diff --git a/js/codeboy.min.js b/js/codeboy.min.js new file mode 100644 index 0000000..0b5a327 --- /dev/null +++ b/js/codeboy.min.js @@ -0,0 +1,6 @@ +/*! + * Clean Blog v1.0.0 (http://startbootstrap.com) + * Copyright 2015 Start Bootstrap + * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE) + */ +;$(function(){$("[data-toggle='tooltip']").tooltip()});$(document).ready(function(){$("table").wrap("
");$("table").addClass("table")});$(document).ready(function(){$('iframe[src*="youku.com"]').wrap('
');$('iframe[src*="youku.com"]').addClass("embed-responsive-item");$('iframe[src*="vimeo.com"]').wrap('
');$('iframe[src*="vimeo.com"]').addClass("embed-responsive-item")});jQuery(document).ready(function(b){var c=1170;if(b(window).width()>c){var a=b(".navbar-custom").height();b(window).on("scroll",{previousTop:0},function(){var d=b(window).scrollTop();if(d0&&b(".navbar-custom").hasClass("is-fixed")){b(".navbar-custom").addClass("is-visible")}else{b(".navbar-custom").removeClass("is-visible is-fixed")}}else{b(".navbar-custom").removeClass("is-visible");if(d>a&&!b(".navbar-custom").hasClass("is-fixed")){b(".navbar-custom").addClass("is-fixed")}}this.previousTop=d})}}); \ No newline at end of file diff --git a/js/jquery.tagcloud.js b/js/jquery.tagcloud.js new file mode 100644 index 0000000..9c97bfa --- /dev/null +++ b/js/jquery.tagcloud.js @@ -0,0 +1,81 @@ +(function($) { + + $.fn.tagcloud = function(options) { + var opts = $.extend({}, $.fn.tagcloud.defaults, options); + tagWeights = this.map(function(){ + return $(this).attr("rel"); + }); + tagWeights = jQuery.makeArray(tagWeights).sort(compareWeights); + lowest = tagWeights[0]; + highest = tagWeights.pop(); + range = highest - lowest; + if(range === 0) {range = 1;} + // Sizes + if (opts.size) { + fontIncr = (opts.size.end - opts.size.start)/range; + } + // Colors + if (opts.color) { + colorIncr = colorIncrement (opts.color, range); + } + return this.each(function() { + weighting = $(this).attr("rel") - lowest; + if (opts.size) { + $(this).css({"font-size": opts.size.start + (weighting * fontIncr) + opts.size.unit}); + } + if (opts.color) { + // change color to background-color + $(this).css({"backgroundColor": tagColor(opts.color, colorIncr, weighting)}); + } + }); + }; + + $.fn.tagcloud.defaults = { + size: {start: 14, end: 18, unit: "pt"} + }; + + // Converts hex to an RGB array + function toRGB (code) { + if (code.length == 4) { + code = jQuery.map(/\w+/.exec(code), function(el) {return el + el; }).join(""); + } + hex = /(\w{2})(\w{2})(\w{2})/.exec(code); + return [parseInt(hex[1], 16), parseInt(hex[2], 16), parseInt(hex[3], 16)]; + } + + // Converts an RGB array to hex + function toHex (ary) { + return "#" + jQuery.map(ary, function(i) { + hex = i.toString(16); + hex = (hex.length == 1) ? "0" + hex : hex; + return hex; + }).join(""); + } + + function colorIncrement (color, range) { + return jQuery.map(toRGB(color.end), function(n, i) { + return (n - toRGB(color.start)[i])/range; + }); + } + + function tagColor (color, increment, weighting) { + rgb = jQuery.map(toRGB(color.start), function(n, i) { + ref = Math.round(n + (increment[i] * weighting)); + if (ref > 255) { + ref = 255; + } else { + if (ref < 0) { + ref = 0; + } + } + return ref; + }); + return toHex(rgb); + } + + function compareWeights(a, b) + { + return a - b; + } + +})(jQuery); diff --git a/open.html b/open.html new file mode 100644 index 0000000..4d073dc --- /dev/null +++ b/open.html @@ -0,0 +1,140 @@ +--- +layout: page +title: "Open" +description: "自由 包容 发展 共赢" +header-img: "img/open-bg.jpg" +--- + + + + +
+ + +
+ + +
+ + + +
+
+ + + + + + + + + + + + diff --git a/search/cb-search.json b/search/cb-search.json new file mode 100644 index 0000000..5b45a1d --- /dev/null +++ b/search/cb-search.json @@ -0,0 +1,17 @@ +--- +layout: null +--- +{ + "code" : 0 , + "data" : [ + {% for post in site.posts %} + { + "title" : "{{ post.title }} - {% for tag in post.tags %}{% if forloop.rindex != 1 %}{{ tag }}_{% else %}{{ tag }}{% endif %}{% endfor %}", + "url" : "{{ post.url }}" + } + {% if forloop.rindex != 1 %} + , + {% endif %} + {% endfor %} + ] +} diff --git a/search/css/cb-search.css b/search/css/cb-search.css new file mode 100644 index 0000000..3abb7a8 --- /dev/null +++ b/search/css/cb-search.css @@ -0,0 +1,61 @@ + @media screen and (min-width: 768px) { + .dropdown-menu { + position:relative; + float: none; + font-size: 20px; + width: 70%; + margin: 0 15%; + } + + .cb-search-tool ul{ + width: 70% ; + white-space:nowrap; + overflow:hidden; + text-overflow: ellipsis; + } + + + .cb-search-content { + width: 70%; + margin: 0 15%; + position: absolute; + top: 13%; + left: auto; + right: auto; + font-size: 22px; + height: 50px; + background-color: #eee; + color: black; + opacity: 1.0; + } + } + + @media screen and (max-width: 767px) { + .dropdown-menu { + position:relative; + float: none; + font-size: 20px; + width: 96%; + margin: 0 2%; + } + .cb-search-tool ul{ + width: 96% ; + white-space:nowrap; + overflow:hidden; + text-overflow: ellipsis; + } + + .cb-search-content { + width: 96%; + margin: 0 2%; + position: absolute; + top: 10%; + left: auto; + right: auto; + font-size: 22px; + height: 50px; + background-color: #eee; + color: black; + opacity: 1.0; + } + } diff --git a/search/img/cb-close.png b/search/img/cb-close.png new file mode 100644 index 0000000..f45d924 Binary files /dev/null and b/search/img/cb-close.png differ diff --git a/search/img/cb-search.png b/search/img/cb-search.png new file mode 100644 index 0000000..998e5d2 Binary files /dev/null and b/search/img/cb-search.png differ diff --git a/search/js/bootstrap3-typeahead.min.js b/search/js/bootstrap3-typeahead.min.js new file mode 100644 index 0000000..49fea66 --- /dev/null +++ b/search/js/bootstrap3-typeahead.min.js @@ -0,0 +1 @@ +!function(a,b){"use strict";"undefined"!=typeof module&&module.exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):b(a.jQuery)}(this,function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.typeahead.defaults,c),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.select=this.options.select||this.select,this.autoSelect="boolean"==typeof this.options.autoSelect?this.options.autoSelect:!0,this.highlighter=this.options.highlighter||this.highlighter,this.render=this.options.render||this.render,this.updater=this.options.updater||this.updater,this.displayText=this.options.displayText||this.displayText,this.source=this.options.source,this.delay=this.options.delay,this.$menu=a(this.options.menu),this.$appendTo=this.options.appendTo?a(this.options.appendTo):null,this.shown=!1,this.listen(),this.showHintOnFocus="boolean"==typeof this.options.showHintOnFocus?this.options.showHintOnFocus:!1,this.afterSelect=this.options.afterSelect,this.addItem=!1};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").data("value");if(this.$element.data("active",a),this.autoSelect||a){var b=this.updater(a);this.$element.val(this.displayText(b)||b).change(),this.afterSelect(b)}return this.hide()},updater:function(a){return a},setSource:function(a){this.source=a},show:function(){var b,c=a.extend({},this.$element.position(),{height:this.$element[0].offsetHeight});return b="function"==typeof this.options.scrollHeight?this.options.scrollHeight.call():this.options.scrollHeight,(this.$appendTo?this.$menu.appendTo(this.$appendTo):this.$menu.insertAfter(this.$element)).css({top:c.top+c.height+b,left:c.left}).show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){if(this.query="undefined"!=typeof b&&null!==b?b:this.$element.val()||"",this.query.length0?this.$element.data("active",b[0]):this.$element.data("active",null),this.options.addItem&&b.push(this.options.addItem),"all"==this.options.items?this.render(b).show():this.render(b.slice(0,this.options.items)).show()):this.shown?this.hide():this},matcher:function(a){var b=this.displayText(a);return~b.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){for(var b,c=[],d=[],e=[];b=a.shift();){var f=this.displayText(b);f.toLowerCase().indexOf(this.query.toLowerCase())?~f.indexOf(this.query)?d.push(b):e.push(b):c.push(b)}return c.concat(d,e)},highlighter:function(b){var c,d,e,f,g,h=a("
"),i=this.query,j=b.toLowerCase().indexOf(i.toLowerCase());if(c=i.length,0===c)return h.text(b).html();for(;j>-1;)d=b.substr(0,j),e=b.substr(j,c),f=b.substr(j+c),g=a("").text(e),h.append(document.createTextNode(d)).append(g),b=f,j=b.toLowerCase().indexOf(i.toLowerCase());return h.append(document.createTextNode(b)).html()},render:function(b){var c=this,d=this,e=!1;return b=a(b).map(function(b,f){var g=d.displayText(f);return b=a(c.options.item).data("value",f),b.find("a").html(c.highlighter(g)),g==d.$element.val()&&(b.addClass("active"),d.$element.data("active",f),e=!0),b[0]}),this.autoSelect&&!e&&(b.first().addClass("active"),this.$element.data("active",b.first().data("value"))),this.$menu.html(b),this},displayText:function(a){return a.name||a},next:function(){var b=this.$menu.find(".active").removeClass("active"),c=b.next();c.length||(c=a(this.$menu.find("li")[0])),c.addClass("active")},prev:function(){var a=this.$menu.find(".active").removeClass("active"),b=a.prev();b.length||(b=this.$menu.find("li").last()),b.addClass("active")},listen:function(){this.$element.on("focus",a.proxy(this.focus,this)).on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),this.eventSupported("keydown")&&this.$element.on("keydown",a.proxy(this.keydown,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this)).on("mouseleave","li",a.proxy(this.mouseleave,this))},destroy:function(){this.$element.data("typeahead",null),this.$element.data("active",null),this.$element.off("focus").off("blur").off("keypress").off("keyup"),this.eventSupported("keydown")&&this.$element.off("keydown"),this.$menu.remove()},eventSupported:function(a){var b=a in this.$element;return b||(this.$element.setAttribute(a,"return;"),b="function"==typeof this.$element[a]),b},move:function(a){if(this.shown){switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:if(a.shiftKey)return;a.preventDefault(),this.prev();break;case 40:if(a.shiftKey)return;a.preventDefault(),this.next()}a.stopPropagation()}},keydown:function(b){this.suppressKeyPressRepeat=~a.inArray(b.keyCode,[40,38,9,13,27]),this.shown||40!=b.keyCode?this.move(b):this.lookup()},keypress:function(a){this.suppressKeyPressRepeat||this.move(a)},keyup:function(a){switch(a.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}a.stopPropagation(),a.preventDefault()},focus:function(){this.focused||(this.focused=!0,this.options.showHintOnFocus&&this.lookup(""))},blur:function(){this.focused=!1,!this.mousedover&&this.shown&&this.hide()},click:function(a){a.stopPropagation(),a.preventDefault(),this.select(),this.$element.focus()},mouseenter:function(b){this.mousedover=!0,this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")},mouseleave:function(){this.mousedover=!1,!this.focused&&this.shown&&this.hide()}};var c=a.fn.typeahead;a.fn.typeahead=function(c){var d=arguments;return"string"==typeof c&&"getActive"==c?this.data("active"):this.each(function(){var e=a(this),f=e.data("typeahead"),g="object"==typeof c&&c;f||e.data("typeahead",f=new b(this,g)),"string"==typeof c&&(d.length>1?f[c].apply(f,Array.prototype.slice.call(d,1)):f[c]())})},a.fn.typeahead.defaults={source:[],items:8,menu:'',item:'
  • ',minLength:1,scrollHeight:0,autoSelect:!0,afterSelect:a.noop,delay:0,addItem:!1},a.fn.typeahead.Constructor=b,a.fn.typeahead.noConflict=function(){return a.fn.typeahead=c,this},a(document).on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(){var b=a(this);b.data("typeahead")||b.typeahead(b.data())})}); \ No newline at end of file diff --git a/search/js/cb-search.js b/search/js/cb-search.js new file mode 100644 index 0000000..e3b87a2 --- /dev/null +++ b/search/js/cb-search.js @@ -0,0 +1,85 @@ + $(document).ready(function () { + var time1 = 0; + var show = false; + var names = new Array(); //文章名字等 + var urls = new Array(); //文章地址 + $(document).keyup(function (e) { + var time2 = new Date().getTime(); + if (e.keyCode == 17) { + var gap = time2 - time1; + time1 = time2; + if (gap < 500) { + if (show) { + $(".cb-search-tool").css("display", "none"); + show = false; + } else { + $(".cb-search-tool").css("display", "block"); + show = true; + $("#cb-search-content").val(""); + $("#cb-search-content").focus(); + } + time1 = 0; + } + }else if(e.keyCode == 27){ + $(".cb-search-tool").css("display", "none"); + show = false; + time1 = 0; + } + }); + + $("#cb-search-content").keyup(function (e) { + var time2 = new Date().getTime(); + if (e.keyCode == 17) { + var gap = time2 - time1; + time1 = time2; + if (gap < 500) { + if (show) { + $(".cb-search-tool").css("display", "none"); + show = false; + } else { + $(".cb-search-tool").css("display", "block"); + show = true; + $("#cb-search-content").val(""); + $("#cb-search-content").focus(); + } + time1 = 0; + } + } + }); + + $("#cb-close-btn").click(function () { + $(".cb-search-tool").css("display", "none"); + show = false; + time1 = 0; + }); + + $("#cb-search-btn").click(function(){ + $(".cb-search-tool").css("display", "block"); + show = true; + $("#cb-search-content").val(""); + $("#cb-search-content").focus(); + time1 = 0; + }); + + $.getJSON("/search/cb-search.json").done(function (data) { + if (data.code == 0) { + for (var index in data.data) { + var item = data.data[index]; + names.push(item.title); + urls.push(item.url); + } + + $("#cb-search-content").typeahead({ + source: names, + + afterSelect: function (item) { + $(".cb-search-tool").css("display", "none"); + show = false; + window.location.href = (urls[names.indexOf(item)]); + return item; + } + }); + } + }); + + }); diff --git a/tags.html b/tags.html new file mode 100644 index 0000000..286b3a4 --- /dev/null +++ b/tags.html @@ -0,0 +1,62 @@ +--- +title: Tags +layout: default +header-img: "img/tags-bg.jpg" +--- + + +
    +
    +
    +
    +
    +

    {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}

    + {{ page.description }} +
    +
    +
    +
    +
    + + +
    +
    +
    + +
    + {% for tag in site.tags %} + {{ tag[0] }} + {% endfor %} +
    + +
    + 标签命名规则: +
  • 一篇文章相关的领域都将打上标签
  • +
  • 每个便签下含有所有包含此标签的文章
  • +
    + + + {% for tag in site.tags %} +
    + {{ tag[0] }} + {% for post in tag[1] %} +
    + +

    {{ post.title }} +

    + {% if post.subtitle %} +

    + {{ post.subtitle }} +

    + {% endif %} +
    + +
    +
    + {% endfor %} +
    + {% endfor %} + +
    +
    +
    diff --git a/wechat/create.sh b/wechat/create.sh new file mode 100644 index 0000000..b52cb81 --- /dev/null +++ b/wechat/create.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# 创建目录 +if [ ! -d content ] + then + mkdir content; +fi + +# 生成文件 +position=1; +for loop in `ls ../_posts` +do + id=${loop/.md/}; + echo "$id $position"; + content=`cat template`; + content=${content/cb_page_index/$position} + echo "${content}" > "content/$id" + ((position++)); +done diff --git a/wechat/template b/wechat/template new file mode 100644 index 0000000..bb82b90 --- /dev/null +++ b/wechat/template @@ -0,0 +1,8 @@ +--- +layout: null +--- +{% for post in site.posts %} + {% if forloop.rindex == cb_page_index %} + {{ post.content }} + {% endif %} +{% endfor %}