Showing posts from October, 2017

Check rabbitmq user's credential

This is pretty helpful when you want to check if the user's password of rabbitmq is correct:

$ curl -i -u <theuser>:<thepassword> http://<rabitmq-host>:15672/api/whoami

Change rabbitmq user password

Run this command

# rabbitmqctl change_password theuser thenewpassword

Pulling all images from a private docker registry

I couldn't find any command that help pulling all the docker images from a private registry so I wrote it myself:

Modify the script with your information and run:

$ bash

How to delete a port with fixed IP address on an OpenStack Pike instance (deployed by Kolla-Ansible)

You cannot delete a network from the dashboard interface if it's attached to a port with fixed IP address on OpenStack (I'm running Pike). So what you have to do is to delete the port directly from the database:

1. Go to the mariadb docker instance:

$ docker exec -it <id or name of the nova docker instance> /bin/bash

2. Login to mariadb console using the password in /etc/kolla/passwords.yml

$ mysql -u root -p

3. Run these commands to delete the port (you may need to delete all of its relationship, for example from sfc_flow_classifiers table first)

use neutron;
select id from sfc_flow_classifiers; # get the id of the classifier that linked to the port
delete from sfc_flow_classifiers where id='<the id you get from the previous command>';
delete from ports where id='<the port id you get from the dashboard>';

4. Then you can delete the network.

Openstack Pike (deployed by Kolla-Ansible) can not delete instance from dashboard and how to fix

I's trying to delete an compute instance in an OpenStack environment deployed using Kolla-Ansible from the dashboard but helpless. The instance kept saying error... Then I have to do this workaround to delete it: directly from the database (MariaDB)

1. First login to the bash shell of the nova-compute instance:

$ docker exec -it <id or name of the nova docker instance> /bin/bash

2. Go to mariadb console using the password generated when I ran kolla-ansible (/etc/kolla/passwords.yml):

$ mysql -u root -p

3. Run these command to delete the instance:

user nova;

update instances set deleted_at = updated_at,  deleted = id,  power_state = 0,  vm_state = "deleted",  terminated_at = updated_at,  root_device_name = NULL,  task_state = NULL  where  deleted = 0;

update instance_info_caches set deleted_at = updated_at, deleted = id where deleted = 0;

Checking to see if one array's elements are in another array in PHP

So you have 2 arrays:

$a = array("a", "b", "c", "d");
$b = array("x", "y", "z", "b", "o");

And you want to check if one of the array a's item are in the b array, here is how:

if( !empty(array_intersect($a, $b))) {
      echo "Gotcha!";

How to list all the images on a Docker Registry

Pretty easy:

* Normally with a insecure private Docker Registry you would do:

curl http://<the domain>:<the port if not 80, usually it's 5000>/v2/_catalog

* In a secure private Docker Registry:

curl https://<user_name>:<password>@<the domain>/v2/_catalog

The result will be something like:


Calculate the date difference between 2 dates in PHP

You can use the diff method  to calculate the dates difference between two DateTime object, for example:
$date1 = DateTime::createFromFormat('d-m-Y', '05-09-2017'); $now = new DateTime("now"); $diff = $now->diff($date1); echo "Date difference: " . $diff->format('%a') ;
The result will be:
Date difference: 30

To use WordPress's wp_delete_user function in your theme or plugin

Just add this line before calling wp_delete_user function:


How to fix "Uncaught TypeError: $(…).owlCarousel is not a function" err

Ok, jQuery included, Owl Carousel included, checked checked checked, still doesn't work. The error kept showing up:

Uncaught TypeError: $(…).owlCarousel is not a function

What the hell is going on?

Then I realized that the jQuery library was included twice by some of the plugins. So I'm using this following technique to get rid of the error:

(function($) {
}) (jQuery);