edwin Posts

Create A Docker for Running Apache and PHP

Below is the script for creating a docker which contain Apache and PHP,

docker run --rm \
--detach \
--name=web_01 \
--net mynet \
--ip 192.168.0.29 \
--publish 10209:80 \
--volume="$PWD"/apps:/app \
--volume="$PWD"/logs:/app/application/logs \
--workdir=/app \
-e PHP_DATE_TIMEZONE='Asia/Jakarta' \
-e LOG_STDOUT='/logs' \
-e LOG_STDERR='/logs' \
webdevops/php-apache:alpine
Google+

A Simple Thousand Separator using Java

Trying to create a quick and simple solution for formatting an Integer into a formatted string with thousand separator,

	class Main
	{
		public static void main (String[] args) throws java.lang.Exception
		{
			String s = (String.format("%,d", 10000000)).replace(",",".");
			System.out.println(s);
		}
	}

The output will be, 10.000.000. (H)

Google+

Simulating Slow Response on Mule ESB

Below is the code im using for simulating a 2minutes reply using MuleESB.

		<expression-component doc:name="Expression"><![CDATA[
			Thread.sleep(120000);
		]]></expression-component>

Thank you

Google+

Changing Couchbase Data Directory Location

Usually Couchbase put its data on default location (/opt/couchbase/var/lib/couchbase/data). But because my disk’s space is full, i have to move Couchbase data to other location. In my case, /data folder which is mounted to an empty 100GB SSD disk. Below is how i change it,

First, i have to change the content of below file,

vi /opt/couchbase/etc/couchdb/default.d/capi.ini 

Changing database_dir and view_index_dir on below Couchbase configuration file, to my new location folder

[couchdb]
max_dbs_open = 10000
database_dir = /data
view_index_dir = /data

[httpd]
db_frontend = capi_frontend
ip4_bind_address = 0.0.0.0
ip6_bind_address = ::
port = 8092

Next is move the content of old folder (/opt/couchbase/var/lib/couchbase/data), to our new folder (/data). And restart our Couchbase service to implement our changes.

  sudo service couchbase-server stop
  sudo service couchbase-server start

We can see the result on our Couchbase web console, hopefully it helps (H)

ps. My Couchbase version is “Enterprise Edition 6.0.0 build 1693”.

Google+

[Python] Fixing Fatal Error when Installing Mysqlclient with Pip

On my current project, im using Python, Django and Pip. But there is some issue when installing libraries needed for running the app,

pip install -r requirements.txt

Below is the error generated when running it,

_mysql.c:29:10: fatal error: 'my_config.h' file not found
   #include "my_config.h"
            ^~~~~~~~~~~~~
   1 error generated.
   error: command 'clang' failed with exit status 1
----------------------------------------
 Rolling back uninstall of mysqlclient

Looks like error happen when trying to install below library,

mysqlclient==1.3.7

Below is Python and Pip version that im using,

 
$ python --version
Python 3.4.3
$ pip -V
pip 18.1 from /Users/m/.pyenv/versions/3.4.3/envs/logistic_backend/lib/python3.4/site-packages/pip (python 3.4)

The main culprit is corresponding library is not supported by Python 3.4.3, changing it into below lib fix the error

pymysql==0.9.2
Google+