Author: Xuan Hu

  • 使用密钥自动登录SSH(更新ssh-copy-id)

    【更新】
    lyxint提醒,发现了ssh-copy-id命令,第二步可以更简单的实现
    ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname
    其中username为用户名,hostname为服务器VPS的IP地址

    1)在本机生成公钥密钥
    ssh-keygen -t rsa
    一路回车,选择默认路径即可,默认路径为~/.ssh/

    2)将本地公钥上传至服务器
    cat ~/.ssh/id_rsa.pub|ssh username@hostname ‘sh -c “cat – >>~/.ssh/authorized_keys”‘
    其中username为用户名,hostname为服务器VPS的IP地址

    3)ssh设置文件的几点说明(一般是默认即可)
    路径:/etc/ssh/sshd_config
    相关行:
    PubkeyAuthentication yes #开启公钥验证
    #AuthorizedKeysFile %h/.ssh/authorized_keys #公钥的位置,建议使用默认路径

  • LaTeX笔记(1)

    取消连字符
    sloppy: 弱命令
    效果不是很明显,但是基本保证布局美观

    pretolerance=10000: 强命令
    效果很明显,几乎可以去掉所有连字符,但是对布局影响很大
    10000是一个阈值,可以适当变小,可能会有比较折中的效果
    补救措施:在字符间距非常大的地方用 – 命令强制生成连字符

    引号
    ` ` : 左双引号(两个小撇,和波浪号同一个键)
    ` : 左单引号(一个小撇,同上)
    ‘ ‘ : 右双引号(两个单引号)
    ‘ : 右单引号(一个单引号)
    P.S.请不要直接复制粘贴,中间有空格,为了HTML下的显示需要

    强制不分行
    mbox{content here will not be split up}

    四级标题
    section{}
    subsection{}
    subsubsection{}
    paragraph{*.*.*.* }

    波浪线
    ~{}

    上角标
    textsuper{}: 非数学环境
    ^{}: 数学环境

    首段缩进(默认不缩进)
    usepackage{indentfirst}

    推荐的格式设置
    documentclass[a4paper,12pt]{article}: 纸张类型,主体字号,文档类型
    usepackage[top=1in,bottom=1in,left=1.25in,right=1.25in]{geometry}: 页边距

    超链接去边框和颜色
    usepackage[colorlinks,allcolors=black]{hyperref}

    嵌入所有字体
    dvips -Pdownload35 inputfilename.dvi

  • Android平台下FreePascal的交叉编译器

    0) Preface
    0.1) The Operating System is Ubuntu 10.10
    0.2) All the softwares are the latest stable version by April 12, 2011

    1) Download the Source of Free Pascal Compiler
    The ‘fpc-2.4.2.source.tar.gz’ on http://sourceforge.net/projects/freepascal/files/Source/2.4.2/

    2) Install the fpc-source. Just extract it.
    The root folder of fpc-source for me is ‘/home/victorhu/fpc-source’

    3) Download the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
    The ‘IA32 GNU/Linux Installer’ on http://www.codesourcery.com/sgpp/lite/arm/portal/release1600

    4) Install the Arm-Eabi (Sourcery G++ Lite 2010.09-50 for ARM GNU/Linux)
    The installation need the system shell to be bash not dash which is default for Ubuntu. So
    4.1) [shell]sudo dpkg-reconfigure -plow dash[/shell] Choose NO to make the bash as the system shell.
    4.2) Goto the root folder of Arm-Eabi for me is ‘/home/victorhu/toolchain/’
    4.3) [shell]chmod +x arm-2010.09-05-arm-none-linux-gnueabi.bin[/shell]
    4.4) [shell]./arm-2010.09-05-arm-none-linux-gnueabi.bin[/shell]

    5) Get the Cross Compiler
    5.1) Goto the root folder of fpc-source
    5.2) [shell]make crossall CPU_TARGET=arm OS_TARGET=linux OPT=”-dFPC_ARMEL -O- -gl” CROSSPORT=”-O-” CROSSBINDIR=/home/victorhu/toolchain/arm-none-linux-gnueabi/bin[/shell]
    5.3) The ‘ppcrossarm’ under ‘/home/victorhu/fpc-source/compilers/’ is just what we want.
    Note: CROSSBINDIR is depend on the folder of Arm-Eabi.

    6) Write a Hello Word in Pascal
    The path for me is /home/victorhu/hello.pas
    [pascal]
    Program hello;
    begin
    writeln(‘Hello World!’);
    end.
    [/pascal]

    7) Compile the Hello World in Pascal via CrossCompile Environment.
    7.1) Goto the folder contains ‘ppcrossarm’
    7.2) [shell]./ppcrossarm -Tlinux -O- -XP -Fu/home/victorhu/fpc-source/rtl/units/arm-linux/ -FD/home/victorhu/toolchain/arm-none-linux-gnueabi/bin /home/victorhu/hello.pas[/shell]
    Note: -Fu is the unit path, -FD is the compiler utilities path.
    7.3) The ‘hello’ under ‘/home/victorhu/temp’ is just the what we want (not hello.pas).

    8) Test the Crosscompiled Hello World in Android Emulator
    8.1) the tools under Android SDK or the ADT of Eclipse is where we can find it.
    8.2) Goto the adb root folder under Android SDK .
    It’s ‘platform-tools’ under the main root folder of Android SDK now while it’s ‘tools’ before.
    8.3) Test whether is device is connected.
    [shell]./adb devices[/shell]
    If it shows somthing like ‘Emulator-5544 device’ (for me), then it’s right.
    8.4) Push the program into Android Emulator.
    [shell]./adb push ~/hello /data/hello[/shell]
    8.5) Run the program on the Android Emulator.
    [shell]./adb shell data/hello[/shell]
    If it shows ‘Hello World!’ (the result of the original program), then everything is done now!

    9) Reference
    9.1) http://alexmogurenko.com/blog/programming/android-building-free-pascal-compiler-for-android/
    9.2) http://wiki.freepascal.org/Android_Interface
    9.3) http://wiki.freepascal.org/Setup_Cross_Compile_For_ARM

    P.S.本文参与“第二届 Google 暑期大学生博客分享大赛 – 2011 Android 成长篇”,感谢大家支持