Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am spekkorice on github.
* I am spekko (https://keybase.io/spekko) on keybase.
* I have a public key ASC948-AR9Mq8WEP7cQK66fB4ZCx8J50D91VlxLgi8RbtAo
To claim this, I am signing this object:
docker pull mysql:5.6.27
docker run -p 3306:3306 --name <my-docker-name> -e MYSQL_ROOT_PASSWORD=password -d mysql:5.6.27
mysql -h 0.0.0.0 -P 3306 -u root -ppassword
function quicksort($seq) {
if(!count($seq)) return $seq;
$pivot= $seq[0];
$low = $high = array();
$length = count($seq);
for($i=1; $i < $length; $i++) {
// The index at which you would like to sort
$sortIndex = 0;
if($seq[$i][$sortIndex] <= $pivot[0]) {
$low [] = $seq[$i];
@SpekkoRice
SpekkoRice / checkiftablexists
Created March 5, 2015 12:37
BASH: Check if MySQL Table exists
#!/bin/bash
checkIfMySQLTableExists() {
table=$1;
if [ $(mysql -N -s -u root -p -e \
"select count(*) from information_schema.tables where \
table_schema='${table}' and table_name='${DB}';") -eq 1 ]; then
echo "Table ${table} exists! ...";
else
echo "Table ${table} does not exist! ..."
@SpekkoRice
SpekkoRice / checkPHPVersion
Last active July 21, 2020 07:40
Bash: Check the version of PHP
#!/bin/bash
# Function to check if the PHP version is valid
checkPHPVersion() {
# The current PHP Version of the machine
PHPVersion=$(php -v|grep --only-matching --perl-regexp "5\.\\d+\.\\d+");
# Truncate the string abit so we can do a binary comparison
currentVersion=${PHPVersion::0-2};
# The version to validate against
minimumRequiredVersion=$1;
@SpekkoRice
SpekkoRice / expectSSH
Last active August 29, 2015 14:03
Expect Script to log into SSH
#!/usr/bin/expect -f
# Please remember to make the file executable using:
# chmod +x expectSSH.exp
#
# To run the Script simply use ./expectSSH.sh yourhost.com root password
set host [lindex $argv 0]
set user [lindex $argv 1]
set pass [lindex $argv 2]