Skip to content

Instantly share code, notes, and snippets.

View makeittotop's full-sized avatar

abhishek pareek makeittotop

  • Canada
  • 23:50 (UTC -07:00)
View GitHub Profile
@makeittotop
makeittotop / couch_db_rest_api
Created March 26, 2015 13:51
couch db rest api
curl -XGET 'http://localhost:5984/employee/_design/view_name/_view/_by_name?startkey=%22abhishek%22&endkey=%22foo%22' -v
curl -XGET 'http://localhost:5984/employee/_design/view_name/_view/_by_name?startkey=%22abhishek%22&endkey=%22foo%22&limit=5' -v
curl -XPOST 'http://localhost:5984/employee/_design/view_name/_view/_by_name' -v -H 'Content-Type: application/json' --data '{"keys":["abhishek", "foo", "dfdgfdf"]}'
curl -XPOST 'http://localhost:5984/employee/_design/view_name/_view/_by_name' -v -H 'Content-Type: application/json' --data '{"keys":["abhishek", "foo"]}'
curl -XGET 'http://localhost:5984/employee/_design/view_name/_view/_by_name?key=%22abhishek%22'
@makeittotop
makeittotop / clear_local_storage_chrome.gist
Created March 29, 2015 07:08
A how-to on cleaning up local storage data in chrome browser
# To clear local storage for a particular website in chrome web dev console
localStorage.clear()
# or rm them from the home dir manually
unix> ls ~/.config/google-chrome/Default/Local\ Storage/*au* | xargs -I file rm -rfv 'file'
# or drop the `ItemTable` table from the `main` database in the .localstorage file
unix> sqlite3 /home/abhishek/.config/google-chrome/Default/Local\ Storage/http_www.****_0.localstorage
SQLite version 3.6.20
Enter ".help" for instructions
@makeittotop
makeittotop / install mod_fcgid.sh
Created March 29, 2015 07:41
Install mod_fcgid on centos 6.x
#mod_fcgid is a high performance alternative to mod_cgi or mod_cgid, which starts sufficient instances of the CGI program to handle #concurrent requests
# Install EPEL repo
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# OR
yum install wget &&
wget dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm &&
rpm -ivh epel-release-6-8.noarch.rpm
@makeittotop
makeittotop / compare_md5_files.sh
Last active August 29, 2015 14:17
Basic md5sum comparison to determine if 2 given files are identical
md5sum ./TACTIC-4.3.0.v01/src/install/postgresql/pg_hba.conf /var/lib/pgsql/9.4/data/pg_hba.conf | awk '{ print $1; }' |
for arg in `xargs`;
do
if [ -z $first_arg ];
then first_arg=$arg;
else
if [ "$first_arg" == "$arg" ];
then echo "files match";
else
echo "files don't match";
@makeittotop
makeittotop / oom-killer-explanation.gist
Last active November 18, 2025 07:09
Excellent discussion on OOM-Killer
Out of Memory (OOM) refers to a computing state where all available memory, including swap space, has been allocated.
Normally this will cause the system to panic and stop functioning as expected.
There is a switch that controls OOM behavior in /proc/sys/vm/panic_on_oom.
When set to 1 the kernel will panic on OOM.
A setting of 0 instructs the kernel to call a function named oom_killer on an OOM.
Usually, oom_killer can kill rogue processes and the system will survive.
The easiest way to change this is to echo the new value to /proc/sys/vm/panic_on_oom.
# cat /proc/sys/vm/panic_on_oom 1
@makeittotop
makeittotop / django_create_user.gist
Last active July 24, 2026 17:57
Create / remove user / superuser in a django app
>>> from django.contrib.auth.models import User
# Create a regular user 'foo'
>>> user = User.objects.create_user('foo', 'foo.bar@xxx.com', 'bar')
# List all users
>>> User.objects.all()
[<User: admin>, <User: abegail>, <User: foo>]
>>> User.objects.all()[1].is_superuser
@makeittotop
makeittotop / http_request_response_header_sample.gist
Created March 30, 2015 13:07
Http request response header sample from chrome webRequest API. Notice the identical requestId suggesting the request and response headers are related.
# Notice the identical requestId suggesting the request and response headers are related.
chrome_dev_console>> request_objs[46]
Object {frameId: 0, method: "POST", parentFrameId: -1, requestBody: Object, requestId: "728099"…}
frameId: 0
method: "POST"
parentFrameId: -1
requestBody: Object
requestId: "728099"
@makeittotop
makeittotop / ansible_basic_comands.gist
Last active August 29, 2015 14:18
Basic Ansible workflow
[root@RenderV-1-8 ~]# ll ~/hosts
-rw-r--r-- 1 root root 36 Mar 30 23:28 /root/hosts
[root@RenderV-1-8 ~]# cat ~/hosts
[prod]
# Cool way to interface with multiple hosts
10.50.18.[1:254]
[prod:vars]
ansible_ssh_user=root
@makeittotop
makeittotop / inspect.py
Created March 31, 2015 09:53
Python inspect module usage
import inspect
import psutil
# List the source code of classes defined in a module
for _, type in inspect.getmembers(psutil, inspect.isclass):
try:
print inspect.getsource(type)
except :
print "Error with ", type
@makeittotop
makeittotop / nginx_ports.py
Created April 1, 2015 08:06
Check if a local nginx instance is running and listening to specific ports.
import psutil
def is_nginx_running_on_ports(process_name="nginx", ports=(80, 443)):
"""
Check if a local nginx instance is running and listening to specific ports.
"""
nginx_ports = list(ports)
# Iterate over all system processes (ps)