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 / 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
@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 / 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 / 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 / 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 / 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 / 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 / Dockerfile
Last active May 15, 2023 08:12
php7.3-alpine-composer (Dockerfile)
# Set master image
FROM php:7.3-fpm-alpine
MAINTAINER Rajesh Chaudhary <rajeshisnepali@gmail.com>
# Copy composer.lock and composer.json
#COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
@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 / Envoy.blade.php
Created June 12, 2019 08:12
Zero Downtime deploy project to server (production)
@servers(['production' => 'ubuntu@X.X.X.X'])
@setup
$repo = 'git@gitlab.com:<username>/<project-name>.git';
date_default_timezone_set('Asia/Kathmandu');
$release = date('YmdHis');
$releases_dir = '/var/www/html/final/releases';
$app_dir = '/var/www/html/final';
$new_release_dir = $releases_dir .'/'. $release;