This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mdls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
k_regex = re.compile('{{\s*(\w+)\s*}}') | |
k_template = ''' | |
<html> | |
<head> | |
<title>{{ title }}</title> | |
</head> | |
<body> | |
{{content}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
cl = clone --recursive | |
un = reset --hard | |
st = status -s | |
aa = add --all | |
ci = commit -m | |
co = checkout | |
cob = checkout -b | |
br = branch | |
rbr = branch -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//borrowed from jQuery easing plugin | |
//http://gsgd.co.uk/sandbox/jquery.easing.php | |
$.easing.elasout = function(x, t, b, c, d){ | |
var s=1.70158, p=0, a=c; | |
if(t===0){return b;} | |
if((t/=d)===1){return b+c;} | |
if(!p){p=d*0.3;} | |
if(a < Math.abs(c)){a=c; s=p/4;}else{s = p/(2*Math.PI) * Math.asin(c/a);} | |
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modified from: http://ejohn.org/blog/javascript-pretty-date/ | |
(function($){ | |
$.prettyDate = function(time){ | |
var date = new Date((time || '')); | |
var diff = (((new Date()).getTime() - date.getTime())/1000); | |
var day_diff = Math.floor(diff / 86400); | |
if(diff === 0 || isNaN(day_diff) || day_diff < 0){ | |
return; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
import subprocess | |
def git(args, **kwargs): | |
environ = os.environ.copy() | |
if 'repo' in kwargs: | |
environ['GIT_DIR'] = kwargs['repo'] | |
if 'work' in kwargs: | |
environ['GIT_WORK_TREE'] = kwargs['work'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var styles, matches, match, url, img = new Image(), loaded = []; | |
function forEach(a,c){if(a&&c){for(var i=0;i<a.length;++i){c.call(a[i])}}}; | |
forEach(this.styleSheets, function(){ | |
forEach(this.rules, function(){ | |
forEach(styles=this.style, function(){ | |
if(this.toString() !== 'background-image')return; | |
if(!(matches=styles[this].match(/url\([^\)]+\)/g)))return; | |
forEach(matches, function(){ | |
if(!(match=this.match(/url\(([^\)]+)\)/)))return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSImage *croppedImageWithRect(NSImage *image, NSRect rect){ | |
NSImage *subImage = [[NSImage alloc] initWithSize:rect.size]; | |
NSRect drawRect = NSZeroRect; | |
drawRect.size = rect.size; | |
[subImage lockFocus]; | |
[image drawInRect:drawRect | |
fromRect:rect | |
operation:NSCompositeSourceOver | |
fraction:1.0f]; | |
[subImage unlockFocus]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)applicationWillTerminate:(NSNotification *)notification{ | |
[[NSStatusBar systemStatusBar] removeStatusItem:self.statusItem]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks to CuriousKea for getting this started! | |
// http://stackoverflow.com/a/8480325/239380 | |
- (void)scrollRowToVisible:(NSInteger)rowIndex animate:(BOOL)animate{ | |
if(animate){ | |
NSRect rowRect = [self rectOfRow:rowIndex]; | |
NSPoint scrollOrigin = rowRect.origin; | |
NSClipView *clipView = (NSClipView *)[self superview]; | |
scrollOrigin.y += MAX(0, round((NSHeight(rowRect)-NSHeight(clipView.frame))*0.5f)); | |
NSScrollView *scrollView = (NSScrollView *)[clipView superview]; |