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.utils.translation import string_concat, ugettext_lazy | |
from django.utils.html import strip_tags | |
from haystack import indexes, site | |
from cms.models.managers import PageManager | |
from cms.models.pagemodel import Page | |
from cms.models.pluginmodel import CMSPlugin |
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 QuerySetDoubleIteration(Exception): | |
"A QuerySet was iterated over twice, you probably want to list() it." | |
pass | |
# "Skinny" here means we use iterator by default, rather than | |
# ballooning in memory. | |
class SkinnyManager(Manager): | |
def get_query_set(self): | |
return SkinnyQuerySet(self.model, using=self._db) |
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
def attach_foreignkey(objects, field, select_related=None): | |
""" | |
Shortcut method which handles a pythonic LEFT OUTER JOIN. | |
``attach_foreignkey(posts, Post.thread)`` | |
""" | |
field = field.field | |
qs = field.rel.to.objects.filter(pk__in=distinct(getattr(o, field.column) for o in objects)) | |
if select_related: | |
qs = qs.select_related(*select_related) |
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 tester = { | |
testing: [], | |
console: window.console || {log: function(a) {window.status = a}, warn: alert}, | |
defineBaseTests: function() { | |
this.baseTestBefore = [this.argumentsDefinedTest, this.thisBindingTest]; | |
this.baseTestAfter = [this.returnTest]; | |
}, | |
testAll: function(root, options) { |
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 import forms | |
from django.conf import settings | |
from cms.plugin_pool import plugin_pool | |
from cms.plugins.text.widgets.wymeditor_widget import WYMEditor | |
from cmsapp_news.models import NewsItem | |
class NewsForm(forms.ModelForm): | |
""" |
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
/* | |
* 1. Find a picture, open it, and disable your popup blocker | |
* 2. Enter the following into your address bar | |
* 3. ??? | |
* 4. Profit | |
*/ | |
javascript:function dr(e){h=e.height;w=e.width;var d=document.createElement("canvas");d.width=w;d.height=h;ct=d.getContext("2d");ct.drawImage(e,0,0);im=ct.getImageData(0,0,w,h);dt=im.data;a=(c=Math.ceil)(w/(z=30));a=2;b=[];str='<p style = "line-height:6px;font-size:6px;padding:0;">';for(j=0;j<c(h/a);j++){for(i=0;i<c(w/a);i++){t=[[],[],[],[]];for(y=j*a;y<(j+1)*a;y++){for(x=i*a;x<(i+1)*a;x++){t[0].push(dt[(pt=y*w*4+x*4)]);t[1].push(dt[pt+1]);t[2].push(dt[pt+2]);t[3].push(dt[pt+3])}}b.push(ls=[(sm=function(f){sg=0;for(id=0;id<f.length;id++){sg+=f[id]==undefined?0:f[id]}sg=c(sg/f.length);return sg>255?255:sg})(t[0]),sm(t[1]),sm(t[2]),sm(t[3])/256]);str+="<span style='background-color:rgba("+ls[0]+","+ls[1]+","+ls[2]+","+ls[3]+")'> </span>"}str+="<br>"}str+="</p>";return str}function dp(f){try{nw=window.open();nw.document.writeln(f)}catch(d){alert(d)}}images= |
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
/* | |
* 1. Find a picture, open it, and disable your popup blocker | |
* 2. Enter the following into your address bar | |
* 3. ??? | |
* 4. Profit | |
*/ | |
javascript:function dr(e){h=e.height;w=e.width;var d=document.createElement("canvas");d.width=w;d.height=h;ct=d.getContext("2d");ct.drawImage(e,0,0);im=ct.getImageData(0,0,w,h);dt=im.data;a=(c=Math.ceil)(w/(z=30));a=2;b=[];str='<p style = "line-height:6px;font-size:6px;padding:0;">';for(j=0;j<c(h/a);j++){for(i=0;i<c(w/a);i++){t=[[],[],[],[]];for(y=j*a;y<(j+1)*a;y++){for(x=i*a;x<(i+1)*a;x++){t[0].push(dt[(pt=y*w*4+x*4)]);t[1].push(dt[pt+1]);t[2].push(dt[pt+2]);t[3].push(dt[pt+3])}}b.push(ls=[(sm=function(f){sg=0;for(id=0;id<f.length;id++){sg+=f[id]==undefined?0:f[id]}sg=c(sg/f.length);return sg>255?255:sg})(t[0]),sm(t[1]),sm(t[2]),sm(t[3])/256]);str+="<span style='background-color:rgba("+ls[0]+","+ls[1]+","+ls[2]+","+ls[3]+")'> </span>"}str+="<br>"}str+="</p>";return str}function dp(f){try{nw=window.open();nw.document.writeln(f)}catch(d){alert(d)}}images= |
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
brew install git | |
brew update | |
brew install readline | |
brew link readline | |
brew install python | |
brew install postgres | |
brew install postgis | |
brew install gdal | |
brew install geos | |
brew install git |
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
# Offering alternative Chef + Vagrant Riak cluster setup to the following blog post at basho: | |
# http://blog.basho.com/2011/02/04/creating-a-local-riak-cluster-with-vagrant-and-chef/ | |
# Assumes Vagrant 0.7.0+ and VirtualBox 4.0+ | |
# Now you should be able to launch your X (where X=4 in this case) vagrant VMs with the following: | |
# % vagrant up db1 | |
# % vagrant up db2 | |
# % vagrant up db3 | |
# % vagrant up db4 |
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
.mouse, #preview{ | |
position: absolute; | |
background-repeat: no-repeat; | |
height: 22px; | |
min-width: 15px; | |
z-index: 100; | |
} | |
.mouse{ | |
background-image: url('../images/cursor.png'); |