Skip to content

Instantly share code, notes, and snippets.

View jpcaparas's full-sized avatar
🐔

Jayps jpcaparas

🐔
View GitHub Profile
@jpcaparas
jpcaparas / selenium
Created June 21, 2019 04:14
Selenium Standalone Server wrapper
# usr/local/bin/selenium
#!/usr/bin/env bash
set -e
# Download from https://www.seleniumhq.org/download/
SELENIUM_PATH=/opt/selenium/selenium-server-latest.jar
SELENIUM_PORT=5555
@jpcaparas
jpcaparas / prompt.sh
Created June 9, 2019 00:22
BASH: Variable substitution on user input
#!/bin/bash
set -e
name=
_prompt() {
local message="$1"
local -n input="$2"
@jpcaparas
jpcaparas / rclone-to-gdrive.sh
Last active June 3, 2019 02:08
Tarball to standard output and then to rclone (rclone-to-gdrive.sh)
#!/bin/bash
# file: rclone-to-gdrive.sh
# usage: $(rclone-to-gdrive.sh /var/www /etc/nginx /var/some\ dir\ with\ spaces)
set -e
# Check if user running the script is root
# https://askubuntu.com/questions/15853/how-can-a-script-check-if-its-being-run-as-root
if [[ $EUID -ne 0 ]]; then
@jpcaparas
jpcaparas / openvpn-client@.conf
Created May 31, 2019 03:29
OpenVPN client Fedora systemd service
[Unit]
Description=OpenVPN tunnel for %I
After=syslog.target network-online.target
Wants=network-online.target
Documentation=man:openvpn(8)
Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO
[Service]
Type=notify
@jpcaparas
jpcaparas / command.sh
Created May 27, 2019 00:30
macos acl
# source https://apple.stackexchange.com/a/31457
sudo chmod +a "group:staff allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" $PWD

Instructions

The files are made for systems with systemd. The instructions are written with Ubuntu 16.04 in mind. Your file locations may vary.

Installation

  1. Become root
  2. Create the service files in lib/systemd/system
  3. Change <user> in the Sonarr service file to the approriate user.
@jpcaparas
jpcaparas / killproc.sh
Created May 23, 2019 04:54
Kill proceses by search
#!/bin/bash
set -e
searchterm=$1
verbose=false
usage() {
echo "Usage: [-v verbose] searchterm"
@jpcaparas
jpcaparas / find.sh
Last active May 21, 2019 00:06
GNU "find" examples
# Find top level directories that are aged or are older than 10 days and delete them.
find . -mindepth 1 -maxdepth 1 -not -newermt '10 days ago' -exec rm -rf {} +
@jpcaparas
jpcaparas / Steps
Last active June 26, 2019 20:15
Install Docker CE on Fedora 30
# Main guide
https://docs.docker.com/install/linux/docker-ce/fedora/
# Set up the repository
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo
@jpcaparas
jpcaparas / References
Last active January 16, 2025 14:09
Limit docker CPU and memory resource usage
Inspired by: https://stackoverflow.com/questions/46408673/docker-17-06-ce-default-container-memory-limit-on-shared-host-resources/46557336#46557336