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
#! /usr/bin/env python | |
import timeit | |
class Divisors(): | |
""" Outputs dividends a specified range of divisors. | |
Prints 'PRIME' if number is prime. | |
Outputs other interesting data. | |
""" | |
def __init__(self): | |
upper_bounds = self.upper_bounds() |
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 el = $('video'), | |
maintain_aspect = function(){ | |
el.each(function(){ | |
var $width = $(this).innerWidth(), | |
$new_height = $width * .562; | |
$(this).css({'height' : $new_height}) | |
}) | |
}; | |
$(window).resize(function(){ |
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
class PickleFieldMixin(object): | |
"""Django PickleField CRUD Mixin. | |
Replace 'field' with PickleField field. | |
Replace 'model' with appropriate model containing \ | |
this mixin. | |
""" | |
def attr_create(self, key, value=None): | |
key = str(key) |
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
floor((i + (i-n)) / 2); n = total and i=1 |
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
$.fn.maintainAspect = function(cb){ | |
var el = this, | |
_maintain_aspect = function(el){ | |
var $width = el.parent().width(); | |
var $height = $width / 2.39; | |
el.attr('width', $width) | |
el.attr('height', $height) | |
//trigger callback |
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(){ | |
$('ul.primary').hover(function(){ | |
$(this).children('ul.secondary').stop(true, true).toggle(function(){ | |
}) | |
}) | |
}) |
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
<script> | |
(function($){ | |
//Adding inputFocus to namespace for the placeholder shim | |
$.fn.inputFocus = function(text){ | |
$(this).focusin(function(){ | |
if($(this).val() == text){ | |
$(this).val('') | |
} | |
}) | |
$(this).focusout(function(){ |
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 $footer_position = function(){ | |
if($(document).height() <= $(window).height()){ | |
$('footer').css({'position' : 'absolute', | |
'bottom' : '0px' | |
}) | |
}else{ | |
$('footer').css({'position' : 'static'}) | |
} | |
}; |
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
rom django import template | |
from django.conf import settings | |
register = template.Library() | |
# Usage: | |
# Define GOOGLE_ANALYTICS_CODE in your settings. | |
# In your base template put: {% google_analytics %} | |
@register.simple_tag | |
def google_analytics(): |
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
#credits - http://stackoverflow.com/questions/1057564/pretty-git-branch-graphs | |
lg1 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative | |
lg2 = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit | |
lg = !"git lg1" |
OlderNewer