Thursday, August 22, 2019

LDAP - Deleting an LDAP entry

To delete an ldif entry, one way is to put an changetype attribute and a value 'delete' in the ldif file
For example
dn: cn=someone,ou=people,dc=abc,dc=com
changetype: deleteobjectClass: inetOrgPerson

Then, run 
ldapmodify -x -D ldap.ldif -x -D "cn=Manager,ou=roles,dc=abc,dc=com" -w your_password

Sunday, July 28, 2019

Tomcat - Enable remote access to manager page

In Tomcat 9, the manager is only allowed to access from local machine.

Below is mentioned at Tomcat 9 Manager page
By default the Manager is only accessible from a browser running on the same machine as Tomcat. If you wish to modify this restriction, you'll need to edit the Manager's context.xml file.
To enable remote access, you need to replace the original setting


(Tomcat 9)/webapps/manager/META-INF/context.xml

Thursday, June 13, 2019

Disk - Shrink MacBook Pro Harddisk Partition And Add to Windows

If you want to transfer some disk space from MacBook Pro partition to Windows partition, you can try the following

1) In your MacBook Pro, Open "Disk Utility" and click on the Partition button as follows

2) Click on Partition you want to resize. For me, I am resizing the "Macintosh HD" partition from 548GB to 200.6GB.

3) Once done, click on Apply button and the resizing process will begin

4) When the resize process completed, you can restart your laptop into Windows

5) Next, log into your Windows and open "Computer Management"

6) You could use the "Extend Volume" option if available. For me, it was grey out because the unused partition is before the NTFS partition. "Extend Volume" will only available if the partition is immediately after the disk volume which you are trying to extend.

7) Since I am unable to use the "Extended Volume" option, I need a 3rd party partition software. For this, I had selected a freeware - "EaseUs Partition Master Home Edition". Next, launch the application. Select the partition and click "Resize/Move"

8) Adjust the partition to your desire size

9) Once adjusted, click Ok

10) Then, click "Execute 1 Operation". The system will reboot.

11) During rebooted, it will adjust the partition. And the system will reboot once the process complete.

12) Now, there is a high chance that your Windows cannot be reboot because the Windows partition boot sector had been modified and adjusted. You will need to use your Windows installation disc to repair the Master Boot Sector. Once the Master Boot Sector is repaired, you should be able to log into Windows with the extends disk size.

Wednesday, May 8, 2019

Python - Simulating File Lock

Sometime, it is useful to simulate file lock to test file locking logic. I had tried some Linux command, e.g. flock, which does not work really well.

Below is a Python code that work quite well for me

$ python
Python 2.7.13 (default, Apr  5 2018, 19:36:11)
[GCC 4.1.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fcntl;
>>> handle = open("/var/abinitio/", "a");
>>> fcntl.lockf(handle.fileno(), fcntl.LOCK_EX|fcntl.LOCK_NB);
The above will hold the lock of the file. fuser could see it.

One done, exit Python to remove the lock.

>>> exit()

Monday, April 29, 2019

NodeJS - Setting up NodeJS with SSL (Self-Signed Certificate)

Below is a one page guide to setup a NodeJS server with SSL (Self-Sign Certificate)

1) Assuming you have NodeJS installed, write a following NodeJS application (see

For me, I had written it at /tmp/nodejsapp/app_https.js

const https = require('https');
const fs = require('fs');
const options = {
  key: fs.readFileSync('keys/key.pem'),
  cert: fs.readFileSync('keys/certificate.pem')
https.createServer(options, (req, res) => {
  res.end('hello world\n');
Note the key and cert location. That will be the directory relative to your NodeJS application. For me, it will be /tmp/nodejsapp/keys

2) You need to generate a self signed certificate with openssl

openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
Answer the prompt and the above command will generate a key.pem and certificate.pem.

You can verify the certificate with

 openssl x509 -text -noout -in certificate.pem


Then, move the key.pem and certificate.pem to the location referenced by the NodeJS key and cert options. For me, that will be /tmp/nodejsapp/keys

3) Run NodeJS with

node app_https.js

4) Test the HTTPS with

curl -k -vvv https://:8000

or from browser

Tuesday, March 26, 2019

Javascript - How to disable modal site

Javascript is a client side scripting (usually), that means, it evaluation of the code happens at the browser.

Recently, I encountered an website ( which uses modal to block user access. You could simply bypass modal by disabling the relevant javascript section with Chrome Developer Tools

1) Access the website, and you will see a Modal page

2) Launch Chrome Developer Tools

3) At the Elements panel, right click and delete the modal div. Then, unchecked the modal css to enable scrolling.

Wednesday, February 27, 2019

Windows - Reset file association to default

At least in Windows 7, once you had set a file association to an file extension, there is no easy way to reset it to default, which is no association and any program.

I had limited luck with assoc and ftype command. It will worked if it works, but, it failed me more of the time. The only reliable way to reset file association to default is to edit the registry with regedit, the steps are (using .c extension for example)

1. Open regedit
2. Find "HKEY_CLASSES_ROOT\.c" and delete it.
3. Find "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.c" and delete it
4. Restart machine or kill and restart explorer if necessary (usually, you do not need to do this)

LDAP - Deleting an LDAP entry

To delete an ldif entry, one way is to put an changetype attribute and a value 'delete' in the ldif file For example dn: cn=so...