2011年1月11日 星期二

[Vim] .vimrc

筆記一下我目前在用的.vimrc

"=== basic ==="
filetype plugin on        "plugin enable
filetype indent on        "auto indent

"=== encoding ==="
set encoding=utf-8        "enc
set fileencodings=utf-8,gbk,big5,cp950,gb18030,gb2312   "fenc
set termencoding=utf-8    "tenc

"=== editing ==="
syntax on
set nocompatible
set backspace=indent,eol,start
set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab
set ic                    "ignorecase
set ru                    "position
set nu                    "line number
set hls                   "hlsearch
set confirm
set wrapscan
set history=1000
set laststatus=2
set statusline=%4*%<\%m%<[%f\%r%h%w]\ [%{&ff},%{&fileencoding},%Y]%=\[Position=%l,%v,%p%%]

"=== buffer ==="
set clipboard+=unnamed

"=== color scheme ==="
set t_Co=256
colorscheme blackbeauty   "for java
colorscheme leo           "for c/c++

"=== vim ==="
autocmd FileType java runtime! autoload/javacomplete.vim
autocmd Filetype java setlocal omnifunc=javacomplete#Complete
autocmd Filetype java set completefunc=javacomplete#CompleteParamsInf
inoremap   
inoremap   

"=== tab ==="
nmap tc :tabnew
nmap te :tabedit
nmap tm :tabmove
nmap tk :tabclose

"=== folding ==="
set foldenable
set foldlevel=10000

2011年1月6日 星期四

[HTML5] HTML5 Rocks

2011年應該是HTML5開始有搞頭的一年...
前一陣子從Ericsk大大那邊看到的任天堂模擬器

昨天在GUTG聽Gasolin介紹Knights of the round,還佛心的掛在google code

看來我應該想想看怎麼用websocket完成我的小遊戲了...

順手記一下有關的資源
* HTML5Rocks
* Dive Into HTML5
* HTML 5 Demos and Examples
* HTML5 Doctor

[Android] Create a fake character device driver

1.download Android kernel, details in here

2.get the current kernel configuration from the emulator
$ adb pull /proc/config.gz .
$ gunzip config.gz
$ mv config .config

3.modify .config file
$ vim .config
CONFIG_MODULES=y

4.modify kernel Makefile
$ vim Makefile
# Use --build-id when available.
#LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
#           $(call ld-option, -Wl$(comma)--build-id,))

5.compile kernel
$ make mrproper
$ sudo make ARCH=arm CROSS_COMPILE={/path/to/android}/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

6.get kernel image
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready

7.create fake driver, devone.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>

MODULE_LICENSE("Dual BSD/GPL");

static int devone_devs = 1; /* device count */
static int devone_major = 0; /* dynamic allocation */
static int devone_minor = 0;
static struct cdev devone_cdev;

ssize_t devone_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
  int i;
  unsigned char val = 0xff;
  int retval;

  for (i = 0 ; i < count ; i++) {
    if (copy_to_user(&buf[i], &val, 1)) {
      retval = -EFAULT;
      goto out;
    }
  }

  retval = count;
out:
  return (retval);
}

struct file_operations devone_fops = {
  .read = devone_read,
};

8.write fake driver Makefile
KERNELDIR={/path/to/android}/kernel
PWD := $(shell pwd)
obj-m := devone.o
modules:
  make -C $(KERNELDIR) M=$(PWD) modules
clean:
  rm -rf *.o *~ core.depend .*.cmd *.ko *.mod.c .tmp_versions modules.* Module*

9.compile kernel module
$ sudo make ARCH=arm CROSS_COMPILE={/path/to/android}/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

10.start the emulator with our kernel
$ emulator -avd {name} -partition-size {number} -kernel {/path/to/kernel/zImage}

11.put busybox into emulator
$ adb push busybox /system/bin
$ adb shell chmod 755 /system/bin/busybox

12.put ko into emulator
$ adb remount
$ adb push devone.ko /system/lib

13.insert kernel module in emulator
$ adb shell
# insmod devone.ko
# lsmod
devone 1784 - - Live 0xbf000000

14.check the major number of devone
# cat /proc/devices
...
136 pts
252 devone
253 ttyS
...

15.insert the device node of devone
# /system/bin/busybox mknod /dev/devone c 252 0
# /system/bin/busybox ls /dev/
...
device-mapper       tty20               tty51
devone              tty21               tty52
eac                 tty22               tty53
...
# /system/bin/busybox ls -al /dev/devone
crw-rw-rw-    1 0        0        252,   0 Jan  4 05:33 /dev/devone

reference:
* 實作一個假的character driver 在emulator上跑
* Writing your first kernel module

2011年1月3日 星期一

[Vim] Color scheme

用Vim寫程式時通常會對原有的配色不太滿意,尤其是在切換不同的程式語言時會更有這樣的需求,強大的Vim有colorscheme這樣的好物

googlecode上有個專案已經幫我們整理好許多可用的color scheme,比如說寫C/C++的,或是寫Java的都可以在這邊找找看

使用/安裝color scheme相當簡單,
1.先建立存放顏色的目錄
$ mkdir ~/.vim/colors
2.看到喜歡的,下載{COLOR_SCHEME}.vim到colors目錄下
$ mv /path/to/{COLOR_SCHEME}.vim ~/.vim/colors
3.修改Vim顏色設定,我目前是用blackbeauty和leo
$ vim ~/.vimrc
set t_Co=256              "support 256 colors
colorscheme blackbeauty   "blackbeauty is the name of color scheme
colorscheme leo           "leo is the name of color scheme
4.在Vim中使用
:colorscheme COLOR_SCHEME

Bye Bye 2010

2010年快結束了,今年發生一件大事,還有幾件小事,雖然最近運氣不太好,但強者我朋友要我強調總和來說還是旺的...
2011年希望一切順利,眾家親朋好友兄弟姊妹都能平安喜樂,比今年還好

Bye Bye 2010

2010年12月26日 星期日

[Vim] Some plugins for Vim

紀錄一下我在用的plugin,隨時會更新

1.Comment/Un-Comment
How to use?
<Ctrl-C> To comment
<Ctrl-X> To un-comment
How to install?
For VIM 6 and higher, stick this file in your ~/.vim/plugin directory or in some other 'plugin' directory that is in your runtime path

2010年12月20日 星期一

[阿宅專區] Toolbars on Internet Explorer

沒想到我的標籤竟然也要增加這一區了... 囧rz
而且是因為這個月都還沒寫一篇比較完整的文章,只好濫竽充數一下 ㄎㄎ

廢話不多說,今天胡亂逛,發現幾張圖蠻有趣的,以後也許會用到,先偷過來用,標題是"Toolbars on Internet Explorer"
source:http://www.ctbytes.com/blog/wp-content/uploads/2010/02/toolbars2-small.gif

看一張更厲害的
source:http://www.nuk3.com/gallery/images/comedy/full/308.jpg

謝謝觀賞