Scrambled chinese text in chromium-browser/google-chrome-stable tabs

On adding chinese input (ibus-pinyin etc) on ubuntu desktop, chinese text in the browser tabs became scrambled.

To get back legible tabs, remove the offending fonts:

rm /etc/fonts/conf.d/65-droid-sans-fonts.conf
fc-cache -f -r

In my case it was 65-droid-sans-fonts.conf, but I suppose it could be other fonts that was installed with the browser too.

Unicode characters cannot be displayed on Chrome tab title on Linux – Super User
Issue 316723 – chromium – Chinese <title> tags are not displayed correctly

Set up Asus router network printing on Ubuntu

Certain routers like the Asus RT-N66U have built-in network print server capability, which is an under-appreciated feature IMHO. But the settings > add printer dialog in Ubuntu 14.04 left much to be desired when it could not add the printer running behind the Asus router.

As a workaround, run the following command to get a better add-printer facility:

system-config-printer

Select Add.

Select Network Printer.

Select LPD/LPR Host or Printer.

Enter router IP (commonly 192.168.1.1) in “Host”, and LPRServer in “Queue”, and select Forward.

Choose the driver that matches the printer to add it to the system. You can now print from other applications.

 

ASUSTeK Computer Inc.-Forum- How to setup network printer in Ubuntu 12.04

 

apt-get stuff

1. Add redundant repo

In /etc/apt/sources.list, add:

deb http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://ap-southeast-1.ec2.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

 

2. Set timeout

Create /etc/apt/apt.conf.d/99timeout, add:

Acquire::http::Timeout "10";

 

apt-get away!

 

apt – How to lower wait time for repository updates – Ask Ubuntu

Breaking into a forked child in gdb

Disclaimer: I am a noob at gdb.

To use intel syntax and display the current instruction:

(gdb) set disassembly-flavor intel
(gdb) display/i $pc

Next, setting a breakpoint where 0xdeadbeef is the address of call fork instruction. Get gdb to follow fork child instead of parent, which is the default behaviour. Step over the fork to land in the child process:

(gdb) break *0xdeadbeef
(gdb) run
(gdb) set follow-fork-mode child
(gdb) nexti

Bonus, setting a rwx data breakpoint:

(gdb) awatch *0xbabecafe
(gdb) continue

Now I am not sure which is the greater evil, gdb or windbg…

ZFS with HP Smart Array P410i

As I was trying out zfs (on Ubuntu) on our HP server, I realised the RAID card that came with the server, HP Smart Array P410i, does not have a JBOD (Initiator-Target) mode. Now this is a First-world-problem – the card can support RAID 0, 1, 10, 5, 6, 50, 60, but not JBOD (?!).

Moving on, the next best thing is to configure every disk (we have 8 SSD) to be a 1-disk RAID 0 array to “simulate” a JBOD setup. Inside Ubuntu, there is now a 1-to-1 mapping of device to drive (sda – sdh), which is what is recommended by zfs.

Creating the zfs pool and setting some options:

zpool create tank sda sdb sdc sdd sde sdf sdg sdh
zfs set atime=off tank
zfs set sharesmb=on tank

But this is not the crux of this article. The problem is that random write performance is not as good as we expected out of zfs. The ideal setup would be to expose individual disks to zfs, but we could only expose the disks through the RAID card. After some tinkering, we found that the drive write cache was disabled, probably due to the fact that there is no battery unit on the RAID card.

To enable drive write cache:

hpacucli controller slot=0 modify drivewritecache=enable

IIRC there was some warnings, but I ignored them as what I want is a JBOD setup to hold non-mission critical data. A raidz pool can be setup if need be for redundancy, but at this point I lost myself looking at the 2x increase in write bandwidth. Next up, trying to saturate the pipe :D

diffutils for windows 64-bit

Needed to diff large (> 1GB) text files as part of a toolset, but DiffUtils provided by gnuwin32 is 32-bit only :( Of course I tried, but expectedly, it failed to diff the large files. Next solution: compile a native 64-bit version of diff. (Why is there no gnuwin64?) Anyway, I chose to compile on a x86_64 linux machine because I happen to have such a test machine around.

apt-get install mingw-w64
wget http://ftp.gnu.org/gnu/diffutils/diffutils-3.3.tar.xz
tar xJf diffutils-3.3.tar.xz
cd diffutils-3.3
# get diffutils-3.3-mingw64.patch and place it here
patch -p1 -i diffutils-3.3-mingw64.patch
./configure --host=x86_64-w64-mingw32 --prefix=/tmp/diffutils-3.3-mingw64
make && make install

Now, the goods are in /tmp/diffutils-3.3-mingw64/bin. Enjoy!

The file diffutils-3.3-mingw64.patch can be found under Resources. I would have gladly pasted the file here if not for the non-printable character found in the original source. If anyone knows the settings for diff to generate pure printable patch file do drop a comment below, thanks!

Further interesting read: MinGW 64 how-to

 

Point to note when using idapython get_func()

For those who are interested in IDA Pro/idapython, here is a “mystery” I found myself getting stuck. Consider the following snippet for a .idb of a sizeable binary (e.g. user32.dll):

f = idaapi.get_func(idc.here())
print f.startEA
for x in idautils.Heads():
    idaapi.get_func(x)
print f.startEA

The output will be something like this:

2024480284
2024989954

Different addresses?! Mind-blowing!! (Of course, ignorance is the #1 reason for getting mind-blown.) Now for the reason behind this phenomenon, from idapython project site:

What happens is that the returned func_t* points inside the internal cache of func_t objects, and as you do more get_func() calls eventually that cache slot gets replaced by another function.

So instead of the code above, we can replace with the following using helper class lock_func:

f = idaapi.get_func(idc.here())
print f.startEA
flock = idaapi.lock_func(f) # lock the pointer
for x in idautils.Heads():
    idaapi.get_func(x)
print f.startEA
flock = None # don't need it anymore, free the lock

In short, excessive use of idapython idaapi.get_func() inside IDA Pro should be complemented with helper class idaapi.lock_func unless you are fine with references changing under your nose (a.k.a. without warning).

 

On-Line IDA Python Plugin manual: idaapi.lock_func