@TestFlightX · Post #35138 · 07.04.2026 г., 17:12
#Steam Mobile https://testflight.apple.com/join/8BOPXsGz
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #121 · 20 јул.
Регулярно требуется преобразовать какой-либо текст в максимально совместимый текст для URL, имени файла, имени объекта в каком-то софте и тд. Требования совместимости простые: в тексте должны быть только допустимые символы. Обычно это a-z, 0-9 и "_" или "-". То есть, только прописные буквы латинского алфавита и цифры (как пример). Допустим, нам нужно название статьи в блоге преобразовать в slug для добавления его в URL этой статьи. Как это лучше всего сделать? В Django по умолчанию есть готовая функция slugify для таких случаев. Но я её никогда не использую. Почему? Потому что её недостаточно! Приведём пример >>> from django.utils.text import slugify >>> slugify('This is a Title') 'this-is-a-title' Пока всё отлично >>> slugify('This is a "Title!"') 'this-is-a-title' Спец символы удалились, всё хорошо. >>> slugify('Это заголовок статьи') '' Вот и приехали 😢. Если текст не английский то буквы просто игнорируются. Можно это поправить >>> slugify('Это заголовок статьи', allow_unicode=True) 'это-заголовок-статьи' Но тогда мы не вписываемся в условие. У нас появилась кириллица в тексте. Так как я часто пишу сайты для русскоязычных пользователей эта проблема весьма актуальна. Я не использую стандартную функцию и всегда пишу свою. Оригинал я не беру в расчёт и пишу полностью свою функцию. И так, по порядку: 🔸1. Исходный текст: >>> text = 'Мой заголовок №10 😁!' Взял специально посложней со специальными символами. 🔸2. Транслит Необходимо сделать транслит всех символов в латиницу. Здесь очень выручает библиотека unidecode. Помимо простого транслита кириллицы в латиницу она умеет преобразовывать спец символы и иероглифы в текстовые аналоги. from unidecode import unidecode >>> unidecode("Ñ Σ ® µ ¶ ¼ 月 山") 'N S (r) u P 1/4 Yue Shan' Очень крутая библиотека, советую👍 В нашем случае получаем такое преобразование: >>> text = unidecode(text) >>> print(text) 'Moi zagolovok No. 10 !' Отличный транслит. Смайл просто удалился, хотя я ждал что-то вроде :). Ну и ладно, всë равно невалидные символы. А еще наш код уже поддерживает любой язык, будь то хинди или корейский. 🔸4. Фильтр символов Unidecode не занимается фильтрацией по недопустимым символам. Это мы делаем в следующем шаге через regex. Просто заменим все символы на "_" если они вне указанного диапазона. >>> text = re.sub(r'[^a-zA-Z0-9]+', '_', text) >>> print(text) 'Moi_zagolovok_No_10_' Символ "+" в паттерне выручает когда несколько недопустимых символов идут рядом. Все они заменяются на один символ "_". 🔸5. Slugify Осталось удалить лишние символы по краям и сделать нижний регистр >>> text = text.strip('_').lower() >>> print(text) 'moi_zagolovok_no_10' Получаем отличный slug! 😎 🌎 Полный код в виде функции. ______________ PS. Проверку что в строке остался хоть один допустимый символ я бы вынес в отдельную функцию. #libs#tricks#django
Пребарај: #steam
@TestFlightX · Post #35138 · 07.04.2026 г., 17:12
#Steam Mobile https://testflight.apple.com/join/8BOPXsGz
Hashtags
@ParadoxW98 · Post #24067 · 12.02.2025 г., 22:47
Steam发布公告:禁止在游戏中植入干扰玩家体验的广告 开发者不应该使用付费广告作为游戏内的业务模式,例如要求玩家观看广告或以其他方式参与广告才能玩游戏,或是用广告来限制游戏内容。 🗒 标签: #Steam
Hashtags
@linuxgram · Post #18771 · 13.05.2026 г., 09:59
📰 Unreal Engine 5.8 adds experimental Steam Frame support, Qualcomm give the Steam Frame a dedicated page Valve's new VR kit the Steam Frame appears to be inching closer to a release announcement - here's two more fun bits of news on it for you.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/05/unreal-engine-5-8-adds-experimental-steam-frame-support-qualcomm-give-the-steam-frame-a-dedicated-page/ #steam
Hashtags
@linuxgram · Post #18567 · 25.04.2026 г., 16:12
📰 Your Gen 5 SSD is probably throttling right now, and you have no idea You paid a premium for 14,000 MB/s speeds, but during a large Steam download or 4K video export, it feels like your PC is struggling to keep up and overall just comes across quite mushy. Unlike a CPU, which might trigger a loud fan spike, an SSD suffers in silence, making it hard for you to identify when it is actually occurring. 🔗 Source: https://www.xda-developers.com/your-pcie-50-ssd-might-be-throttling-without-you-knowing/ #steam
Hashtags
@linuxgram · Post #18465 · 16.04.2026 г., 22:16
📰 Proton 11.0 Beta Released With More Games Playable On Steam Play Valve and CodeWeavers have just released Proton 11.0 Beta as their first beta milestone for this software that powers Steam Play now rebased against upstream Wine 11.0... 🔗 Source: https://www.phoronix.com/news/Proton-11.0-Beta #steam
Hashtags
@linuxgram · Post #18297 · 03.04.2026 г., 13:59
📰 Valve recently confirmed Steam game pricing updates across different regions At the end of March, Valve issued an announcement to game developers on Steam about changes to how games get priced across different regions.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/04/valve-recently-confirmed-steam-game-pricing-updates-across-different-regions/ #steam
Hashtags
@linuxgram · Post #18285 · 02.04.2026 г., 15:05
📰 SteamOS 3.8 just dramatically improved a lot of handhelds except the Steam Deck itself The Steam Deck just saw one of its biggest updates enter the preview phase, and if you're on the Preview update channel, then chances are you've already updated it. After such a major update, you might realize that not much has changed, though. SteamOS 3.8 is, by all accounts, one of Valve's most important updates yet. It expands compatibility, improves performance, and lays the groundwork for something much bigger than a handheld. 🔗 Source: https://www.xda-developers.com/steamos-38-dramatically-improves-many-gaming-handhelds-except-steam-deck/ #steam
Hashtags
@linuxgram · Post #18119 · 20.03.2026 г., 07:36
📰SteamOS 3.8.0 is finally making the Steam Machine a reality The first glimpse of the Steam Machine's release date is on the horizon. 🔗 Source: https://www.xda-developers.com/steamos-380-is-finally-making-the-steam-machine-a-reality/ #steam
Hashtags
@linuxgram · Post #18057 · 13.03.2026 г., 23:43
📰 New Steam Release Fixes Proton Games Wrongly Flagged as Unplayable Also includes opt-in frame rate telemetry, hardware-tagged reviews, and several quality-of-life improvements. 🔗 Source: https://feed.itsfoss.com/link/24361/17298791/steam-client-march-2026-release #steam
Hashtags
@linuxgram · Post #17987 · 05.03.2026 г., 22:17
📰 Theme park building game Parkitect gets its first ever Steam Free Weekend Parkitect is an absolute gem and if you've not played this theme park builder before - well, now is your best chance because it's free for a while.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/03/theme-park-building-game-parkitect-gets-its-first-ever-steam-free-weekend/ #steam
Hashtags
@linuxgram · Post #17846 · 20.02.2026 г., 12:19
📰 Steam Deck now out of stock in Europe in addition to USA, Canada and Asia Unfortunately the stock availability of the Steam Deck has only worsened recently, with Europe now appearing to be completely out of stock.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/02/steam-deck-now-out-of-stock-in-europe-in-addition-to-usa-canada-and-asia/ #steam
Hashtags
@linuxgram · Post #17810 · 17.02.2026 г., 16:02
📰Valve confirm Steam Deck stock issues due to "memory and storage shortages" We reported recently how the Steam Deck was completely out of stock in the USA, Canada and Asia and now Valve have put up a short statement on it.Read the full article on GamingOnLinux. 🔗 Source: https://www.gamingonlinux.com/2026/02/valve-confirm-steam-deck-stock-issues-due-to-memory-and-storage-shortages/ #steam
Hashtags