Sunday, March 13, 2011

facebook's new photo viewer (theatre) - hate hate hate

those who hate fb's new photo viewer, you can disable it by installing greasemonkey (firefox addon) and a userscript:

http://userscripts.org/scripts/show/96773

Friday, February 25, 2011

how to access vmware virtual infrastructure web access

After I had installed vmware server 2 on an ubuntu linux server running remotely, I followed the instruction to access the vmware console from a web browser by going to this url from the Internet, remotely:

http://the-remote-server.nerd:8222

The page then redirected me to another https url on port 8333.  Then, I always got requested timeout.  It also seemed like it was reloading the page forever.  I really had no idea what was going on.  I did a 4 hours research on google.  I found many people experienced the same issue.  But, unfortunately, there was no single resolution.  (Some said that I needed to use another linux distro instead of ubuntu.)

For some unknown reason, I had come up with an idea to try to access that url locally.  *locally* with a server which is located far far away from me? ... With the great ssh client from OpenSSH suite, we can easily create a SOCKS proxy server and configure Firefox which can act as a SOCKS client so that it will use this SOCKS proxy server as a connection.  This is a sample command I use to create it:

% ssh -D localhost:5555 unsigned_nerd@the-remote-server.nerd

Then in Firefox, I configure it to use connection from SOCKS host: localhost port: 5555.  After that any websites I browse in Firefox are proxied through the-remote-server.nerd.  Therefore, when I browse http://localhost:8222, I can get to the vmware virtual infrastructure web access.  It's a big surprise that ... everything works smoothly without a problem.

I guess there are some bugs in it.  But the problem is gone if we browse the control panel locally for some unknown reason.

Good luck!

--
unsigned_nerd

Thursday, February 10, 2011

how to add pub key to gpg and add it into apt keyring

# gpg --keyserver subkeys.pgp.net --recv-keys <KEY_ID>
# gpg -a --export <KEY_ID> | apt-key add -

Wednesday, February 9, 2011

how to force install perl module from cpan

perl -MCPAN -e "CPAN::Shell->force(qw(install IO::Socket::SSL));"


Wednesday, January 26, 2011

how to securely erase files from harddisk

wipe!


Thursday, September 23, 2010

how to swapping ctrl key and capslock key in console



% loadkeys /usr/share/keymaps/i386/qwerty/emacs2.kmap.gz

Tuesday, September 21, 2010

how to disable automatic captializing the first letter of sentences in OpenOffice.org

The automatic captilizing the first letter of every sentences is very annoying [for me][I believe many people still have good reasons to use it][but this is just for me].

You can disable it by going to Tools => AutoCorrect Options

Please see the screenshot:

Thursday, September 16, 2010

how to update facebook status via command line

Recently, I found a text-based twitter client named "twidge".  It allows me to tweet right from command line.  For example, if you want to do a hello world tweet, you run this:

% twidge update "hello world"

I then think it would be a good idea if I can do the same thing with facebook i.e. to update facebook status right from command line.  However, when I did search on google, I found nothing.

Well, actually, there is an indirect way by:
  1. Adding facebook application "Selective Tweet".
  2. With the same twitter account you use to add "Selective Tweet", whenever you append "#fb" to your tweet, that tweet will also appear on facebook status.
But for many personal reasons, I just dislike this method as the same thing will be put onto both twitter and facebook which is not always what I want.

So what if I want to do it directly...

Recently, I had a chance to try out the Perl module "WWW::Mechanize" - Handy web browsing in a Perl object.  It is a subclass of the well-known LWP::UserAgent module which is a User Agent module for Perl which we use to write robot, spider and such.

Here is the Perl script I use to update facebook status:

#!/usr/bin/perl

use WWW::Mechanize;

$mech = WWW::Mechanize->new;
$mech->agent_alias('Windows Mozilla');

$base_url = 'http://m.facebook.com';

# {{{ login
$mech->get($base_url);
$response = $mech->submit_form(
  fields => {
    email => 'your_email_address',
    pass => 'facebook_password'
  }
);
die $response->status_line unless $response->status_line;
# }}}
 
while (1) {
  print "What's on your mind? : ";
  $status = <STDIN>;
  $response = $mech->submit_form(
    fields => {
      status => $status
    }
  );
  die $response->status_line unless $response->status_line;
}

Here is what you will see when you run it:

unsigned_nerd@linuxsucks ~ % fbset
What's on your mind? : it's easier to update facebook status from command line

By the way, isn't it better if I use some Facebook API instead...?  Umm... maybe later.

Friday, September 10, 2010

how to set up crypted partition under Ubuntu 8.04 or Debian stable (5.0)

Install cryptsetup:

# apt-get install cryptsetup

Load 2 modules:

# modprobe dm-crypt 
# modprobe dm-mod

Use luks to format partition and map it to a device:

# luksformat -t ext3 /dev/sdb1
# cryptsetup luksOpen /dev/sdb1 crypteddisk


crypteddisk is a user defined name.  You can name it whatever you want.  It will be found under /dev/mapper.

I put this line in /etc/crypttab:

crypteddisk /dev/md0 none luks,noauto

I also put this line in /etc/fstab:

/dev/mapper/crypteddisk /data ext3 defaults,noauto 0 0 

Make sure you have /data/ directory and maybe prevent it to be used before being mounted by chattr +i /data.

Now you can mount your new encrypted partition by:

cryptdisk_start crypteddisk
mount /data


Note that I config fstab and crypttab in such a way that it won't automatically mount the encrypted partition at boot time.  You know why?  Thinking about when the machine you are working on is a server located in some data centre (no need to be so far away from your house).  If you set it to be auto mount, it will ask you to enter the LUKS passphrase at boot time which means you won't be able to ssh to the machine as it will just wait there forever until you enter the password lol

vimdiff - useful configuration

Say you want vimdiff to open in horizontal mode and also wrap long lines, you just put the below code into your .vimrc:

" for vimdiff
set diffopt+=horizontal
au FilterWritePre * if &diff | exe 'windo set wrap' | endif
" [end] for vimdiff