Skip to content

Instantly share code, notes, and snippets.

View subhajeet2107's full-sized avatar

Subhajeet Dey subhajeet2107

  • India
View GitHub Profile
@subhajeet2107
subhajeet2107 / Vagrantfile
Created October 8, 2018 15:10
vagrant file with docker installed for Rancher
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@subhajeet2107
subhajeet2107 / gist:369bea339277e14e861e978e68d88ccc
Last active October 11, 2018 09:25
Nginx Pagespeed Settings and compilation
--with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --wit
@subhajeet2107
subhajeet2107 / rancher.sh
Created October 14, 2018 07:20
Rancher Custom Master
sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:latest
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------
@subhajeet2107
subhajeet2107 / commands.sh
Created April 7, 2019 07:53
How to connect docker mysql with docker sqlpad or phpmyadmin
mysql -u root -p --protocol=tcp -P 3309 #from this you can connect to docker container from host
docker run --name=testsql -p 3309:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
docker run --name myadmin -d --link testsql:db -p 8080:80 phpmyadmin/phpmyadmin
docker run --name sqlpadman -d --link testsql:db -p 3000:3000 sqlpad/sqlpad
@subhajeet2107
subhajeet2107 / download_images.py
Created May 4, 2019 14:22
Download images and stores in nested folders
#Download images
from pathlib import Path
import shutil, os, requests
urls = []
for url in urls:
r = requests.get(url, stream=True)
image_path = url.replace('https://www.somedomain.com/images/','')
path = Path('/assets/images/' + image_path)
path.parent.mkdir(parents=True, exist_ok=True)
@subhajeet2107
subhajeet2107 / mysqlimport.sh
Created July 17, 2019 10:59
Import CSV in mysql faster
mysqlimport --ignore-lines=1 \
--fields-terminated-by=, \
--local -u root \
-p Database \
institute_courses_complete.csv
@subhajeet2107
subhajeet2107 / clickhousedump
Created October 9, 2019 09:15
Dump Databases from clichouse
#!/bin/bash
OUTDIR=.
while read -r db ; do
while read -r table ; do
if [ "$db" == "system" ]; then
echo "skip system db"
continue 2;
@subhajeet2107
subhajeet2107 / Geo Chart
Created March 20, 2020 07:01
Geo Codes for India Geo Chart
India State Codes for Geo:
var data = google.visualization.arrayToDataTable([
['State Code', 'State', 'Result'],
['IN-AN','Andaman and Nicobar Islands',9],
['IN-AP','Andhra Pradesh',13],
['IN-AR','Arunachal Pradesh',34],
['IN-AS','Assam',13],
['IN-BR','Bihar',34],
['IN-CH','Chandigarh',15],
Install existing with pagespeed, brotli and other: bash <(wget -O - vtb.cx/nginx-ee || curl -sL vtb.cx/nginx-ee) --full --pagespeed --naxsi