Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

Rajesh Chaudhary rajeshisnepali

:octocat:
Focusing
View GitHub Profile
@rajeshisnepali
rajeshisnepali / laravel_permission.sh
Created Sep 15, 2020
Set webserver permission for laravel project
View laravel_permission.sh
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 Apr 22, 2020
Download youtube video/audio from CLI
View yt-download.sh
#!/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 Apr 19, 2020
toggle bluetooth connection (on/off) & connect devices (connect/disconnect) in an easy way
View bt-toggle.sh
#!/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 Mar 22, 2020
Redirect subdomain home page to another url of same subdomain
View subdomain-redirect.conf
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 Mar 3, 2020
serve pages from directory according to subdomain name
View subdomain.conf
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 Jan 28, 2020
modify /etc/hosts [docker container networks]
View manage-etc-hosts.sh
#!/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 Sep 10, 2021
php7.3-alpine-composer (Dockerfile)
View 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 Jul 23, 2020
Redirect URL to https:// with non-www.
View website.conf
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 Jun 12, 2019
Zero Downtime deploy project to server (production)
View Envoy.blade.php
@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;
@rajeshisnepali
rajeshisnepali / setup-project.sh
Last active Dec 28, 2019
setup a project (laravel or any php) making serverblock (nginx) after cloning from git.
View setup-project.sh
#!/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