Skip to content

Instantly share code, notes, and snippets.

View kjantzer's full-sized avatar
👨‍💻
Likely writing JavaScript

Kevin Jantzer kjantzer

👨‍💻
Likely writing JavaScript
View GitHub Profile
@kjantzer
kjantzer / PubSub.js
Created September 10, 2012 20:37
PubSub.js - Simple Publish/Subscribe "Class"
/*
Lightweight PUBLISH / SUBSCRIBE Class
Original code from: <http://blog.bobcravens.com/2011/01/loosely-coupled-javascript-using-pubsub/>
Can be initialized on other Objects to provide pub/sub functionality within that object
ex: this.events = new PubSub();
*/
@kjantzer
kjantzer / jquery.sortableWithIndexWatch.js
Created September 19, 2012 17:00
jQuery sortableWithIndexWatch - modified jquery ui sortable widget to store before and after index of moved item
// custom Sortable widget - gets before and after index of moved item
// https://gist.github.com/3750782
$.widget("ui.sortableWithIndexWatch", $.extend({}, $.ui.sortable.prototype, {
_trigger: function() {
switch(arguments[0]){
case 'start':
this.currentItem.indexStart = this.currentItem.index();
@kjantzer
kjantzer / underscore.move.js
Created October 29, 2012 16:50
Underscore.js Mixin: Move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
/*
_.move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
*/
_.mixin({
move: function (array, fromIndex, toIndex) {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
return array;
}
@kjantzer
kjantzer / FilterView.js
Last active October 22, 2021 20:41
Backbone.js: FilterView – extendable View for adding filtering/searching to a view
/*
FilterView
@author Kevin Jantzer, Blackstone Audio Inc.
@since 2012-11-06
Filter by Presets and user typed Terms. If filtered by a preset,
search term will filter within the preset filtered collection
USE:
@kjantzer
kjantzer / InfiniteListView.js
Last active October 22, 2021 20:41
Backbone.js: Infinite Scrolling List View
/*
Infinite List View
creates <ul> with triggers for infinite scrolling
@author Kevin Jantzer, Blacktone Audio Inc.
@since 2012-11-06
USE - listen for:
@kjantzer
kjantzer / .htaccess
Created November 26, 2012 04:44
.htaccess for WordPress when moving it to a different directory
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Base is the URL path of the home directory
RewriteBase /
RewriteRule ^$ wordpress/index.php [L]
# Skip real files and directories
RewriteCond %{REQUEST_FILENAME} !-f
@kjantzer
kjantzer / DB.php
Created November 30, 2012 15:49
PHP MySQL Database Class
<?php
/*
Database Class
this class should be extended (see DBCore.php) to be made
into a singleton class
@author Kevin Jantzer, Blackstone Audio Inc.
@since 2012-04-20
@kjantzer
kjantzer / gist:4227244
Last active October 13, 2015 16:58
Slim Class static method init
/*
Catch-all Static methods when they are not explicitly defined
if the method name is prefixed with "slim_", we will instansiate the called class
and attempt to call the method name with the prefix stripped off
ex: "slim_transcode_task" becomes "transcode_task"
it is designed to be used with the SLIM api
ex: $app->get('/book/:book_id/baker/trascode', 'Baker::slim_transcode_task');
@kjantzer
kjantzer / SortableCollection.js
Last active October 13, 2015 20:07
Backbone.js: sortable collection
var SortableCollection = Backbone.Collection.extend({
//key: 'LocalStorageKey', // define a key for saving sort info to local storage
//defaultSort: 'some_key', // the default key to sort by
defaultDesc: false,
localStoreKey: function(extra){
return 'list:'+this.key+(extra?':'+extra:'');
@kjantzer
kjantzer / Swipe Controls with Backbone.js and Hammer.md
Created December 13, 2012 19:26
Backbone.js: Swipe Controls

Swipe Controls with Backbone.js

Requires

Hammer.js