Skip to content

Instantly share code, notes, and snippets.

@Sam-R
Sam-R / Install Apache MySql PHP5
Last active September 9, 2016 19:15
Install Apache, MySQL and PHP5 on a Debian/Ubuntu based machine
#!/bin/bash
# ----------------------------------------------- #
# Install an AMP environment on Ubuntu 14.04
# ----------------------------------------------- #
# Update the system's repositories
sudo apt-get update
# Install apache2, mysql-server and PHP5
sudo apt-get install apache2 mysql-server libapache2-mod-auth-mysql php5-mysql php5 libapache2-mod-php5 php5-mcrypt php5-cli php5-gd php5-curl php5-imagick mcrypt phpmyadmin
#!/bin/bash
# ----------------------------------------------- #
# Restart AMP
# ----------------------------------------------- #
sudo service apache2 stop
sudo service mysql restart
sudo service apache2 start
@Sam-R
Sam-R / insert_countries.php
Created April 21, 2016 12:38
Insert ISO 3166-1 alpha-2 country codes into MySQL
$country_codes = array(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',
'AO' => 'Angola',
'AI' => 'Anguilla',
'AQ' => 'Antarctica',
@Sam-R
Sam-R / Flac to MP3
Created June 29, 2016 16:36
Bash convert FLAC to MP3 using lame on Ubuntu 14.04/Mint 17
#
# Original code copied from @ http://www.boback.com/2013/how-to-convert-flac-to-mp3-ubuntu-command-line/
#
# Install lame and flac
sudo apt-get install lame flac
# For each file in the current directory, pass it through lame and output as MP3
for f in *.flac; do flac -cd "$f" | lame -b 320 - "${f%.*}".mp3; done
@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

@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 / 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 / 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 / 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 / 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 "