Skip to content

Instantly share code, notes, and snippets.

View psujit775's full-sized avatar
:octocat:
Learning is in progress

Sujit Patel psujit775

:octocat:
Learning is in progress
View GitHub Profile
@psujit775
psujit775 / docker-compose.yaml
Last active August 7, 2023 08:14
thanos docker compose with s3 storage
version: '3.3'
services:
thanos_sidecar:
container_name: thanos_sidecar
image: quay.io/thanos/thanos:v0.28.0
volumes:
- './data/prometheus:/data/prometheus/data' #prometheus data dir
command:
- 'sidecar'
- '--prometheus.url=http://prometheus_ip:port'
@psujit775
psujit775 / swaks-aws-ses.md
Last active March 22, 2023 16:19
Steps to test AWS SES service using swaks

Using swaks standalne script

swaks git: https://github.com/jetmore/swaks

step 1 (download script)

curl https://jetmore.org/john/code/swaks/files/swaks-20201014.0/swaks -o swaks.sh

step2 (grant execute permissions)

chmod +x swaks.sh

@psujit775
psujit775 / check-permission.sh
Created October 18, 2022 16:54
check user permissions on file or directory
#!/bin/bash
echo -n "Enter File or DIR name to check permissions : "
read user_input # Read from user input
#check if input is directory or file
if [[ -d $user_input ]]; then #if input is dir then recursively list all sub-dir and files.
declare -a list_all_files=( $(find $user_input -d) ) #storing result in a array
for x in ${list_all_files[@]}
do
@psujit775
psujit775 / xstartup
Created October 17, 2022 11:08
vnc xstartup file
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
@psujit775
psujit775 / log-insight-query.txt
Last active June 20, 2023 13:37
log-insight-query-for-mysql-and-postgresql
# For MySql
fields @timestamp, @message
| filter @message like /Query_time/
| parse @message /User@Host:\s*(?<user>[^;]*)\s*Query_time:\s*(?<Query_time_in_sec>[0-9]+(?:\.[0-9]+)?)\s*Lock_time:\s*(?<Lock_time_in_sec>[0-9]+(?:\.[0-9]+)?)[\s\S]*?;\s*(?<Query>[^;]*)/
| display @timestamp, user, Query_time_in_sec, Lock_time_in_sec, Query
| sort Query_time_in_sec desc
| limit 100
@psujit775
psujit775 / docker-compose.yml
Created August 10, 2022 12:54
docker compose file for wordpress with mysql
version: "3.9"
services:
wordpress:
image: wordpress:6.0.1-apache
restart: always
container_name: wordpress_v6.0.1
working_dir: /var/www/html
depends_on:
- mysql
environment:
@psujit775
psujit775 / restore-mysql.sh
Last active June 17, 2022 08:41
restore sql file in mysql
USER="root"
PASSWORD_FILE="/root/.local.cnf"
HOST="localhost"
echo "Restoring Databases...."
COUNTER=1
TOTAL_FILES=$(ls *.sql|wc -l)
for SQL in *.sql
do
@psujit775
psujit775 / backup-schema.sh
Last active June 17, 2022 07:39
take schema dump of mysql
#!/bin/bash
HOST="some-database.rds.amazonaws.com"
USER="admin"
PASSWORD_FILE="/root/.rds.cnf"
OUTPUT="/data/schema"
databases=`mysql --defaults-extra-file=$PASSWORD_FILE -u $USER -h $HOST -NBe "select group_concat(schema_name separator ' ') from information_schema.schemata where schema_name not in ('sys','mysql', 'information_schema', 'performance_schema')"`
# GET Total number of databases.
@psujit775
psujit775 / mqtt.conf
Created April 7, 2022 18:07
nginx conf for mqtt websocket
upstream websocket {
server localhost:9001;
}
server {
server_name mqtt.sujitpatel.in; #change accordingly
location / {
proxy_pass http://websocket;
@psujit775
psujit775 / mosquitto.conf
Created April 7, 2022 17:54
mosquitto.conf fro mqtt websocket
#web socket
listener 9001
protocol websockets
pid_file /var/run/mosquitto.pid
user ubuntu
persistence true
persistence_location /var/lib/mosquitto/
max_connections -1