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
| for k, field in form.fields.items(): | |
| field.widget.attrs.update({"class": "special"}) | |
| if 'class' in field.widget.attrs: | |
| classes = field.widget.attrs['class'].split() | |
| classes = [cls for cls in classes if cls != 'is-valid'] | |
| field.widget.attrs['class'] = ' '.join(classes) |
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 HtmxPage(Page): | |
| def get_context(self, request): | |
| context = super().get_context(request) | |
| context['base_template'] = "partial.html" if request.htmx else "base.html" | |
| return context | |
| class Meta: | |
| abstract = True |
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_context(self, request, *args, **kwargs): | |
| context = super().get_context(request, *args, **kwargs) | |
| # Add extra variables and return the updated context. E.g. | |
| #context['blog_entries'] = BlogPage.objects.child_of(self).live() | |
| return context |
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 timeit | |
| import csv | |
| import pandas as pd | |
| filename = '../datasets/data.tsv' | |
| def talktime(filename, funcname, func): | |
| print(f"# {funcname}") | |
| t = timeit.timeit(f'{funcname}("{filename}")', setup=f'from __main__ import {funcname}', number = 100) / 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 Exception - All exception object's default descriptions | |
| try: | |
| error | |
| except Exception as e: | |
| print("error: \t", e) | |
| print("type: \t", type(e)) | |
| print("message: \t", repr(e)) | |
| print("error args: \t", e.args) | |
| print("error class: \t", e.__class__) | |
| print("class name: \t", e.__class__.__name__) |
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
| <?php | |
| /* Source file to be downloaded */ | |
| $source = "https://releases.wikimedia.org/mediawiki/1.30/mediawiki-1.30.0.tar.gz"; | |
| //$source = "http://www.question2answer.org/question2answer-latest.zip"; | |
| /* temporary zip file location for extraction */ | |
| $filename = 'file.tar.gz'; | |
| /* destination folder */ |
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 pandas as pd | |
| dataset_path_movies = '/movies.list.gz' | |
| dataset_path_keywords = '/keywords.list.gz' | |
| dataset_path_genres = '/genres.list.gz' | |
| dataset_path_ratings = '/ratings.list.gz' | |
| print("Opening Keyword File.") | |
| cols_keywords = ['movie', 'keyword'] |
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
| <?php | |
| if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser | |
| header('Location: ../'); | |
| exit; | |
| } | |
| require_once '../oc-load.php'; | |
| require_once '../oc-includes/osclass/helpers/hUsers.php'; | |
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
| {% if movies.has_other_pages %} | |
| <div class="paginator-container"> | |
| <ul class="pagination"> | |
| {% if movies.has_previous %} | |
| <li><a href="?page=1"><i class="fa fa-angle-double-left"></i></a></li> | |
| <li><a href="?page={{ movies.previous_page_number }}"><i class="fa fa-angle-left"></i></a></li> | |
| {% else %} | |
| <li class="disabled"><a href="?page=1"><i class="fa fa-angle-double-left"></i></a></li> | |
| <li class="disabled"><a href="?page=1"><i class="fa fa-angle-left"></i></a></li> | |
| {% endif %} |
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
| # CMD | |
| python manage.py shell | |
| #SHELL | |
| from django.contrib.auth.models import User | |
| users = User.objects.all() | |
| #get an id for user based on output | |
| print(users) | |
| user = users[0] |
NewerOlder