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 HistoryMixin(object): | |
| _diff_fields = set() | |
| _ignore_fields = set() | |
| _save_model = None | |
| _model_fk = None | |
| def save(self, *args, **kwargs): | |
| should_save = False | |
| saving_fields = {} |
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 AssignModelChoiceIterator(forms.models.ModelChoiceIterator): | |
| def choice(self, obj): | |
| return ( | |
| self.field.prepare_value(obj), | |
| self.field.label_from_instance(obj), obj) | |
| class AssignModelChoiceField(forms.ModelChoiceField): | |
| def _get_choices(self): | |
| if hasattr(self, '_choices'): |
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
| {% with items|length as item_count %} | |
| {% with ''|center:item_count as range %} | |
| {% for _ in range %} | |
| <li class="hscroll_list__item"> | |
| {% render_next 'simple_card_type_SPsA' %} | |
| </li> | |
| {% endfor %} | |
| {% endwith %} | |
| {% endwith %} |
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 cloneMore(selector, type) { | |
| var newElement = $(selector).clone(true); | |
| var total = $('#id_' + type + '-TOTAL_FORMS').val(); | |
| newElement.find(':input').each(function() { | |
| var name = $(this).attr('name').replace( | |
| '-' + (total - 1) + '-', '-' + total + '-'); | |
| var id = 'id_' + name; | |
| $(this).attr({'name': name, 'id': id}).val('').removeAttr('checked'); | |
| }); | |
| newElement.find('label').each(function() { |
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
| var rtn = sourceURL.split("?")[0], | |
| param, | |
| params_arr = [], | |
| queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : ""; | |
| if (queryString !== "") { | |
| params_arr = queryString.split("&"); | |
| for (var i = params_arr.length - 1; i >= 0; i -= 1) { | |
| param = params_arr[i].split("=")[0]; | |
| if (param === key) { | |
| params_arr.splice(i, 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
| window.addEventListener("click", function(e) { | |
| var href = e.target.getAttribute("href"); | |
| if (href) { | |
| href += (href.match(/\?/) ? '&' : '?'); | |
| location.href = href + "_st_userhash=" + docCookies.getItem('analytics-user'); | |
| e.preventDefault(); | |
| } | |
| }); |
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
| import inspect | |
| curframe = inspect.currentframe() | |
| calframe = inspect.getouterframes(curframe, 2) | |
| print calframe[1][2], calframe[1][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
| def get_key_borders(self, count): | |
| borders = [] | |
| cpu_count = CPU_COUNT | |
| while cpu_count: | |
| count = count - (count / cpu_count) | |
| borders.append(count) | |
| cpu_count -= 1 | |
| borders.sort() | |
| return borders |
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
| db['collection_name'].aggregate({$group: { _id: "$uuid"}}, {$group: { _id: 1, count: {$sum: 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
| def inject_app_defaults(application): | |
| """Inject an application's default settings""" | |
| try: | |
| __import__('%s.settings' % application) | |
| import sys | |
| # Import our defaults, project defaults, and project settings | |
| _app_settings = sys.modules['%s.settings' % application] | |
| _def_settings = sys.modules['django.conf.global_settings'] | |
| _settings = sys.modules['django.conf'].settings |
OlderNewer