Monday, April 22, 2013

Ubuntu: Display Tibetan Characters

To display Tibetan characters on Ubuntu/Linux, one need to install Tibetan language support. First go to Dash (press Win Key or on Mac ), search language support, click Install/Remove Lanugages button, and select Tibetan from the list, then Apply Changes.

Brightness Key Freezes Ubuntu 12.04

Notebook: Dell INSPIRON 1564. There was no such problem in Ubuntu 11.04. Don't upgrade to 12.10, you will encounter ugly interface problem (see here).

Noticed from here: askubuntu, a method was proposed, which was to modify a line in /etc/default/grub into

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor acpi_osi=Linux"
And then update and reboot
sudo update-grub
sudo reboot

Although I tried the same, I don't confirm this will definitely work. My experience is, if you tap slowly one at a time until it changes the brightness and show the notification, then proceed, it will be okay. If you are stuck in such freezing state, any keyboard combo can't save you out.

Reset brightness to lowest on reboot

That is what I wanted to do. Ubuntu didn't save (or the video driver) the last-time configuration of brightness. (link)

The solution, I too confirm, is to add a local script to be executed on reboot. Here is the excerpt.

sudo vi /etc/rc.local

Add the following due to your folders under /sys/class/backlight (you might need play around with it)

echo 0 > /sys/class/backlight/acpi_video0/brightness
exit 0

My machine uses a default video driver (non-proprietary) and the video card ATI RV710.

Sunday, April 21, 2013

grep Boolean Operators

OR (equivalent variations)

grep "foo\|bar"
grep -E "foo|bar"
egrep "foo|bar"
grep -e foo -e bar

AND (use grep twice)

grep foo | grep bar


grep -v foo

Sunday, April 14, 2013

An Easy Chrome App

This app is basically a link to a website.

Create manifest.json with the following content

  "name": "BBC News",
  "description": "BBC World News",
  "version": "1",
  "manifest_version": 2,
  "icons": { "128": "bbc-icon-128.png" },
  "app": {
    "launch": {
             "web_url": ""

I got this icon,

At chrome://extensions/, turn on Developer Mode, and click Load unpacked extension, locate the folder, that's it!

Saturday, April 13, 2013

Get Gwibber Authorizing Twitter

Error Encountered

** Unable to load page **
** blah blah blah **
** Cannot resolve proxy hostname () **

Upgrading Gwibber From PPA

sudo add-apt-repository ppa:ubuntu-desktop/ppa
sudo apt-get update
sudo apt-get upgrade

Another personal package archive source is ppa:gwibber-daily/ppa.

Network Proxy Settings

System Settings > Network > Network Proxy > Method

Set its value none and Apply system wide.

Wednesday, April 10, 2013

Safe Ways to Force Reboot Ubuntu

(Credit: link)

If lucky,


If still lucky, call a terminal

CTRL + ALT + F1/.../F5

If not so lucky,

ALT + SysRq (PrtScr) + K

Ah, everything fails. Here is the magic wand for Linux kernel

CTRL + ALT + SysRq (PrtScr)

That is to hold Ctrl+Alt, tap SysRq, then type in order:


which is BUSIER in reverse order.


  1. Freezes - Linux Guide - WikiBooks
  2. Magic SysRq Key - Wikipedia

Tuesday, April 9, 2013

Rescue Windows 7


I run into a period that I have to give up my hard disk (hardware failing).

Download OS ISO from the links provided in Windows Community (search "windows 7 home / professional iso etc.")

Burn to DVD

You know how. :) I downloaded Home Premium version (didn't find an Italian version which I was using).

Or Burn to USB!

Windows 7 USB/DVD Download Tool is an open project from Microsoft that allows you to burn to USB easily. Try it, it is neat.


One thing needs to mention. you might see setup was unable to create a new system partition.... Windows 7 seems to find difficulty in identifying the primary drive. In this case, configure your booting priority from BIOS so that your HDD is the first. Then choose from boot options for starting from USB. Hope this helps.

Activate it

It is said to be working (confirmed now by me) if you have an OEM (most of us do) product key (on your COA label at the back, needed at installation). After installation, you will have three days to activate it. Go to Control Panel > System and Security > System, under Windows Activation, call the toll-free number shown, enter the numbers in groups, then you will receive the same amount of numbers to activate the system. It is indeed working!

Further Notes

An OEM product key is said to be reusable for the same machine. I replaced my hard disk with a new one, I think this doesn't make my notebook a new one according to Microsoft. The fact is I did have installed the English Win 7 Home Premium with my Italian Home Premium Key.

I guess Microsoft is encouraging customers to solve problems on their own so as to get rid of lots of unnecessary labor. And you are able to legally download their whole system (though not emphasized officially)!

Wednesday, April 3, 2013

awk: Filtering and Calculation

Filter wanted data columns

Here is a list of output from ftrace, filtered by the pid (12798) of sample program, then filtered with grep:

sample-12798 [003] 42655.062100: sched_stat_runtime: comm=bash pid=12798 runtime=258929 [ns] vruntime=143898862 [ns]
sample-12798 [001] 42655.062977: sched_stat_runtime: comm=sample pid=12798 runtime=864136 [ns] vruntime=94618957 [ns]

Print only the column of runtime,

... | awk '{printf"%s\n", substr($7,9,length($7)-8)}'

Calculate the Sum

... | awk 'BEGIN {sum=0}{sum+=$1} END {print sum}'

tikz: Plotting Functions

Use plot (in tikz package) to draw functions in $\mathrm{\LaTeX}$.


The example below generates this graph.

\draw[->] (0,0) -- (8,0) node[right] {$x$};
\draw[->] (0,0) -- (0,10) node[above] {$f(x)$};
\draw (1.5,0) -- (1.5,0.1) node[below] {$\frac{3}{2}$};
\draw (2.25,0) -- (2.25,0.1) node[below] {$\frac{5}{2}$};
\draw[dotted] (3,9) -- (3,0)  node[below] {$3$};
\draw [domain=0:3] plot (\x,{4/3 * \x*\x*\x - 8*\x*\x+15*\x}) node[right] {$\frac{4}{3}x^3-8x^2+15x$};
\draw [domain=3:6] plot (\x,{9*exp(3-\x)}) node[right] {$9e^{3-x}$};

Monday, April 1, 2013

shell: Rename Multiple Files in a folder

Substitute foo in file names to bar:

for f in *;
  mv $f ${f/foo/bar}

Prefix all .jpg files with foo and a counter:

for f in *.jpg;
  mv $f 'foo-'$i'.jpg'
  i=`expr $i + 1`

Notice spaces in expr can not be omitted.

Windows: MINGW32

You can start a MINGW32 shell command line from git cmd under Windows.

i=0;for f in *.jpg; do mv $f $i'.jpg'; i=`expr $i + 1`; done