Skip to content

Instantly share code, notes, and snippets.

View codeasashu's full-sized avatar
🌊
Waiting to sail

ashutosh chaudhary codeasashu

🌊
Waiting to sail
View GitHub Profile

Start your application in uwsgi

Create a file wsgi.py and write your bootstrap script like this:

from app import applicationn

if __name__ == "__main__":
  application.run()
@codeasashu
codeasashu / git-cheatsheet.md
Last active October 18, 2019 17:01
Git cheatsheet
@codeasashu
codeasashu / greps.txt
Created April 8, 2019 08:23
Some better Regexes
1. Extract all (PHP) requests from apache access.log:
grep -Eo '"POST /[a-zA-Z0-9_ ]+/[a-zA-Z0-9_]+.php HTTP/1.1"' access.log
2. find all urls in a folder across all files:
grep -rnEo "(http|https)://[a-zA-Z0-9./?=_-]*" folder/
3. SED delete range of lines in a huge text files:
sed -i '21,141d' file
  1. Toggle hidden files I

  2. Create new file at given directory cursor: ma

@codeasashu
codeasashu / default.conf
Created March 21, 2019 20:30
nginx json logging
#log_format custom '$request_body';
log_format custom '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" "$request_body"';
log_format json_combined escape=json
'{'
'"time_local":"$time_local",'
'"remote_addr":"$remote_addr",'
'"remote_user":"$remote_user",'
@codeasashu
codeasashu / getes.sh
Last active March 8, 2019 14:03
Get Elasticsearch Data
#!/bin/sh
##Useage: ./getes.sh
## To dry run query: ./getes.sh -v -x POST -d '{a:b}' http://elasticurl
## To actually run query: ./getes.sh -x POST -d '{a:b}' http://elasticurl
## Default action is search, so you can omitt -x GET switch
METHOD="GET"
DATA="{}"
DRYRUN=0
@codeasashu
codeasashu / entrypoint.sh
Created February 5, 2019 09:20
Docker gotchas
#!/bin/bash
## Below script allows to fetch private github/gitlab repo
## Assume, $PRIVATE_SSH =
## -----BEGIN OPENSSH PRIVATE KEY-----
## b3BlbnNzaC1rZXktdjEAAAAABG5.....
cat > /root/.ssh/id_rsa <<EOF
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5.....
@codeasashu
codeasashu / Dockerfile
Created January 20, 2019 20:41
Steps to launch a consul server deamon
FROM python:3
EXPOSE 8000
CMD ["python", "-m", "http.server"]
@codeasashu
codeasashu / entrypoint.sh
Created January 9, 2019 10:06
Restrict docker container access from internet except for few allowed ips
#
# iptables configuration
#
# The following allows in- and outbound traffic
# within a certain `CIDR` (default: `192.168.0.0/24`),
# but blocks all other network traffic.
#
ALLOWED_CIDR1=172.0.0.0/16
ALLOWED_CIDR2=13.233.249.192
@codeasashu
codeasashu / docker-compose.yaml
Created December 18, 2018 08:48
Yaml learning center
version: '3'
services:
consul-agent-1: &consul-agent
image: consul:latest
networks:
- consul-demo
command: "agent -retry-join consul-server-bootstrap -client 0.0.0.0"