Skip to content

Instantly share code, notes, and snippets.

View alexphelps's full-sized avatar
🤔

Alex Phelps alexphelps

🤔
View GitHub Profile
@alexphelps
alexphelps / premailer.rb
Last active August 29, 2015 14:17
Jekyll Plugin for Premailer
require 'premailer'
module Jekyll
class Site
#declare plugin properties
#safe true
#priority :low
# create an alias for the overriden site::write method
alias orig_write write
@alexphelps
alexphelps / gist:5a2dfc2ca46341d9e172
Created April 6, 2015 03:01
Base Vagrant Ubuntu Starter File
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :private_network, ip: "192.168.22.100"
config.vm.provider :virtualbox do |vb|
@alexphelps
alexphelps / email.py
Last active September 24, 2015 13:29
Premailer Custom HTML Template
from django.conf import settings
from django.core.mail import EmailMessage,EmailMultiAlternatives
from django.template import Context, Template
from django.utils.html import strip_tags
from django.template.loader import get_template
from premailer import Premailer
from drip.drips import DripMessage
class DefaultDripEmail(DripMessage):
@alexphelps
alexphelps / dynamiclogomodel.py
Last active October 1, 2015 06:44
Django Dynamic Logo Resize and Background Fill
from PIL import Image
from django.db import models
from django.conf import settings
from imagekit import ImageSpec, register
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFit
@alexphelps
alexphelps / gravity-forms-scroll-fix.php
Last active October 20, 2015 08:55
Gravity Forms Validation Scroll Fix
/**
* Add this to your theme or wherever you feel comfortable.
* It will return the user to the form on the page when
* validation fails.
**/
if ( is_plugin_active( 'gravityforms/gravityforms.php') ){
add_filter( 'gform_confirmation_anchor', '__return_true' );
}
@alexphelps
alexphelps / global-unique-ids.php
Last active June 18, 2018 01:10
Gravity Forms Addon extend Gravity Perks Unique ID for Global Unique ID
<?php
/*
Plugin Name: Global Unique ID for Gravity Perks
Plugin URI: http://www.prontomarketing.com
Description: Adds the ability to set a starting ID for sequential Unique IDs.
Version: 0.1
Author: Pronto Marketing
Author URI: http://www.prontomarketing.com
*/
if (class_exists("GFForms")) {
@alexphelps
alexphelps / cleaned_uuid.py
Last active November 5, 2015 04:19
Cleaned UUID for Token
"""
Clean the dashes from a UUID to a create
a resonably acceptable API Token
"""
import uuid
uuidtoken = str(uuid.uuid4())
token = filter(lambda x: x != '-', uuidtoken)
@alexphelps
alexphelps / query.php
Last active December 18, 2015 04:23
Wordpress Query with Prepare
<?php
/**
* SQL query using $wpdb->prepare to protect it from sql injection
*/
private function get_users_pending( $user_id ) {
global $wpdb;
$the_post_type = 'post';
$status = 'pending';
return $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = %s AND post_status = %s AND post_author = %s ORDER BY post_modified DESC", $the_post_type, $status, $user_id ) );
}
@alexphelps
alexphelps / password-reset-tests.py
Last active January 3, 2016 08:30
Example Tests
class PasswordResetViewTest(TestCase):
fixtures = [
'auth_initial_data.json',
]
def setUp(self):
url = '/password/reset/'
self.url = url
@alexphelps
alexphelps / dj-stripe-settings.py
Created February 23, 2016 13:20
DJ Stripe Callback Settings
# settings.py
def account_request_callback(request):
return Account.objects.get(id=request.account_id)
DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK = account_request_callback