Skip to content

Instantly share code, notes, and snippets.

View ericrallen's full-sized avatar
🎮
https://blog.dvdagames.com

Eric Allen ericrallen

🎮
https://blog.dvdagames.com
View GitHub Profile
@ericrallen
ericrallen / relative-date.php
Created January 22, 2013 22:47
Create an estimated relative date for any past date string via PHP.
<?php
/*--------------------------------------------------------------------------
This function accepts any date string that str_to_time() can handle
and returns a relative date string
It can account for seconds, minutes, days, weeks, months, years,
decades, centuries, and millenia
@ericrallen
ericrallen / gist:3220635
Created July 31, 2012 21:15
Remove "or Create An Account" from BigCommerce Sign In link but preserve Sign In/Sign Out functionality
//the next few lines strip "or Create an Account" from the log-in menu option
//I usually set the overall navigation to display:none; in my CSS if I know js is enabled
//I use Modernizr and check for the js class on the <html> tag with the style selector for my menu
//like: .js #navigation { display: none; }
//You'll want to add a class or ID to the <div> containing the log-in/log-out link
//usual output (with added ID):
//<li>
// <div id="log_in_options">
// <a onclick="" href="[url]">Sign in</a> or <a onclick="" href="[url]">Create an account</a>
@ericrallen
ericrallen / Developer Instagram Feed Output
Last active January 3, 2016 01:59
Using Developer Instagram Feed
<?php if(function_exists('DIF_get_user_images')) {
$test = DIF_get_user_images($user_id); //replace $user_id with the ID of the user you'd like to get the feed for
if($test) {
foreach($test as $image) {
echo '<pre>';
print_r($image);
echo '</pre>';
@ericrallen
ericrallen / config.ru
Created October 11, 2013 02:15
Commented out one line from the config.ru found at https://gist.github.com/brianpattison/4129846 because it was preventing CSS and JS from loading on my local WordPress sites.
# config.ru for Pow + Wordpress, based on http://stuff-things.net/2011/05/16/legacy-development-with-pow/
# added hackery to work around wordpress issues - Patrick Anderson (patrick@trinity-ai.com)
# clearly this could be cleaner, but it does work
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
# patch Php from rack-legacy to substitute the original request so
# WP's redirect_canonical doesn't do an infinite redirect of /
@ericrallen
ericrallen / xip.io.scpt
Last active December 25, 2015 03:18
copy xip.io URL for current project to clipboard
-- generates xip.io url with optional port
-- I store this script in my ~/bin directory and then use `ln -s ~/bin/xip.io.scpt` to create a symbolic link in the folder for my current project
-- Here's the funciton in my ~/.bashrc file:
-- function xipit() {
-- port=$@
-- if [ ! -f xip.io.scpt ]; then
-- ln -s ~/bin/xip.io.scpt;
-- fi
-- osascript xip.io.scpt $port;
@ericrallen
ericrallen / custom-ajax.php
Created March 29, 2013 08:32
Work in Progress for running custom wp_ajax actions
<?php
/*--------------------------------------------------------------------------
Better AJAX for WordPress
inspired by:
http:wordpress.stackexchange.com/questions/28342/is-there-a-way-to-use-the-wordpress-users-but-without-loading-the-entire-wordpre#answer-45011
--------------------------------------------------------------------------*/
@ericrallen
ericrallen / get-tweets-from-plugin.php
Created January 25, 2013 06:00
Pulls in Twitter feed from specific twitter WordPress plug-in for developers and converts links to anchor tags
<?php
/*--------------------------------------------------------------------------
This pulls in tweets gathered from the WordPress plugin
ouath-twitter-feed-for-developers and converts them into
an <article> tag
It takes retweets into account and then updates links within
the tweet text to convert urls, tags, and hashes into anchor
@ericrallen
ericrallen / [Wordpress] Twitter Search API with WP Transient Caching
Created October 4, 2012 20:34
Wordpress Twitter Search API simple integration with 2 levels of wp transient caching for fallback
<?php //get tweets
function get_tweets($s) {
$url = 'http://search.twitter.com/search.json?q=' . urlencode($s);
//set up var for holding tweets
$local_tweets = '';
//check for cache from 5 minutes ago
if(get_transient('bodyadorned_tweets_short')) {
$local_tweets = get_transient('bodyadorned_tweets_short');
//if it isn't found, try to update tweets
} else {
@ericrallen
ericrallen / sublime-text-2-scheme
Created August 21, 2012 22:59
My Sublime Text 2 Color Scheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>Crafted with love and passion by Bernat Fortet, special treatment for Front End coding: HTML, CSS, LESS, JADE, JS... more coming soon </string>
<key>author</key>
<string>Bernat Fortet</string>
<key>name</key>
<string>Bernat's FrontEnd Deligh</string>
@ericrallen
ericrallen / js-ua-checker
Created August 1, 2012 18:16
JavaScript UA Checker, modified from http://bit.ly/nMEXh4 to represent ipad, as well.
//check for mobile devices
//modified from http://bit.ly/nMEXh4
var ua = navigator.userAgent;
var checker = {
iphone: ua.match(/(iPhone|iPod)/),
ipad: ua.match(/(iPad)/),
blackberry: ua.match(/BlackBerry/),
android: ua.match(/Android/)