跳转至

博客

Using chinese pyim

Recently i have been using tumashu's chinese-pyim. It's great to write Chinese right in Emacs. But as the personal dict is empty, this must be a hard time for me to build it. And i have found several bugs, too. After all, this project is great. I have donated some money to it.

Unix nice

I just saw this interesting tweet:

Unix系统的每个进程,都有一个nice值。这个值越大,优先级越低。然后,还有一个nice命令,每运行一次,指定进程的nice值+10。它的意思就是做人要nice,把更多的CPU时间留给别人。nice值越高,你留给自己的份额就越少。

From hereby @ruanyf.

And i didn't known that until now. Cool! The name 'nice' is nice, too.

Don't worry if you can't read Chinese. See also here and here.

Start next term tomorrow

My term starts tomorrow. Sad. Homework haven't finished. I went to Guangzhou for GDKOI thie weekend, and i haven't known the result. It should be bad. I have no confidence at all. I may write less when this term starts. The second term of Senior 2 should a hard time for me. That's all. Sorry for the laziness.

Building emacs git version with xwidgets and modules in archlinux

First you need to install these packages:

sudo pacman -S git autoconf automake gtk3 webkitgtk
git clone --depth 1 https://github.com/emacs-mirror/emacs.git (or git protocol if you like)
cd emacs
./autogen.sh all
./configure --with-xwidgets --with-x --with-x-toolkit=gtk3 --with-modules
make
cd lisp
make autoloads
make
make
make

Until you got everything ok.

Then you can just:

cd src
./emacs

And then, M-x webkit-browse-url RET: xwidget-webkit

Also, test the modules feature using syohex/emacs-qrencode: qrencode

I'm using ssh and X11 Forward to show Emacs in Mac OS X! Cool!

Screen Capturing Tips in macOS

I'm sure many people have already known this. But i haven't memorize it yet.

How to screen capture:

Shift+Command+3: Capture fullscreen.
Shift+Command+4: Capture region.
               : Press space to capture window. 
               : Hold option and drag, then
               : you will capture a region with its center in where you started dragging 
               : and one of its corners under your cursor.
Ctrl+OneOfTheTwoAbove: Capture to clipboard.
defaults write com.apple.screencapture location: Change the default location storing the images.

Apps enhancing the snapshots: Snappy and Mapture.

See more detailed here.

News

Oh StartSSL places its PKI in 360's server. You know, i hate 360. SO please beware if the website is using StartSSL. Here is the link.

And here comes the vim-tips:

You probably know that 'u' is undo. Do you know that Ctrl-R is redo?
It comes from here.

Good software engineering rules

I saw a great saying:

No code runs faster than no code.

No code has fewer bugs than no code.

No code uses less memory than no code.

No code is easier to understand than no code.

It comes from here.

And i strongly recommends this article for a better understanding of monads.

The beginning of my blog

This is the first blog here.

I am talkative deep inside, but i do not have enough opportunities to express myself. Most of the listeners can't understand me. So i would like to write something on my blog. Kinda outdated media, though. Whatever, the first step is always the hardest.

That's all. Thanks Emacs, Github Pages, Jekyll and Ruby to support this blog.

Android Studio 手工更新小记

迁移自本人在 CSDN 上的博客:https://blog.csdn.net/build7601/article/details/41776599

因为长时间不更新 Android Studio,回头一看,我的版本才 135.1339820,最新版本都 135.1626825 去了,我就萌生了更新的念头。。

首先,我尝试调用 update_studio.sh。。。。。但是!!404 Not Found!!看来版本跨度太大无法打补丁了呢。。

那只好看看 https://dl.google.com/android/studio/patches/updates.xml 这个里面了,找到我的版本号:

<channel id="AI-0-beta" name="Android Studio updates" status="beta" url="http://tools.android.com/recent" feedback="https://code.google.com/p/android/issues/entry?template=Android+Studio+bug" majorVersion="0">
<build number="135.1623071" version="0.9.9">
<message>
<![CDATA[
<html> A new Android Studio 0.9.9 is available in the beta channel.<br> This patch will allow you to update from 0.x to 1.x.<br> After updating, please check for updates again to install 1.0 RC.<p/> </html>
]]>
</message>
<button name="Download" url="http://developer.android.com/sdk/installing/studio.html" download="true"/>
<button name="Release Notes" url="http://tools.android.com/recent"/>
<patch from="135.1339820" size="176"/>
<!-- 0.8.6 -->
<patch from="135.1404660" size="176"/>
<!-- 0.8.9 -->
<patch from="135.1446794" size="161"/>
<!-- 0.8.11 -->
<patch from="135.1503853" size="90"/>
<!-- 0.8.12 -->
<patch from="135.1525417" size="89"/>
<!-- 0.8.13 -->
<patch from="135.1538390" size="89"/>
<!-- 0.8.14 -->
<patch from="135.1551333" size="71"/>
<!-- 0.9.0 -->
<patch from="135.1561280" size="71"/>
<!-- 0.9.1 -->
<patch from="135.1569493" size="71"/>
<!-- 0.9.2 -->
<patch from="135.1585741" size="71"/>
<!-- 0.9.3 -->
</build>
</channel>

还好还好,差点就升不上去了。。。

立马下载 https://dl.google.com/android/studio/patches/AI-135.1339820-135.1623071-patch-mac.jar ..也是大,差不多和重新下载一样大了。。

进入 Android Studio 目录,输入 java -cp AI-135.1339820-135.1623071-patch-mac.jar com.intellij.updater.Runner install . (记住后面的。表示安装目录)。

弹出窗口,升级成功,yeah!

以后要想用 patch 升级,一定要尽快啊~

吐槽一下 update_studio.sh 的编写人,我要改进一下他的脚本。。升不上去太挫了。。

题外话:

打完补丁,出现 Java not found 错误,发现我的 java 版本是 Oracle1.8,而他要的是 Apple1.6.。。那我只好安装一下,然后呢?就好了!!!!!

"@微信 SDK 开发者,发现一个 BUG~"

迁移自本人在 CSDN 上的博客:https://blog.csdn.net/build7601/article/details/39826065

经过测试,发现微信客户端登录 SDK 有一个 BUG。注:目前只在 iOS 上测试过,可以重现。

BUG 重现

1.做一个可以用微信登陆的软件,先安装到设备。 2.更改 project 的 Bundle Identifier,只更改大小写,重新安装到设备。P.S.实际情况是包名大小写修改过引发这个问题。 3.打开第二个安装的 APP,选择微信登陆,跳转到微信。 4.点击微信登陆,则会跳转到第一个 APP 中,而不会跳转到第二个 APP。

我的 BUG 分析

这可能是因为,微信 sdk 传到微信的是一个 bundle identifier+回调函数地址,回调时找到另一个 APP 再执行回调。 可能在某处进程的名称不分大小写,按照顺序找到了第一个去了。一旦两个 APP 版本不一致,可能执行到空的地址甚至发生不可预测的行为。 经过测试,发现同一样的版本的 APP 也发生了崩溃。

用数学方法 + 数学软件去做一个物理题~

迁移自本人在 CSDN 上的博客:https://blog.csdn.net/build7601/article/details/39433177

经过测试,发现微信客户端登录 SDK 有一个 BUG。注:目前只在 iOS 上测试过,可以重现。

原题:

跳伞运动员在下落过程中,假定伞所受空气阻力大小跟下落速度的平方成正比,即 F= kv2,比例系数 k=20N·s2/m2,跳伞运动员与伞的总质量为 72 kg,起跳高度足够高,则:(g 取 10 m/s2)

  1. 跳伞运动员在空中做什么运动?收尾速度多大?
  2. 当速度达到 4 m/s时,下落加速度是多大?

做法:

我拿出我的数学大杀器,直接受力分析 + 牛顿第二定律得出 a=g-k/mvv. 我一看,这转化成数学不就是 f''(t)=10-5/18*f'(t)^2, f(0)=0, f'(0)=0,喜闻乐见的微分方程啊哈哈!

直接丢到各种数学软件,我用了Wolfram|Alpha

瞬间得到答案: f(t) = -6/5 (5 t-3 log(e^(10 t/3)+1)+log(8)) yeah~

看看上面那个网址里面下面的函数图像,表示第一题可以秒杀~

好的,至于第二题,因为速度为 4,则可以写出:f'(t)=4 的方程,输入 d(-6/5 (5 t-3 log(e^(10 t/3)+1)+log(8)))/dt=4 解出 t = (3 log(5))/10 带入 f''(t),输入 diff(diff(-6/5 (5 t-3 log(e^(10 t/3)+1)+log(8)),t),t),t=(3 log(5))/10, 得 a=5.5556.

大功造成~

写了一个程序,分析各个源文件之间的 include 关系。

迁移自本人在 CSDN 上的博客:https://blog.csdn.net/build7601/article/details/37343993

最左边是 expat,上面 zlib,左下角 mxml,中间最恶心的是 lua,右边的是 jpeg。

讲讲大概思路:

1.扫描源文件,这里判断最简单的#include,然后建立关系。

2.把这些作为一个个 body 加到 box2d 的世界里,让物理解决这一切!!

3.然后把有 include 关系的用一个 distancejoint 连接起来~你会发现他们就能保持一定距离了。但是!没有被连接的全都聚在一起,怎么办!

4.把距离近的,不和自己相连的(来个 dfs)给个反方向的力!

5.好吧,这就是最终结果,有什么更好的方法?希望大家交流。

6.我不想开源,毕竟这还只是个半成品。。。。。做好了自然会开源的

7.像那个恶心的 lua 怎么解开?文件之间的依赖太多了,成环了。

8.使用 java+libgdx+box2d 写成,也就是说 android 也支持。

9.没啥了。。。。

IntelliJ IDEA 手动更新方法

迁移自本人在 CSDN 上的博客:https://blog.csdn.net/build7601/article/details/27704683

经常,IntelliJ IDEA 更新时,会发现这个:

download-cf.jetbrains.com/idea/IU-135.690-135.909-patch-win.jar 下载不了。不然只能去下载完全版重新安装一次

解决方案如下:

使用代理下载上面那个文件(视版本而定),

拷贝到 IntelliJ IDEA 安装目录,

敲击 java -classpath IU-135.690-135.909-patch-win.jar com.intellij.updater.Runner install .

注意,最后那个点表示更新到当前目录。

会输出这个:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layo ut at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) at sun.launcher.LauncherHelper.validateMainClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Layout at java.net.URLClassLoader\(1.run(Unknown Source) at java.net.URLClassLoader\)1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 6 more

发现少了 log4j,发现 lib 目录下就有,果断加到 classpath:

java -classpath IU-135.690-135.909-patch-win.jar;.\lib\log4j.jar com.intellij.updater.Runner install . 弹出升级窗口,成功!

IntelliJ IDEA 设置代理升级失败,设置系统代理也失败。。可能是 rp?但是浏览器就可以。

Linux on Android 简单教程

迁移自本人在 CSDN 上的博客:https://blog.csdn.net/build7601/article/details/24544879

介绍: Linux on Android,顾名思义,就是让你能在 Android 上跑 linux。。。。

步骤: 1.下载所需的文件: 项目主页为:tinyurl.com cn3lxgz 在这里举 Ubuntu 13.10 为例,下载 tinyurl.com lp7fqw4 Core 只有最基本的东西,没界面。。但是我的 sd 卡空间过小,只好用这个, Small 就有界面了,Large 还有很多东东,具体看 tinyurl.com m5tdmkj 下面的 Readme

然后下载 Complete Linux Installer,这是用来启动 linux 的: tinyurl.com mzsbud8

还要下载 VNCViewer(浏览 linux 桌面),终端模拟器

2.做好准备工作: 解压下载好的 zip,把里面的.img 解压出来。 安装好 Complete Linux Installer VNCViewer 终端模拟器到 android 上,把解压的.img 文件传到 sd 卡上,比如: adb push ubuntu-13.10.CORE.ext2.img 你的 sd 卡路径

安装完是这个样子的:

3.开始启动! 打开 Complete Linux Installer, 选择启动系统,点击右上角 Settings,选择添加:

在名称输入你喜欢的名称,比如 ubuntu。 选择...,然后选择 sd 卡上的 img 文件。保存更改

选择你刚才创建的 ubuntu,点击启动 linux!

你会发现出现了一个终端模拟器有没有!!

完成!你可以用 VNCViewer 去查看他的界面: 连接 localhost:5900。

什么都没有,什么情况!?!? 因为我下载的是 Core 啊!什么都没有啊啊啊啊。。。。 如果下载的是别的,那估计已经有界面了。。

如果没法连接到,请在终端模拟器输入 vncserver 并回车,然后 VNC 连接 5901 端口即可!