Dec 5, 2018

Configuring docker data directory

The data directory is where docker saves images, containers and some other stuffs. Sometimes its beneficial to configure the data directory outside of the default location. For example, when you wa...

Nov 26, 2018

Console output from AWS instance in CLI

AWS CLI can be used to retrieve the console output from an EC2 instance. This can be of great help in debugging and troubleshooting.

aws ec2 get-console-output --instance-id <my-instance-id>
Oct 8, 2018

Docker Cheat Sheet

Containers

docker create IMAGE
Creates a docker container based off of IMAGE, but does not run

docker rename CONTAINER NEW_NAME
Renames a docker container

docker start CONTAINER
Starts a docker container

docker restart CONTAINER
Restarts a docker container

...

Sep 10, 2018

Elastic Search delete by query

Send a POST request to the _delete_by_query endpoint of target index and doctype, make sure the request body has query for matching and deleting the target objects.

POST my_index/my_doc_t...
Aug 1, 2018

Change password of a user in Django

Start by opening the Django shell from your terminal

> python manage.py shell

Then inside the Django shell, first get hold of that user object, then change the password and save.

f...
Nov 28, 2017

Linux date command

The date command is mostly used to get the current date. But there are some underappreciated gems of feature in this command.

Get a date in the past

> date -d "3 days ago"
> date -...
Nov 13, 2017

Copying a file from a different git branch

Sometimes one has to copy a file from one branch to another. The git checkout command comes in handy in this situation. Let's say we need to copy a file named code.py from source-branch to `d...

May 29, 2017

Linux Tree Command

The tree command list contents of directories in a tree-like format. I often use this to document directory structures of my projects. The output of tree is of course, the directory structure drawn in an ASCII art style tree. See example below. A few lines of comment are added to inform team ...

Feb 7, 2017

MySQL table backup for live data manipulation

Sometimes a DB admin has to access a live DB to perform some investigation and/or generate custom reports. It'd be a bad practice to directly manipulate the data on the production tables. A good pr...

Jan 19, 2017

Django HTTP only CSRF cookie

Django sets a CSRF cookie to protect against cross site request forgeries. By default this cookie is set to be accessible to JavaScript on your web page. That means, the cookie will be accessible to a malicious script running on this page, too. ...