Skip to content

Instantly share code, notes, and snippets.

View Riaan-ZA's full-sized avatar

Riaan Riaan-ZA

View GitHub Profile
@Riaan-ZA
Riaan-ZA / new_gist_file_0
Created December 5, 2013 11:49
Facebook get App access token
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
@Riaan-ZA
Riaan-ZA / new_gist_file
Created June 11, 2013 14:35
Jquery - Set all floated columns to height equal to highest column
$(document).ready(function() {
setHeight('.col');
});
var maxHeight = 0;
function setHeight(column) {
//Get all the element with class = col
column = $(column);
//Loop all the column
column.each(function() {
@Riaan-ZA
Riaan-ZA / gist:5626031
Created May 22, 2013 08:17
Validate youtube url's and embeds
<?php
function isValidYoutubeURL($url) {
// Let's check the host first
$parse = parse_url($url);
$host = $parse['host'];
if (!in_array($host, array('youtube.com', 'www.youtube.com'))) {
return false;
}
@Riaan-ZA
Riaan-ZA / gist:5540252
Created May 8, 2013 12:57
Facebook - tab template
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body style="overflow: hidden;">
<div id="fb-root"></div>
<script type="text/javascript">
@Riaan-ZA
Riaan-ZA / gist:5488276
Created April 30, 2013 12:00
SVN - Remove all deleted files from version control
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm %
@Riaan-ZA
Riaan-ZA / gist:4993890
Created February 20, 2013 08:23
Jquery Validate - Validate Phone number
$.validator.addMethod("phoneNumber", function(value, element) {
var filter = /^[0-9-+]+$/;
if (filter.test(value)) {
return true;
}
else {
return false;
}
}, "Please enter a valid phone number");
@Riaan-ZA
Riaan-ZA / gist:4024173
Created November 6, 2012 11:39
PHP: PHP5.2 date diff function
//Used for date difference calculations
function dateTimeDiff($date1, $date2) {
$alt_diff = new stdClass();
$alt_diff->y = floor(abs($date1->format('U') - $date2->format('U')) / (60*60*24*365));
$alt_diff->m = floor((floor(abs($date1->format('U') - $date2->format('U')) / (60*60*24)) - ($alt_diff->y * 365))/30);
$alt_diff->d = floor(floor(abs($date1->format('U') - $date2->format('U')) / (60*60*24)) - ($alt_diff->y * 365) - ($alt_diff->m * 30));
$alt_diff->h = floor( floor(abs($date1->format('U') - $date2->format('U')) / (60*60)) - ($alt_diff->y * 365*24) - ($alt_diff->m * 30 * 24 ) - ($alt_diff->d * 24) );
$alt_diff->i = floor( floor(abs($date1->format('U') - $date2->format('U')) / (60)) - ($alt_diff->y * 365*24*60) - ($alt_diff->m * 30 * 24 *60) - ($alt_diff->d * 24 * 60) - ($alt_diff->h * 60) );
$alt_diff->s = floor( floor(abs($date1->format('U') - $date2->format('U'))) - ($alt_diff->y * 365*24*60*60) - ($alt_diff->m * 30 * 24 *60*60) - ($alt_diff->d * 24 * 60*60) - ($al
@Riaan-ZA
Riaan-ZA / gist:4016096
Created November 5, 2012 08:55
PHP: Get full url
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
@Riaan-ZA
Riaan-ZA / gist:3082261
Created July 10, 2012 09:23
Facebook: Remove Scrollbars
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'ID_HERE',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
@Riaan-ZA
Riaan-ZA / gist:2972799
Created June 22, 2012 13:42
PHP: Validate and Clean inputs function
function validate_and_clean($value, $type = 'text') {
switch ($type) {
case 'text':
$value = filter_var($value, FILTER_SANITIZE_STRING);
$response = true;
break;
case 'email':
$value = filter_var($value, FILTER_SANITIZE_EMAIL);
if(filter_var($value01,FILTER_VALIDATE_EMAIL)) {