Skip to content

Instantly share code, notes, and snippets.

View VMuliadi's full-sized avatar

Vinsen Muliadi VMuliadi

View GitHub Profile
@VMuliadi
VMuliadi / DecisionEngineRouter.java
Created August 6, 2017 04:41
Latest DecisionEngineRouter for Broadcast Message
package routing;
import java.util.*;
import core.*;
/**
* This class overrides ActiveRouter in order to inject calls to a
* DecisionEngine object where needed add extract as much code from the update()
* method as possible.
# Compress JS, HTML, and CSS files
# on the web server. You can put it
# on the main configuration files
<filesMatch "\.(js|html|css)$">
SetOutputFilter DEFLATE
</filesMatch>
@VMuliadi
VMuliadi / install-avconf.sh
Last active March 24, 2018 08:38
Installing avconf for Fedora/CentOS/RHEL
# /bin/bash
wget https://libav.org/releases/libav-12.3.tar.xz
sudo dnf install -y libvorbis yasm freetype zlib bzip2 faac-devel lame-devel speex-devel libvpx libogg libtheora x264 opencore-amr libvpx-devel faac lame speex libvpx-utils
cd libav-12.3/
./configure --extra-cflags=-I/opt/local/include --extra-ldflags=-L/opt/local/lib --enable-gpl --enable-version3 --enable-libvpx
make
sudo make install
@VMuliadi
VMuliadi / shape_bandwidth.sh
Last active March 26, 2018 04:30
This gist is modified version of rbrook's shape_bandwidth.sh (https://gist.github.com/rbrooks/2719817)
#!/bin/bash
TC=/sbin/tc
IF=wlp2s0
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"
start() {
$TC qdisc add dev $IF root handle 1: htb default 3
$TC class add dev $IF parent 1: classid 1:1 htb rate 300kbps ceil 300kbps
$TC class add dev $IF parent 1: classid 1:2 htb rate 200kbps ceil 200kbps
$TC class add dev $IF parent 1: classid 1:3 htb rate 150kbps ceil 150kbps
@VMuliadi
VMuliadi / pip-upgrade-all.py
Created April 7, 2018 09:55
Upgrade all Python package using pip
import pip
from subprocess import call
packages = [dist.project_name for dist in pip.get_installed_distributions()]
call("pip install --upgrade " + ' '.join(packages), shell=True)
@VMuliadi
VMuliadi / remove_old_sprocket.py
Last active June 11, 2018 07:33
Removing old .sprocket and preserve latest file when using Sprocket Integration on Ruby on Rails Web Apps
import os
import glob
from datetime import datetime
def get_youngest(list_of_file):
list_of_ctime = []
for ctime in list_of_file:
list_of_ctime.append(ctime['ctime'])
@VMuliadi
VMuliadi / lid_closed_keep_on.sh
Last active September 27, 2019 15:40
Allow Linux computer to keep working even the lid was closed. Tested on Linux Fedora 29
#!/bin/bash
sudo sed -i 's|#HandleLidSwitch=suspend|HandleLidSwitch=ignore|g' /etc/systemd/logind.conf
read -p "Are you going to restart your computer (y to restart)?" confirmation
if [[ $(echo ${confirmation}) == y || $(echo ${confirmation}) == Y ]]; then
sudo reboot
else echo "DONE"
fi
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce
sudo systemctl start docker
sudo systemctl enable docker
sudo groupadd docker && sudo gpasswd -a ${USER} docker && sudo systemctl restart docker
sudo gpasswd -a ${USER} docker && sudo systemctl restart docker
@VMuliadi
VMuliadi / sysctl.conf
Created April 15, 2019 09:15 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@VMuliadi
VMuliadi / ngrok_cloudflare.sh
Last active October 7, 2019 09:08
Bash script to create a CNAME record that pointing to your ngrok tunnel public address using Cloudflare v4 API
#! /bin/bash
set -e
# Copyright (c) 2019 Vinsen Muliadi
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to