Skip to content

Instantly share code, notes, and snippets.

View rajeshisnepali's full-sized avatar
:octocat:
Focused

Rajesh Chaudhary rajeshisnepali

:octocat:
Focused
View GitHub Profile
@rajeshisnepali
rajeshisnepali / make-server-block.sh
Last active December 28, 2019 14:00
This script makes server block including naming of hostname to /etc/hosts [nginx]
#!/bin/bash
# to be able to work this function globally, copy or create link in /usr/local/bin
# --------------------------------------------------------------------
makeServerBlock() {
try_files='try_files $uri $uri/ /index.php?$query_string;'
block="/etc/nginx/sites-available/$domain"
@rajeshisnepali
rajeshisnepali / setup-project.sh
Last active December 28, 2019 14:00
setup a project (laravel or any php) making serverblock (nginx) after cloning from git.
#!/bin/bash
# version 1.2
### changelog: first ask whether it's a laravel project or not.
# to be able to work this function globally, copy or create link in /usr/local/bin with execute permission (chmod +x)
## Process
# 1. cp .env.example .env
# 2. composer install
# 3. php artisan key:generate
@rajeshisnepali
rajeshisnepali / manage-etc-hosts.sh
Created January 28, 2020 17:18
modify /etc/hosts [docker container networks]
#!/usr/bin/env bash
#format = sudo manage-etc-hosts.sh <docker_webserver_container_name> <domain>
set -eu
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
# PATH TO YOUR HOSTS FILE
@rajeshisnepali
rajeshisnepali / subdomain.conf
Created March 3, 2020 14:55
serve pages from directory according to subdomain name
server {
listen 80 ;
#server_name ~^(www\.)?(?<sname>.+?).<ip>.xip.io$;
server_name ~^(?<sname>.+?).<ip>.xip.io$;
root /var/www/html/review.anipat/$sname;
index index.php index.html index.htm index.nginx-debian.html;
@rajeshisnepali
rajeshisnepali / subdomain-redirect.conf
Created March 22, 2020 03:39
Redirect subdomain home page to another url of same subdomain
server {
listen 80;
root /var/www/html/subdomain/web-app/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name app.web-app.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
@rajeshisnepali
rajeshisnepali / bt-toggle.sh
Last active April 19, 2020 06:08
toggle bluetooth connection (on/off) & connect devices (connect/disconnect) in an easy way
#!/bin/bash
# toggle bluetooth connection (on/off) & connect devices (connect/disconnect)
# run "bluetoothctl" to find the MAC address of your device.
# default MAC (Airdots)
MAC="00:00:00:00:00:00"
enable() {
rfkill unblock bluetooth
}
@rajeshisnepali
rajeshisnepali / yt-download.sh
Created April 22, 2020 14:15
Download youtube video/audio from CLI
#!/bin/bash
# download video/audio from youtube for another sites
#### Format for video
#./yt-download.sh 'url' 'specifiy type [video,audio]' 'download_location'
URL=$1
DOWNLOAD_AS=${2:-'video'}
if [[ -z $(command -v youtube-dl) ]]; then
@rajeshisnepali
rajeshisnepali / website.conf
Last active July 23, 2020 13:27
Redirect URL to https:// with non-www.
server {
listen 80;
server_name domain.com www.domain.com;
return 301 https://domain.com$request_uri;
}
server {
listen 443 ssl;
server_name www.domain.com;
return 301 https://domain.com$request_uri;
#ssl_certificate /etc/ssl/sites/domain.com.pem;
@rajeshisnepali
rajeshisnepali / laravel_permission.sh
Created September 15, 2020 02:59
Set webserver permission for laravel project
function laravel_set_permission() {
sudo find . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;
laravel_storage_permission
}
function laravel_storage_permission() {
# storage & bootstrap/cache should be writable by server
sudo chown -R $USER:www-data storage bootstrap/cache
@rajeshisnepali
rajeshisnepali / kubectl_short.txt
Created February 11, 2023 19:52
kubectl resources shortcuts
bindings
componentstatuses cs
configmaps cm
endpoints ep
events ev
limitranges limits
namespaces ns
nodes no
persistentvolumeclaims pvc
persistentvolumes pv