location /site1 {
alias /var/www/site1;
}
location /site2 {
alias /var/www/site2;
}
location /site3 {
alias /var/www/site3;
}
server {
root /var/www/html;
index index.html index.html;
server_name _;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /site1 { alias /var/www/site1; }
location /site2 { alias /var/www/site2; }
location /site3 { alias /var/www/site3; }
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires max;
log_not_found off;
}
location ~* \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Как сделать дамп базы данных PostgreSQL на локальный компьютер?
pg_dumpall -U user_name -c > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
scp -P 22 user@your-domain.ru:/home/user/path_to_file/this_file.tar ~/backup/this_file.tar
Edit (11/18/2016): GitHub no longer supports languages other than English.
Some DNS providers will only offer A records for root domains. Unfortunately, A records will not suffice for pointing your root domains to Heroku because they require a static IP. These records have serious availability implications when used in environments such as on-premise data-centers, cloud infrastructure services, and platforms like Heroku. Since Heroku uses dynamic IP addresses, it’s necessary to use a CNAME-like record (often referred to as ALIAS or ANAME records) so that you can point your root domain to another domain. See examples below.
heroku domains:add example.com
Adding example.com to ⬢ example-app... done
▸ Configure your apps DNS provider to point to the DNS Target
▸ whispering-willow-5678.herokudns.com.
▸ For help, see https://devcenter.heroku.com/articles/custom-domains
The domain example.com has been enqueued for addition
▸ Run heroku domains:wait 'example.com' to wait for completion
Note By default, the __hash__() values of str, bytes and datetime objects are “salted” with an unpredictable random value. Although they remain constant within an individual Python process, they are not predictable between repeated invocations of Python.
This is intended to provide protection against a denial-of-service caused by carefully-chosen inputs that exploit the worst case performance of a dict insertion, O(n^2) complexity. See www.ocert.org/advisories/ocert-2011-003.html for details.
Changing hash values affects the iteration order of dicts, sets and other mappings. Python has never made guarantees about this ordering (and it typically varies between 32-bit and 64-bit builds).
See also PYTHONHASHSEED.
Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers.
https://people.zoho.com/people/api/employee/counts?authtoken=<token>
{
"response": {
"message": "Success",
"result": {
"RecordCount": 3280
},
"status": 0,
"uri": "/api/forms/department/getRecordCount"
}
}
{
"records": [
{
"id": "1",
"msg": "Success"
},
{
"id": "2",
"msg": "Failed"
},
{
"id": "3",
"msg": "In progress"
},
{
"id": "4",
"msg": "Pending"
}
]
}
const obj = JSON.parse(...);
const recordsLength = Object.keys(obj.records).length;
API должно отдавать количество записей, не надо это делать на клиенте.
- 1 vCPU
- 2 Gb RAM
- 20 Gb SSD
- 20 Tb traffic
Такого хостинга хватит на несколько сайтов с небольшой нагрузкой,
и еще десяток ботов в придачу.
def test_send_message_with_markdown(self):
tb = telebot.TeleBot(TOKEN)
markdown = """
*bold text*
_italic text_
[text](URL)
"""
ret_msg = tb.send_message(CHAT_ID, markdown, parse_mode="Markdown")
assert ret_msg.message_id
bot.send_message(CHAT_ID, "*Здесь должен быть жирный шрифт*", parse_mode= "Markdown")
https://username.github.io/awesome-repo/?version=f36af92
Как скопировать файл с помощью Python?Зачем это делать Питоном?
scp -P 22 user@your-domain.ru:/home/user/projects/this_file.tar ~/backup/this_file.tar
*/30 * * * * /home/user/backup_data_from_server.sh
backup_data_from_server.sh
mv ~/backup/this_file.tar "/full_path_to/backup/this_file.tar.backup.$(date +%F_%R)"
sentence = ' hello Alice'
" ".join(sentence.split())
>>> 'hello Alice'
Return a copy of the string with all the cased characters converted to lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode Standard.
The "set" directive isn't something essential, and actually it is just a
directive from the rewrite module.
See here how it works:
nginx.org/en/docs/http/ngx_http_rewrite_module.html
It is evaluated on the rewrite phase of request processing. Thus, if
the request is finalized before this phase, then your variable is left
uninitialized.
To debug your locations and for better understanding what is going on,
you can use nginx debug log: nginx.org/en/docs/debugging_log.html
uninitialized_variable_warn off;
server {
if ($host = your-site.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name your-site.com;
return 404; # managed by Certbot
}
⚡ user@host ~ curl -I http://site.ru/about
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Mon, 29 Apr 2019 10:43:47 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://site.ru/about
X-XSS-Protection: 1; mode=block
HTTP/1.1 301 Moved Permanently
Location: https://site.ru/about
from django.views.generic.base import TemplateView
from articles.models import Article
class HomePageView(TemplateView):
template_name = "home.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['latest_articles'] = Article.objects.all()
return context
<h1>Articles</h1>
<ul>
{% for article in latest_articles %}
<li>{{ article.pub_date|date }} - {{ article.headline }}</li>
{% empty %}
<li>No articles yet.</li>
{% endfor %}
</ul>