Обновить
0
0
Дмитрий@Robomanus

Пользователь

Отправить сообщение

Да, один ваш промт на английском. Платный да. Не gpt, а Claude. Возможно с одной итерации не сделать, нужно несколько подходов.

Я пытался=) Но это был не gpt 5, а Claude sonnet 4.5.

# Makefile for 7z extractors

CXX = g++
CXXFLAGS = -std=c++14 -O2 -Wall

# Path to 7-Zip SDK (adjust this to your SDK location)
SEVENZ_SDK = ./p7zip

# For bit7z approach (simpler)
bit7z: simple_extractor_bit7z.cpp
	$(CXX) $(CXXFLAGS) simple_extractor_bit7z.cpp -o extract_bit7z -lbit7z -ldl
	@echo "Built extract_bit7z - Usage: ./extract_bit7z <archive> <output_dir>"

# For direct 7z.so approach (more complex, requires 7-Zip SDK headers)
direct: simple_7z_extractor.cpp
	$(CXX) $(CXXFLAGS) -I$(SEVENZ_SDK) simple_7z_extractor.cpp -o extract_direct -ldl
	@echo "Built extract_direct - Usage: ./extract_direct <archive> <output_dir>"

clean:
	rm -f extract_bit7z extract_direct

.PHONY: bit7z direct clean

Команды

// Simple 7z.so extractor - compile with: g++ -std=c++11 simple_7z_extractor.cpp -o extract7z -ldl
#include <iostream>
#include <string>
#include <dlfcn.h>
#include <sys/stat.h>
#include <sys/types.h>

// 7-Zip SDK header includes (you need these from p7zip or 7-Zip source)
#include "CPP/7zip/Archive/IArchive.h"
#include "CPP/7zip/IPassword.h"
#include "CPP/Common/MyCom.h"
#include "CPP/Windows/PropVariant.h"
#include "CPP/Common/MyString.h"
#include "CPP/7zip/Common/FileStreams.h"

using namespace NWindows;

// GUID for 7z format
#define CLSID_Format {0x23170F69, 0x40C1, 0x278A, {0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00}}

// Extract callback class
class CArchiveExtractCallback : 
    public IArchiveExtractCallback,
    public ICryptoGetTextPassword,
    public CMyUnknownImp
{
public:
    MY_UNKNOWN_IMP2(IArchiveExtractCallback, ICryptoGetTextPassword)
    
    // IProgress
    STDMETHOD(SetTotal)(UInt64 size);
    STDMETHOD(SetCompleted)(const UInt64 *completeValue);
    
    // IArchiveExtractCallback
    STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode);
    STDMETHOD(PrepareOperation)(Int32 askExtractMode);
    STDMETHOD(SetOperationResult)(Int32 resultEOperationResult);
    
    // ICryptoGetTextPassword
    STDMETHOD(CryptoGetTextPassword)(BSTR *password);

private:
    CMyComPtr<IInArchive> _archiveHandler;
    UString _directoryPath;
    UString _filePath;
    COutFileStream *_outFileStreamSpec;
    CMyComPtr<ISequentialOutStream> _outFileStream;

public:
    void Init(IInArchive *archiveHandler, const UString &directoryPath);
    UInt64 NumErrors;
    
    CArchiveExtractCallback() : NumErrors(0) {}
};

void CArchiveExtractCallback::Init(IInArchive *archiveHandler, const UString &directoryPath)
{
    NumErrors = 0;
    _archiveHandler = archiveHandler;
    _directoryPath = directoryPath;
}

STDMETHODIMP CArchiveExtractCallback::SetTotal(UInt64 /* size */)
{
    return S_OK;
}

STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeValue */)
{
    return S_OK;
}

STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
{
    *outStream = nullptr;
    _outFileStream.Release();
    
    // Get archived file name
    NCOM::CPropVariant prop;
    RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
    
    UString fullPath;
    if (prop.vt == VT_EMPTY)
        fullPath = L"[Content]";
    else
    {
        if (prop.vt != VT_BSTR)
            return E_FAIL;
        fullPath = prop.bstrVal;
    }
    
    _filePath = _directoryPath + fullPath;
    
    if (askExtractMode != NArchive::NExtract::NAskMode::kExtract)
        return S_OK;
    
    // Check if it's a directory
    NCOM::CPropVariant prop2;
    RINOK(_archiveHandler->GetProperty(index, kpidIsDir, &prop2));
    if (prop2.vt == VT_BOOL && prop2.boolVal != VARIANT_FALSE)
    {
        // Create directory
        mkdir(GetAnsiString(_filePath).c_str(), 0755);
        return S_OK;
    }
    
    // Create parent directories if needed
    int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR);
    if (slashPos >= 0)
    {
        UString dirPath = _filePath.Left(slashPos);
        mkdir(GetAnsiString(dirPath).c_str(), 0755);
    }
    
    // Create file stream
    _outFileStreamSpec = new COutFileStream;
    CMyComPtr<ISequentialOutStream> outStreamLoc(_outFileStreamSpec);
    if (!_outFileStreamSpec->Open(GetSystemString(_filePath), false))
    {
        std::cout << "Cannot open output file: " << GetAnsiString(_filePath) << std::endl;
        NumErrors++;
        return S_OK;
    }
    _outFileStream = outStreamLoc;
    *outStream = outStreamLoc.Detach();
    return S_OK;
}

STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 /* askExtractMode */)
{
    return S_OK;
}

STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
{
    if (operationResult != NArchive::NExtract::NOperationResult::kOK)
    {
        NumErrors++;
        switch(operationResult)
        {
            case NArchive::NExtract::NOperationResult::kUnsupportedMethod:
                std::cout << "Unsupported Method" << std::endl;
                break;
            case NArchive::NExtract::NOperationResult::kCRCError:
                std::cout << "CRC Failed" << std::endl;
                break;
            case NArchive::NExtract::NOperationResult::kDataError:
                std::cout << "Data Error" << std::endl;
                break;
            default:
                std::cout << "Unknown Error" << std::endl;
        }
    }
    return S_OK;
}

STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
{
    // Password not supported in this simple example
    return E_ABORT;
}

// Open callback class
class CArchiveOpenCallback :
    public IArchiveOpenCallback,
    public ICryptoGetTextPassword,
    public CMyUnknownImp
{
public:
    MY_UNKNOWN_IMP2(IArchiveOpenCallback, ICryptoGetTextPassword)
    
    STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes);
    STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes);
    
    STDMETHOD(CryptoGetTextPassword)(BSTR *password);
};

STDMETHODIMP CArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
{
    return S_OK;
}

STDMETHODIMP CArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
{
    return S_OK;
}

STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR * /* password */)
{
    return E_ABORT;
}

// Function type for CreateObject
typedef UINT32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *iid, void **outObject);

int main(int argc, char* argv[])
{
    if (argc != 3)
    {
        std::cout << "Usage: " << argv[0] << " <archive.7z> <output_directory>" << std::endl;
        return 1;
    }
    
    const char* archivePath = argv[1];
    const char* outputDir = argv[2];
    
    // Load 7z.so
    void* lib = dlopen("./7z.so", RTLD_LAZY);
    if (!lib)
    {
        std::cerr << "Cannot load 7z.so: " << dlerror() << std::endl;
        return 1;
    }
    
    // Get CreateObject function
    CreateObjectFunc createObjectFunc = (CreateObjectFunc)dlsym(lib, "CreateObject");
    if (!createObjectFunc)
    {
        std::cerr << "Cannot find CreateObject function" << std::endl;
        dlclose(lib);
        return 1;
    }
    
    // Create archive handler
    GUID clsid = CLSID_Format;
    CMyComPtr<IInArchive> archive;
    if (createObjectFunc(&clsid, &IID_IInArchive, (void **)&archive) != S_OK)
    {
        std::cerr << "Cannot create IInArchive object" << std::endl;
        dlclose(lib);
        return 1;
    }
    
    // Open archive file
    CInFileStream *fileSpec = new CInFileStream;
    CMyComPtr<IInStream> file = fileSpec;
    
    if (!fileSpec->Open(GetSystemString(GetUnicodeString(archivePath))))
    {
        std::cerr << "Cannot open archive file: " << archivePath << std::endl;
        dlclose(lib);
        return 1;
    }
    
    // Open archive
    CArchiveOpenCallback *openCallbackSpec = new CArchiveOpenCallback;
    CMyComPtr<IArchiveOpenCallback> openCallback(openCallbackSpec);
    
    const UInt64 scanSize = 1 << 23;
    if (archive->Open(file, &scanSize, openCallback) != S_OK)
    {
        std::cerr << "Cannot open archive: " << archivePath << std::endl;
        dlclose(lib);
        return 1;
    }
    
    // Create output directory
    mkdir(outputDir, 0755);
    
    // Extract
    CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
    CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
    extractCallbackSpec->Init(archive, GetUnicodeString(outputDir) + L"/");
    
    std::cout << "Extracting archive..." << std::endl;
    HRESULT result = archive->Extract(nullptr, (UInt32)(Int32)(-1), false, extractCallback);
    
    if (result != S_OK)
    {
        std::cerr << "Extract error!" << std::endl;
        dlclose(lib);
        return 1;
    }
    
    if (extractCallbackSpec->NumErrors > 0)
    {
        std::cerr << "Extraction completed with " << extractCallbackSpec->NumErrors << " errors" << std::endl;
        dlclose(lib);
        return 1;
    }
    
    std::cout << "Extraction completed successfully!" << std::endl;
    
    archive->Close();
    dlclose(lib);
    return 0;
}

Using 7z.so directly - Requires ~300+ lines with:

Dynamic loading of 7z.so via dlopen()

Implementing COM-like interfaces (IInArchive, IArchiveExtractCallback)

Manual callback handling for file extraction

Complex error handling

Approach 2: Using 7z.so Directly (More Complex)

This requires understanding the 7-Zip COM-like interface and implementing callbacks.

### Requirements

You need header files from the 7-Zip SDK. Download from: https://www.7-zip.org/sdk.html

Required headers:
``
CPP/7zip/Archive/IArchive.h
CPP/7zip/IPassword.h
CPP/Common/MyCom.h
CPP/Windows/PropVariant.h
CPP/Common/MyString.h
CPP/7zip/Common/FileStreams.h
``

### Compile

```bash
# Assuming 7-Zip SDK is in ./p7zip
g++ -std=c++11 -I./p7zip simple_7z_extractor.cpp -o extract_direct -ldl

# Run
./extract_direct archive.7z /tmp/output_dir
```

// Simple extractor using bit7z library
// Compile: g++ -std=c++14 simple_extractor_bit7z.cpp -o extract -lbit7z -ldl

#include <iostream>
#include <bit7z/bitfileextractor.hpp>

using namespace bit7z;

int main(int argc, char* argv[])
{
    if (argc != 3)
    {
        std::cout << "Usage: " << argv[0] << " <archive> <output_directory>" << std::endl;
        std::cout << "Example: " << argv[0] << " test.7z /tmp/output" << std::endl;
        return 1;
    }
    
    const std::string archivePath = argv[1];
    const std::string outputDir = argv[2];
    
    try
    {
        // Load 7z.so library
        Bit7zLibrary lib{ "./7z.so" };
        
        // Create extractor - BitFormat::Auto will auto-detect format
        BitFileExtractor extractor{ lib, BitFormat::Auto };
        
        // Extract archive
        std::cout << "Extracting " << archivePath << " to " << outputDir << "..." << std::endl;
        extractor.extract(archivePath, outputDir);
        std::cout << "Extraction completed successfully!" << std::endl;
        
        return 0;
    }
    catch (const BitException& ex)
    {
        std::cerr << "Error: " << ex.what() << std::endl;
        return 1;
    }
}

Using bit7z (RECOMMENDED) - Just ~10 lines of code:

Bit7zLibrary lib{ "./7z.so" };

BitFileExtractor extractor{ lib, BitFormat::Auto };

extractor.extract(archivePath, outputDir);

Approach 1: Using bit7z (RECOMMENDED - Much Simpler)

### Installation

``bash
# Clone and build bit7z
git clone
https://github.com/rikyoz/bit7z.git
cd bit7z
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j
sudo cmake --install .
``

### Compile and Run

```bash
# Compile
g++ -std=c++14 simple_extractor_bit7z.cpp -o extract -lbit7z -ldl

# Run
./extract archive.7z /tmp/output_dir
```

Техномилфа знает куда копать надо.

Вы.

Отрывок, кек) Так и говори, что перводит с задержкой и скорее всего не точно, учитывая скорость и посторонние звуки в фильме. Человек подумает, что там прям про первод с ходу. Копить мне не нужно, пользую вторые, пока особого отличия в качестве и скорости первода видимо нет, так как ядро Galaxy AI одно. Вы это подтвердили, благодарочка.

Да, Buds 2 Pro. Внешний источник звука не равно просмотру фильма.

Buds2 Pro получили обновление, которое добавляет функции «Live Translate» и «Interpreter».Однако эти функции ориентированы на разговоры / звонки / живое слушание речи (ова-слушание / перевод через микрофон) — не на автоматический перевод звука фильма.

Учи матчасть.

Нельзя, синхронный перевод только для звонков.

Нет, ставишь на комп и допиливаешь в направлении постепенного перехода от улучшенного DQN к policy-based или модель-ориентированным методам, сопровождаемый:

-расширением данных и признаков,

-учётом неопределённости и риска в награде,

-реальным stream + execution контуром.

Таким образом надо:

1. Переписать replay-буфер: PER + β schedule; добавить n-step sampling.

2. Заменить ε-жадность на NoisyLinear; переобучить базовую сеть.

3. Докрутить Optuna для n-step, γ, β, noisy_σ; 200 trials достаточно.

4. Интегрировать risk-penalty в reward и пересчитать метрики.

5. Ветка A (механика): Transformer-encoder вместо CNN, затем C51.

6. Ветка B (action space): прототип SAC (continuous size), backtest 2025-03—06.

7. Развёртывание dry-run на Binance Testnet с real-time stream.

8. Собрать baseline Dreamer на тех же данных; сравнить sample-efficiency.

9. Выбрать победителя → live ключи под строгими лимитами.

В статье указано, что написан пример кода, а не реальная алгостратегия для фонда, а то в комментах сразу критика пошла). А так было бы интересно ещё в выводе бэктеста увидеть параметры:

1)Коэффициент стабильности прибыли(Sharp ratio)

2)Максимальная просадка %(Max. draw down%)

3)Коэффициент прибыльности(Profit factor).

Тогда можно сделать какие-то выводы о стратегии.

Мануальный тестировщик=)

В принципе наполнение статьи соответствует названию, описывается пример простейшего алгоритма. Почему выбран PineScript думаю из-за его относительной простоты освоения, как тот-же MQL из MetaTrader и популярности платформы, на которой он используется. Но вот его функциональность вызывает вопросы, так как это узкоспециализированное решение самой TradingView и ни о какой гибкости и сложной кастомизации и речи быть не может, грубо говоря вот тебе 10 деталек конструктора, как хочешь их так и используй. Поэтому, конечно более сложные алгоритмы пишутся на известных всем яп.

Заказываем редкоземельные металлы в Китае в нужной нам геометрии — в России их не делают. 

Прям грустно стало, из всех утюгов слышим, что у нас вся таблица Менделеева, а на деле вот такое...

Статья классная, автору успехов.

Ждём новых статей, но уже с уклоном в системность и алгоритмику с примерами кода.

Информация

В рейтинге
Не участвует
Зарегистрирован
Активность

Специализация

Директор проекта, Менеджер продукта