Skip to content

Instantly share code, notes, and snippets.

View jasontucker's full-sized avatar

Jason Tucker jasontucker

View GitHub Profile
@jasontucker
jasontucker / htaccessdynamic.sh
Created September 16, 2012 19:17
htaccessdynamic.sh
#!/bin/bash
## Example:
## /bin/sh ~/htaccessdynamic.sh myhostname.dyndns-remote.com ~/infinatewp.mydomain.com/.htaccess
dynDomain="$1"
htaccessLoc="$2"
dynIP=$(/usr/bin/dig +short $dynDomain)
echo "dynip: $dynIP"
@jasontucker
jasontucker / gist:3757446
Created September 20, 2012 18:09
How to use your Gravatar as a favicon
//saw this on WpRecipes.com
function GravatarAsFavicon() {
//We need to establish the hashed value of your email address
$GetTheHash = md5(strtolower(trim('you@yourdomain.com')));
echo 'http://www.gravatar.com/avatar/' . $GetTheHash . '?s=16';
}
//in the header.php use this:
@jasontucker
jasontucker / gist:3780458
Created September 25, 2012 07:30
filter oembed for wmode transparent youtube video
<?php
function add_video_wmode_transparent($html, $url, $attr) {
if (strpos($html, "<embed src=" ) !== false) {
$html = str_replace('</param><embed', '</param><param name="wmode" value="transparent"></param><embed wmode="transparent" ', $html);
return $html;
} else {
return $html;
}
}
add_filter('embed_oembed_html', 'add_video_wmode_transparent', 10, 3);
@jasontucker
jasontucker / gist:3837819
Created October 5, 2012 03:02
Protect a site using a dyndns host and htaccess.
#!/bin/bash
## Crontab Example:
## #*/3 * * * * /bin/sh ~/htaccessdynamic.sh whatevermydyndnsis.dyndns-remote.com ~/domainiwanttoprotect.com/.htaccess > /dev/null 2>&1
dynDomain="$1"
htaccessLoc="$2"
dynIP=$(/usr/bin/dig +short $dynDomain)
@jasontucker
jasontucker / gist:3856670
Created October 9, 2012 04:47
WPwatercooler at 11 to 11:30am autoplay
<script type="text/javascript">
var now = new Date(),
day = now.getDay(),
hour = now.getHours();
//Check if day is Mon
if(0 = day) {
//check between 11am and 11:30am
if(11 <= hours <= 00) {
if(hours !== 11 || now.getMinutes() <= 30) {
@jasontucker
jasontucker / gist:3856679
Created October 9, 2012 04:50
Modify iFrame code to autoplay on Mondays, later I'll narrow it down to 11:00 11:30am
var $j = jQuery.noConflict();
function changeYoutube() {
$j('iframe').each(function () {
var that = $j(this);
var href = that.attr('src');
if (href.search('youtube.com') != -1) {
that.attr('src', href + '&autoplay=1');
@jasontucker
jasontucker / output.txt
Created October 16, 2012 20:42 — forked from mckabi/get_full_RTers.php
Get all of RTers by tweet
<?php
/*
* 공식 트위터 사이트에서는 트윗을 RT한 사람 목록을 볼 수가 있는데
* 숫자가 조금만 많아도 줄여서 보여주기 때문에 모두 확인하기가 어렵다.
*
* 트위터 API를 써서 모두 확인하는 방법
*/
$tweet_id = '101450759463383041'; // 트위터 사이트에서 트윗한 시간을 누르면 확인 가능
@jasontucker
jasontucker / updateip.php
Created October 26, 2012 19:32
Update single ip address from dyndns into the allowed IP address of InfiniteWP
<?php
// Install this file in the infiniteWP folder, name it something
// obscure then have cron run ever 3 mins to update the db to the latest IP.
// Add the following to cron, this will update the ip address every 3 minutes.
//
// */3 * * * * /usr/local/bin/php /home/username/infinitewp/updateip.php
// What is your dyndns hostname?
@jasontucker
jasontucker / gist:3981492
Created October 30, 2012 16:52
Disable “enter” key in your forms
$("#form").keypress(function(e) {
if (e.which == 13) {
return false;
}
});
//Source: http://www.catswhocode.com/blog/10-awesome-jquery-snippets
@jasontucker
jasontucker / gist:3981500
Created October 30, 2012 16:53
Clear form data - jQuery
//Need to clear all form data? Here’s a handy function to do it.
function clearForm(form) {
// iterate over all of the inputs for the form
// element that was passed in
$(':input', form).each(function() {
var type = this.type;
var tag = this.tagName.toLowerCase(); // normalize case
// it's ok to reset the value attr of text inputs,
// password inputs, and textareas