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
.flash-message { | |
border: 0; | |
color: #ffffff; | |
margin-bottom: 0; | |
position: fixed; | |
width: 100%; | |
top: 0; | |
left: 0; | |
z-index: 100000; | |
border-radius: 0; |
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
from ._base import db | |
from sqlalchemy.exc import IntegrityError, InterfaceError | |
from flask import flash | |
from sqlalchemy import event | |
from sqlalchemy.event import listen | |
from sqlalchemy.orm.interfaces import MapperExtension | |
from ..utils.redis import redis_store | |
from sqlalchemy import inspect | |
from sqlalchemy.ext.declarative import as_declarative, declared_attr | |
from pickle import dumps, loads |
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
-- We are dropping the foreign key constraint on dependant table (in other case it will prevent us from updating the values) | |
ALTER TABLE foo_table DROP CONSTRAINT fk_e52ffdeea76ed395; | |
-- Then, we're swapping values in foreign key column from id to another_id | |
UPDATE foo_table T SET user_id = (SELECT another_id FROM users WHERE id = T.user_id); | |
-- And finally we're creating new foreign key constraint pointing to the another_id instead of id | |
ALTER TABLE foo_table ADD CONSTRAINT fk_e52ffdeea76ed395 FOREIGN KEY (user_id) REFERENCES users (another_id) ON DELETE CASCADE; |
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
<script> | |
function defer(method) { | |
if (window.inputmask) // Important! Wait loading last script! | |
method(); | |
else | |
setTimeout(function() { defer(method) }, 50); | |
} | |
<script> | |
<script type="text/javascript" defer src="js/jquery-3.2.1.min.js"></script> | |
<script type="text/javascript" defer src="js/bootstrap-3.3.7.min.js"></script> |
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 i in `find /var/lib/nginx/cache -type f`; do rm $i ; done | |
or | |
find /var/lib/nginx/cache -type f -exec rm {} \; | |
# /var/lib/nbinx/cache -- path of the nginx cache |
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
<script> | |
z = document.getElementsByTagName('link').length | |
for (i = 0; i < z; i++) { | |
function loadStyleSheet(i){ | |
if (document.createStyleSheet) document.createStyleSheet(i); | |
else { | |
var stylesheet = document.createElement('link'); | |
stylesheet.href = i; | |
stylesheet.rel = 'stylesheet'; | |
stylesheet.type = 'text/css'; |
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 os | |
...: filelist=os.listdir('static/css/') | |
...: for fichier in filelist[:]: # filelist[:] makes a copy of filelist. | |
...: if not(fichier.endswith(".css")): | |
...: filelist.remove(fichier) | |
...: print(filelist) |
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 googlemaps | |
gmaps = googlemaps.Client(key='YOUR_API_KEY') | |
reverse_geocode_result = gmaps.reverse_geocode((53.9115621, 27.49615610000007)) | |
reverse_geocode_result # This is a list | |
reverse_geocode_result[0] # This is a dict |
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 is_paginated %} | |
<div class="pagination"> | |
<span class="page-links"> | |
{% if page_obj.has_previous %} | |
<a href="{% url 'cities:cities' %}?page={{ page_obj.previous_page_number }}">Предыдущая</a> | |
{% endif %} | |
<span class="page-current"> | |
страница {{ page_obj.number }} из {{ page_obj.paginator.num_pages }}. | |
</span> |
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
sudo lsof -t -i tcp:8000 | xargs kill -9 |
OlderNewer