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
;;; Problem solved, by subterfuge. | |
(defadvice rgrep (around rgrep-rename-previous-buffer activate compile) | |
"If a previous *grep* buffer exists, offer to rename it before | |
running the new process." | |
(interactive | |
(let ((old-grep-buf (get-buffer "*grep*"))) | |
(if (and old-grep-buf | |
(y-or-n-p "Grep results buffer already exists; rename it first? ")) | |
(let ((new-buf-name (read-string "New name: "))) | |
(with-current-buffer old-grep-buf |
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
(defvar *mh/lisp-base* (file-name-directory (file-truename user-init-file)) | |
"Base code directory; contains free-standing code and | |
subdirectories of other projects. Defaults to the directory | |
containing the user's initialisation file (including following | |
symlinks).") | |
(add-to-list 'load-path *mh/lisp-base*) | |
;;; site-specific customisations; for now, assume that this can be | |
;;; done by platform, since it's linux at work, OSX at home. Just | |
;;; name the file the same as is reported by system-type (#'load will |
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
from django.conf import settings | |
from django.contrib.auth.models import User | |
import cx_Oracle | |
class OracleBackend(object): | |
"""Authenticate by attempting to establish an oracle connection. | |
Uses the database from the settings. The django user module is | |
still used for management, just not authentication.""" | |
def authenticate(self, username=None, password=None): | |
try: |
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
(defadvice rec-fib (around rec-fib-memoize compile activate) | |
(let* ((memo-table (memo-table-for-symbol 'rec-fib)) | |
(arg (ad-get-arg 0)) | |
(result (gethash arg memo-table))) | |
(if result | |
(setq ad-return-value result) | |
ad-do-it | |
(puthash arg ad-return-value memo-table)))) |
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 re = /\d{6}/, | |
dt = re.exec(document.location.href)[0]; | |
var m = dt.slice(0,2), | |
d = dt.slice(2,4), | |
y = dt.slice(4); | |
y = y.charAt(0)==='0' ? '20'+y : '19'+y; | |
dt = newDate(y, parseInt(m,10)-1, d); | |
dt.setDate(dt.getDay()===5 ? dt.getDate()+3 : dt.getDate()+2); | |
y = dt.getFullYear().toString().slice(2); | |
m = dt.getMonth(); m++; m = m.toString(); |
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
jQuery.fn.log = function (msg) { | |
console.log("%s: %o", msg, this); | |
return this; | |
}; | |
// $('selector').log('BEGIN') | |
// .css('color', 'red') | |
// .log('new value') | |
// // etc |
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
// From here, with a few improvements (options classes argument, ability to pass plain text in): | |
// http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript | |
(function($) { | |
$.textMetrics = function(el, classes) { | |
var h = 0, w = 0; | |
var div = document.createElement('div'); |
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
// Clean up all those invasive and ugly utm_ parameters, so you can paste a url. | |
// (will reload the page, be warned) | |
(function(){ | |
var qs = window.location.search.slice(1).split('&'), | |
newqs = []; | |
for (var i = 0; i < qs.length; i++) { | |
if (qs[i].slice(0,4)!='utm_') { | |
newqs.push(qs[i]); | |
} | |
} |
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 $LL = (function($) { | |
var deferreds = {}; | |
return function(s, c) { | |
if (s in deferreds) { | |
deferreds[s].done(function(){ | |
c(); | |
}); | |
return; | |
} | |
deferreds[s] = $.Deferred(); |
OlderNewer