Skip to content

Instantly share code, notes, and snippets.

View khairulcs's full-sized avatar
🎯
Focusing

Khairul Azwan khairulcs

🎯
Focusing
View GitHub Profile
@khairulcs
khairulcs / letsencrypt.md
Created May 6, 2022 00:02
Using Free Let’s Encrypt SSL/TLS Certificates with NGINX

apt-get update sudo apt-get install certbot apt-get install python3-certbot-nginx


server {
    listen 80 default_server;
    listen [::]:80 default_server;
 root /var/www/html;
@khairulcs
khairulcs / rails http status codes
Created August 22, 2021 14:03 — forked from mlanett/rails http status codes
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@khairulcs
khairulcs / readme.md
Created May 25, 2021 13:16
Installing kubectl client on Ubuntu
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(<kubectl.sha256) kubectl" | sha256sum --check

Should echo kubectl: OK

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client
@khairulcs
khairulcs / install_ffmpeg_ubuntu.sh
Created April 23, 2021 05:34 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@khairulcs
khairulcs / readme.md
Last active December 31, 2020 04:23 — forked from vortizhe/gist:f1bc1391c55d644cd2fa
Add sidekiq as a service in Ubuntu 20.04

STEPS

vim /etc/init.d/sidekiq

Copy and paste the code below and change appropriately Save and exit (ESC + :wq)

sudo update-rc.d sidekiq defaults
@khairulcs
khairulcs / clear-sidekiq-jobs.md
Last active May 25, 2021 13:23 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs

1. Clear retry set

Sidekiq::RetrySet.new.clear

1.1 Retry all

Sidekiq::RetrySet.new.retry_all

2. Clear scheduled jobs

Sidekiq::ScheduledSet.new.clear

3. Clear 'Processed' and 'Failed' jobs

Sidekiq::Stats.new.reset

4. Clear 'Dead' jobs statistics

Sidekiq::DeadSet.new.clear

@khairulcs
khairulcs / gist:075a90f7f6497c5b693029cf6f9e23da
Created March 2, 2020 04:06 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@khairulcs
khairulcs / checking-cpu-ram.md
Created February 19, 2020 01:52
Check top 5 using CPU and MEMORY

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head

Brief explanation of above options used in above command.

The -o (or –format) option of ps allows you to specify the output format. A favorite of mine is to show the processes’ PIDs (pid), PPIDs (pid), the name of the executable file associated with the process (cmd), and the RAM and CPU utilization (%mem and %cpu, respectively).

Additionally, I use --sort to sort by either %mem or %cpu. By default, the output will be sorted in ascendant form, but personally I prefer to reverse that order by adding a minus sign in front of the sort criteria.

To add other fields to the output, or change the sort criteria, refer to the OUTPUT FORMAT CONTROL section in the man page of ps command.

@khairulcs
khairulcs / dstat.md
Created February 14, 2020 02:23
Measuring Linux System Performance with dstat

Install the package

apt install dstat -y

use nohup to run the dstat

nohup dstat -c --top-cpu -d --top-bio --top-latency --output systemstats.csv &

end the nohup

ps -ef |grep nohup

if the process ID == 22182

kill -9 22182

@khairulcs
khairulcs / Clear the buffer caches
Created January 29, 2020 08:15
clear linux buffer caches
# free && sync && echo 3 > /proc/sys/vm/drop_caches && free