This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |