Skip to content

Instantly share code, notes, and snippets.

View Stmol's full-sized avatar
👨‍🔧
SwiftUI & Flutter

Yury S. Stmol

👨‍🔧
SwiftUI & Flutter
  • Earth
View GitHub Profile
@Stmol
Stmol / iter.ts
Created June 14, 2024 11:36
test
type ValueType = number
const InvalidValue: ValueType = 1 << 0,
StringValue: ValueType = 1 << 1,
NumberValue: ValueType = 1 << 2,
NilValue: ValueType = 1 << 3,
BoolValue: ValueType = 1 << 4,
ArrayValue: ValueType = 1 << 5,
ObjectValue: ValueType = 1 << 6
//
// 1. Дано N ячеек с произвольным содержимым (content: number)
//
// 2. На вход поступает содержимое произвольной длины (number)
//
// 3. Нужно распределить входящее содержимое по ячейкам так, чтобы сначала заполнить наиболее полные ячейки
//
// 4. Если места не хватает, надо упасть с ошибкой
//
// Например:
@Stmol
Stmol / generate-bitcoin-keys.sh
Created February 27, 2023 20:36 — forked from gadiener/generate-bitcoin-keys.sh
OpenSSL commands to create a Bitcoin private/public keys from a ECDSA keypair
#!/bin/sh
PRIVATE_KEY="ECDSA"
PUBLIC_KEY="ECDSA.pub"
BITCOIN_PRIVATE_KEY="bitcoin"
BITCOIN_PUBLIC_KEY="bitcoin.pub"
echo "Generating private key"
openssl ecparam -genkey -name secp256k1 -rand /dev/random -out $PRIVATE_KEY
@Stmol
Stmol / ExportIPA.swift
Created December 26, 2021 15:01 — forked from rileytestut/ExportIPA.swift
Export Swift Playgrounds .ipa
import Foundation
// Export running app as .ipa, then return path to exported file.
// Returns String because app crashes when returning URL from async function for some reason...
func exportIPA() async throws -> String
{
// Path to app bundle
let bundleURL = Bundle.main.bundleURL
// Create Payload/ directory
@Stmol
Stmol / plural.php
Created January 27, 2020 09:17
Pluralization
<?php
function declOfNum($num, $titles) {
$cases = array(2, 0, 1, 1, 1, 2);
return $num . " " . $titles[($num % 100 > 4 && $num % 100 < 20) ? 2 : $cases[min($num % 10, 5)]];
}
echo declOfNum(5, array('человек просит', 'человека просят', 'человек просят'));
@Stmol
Stmol / scroll_view_height.dart
Created January 24, 2020 09:40 — forked from slightfoot/scroll_view_height.dart
ScrollView With Height for Flutter. Simple ScrollView with its content having a minimum height of the ScrollView's parent. This allows you to space out your components inside your ScrollView to fit the avaliable space and not have them "squish up" when the soft keyboard (IME) appears.
class ScrollViewWithHeight extends StatelessWidget {
final Widget child;
const ScrollViewWithHeight({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
return new SingleChildScrollView(
child: new ConstrainedBox(
@Stmol
Stmol / ApiClient.php
Last active December 15, 2019 17:47
Skyeng interview test
<?php
namespace src\Integration;
use src\Contracts\ApiRequestInterface;
use src\Contracts\ApiResponseInterface;
use src\Contracts\ApiClientInterface;
use Psr\Http\Client\ClientInterface;
/**
@Stmol
Stmol / ApiClient.swift
Created March 29, 2019 11:19
API Client with pure URLSession
enum HTTPMethod: String {
case get = "GET"
case put = "PUT"
case post = "POST"
case delete = "DELETE"
case head = "HEAD"
case options = "OPTIONS"
case trace = "TRACE"
case connect = "CONNECT"
}
@Stmol
Stmol / site.dart
Last active February 15, 2020 18:04
Dart Isolate
import 'dart:async';
import 'dart:collection';
import 'dart:isolate';
/// Easy and convenient to use, thread-pool-like implementation for delegating
/// expensive tasks to a pool of isolates
///
/// Just pass the function and the desired params to [commission] and let
/// the site handle everything for you by returning a really parallel computed [Future] object.
/// If the [Site] currently holds a reference to an idle Isolate, then the requested computation
@Stmol
Stmol / SynchronizedArray.swift
Created October 1, 2018 19:48
Swift 4 - Thread Safe Array
import Foundation
/// A thread-safe array.
public class SynchronizedArray<Element> {
fileprivate let queue = DispatchQueue(label: "io.data.SynchronizedArray", attributes: .concurrent)
fileprivate var array = [Element]()
}
// MARK: - Properties
public extension SynchronizedArray {