Skip to content

Instantly share code, notes, and snippets.

View MPJHorner's full-sized avatar
👨‍💻
Focusing

Matt Horner MPJHorner

👨‍💻
Focusing
View GitHub Profile
Checkout
`git checkout --orphan latest_branch`
Add all the files
`git add -A`
Commit the changes
`git commit -am "commit message"`
Delete the branch
@MPJHorner
MPJHorner / FindPricelistDuplicates.sql
Created May 20, 2016 09:54
Find Pricelist Duplicates Report - Khaos Control (Keystone Software)
SELECT
sd.compclass_id as 'Pricelist ID',
cc.short_desc as 'Pricelist',
UPPER(st.stock_code) as 'SKU'
FROM struc_discounts AS sd
LEFT JOIN stock as st
ON sd.stock_id = st.stock_id
LEFT JOIN company_class as cc
@MPJHorner
MPJHorner / FindCompanyContactsAddresses.sql
Created May 23, 2016 11:35
Show Company Contacts & Addresses Report - Khaos Control (Keystone Software)
SELECT
company.company_id,
address.address_id,
contact.contact_id,
company.company_code,
company.company_name,
address.address1,
address.address2,
address.locality,
address.town,
#In this example 'phpfpm-demo' is the name of the image, you need to run this as a 'sh' script in the directory where the Dockerfile is located.
docker ps -a | awk '{ print $1,$2 }' | grep phpfpm-demo | awk '{print $1 }' | xargs -I {} docker rm {}
docker rmi phpfpm-demo
docker build -t phpfpm-demo .
docker run -p 9000:9000 phpfpm-demo
The API is at https://www.ipify.org/
The API endpoint is https://api.ipify.org?format=json
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
@MPJHorner
MPJHorner / lumen-resource-route.php
Created April 13, 2017 15:06 — forked from sohelamin/lumen-resource-route.php
Lumen Resource Routing
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
@MPJHorner
MPJHorner / clean-docker-for-mac.sh
Created July 18, 2017 17:10 — forked from MrTrustor/clean-docker-for-mac.sh
This script cleans the Docker.qcow2 file that takes a lot of disk space with Docker For Mac. You can specify some Docker images that you would like to keep.
#!/bin/bash
# Copyright 2017 Théo Chamley
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
@MPJHorner
MPJHorner / Docker.qcow2.reduce.sh
Created August 21, 2016 10:15
Reduce / Clean Up Docker.qcow2 File
#Ensure to exit docker from taskbar first.
cd ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux /Applications/Docker.app/Contents/MacOS/qemu-img convert -O qcow2 Docker.qcow2 Docker2.qcow2 mv Docker2.qcow2 Docker.qcow2
@MPJHorner
MPJHorner / s3-invalidation.js
Created March 13, 2018 13:12 — forked from supinf/s3-invalidation.js
AWS Lambda script:: CloudFront Invalidations which are triggered by s3 events.
console.log('Loading event');
var Q = require('q');
var aws = require('aws-sdk');
var cloudfront = new aws.CloudFront();
exports.handler = function (event, context) {
//_log('Received event: ', event);
var bucket = event.Records[0].s3.bucket.name;
@MPJHorner
MPJHorner / mysql-docker.sh
Created June 4, 2018 22:42 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE