Skip to content

Instantly share code, notes, and snippets.

View bikalbasnet's full-sized avatar
🎯
Focusing

Bikal Basnet bikalbasnet

🎯
Focusing
View GitHub Profile
@bikalbasnet
bikalbasnet / allowed-childprocess-php-fpm-nginx
Created March 27, 2022 09:39
Determining correct number of child process for php-fpm on nginx
1. Find if you do not have enough processes available for php-fpm
Search for php-fpm.log to find following kinds of errors suggesting you need to increase `pm.max_children` value
```
WARNING: [pool www] server reached pm.max_children setting (35), consider raising it
```
2. Find average memory usage per php process
List php fpm process by RSS. RSS (Resident Set Size) is the portion of memory occupied by a process that is held in RAM
```
ps -ylC php-fpm --sort:rss
@bikalbasnet
bikalbasnet / mitmproxy
Created April 9, 2021 10:26
mitmproxy
sudo apt install mitmproxy
mitmweb -p 6666
# Get the ip
ip r
# Phone advanced options
# Setup manual proxy to the ip of laptop and port in advanced options of wifi
@bikalbasnet
bikalbasnet / useful-linux-commands
Last active April 26, 2022 09:22
Useful linux commands that I often end up googling
## View all disk partition
fdisk -l
## Displays information about block device
blkid
## Lists info about all block devices
lsblk
## Displays amount of disk space available on the file system
alias vscode:update="wget https://vscode-update.azurewebsites.net/latest/linux-deb-x64/stable -O /tmp/code_latest_amd64.deb && sudo dpkg -i /tmp/code_latest_amd64.deb"
@bikalbasnet
bikalbasnet / run-php-mysql-from-docker
Last active April 18, 2022 07:10
This Gist allows you to run php applications and database without installing anything on your machine except docker
# Need to run composer install for a repo does not have docker? Use this
docker run --rm -v $(pwd):/app webdevops/php:8.0 bash -c "cd /app && composer install"
# Create Network
docker network create some-network
# Run the PHP Project
docker run --rm --name some-app -e 'WEBROOT=/var/www/html/public/' -e 'PHP_CATCHALL=1' -e "PUID=`id -u $USER`" -e "PGID=`id -g $USER`" -v $(pwd):/var/www/html/ -p 8000:80 --net=some-network richarvey/nginx-php-fpm:latest
@bikalbasnet
bikalbasnet / beanstalk-purge
Created January 23, 2020 05:35
Code to delete data from tube (uses loop)
#!/usr/bin/expect -f
# Filename: beanstalk-purge
set timeout 1
spawn telnet [lindex $argv 0] [lindex $argv 1]
sleep 1
send "use [lindex $argv 2]\n"
expect "USING"
for {set i 1} {$i < [lindex $argv 3]} { incr i 1 } {
@bikalbasnet
bikalbasnet / gist:db38e7fd0ea068b459e970e3587e23a3
Last active March 30, 2019 15:50
c608e17292ef41ba87ac57995a10c3c3
rm -rf abc.txt
@bikalbasnet
bikalbasnet / common-codes.txt
Last active January 14, 2019 16:04
Common commands that I use (Chetsheet)
Setting The PATH on linux
export PATH="$PATH:/path/to/dir"
Symlink to Binaries
sudo ln -s /path/to/binary /usr/bin/binary-name
### Export MYSQL database
> mysqldump -u [username] -p [database name] > [database name].sql
### Import MYSQL database
@bikalbasnet
bikalbasnet / new ubuntu setup
Last active November 19, 2018 06:45
codes that I run to setup my new ubuntu laptop
sudo apt-get install -y curl git zsh vim &&\
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb &&\
sudo dpkg -i google-chrome-stable_current_amd64.deb &&\
rm google-chrome-stable_current_amd64.deb
sudo apt-get install terminator &&\
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" &&\
wget https://github.com/powerline/powerline/raw/develop/font/PowerlineSymbols.otf &&\
wget https://github.com/powerline/powerline/raw/develop/font/10-powerline-symbols.conf &&\
#!/bin/bash
for i in $(curl "https://api.github.com/orgs/[ORGANIZATION]/repos?access_token=[TOKEN]&per_page=200" | sed '/[ ]*"ssh_url":/!d;s/[^:]*: "//;s/",$//'); do
git clone $i
done