Skip to content

Instantly share code, notes, and snippets.

View prasetiyohadi's full-sized avatar

Prasetiyo Hadi Purwoko prasetiyohadi

View GitHub Profile
@prasetiyohadi
prasetiyohadi / nginx
Created February 21, 2015 09:46
Nginx init script for passenger nginx module for CentOS 6
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
@prasetiyohadi
prasetiyohadi / pacman-fonts.sh
Last active December 23, 2015 09:51
pacman install all fonts except *mate* and *tex* package
#!/bin/bash
sudo pacman -S --needed $(pacman -Ss font | awk -F" " '{print $1}' | grep "/" | awk -F"/" '{print $(NF)}' | grep -v mate | grep -v tex | tr '\n' ' ')
@prasetiyohadi
prasetiyohadi / nginx.conf
Last active December 23, 2015 09:52
nginx proxy configuration for php-fpm, fastcgi, and kibana4
server {
listen 80;
server_name domain.com;
root /usr/share/nginx/html;
try_files $uri =404;
index index.php index.html;
location / {
}
@prasetiyohadi
prasetiyohadi / file.sh
Last active December 23, 2015 09:53
Convert file types and optimize PDF file
#!/bin/bash
# using imagemagick package
# convert *.png file to *.jpg file
convert file.png file.jpg
# convert *.jpg file to *.pdf file
convert file.jpg file.pdf
# using ghostscript package
@prasetiyohadi
prasetiyohadi / .vimrc
Created November 8, 2015 09:46
My .vimrc file
set nocompatible " required
filetype off " required
filetype plugin indent on " required
" Control split
set splitbelow
set splitright
" Split navigations
@prasetiyohadi
prasetiyohadi / vgaoutput.sh
Last active December 23, 2015 09:55
Connect to a VGA output for Arch Linux notebooks
#!/bin/bash
# Arch Linux
# clone desktop
xrandr --auto
# extend desktop
xrandr --output LVDS-1-0 --auto --output VGA-1-0 --auto --right-of LVDS-1-0
@prasetiyohadi
prasetiyohadi / iredmail_mailman_aliases.py
Created November 25, 2015 05:19
Insert Mailman domain and aliases to iRedmail MySQL database
#!/usr/bin/env python
import MySQLdb
db = MySQLdb.connect("localhost", "dbuser", "dbpass", "dbname")
cursor = db.cursor()
print "Insert mailman domain and aliases to iRedmail database."
sql = """
select * from domain where domain="lists.example.com"
@prasetiyohadi
prasetiyohadi / openvpn-fw.sh
Last active December 23, 2015 09:56
Firewall-cmd configuration for OpenVPN service
#!/bin/bash
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
sudo systemctl start firewalld.service
sudo firewall-cmd --zone=public --add-service openvpn --permanent
sudo firewall-cmd --zone=public --add-masquerade --permanent
# confirm
sudo firewall-cmd --zone=public --query-masquerade
@prasetiyohadi
prasetiyohadi / openstack.sh
Last active April 12, 2017 11:48
Openstack commands example
#!/bin/bash
# load authentication key
cd $HOME
source keystonerc_admin
# list neutron routers
neutron router-list --max-width 50
# remove router gateway
@prasetiyohadi
prasetiyohadi / nginx.conf
Created December 23, 2015 07:23
Using Nginx to protect against CVE-2015-1635
# See https://www.nginx.com/blog/nginx-protect-cve-2015-1635/
# Using Nginx to protect against CVE-2015-1635
# Exploit: https://ma.ttias.be/remote-code-execution-via-http-request-in-iis-on-windows/
# Identifying and handling reconnaisance traffic
# HTTP requests with a large byte range in the **Range** header trigger the crash:
#
# GET / HTTP/1.1\r\n
# Host: stuff\r\n
# Range: bytes=0-18446744073709551615\r\n