Skip to content

Instantly share code, notes, and snippets.

@mrgarymartin
mrgarymartin / index.html
Created October 8, 2015 18:06
Bare Boostrap Template with CDNs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
@mrgarymartin
mrgarymartin / lockdown.sh
Created December 11, 2015 15:34
Lockdown IPTables to all traffic Expect STATIC IPs.
#!/usr/bin/env bash
## Author: Gary Martin
##
## Usage ./lockdown.sh {IPADDRESS} {IPADDRESS2}
function valid_ip()
{
local ip=$1
local stat=1
Goodbye
@mrgarymartin
mrgarymartin / convertArrayToOject.php
Last active May 4, 2016 17:47
Convert Array to Object Function
<?php
/**
* Convert Arrays to Class Objects
* Author: Gary Martin
* Date: 5/2/2016
*
* Description: This Converts arrays to Objects that have getters and setters preventing.
* If the $key is not defined in the model it gets skipped.
* The model must have a getAttributes function that returns the attributes in a array.
* This code will reduce that to check if its in the array.
@mrgarymartin
mrgarymartin / mysql_5-6_update.sh
Last active July 19, 2016 19:40 — forked from tobi-pb/migrate.sh
Upgrade MAMP to Mysql 5.6
#!/bin/sh
curl -O http://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.24-osx10.9-x86_64.tar.gz
tar xfvz mysql-5.6*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
@mrgarymartin
mrgarymartin / mysql_5-7_update.sh
Last active July 20, 2016 05:34 — forked from dj1020/migrate.sh
Upgrade MAMP to Mysql 5.7 tested by Ken Lin 2015/11/09
#!/bin/sh
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.9-osx10.10-x86_64.tar.gz
tar xfvz mysql-5.7*
echo "stopping mamp"
sudo /Applications/MAMP/bin/stop.sh
sudo killall httpd mysqld
echo "creating backup"
@mrgarymartin
mrgarymartin / gist:9fc8a3272a00e88cc16b
Last active April 13, 2017 09:00
Wordpress File Uploader for images in custom post types
<?php
/*******************************************************Podcast Meta-boxes *******************/
//Add Metabox
//Source: http://wordpress.stackexchange.com/questions/139841/add-metabox-with-media-uploader-in-a-custom-post-type
add_action( 'add_meta_boxes', 'add_upload_file_metaboxes' );
function add_upload_file_metaboxes() {
add_meta_box( 'swp_file_upload', 'File Upload', 'swp_file_upload', 'videos', 'normal', 'default' );
}
@mrgarymartin
mrgarymartin / centos-build.sh
Last active February 13, 2018 05:39
build centos 7.4 with php7 mysql 5.7 and nginx nodejs composer
#!/usr/bin/env bash
# update system
sudo yum update -y
# install basic items
sudo yum install -y vim wget git epel-release
#set timezone
timedatectl set-timezone America/Chicago
@mrgarymartin
mrgarymartin / cleanup-docker.sh
Last active December 9, 2020 17:37
This script installs automated docker cleanup via "docker image prune"
#!/bin/sh
# This script installs automated docker cleanup via "docker image prune"
# onto systemd-based systems.
# It requires that docker is installed properly
# source: https://techoverflow.net/2019/10/03/how-to-automatically-cleanup-prune-docker-images-daily/
cat >/etc/systemd/system/PruneDocker.service <<EOF
[Unit]
Description=PruneDocker
@mrgarymartin
mrgarymartin / pushFileToStorage.ts
Created January 2, 2023 18:33
Angular Fire Upload tasks
pushFileToStorage(fileUpload: FileUpload) {
const filePath = `${this.basePath}/${fileUpload.file.name}`;
const storageRef = ref(this.storage, filePath);
const uploadTask = uploadBytesResumable(storageRef, fileUpload.file);
uploadTask.on('state_changed',
(snapshot) => {
// Observe state change events such as progress, pause, and resume
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded