Skip to content

Instantly share code, notes, and snippets.

@prhomhyse
prhomhyse / node-updater.sh
Last active May 12, 2024 23:50
This script updates Node to the latest LTS version using NVM
#!/bin/bash
echo "This script will update Node to the latest version using NVM"
# Fix `nvm: command not found` error on macOS
echo "Sourcing nvm to make it available"
. ~/.nvm/nvm.sh
@prhomhyse
prhomhyse / clear-nginx-cache.sh
Created July 25, 2021 23:25
A simple script to help you clear your Nginx caches when they get above your specific sizes.
#!/bin/bash
LOG="/var/log/cache-clean.log"
#Check if the /run directory size is above 100MB
run_size=`du -sh /run | awk '{print $1}' | grep -Eo '[0-9]{3}'`
if [[ $run_size -gt 100 ]]; then
@prhomhyse
prhomhyse / clear-redis-wpcli.sh
Created July 25, 2021 22:48
Clear Redis cache with a script
#!/bin/bash
# Or create the custom log path
LOG="/var/log/redis-clean.log"
#Check if Redis used memory is above 100MB
used_size=`su -s /bin/bash -c "wp redis info --path=/var/www/htdocs" www-data | grep used_memory | awk '{print $2}' | cut -d'M' -f1 | cut -d "." -f 1`
@prhomhyse
prhomhyse / ee-local-redis-starter.sh
Last active June 29, 2021 20:00
Start Local Redis on EasyEngine when it disappears
#!/bin/bash
## Check for the exact site's Redis container
is_redis_running=`grep -w sitenamecom_redis_1`;
if [[! $is_redis_running ]]; then
ee site refresh sitename.com;
fi
@prhomhyse
prhomhyse / docker-compose.yml
Created April 17, 2020 23:00
docker-compose for installing rocket.chat
version: '2'
services:
rocketchat:
image: rocketchat/rocket.chat:latest
restart: unless-stopped
volumes:
- ./uploads:/app/uploads
environment:
- PORT=3000
@prhomhyse
prhomhyse / mkdocs-build.md
Created September 5, 2019 08:47
The output of MkDocs build script for Netdata documentation on MacOS
netdata
Cloning into 'collectors/go.d.plugin'...
remote: Enumerating objects: 63, done.
remote: Counting objects: 100% (63/63), done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 5127 (delta 15), reused 35 (delta 5), pack-reused 5064
Receiving objects: 100% (5127/5127), 4.80 MiB | 716.00 KiB/s, done.
Resolving deltas: 100% (2876/2876), done.
# BEGIN All In One WP Security
#AIOWPS_BASIC_HTACCESS_RULES_START
<Files .htaccess>
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@prhomhyse
prhomhyse / nginx-tuning.md
Created December 25, 2017 22:24 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@prhomhyse
prhomhyse / nginx.conf
Created December 18, 2017 21:55 — forked from leandromoreira/nginx.conf
nginx.conf optmized for http/2 = HTTPS TLS (ssl)
# command to generate dhparams.pen
# openssl dhparam -out /etc/nginx/conf.d/dhparams.pem 2048
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
limit_req_status 444;
limit_conn_status 503;
proxy_cache_path /var/lib/nginx/proxy levels=1:2 keys_zone=backcache:8m max_size=50m;
proxy_cache_key "$scheme$request_method$host$request_uri$is_args$args";