Skip to content

Instantly share code, notes, and snippets.

View kgn's full-sized avatar

David Keegan kgn

View GitHub Profile
@kgn
kgn / ZipDir.py
Created October 5, 2010 03:04
Python function to zip up a directory and preserve any symlinks and empty directories.
import os
import zipfile
def ZipDir(inputDir, outputZip):
'''Zip up a directory and preserve symlinks and empty directories'''
zipOut = zipfile.ZipFile(outputZip, 'w', compression=zipfile.ZIP_DEFLATED)
rootLen = len(os.path.dirname(inputDir))
def _ArchiveDirectory(parentDirectory):
contents = os.listdir(parentDirectory)
@kgn
kgn / getElementsByClassName.js
Created October 6, 2010 06:13
Get html elements by class name.
/*
There are many scripts out there for this but
many of them use a regular expression with \b.
The problem with this is \b matches more then
white space, like '-'. So if you want to find
all elements with the class 'expando' elements
with 'expando-button' will be returned.
This function fixes this problem.
*/
@kgn
kgn / jquery.rollover.js
Created October 14, 2010 09:36
Assign a class to an element, or a child of the element on mouse over.
/*
Assign a class to an element, or a child of the element on mouse over.
$('#apps .header').rollover({
'className' : 'glow',
'childSelector' : 'h2',
});
*/
(function($){
@kgn
kgn / jquery.accordion.js
Created October 19, 2010 07:24
This is the accordion plugin developed for inscopeapps.com
(function($){
$.fn.accordion = function(options){
options = $.extend({
'header': 'h1', //The header that will be clicked
'content': 'div', //The content, this must be a sibling of the header
'showFirst': false, //If true the first item will be expanded on page load
'easing': null, //The easing style of the animation
//Called when the content will hide
'willHide': null,
@kgn
kgn / jquery.twitter.js
Created October 19, 2010 07:35
This is the twitter plugin developed for inscopeapps.com
(function($){
$.fn.twitter = function(options){
options = $.extend({
//twitter url variables
'screen_name': null, //required
'count': null,
//plugin variables
'displayCount': null, //number of posts to display, regardless of how many were pulled
'blockSource': null, //A search string to block the diaplay of posts based on what submitted them
@kgn
kgn / jquery.feed.js
Created October 19, 2010 07:50
This is the rss feed plugin developed for inscopeapps.com
(function($){
$.fn.feed = function(options){
options = $.extend({
'url': null, //required
'count': null,
'loadingImg': null
}, options);
var root = this;
@kgn
kgn / gist:638133
Created October 21, 2010 08:31
jQuery accordion plugin usage on inscopeapps.com
var $sidebar = $('#sidebar');
var easing = 'normal';
function showSidebar(header, content){
$.scrollTo(header, easing, function(){
var sidebarContent = $(content).siblings('.sidebar')[0];
if(sidebarContent){
//set the width to help slideDown figure out the correct height
$(sidebarContent).clone().width($sidebar.width()).setClass('separator').prependTo($sidebar).slideDown(easing);
}
@kgn
kgn / jquery.flipbook.js
Created November 29, 2010 07:22
jQuery plugin to display an animated image sequence.
//By David Keegan
//InScopeApps.com
//http://inscopeapps.com/demos/flipbook/
(function($){
$.fn.flipbook = function(options){
options = $.extend({
'start': 0, //start frame
'end': 100, //end frame, must be greater then start
'step': 1, //number of frames to step over while animating
@kgn
kgn / inset-shadow.html
Created December 10, 2010 00:29
An example of how to add an inset shadow on an img.
<!DOCTYPE HTML>
<html>
<head>
<title>Inset Shadow on Images</title>
<style type="text/css">
.inset-shadow{
-moz-box-shadow: 0 0 5px black inset;
-webkit-box-shadow: 0 0 5px black inset;
box-shadow: 0 0 5px black inset;
}
@kgn
kgn / Delegate.h
Created December 13, 2010 09:29
Objective-c delegate
@protocol MyControlDelegate;
@interface MyControl : NSObject
@property (nonatomic, weak) id<MyControlDelegate> delegate;
- (id)initWithDelegate:(id<MyControlDelegate>)aDelegate;
+ (id)objectWithDelegate:(id<MyControlDelegate>)aDelegate;
@end