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 ContentTypeForeignKey(models.ForeignKey): | |
def __init__(self, **kwargs): | |
if "choices" in kwargs: | |
kwargs["choices"] = self._process_choices(kwargs["choices"]) | |
# It is possible for `to` to be passed in with **kwargs. Since | |
# ContentType is hardcoded in for the `to` arg when calling super(), | |
# this can lead to problems. | |
if "to" in kwargs: | |
del kwargs["to"] |
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
/** | |
* rotator.js | |
* @author Chris Barna <chris@unbrain.net> | |
* Rotate images based on the date. | |
**/ | |
// Variables | |
var url = "rotation.cfm"; | |
var srcID = "#cs_control_9951781"; | |
var customPanelDivs = new Array("#cs_control_9963945", "#cs_control_9963960"); |
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
//Conditionally load jQuery | |
//inspired by http://www.smashingmagazine.com/2010/05/23/make-your-own-bookmarklets-with-jquery/ | |
window.onload = function () { | |
if (typeof jQuery == 'undefined') { | |
var jQ = document.createElement('script'); | |
jQ.type = 'text/javascript'; | |
jQ.onload = jQ.onreadystatechange = myOnLoadEvent; | |
jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js'; | |
document.body.appendChild(jQ); |
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
var gaParentDiv = ""; // Only change links in this selector including trailing space. | |
var trackingBase = "/ext/"; | |
$(parentDiv+"a[href^=http\\:\\/\\/]:not(a[href*=\\/"+document.domain+"])").click(function () { | |
pageTracker._trackPageview(trackingBase+$(this).attr("href")); | |
}); |
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
# Parse the FDNY average response time into JSON. | |
require 'rubygems' | |
require 'csv' | |
require 'json' | |
FILE = '../../Data/FDNY_monthly_response_time_001.TXT' | |
# Read the data | |
data = CSV.read(FILE, :col_sep => "\t", | |
:headers => true, :write_headers => false) |
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
# Download book covers from Amazon. | |
# Requires asin gem. | |
require 'net/http' | |
require 'asin' | |
client = ASIN::Client.instance | |
# Images Folder | |
IMG_DIR = "" | |
# API credentials |
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
# Shell script to install PARI/GP | |
VERSION=2.5.0 | |
URL=http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-$VERSION.tar.gz | |
DATE=`date +%s` | |
# Credit to http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in | |
DIR="$( cd "$( dirname "$0" )" && pwd )" | |
mkdir $DIR/tmp$DATE | |
cd $DIR/tmp$DATE |
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
# hw4prob1.r | |
# 2d ising model | |
hamiltonian <- function (E, J, sig, N) { | |
nearest_neighbor_sum = sum(sig[1:N-1,]*sig[2:N,], sig[,1:N-1]*sig[,2:N]) | |
return(-E * nearest_neighbor_sum - J * sum(sig)) | |
} | |
ising <- function (E, J, N, beta, iterations) { | |
number = N*N |
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
Number::toPaddedString = (radix, digits=2) -> | |
str = this.toString(radix) | |
while str.length < digits | |
str = "0" + str | |
str |
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
root = exports ? window | |
Number::toPaddedString = (radix, digits=2) -> | |
str = this.toString(radix) | |
while str.length < digits | |
str = "0" + str | |
str |
OlderNewer