2012年9月1日 星期六

Grub / Grub2 Rebuild


進入linux中(ubuntu12.04), 用grub2的重建方式:
1. mount /dev/sda1 /mnt
  (假設要修復的硬碟的/boot是在/dev/sda1的位置上)
2. grub-install --boot-directory=/mnt /dev/sda

此時會將GRUB2放入 MBR中

重新開機後, 若是原本的系統不是Grub2的, 則會進入grub命令列

1. ls
  (列出目前的硬碟)
2. set root=(hd0,msdos1)
  (可以用tab來取得一些msdosX的資料)
3. linux /boot/vmlinuz root=/dev/sda1
  (vmlinuz可能有多個, 要自己選一下)
4. initrd /boot/initrd
  (initrd的位置可用tab補全)
5. boot
  (開機)

開機進去之後, 將grub2復原為原本的grub

1. find /boot/grub/stage1
  (找尋grub的位置)
2. root (hd0,0)
  (上一個指令讀回的位置)
3. setup (hd0)
4. quit
5. 重新開機, 做確認

GLib Compile Parameter

- If you don't want to use DEPRECATE widget, can add define G_DISABLE_DEPRECATED
 (ex. -DG_DISABLE_DEPRECATED=1)

 - If you can't accept one include file, can add define G_DISABLE_SINGLE_INCLUDES
 (ex. -DG_DISABLE_SINGLE_INCLUDES)

 - Header File List
    - glib.h
    - glib-object.h
    - gio.h
    - gmodule.h
    - glib/gi18n-lib.h or glib/gi18n.h
    - glib/gprintf.h
    - glib/gstdio.h

 - pkg-config --cflags glib-2.0 means:
   -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include

 - pkg-config --libs glib-2.0 measn:
    -L/usr/lib -lm -lglib-2.0

 - GLib Compile parameter
    pkg-config --cflags --libs glib-2.0

 - GThread compile parameter
    pkg-config --cflags --libs gthread-2.0

 - GObject compile parameter
    pkg-config --cflags --libs gobject-2.0

 - Gmodules compile parameter
    pkg-config --cflags --libs gmodule-no-export-2.0
    OR
    pkg-config --cflags --libs gmodule-2.0
    Difference:gmodule-2.0 has "--export-dynamic" (link flag)

2012年5月4日 星期五

bitbucket.org first push with GIT

- Create a new repository
- >> git remote add origin https://[user]@bitbucket.org/[user]/[repo].git
- Settin the public/private key
- >> git push -u origin master

2012年3月25日 星期日

Plurk API 1.0 with libcurl (Linux)

Platform: Debian Squeeze

Requirement: libcurl4-openssl-dev

Get Plurk API Key: Goto  http://www.plurk.com/API/1.0/ to get an API key (Fill the form, and click "Issue API key")

Plurk.c: (need API_KEY/USERNAME/PASSWORD)
#include <stdio.h> #include <stdlib.h> #include <curl/curl.h> int main (int argc, char *argv[]) { char POST[256]; CURL *curl; curl = curl_easy_init (); sprintf (POST, "api_key=API_KEY&username=USERNAME&password=PASSWORD&no_data=1"); curl_easy_setopt (curl, CURLOPT_URL, "http://www.plurk.com/API/Users/login"); curl_easy_setopt (curl, CURLOPT_POSTFIELDS, POST); curl_easy_setopt (curl, CURLOPT_COOKIEFILE, "cookie.txt"); curl_easy_setopt (curl, CURLOPT_COOKIEJAR, "cookie.txt"); curl_easy_perform (curl); /* Perform Login */ sprintf (POST, "api_key=API_KEY&qualifier=says&lang=tr_ch&content=!FB %s", argv[1]); curl_easy_setopt (curl, CURLOPT_URL, "http://www.plurk.com/API/Timeline/plurkAdd"); curl_easy_setopt (curl, CURLOPT_POSTFIELDS, POST); curl_easy_setopt (curl, CURLOPT_COOKIEFILE, "cookie.txt"); curl_easy_setopt (curl, CURLOPT_COOKIEJAR, "cookie.txt"); curl_easy_perform (curl); /* Perform an Plurk messge and this message willnot send to Facebook */ curl_easy_cleanup (curl); return 0; }

Makefile:
all: Plurk.c gcc -o Plurk Plurk.c -lcurl

Usage
>> ./Plurk "Plurk API Test"

Finish

在Blogger中加入Source Code區塊

在HTML的POST中加入以下內容即可

.post code { display: block; font-family: Courier New; font-size: 10pt; margin:.75em 0; overflow: auto; background: #f0f0f0; border: 1px solid #c0c0c0; padding: 10px 10px 10px 10px; line-height: 1.0em; white-space: pre; }