Skip to content

Instantly share code, notes, and snippets.

Avatar

Gary Martin mrgarymartin

View GitHub Profile
@mrgarymartin
mrgarymartin / firewall.sh
Created Feb 23, 2018
Updated version to whitelist all cloudflare ips in firewalld
View firewall.sh
#!/usr/bin/env bash
#https://techstat.net/automatic-whitelist-cloudflare-ips-firewalld-bash-script-via-cron-job/
SERVER_IP=xxx.xxx.xxx.xxx
for i in $(curl "https://www.cloudflare.com/ips-v4"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv4" source address="'$i'" port port=80 protocol=tcp accept'; done
for i in $(curl "https://www.cloudflare.com/ips-v4"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv4" source address="'$i'" port port=443 protocol=tcp accept'; done
for i in $(curl "https://www.cloudflare.com/ips-v6"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv6" source address="'$i'" port port=80 protocol=tcp accept'; done
for i in $(curl "https://www.cloudflare.com/ips-v6"); do sudo firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv6" source address="'$i'" port port=443 protocol=tcp accept'; done
@mrgarymartin
mrgarymartin / centos-build.sh
Last active Feb 13, 2018
build centos 7.4 with php7 mysql 5.7 and nginx nodejs composer
View centos-build.sh
#!/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 / mysql_5-7_update.sh
Last active Jul 20, 2016 — forked from dj1020/migrate.sh
Upgrade MAMP to Mysql 5.7 tested by Ken Lin 2015/11/09
View mysql_5-7_update.sh
#!/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 / mysql_5-6_update.sh
Last active Jul 19, 2016 — forked from tobi-pb/migrate.sh
Upgrade MAMP to Mysql 5.6
View mysql_5-6_update.sh
#!/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 / convertArrayToOject.php
Last active May 4, 2016
Convert Array to Object Function
View convertArrayToOject.php
<?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 / lockdown.sh
Created Dec 11, 2015
Lockdown IPTables to all traffic Expect STATIC IPs.
View lockdown.sh
#!/usr/bin/env bash
## Author: Gary Martin
##
## Usage ./lockdown.sh {IPADDRESS} {IPADDRESS2}
function valid_ip()
{
local ip=$1
local stat=1
@mrgarymartin
mrgarymartin / index.html
Created Oct 8, 2015
Bare Boostrap Template with CDNs
View index.html
<!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 / gist:9fc8a3272a00e88cc16b
Last active Apr 13, 2017
Wordpress File Uploader for images in custom post types
View gist:9fc8a3272a00e88cc16b
<?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' );
}
You can’t perform that action at this time.