Skip to content

Instantly share code, notes, and snippets.

View MihaelIsaev's full-sized avatar
⌨️
developing Swift for Web

Mikhail Isaev aka iMike MihaelIsaev

⌨️
developing Swift for Web
View GitHub Profile
@MihaelIsaev
MihaelIsaev / bash.ts
Created October 23, 2024 17:32
Node.js multiple persistent shells instead of multiple spawns
///
// This file is MIT licensed.
// This implementation in real life is actually slower than calling `spawn` multiple times.
// But I just want to save it as a concept.
// If you have ideas of how to improve its speed please feel free to contribute.
///
import { ChildProcessWithoutNullStreams, exec, spawn } from 'child_process'
import { isNull } from 'util'
import { LogLevel, print } from './webber'
import { TimeMeasure } from './helpers/timeMeasureHelper'
@MihaelIsaev
MihaelIsaev / AwesomeWSPing.swift
Created July 4, 2022 21:23
AwesomeWS automatic ping implementation
class YourCustomWS: ClassicObserver, LifecycleHandler {
var pingTask: RepeatedTask?
var waitForPongAttempts: [WaiterForPongAttempt] = []
public required init (app: Application, key: String, path: String, exchangeMode: ExchangeMode) {
super.init(app: app, key: key, path: path, exchangeMode: exchangeMode)
pingTask = app.eventLoop.scheduleRepeatedTask(initialDelay: .seconds(5), delay: .seconds(5)) { [weak self] task in
guard let self = self else { return }
self.waitForPongAttempts.enumerated().forEach { i, object in
if object.attempt >= 2 {

What's new in Swift 6 (Swiftify article translated into Russian)

Что нового в Swift 6 (перевод статьи Swiftify)

Apple планирует выпустить Swift 6 в сентябре 2024 года наряду с Xcode 16. Это будет первое крупное обновление Swift за последние пять лет, начиная с Swift 5. Этот выпуск приурочен к 10-летнему юбилею Swift. За эти годы Swift значительно развился, от простого улучшения Objective-C до безопасного, многофункционального и производительного языка, который легко использовать.

Apple ранее упоминала, что будут последовательно выпускаться версии Swift 5.x, вводящие инкрементальные изменения и новые функции для подготовки к Swift 6. Основные цели включали улучшение поддержки параллелизма и модели владения памятью. На данный момент они были достигнуты в значительной степени.

Давайте кратко вспомним эволюцию версий Swift

//
// TableViewController.swift
// RSSParser
//
// Created by mihael on 14/04/15.
// Copyright (c) 2015 Mihael Isaev inc. All rights reserved.
//
import UIKit
@MihaelIsaev
MihaelIsaev / CameraViewController.swift
Created April 16, 2015 19:30
This is the example of camera view for iOS written in Swift
import UIKit
import AVFoundation
class ViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
@IBOutlet weak var myView: UIView!
var session: AVCaptureSession?
var device: AVCaptureDevice?
var input: AVCaptureDeviceInput?
@MihaelIsaev
MihaelIsaev / Bindings.swift
Created June 14, 2019 02:51 — forked from AliSoftware/Bindings.swift
Re-implementation of @binding and @State (from SwiftUI) myself to better understand it
// This is a re-implementation of the @Binding and @State property wrappers from SwiftUI
// The only purpose of this code is to implement those wrappers myself just to understand how they work internally and why they are needed
// Re-implementing them myself has helped me understand the whole thing better
//: # A Binding is just something that encapsulates getter+setter to a property
@propertyDelegate
struct XBinding<Value> {
var value: Value {
get { return getValue() }
@MihaelIsaev
MihaelIsaev / Vapor3HTTPClientRequestProxy.swift
Created June 26, 2018 02:49
Example of http request through proxy for Vapor 3
public func boot(_ app: Application) throws {
let config = URLSessionConfiguration.default
config.requestCachePolicy = URLRequest.CachePolicy.reloadIgnoringLocalCacheData
config.connectionProxyDictionary = [AnyHashable: Any]()
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPEnable as String] = 1
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPProxy as String] = "proxy-server.com"
config.connectionProxyDictionary?[kCFNetworkProxiesHTTPPort as String] = 8080
let session = URLSession.init(configuration: config)
@MihaelIsaev
MihaelIsaev / proxy.pac
Created March 26, 2021 11:35 — forked from swinton/proxy.pac
Example proxy.pac, using a SOCKS proxy for certain hosts.
function FindProxyForURL(url, host) {
var useSocks = ["imgur.com"];
for (var i= 0; i < useSocks.length; i++) {
if (shExpMatch(host, useSocks[i])) {
return "SOCKS localhost:9999";
}
}
return "DIRECT";
function getCache(name) {
return new Promise((resolve, reject) => {
const version = 1;
const request = indexedDB.open(name, version);
request.onsuccess = event => {
const db = event.target.result;
/*
* Returns a Promise that resolves with an object
@MihaelIsaev
MihaelIsaev / ARMDebianUbuntu.md
Created September 5, 2020 01:32 — forked from Liryna/ARMDebianUbuntu.md
Emulating ARM on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux