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
$.fn.followTo = function (pos) { | |
var $this = this, | |
$window = $(window); | |
$window.scroll(function (e) { | |
if ($window.scrollTop() > pos) { | |
$this.css({ | |
position: 'absolute', | |
top: pos | |
}); |
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
class CacheGroup(object): | |
ttl = 3600 | |
initial = 1 | |
group = '' | |
def __init__(self, group, ttl): | |
self.group = group | |
self.ttl = ttl | |
def key(self, key): |
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
tree_already_apended = [] | |
tree_childs_key = 'childs' | |
data = [ | |
dict( | |
id=1, | |
parent=None | |
), | |
dict( | |
id=2, | |
parent=1 |
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
class ExtjsTreeResource(ExtJsModelResource): | |
max_limit = 1000 | |
cache_group = '' | |
cache_ttl = 3600 | |
cache_url_params = ['offset', 'page', 'limit', 'node'] | |
tree_parent_key = '' | |
tree_childs_key = 'childs' | |
tree_id_key = 'id' | |
def prepend_urls(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
class UsualCustomResourceTestCase(CustomResourceTestCase): | |
tested_object = None | |
resource_object = None | |
resources = None | |
created_stack = [] | |
generated_numbers = [] | |
exclude_fields = ['created', 'modified'] | |
exclude_ignore_fields = ['name', ] | |
username = 'dmitri' | |
password = '12345' |
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
def str_replace_multi(string, replacements, empty_if_list=True): | |
try: | |
iterator = repls.iteritems() | |
except: | |
if isinstance(replacements, (list, tuple)): | |
first = iter(replacements) | |
second = ['']*len(replacements) if empty_if_list else\ | |
first | |
iterator = dict(zip(first, second)) | |
else: |
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
# bash | |
alias rr=". ~/.bash_profile" | |
alias ..="cd .." | |
alias ...="cd ../.." | |
alias ....="cd ../../.." | |
alias .....="cd ../../../.." | |
alias ......="cd ../../../../.." | |
alias c=clear | |
function freem() { |
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
# pluralize for russian language | |
# {{someval|rupluralize:"товар,товара,товаров"}} | |
@register.filter(is_safe = False) | |
@stringfilter | |
def rupluralize(value, arg): | |
bits = arg.split(u',') | |
try: | |
value = str( 0 if not value or value <= 0 else value )[-1:] # patched version | |
return bits[ 0 if value=='1' else (1 if value in '234' else 2) ] | |
except: |
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 MYMODULE_form_node_admin_content_alter(&$form, &$form_state, $form_id) { | |
$column_alias = 'my_cool_column'; | |
$column_title = 'Header of my cool column'; | |
// Load the nodes. This incurrs very little overhead as | |
// "$nodes = node_load_multiple($nids);" has already been run on these | |
// nids in node_admin_nodes(). The static cache will be used instead of | |
// another db query being invoked | |
$nodes = node_load_multiple(array_keys($form['admin']['nodes']['#options'])); |