Skip to content

Instantly share code, notes, and snippets.

View johntimothybailey's full-sized avatar

John Bailey johntimothybailey

View GitHub Profile
@jstott
jstott / paginated.js
Created January 14, 2017 16:22
lodash paginated items
function getPaginatedItems(items, page, pageSize) {
var pg = page || 1,
pgSize = pageSize || 100,
offset = (pg - 1) * pgSize,
pagedItems = _.drop(items, offset).slice(0, pgSize);
return {
page: pg,
pageSize: pgSize,
total: items.length,
total_pages: Math.ceil(items.length / pgSize),
@johntimothybailey
johntimothybailey / jquery.append.js
Created April 29, 2012 21:21
Polyfills for jQuery to work in IE5.5
jQuery.fn.append = function( ) {
var element = this.get(0);
var appending = arguments[0];
if( appending.charAt(0) === "<" ){
throw Error("This appears to be a dom element represented as a string. Please create the element then append");
} else{
// Wonder if there is a better way to do this
element.innerHTML = element.innerHTML + appending;
}
};