Arm1.ru

Tag: «open source»

Swift CouchDB client 1.5.0

Swift CouchDB client 1.5.0

And here we go, one more new version of the CouchDB client library. After the recent post about 1.4.0 the Swift on Server released a new version of async-http-client that has a new implementation of the client singleton. Now it's HTTPClient.shared, so I've updated the CouchDB library to adopt that. That also requires not to call httpClient.syncShutdown() if the singleton is used. Also they've bumped the minimum Swift version to 5.8 (I did the same in 1.4.0 for the CouchDB client library). So keeping the library up to date.

Changelog:

  • Bumped async-http-client minimum version to the new 1.21.0. If you can't use it in your project you can stay on 1.4.0.
  • The library will use HTTPClient.shared (new in async-http-client 1.21.0) internally for requests if no EventLoopGroup is provided.
  • No more internal calls for httpClient.syncShutdown() in case of HTTPClient.shared usage.

CouchDB Client on GitHub | Documentation with examples and tutorials.

comment comments

Swift CouchDB client 1.4.0

Swift CouchDB client

A new CouchDB Client version has been released:

  • The library migrated from HTTPClient.Response to HTTPClientResponse which is similar to HTTPClient.Response, but used for the Swift Concurrency API. Also it migrated from HTTPClient.Body to HTTPClientRequest.Body. These changes affect get and find methods. Old methods are marked as deprecated, check the docs for the updated methods.
  • Minimum Swift version is 5.8 now.
  • CouchDBRepresentable protocol is now marked as Codable.
  • Added a new RowsResponse data model that accepts a generic CouchDBRepresentable type which makes it easier to get rows from a database. Example:
    class="swift">let decodeResponse = try JSONDecoder().decode(RowsResponse<MyApp>.self, from: data)
  • Small improvements in the documentation and tutorials.

CouchDB Client on GitHub | Documentation with examples and tutorials.

comment comments

Модульбанк информер 1.3

Модульбанк информер 1.3

Выпустил небольшое обновление для Модульбанк инфомера. Обновил иконку в статусбаре (тепер узнаваемая), и добавил чекбокс для скрытия счетов с нулевым балансом. Ну и немного рефакторинга.

Исходный код на GitHub: https://github.com/makoni/ModulbankInformer
Скачать можно тут: https://github.com/makoni/ModulbankInformer/releases

comment comments

Swift CouchDB client 1.3.2

Swift CouchDB client

Recently there was a couple new releases of my Swift CouchDB library. Recent changes:

  • dateDecodingStrategy and dateEncodingStrategy can be passed as a param for get/update/insert methods.
  • Added a check if auth cookie expired.
  • Comparing set-cookie as lowercased in the response header.
  • Added new methods to use _find API method that allows to find documents using a declarative JSON querying syntax
  • Fixed when update method didn’t use dateEncodingStrategy param.

CouchDB Client on GitHub | Documentation with examples and tutorials.

comment comments

Модульбанк информер 1.2

Модульбанк информер 1.2

Обнаружил досадный баг в Модульбанк Информере - если был счёт в турецких лирах, то JSON не парсился и данных не было совсем. Исправил в обновлении.

Исходный код на GitHub: https://github.com/makoni/ModulbankInformer
Скачать можно тут: https://github.com/makoni/ModulbankInformer/releases

comment comments

Модульбанк информер

Модульбанк информер

Недавно увидел, что у Модульбанка, которым я пользуюсь, есть публичный API. Поскольку у них для macOS нет приложения, а приложение для iOS не работает на Apple Silicon (их ограничение в целях безопасности), я сделал небольшой информер, который показывает в статус баре список счетов и баланс.

Приложение macOS 13+, т.к. хотелось выжать из SwiftUI всё самое актуальное, заодно попрактиковаться.

Исходный код на GitHub: https://github.com/makoni/ModulbankInformer
Скачать можно тут: https://github.com/makoni/ModulbankInformer/releases

comment comments

Swift CouchDB client 1.2.1

Swift CouchDB client 1.2.1

Just a small update for Swift CouchDB client lib with couple new methods that I needed by myself:

  • Added a new method to create a database [docs].
  • Added a new method to delete a database [docs].
  • Added a new method to check if a database exists [docs].
  • Every request handles unauthorised errors now.
  • CouchDBClientError model has a description text now.

CouchDB Client on GitHub | Documentation with examples and tutorials.

comment comments

Swift CouchDB client 1.2.0

Swift CouchDB client 1.2.0

Couple months ago I started learning Apple's DocC tool that generates documentation from your source code. I've decided to use as many features as possible so I took my small lib CouchDB Client and added docs to every method including usage examples that Xcode will show in the autocomplete popup. As it often happens, during adding docs and examples I found that many things in the library can be done in a much better way. So I've updated existing methods and added some more that can take a doc as a param and use generic types.

Next step was tutorials. Apple allows devs to create exactly the same tutorials as they have for SwiftUI on their own website. So I've added a couple. They're also part of the repo on GitHub.

Pretty sure that I've spent more time on the documentation than on the lib itself but I hope it's worth it.

CouchDB Client on GitHub | Documentation with examples and tutorials.

comment comments

Swift CouchDB client 1.0.0

Swift CouchDB client library

Finished new version of Swift CouchDB client. Now it's using only async-http-client as a dependency to make http/https requests. Can be used with Vapor 4.

Available on Github: https://github.com/makoni/couchdb-vapor

comment comments

Syntax sugar for JSON parsing in Swift

JSON decoding and encoding became easy after adding Codable protocol in Swift 4.0. But during coding I wanted to have something shorter and more elegant than Do-Catch statement that looks like this:

var myModel: MyModel?
let decoder = JSONDecoder()

do {
    myModel = try decoder.decode(MyModel.self, from: data)
} catch {
    print(error.localizedDescription)
}

Or like this:

let myModel: MyModel? = try? decoder.decode(MyModel.self, from: data)

So I wrote a protocol with default implementation that allows to do decoding just like that:

let myModel = MyModel.decodeFromData(data: data)

And the same for encoding:

let data = MyModel.encode(fromEncodable: myModel)

All you need is just to add protocol conformance:

extension MyModel: Parseable {
    typealias ParseableType = Self
}

It's available on GitHub as a Swift Package: https://github.com/makoni/parsable

comment comments

Select like a Boss для Safari в Mac App Store

Select like a boss for Safari

24 сентября вышла новая версия macOS - Mojave. А вместе с ней и Safari 12, который теперь поддерживает установку расширений только из Mac App Store. Пришлось запилить приложение с расширением.

Загрузить

comment comments

JPG to HEIF converter

JPG to HEIF converter

Today I've decided to experiment with HEIF that was introduced by Apple with macOS 10.13 and iOS 11. They said that it has the same quality with much lower file size.

It's supported in the latest versions of macOS and iOS and last models of iPhone can take pictures in that format.

I'm thinking about compressing my home archive of photos and videos. I was experimenting with HEVC (H.265) and results were great - I had reduced the size of my videos by encoding them to HEVC with an awesome util called HandBrake.

I found the only way to convert JPG to HEIF (which has HEIC extension). It's possible with the Preview app from macOS. But it would be interesting for me if I can do it by myself in Swift. So I did :)

My folder with 64 photos from my action camera was 203 mb in JPG format. And it's only 31.3 mb in HEIC.

macOS and iOS support it from the box. And what's interesting - it's easy to add pictures in this format to the Photos library and it will appear on all your devices that use iCloud. But if you want to export this picture from the Photos library - it will be converted to JPG on the fly, so it looks like you can't export the original HEIC file.

The converter is free and open source (but it's for macOS only): https://github.com/makoni/jpg-to-heif-converter

comment comments