Categories
Tech Tips

How to determine which repo a RHEL/CentOS package belongs to

I thought this command should show me which repo the package ‘htop’ belongs to, but I was wrong:

[root@server ~]# yum info htop
Loaded plugins: rhnplugin, security
Installed Packages
Name : htop
Arch : x86_64
Version : 0.8.3
Release : 1.el5
Size : 136 k
Repo : installed 
Summary : Interactive process viewer
URL : http://htop.sourceforge.net/
License : GPL+
Description: htop is an interactive text-mode process viewer for...

Notice that it merely indicates ‘installed’ for the ‘Repo’ field? Not very helpful here. I wonder why yum works this way.

To find out which repo ‘htop’ comes from, use this command instead:

[root@server ~]# yum provides `which htop`
Loaded plugins: rhnplugin, security
htop-0.8.3-1.el5.x86_64 : Interactive process viewer
Repo : epel
Matched from:
Filename : /usr/bin/htop

htop-0.8.3-1.el5.x86_64 : Interactive process viewer
Repo : installed
Matched from:
Other : Provides-match: /usr/bin/htop

See ‘epel’ there? Bingo!

Categories
Tech Tips

Workaround for attaching > 1MB file attachment in Gmail

When I upload file attachment larger than ~1mb to Gmail using the Chrome web browser (v18.0.1025.33-r122015 google-chrome-beta on Ubuntu 11.10), the uploading will always fail after a while and Gmail will retry, resulting in an infinite loop to attach the same file.

Workaround: Use Firefox to attach such larger file attachments in Gmail. It works for me on the first try with Firefox 10.0.2.

Categories
Tech Tips

App for storing private files securely on Android devices

Are you looking for a Truecrypt-like app to store confidential files on your Android phone using virtual folder/container so that you don’t have to tediously encrypt/decrypt individual file?

Check out the LUKS Manager by Nemesis][. It works very well for me. Need rooted phone though.

Categories
Tech Tips

How to make bash step through matches from possible TAB completions

By default, TAB runs the ‘complete’ function whereas ‘\C-n’ runs ‘menu-complete’ and ‘\C-p’ runs ‘menu-complete-backward’.

So, let’s say you have .bash_history, .bash_logout and .bashrc in your current directory. When you type “ls .bash<TAB>“, this will be shown:

$ ls .bash<TAB>
.bash_history .bash_logout .bashrc

When you hit CTRL+N (next) now, the auto completion will replace ‘.bash’ with the first match from the list of possible completions, i.e. ‘.bash_history’. Repeated CTRL+N steps through the list of possible completions, inserting each match in turn.

CTRL+P (previous) moves backward through the list and matches in reverse sequence.

Categories
Tech Encounters Tech Tips

Some design considerations for tablet devices

I’ve got a chance to play with the old iPad and the newer Motorola Xoom. Here’s a list of some of my observations comparing the two in terms of hardware/form factor. It’s just a personal list and by no means comprehensive.

  1. iPad battery lasts longer when in sleep mode. Shorter battery life makes using the tablet tiring because I have to keep thinking about conserving the battery, e.g. by shutting it down but that means if I need to quickly google something, I’ll have to wait for it to power up first.
  2. iPad power button is on the top edge, while Xoom is at the back of the tablet, making it unreachable when it’s lying flat on the table. You are forced to leave it up when you want to access the button just to wake it from sleep mode, which is a very frequent action. This one gets on my nerves very quickly.
  3. iPad’s volume buttons are at the right edge and protruding high enough for ease of pressing. The Xoom’s are also by the side by it’s difficult to press because it’s too thin and flat.
  4. iPad’s speaker sounds a lot better than Xoom’s, at least to my untrained ears. Furthermore, iPad’s speaker is at the lower-right edge, i.e. it’s able to project the sound out to the front, especially if you hold it such that the body channels the sound upwards to your ears. The Xoom’s speakers are at the back! Why will anyone want to project the sound away from the user’s ears? It sounds a lot softer, feels further away and hollow!

So, in terms of design, iPad beats Xoom on many points. However, I’ll definitely prefer the open Android over Apple’s closed iOS. If any manufacturer can combine Apple’s design/hardware with Android without being hit by patent trolls, consumers will be very happy.

Do you know of any Android tablets with superb design?

Categories
Tech Tips

How to move VirtualBox VM from 1 machine to another

Environment: VirtualBox v4.1.8

  1. Backup everything that you’ll be touching in case anything goes wrong and you need to revert back.
  2. Move the <vm>.vdi hard disk file from the old machine’s "$HOME/.VirtualBox/VDI" to the new machine.
  3. Move the <vm> directory from the old machine’s "$HOME/VirtualBox VMs" to the new machine.
  4. Edit the "$HOME/VirtualBox VMs/<vm>/<vm>.vbox" file to change the old <HardDisk> location to that of the new machine.
  5. Double-click on this vbox file to load it into VirtualBox.
  6. Start the VM. It should load without any error.
Categories
Tech Tips

How to hide the title of specific post or page in WordPress 3.3

This makes sense especially for article that you’ve made as the static front/home page.

Add the following HTML into the post or page’s code:

<style>
.entry-title {display:none;}
</style>
Categories
Tech Tips

How to combine 2 single-page PDFs into 1 page

(1) Join the 2 separate PDFs into 1 file (e.g. joined.pdf) using tools such as pdfunite, pdfsam or pdfshuffler.

(2) Install pdfjam.
(Note: If you’re using Arch Linux, pdfjam is included in the texlive-bin package)

(3) Use the pdfnup tool from the pdfjam package to merge page 1 and page 2 of joined.pdf into a new pdf file consisting of only a single page, with page 1 stacked on top of page 2:

$ pdfnup joined.pdf --nup 1x2

Categories
Tech Tips

How to check if promiscuous mode is enabled on network interface in Linux

$ netstat -i

Look under the last column “Flg” for value “P”. If it’s there, it means promiscuous mode is enabled for that network interface. Is the flag really P and not M? Here’s a quick test. Check existing active flags:

[root@localhost ~]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0     2075      0      0      0     1366      0      0      0 BMRU
lo        16436   0     1985      0      0      0     1985      0      0      0 LRU

Turn multicast off on eth0:

[root@localhost ~]# ip link set eth0 multicast off

Notice that the ‘M’ flag is gone? So, M is for multicast:

[root@localhost ~]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0     2075      0      0      0     1369      0      0      0 BRU
lo        16436   0     1985      0      0      0     1985      0      0      0 LRU

Turn promiscuous mode on:

[root@localhost ~]# ip link set eth0 promisc on

Notice that the ‘P’ flag is now shown:

[root@localhost ~]# netstat -i
Kernel Interface table
Iface       MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0     2075      0      0      0     1370      0      0      0 BPRU
lo        16436   0     1985      0      0      0     1985      0      0      0 LRU

UPDATE 20130531: This post wrongly indicated that the “M” flag indicates promiscuous mode. Sorry for the confusion. I got that from other incorrect sources as well. It seems quite many online sources got that wrong. Thanks to the helpful commenters for correcting this mistake.

Categories
Tech Tips

GVim problems after upgrading to Ubuntu 11.10 Oneiric Ocelot

After upgrading Ubuntu 11.04 (Natty Narwhal) to 11.10 (Oneiric Ocelot), GVim starts to behave weirdly.

6 May 2012 UPDATE: Issue persists even after upgrading to 12.04 (Precise Pangolin)! 🙁

Symptoms:

  1. It sometimes freezes during startup, rendering the window greyish. If you wait, it may or may not regain control.
  2. When it doesn’t freeze during startup, typing response becomes very slow. For example, when you hit ‘j’ to move the cursor down 1 line, it takes ~7s before the action takes place. Key response then returns to normal if GVim is editing an empty file.
  3. When GVim loads a large file, typing response becomes very slow all the time.
  4. Sometimes you may see this error in the Terminal window you used to run gvim:
    ** (gvim:5933): IBUS-WARNING **: Create input context failed: Timeout was reached.
  5. Other times you may see this instead:
    ** (gvim:5760): WARNING **: Unable to register window with path '/com/canonical/menu/5C00024': Timeout was reached

Workaround:

Run gvim -f instead of just gvim.

Put this in your .bashrc if you don’t want to add -f all the time, or if you already have other aliases using gvim and you don’t want to change all of them:

gvim(){ setsid /usr/bin/gvim -f "$@"; }