Skip to content

Instantly share code, notes, and snippets.

@rafpro
rafpro / emailcli.py
Created November 17, 2018 03:28 — forked from CITGuru/emailcli.py
EmailCLI - A Python Command Line App for sending mails using SendGrid
import os
import re
import click
import sendgrid
import six
from pyconfigstore import ConfigStore
from PyInquirer import (Token, ValidationError, Validator, print_json, prompt,
style_from_dict)
from sendgrid.helpers.mail import *
@rafpro
rafpro / functions.php
Created November 13, 2018 21:09 — forked from srikat/functions.php
Adding a cart icon with number of items and total cost in nav menu when using WooCommerce. http://sridharkatakam.com/adding-cart-icon-number-items-total-cost-nav-menu-using-woocommerce/
//* Make Font Awesome available
add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' );
function enqueue_font_awesome() {
wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css' );
}
/**
* Place a cart icon with number of items and total cost in the menu bar.
@rafpro
rafpro / uploads.yml
Created October 22, 2018 05:49 — forked from louim/uploads.yml
Drop-in playbook for Trellis to push and pull uploads from the server to your local machine.
---
- name: Sync uploads between environments
hosts: web
remote_user: "{{ web_user }}"
vars:
project: "{{ wordpress_sites[site] }}"
project_root: "{{ www_root }}/{{ site }}"
tasks:
@rafpro
rafpro / dateform.js
Created October 11, 2018 15:17 — forked from thewebprincess/dateform.js
Gravity Forms - Datepicker extension for Date Range Fields
jQuery(function ($) {
var datepickerInArgs = {
minDate: 1,
defaultDate: 0,
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
onClose: function( dateText, inst ) {
var d = $.datepicker.parseDate( inst.settings.dateFormat, dateText );
@rafpro
rafpro / React + Gravity Forms + WordPress.md
Created October 8, 2018 22:49 — forked from Veraxus/React + Gravity Forms + WordPress.md
Two approaches for allowing Gravity Forms (or other plugins) to work seamlessly when building a React frontend for WordPress

This question may be old, but building React applications on WordPress "facelessly" using the WP REST API is gaining momentum in a huge way (it's even the future for WordPress core), so this is bound to come up more and more.

So what is happening is that Gravity Forms sets it's form action by via $action = remove_query_arg( 'gf_token' ); which in turn calls add_query_arg() which then calls $uri = $_SERVER['REQUEST_URI']; - this means that when you use React to display WordPress content containing a Gravity Form, the form's action is set to the REST endpoint called, not the content's permalink. Whoops!

Although Gravity Forms has an bona-fide WP REST API add-on in works, there are two solid options I've been able to suss out so far:

Option 1 - Fully Headless

Ensure you have a REST route that accepts POST (I suggest just reusing a GET route) and add do_action('wp'); to your route callback. You could add it earlier if you like, like the rest_api_init hook. This will ensure that Gravity Forms gets

@rafpro
rafpro / Middleware.js
Created October 4, 2018 15:37 — forked from unbug/Middleware.js
Powerful Javascript Middleware Pattern Implementation, apply middleweares to any object. https://unbug.github.io/js-middleware/
'use strict';
/* eslint-disable consistent-this */
let middlewareManagerHash = [];
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
@rafpro
rafpro / Makefile
Created October 1, 2018 14:08 — forked from postmodern/Makefile
A generic Makefile for building/signing/install bash scripts
NAME=project
VERSION=0.0.1
DIRS=etc lib bin sbin share
INSTALL_DIRS=`find $(DIRS) -type d 2>/dev/null`
INSTALL_FILES=`find $(DIRS) -type f 2>/dev/null`
DOC_FILES=*.md *.txt
PKG_DIR=pkg
PKG_NAME=$(NAME)-$(VERSION)
@rafpro
rafpro / easing.js
Created September 28, 2018 09:30 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@rafpro
rafpro / default_fonts.css
Created September 26, 2018 09:35 — forked from praveensewak/default_fonts.css
Use browser based fonts
html {
font-family: sans serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;
letter-spacing: 0;
font-weight: 400;
@rafpro
rafpro / MySQL_macOS_Sierra.md
Created September 21, 2018 12:02 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :