Converting MP4 to GIF with ffmpeg

I was able to convert MP4 to GIF with ffmpeg with the following commands on Ubuntu 22.04:

ffmpeg \
  -i iphone884.mp4 \
  -r 15 \
  -vf "scale=512:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
  -ss 00:00:03 -to 00:00:06 \
  iphone884.gif

ffmpeg \
  -i iphone884.mp4 \
  -r 15 \
  -vf "scale=300:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
  iphone884.gif

Move assignment operator in C++

Implicitly-declared move assignment operator

If no user-defined move assignment operators are provided for a class type, and all of the following is true:

(more…)

Earned $50 on Binance with my Trading Bot

I have a home made Trading Bot that short coins on Binance with some simple strategy:

(more…)

Examples of C++/Objective-C interop

From QT’s Purchasing:

//SKProductsRequestDelegate
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray<SKProduct *> *products = response.products;
    SKProduct *product = [products count] == 1 ? [[products firstObject] retain] : nil;

    if (product == nil) {
        //Invalid product ID
        NSString *invalidId = [response.invalidProductIdentifiers firstObject];
        QMetaObject::invokeMethod(backend, "registerQueryFailure", Qt::AutoConnection, Q_ARG(QString, QString::fromNSString(invalidId)));
    } else {
        //Valid product query
        //Create a IosInAppPurchaseProduct
        IosInAppPurchaseProduct *validProduct = new IosInAppPurchaseProduct(product, backend->productTypeForProductId(QString::fromNSString([product productIdentifier])));
        if (validProduct->thread() != backend->thread()) {
            validProduct->moveToThread(backend->thread());
            QMetaObject::invokeMethod(backend, "setParentToBackend", Qt::AutoConnection, Q_ARG(QObject*, validProduct));
        }
        QMetaObject::invokeMethod(backend, "registerProduct", Qt::AutoConnection, Q_ARG(IosInAppPurchaseProduct*, validProduct));
    }

    [request release];
}
(more…)

Copy a file with CMake

Copy Podfile at the build stage:

message("Copy ${CMAKE_CURRENT_SOURCE_DIR}/Podfile -> ${CMAKE_BINARY_DIR}")
add_custom_target(copy_podfile
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${CMAKE_CURRENT_SOURCE_DIR}/Podfile"
        "${CMAKE_BINARY_DIR}"
    COMMENT "Copying Podfile"
)
add_dependencies(${PROJECT_NAME} copy_podfile)

Copy Podfile at the configuration stage:

execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
    "${CMAKE_CURRENT_SOURCE_DIR}/Podfile"
    "${CMAKE_BINARY_DIR}"
)

The right way to build Yandex Mobile Ads Example for iOS

To build the example with CocoaPods do the following steps:

Install build tools

Install Ruby with rbenv on macOS and install CocoaPods without sudo:

gem install cocoapods
(more…)

Installing Ruby with rbenv on macOS

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install rbenv

brew install rbenv
(more…)

Installing latest Ruby version on MacOS Sonoma with Homebrew

Determining how was Ruby Installed.

I have system Ruby:

% which -a ruby
/usr/bin/ruby
ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin23]

Installing Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(more…)

Recording video with Nvidia DSR

Installed GTX 1060 driver:

(more…)

Application folder does not exist when MacOS app is run the first time

When my QT app starts first time on MacOS, its directory ./Application Support/Sharlines/Lines/ does not exit, but QT creates it when I write to QSettings first time.

To create the local directory I added the following code:

// Local data directory does not exist when the app is run first time on MacOS.
if (fs::create_directories(GetLocalFolder()))
{
    qDebug() << static_cast<QString>(qtil::Format() << "Local folder '" << GetLocalFolder() << "' has been created.");
}
(more…)