Skip to content

Instantly share code, notes, and snippets.

View ryarwood's full-sized avatar

Russell Yarwood ryarwood

View GitHub Profile
@ryarwood
ryarwood / wordpress.gitignore
Last active August 29, 2015 14:17
Wordpress .gitignore
## OS and Utility Stuff ##
#==================#
# OS Files #
#==================#
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
@ryarwood
ryarwood / preloader.js
Last active February 16, 2016 23:05
Simple jquery based pre-loader
$(document).ready(function () {
"use strict"
//indexOf is not supported by IE9>.
if (!Array.prototype.indexOf){
Array.prototype.indexOf = function(elt /*, from*/){
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
@ryarwood
ryarwood / video.html
Created November 12, 2014 05:42
Quick Video Player
<div id="videoBoxList">
<ul>
<li><a href="javascript:showFeature('videoBox1','qFKHjfVz1IQ');" id="videoBox1"><span class="videoBoxNumber">Video No. 1</span><br />O'Neill Girls 2012</a></li>
<li><a href="javascript:showFeature('videoBox2','TeqdCYYvLAk');" id="videoBox2"><span class="videoBoxNumber">Video No. 2</span><br />O'Neill Kings of Freak</a></li>
<li><a href="javascript:showFeature('videoBox3','QvGZxMH9e2c');" id="videoBox3"><span class="videoBoxNumber">Video No. 3</span><br />Sofia Z Shoes</a></li>
<li><a href="javascript:showFeature('videoBox4','_MCcy3_sWcI');" id="videoBox4"><span class="videoBoxNumber">Video No. 4</span><br />O'Neill Womens Fall/Holiday 2014</a></li>
<li><a href="javascript:showFeature('videoBox5','7PiNTX9adZk');" id="videoBox5"><span class="videoBoxNumber">Video No. 5</span><br />Rob Rojas - A Paddlers Perspective</a></li>
<li><a href="javascript:showFeature('videoBox6','auM_-QglpnE');" id="videoBox6"><span class="videoBoxNumber">Video No. 6</span><br />O'Neill "End of
@ryarwood
ryarwood / upload_file.php
Last active January 1, 2021 20:42
Simple file upload example from Vandaele.
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
function ftp_uploaddirectory($conn_id, $local_dir, $remote_dir)
{
ftp_mkdir($conn_id, $remote_dir);
$handle = opendir($local_dir);
while (($file = readdir($handle)) !== false)
@ryarwood
ryarwood / functions.php
Created October 29, 2013 17:25
Remove links from images in Wordpress functions.php
add_filter( 'the_content', 'attachment_image_link_remove_filter' );
function attachment_image_link_remove_filter( $content ) {
$content =
preg_replace(
array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}',
'{ wp-image-[0-9]*" /></a>}'),
array('<img','" />'),
$content
);
@ryarwood
ryarwood / lts.php
Created July 19, 2013 16:56
LTS Email
<?php
require_once 'mime.php'; // fix path dummy!
$mail = array();
$mail['sender'] = $_POST['email'];
$mail['recipient'] = $_POST['communityEmail'];
$mail['subject'] = '--New Email Lead for '.$_POST['communityName'].'--';
$mail['header'] = sprintf("From: %s\n", $mail['sender']);
$mail['header'] .= sprintf("Reply-To: %s",$mail['sender']);
@ryarwood
ryarwood / shuffle.php
Created March 26, 2013 21:26
Shuffle array and spit out X number
/* set vars */
$numbers = range(1, 9);
shuffle($numbers);
$imgString = "/img/header-side-default";
/* loop */
foreach($numbers as $arr) {
$i++;
echo '<img src="'.$imgString.$arr.'.jpg" width="715" height="320" />';
if ($i == 3) break; /* change 3 to how many you want! */
@ryarwood
ryarwood / functions.php
Last active December 15, 2015 02:59
Load first post outside wordpress.
<?php
/**
* @package WordPress
* @subpackage p11news
*/
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'custom_trim_excerpt');
function custom_trim_excerpt($text) { // Fakes an excerpt if needed
@ryarwood
ryarwood / rss.php
Created March 1, 2013 19:29
Create RSS feed for easyphp calendar. Add rssfeed.php to root of calendar, then add rss.php to templates. Viola!
<!--head-->
<!--head-->
<!--body-->
<item>
<date>[date][time]</date>
<title>[title]</title>
<description><![CDATA[[descr]]]></description>
</item>
<!--body-->
<!--foot-->
@ryarwood
ryarwood / auto_increment.php
Last active December 13, 2015 18:28
Get next row for mysql query.
<?php
/* outputs array */
$query = "SHOW TABLE STATUS LIKE 'tablename'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
var_dump($row);
/* outputs number maybe :( */