Skip to content

Instantly share code, notes, and snippets.

View ezrabrook's full-sized avatar

Ezra Brook ezrabrook

  • United States
  • 16:46 (UTC -04:00)
View GitHub Profile
@ezrabrook
ezrabrook / published-from-wp.sql
Created August 4, 2019 23:53
Grab all published posts from WP
select * from wp_posts
where post_status = 'publish'
and post_type = 'post'
@ezrabrook
ezrabrook / Add PDF or Doc to documents
Created July 21, 2014 13:47
Add icon to pdf, doc or any other file extension based on extension type.
/* Add PDF/Doc icons to Documents. */
String.prototype.endsWith = function (suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
$('.sub_content_area .sub_right a').each(function () {
if ($(this).attr("href")) {
var href = $(this).attr("href");
if (href.endsWith("xlsx") || href.endsWith("xls")) {
$(this).append('&nbsp;<img width="88" height="28" class="excel-icon" src="/sites/all/themes/hdfsresponsive/css/images/download_excel.png" />');
}
function hdfs_summarise($paragraph, $limit) {
$textfield = strtok($paragraph, " ");
while ($textfield) {
$text .= " $textfield";
$words++;
if (($words >= $limit) && ((substr($textfield, -1) == "!") || (substr($textfield, -1) == "."))) {
break;
}
$textfield = strtok(" ");
}
jQuery.extend(jQuery.fn.dataTableExt.oSort, {
"currency-pre" : function(a) {
a = (a === "-") ? 0 : a.replace(/[^\d\-\.]/g, "");
return parseFloat(a);
},
"currency-asc" : function(a, b) {
return a - b;
},
function aasort(&$array, $key){
$sorter = array();
$ret = array();
reset($array);
foreach($array as $ii =>$va){
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach($sorter as $ii=>$va){
$ret[$ii]=$array[$ii];
foreach ($mdarray as $key => $row) {
$dates[$key] = $row[0];
// of course, replace 0 with whatever is the date field's index
}
array_multisort($dates, SORT_DESC, $mdarray);