Category Archives: Uncategorized

2025 秋天来了

秋天来了,感觉到了三十多岁的阶段,日子过得真快。上班的时候每天的工作内容都比较相似,盼到了周末,马上就到了周一,嗖一下一周就过去了。

 

我在这个站里写了不少日记,基本都是隐藏的状态。把心里的话记下来,絮絮叨叨一阵子,心里就会舒坦不少。 到了这个年龄不知为何,心里有好多好多话无处诉说。

翻了翻很久之前的文件,有个老朋友说过:
平静也是幸福。
一切不会重来。
珍惜现在每一天的幸福。每一刻的小喜小悲。
还真是这样的,年龄变大了,对平静的定义也会慢慢改变。小时候心惊胆颤额度瞬间现在也能淡定面对。 因为一切真的不会重来,也回不去了。
唉。
家,是避风港么?
茫然了很久,好像总是放轻松不下来。 恍惚之间,突然有种我的TT已经不在我身边的感觉。真实的她已经走了,嗯,留下了个副本给我。 十年了,好多回忆涌上心头,曾经的热情与纯真已经不见了。
我很想她,可是已经找不到了。我还想牵着她的小手在DUFE里面走走,看她穿着黑色的棉袄,在雪地里呼着白气慢慢走。 想和她再去吃一次食堂,一起无话不谈,一起再去逛逛街。那时的日子回不去了,那时的人也不在了。
我回归到了一种重复规律却没有任何意义的平静生活,沉浸在假笑苦笑,循规蹈矩,天天说些不痛不痒的客套话的日子里。心里的话没处说,憋的难受, 这样高压的日子让我喘不过气,但我好像也没有什么别的选择了,只能硬着头皮继续走。
石石就不一样了,咯咯笑。爸爸每次看到你就能感受到发自内心的阳光,心暖暖的。

Install PHP7 on Debian 8 Jessie (with Apache)

Important:

Double check your operate system: ONLY  Debian 8 (Jessie) works with this instruction

Apache version: 2.4 which is the default version comes with Debian 8 (Not working with Apache 2.2 or lower)

Install Apache2:

Update package list and upgrade outdated packages:

sudo apt-get update && sudo apt-get upgrade

Install Apache2:

sudo apt-get install apache2

Install PHP7:

Since PHP7 is not included in any Debian official source list, we gonna use the version compiled by Dotdeb.org, which is pretty widely used.

Add source:

sudo nano /etc/apt/sources.list

Add the following two lines to the end of the file:

deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

If you server is far from US, try find the nearest mirror: https://www.dotdeb.org/mirrors/

Get and Install GnuPG key:

wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg

Update packages again

sudo apt-get update

Install PHP7:

here is a list of available packages currently: (By the way, Swoole also work with php7, use ‘pecl install swoole to install’)

php7.0-apcu       php7.0-dbg        php7.0-imagick    php7.0-memcached  php7.0-phpdbg     php7.0-sybase
php7.0-apcu-bc    php7.0-dev        php7.0-imap       php7.0-mongodb    php7.0-pspell     php7.0-tidy
php7.0-bz2        php7.0-enchant    php7.0-interbase  php7.0-msgpack    php7.0-readline   php7.0-xdebug
php7.0-cgi        php7.0-fpm        php7.0-intl       php7.0-mysql      php7.0-recode     php7.0-xmlrpc
php7.0-cli        php7.0-gd         php7.0-json       php7.0-odbc       php7.0-redis      php7.0-xsl
php7.0-common     php7.0-gmp        php7.0-ldap       php7.0-opcache    php7.0-snmp
php7.0-curl       php7.0-igbinary   php7.0-mcrypt     php7.0-pgsql      php7.0-sqlite3

Choose your list of mod, install with php

sudo apt-get install php7.0 php7.0-common php-pear #add your list of mods here

Install mod_php7 for Apache 2.4 and restart apache:

sudo apt-get install libapache2-mod-php7.0
sudo service apache2 restart

That’s it! Done!

 

My note on Installing OpenWRT on Banana Pi R1 (BPi-R1)

Today, I just got my Banana Pi R1.  Here is a simple guide to set it up as an OpenWRT router.

Step 1: Flash the TF(microSD) card.

  • Goto the download page of BPi-R1 (http://www.bananapi.com/index.php/download?layout=edit&id=65)
  • Find and download the latest OpenWRT Image, which is version 4.0 (01/09/2015) as I write this.
  • Write the OpenWRT image to the TF card. I use OS X, here is the code I used in Terminal:
  • Find the disk number of your TF card. Mine is disk2[Bold number may varies on your computer, wrong number will cause serious problem, you will lose your data on the wrong disk]:
    diskutil list

    Unmount it:

    diskutil unmountDisk /dev/disk<strong>2</strong>

    Write the image:

    sudo dd bs=1m if=~/Downloads/BPI-R1_OpenWrt_V4.0.img of=/dev/rdisk<strong>2</strong>
  • If you are using other OS, follow the guide here (From Raspberry Pi, their are all the same except the image)
  • Eject the TF card  from your computer and insert it into Banana Pi.

Step 2: Power On your Banana Pi R1.

  • Plug in the 5V power cord to the correct port, it will power on by itself.
  • HDMI is not working on OpenWRT(only works few seconds while booting)
  • Connect the BPI-R1’s WAN to your home router/switch’s LAN (Assume DHCP is enabled )
  • Find the BPI-R1’s IP address. You may find it in the web management interface of your home router. Scan port 80 and 22 for the whole subnet other wise.
  • use root/admin to login BPI-R1
  • Mostly Done.

After that, I found only 80M(VFAT) + 150M(EXT4) was used on BPI-R1, which waste pretty much space on my 32GB TF card.

Extra Step: Expand the ext4 partition. (Inspired by SaruMaaz)

  • Download Gparted Live
  • Write Image to a Flash Drive (Assume the flash drive is disk2)
    sudo dd bs=4m if=~/Downloads/gparted-live-0.24.0-2-i586.iso of=/dev/rdisk<strong>2</strong>;sync
  • Restart OS X and hold Option key while booting,
  • Chooes ‘EFI Disk’
  • Enter your language code
  • Enter 0 and get to the GUI
  • Plug in the TF card, Find the TF card (mine is sdd)
  • Find the 150M partition, right click, change the size…
  • Apply
  • Done

Netbeans 无法显示中文之解决方案

今天偶然发现Netbeans不能显示中文,本来以为是charset的问题,然后意识到错误的charset会导致乱码,而不是小方块。

经过测试,使用最常用的英文字体,例如Arial, New Times Roman 都可以正常显示中文。其余字体,比如编程常用的MonoSpace,Consolas,Monaco什么的会无法显示中文。如图:

乱码

经过一番搜索,找到原因,简单地说,原因在于这些字体里面不包含中文,fallback font也没有中文.

又搜了一大圈,发现了一个很好的第三方字体,使用Consolas+微软雅黑中文,非常漂亮,成功解决,如图:(如果细心就会发现字数不一样,所以只是我的一个例子么~)

After

 

下载链接:

http://ishare.iask.sina.com.cn/f/8965397.html

备用链接:

YaHei.Consolas.1.12

Practice it CSE142 MT 06au 的一道题

Write a method named hasMidpoint that accepts three integers as parameters and returns true if one of the integers is the midpoint between the other two integers; that is, if one integer is exactly halfway between them. Your method should return false if no such midpoint relationship exists.
The integers could be passed in any order; the midpoint could be the 1st, 2nd, or 3rd. You must check all cases.
Calls such as the following should return true:
hasMidpoint(4, 6, 8)
hasMidpoint(2, 10, 6)
hasMidpoint(8, 8, 8)
hasMidpoint(25, 10, -5)
Calls such as the following should return false:
hasMidpoint(3, 1, 3)
hasMidpoint(1, 3, 1)
hasMidpoint(21, 9, 58)
hasMidpoint(2, 8, 16)
=========================================================
以下是我和晓天想出来的答案。我们最开始打算先进行排序,再求差,来判断,很是程序写起来会很长,而且我们现在没有讲各种排序法。
=========================================================

public static boolean hasMidpoint(int a,int b,int c){
    int e=a+b+c;
    if (e/3==a||e/3==b||e/3==c)
        return true;
    return false;
}

=============================================================

# name expected return your return result
1 hasMidpoint(1, 2, 3) true true pass
2 hasMidpoint(2, 10, 6) true true pass
3 hasMidpoint(0, -50, -25) true true pass
4 hasMidpoint(21, 9, 58) false false pass
5 hasMidpoint(-2, 9, 27) false false pass
=================================================
提交答案之后,我突然觉得这个程序存在问题,虽然在系统给的数值里没有测出问题,但是由于int类数据的特点,10/3是等于3的。所以输入以下测试代码。
==================================================

public class test{
public static void main(String[] args){
System.out.println(hasMidpoint(0,-51,-25));
}
public static boolean hasMidpoint(int a,int b,int c){
int e=a+b+c;
if (e/3==a||e/3==b||e/3==c)
return true;
return false;
}
}

//由于是复制过来的,就不能保持很好的代码格式了。

=============================================================
输出结果:true
=============================================================
很显然,-25不是-51和0的中点,刚刚的源码是有问题的。
=================================================
把if的条件语句作了如下调整:

if ((e/3==a||e/3==b||e/3==c)&&e%3==0)

再次调用

System.out.println(hasMidpoint(0,-501,-250));

输出是false
=================================================
现在基本已经不会存在问题了,通过了我的所有测试。
如果有人认为我的代码还存在问题,欢迎回复。