Skip to content

Instantly share code, notes, and snippets.

@frengky
frengky / auth-script.sh
Last active December 28, 2015 14:51
OpenVPN setup and configuration, complete with example for Linux
#!/bin/sh
echo "auth-script: authentication for username: ${username}, password: ${password}"
if [ "$username" == "your-username" ] && [ "$password" == "your-password" ]
then
echo "auth-script: login success"
exit 0
else
echo "auth-script: invalid username or password"
@frengky
frengky / border-box-transform.css
Created December 28, 2015 08:58
CSS border-box, transform syntax with IE9 compatibility
/*
* Box sizing border-box will help to prevent padding inside a container affecting outer size.
*/
html {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
*, *:before, *:after {
@frengky
frengky / nginx-cert.sh
Last active September 18, 2021 12:38
Nginx dynamic document root folder and sub-domain configuration
#!/bin/sh
# Self signed certificate for Nginx HTTPS
#
openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout /etc/nginx/ssl/my-domain.key -out /etc/nginx/ssl/my-domain.crt
@frengky
frengky / mkvsrt.sh
Created December 28, 2015 15:25
Bash script wrapper for mkvmerge, which make easy to merge video/movie file and the .srt subtitle into one file.
#!/bin/sh
SELF=$(basename $0)
if [ "$#" -ne 2 ]; then
echo -e "\nUsage: $SELF [video-file] [subtitle-file]\n"
exit 1
fi
SRC_FILE="$1"
@frengky
frengky / rtorrent.rc
Created December 30, 2015 02:55
Setup systemd with the rtorrent service
# This is an example resource file for rTorrent. Copy to
# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
# Maximum and minimum number of peers to connect to per torrent.
min_peers = 1
max_peers = 300
# Same as above but for seeding completed torrents (-1 = same as downloading)
min_peers_seed = 1
@frengky
frengky / nvidia-centos-update.md
Last active July 19, 2023 09:31
Update Nvidia driver on CentOS 7.x after kernel update

Update Nvidia driver on CentOS 7.x

Download the latest Nvidia driver on http://www.nvidia.com/drivers

Update the kernel to the latest version

$ yum update

Change to runlevel 3 - multi user mode for the next reboot

@frengky
frengky / firewalld.md
Last active December 27, 2022 17:28
FirewallD command line snippets for Linux

FirewallD command line snippets for Linux

Create new zone identified by an IP Address or interface This 'example' zone rules will applied to the connection from 192.168.1.2

  $ firewall-cmd --list-all-zones
  $ firewall-cmd --permanent --new-zone=example
  $ firewall-cmd --permanent --zone=example --add-source=192.168.1.2
  $ firewall-cmd --zone=example --list-sources
@frengky
frengky / udev.md
Created January 13, 2016 01:58
Linux UDEV snippets

Linux UDEV snippets

Find out what is the device path

$ udevadm info -q path -n /dev/sda1

Testing the udev rules, make sure its handle the device as expected

$ udevadm test `udevadm info -q path -n /dev/sda1`
#!/bin/sh
BACKUPDIR="/usr/backup/databases"
TODAY=$(date '+%Y-%m-%d')
DATABASES=$(echo "show databases;" | mysql)
mkdir -p "${BACKUPDIR}/${TODAY}"
for DB in $DATABASES; do
if [ "$DB" != "Database" ] && \
@frengky
frengky / pull-apk-from-phone.txt
Created December 20, 2016 15:02
How to pull apk from android phone
# Determine the package name of the app, e.g. "com.example.someapp". Skip this step if you already know the package name.
adb shell pm list packages
Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.
# Get the full path name of the APK file for the desired package.
adb shell pm path com.example.someapp
The output will look something like this: package:/data/app/com.example.someapp-2.apk
# Pull the APK file from the Android device to the development box.
adb pull /data/app/com.example.someapp-2.apk path/to/desired/destination