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 Person { | |
| private first_name: string; | |
| private last_name: string; | |
| private age: number; | |
| private is_married: boolean; | |
| constructor(fname:string, lname:string, age:number, married:boolean) { | |
| this.first_name = fname; | |
| this.last_name = lname; |
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
| # Empty strings are "falsy" (python 2 or python 3 reference), | |
| # which means they are considered false in a Boolean context, so you can just do this: | |
| if not myString: |
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
| with open('list.txt') as file: | |
| self.lines = [line.rstrip() for line in file.readlines()] |
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
| # Удалить словарь из списка: | |
| thelist[:] = [d for d in thelist if d.get('id') != 2] | |
| # Используя синтаксис thelist[:], мы можем сохранить ссылку на исходный список и избежать создания нового списка. | |
| # Это может быть полезно, если переменная thelist уже используется в других частях кода, и вы хотите обновить ее содержимое. |
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
| files = {'upload_file': open('file.txt','rb')} | |
| values = {'DB': 'photcat', 'OUT': 'csv', 'SHORT': 'short'} | |
| r = requests.post(url, files=files, data=values) |
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
| Простые свойства CSS могут помочь. Ниже приведено трехстрочное многоточие. | |
| display: -webkit-box; | |
| -webkit-line-clamp: 3; | |
| -webkit-box-orient: vertical; | |
| overflow: hidden; | |
| text-overflow: ellipsis; |
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 asyncio | |
| from pyppeteer import launch | |
| async def main(): | |
| browser = await launch() | |
| page = await browser.newPage() | |
| await page.goto('http://example.com') | |
| await page.screenshot({'path': 'example.png', 'fullPage': 'true'}) | |
| await browser.close() |
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
| function getTextWidth() { | |
| text = document.createElement("span"); | |
| document.body.appendChild(text); | |
| text.style.font = "times new roman"; | |
| text.style.fontSize = 16 + "px"; | |
| text.style.height = 'auto'; | |
| text.style.width = 'auto'; | |
| text.style.position = 'absolute'; | |
| text.style.whiteSpace = 'no-wrap'; |
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 LockIcon from "../assets/lock.svg" | |
| // and then render it as: | |
| <LockIcon color={theme.colors.text.primary} /> | |
| // and then in lock.svg I just add fill="currentColor" in the svg tag. | |
| /* | |
| Чтобы установить цвет иконки, указанный в пропсе color, в SVG-файле lock.svg, к тегу <svg> добавляется атрибут | |
| fill="currentColor". Значение currentColor означает, что цвет будет взят из текущего контекста, в данном случае | |
| он будет взят из переданного цвета color для компонента LockIcon. Таким образом, в итоге, иконка будет отображена |
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 math | |
| # Function to Parse Hexadecimal Value | |
| def parse_hex_color(string): | |
| if string.startswith("#"): | |
| string = string[1:] | |
| r = int(string[0:2], 16) # red color value | |
| g = int(string[2:4], 16) # green color value | |
| b = int(string[4:6], 16) # blue color value |