Skip to content

Instantly share code, notes, and snippets.

View matthewstokeley's full-sized avatar
🎯
Focusing

Matthew Stokeley matthewstokeley

🎯
Focusing
View GitHub Profile
@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 / elements.js
Last active December 14, 2018 14:28
an incredibly light-weight class for handling css classes of element with a jQuery-esque syntax
import './addClass';
import './removeClass';
import './addAttribute';
import './removeAttribute';
export default var elements = (element) => {
return {
addClass: (className) => { return addClass(element, className) },
removeClass: (className) => { return removeClass(element, className); },
@matthewstokeley
matthewstokeley / pojo-to-replace-conditional.js
Last active December 15, 2018 01:50
objects can be used instead of conditionals and switches
/**
* This is an object
* where we can store methods
* that are accessible with a string
*/
var conditional = {
humanities: () =>
@matthewstokeley
matthewstokeley / really-simple-form-to-xhr-request.md
Created December 15, 2018 15:23
really simple form to xhr request

Really simple form-to-xhr requests with FormData, Request and onclick

<form id="form">
    <input id="input" name="input" placeholder="" />
    <input type="submit" onclick="submitForm(event)" />
</form>
@matthewstokeley
matthewstokeley / grid-coordinates-with-drag-event.js
Created December 17, 2018 14:50
Find grid coordinates with the drag event object - needs testing.
var findX = () => event.clientX - event.target.offsetLeft;
var findY = () => event.target.offsetTop - event.clientY;