location ~ \.(png|jpg)$ {
error_page 404 /404.png;
}
location /images/ {
try_files $uri /images/default.jpg;
}
location = /images/default.jpg {
expires 30s;
}
import math
def is_smooth(my_list: list):
my_list_max_index = len(my_list) - 1
a = my_list[math.ceil(my_list_max_index / 2)]
b = my_list[math.floor(my_list_max_index / 2)]
if a == my_list[0] and b == my_list[my_list_max_index]:
return True
if a + b == my_list[0] and a + b == my_list[my_list_max_index]:
return True
return False
http {
upstream cluster {
# simple round-robin
server 192.168.0.1:80;
server 192.168.0.2:80;
check interval=5000 rise=1 fall=3 timeout=4000;
#check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;
#check interval=3000 rise=2 fall=5 timeout=1000 type=http;
#check_http_send "HEAD / HTTP/1.0\r\n\r\n";
#check_http_expect_alive http_2xx http_3xx;
}
server {
listen 80;
location / {
proxy_pass http://cluster;
}
location /status {
check_status;
access_log off;
allow SOME.IP.ADD.RESS;
deny all;
}
}
}
This module is available as part of our commercial subscription.
import React from 'react';
import {Div, Group, Panel, View} from '@vkontakte/vkui';
import '@vkontakte/vkui/dist/vkui.css';
class App extends React.Component {
constructor(props) {
super(props);
this.videoRef = React.createRef();
this.handleVideo = this.handleVideo.bind(this);
this.videoError = this.videoError.bind(this);
}
handleVideo(stream) {
this.videoRef.current.srcObject = stream;
}
videoError = (err) => {
alert(err.name)
}
componentDidMount() {
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
if (navigator.getUserMedia) {
let constraints = {
audio: false,
video: {facingMode: 'environment'}
};
navigator.mediaDevices.getUserMedia(constraints)
.then(this.handleVideo)
.catch(this.videoError)
}
}
render() {
return (
<View activePanel="mainPanel" header={false}>
<Panel id="mainPanel">
<Group>
<Div>
<video ref={this.videoRef} style={{width: '100%'}} playsInline autoPlay muted/>
</Div>
</Group>
</Panel>
</View>
);
}
}
export default App;
Сейчас в основе приложений сообществ — JavaScript SDK. Однако чтобы оставаться на острие технологий и унифицировать разработку всей экосистемы ВКонтакте, мы приняли решение отказаться от JavaScript SDK в пользу VK Connect.
С 1 марта приложения, которые интегрированы с платформой через JavaScript SDK, перестанут работать. В каталоге будут размещены только приложения, использующие VK Connect.
class MyModelAdmin(admin.ModelAdmin):
readonly_fields = ('id',)
admin.site.register(MyModel, MyModelAdmin)
В гугле есть один,
Почему в двумерном массиве каждый подмассив становится копией другого
Assignment statements in Python do not copy objects, they create bindings between a target and an object. For collections that are mutable or contain mutable items, a copy is sometimes needed so one can change one copy without changing the other. This module provides generic shallow and deep copy operations (explained below).
new_list = old_list.copy()
# или
new_list = old_list[:]
import copy
new_list = copy.deepcopy(old_list)
Как отключить проверку SSL в телеграмм боте?
import boto3
from botocore.exceptions import ClientError
def upload_file(file_name, bucket, object_name=None):
"""Upload a file to an S3 bucket
:param file_name: File to upload
:param bucket: Bucket to upload to
:param object_name: S3 object name. If not specified then file_name is used
:return: True if file was uploaded, else False
"""
# If S3 object_name was not specified, use file_name
if object_name is None:
object_name = file_name
# Upload the file
s3_client = boto3.client('s3')
try:
response = s3_client.upload_file(file_name, bucket, object_name)
except ClientError as e:
logging.error(e)
return False
return True
import logging
import boto3
from botocore.exceptions import ClientError
def create_presigned_url(bucket_name, object_name, expiration=3600):
"""Generate a presigned URL to share an S3 object
:param bucket_name: string
:param object_name: string
:param expiration: Time in seconds for the presigned URL to remain valid
:return: Presigned URL as string. If error, returns None.
"""
# Generate a presigned URL for the S3 object
s3_client = boto3.client('s3')
try:
response = s3_client.generate_presigned_url('get_object',
Params={'Bucket': bucket_name,
'Key': object_name},
ExpiresIn=expiration)
except ClientError as e:
logging.error(e)
return None
# The response contains the presigned URL
return response