Skip to content

Instantly share code, notes, and snippets.

View byronrode's full-sized avatar

Byron Rode byronrode

View GitHub Profile
@byronrode
byronrode / morph-demo-countdown-timer.php
Created March 30, 2011 11:16
This function generates and returns static time remaining for Morph Demo refresh, based on current server time. To customize the output, edit the $time_remaining string.
<?php
function get_time_remaining($duration_in_hours){
$timestamp = time();
$current_minutes = date('i', $timestamp);
$current_seconds = date('s', $timestamp);
// pluralize hours, minutes and seconds
(($duration_in_hours - 1) == 1) ? $hours = ' hour ' : $hours = ' hours ';
((60 - $current_minutes) <= 01) ? $minutes = ' minute ' : $minutes = ' minutes ';
@byronrode
byronrode / twitter.platform.js.markdown
Created May 17, 2011 08:10
Twitter Intents over SSL

Serving Twitter's JS for Intents or Tweet Button's is a pain when it comes to SSL as Twitter has no SSL Cert installed on their serving subdomain. To get around this, without having to manually maintain the JS, I came up with the following workaround.

Create a file called twitter.platform.js.php in your JS Folder and paste the following:

<?php
header('Content-type: text/javascript'); 
echo file_get_contents('http://platform.twitter.com/widgets.js');
?>
@byronrode
byronrode / update_timthumb.sh
Created September 20, 2011 12:31
Update TimThumb across your Server
#!/bin/bash
# Fix TimThumb
# The following will replace any versions of timthumb.php or thumb.php across your server.
# Change the folder to match your server's setup.
# If you have made any modifications, or have any additional allowed hosts in your current
# TimThumb file they will be updated, so make sure you have those changes backed up.
wget -q -O /tmp/new_timthumb.php http://timthumb.googlecode.com/svn/trunk/timthumb.php
find /var/www/vhosts/ -name "thumb.php" -exec bash -c "echo Replacing file {} && cp /tmp/new_timthumb.php {}" \;
@byronrode
byronrode / custom_field_shortcode.php
Created March 22, 2012 07:55
Adding this to your functions.php will allow you to use custom field values in your post via short code.
<?php
/*
@description: Adding this to your functions.php will allow you to use custom field values in
your post via shortcode. Useful for when you need to add javascript to a post.
@usage: [custom_field name="name_of_custom_field"]
@returns: Custom Field Value
@author: Byron Rode
@license: Free to use, modify, whatever.
*/
@byronrode
byronrode / SendToThings.scpt
Created April 28, 2012 01:12
Create To Do in Things
on perform_mail_action(info)
set selectedMessages to |SelectedMessages| of info
tell application "Mail"
repeat with eachMessage in selectedMessages
set theSubject to the subject of the eachMessage
set theContent to the content of the eachMessage
set tid to AppleScript's text item delimiters
@byronrode
byronrode / header.php
Created May 14, 2012 07:07
LESS for WP
<?php
require 'modules/lessphp/lessc.inc.php';
try {
lessc::ccompile(get_stylesheet_directory() . '/style.less', get_stylesheet_directory() . '/style.css');
} catch (exception $ex) {
exit('lessc fatal error:<br />'.$ex->getMessage());
}
?>
@byronrode
byronrode / update_product_variations.sql
Created June 28, 2012 14:38
Update product variations using MySQL.
UPDATE wp_postmeta as pm, wp_posts as p
SET pm.meta_value = 500 /* <new price> */
WHERE pm.post_id = p.ID
AND p.post_type = 'product_variation'
AND pm.meta_key = '_price'
AND pm.meta_value = 1000 /* <old price> */
AND p.post_status = 'publish';
@byronrode
byronrode / custom.css
Created April 10, 2013 07:48
How to overwrite CSS in a child theme or custom CSS file. Here I want to change the background colour and colour of an element with the class of "my_cool_css_class".
/* Parent CSS file*/
.my_cool_css_class {background:#fff;border-radius:5px;box-shadow:1px 1px 2px #000;color:#ff2361;padding:0px 10px;line-height:25px;height:25px;width:100%;}
/* This is WRONG. Very WRONG. */
/* Child Theme or Custom CSS file */
.my_cool_css_class {background:#2d2d2d;border-radius:5px;box-shadow:1px 1px 2px #000;color:#fff;padding:0px 10px;line-height:25px;height:25px;width:100%;}
/* This is RIGHT. Very RIGHT. */
/* Child Theme or Custom CSS file */
.my_cool_css_class {background:#2d2d2d;color:#fff;}
@byronrode
byronrode / gist:5753022
Created June 10, 2013 22:34
Allows developer/client only customization previews with WordPress.
<?php
/*
*
* @author: Byron Rode
* @description: Allows developer/client only customization previews with WordPress. Uses a simple
* cookie to handle previews, so don't go showing sensitive data. PS. I am NOT responsible
* if you do.
* @license: Free as in Beer
*
*/
@byronrode
byronrode / gist:a7a2c1b45d306a2edb3f
Last active August 29, 2015 14:03
Textmate 2 and Tabs (Admin Privileges)
set transmitCleanup to "/Users/byronrode/Library/Caches/Cleanup At Startup/Transmit/"
do shell script "mkdir -p '" & transmitCleanup & "' | touch '" & transmitCleanup & ".tm_properties'" with administrator privileges
do shell script "echo 'projectDirectory = \"$CWD\"' > '" & transmitCleanup & ".tm_properties'"