When restarting Windows 7 and it stuck at the black screen

When restarting Windows 7 and it stuck at the black screen with the cursor blinking, the first thing is insert the Windows 7 DVD and fix the Mbr. Main reason is because it is the OEM disc and not the Retail disc was used during the installation.

1. Put the Windows 7 installation disc in the disc drive, and then start your computer.

2. Hold down Option key till all available disks are displayed and select DVD. Press a key when you are prompted.

3. Select a language, a time, a currency, a keyboard or an input method, and then 4. click Next.

5. Click Repair your computer.

6. Click the operating system that you want to repair, and then click Next.

7.In the System Recovery Options dialog box, click Command Prompt.


Type (these commands are safe)

Code: Bootrec.exe /FixMbr

Code: Bootrec.exe /FixBoot

Code: Bootrec.exe /RebuildBcd

*Press ENTER after each command.*

*Restart your computer.*


PostgreSQL error “duplicate key violates unique constraint”

When insert data into PostgreSQL and getting the error of “ERROR: duplicate key violates unique constraint”. That means the primary key has out of sync. 

Need to check the database

SELECT MAX(the_primary_key) FROM the_table;
SELECT nextval(‘the_primary_key_sequence’);

if both working fine, then use this query

SELECT setval(‘the_primary_key_sequence’, (SELECT MAX(the_primary_key) FROM the_table)+1);


My case:

SELECT setval(‘users_id_seq’::regclass, (SELECT MAX(id) FROM users)+1);

WordPress Asking for FTP credentials

I notice when I upgrade one of my blog doesn’t require any FTP credentials but another requires. To avoid this, is to set the directory to the same user as the hosting daemon service running. For example mine was www-data.

So just need to ensure it is running correctly by 

$sudo chown -R www-data:ubuntu blog

Install Nginx source on Ubuntu

I want to get FancyIndex install on my nginx but without removing my original nginx settings. So first follow the instruction here http://wiki.nginx.org/NgxFancyIndex 

Some of additional libraries and files required for compiling nginx
$sudo apt-get install build-essential libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

During ./configure adding in 

$./configure --add-module=../ngx-fancyindex --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module

then follow by

$sudo make install

I overcome an issue when running nginx because a folder /var/cache/nginx/client_temp is required for the cache. So created it then shouldn’t have any issue.

umount: device is busy.

When umount a device, which process is causing “device busy”?

The suggested method is using lsof and fuser

Here is an example:

lsof | grep <device or directory name>


fuser -m <device or directory name> to check out the process id.

Mac App Store Weird App appears

I’m getting updates for Twitter app on app store updates, but the thing is I didn’t install Twitter app at all.

So checking Mac with proper App Store registry by typing:

mdfind kMDItemAppStoreHasReceipt=1

in terminal. Then, cross check the list of applications with the one appear on App Store Purchase. You might find the one that is pirated.