Octopress Tips

Hide AsideBar

Add following lines into your _config.yml:

sidebar: collapse

Then regenerate the whole website.

Changing Navigation

Add “About Me” navigation:

$ cat source/_includes/custom/navigation.html
<ul class="main-navigation">
  <li><a href="{{ root_url }}/">Blog</a></li>
  <li><a href="{{ root_url }}/blog/archives">Archives</a></li>
  <li><a href="{{ root_url }}/about">About Me</a></li>
</ul>

Add customized tags:

  <li><a href="{{ root_url }}/blog/categories/linux/">Linux</a></li>
  <li><a href="{{ root_url }}/blog/categories/embedded/">Embedded</a></li>

Add Customized Background

Edit the sass/cumstom/_style.css, change following content:

html {
  background: #555555 url("/images/pagebackground.jpg");
  //background: #555555;
}

Now regenerate the website, ten you got the modified background website.

Upgrade OpenWRT on MW151RM3G

Prepare

First go to http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/, find the “wr703n”, download the 2 files.

$ ls -l openwrt*
-rw-r----- 1 Trusty root 3932160 Nov 24 13:50 openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-factory.bin
-rw-r----- 1 Trusty root 3342340 Nov 24 13:50 openwrt-ar71xx-generic-tl-wr703n-v1-squashfs-sysupgrade.bin

sysupgrade.bin is for upgrading.

Upgrade

System-> Backup/Flash Firmware.
Flash New firmware image, choose File. Select the sysupgrade.bin, Upgrade.

Tehn you have to wait for the changes to be applied, around half a miniutes, then everything will be OK.

Use Flash Disk For Booting

Cause the inner storage is only 4M-BYTE, we have to enlarge it via adding the external flash disk .

$ opkg update
$ opkg install block-mount kmod-usb-storage fdisk

Comparing to Attitude Adjustment, the kmod-fs-ext4 couldn’t be installed, thus we have to formt the flash disk into ext3 format.

Cause we won’t installed the kmod-fs-ext4, so the external system couldn’t be used, this time just flash back the Attitude Adjustment.

Rootfs on External Storage

Copy the filesystem into the external disk:

root@OpenWrt:/mnt/sda2# tar -C /overlay -cvf - . | tar -C /mnt/sda2 -xf -
root@OpenWrt:/mnt/sda2# ls
etc         lib         lost+found  mnt         sbin        usr

Configure the /etc/config/fstab:

config mount
        option target   /overlay
        option device   /dev/sda2
        option fstype   ext3
        option options  rw,sync
        option enabled  1
        option enabled_fsck 0

Reboot and you got 8G rootfs enabled router.

Wireless-> Wired.

First set the wireless port to client mode:
/images/wireless_client.jpg

Then set the wired port to static address:
/images/wired_config.jpg

Now reset your router and connect the ethernet port with a line, the equipments who only have ethernet could use router’s wireless signal for accessing the network.
Later when I study in the library, this router could easily transfer the signal from wireless to wired and let surfacePro work properly.

DNSCrypt+ssh

Sometips for recording how to cross the greatfxxewall:

SSH

Use following command for forwarding your flow to remote machine:

alias enablexx='ssh -C -qTfnN -D 1395 root@xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx should be the machine outside of China.
Then in your browser set the proxy to 127.0.0.1:1395, while this is the socket proxy, so choose sock4/sock5 for configuration parameters.

DNS Cryption

For the DNS flow will be hijacked by greatfxxxewall, we have to encrypt all of the traffics for DNS Querying.

DNSCrypt is a piece of software that encrypts DNS traffic between the user and a DNS resolver, preventing spying, spoofing or man-in-the-middle attacks.
Install it via:

$ sudo pacman -S  dnscrypt-proxy

Then modify the /etc/resolv.conf content to:

# Generated by resolvconf
nameserver 127.0.0.1

Previously it would be 10.0.0.1, but after we enabled the DNS cryption, we will use our own dns server as in 127.0.0.1.
Note: In office I won’t change this file because the DNS is safe in ALU.

Start/Stop the service via:

### encrypt my dns flow
alias enabledns='sudo systemctl start dnscrypt-proxy.service'
alias disdns='sudo systemctl stop dnscrypt-proxy.service'

Above 2 lines has been written to ~/.zshrc, so everytime I just type enable/dis(dns) I could enable/disable the DNS encryption.

Tips on 30Days30Skills(1)

Day 3 - Flask

First install the virtualenv environment via:

$ brew install pyenv-virtualenv

Create the 2.7 virtualenv of python, first you have to install 2.7(before you could use list for listing all of the aviable versions), then use following command for creating the 2.7 virtualenv for developing flask:

$ eval "$(pyenv init -)"
$ pyenv install --list
$ pyenv install 2.7
$ pyenv virtualenv 2.7 venv_For_Flask_2.7
$ pyenv versions
$ pyenv activate venv_For_Flask_2.7
(venv_For_Flask_2.7)Yosemite:~ Trusty$ pip install flask

Git clone the project from github, then install via the requirement.txt:

$ git clone https://github.com/shekhargulati/instant-flask-web-development-book-app.git scheduleapp
$ cd scheduleapp/
$ pip install -r requirements.txt
$ python manage.py create_tables
$ python manage.py runserver

Now you could visit the http://localhost:5000 for viewing the result.

Since you created this appliation, so it’s very easy for deploying it on Openshift.

Install rhc on Mac, before install, make sure your network is configured OK(mine is set the proxy via ):

sudo gem install rhc

Run following command for setup the rhc on your own machine:

rhc setup

Deploy the app via following command;

MacBook-Air-di-Trusty:schedulingapp Trusty$ rhc create-app schedapp python-2.7 postgresql-9.2 --from-code=https://github.com/shekhargulati/schedapp-openshift.git

After deployment, the following app will be available for accessing:
http://schedapp-kkkttt.rhcloud.com/

Day 4 - PredictionIO

Install Vagrant and its plug-ins:

$ sudo pacman -S vagrant
$ vagrant plugin install vagrant-login vagrant-share

Download the latest PredictionIO-Vagrant:

$ wget https://github.com/PredictionIO/PredictionIO-Vagrant/archive/v0.8.2.tar.gz

For working under proxy, install vagrant-proxyconf plugins:

$ vagrant plugin install vagrant-proxyconf

Add following to

  # Proxy Setting
  config.proxy.http = "http://1xx.x.xx.xxx:2xxx"
  config.proxy.https = "http://1xx.x.xx.xxx:2xxx"
  config.proxy.no_proxy = "localhost,127.0.0.1"
end

Following the tutorial may cause error, so I follow the guideline from the official website:

$ vagrant box add precise64 http://files.vagrantup.com/precise64.box

Then go the downloaded folder and start the vagrant:

$ pwd
/media/y/Vagrant/PredictionIO/PredictionIO-Vagrant-0.8.2
$ vagrant up

Now login into the vagrant machine and add the new user:

$ vagrant ssh
vagrant@precise64:~$ /opt/PredictionIO/bin/users 
Warning: JAVA_HOME environment variable is not set.

PredictionIO CLI User Management

1 - Add a new user
2 - Update email of an existing user
3 - Change password of an existing user
Please enter a choice (1-3): 1
Adding a new user
Email: kkkttt@gmail.com
Password: ********
Retype password: ********
First name: Trusty
Last name: mao
User added

For settingup the vagrant in opensuse:

$ wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.5_x86_64.rpm
$ rpm -ivh vagrant_1.6.5_x86_64.rpm
$ which vagrant
/usr/bin/vagrant 
$ vagrant box add precise64 http://files.vagrantup.com/precise64.box
$ vagrant plugin install vagrant-proxyconf

Previous version won’t create the user successfully, then I switch to 0.6.5, thus everything goes OK.

After Added the users, you could visit the webpage at “http://localhost:9000”

Add the application named “blog-recommender” in the webpage.

Eclipse Setup

The Url for input in the elipse is:
http://download.eclipse.org/technology/m2e/releases

Install the m2eclipse via following methods:
/images/eclipseplugins_m2eclipse1.jpg Then:
/images/eclipseplugins_m2eclipse2.jpg

Create project via:
/images/createmaven.jpg
You will encounter error, simply download the catelog file from:
http://repo1.maven.org/maven2/archetype-catalog.xml_
Then add the catalog file like following:
/images/addcatalog.jpg
Now re-create the project :
/images/maven_archetype_quickstart.jpg

But this won’t solve the problem, we have to install maven manually in ArchLinux:

$ sudo pacman -S maven
$ # fetch the files from: 
	http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/
	maven-archetype-quickstart-1.1.jar
$ mvn install:install-file -DgroupId=org.apache.maven.archetypes -DartifactId=maven-archetype-webapp -Dversion=1.0 -Dpackaging=jar -Dfile=maven-archetype-weba
pp-1.0.jar

Now re-new the configuration.

This method is not OK, finally I downloaded the Eclipse Kepler and place it under the /media/y/Vagrant/eclipse, this time it could create the project successfully, but it failed when creating classes, complaing that missing some dependencies.

重装手记

昨晚的安装还是没能解决问题,所以今天重新来一次。

安装步骤

1. 插入Yosemite USB安装盘,选择"Ignore caches and inject kext"后按回车,进入到Yosemite安装界面。这时候的语言界面是意大利语的。分区选择Utility-> Utility Disco, 点击磁盘,按Inizilalizza, 输入Name后按Inizializza. 再一次确认也是Inizilalizza. 分区完毕后点x返回到安装界面,点击Continua-> Continua-> Accetta后选择Hard磁盘, Continua. 这时弹出拷贝窗口,需要等待大概15分钟时间用于拷贝/安装到磁盘。安装完毕后会自动重启。

2. 重启后需要选择"Boot Mac OS X from Hard”, 空格后选择"Ignore caches and inject kext” 后回车,这时会进入到一个配置界面。首选选择时区,点击Mostra tuite后选择你要的时区后, Continua, 然后选择键盘布局,USA, Continua, 网络配置选择"II mio computer non si connette a Internet”, Continua, Continua, 而后选择Non trasferrie informazioni adesso, Continua, Accetto, Accetta, 接着输入用户名/密码, Continua, 再一次Continua后进入Configuro iL Mac界面后,登录成功。

3. 在登录后的界面里,首先安装Clover到系统硬盘Hard,这样下一次我们就可以不用插入优盘以进行引导了。Clover安装时选择Install in UEFI和Drivers64UEFI。而后用UEFI Mount加载上系统真正的UEFI分区后,把根目录下的EFI目录全盘拷贝到系统UEFI分区下。同时使用KextDrop.dmg drop同用的Kext到系统。重启。

4. Drop Yosemite自己的驱动后,重启。这时候的声卡,USB, 蓝牙等应该都已经驱动上了。由于我们使用了修改过的Display驱动,DP口现在也应该是好的。开始安装有线/无线驱动。安装完毕后系统自动要求重启。

5. 重启完毕后可以直接链入网络,为了可以访问App Store, 删除掉系统里所有网络配置,删除掉/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist, 重启。这将使得我们手动配置网卡的build-in模式。

6. 手动添加网络,打开App Store,尝试安装一个软件,看是否如愿,如果OK,那么恭喜你。如果不OK,接着走下一步。我这里出现的错误是"Your device or computer could not be verified, Contact support for assistance.” 下载NullEthernet包,drop之。并使用MaciASL, Apply patch.txt. 完成这些后重启。

7. 重启后依然无法访问,吃欧冠内心删除所有的网卡驱动,重新删除/L/P/S/NetworkInterfaces.plist, 重启。重新添加USB网卡,访问App Store. 好了,现在你可以访问,享受之。

可能存在的问题

插入USB无线网卡可能会造成系统不稳定。譬如蓝牙丢失之类。这和驱动的稳定性有关系。所以在我的SurfacePro上我打算采用不稳定的驱动,我会采用一个便携式路由器把无线转成有线的功能。