Skip to content

Instantly share code, notes, and snippets.

View mdemblani's full-sized avatar

Manish Demblani mdemblani

View GitHub Profile
@mdemblani
mdemblani / amazon-cloudwatch-agent.log
Last active September 18, 2022 18:08
Cloudwatch Agent Configuration Snippets
2020-05-06T10:17:35Z I! will use file based credentials provider
2020-05-06T10:17:35Z I! cloudwatch: publish with ForceFlushInterval: 1m0s, Publish Jitter: 37s
2020-05-06T10:17:35Z I! Starting AmazonCloudWatchAgent (version 1.237768.0)
2020-05-06T10:17:35Z I! Loaded outputs: cloudwatch cloudwatchlogs
2020-05-06T10:17:35Z I! Loaded inputs: tail cpu diskio processes statsd swap disk mem netstat socket_listener
2020-05-06T10:17:35Z I! Tags enabled: host=ip-X-X-X-X
2020-05-06T10:17:35Z I! Agent Config: Interval:1m0s, Quiet:false, Hostname:"ip-X-X-X-X", Flush Interval:1s
2020-05-06T10:17:35Z I! Started the statsd service on :8125
2020-05-06T10:17:35Z I! Statsd listener listening on: [::]:8125
2020-05-06T10:17:35Z I! will use file based credentials provider
@mdemblani
mdemblani / docker-not-detecting-shutdown-signal.md
Last active August 8, 2018 06:54
Solution for Dockerfile, if image doesnot shutdown on CTRL(CMD)+C

In-case if you run a Docker image and after that you try to kill it, the kill signal is not detected by the Docker container process and in that scenario you have to resort to restarting your Docker process. This is because, the Docker image on which the container is built upon, doesnot detect the Kill Signal i.e. doesnot register any listeners for the kill signal and in this process the signal gets lost whenever fired. Considering on of the most popular Docker Library: mysql also has the same issue.

Issue: Container does not catch signals and exit "Ctrl+C"

In that case you can use the following solution:

  1. Create a file docker-shutdown-patch.sh in the same directory as your Dockerfile
  2. In the Dockerfile, change the EntryPoint and CMD defaults of the image as in the sample Dockerfile.
  3. Build the image and start the container
@mdemblani
mdemblani / Mysql Character Set conversion - Latin1 to UTF-8(utf8mb4).md
Last active June 20, 2023 08:03
Mysql Character Set conversion - Latin1 to UTF-8(utf8mb4)
  1. Make sure mysql-client is installed. If not, then :
    sudo apt install mysql-client
	or
    sudo apt-get install mysql-client
  1. Open php.ini

; PHP's default character set is set to UTF-8.

@mdemblani
mdemblani / CountryDetails.json
Created March 4, 2016 08:37
Json data of all the cuntries with theri calling codes, iso-code, gdp, population
[
{
"country": "Afghanistan",
"country_code": 93,
"iso_codes": "AF / AFG",
"population": 29121286,
"area": 647500,
"gdp": "20.65 Billion"
},
{
@mdemblani
mdemblani / CakePhp Rest Route with api prefi steps.md
Last active May 28, 2018 20:59
CakePhp Rest Route with api prefix. A small hack in cakephp v2.X Lib to support restful routes with api prefix

I had my api ready and faced the problem of converting them into rest routes with api and version prefixs using the cakephp Router::mapResources function that was provided by default by CakePhp,

My api was intially,
http://www.xyz.com/controller/
supporting basic rest routes and I wanted it to be in the form
http://www.xyz.com/api/version_number/controller/action
that would support basic rest routes with prefix including api and version number.

To achieve this there are two ways:

  1. Create routes using Router::connect for each function and list them down manually in your routes.php file.