Skip to content

Instantly share code, notes, and snippets.

View matthewstokeley's full-sized avatar
🎯
Focusing

Matthew Stokeley matthewstokeley

🎯
Focusing
View GitHub Profile
less /var/log/mysql/error.log
free -m
mysqltuner
tail -f /var/log/apache2/error.log
#!/bin/bash
SERVERIP=192.168.2.3
NOTIFYEMAIL=test@example.com
ping -c 3 $SERVERIP > /dev/null 2>&1
# working with text in bash
# paste string into a text file
echo string > textfile
# export stdout to a text file
command > textfile
# copy contents of a text file
cat filename > /dev/clipboard
<!-- vertically-aligned center and bottom boxes in a column with flex box -->
<div class="container">
<div class="center">
<span>center</span>
</div>
<div class="bottom">
<span>bottom</span>
</div>
@matthewstokeley
matthewstokeley / post-receive
Created December 7, 2018 00:14
git 'one click' deployment
// git init --bare
// cd hooks && touch post-receive && cat /dev/clipboard > post-receive && chown USER:GROUP post-receive
#!/bin/bash
# forked from
# https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa#file-post-receive
TARGET="/var/www/html/"
GIT_DIR="/var/www/html/REPOSITORY.git"
BRANCH="production"
class API {
private $path;
private $length;
private $route;
private $db;
function __construct(array $options) {
@matthewstokeley
matthewstokeley / gist:1039f6563e02246ab4a9bab5e9e06b72
Created December 8, 2018 16:31
a wordpress database migration script
#! /bin/bash
if [[$1 == "export"]]
then mysqldump -u $2 $3 > "$3.sql";
fi
if [[$1 == "import"]]
then mysql -u $2 $3 < "$3.sql";
fi
@matthewstokeley
matthewstokeley / mysql-pdo.php
Last active December 8, 2018 21:38
very simple mysql pdo implementation
<?php
//https://gist.github.com/taniarascia/013fb512078329cc6c40f4e4bf98fdbf
class MysqlDriver {
private $host;
private $dbname;
private $username;
private $password;
private $charset;
private $collate;
#!/usr/bin
# https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04
sudo apt install php libapache2-mod-php php-mysql
sudo nano /etc/apache2/mods-enabled/dir.conf
@matthewstokeley
matthewstokeley / simple-join-sql-statement.md
Last active December 11, 2018 11:04
a sql statement to request the row of items with the most occurrences

// `table A` is filled with rows of data that contain a reference key to the `id` column of `table B`
// we need to rows with the most occurrences of reference keys, then return the data from the matching row in `table B`

// for instance,
// `table A` are newspapers, and `table B` are countries

// `table A` might look like 
//  name       | key
@matthewstokeley
matthewstokeley / wordpress-api-menu.php
Last active July 19, 2019 16:48
add a menu endpoint to the wordpress rest api
/**
*
* @param array $data options
* @return array|null an array of links
*/
function find_menu( WP_REST_Request $data ) {
$menu = wp_get_nav_menu_items( $data['name'] );