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
/* | |
* BLANK jQuery Plugin | |
*/ | |
(function($) { | |
// replace pluginName to yours | |
$.fn.pluginName = function(opts) { | |
// extends default options to that of user-defined | |
var options = $.extend({}, $.fn.pluginName.defaults, opts); | |
// selector |
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 os | |
from django.conf import settings | |
PWD = os.path.dirname(os.path.dirname(__file__)) | |
### ... | |
DATABASES = { | |
### ... | |
'NAME': os.path.join(PWD, 'databasename.db'), # Or path to database file if using sqlite3. | |
### ... |
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. sudo apt-get install python-dev zlib1g-dev libjpeg62-dev libpng12-dev libfreetype6-dev | |
2. Download PIL Installer from http://www.pythonware.com/products/pil/ | |
3. Extract, cd, | |
4. sudo python setup.py install | |
5. Just wait. |
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
@mixin set-space($kind, $indicator, $selector) { | |
.#{$kind}-#{$indicator}-#{$selector} { | |
@if ($indicator == 'all') { | |
#{$kind}: ($selector / 16) + rem !important;; | |
} @else { | |
#{$kind}-#{$indicator}: ($selector / 16) + rem !important; | |
} | |
} | |
} |
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 sys | |
from django.conf import settings | |
settings.configure( | |
DEBUG=True, | |
SECRET_KEY='th15-15-4-53c123t-k3y', | |
ROOT_URLCONF=__name__, | |
MIDDLEWARE_CLASSES=( |
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
<!DOCTYPE html> | |
<html data-ng-app="app"> | |
<head> | |
<title>Test Select2</title> | |
<link rel="stylesheet" href="{{ STATIC_URL }}front/bower_components/select2/select2.css"> | |
</head> | |
<body> | |
<div data-ng-controller="MyController"> | |
{[{ apaAtuh }]} |
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
app.run(['$rootScope', '$location', function($rootScope, $location) { | |
$rootScope.$watch(function() { | |
return $location.path(); | |
}, function(a) { | |
$(document).foundation(); | |
$rootScope.flash_messages = []; | |
// FIX TOP BAR EXPANSION | |
$('.top-bar').removeClass('expanded').css({ | |
height: '' | |
}); |
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
MyModel.objects.aggregate(subtotal=Sum('qty', field='qty * price')) | |
'qty' ==> fill whatever you want | |
'qty * price' ==> the real aggregate | |
annotate is applicable too! | |
PS: |
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
# http://stackoverflow.com/questions/5360995/polymorphism-in-django-models | |
# http://stackoverflow.com/questions/929029/how-do-i-access-the-child-classes-of-an-object-in-django-without-knowing-the-nam/929982#929982 | |
from django.db import models | |
from django.contrib.contenttypes.models import ContentType | |
from django.db.models.query import QuerySet | |
class SubclassingQuerySet(QuerySet): | |
def __getitem__(self, k): |
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
fm1 = FakeModel.objects.create(name='Fake Name', event_date='2014-01-01 00:00:00') | |
then, in database, the event_date is '2013-12-31 17:00:00' | |
Django treats the date as current time zone, while SQL backend saves it as GMT |
OlderNewer