Skip to content

Instantly share code, notes, and snippets.

View ryanscherler's full-sized avatar

Ryan Scherler ryanscherler

View GitHub Profile
@ryanscherler
ryanscherler / gitignore-wp.txt
Created February 17, 2014 05:01
.gitignore file for git-managed WordPress projects
# This is a .gitignore file for git-managed WordPress projects.
# Ignore everything in the root except the "wordpress" directory.
/*
!.gitignore
!wordpress/
# Ignore everything in the "wordpress" directory except the "wp-content" directory
wordpress/*
!wordpress/wp-content/
@ryanscherler
ryanscherler / .gitignore
Last active December 14, 2015 17:09
This is a template .gitignore file for git-managed WordPress projects. It ignores everything in the root except the theme you're working on.
# This is a template .gitignore file for git-managed WordPress projects.
# Ignores everything in the root except the theme you're working on.
/*
/*/
!/_tpl/
!/wordpress/
/wordpress/*
!/wordpress/wp-content
/wordpress/wp-content/*
@ryanscherler
ryanscherler / mixin-arrows.scss
Created May 23, 2013 19:33
SASS Mixin: Image-less Arrows
/*
* Arrow Mixin
*/
@mixin arrow($font-size: 1em, $color: $black, $hover-color: $white, $background-color: $white, $hover-background-color: $black) {
@include inline-block;
position: relative;
background: $background-color;
font-size: $font-size;
line-height: 1em;
@ryanscherler
ryanscherler / htaccess-compression-directive
Created August 11, 2013 23:25
Enable compression in .htaccess (adapted from HTML5 BP directives).
<FilesMatch "\.(js|css|html|htm|php|svg)$">
SetOutputFilter DEFLATE
</FilesMatch>
@ryanscherler
ryanscherler / .htaccess
Last active January 28, 2016 21:56
ProcessWire - Redirect site files to production server for local development.
# -----------------------------------------------------------------------------------------------
# Redirects all file requests that do not exist locally to the production server
# -----------------------------------------------------------------------------------------------
# Force local files that exist to be generated.
RewriteCond %{REQUEST_URI} ^/site/assets/files/[^\/]*/((.*))$
RewriteCond %{DOCUMENT_ROOT}/site/assets/files/%1/%2 -f
RewriteRule ^(.*)$ $1 [QSA,L]
# Otherwise, send anything else that's in the files directory to the production server.
@ryanscherler
ryanscherler / Instagram WP Transient
Created April 27, 2016 00:24
Gets Recent Instagrams and sets as WP transient.
<?php
namespace Starter\Extras;
function instagramUserMedia($token, $count = 6, $minutes = 5) {
$results = [];
$transient_key = __NAMESPACE__ . 'instagram';
if (!$results = get_transient($transient_key)) {
$ch = curl_init();
curl_setopt_array($ch, array(
@ryanscherler
ryanscherler / ip-geolocation.php
Last active July 5, 2016 19:46
Get approximate geo location from public IP.
<?php
$ip = file_get_contents('https://api.ipify.org');
$location = file_get_contents('http://freegeoip.net/json/'.$ip);
print_r($location)
@ryanscherler
ryanscherler / .gitignore
Last active August 4, 2016 19:04
Wordpress gitignore
# Ignore everything in the root except the "wordpress" directory.
/*
!.gitignore
!wordpress/
# Ignore everything in the "wordpress" directory, except the "wp-content" directory.
wordpress/*
!wordpress/wp-content/*
# Ignore everything in the "wp-content" directory, except the "themes" directory.
@ryanscherler
ryanscherler / Email.php
Created August 23, 2016 19:06 — forked from narfbg/Email.php
CodeIgniter Email.php with patch from gist 3870694 applied
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
* Licensed under the Open Software License version 3.0
*
@ryanscherler
ryanscherler / env.helper.php
Last active January 24, 2017 07:17
Gets the value of an environment variable. Supports boolean, empty and null.
<?php
if ( ! function_exists('env')) {
/**
* Gets the value of an environment variable. Supports boolean, empty and null.
*
* @author Taylor Otwell / Laravel
* @param string $key
* @param mixed $default
* @return mixed
*/