// jQuery
$(document).ready(function() {
// code
})
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
| function isOnScreen(elem) { | |
| // if the element doesn't exist, abort | |
| if( elem.length == 0 ) { | |
| return; | |
| } | |
| var $window = jQuery(window) | |
| var viewport_top = $window.scrollTop() | |
| var viewport_height = $window.height() | |
| var viewport_bottom = viewport_top + viewport_height | |
| var $elem = jQuery(elem) |
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
| /* | |
| * Project: | |
| * Description: | |
| * Author: | |
| * License: | |
| */ | |
| // the semi-colon before function invocation is a safety net against concatenated | |
| // scripts and/or other plugins which may not be closed properly. | |
| ;(function ($, window, document, undefined) { |
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
| <script type='text/javascript'>//<![CDATA[ | |
| $(function(){ | |
| ;(function( $, window ) { | |
| var _defaults = { | |
| x : 2, // number of tiles in x axis | |
| y : 2, // number of tiles in y axis | |
| random : true, // animate tiles in random order | |
| speed : 2000 // time to clear all times | |
| }; |
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 datetime import datetime, timedelta | |
| print (datetime(*(datetime.now() + timedelta(days=1)).timetuple()[:3]) - datetime.now()).seconds |
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.filter | |
| def cool_number(value, num_decimals=2): | |
| """ | |
| Django template filter to convert regular numbers to a | |
| cool format (ie: 2K, 434.4K, 33M...) |
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.db import models | |
| class Person(models.Model): | |
| name = models.CharField(max_length=200) | |
| groups = models.ManyToManyField('Group', through='GroupMember', related_name='people') | |
| class Meta: | |
| ordering = ['name'] | |
| def __unicode__(self): |
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.db import models | |
| from django.contrib.auth.models import User | |
| class Profile(models.Model): | |
| user = models.OneToOneField(User, on_delete=models.CASCADE) | |
| bio = models.TextField(max_length=500, blank=True) | |
| location = models.CharField(max_length=30, blank=True) | |
| birth_date = models.DateField(null=True, blank=True) | |