Skip to content

Instantly share code, notes, and snippets.

View themarcusbattle's full-sized avatar

Marcus Battle themarcusbattle

View GitHub Profile
@themarcusbattle
themarcusbattle / airtable-sms.js
Created November 6, 2019 17:22
Twilio Superclass DC Airtable Demo
'use strict'
const express = require('express')
const bodyParser = require('body-parser')
const axios = require('axios')
// Create a new instance of express
const app = express()
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
@themarcusbattle
themarcusbattle / newpress.sh
Last active November 18, 2018 07:12
Bash script to create WordPress + Valet installation
#!/bin/bash
echo
echo "This script will install a new WordPress site and use Valet to create a local domain."
echo
echo "Let's define the folder name. This folder will also serve as the domain of our site."
echo "(i.e. mysite => http://mysite.test)"
echo
echo -n "Enter folder name: "
read foldername
@themarcusbattle
themarcusbattle / gist:cfbc8079f363d66a1288d61424104e75
Created February 16, 2018 18:12
Gutenberg Example for Greg
import './style.scss';
import './editor.scss';
// Get just the __() localization function from wp.i18n
const { __ } = wp.i18n;
// Get registerBlockType and Editable from wp.blocks
const { registerBlockType, Editable } = wp.blocks;
// Set the h2 header for the block since it is reused
const blockHeader = <h2>{ __( 'Scripture Display' ) }</h2>;
@themarcusbattle
themarcusbattle / racerave-races-example.json
Created January 31, 2018 14:55
RaceRaves GET /Rest/races/ example data set
{
"races": [
{
"race": {
"race_id": 24024,
"name": " \tCarson Park 5 and 10",
"last_date": "10/28/2017",
"last_end_date": "10/28/2017",
"next_date": "10/27/2018",
"next_end_date": "10/27/2018",
@themarcusbattle
themarcusbattle / forward.php
Created October 1, 2014 20:13
WordPress Post Forwarding
/**
* Forwards a post to an external URL
*/
function forward_post( $url, $post, $leavename ) {
// Check to see if a forwarding URL exists
if ( $forwarding_url = get_post_meta( $post->ID, '_forward_to_url', true ) )
$url = $forwarding_url;
return $url;
@themarcusbattle
themarcusbattle / post-type-rewrite.php
Created July 24, 2014 16:07
Custom Post Type Permalink Rewrite
function custom_post_type_init() {
// Define desired permalink structure
$post_type_rewrite = '/some_sluge_prefix/%[param1]%/%[param2]%/%[custom_post_type]%';
// Add rewrite functions
add_rewrite_tag( '%[custom_post_type]%', '([^/]+)' );
add_permastruct( '[custom_post_type]', $post_type_rewrite, false );
}
@themarcusbattle
themarcusbattle / Oauth (Explicit)
Last active December 24, 2015 06:49
Oauth Example
<?php
if ( isset( $_REQUEST['logout'] ) ) {
setcookie("access_token", '', time()-3600);
setcookie("full_name", '', time()-3600);
header('Location: ');
}
if ( isset( $_COOKIE['access_token'] ) ) {
echo "<p>Hey " . $_COOKIE['full_name'] . "! You're already logged in. We don't know anything else about you, but we do know you gave us access to your information lol</p>";
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} (\.json)$
RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]