Skip to content

Instantly share code, notes, and snippets.

@randomweapon
randomweapon / cron.sh
Last active August 29, 2015 14:19
WP-CLI cron bash script for Wordpress
#!/bin/bash
for EVENT_HOOK in $(cd /location/wordpress/ && /usr/local/bin/wp cron event list --format=csv --fields=hook,next_run_relative | grep now | awk -F ',' '{print $1}')
do
/usr/local/bin/wp cron event run $EVENT_HOOK
done
@randomweapon
randomweapon / fireConversionCode.js
Last active August 29, 2015 14:05
Google AdWords Conversion Tracking with jQuery
// accepts 1 parameter which is passed straight through to php file for determining which tracking code to display
function fireConversionCode( code )
{
// check to see if iframe is already created. We only want to create one iframe on the page, but can load multiple pixels
if ( $('#trackingFrame').length == 0 )
{
// create empty iframe
var iframe = $('<iframe id="trackingFrame" width="0" height="0">').css({"width":"0px","height":"0px"});
// append to end of document
@randomweapon
randomweapon / gist:2773235
Created May 23, 2012 04:15
Alternating row colours in objective-c (modulo)
for ( int i = 0; i < 5; i++ )
{
UIView *subview = [[UIView alloc] initWithFrame:CGRectMake(0, 44 * i, self.view.frame.size.width, 44)];
// this is where the magic is done. Check to see if the number is dividable by 2 (modulo)
if ( i % 2 == 1 )
{
subview.backgroundColor = [UIColor blackColor];
}
@randomweapon
randomweapon / validateUUID.cfm
Created May 22, 2012 01:07
Coldfusion function to validate a string to see if it is a UUID
<!---
Function Name : validateUUID()
Author : Ryan Spencer
Created : 13/02/2009
General Notes :
Function in :
uuid | string
@randomweapon
randomweapon / numberToLetter.cfm
Created May 22, 2012 01:06
coldfusion function to convert a number into a letter similar to how excel columns work.
<!---
Function Name : numberToLetter()
Author : Ryan Spencer
Created : 22/05/2012
General Notes : convert a number into a letter similar to how excell columns work.
Function in :
number (int)
@randomweapon
randomweapon / linuxDateTime.cfc
Created May 8, 2012 23:50
create linux date time in coldfusion as well as convert epoch time back to a coldfusion date.
<cfcomponent>
<!---
Function Name : linuxDateTime()
Author : Ryan Spencer
Created : 26/09/2008
General Notes : Returns the date from a Epoch Time format of seconds
since UTC January 1, 1970, 00:00:00 (Epoch time).
@randomweapon
randomweapon / csv.cfc
Created May 8, 2012 23:40
convert a CSV to query in coldfusion
<cfcomponent>
<cffunction name="csvToQuery">
<cfargument name="data" default="">
<cfargument name="cols" default="">
<cfargument name="delimiter" default=",">
<cfscript>