Thursday, September 26, 2013

Latex 对齐方式

LaTeX 对齐方式

一行对齐:
\leftline{左对齐} \centerline{居中} \rightline{右对齐}

多行或者段落对齐:
左对齐 \begin{flushleft}...\end{flushleft},
居中 \begin{center}...\end{center}
右对齐 \begin{flushright}...\end{flushright}


LaTeX公式左对齐
LaTeX中公式默认是居中对齐的, 但有时我们希望它能左对齐, 使用的方法如下:

1. \documentclass[a4paper,fleqn]{article} 这个对整篇文章有效.

如果只需要对一行公式进行左对齐的话, 可使用
\begin{flalign}
your equation (1)
\end{flalign}


2. 对某一个公式:
some text here\\
your equation here
and more text here.


3. 如果你说的是某一个公式有两三行, 你想把这几行做左对齐.
\begin{flalign}
\begin{split}
your equation (1)
your equation (2)
\end{split}&
\end{flalign}


还有其它方法,
例如使用 左对齐、居中对齐、右对齐的环境分别为flushleft、center和flushright。也可以使用命令\raggedright、\centering和\raggedleft使以后的文本按指定方式对齐.

或者

加载amsmath宏包后,使用选项fleqn(就是声明加载宏包时使用\usepackage[fleqn]{amsmath})可以使本该居中对齐的行间公式改为左对齐.
Read more ...

Solution to iPad “Not Charging” When Connected to Computer USB

Download the software > ASUS Ai Charger
Read more ...

Sunday, September 15, 2013

Java 1.6.0_51 breaks MATLAB 2012b

The was an issue in the Java security updates that Apple released for Mac OS X (as mentioned above). These updates install Java 1.6.0_51 and the exact build number looks like this (ending with M4508):
Java™ SE Runtime Environment (build 1.6.0_51-b11-456-10M4508) You can check if you have installed the xM4508 versions by running any one of the following commands on the Terminal of your Mac OS X:
java -version 
OR
/usr/libexec/java_home -v 1.6 -exec java -version 
If you have previously installed the xM4508 versions of the Java updates you can upgrade to the fixed xM4509 version by manually installing the following update:
Mac OS 10.7.x and 10.8.x:
================
Mac OS 10.6.x:
================
Confirm that you have the updated Java version by executing any of the above two commands. The exact build number looks like this (ending with M4509):
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-10M4509)
updates already (ending with M4508), you should receive this fix (ending with M4509) automatically through Software Update / App Store.

source: here
Read more ...

Wednesday, August 14, 2013

Monday, July 15, 2013

Cut or trim mp3 files with Linux

Link.


We are going to see two different options:

1. mpgtx
To install this program under Debian
$ sudo aptitude install mpgtx
Now if you want to trim a mp3 file into 10 pieces just enter this command
mpgtx -10 input.mp3 -o output
You will get output01.mp3, output02.mp3 .... output10.mp3 files, and now you can easily transport them, use them as ringtones, or anything you need.
Now if you want to cut an specific part of the mp3 file you may use ranges:
$ mptsplit input.mp3 [00:00:20-00:00:58] -o output.mp3
Now you will have from the 20th second to the 58th second of the song, in output.mp3 file, which is great for creating ringtones for your cellular.
Read the man page for more options, as you can also join files and some other useful things.

2. mp3cut
First install the program, mp3cut is one tool, of the mp3 suite tools called poc-streamer, so lets install the suite of tools.
$ sudo aptitude install poc-streamer
Now to cut or trim the mp3 files, it works a lot like the first option in this article, lets try the same example.
$ mp3cut -o output.mp3 -t 00:00:20+000-00:00:58+000 input.mp3
This will have the same effect and you will get a resulting file containing the song from the 20th second to the 58th second.
Do not forget to check the man page, and also to hear to your resulting files also from the command line check out: mpg123
Read more ...

Tuesday, July 9, 2013

X Forwarding with Putty on Windows

Prerequisites

Configuring Putty
  1. Add Unix hostname/IP address
  2. Switch Protocol to SSH
  3. Type name of session in saved sessions
  4. Click 'Save'
  5. Expand the 'SSH' tab from the 'Category' list
  6. Choose 'X11' from 'SSH' list
  7. Check 'Enable X11 Forwarding'
  8. Put localhost:0 to X display location
  9. Choose 'Session' from 'Category' list
  10. Click 'Save'
Connecting
  1. Start Xming
  2. Start Putty
  3. Double click on the saved session you want
via: here

Read more ...

Windows 下配置 Latex

首先安装 MiKTeX 或者 TexLive
然后安装 TeXstudio

MiKTeX 的 texmf 路径可以通过 MiKTeX Options (Admin) 程序查看

打开 MiKTeX Options (Admin)
选择 Roots
勾选 Show MiKTeX-mantained root directories

就可以看到了

第三方的 theme 可以直接放到这里面

另外安装 package 可以用 Package Manager (Admin) 程序安装
如果是下载好的宏包安装
可以打开 Package Manager (Admin)
选择 Repository
选择 Change Package Repository
选择 Package shall be installed from a directory
Read more ...

Thursday, June 27, 2013

Debian change default display manager and session

To change default display manager
$  sudo nano /etc/X11/default-display-manager

To change default session
$ update-alternatives --config x-session-manager
Read more ...

Wednesday, June 26, 2013

Linux command for username and group

Change or rename user name and UID (user-id)
# usermod -l <new_username> <old_username>
# usermod -u UID <username>

List username from a group
# getent group <groupname>

Remove username from a group
# gpasswd -d <username> <group>

Remove/Delete a user account
# userdel <username>
The following command will also remove user home directory
# userdel -r <username>

Add user to a group
# adduser <username> <group>
Read more ...

Control Volume with Keyboard Shortcut in Xfce

Add an Xfce shortcut by going to Applications > Settings > Keyboard.

Code for volume up/down/mute

1 amixer set Master 3%+
2 amixer set Master 3%-
3 amixer set Master toggle


Read more ...

Friday, June 21, 2013

Ubuntu/Debian 下安装 VirtualBox 虚拟 Win7

官方网站:http://www.virtualbox.org/

VirtualBox中虚拟Win7
运行Vbox
–》单击左上角New,新建虚拟环境。
–》填写名称和将要虚拟的操作系统版本。
–》然后是内存设置,默认即可,如果host主机内存够大,可以多设。
–》接下来虚拟硬盘,一路默认即可,最后确认,完成。

安装Win7
–》准备好系统镜像。win7.iso。
–》单击左上角Settings,会提示:Failed to access the USB subsystem.VirtualBox is not currently allowed to access USB devices. You can change this by adding your user to the ‘vboxusers’ group. Please see the user manual for a more detailed explanation.
将用户名添加到vboxusers组,重启或注销后即可解决。
sudo adduser usrname vboxusers
–》选择Storage,在看到IDE controler控制器下有硬盘和光盘, 光盘显示Empty,点击右侧Attributes属性中CD/DVD drive 右边的光盘图像,Set up the virtual CD/DVD drive,选择硬盘上下载的iso镜像文件,创建虚拟光驱。如果下面的步骤无法继续,在这里还可以尝试添加Sata 控制器。
–》设置好Storage点击Start 开始。接下来和普通安装Win7一样了。
–》安装完。优化设置,重新安装有问题的主板驱动;配置网络:如果无法上网,Settings中设置network从AMD换为intel(r) PR0/1000 MT Network Connection等,启动网卡驱动安装。

设置共享文件
Guest(win)
–》在Settings – Share Folders 点击+号新建共享文件夹,可选择Auto Mount 自动挂载。
–》点击顶部菜单设备device选项–Install Guest Additions,进行安装。
安装完毕,即可看到共享文件夹。

Guest(linux)

For linux guest, You may have to install following packages to complete Guest additions.

To dispaly the KERNELVERSION of the running distribution, you can use
uname -r

sudo apt-get install xserver-xorg xserver-xorg-core build-essential linux-headers-KERNELVERSION dkms
  1. sudo mkdir /media/shared  
  2. sudo mount.vboxsf Share /media/shared  
  3. sudo gedit /etc/fstab  
add the following into fstab:
Share /media/shared vboxsf rw 0 0
Share 为你要共享的文件夹 可以在settings里面设置。


支持USB
VirtualBox启用USB 2.0 必须安装:Oracle VM VirtualBox Extension Pack for Windows。在窗口顶部菜单File-Preferance-Extensions中添加下载的extpack。最后在Settings的usb选项中启用USB2.0,然后添加usb设备,即可。

摄像头驱动
同样在USB设置中添加摄像头。然后到虚拟的Win7里面安装相应驱动即可。
 
Read more ...

MATLAB FUNCTION accumarray

A = accumarray(subs,val,sz,fun,fillval)
  sub:提供累计信息的指示向量
   val:提供累计数值的向量
    sz:控制输出向量A的size
   fun:用于计算累计后向量的函数,默认为@sum,即累加
fillval:填补A中的空缺项,默认为0


例子:

  1. myfun = @(x) 1./(2*numel(x)) * sum(x);  

myfun = 

    @(x)1./(2*numel(x))*sum(x)

  1. subs=[7,2,5,7,2]';  

subs =

     7
     2
     5
     7
     2

  1. val=1:5;  

val =

     1     2     3     4     5

  1. sz=[10,1];  

sz =

    10     1

  1. A=accumarray(subs,val,sz,myfun,nan);  

A =

       NaN
    1.7500
       NaN
       NaN
    1.5000
       NaN
    1.2500
       NaN
       NaN
       NaN

个人对此函数的理解:
首先,函数根据参数中sz,生成一个中间矩阵B,此例中sz=[10,1],所以B是一个10*1的矩阵。
然后,函数根据subs中的指示,将val中的数值摆放到B中。
  subs  val
     7     1
     2     2
     5     3
     7     4
     2     5
意思就是,val中的1被扔到了B中第7的位置,同样,2扔到B中第2个位置,3到B中5,4到B中7,5到2。
这样B中的2,5,7位就被摆放上了数值,而且,2和7两个位置上被摆上了2个数值。

B =

   NaN
   2,5
   NaN
   NaN
   3
   NaN
   1,4
   NaN
   NaN
   NaN
其他还有7个位置并没有被摆放任何数值,我们暂时不管他,给他扔上NaN。
然后,accumarray函数就会根据自定义的函数myfun,来计算了。拿什么算呢,拿的就是这个中间矩阵B,我们定义的myfun意义就是均值的一般,所以也可以定义的时候写成:

  1. myfun = @(x) mean(x)./2;  

这下就简单了,就相当于mean(B)./2,然后得出的结果就是A了。
A =

       NaN
    1.7500
       NaN
       NaN
    1.5000
       NaN
    1.2500
       NaN
       NaN
       NaN
个人理解大概是个这样的过程,接下来再去看matlab的help文件就比较容易懂了。
Read more ...