Skip to content

Instantly share code, notes, and snippets.

@devig
devig / uniq.py
Created May 16, 2025 12:43
Оставляем только уникальные строки
import sys
import os
def extract_unique_lines(input_file):
seen = set()
unique_lines = []
total_lines = 0
with open(input_file, 'r', encoding='utf-8') as f:
for line in f:
@devig
devig / allforms.py
Last active May 16, 2025 12:41
Генерация всевозможных словоформ из списка слов (минус-слов)
import pymorphy2
import os
import sys
def is_russian(word):
return all('а' <= ch <= 'я' or ch == 'ё' for ch in word)
def get_word_forms(word, morph):
parses = morph.parse(word)
word_forms = set()
@devig
devig / filter.py
Last active May 16, 2025 12:41
Фильтрация фраз по списку минус-слов
import re
import sys
from pathlib import Path
def load_words(words_file):
words_set = set()
with open(words_file, encoding='utf-8') as f:
for line in f:
word = line.strip()
# Удаляем начальные -, ", !
import torch
from transformers import AutoTokenizer, pipeline, AutoModelForCausalLM
import time
def custom_chat_template(chat):
# This template concatenates role and content, each on new line
return "\n".join(f"{turn['role']}: {turn['content']}" for turn in chat)
def generate_response(system_prompt, user_prompt):
try:
# Конфигурация для HTTP-сервера
server {
# Указываем доменное имя
server_name new-automation.ru;
# Путь к корневой директории сайта
root /var/www/opencart/public_html;
# Указываем, какие файлы должны обрабатываться при запросе корня сайта
index index.php index.html
@devig
devig / .htaccess
Created May 24, 2023 10:33
htaccess redirect www to non-www https and from index.html
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On
#Если у Вас переход на index.html:
@devig
devig / main.go
Created April 3, 2023 05:32
Check if struct implemented interface
package main
import (
"fmt"
)
type Foo interface {
bar(name string)
}
@devig
devig / nginx.conf
Created February 17, 2022 22:05 — forked from morhekil/nginx.conf
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@devig
devig / main.go
Last active January 15, 2022 11:45
Gorose ORM
package main
import (
"fmt"
"os"
"github.com/gohouse/gorose/v2"
_ "github.com/go-sql-driver/mysql"
)
var err error
@devig
devig / tree.php
Last active July 23, 2020 13:57
jiaxincui/closure-table
<?php
$menu = \App\Menu::find(1);
$menu->getDescendantsAndSelf();
$menu = \App\Menu::find(3);
$menu->getAncestorsAndSelf();
$menu = \App\Menu::find(1);
dd($menu->getTree());