Skip to content

Instantly share code, notes, and snippets.

@Sam-R
Sam-R / Docker Dev.md
Created June 13, 2019 11:25
Docker Development Environment Notes

MySQL

Create a MySQL instance in a docker container that's bound to the hosts standard MySQL ports. This is useful if you're developing locally without a docker-compose enviornment and don't want to run MySQL on your local or virtual machine.

sudo docker run --name mysql5 -e MYSQL_ROOT_PASSWORD=toor -P 3306:3306 -d mysql:5

You should be able to connect to the server using root and toor as credentials.

@Sam-R
Sam-R / NextCloud Fail2Ban.md
Created May 31, 2019 20:05
Fail2Ban config for NextCloud

sudo nano /etc/fail2ban/filter.d/nextcloud.conf

[Definition]
failregex=^{"reqId":".*","remoteAddr":".*","app":"core","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)","level":2,"time":".*"}$
	^{"reqId":".*","level":2,"time":".*","remoteAddr":".*","app":"core".*","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)".*}$
	^.*\"remoteAddr\":\"<HOST>\".*Trusted domain error.*$
`sudo nano /etc/fail2ban/filter.d/nextcloud.conf`
```
[Definition]
failregex=^{"reqId":".*","remoteAddr":".*","app":"core","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)","level":2,"time":".*"}$
^{"reqId":".*","level":2,"time":".*","remoteAddr":".*","app":"core".*","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)".*}$
^.*\"remoteAddr\":\"<HOST>\".*Trusted domain error.*$
```
@Sam-R
Sam-R / Zabbix 4.0 Ubuntu 18.04.md
Last active December 12, 2018 10:21
Setup notes for Zabbix 4.0 on Ubuntu 18.04
@Sam-R
Sam-R / find_files.sh
Created April 5, 2017 10:34
Find files with the same name but different extensions in a directory
# Find duplicate filenames
## Find everything in the Pictures directory with the same file name excluding extension.
ls -1 ~/Pictures/ | sed 's/\(.*\)\..*/\1/' | sort | uniq -c | grep -v " 1 "
# Find unique filenames
## Find everything in the Pictures directory without the same file name excluding extension.
ls -1 ~/Pictures/ | sed 's/\(.*\)\..*/\1/' | sort | uniq -c | grep -v " 2 "
@Sam-R
Sam-R / bash_aliases
Last active September 19, 2020 13:26
Bash aliases file.
# ---------------------------------------
# Git Commands
# ---------------------------------------
alias gits="git status"
alias gitp="git push"
alias gita="git add -A"
alias gitc="git commit"
alias gitcr="git remote set-url origin"
alias gitdiff="git difftool --tool=meld --dir-diff"
@Sam-R
Sam-R / working_with_imagick_links.md
Last active December 18, 2018 09:42
Some links for working with image extraction from transparencies in imagick (bash/PHP)
@Sam-R
Sam-R / install_apache.sh
Created September 9, 2016 19:19
Install Apache, MySQL, PHP7 on Ubuntu 16.04 based systems
#!/bin/bash
# ----------------------------------------------- #
# Install an AMP environment on Ubuntu 16.04
# ----------------------------------------------- #
# Update the system's repositories
sudo apt-get update
# Install apache2, mysql-server and PHP5
sudo apt-get install apache2 mysql-server php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7
@Sam-R
Sam-R / find_and_move.sh
Created August 26, 2016 13:17
Bash script to find files from one directory, rename them with a PNG extension and move them to another directory
#!/bin/bash
# Move a Source set of files to a Destination folder with a ".png" extension.
# Note that by default this script looks for any file with a name ending in "_IMAGE" but you can change this as you see fit.
# It also limits the depth to 1, so it doesn't search subfolders.
# The original purpose of this script was to move artwork loaded into an SFTP area by a client and place it somewhere else for automated processing, keeping their SFTP jail clear from old files.
# One Liner for Crontab
#cd /path/to/source; find . -name '*_IMAGE' -maxdepth 1 -exec mv '{}' /path/to/destination/'{}'.png \; ;
# We move to the source directory of the files, so during the find there's less work to to extracting the file name from the path in the mv command.
@Sam-R
Sam-R / raspberry_pi_kiosk.md
Created June 30, 2016 15:59
Setup the Raspberry PI as a Web Kiosk.

Install Software

We need to install chrome (browser), x11 server (utilities) and unclutter (remove cursor)

sudo apt-get install chromium x11-xserver-utils unclutter

Enable SSH

Enable SSH access and boot to desktop in using rasp-config