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
location / { | |
include uwsgi_params; | |
uwsgi_param SCRIPT_NAME ""; | |
uwsgi_pass 127.0.0.1:8003; | |
uwsgi_read_timeout 300; | |
} |
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.core.urlresolvers import RegexURLResolver | |
from django.contrib.auth.decorators import login_required | |
from django.conf.urls import patterns, include, url | |
from django.conf import settings | |
from django.contrib import admin | |
admin.autodiscover() | |
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
# Deep copy the *items* list of objects | |
items_list = [] | |
for item in items | |
items_list.push($.extend({}, item)) |
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 dateutil.relativedelta import relativedelta | |
# Calculate the relative timedelta | |
relative_delta = relativedelta(now_gmt, posted_time_gmt) | |
relative_time_format = { | |
'future' : 'in %s', | |
'past' : '%s ago', | |
's' : 'a few seconds', | |
'm' : 'a minute', |
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 | |
# how to use: | |
# Formset = inlineformset_factory(ParentModel, Model, ModelForm, \ | |
# formset=MinimumRequiredFormSet, extra=1, can_delete=True) | |
# instance = Formset(request.POST or None, instance=obj, prefix="prefix_form", \ | |
# minimum_forms=2, minimum_forms_message="At least two items are required.",) | |
class MinimumRequiredFormSet(forms.models.BaseInlineFormSet): | |
""" |
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
# * Add jquery support for checking if an element is in view | |
$.fn.inView = () -> | |
$win = $(window) | |
viewport = { | |
top: $win.scrollTop() | |
left: $win.scrollLeft() | |
} |
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
# Format count numbers depending on how they are: | |
# 1-999: 999 | |
# 1000+: 1K | |
# 1100+: 1.1K | |
# 10000+: 10K | |
# 100000+: 100K | |
# 1000000+: 1M | |
# 1100000+: 1.1M | |
window.format_count = (value)-> |
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
setSelectionRange: (input, selectionStart, selectionEnd)-> | |
if input.setSelectionRange | |
input.focus() | |
input.setSelectionRange(selectionStart, selectionEnd) | |
else if input.createTextRange | |
range = input.createTextRange() | |
range.collapse(true) | |
range.moveEnd('character', selectionEnd) |
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
window.abbreviate = (str, max, suffix) -> | |
# | |
# Trim leading and trailing white space | |
# | |
str = str.replace /^\s+|\s+$/g, "" | |
# | |
# If the string is less than max, return it | |
# |
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
usernames = ['@guillaumepiot','@lemans','@guillaumepiot'] | |
isUnique = (value, index, array)-> | |
array.indexOf(value) == index | |
console.log usernames.filter(isUnique) |