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
""" | |
Mixed dict type: | |
""" | |
blog_posts = {"Blog disclamer": "Here you can create anything text, integers, lists etc.", | |
1: {"post_title": "Title1", "post_content": "Content1"}, | |
2: {"post_title": "Title2", "post_content": "Content2"}, | |
3: {"post_title": "Title3", "post_content": "Content3"}, | |
4: {"post_title": "Title4", "post_content": "Content4"}} | |
# let's print out our type just in case )) |
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 Price for one item in Cart page Ubercart 3 | |
* Autor: http://stackoverflow.com/a/11046318 | |
* [HOW TO USE] | |
* You can create additional module or add this code into your template.php, change 'YOUR_MODULE_NAME' into 'YOUR_THEME_NAME' | |
*/ | |
// Add 'Price' column in table Cart | |
function YOUR_MODULE_NAME_form_uc_cart_view_form_alter(&$form, &$form_state) { | |
$form['items']['#columns']['remove']['weight'] = 0; | |
$form['items']['#columns']['total']['weight'] = 5; |
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
# Encapsulation | |
class Human(): | |
# __private - переменная | |
__privateVar = "this is __private variable" | |
def __init__(self): | |
self.className = "Human class constructor" | |
self.__privateVar = "this is redefined __private variable" |
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
:: By DeN www.m5-web.com | |
@echo off | |
:: Hour | |
set year=%date:~-4% | |
:: Mounth | |
set mounth=%date:~-7,2% |
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
{% if paginator %} | |
<nav aria-label="pagination"> | |
<ul class="pagination justify-content-center"> | |
{% if blog_posts.has_previous %} | |
<li class="page-item"><a class="page-link" href="?page=1">Начало</a></li> | |
<li class="page-item"><a class="page-link" href="?page={{ blog_posts.previous_page_number }}">Назад</a></li> | |
{% if blog_posts.number >= 4 %} | |
<li class="page-item"><a class="page-link" href="?page=1">1</a></li> | |
<li class="page-item disabled"><a class="page-link" href="#">...</a></li> |
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
<!-- Звонок по логину пользователя: --> | |
<a href="skype:skype_login?call>Call to: skype_login</a> | |
<!-- Звонок на любой телефонный номер: --> | |
<a href="callto://+79880002266">Call to: +79880002266</a> |
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
# Redirect to https | |
@app.before_request | |
def before_request(): | |
if request.url.startswith('http://'): | |
url = request.url.replace('http://', 'https://', 1) | |
return redirect(url, code=301) |
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
# Redirect without WWW | |
from urllib.parse import urlparse, urlunparse | |
@app.before_request | |
def redirect_without_www(): | |
urlparts = urlparse(request.url) | |
if urlparts.netloc == 'www.YOUR-DOMAIN.com': | |
urlparts_list = list(urlparts) | |
urlparts_list[1] = 'YOUR-DOMAIN.com' | |
return redirect(urlunparse(urlparts_list), code=301) |
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
(function($) { | |
$(document).ready(function() { | |
// ... | |
}); | |
}(jQuery)); |
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.validators import MaxValueValidator, MinValueValidator | |
class SomeModel(models.Model): | |
# ... | |
posiitive_integer = models.PositiveIntegerField(verbose_name='Some amount from 0 to 100', help_text='from 0 to 100', validators=[MinValueValidator(0), MaxValueValidator(100)]) | |
# ... | |
OlderNewer