Skip to content

Instantly share code, notes, and snippets.

View alexdremov's full-sized avatar
🥑
study

Aleksandr Dremov alexdremov

🥑
study
View GitHub Profile
@alexdremov
alexdremov / dice_metrics.py
Created October 10, 2023 18:59
SymmetricBestDICE
import numpy as np
import scipy
def ravel_image(img):
"""
Разворачивает изображения в одномерный массив с учетом батча
"""
assert 1 < len(img.shape) < 4
name: Task0 tests
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
@alexdremov
alexdremov / code_16.swift
Created January 9, 2023 09:40
Swift uses ARC to track and deallocate unused objects. Learn about the three types of reference counts and how ARC works — in this detailed post. Post: https://alexdremov.me/dive-into-swifts-memory-management/
class Person {
let name: String
init(name: String) { self.name = name }
var apartment: Apartment?
deinit { print("\(name) is being deinitialized") }
}
class Apartment {
let unit: String
init(unit: String) { self.unit = unit }
class LogInState: ObservableObject {
@Published var isLoggedIn: Bool
init(isLoggedIn: Bool) {
self.isLoggedIn = isLoggedIn
}
func loggedOut() {
isLoggedIn = false
}
@alexdremov
alexdremov / Project.swift
Last active October 7, 2022 12:38
Tuist example project snippets
import ProjectDescription
import ProjectDescriptionHelpers
let project = Project(
name: Feature.Foo.rawValue,
targets: [
.feature(
implementation: .Foo,
dependencies: [
.feature(interface: .Biz),
ColumnsLayout(columnsNumber: 2) {
VStack {
Text("That's one view")
Image(systemName: "tortoise.fill")
}
.padding()
.border(.red)
Text("That's the second view ")
.padding()
.border(.red)
let data = [
(text: "Nice", subtext: "Onborading sequence of screens"),
(text: "OK", subtext: "But how to do it with SwiftUI?"),
(text: "So that", subtext: "it is nice and shiny"),
]
let typeCommon: PathPresenter.PathType =
.animated(
transition: .asymmetric(
insertion: .move(edge: .trailing),
class MyThread: Thread {
override func main() { // Thread's starting point
print("Hi from thread")
}
}
let thread = MyThread()
thread.start()
import enum Accelerate.vDSP
struct AnimatableVector: VectorArithmetic {
var values: [Float]
static var zero = AnimatableVector(values: [0.0])
static func + (lhs: AnimatableVector, rhs: AnimatableVector) -> AnimatableVector {
let count = min(lhs.values.count, rhs.values.count)
return AnimatableVector(
Sequence 1 Sequence 2 Result
1 1
4 4
2 2
3 3