Sunday, December 30, 2012

Create a Shortcut to Terminal on Kubuntu

Go to Applications/Settings/Xfce4 Settings Manager > Keyboard, under Shortcuts to Applications tab, Add a new entry: put the following command
xfce4-terminal
I used
Ctrl+Alt+T
as the shortcut.

Remove Keyring Dialogue on Ubuntu/Kubuntu

One needs to use Passwords and Encryption Keys menu, if it is not found under Applications/Accesories, then install it from terminal

sudo apt-get install seahorse

After the installation, open the menu, remove Default line under Password tab. At next poping-up dialogue, put empty password.

Sunday, December 23, 2012

Fan Cleaning: SONY VAIO PCG-GRV550


  • PREPARE THE TOOLS:
  • KEY POINT: OPEN FROM FRONT, REMOVE THE HIDDEN SCREW
  • SLIDE THE SOUND PANEL TO RIGHT, DETACH THE SIGNAL STRIP UNDERNEATH.
  • TAKE AWAY THE KEYBOARD, TAKE OFF THE SIGNAL STRIPS
  • DRAW A MAP OF SCREWS
  • MANY TEDIOUS STEPS OMITTED, E.G., REMOVE FROM BACK SIDE, BATTERY, HARD-DISK, CD DRIVER, AND REMOVE THE SCREWS AT THE EDGE WHICH CONNECT THE TOUCHPAD SHELL, REMOVE THE LAYER UNDER THE KEYBOARD, WHICH COVERS THE FAN AND MAINBOARD.
  • REACH THE LAYER OF FANS
  • TAKE OFF THE BIG FAN AND REMOVE THE DUST LAYER
  • CLEAN INSIDE OF THE FAN
  • THE MAP OF SCREWS FROM BACK SIDE
  • REASSEMBLE ALL PARTS ACCORDING TO YOUR MEMORY AND SCREW MAP.

Sunday, December 16, 2012

Apache2: Set up Multiple Sites

An example. Modify /etc/apache2/httpd.conf file:
<virtualhost 127.0.0.1>
DocumentRoot /var/www/foo
ServerName www.foo.com
</VirtualHost>

<virtualhost 127.0.0.2>
DocumentRoot /var/www/bar
ServerName www.bar.com
</VirtualHost>
Restart Apache2 with updated configuration file.
sudo /etc/init.d/apache2 restart

Saturday, December 15, 2012

graphicsmagick: *.jpg to .pdf in one line

To convert multiple .jpg files into one single pdf file

sudo apt-get install graphicsmagick
gm convert *.jpg foo.pdf

To reduce rise in cost of quality:

gm convert -quality 60 *.jpg foo.pdf

Thursday, December 13, 2012

Fix wine for Ubuntu 11.04

NOTICE, wine runs WinDLX without problem on Ubuntu 11.10 and above, one can choose upgrading to 11.10 or higher (I did so). The following may disturb your default fontconfigure setting.

When running WinDLX via wine, winevdm.exe says encountering problem and needs to close. Backtraces lead to libfontconfig.so

The Fix

Download the following package

http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.8.0.tar.gz

Install the needed packages

libfreetype6-dev 
libfreetype6 
libxml2 
libxml2-dev

Unzip the download package, compile the package

  ./configure 
make 

Back up the original copies

cd /usr/lib32/ 
sudo cp libfontconfig.so libfontconfig.so.back
... 

Copy these files into /usr/lib32

fontconfig-2.8.0/src/.libs/libfontconfig.so 
fontconfig-2.8.0/src/.libs/libfontconfig.so.1 
fontconfig-2.8.0/src/.libs/libfontconfig.so.1.4.4

Remind the above fix affects the system font configuration. TO recover the old settings, please restore the backup files.

Wednesday, December 12, 2012

Get iSpin Full Featured

One needs to install some other software to use iSpin. Under Ubuntu, this can be easily done by Synaptics, but the package names are not so intuitive.
  • Spin (follow this link), the main background program
  • iSpin (interface), run iSpin/install.sh found in the Spin package
  • Tcl/Tk (Synaptics > tcl), iSpin interface
  • Dot (Synaptics > graphviz), for generating automata view
  • Yacc (Synaptic > bison), for compilation
To generate the channel messages flowchart from .trail file (shown as msc.ps), one can use command
spin -M -t foo.pml
It is saved into foo.pml.ps.
For the flowchart directly built from model, it may be wise to specify it's depth when the model has an infinite behavior.
spin -u100 foo.pml
To generate the automata view in ps file:
./pan -D | dot > foo.dot
dot -Tps foo.dot -o foo.ps
See more here: The Dot Guide.




Monday, December 10, 2012

Ubuntu: Installing EPSON Inkjet Drivers

I was enabling EPSON inkjet Stylus SX218 printer/scanner on Ubuntu 11.04. It requires two specific drivers (for printer and scanner respectively) which can be downloaded from EPSON website.

For the printer, one can use ubuntu recommended driver. It will pop up Update Manager once connected to the printer with USB.

For the scanner, one need to go the EPSON website, search for the right product, and install iscan-data (to which iscan depends on) first, then install iscan.

For me, I chose (visit link and search SX218)

  • iscan-data_1.20.0-1_all.deb
  • iscan_2.29.1-5~usb0.1.ltdl3_amd64.deb (for 64bits < 12.04)
  • iscan_2.29.1-5~usb0.1.ltdl7_amd64.deb (for 64bits >= 12.04)
one can double-click to open the file in Software Center.

Tuesday, December 4, 2012

Ubuntu: Run Compiled Package From Command

To do this, create a symbolic link to /usr/bin/
sudo ln -s exec-complete-path /usr/bin/command-name
Remind that one has to give the complete path, not the relative path.

Saturday, December 1, 2012

Kubuntu: Restoring Missing Panel

Kubuntu serves well on old-fashioned notebooks, as it is a light-weight version of Ubuntu.

To restore the missed top bar and bottom bar, press Alt+F2 (Run program) to open a dialogue, type:

xfce4-panel

It shall come back.

Monday, November 26, 2012

dpkg: Input/output error

This error is usually not hardware-wise (some say your hard disk has bad blocks). Actually, the dpkg database (/var/lib/dpkg/status) is not remembering things well. This leads package management to fail in any case, automatic repairs don't work.
dpkg: unrecoverable fatal error, aborting:
 reading files list for package 'emacs23-common': Input/output error
Due to an archive post by gartss (Refer link), it is repairable by manually removing the error-causing package records in status file.
Here is the sketch.
cd /var/lib/dpkg
sudo cp status status.backup
sudo vi status //remove the error package records (not those of dependencies)
sudo dpkg --configure -a
sudo apt-get -f install

Monday, November 12, 2012

LyX Goes With Tikz

To load tikz package, just like all the other $\mathrm{\LaTeX}$ packages, try set $\mathrm{\LaTeX}$ preamble under Lyx > Document > Settings > LaTeX Preamble, put
\usepackage{tikz}
And in LyX, Press Ctrl + L to insert TeX/LaTeX code. e.g.
\begin{tikzpicture}[thick,minimum size=2.3cm]
\path (0,0) 
 (0.8,1) node (c) [circle,fill=red,fill opacity=0.5]{}
 (-0.8,1) node (b) [circle,fill=green,fill opacity=0.5]{}
 (0,-0.4) node (a) [circle,fill=blue,fill opacity=0.5]{};
\path (0,-0.4) node (a1) {$C$}
      (-0.8,1) node (b1) {$B_0$}
      (0.8,1) node (c1) {$A$};
\end{tikzpicture}
And finally, use File > Export -> PDF (pdfLaTeX).

Saturday, October 27, 2012

Upgrading to Ubuntu 12.10: Restoring Grace

Caution: Upgrading the operating system is especially dangerous, and Quantal Quetzal is not coming without this risk.

Restoring Launch-bar and Top-bar

The reason of low and limited resolution after upgrading is that proprietary fglrx video driver (for AMD/ATI) is no longer compatible with x-server 1.13 equipped in Ubuntu 12.10. At this moment, one can choose downgrading to x-server 1.12 (see details here).

sudo add-apt-repository ppa:makson96/fglrx
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fglrx-legacy

System font

Personally, I favor the nice 12.04 fonts. One can use gnome-tweak-tool to achieve the following,

  • Default: Ubuntu 11
  • Document font: Sans 11
  • Monospace font: Ubuntu Mono 13
  • Window title font: Ubuntu 11

or simply use gsettings from terminal,

gsettings set org.gnome.nautilus.desktop font "Ubuntu 10"
gsettings set org.gnome.desktop.wm.preferences titlebar-font "Ubuntu Bold 10"
gsettings set org.gnome.desktop.interface document-font-name "Ubuntu 10"
gsettings set org.gnome.desktop.interface font-name "Ubuntu 10"
gsettings set org.gnome.desktop.interface monospace-font-name "Ubuntu Mono 11"

Removing Dash Online Results

Not every search is mattering a http request, let alone the ads-like results. Go to Dash, search Privacy, turn off include online search result, or drastically

sudo apt-get remove unity-lens-shopping

Saturday, October 20, 2012

dictd: Tibetan Chinese Dictionary Released

Today (Oct 20th) I issue a simple Tibetan Chinese Dictionary (containing 3063 headwords) compiled from a web resource. The hereby noticed dictionary (software) is free to use, redistribute, modify. However, the content in this software is subject to the author (not me)'s proper right. Anyone who tries to derive a new work from this software might be found guilty.

DOWNLOAD:

USE:

mv tibetan.idx tibetan.index
sudo mv tibetan.dict tibetan.index /usr/share/dictd/
sudo /usr/sbin/dictdconfig -—write
sudo /etc/init.d/dictd restart

Dictionary source: Web.

Disclaimer: The software presented is provided as "AS-IS", any cause from your use is not protected and the quality is not guaranteed. You are using it on your own risk. The author of the dictionary can claim the copyright of this work.

Friday, October 19, 2012

Calculating Indeterminate Limits Using Special Limits

Without using l'Hôpital's rule, one can utilize known limits. (Test MathJax $\Sigma$) \begin{align} &\lim_{x \rightarrow 0} \frac{\sin^2{2x} - e^{2x} + 1}{\ln (1+3x^2)} (\sqrt{3x+1} - \sqrt{1-x}) \\ =&\lim_{x \rightarrow 0} \frac{4x(\sin^2{2x} - e^{2x} + 1)}{(\sqrt{3x+1} + \sqrt{1-x})\ln (1+3x^2)} \\ =&\lim_{x \rightarrow 0} \frac{1}{(\sqrt{3x+1} + \sqrt{1-x})} \times \lim_{x \rightarrow 0} \frac{4x(\sin^2{2x} - e^{2x} + 1)}{\ln (1+3x^2)} \\ =&\frac{1}{2} \lim_{x \rightarrow 0} \frac{4x(\sin^2{2x} - e^{2x} + 1)}{\ln (1+3x^2)} \\ =&\lim_{x \rightarrow 0} \frac{2x(\sin^2{2x} - e^{2x} + 1)}{\ln (1+3x^2)}\\ =&\lim_{x \rightarrow 0} \frac{x(2\sin^2{2x} - 2e^{2x} + 2)}{\ln (1+3x^2)} \\ =&\lim_{x \rightarrow 0} \frac{x[-(1-2\sin^2{2x}) + 1 - 2e^{2x} + 2]}{\ln (1+3x^2)} \\ =&\lim_{x \rightarrow 0} \frac{x[(1-\cos{4x}) + 2(1 - e^{2x})]}{\ln (1+3x^2)} \\ =&\lim_{x \rightarrow 0} \frac{3x^2}{\ln (1+3x^2)} \cdot \frac{(1-\cos{4x}) + 2(1 - e^{2x})}{3x} \\ =&\lim_{x \rightarrow 0} \frac{3x^2}{\ln (1+3x^2)} \times \lim_{x \rightarrow 0} \frac{(1-\cos{4x}) + 2(1 - e^{2x})}{3x} \\ =&1 \times \lim_{x \rightarrow 0}\frac{(1-\cos{4x}) + 2(1 - e^{2x})}{3x} \\ =&\lim_{x \rightarrow 0} \frac{1-\cos{4x}}{4x}\cdot \frac{4}{3} + \lim_{x \rightarrow 0} \frac{2(1 - e^{2x})}{2x} \cdot \frac{2}{3} \\ =& \frac{4}{3} + \frac{4}{3} \\ =& \frac{8}{3} \end{align}

Thursday, October 11, 2012

olkb: open lightweight knowledge base

I've occupied myself for a couple of weeks on bringing out a light version of lexicon-alike knowledge base. http://olkb.zzl.org

Wednesday, October 10, 2012

WinDLX: File Processing

* Notice: WinDLX can be executed under Ubuntu with wine installed.
The WinDLX (obtained from here) processes *.S text file. The following reads a file a.s (<=500B) and print what it has read. Refer the native WinDLX Help file (UofT Vienna): WinDLX Help.
        .data
fn:     .asciiz "a.s"
buf:    .space 500
fstr:   .asciiz "The read text is:%s"

        .align 2
par:    .word fn
fd:     .space 4
        .word buf
        .word 500
out:    .word fstr
        .word buf

        .text
        lhi r14,par>>16
        addui r14,r14,par&0xffff
        trap 1          ;open file, get the descriptor
        sw fd,r1        ;save the descriptor (in r1) into memory

        lhi r14,fd>>16
        addui r14,r14,fd&0xffff   ;read block from file, block saved at buf
        trap 3

        addui r14,r0,out
        trap 5

        trap 0

Sunday, September 23, 2012

vi: Removing Endline Character ^M

A text file commutes between Linux and Windows may cause the endline control character explicitly printed as ^M.
To remove all control characters, under command mode
:%s/^M//g
Be aware that ^M is created by pressing ctrl + v (^) and then ctrl + M (M).
The command is utilizing the Find and Replace under vi:
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
Ranges are
% - the whole file
m,n - from line m to n
Pattern see vim reference.
Flags are
c - asks for confirmation at each replacement 
g - all the occurrences within a line
i - case insensitive
Count means to repeat for n times starting from the current line

Wednesday, September 19, 2012

php: Rendering text files in UTF-8

Pure .txt (even .utf8) files are rendered not as its natural encoding under Chrome (Version 21.0.1180.89 at present time). Then how to tell the browser to display it in the preferred encoding? We wrap it up via php and tell browser it requires utf-8.
  header('Content-Type: text/plain; charset=utf-8');
  include($txtname);

Monday, September 17, 2012

pdfpages: To Scale Freely

An improperly scaled pdf page requires tweaking its size. We use scale from graphicx to resize a page, combined with disabling auto-scale, offering an offset = {top, left}.
\documentclass[landscpae]{article}
\usepackage{grffile}  %to treat the spaces in the file name if needed%
\usepackage{pdfpages,graphicx} %the package to do the combination job%
\begin{document}
{
\includepdf[pages={1}, landscape, scale=1.1,noautoscale=true,offset={100 45}]
{OrariDiDirettrice-E12I-02.pdf}
\includepdf[pages={2}, landscape, scale=1.4,noautoscale=true,offset={150 150}]
{OrariDiDirettrice-E12I-02.pdf}
}
\end{document}

Saturday, September 1, 2012

Ubuntu: Enabling a webcam

The webcam is not detected. It indicates probably the driver is not installed, so we need to find the certain driver, and make it loaded by default. I am running Ubuntu 11.04 64bit on a Sony Vaio.

Use lsusb to find the device ID, as the case for me,
05ca:1839
It is reported as a Ricoh R5U870 webcam, the driver is not preinstalled, among all the online drivers provided, the following one works, containing no compiling error and it has enabled the camera perfectly.

https://bitbucket.org/ahixon/r5u87x/downloads

I quote the installation instructions here,
 $ sudo apt-get install libglib2.0-dev libusb-dev build-essential gcc 
  automake mercurial
 $ hg clone http://bitbucket.org/ahixon/r5u87x/
 $ cd r5u87x
 $ make
 $ sudo make install
 $ sudo r5u87x-loader --reload
It recalls me of my experience on enabling the wireless function on a DELL Inspiron long ago. As ubuntu is designed to be universal, it still faces both legal and technical issues to include all possible drivers. This requires the holders of proprietary drivers to consent the public use such as in a Ubuntu release.

Friday, August 31, 2012

Ubuntu: Uninstall User Fonts

User Fonts are installed easily by Font Viewer, but to uninstall, one can open a terminal:
cd ~/.fonts
rm foobar.otf foobar.ttf
This is needed for a font designer. When one updates a font, he has to install it once again. Unless removing it from the user fonts folder, one gets an install failed error.

Sunday, August 26, 2012

Ubuntu: Overheating Fix

[Update] Caution: Before reading the rest part of the fix (which is mainly the software side), be sure that the overheating is NOT caused by hardware problem. I have just performed a thorough cleaning inside my another DELL notebook, especially the fan (two years running without opening). I've found a thick layer of fluffy and dark dust, which was the major fact why my notebook is extremely hot and can't cool down properly. After that, every thing works like a charm. See how I cleaned the fan of a SONY vaio (step-by-step pics, link).

I was running Ubuntu 11.04 64-bit on a Sony vaio equipped with an Intel Mobile GM965 VGA card. It was said that a non-proprietary GPU driver caused the overheating, on which Ubuntu shuts down for security (>crit). Mine is loaded with i915 driver for video card (not the case here, Intel, however, launches their open Linux drivers via intellinuxgraphics.org.

To see your CPU temp,

sudo add-apt-repository ppa:alexeftimie/ppa
sudo apt-get update
sudo apt-get install lm-sensors indicator-sysmonitor

The System Indicator Monitoris shown on the panel, go to its Preferences, select the sensors for temperature and Add selected sensors. I prefer this tiny indicator. Also, you can type at the terminal

sensors

to get the following result

acpitz-virtual-0
Adapter: Virtual device
temp1:        +49.0°C  (crit = +94.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +41.0°C  (high = +80.0°C, crit = +90.0°C)
Core 2:       +47.0°C  (high = +80.0°C, crit = +90.0°C)

Before applying the fix provided below, it would run up to 90+ Celsius degree then inevitably the automatic shutdown follows.

Fix Confirmed

The fix is to add few lines to let Ubuntu load several modules at the booting time,

sudo vi /etc/modules

Append these lines and reboot,

battery
ac
thermal
processor
acpi-cpufreq
cpufreq-userspace

Open your monitor to track the CPU temp again. This time, when it rises high (>60) you feel the fan cooling off the CPU. The indicator monitor coincides with such change. Although it stays at 40+ when there is no engagement.

I've tried lm-sensors + sensors-dectect + pwmconfig + fancontrol, without success.

From time to time, I find many fixes are always tiny but magic, whilst a lengthy workaround doesn't help us out. The more steps are, the less compatible a fix might be.

Personally, I believe 11.04 is much better in its user interface than that of 12.04.

Sunday, August 19, 2012

Using pdfpages For A beamer Slide

Here is a real example. It simply chooses the specified pages. One might want to get rid of the pages for special effects (e.g. shadowing) to get a printable version.
\documentclass{beamer}
\usepackage{grffile}  %to treat the spaces in the file name if needed%
\usepackage{pdfpages} %the package to do the combination job%
\begin{document}
{
\setbeamercolor{background canvas}{bg=} %set background blank
\setbeamertemplate{navigation symbols}{} %remove navi symbols
\includepdf[pages={1,2,7,12,18,22,24,28,33-45,49,52-76}]{handout-06_fair_ctl_model_checking.pdf}
}
\end{document}

Thursday, July 19, 2012

Build a customized DICT database

Prepare the original word-definition pair file (foobar.txt) in the following format:
:foo:definition of foo
:bar:definition of bar
Create the database (.dict, .index) using dictfmt
dictfmt --utf8 --allchars -s "Foobar Dictionary" -j foobar < foobar.txt
Move to the proper folder, and restart the DICT server dictd
mv foobar.dict foobar.index /usr/share/dictd/
/usr/sbin/dictdconfig -—write
/etc/init.d/dictd restart
You may have DICT client dict to do such query
dict foo

Thursday, March 29, 2012

LaTeX: Creating Doubled Quine Corners

Quine corners are the symbols to enclose Church numerals. In LaTeX, one can create a macro to achieve it.

\documentclass{article}
\usepackage{amsmath}
\def \quine #1{
 \mbox{$\ulcorner$\hspace{-4pt}$\ulcorner$}
 #1
 \mbox{$\urcorner$\hspace{-4pt}$\urcorner$}
}
\begin{document}
$\quine i$
\end{document}

An equivalent way follows

%church number of lambda terms
\def \ch #1{
  \ulcorner #1 \urcorner
}

%quine corners for numerals
\def \quine #1{
   \ch  {\mbox{\hspace{-4pt}} \ch{ #1} \mbox{\hspace{-4pt}}}
}
The result is like $$\ulcorner \hspace{-4pt} \ulcorner n \urcorner \hspace{-4pt} \urcorner$$

Wednesday, March 28, 2012

pdflatex: Combining Multiple .pdf Files

A real example.

\title{The Essential C Notes}
\author{
\url{http://www.acm.uiuc.edu/webmonkeys/book/c_guide/}
}
\date{\today}
\documentclass{article}
\usepackage{grffile} %to treat the spaces in the file name%
\usepackage{pdfpages} %the package to do the combination job%
\usepackage{hyperref} %for the hyperlink%
\begin{document}
\maketitle
\includepdf[pages=-]{C Guide--1.pdf} %pages=- means all the pages%
\includepdf[pages=-]{C Guide--1.3 function.pdf}
\includepdf[pages=-]{C Guide--1.4 pointer.pdf}
\includepdf[pages=-]{C Guide--1.5 operators.pdf}
\includepdf[pages=-]{C Guide--1.6 statements.pdf}
\includepdf[pages=-]{C Guide--1.7 preprocessing.pdf}
\includepdf[pages=-]{C Guide--2.12 stdio.pdf}
\includepdf[pages=-]{C Guide--2.13 stdlib.pdf}
\includepdf[pages=-]{C Guide--2.14 string.pdf}
\includepdf[pages=-]{C Guide--2.15 time.pdf}
\includepdf[pages=-]{C Guide--2.7 math.pdf}
\includepdf[pages=-]{C Guide--Appendix A ASCII Chart.pdf}
\end{document}