This file contains hidden or 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
// center responsive image in fixed size element | |
.center-image(@width, @height) { | |
position: relative; | |
// make parent element width/height divisible by 2 | |
width: floor((@width + 0.5) / 2) * 2; | |
height: floor((@height + 0.5) / 2) * 2; | |
img { | |
display: block; | |
max-width: 100%; | |
max-height: 100%; |
This file contains hidden or 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
$ python -m serial.tools.list_ports | |
/dev/ttyACM0 |
This file contains hidden or 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.totalWidth = function() { | |
var totalWidth = 0; | |
this.each(function() { | |
totalWidth = totalWidth + $(this).width(); | |
}); | |
return totalWidth; | |
}; |
This file contains hidden or 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
alias watchless='watchr -e '\''require "date"; watch("(.*)\.less$") { |f| cmd = "lessc #{f[0]} --source-map #{f[1]}.css"; puts "#{DateTime.now}: #{cmd}"; output = `#{cmd}`; if $? != 0 then puts output end }'\''' |
This file contains hidden or 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
# custom/processors.py | |
from django.conf import settings | |
from django.core.files.storage import default_storage | |
try: | |
from PIL import Image | |
except ImportError: | |
import Image | |
This file contains hidden or 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.core.management import execute_from_command_line | |
execute_from_command_line(['', 'show_urls']) |
This file contains hidden or 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 template | |
register = template.Library() | |
@register.tag | |
def linkif(parser, token): | |
""" | |
Wraps everything between ``{% linkif %}`` and ``{% endlinkif %}`` inside | |
a ``link`` if ``link`` is not False. |
This file contains hidden or 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 feincms.admin.item_editor import FeinCMSInline | |
class AuthorContentTypeInline(FeinCMSInline): | |
# InlineModelAdmin options | |
raw_id_fields = ('author',) | |
class AuthorContentType(models.Model): | |
author = models.ForeignKey(Author) |
This file contains hidden or 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
""" | |
Metaclass example | |
>>> class MyKlass(Klass): | |
... my_field = Field() | |
... | |
... class Meta: | |
... model = "Model" | |
... | |
>>> MyKlass._meta.model |
This file contains hidden or 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
# ...in models.py | |
from django.dispatch import receiver | |
from rosetta.signals import post_save | |
@receiver(post_save) | |
def restart_server(sender, **kwargs): | |
import os | |
os.system("sleep 1 && echo \"Rosetta reload\" && touch %s &" % __file__) |