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 ExampleMiddleware: | |
def _init_(self, get_response): | |
self.get_response = get_response | |
def _call_(self, request): | |
# Код, вызываемый перед представлением при каждом запросе. | |
response = self.get_response(request) |
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
""" | |
Сопрограмма (англ. coroutine) — компонент программы, обобщающий понятие | |
подпрограммы, который дополнительно поддерживает множество входных точек | |
(а не одну, как подпрограмма), и остановку/продолжение выполнения с | |
сохранением определённого состояния. | |
Здесь показан пример такого шаблона использования сопрограмм, как | |
consumer-producer (потребитель-поставщик). | |
Суть задачи в том, чтобы одна сопрограмма поставляла объекты в буфер, |
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 { useParams, useLocation } from "react-router-dom"; | |
import React from 'react'; | |
const Profile = () => { | |
// Используйте хук useParams для получения имени пользователя из URL. | |
// Имя пользователя должно быть применено в качестве именованного параметра в маршруте. | |
let { username } = useParams(); | |
// useLocation применяется для захвата состояния из входных данных в объект. | |
// Так можно захватить каждое поле в объекте, используя то же имя, что и имя переменной. |
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 Post extends Component { | |
constructor(props){ | |
super(props); | |
this.state = {} | |
} | |
render(){ | |
// код пользовательского интерфейса | |
} | |
} |
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 Time extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {date: date: new Date()}; | |
} | |
render() { | |
return ( | |
<div> | |
<h1>It is {this.state.date.toLocaleTimeString()}</h1> |
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 Welcome extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {}; | |
} | |
render() { | |
return ( | |
<div> | |
<h1>Hello, world!</h1> |
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 React, { useState } from 'react'; | |
function Counter() { | |
// Определение переменной-счётчика | |
const [count, setCount] = useState(0); | |
return ( | |
<div> | |
<p>Вы нажали {count} раз</p> | |
<button onClick={() => setCount(count + 1)}> | |
Нажми меня |
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 React, {useState, useEffect} from 'react'; | |
function Example() { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
document.title = `Нажато ${count} раз`; | |
}); | |
} |
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
https://web.archive.org/web/20211114112811/https://gist.github.com/imgVOID/35e1c463ce187fac9f793e06a6688649 |
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 ctypes | |
import pathlib | |
if __name__ == "__main__": | |
# загрузка библиотеки | |
libname = pathlib.Path().absolute() / "libcadd.so" | |
c_lib = ctypes.CDLL(libname) | |
x, y = 6, 2.3 |