Skip to content

Instantly share code, notes, and snippets.

View yrsdi's full-sized avatar
👋
Hi

Yadi Rosadi yrsdi

👋
Hi
View GitHub Profile
@yrsdi
yrsdi / docker_rabbitmqctl.md
Last active June 25, 2020 22:00 — forked from jemc/docker_rabbitmqctl.md
Controlling Docker RabbitMQ via rabbitmqctl

Example invocation of a RabbitMQ docker container (use -d instead of -t -i to run in the background):

docker run -t -i --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management

Example of controlling the rabbitmq-server inside the container using rabbitmqctl (also inside the container).

docker exec rabbitmq rabbitmqctl status
@yrsdi
yrsdi / splitCsvFiles.sh
Last active June 11, 2020 03:04
Split CSV files with rows number specified
splitCsvFiles() {
HEADER=$(head -1 $1)
if [ -n "$2" ]; then
CHUNK=$2
else
CHUNK=1000
fi
tail -n +2 $1 | split -l $CHUNK - $1_split_
for i in $1_split_*; do
echo -e "$HEADER\n$(cat $i)" > $i
@yrsdi
yrsdi / meminfo.sh
Created May 8, 2020 06:41 — forked from csko/meminfo.sh
Bash script to display memory usage per user.
#!/bin/bash
ps ax --no-headers -o user,rss,vsize | awk '{a[$1]+=$2; b[$1]+=$3}END{for (i in a){printf("%-15s%10d MB%10d MB\n", i, int(a[i]/1024), int(b[i]/1024))}}' | sort -k 2,3 -r -g \
| awk '{sum += $2; sum2 += $4; print $0} END {printf("-----------------------------------------\n%-15s%10d MB%10d MB\n", "TOTAL", sum, sum2)}'
@yrsdi
yrsdi / gist:73172e1cede6cefdc53151d4a0f3aa8f
Created September 29, 2019 17:01 — forked from RalfNorthman/gist:4204ed3afda04d2ead43ba3330e7b786
Installing Elm on Antergos (ArchLinux)
sudo pacman -S npm
sudo npm install --unsafe-perm -g elm elm-test elm-oracle elm-format
sudo ln -s /usr/lib/libtinfo.so /usr/lib/libtinfo.so.5
# Add this to your .vimrc if you use Vim with Vundle:
Plugin 'ElmCast/elm-vim'
@yrsdi
yrsdi / nginx-response-code.sh
Last active September 21, 2019 06:26
nginx grep response code from access log
cat api.access.log |sed 's/[][]/ /g'| awk '$4>="$FROM_DATE" && $4<="$END_DATE" {print $0}'| awk '{print $4,$7,$9,$13/1000000}'| sort -nk4 -r | head -n 20
@yrsdi
yrsdi / io-monitor.sh
Created September 20, 2019 06:16 — forked from azhargiri/io-monitor.sh
Simple script to dump iostat command to CSV file
#!/bin/sh
###
## The original code is taken from snippet https://pastebin.com/SxxuaVy4
## Thank's to Harry Sufehmi
##
## Usage:
## Simply put in your crontab.
## Example below will run io-monitor.sh every minutes
## */1 * * * * /path/to/you/io-monitor.sh
@yrsdi
yrsdi / mysite.com
Created September 19, 2019 05:35 — forked from nuhil/mysite.com
Nginx Configuration for Slim
# Assume that inside the 'Slim' directory,
# there is another directory named 'api' inside which there is the index.php file
# '/home/vagrant/Code/' is simply a synched folder from host machine to this directory
server {
listen 80;
server_name www.mysite.com mysite.com;
root /home/vagrant/Code/Slim;
try_files $uri /api/index.php;
@yrsdi
yrsdi / insomnia.sh
Created September 16, 2019 19:00 — forked from yagop/insomnia.sh
Insomnia REST Client Arch installer
#! /bin/bash
cd $(mktemp -d)
wget https://aur.archlinux.org/cgit/aur.git/snapshot/insomnia.tar.gz
tar xzf insomnia.tar.gz
cd insomnia
makepkg -s
sudo pacman -U insomnia-*-x86_64.pkg.tar
@yrsdi
yrsdi / decompile_java.md
Created May 16, 2019 07:10
Decompile Java class or Jar container under Linux Mint / Ubuntu

Lee Benfield's Java decompiler CFR is straight forward and can even batch decompile jar container. 

  1. Download the most recent version of CFR (crf 0.1.15 at the time of writing)
wget http://www.benf.org/other/cfr/cfr_0_115.jar
  1. Run decompile with output into terminal
java -jar cfr_0_115.jar javaclasstodecompiles.class
@yrsdi
yrsdi / install_elixir.md
Created December 27, 2018 00:15 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.