Skip to content

Instantly share code, notes, and snippets.

View st-small's full-sized avatar

Stanislav Shiyanovskiy st-small

  • Kirovohrad, Ukraine
View GitHub Profile
@igmyung
igmyung / UIParentView.swift
Created May 3, 2023 11:41
SwiftUI UIViewRepresentable nested view example
import SwiftUI
struct ContentView: View {
@State private var toggle = false
var body: some View {
CustomParentView {
Button {
toggle.toggle()
} label: {
@hungneox
hungneox / WIN10.MD
Last active June 25, 2024 14:17
How Make a Windows 10 USB Using Your Mac - Build a Bootable ISO From Your Mac's Terminal

Most new PCs don't come with DVD drives anymore. So it can be a pain to install Windows on a new computer.

Luckily, Microsoft makes a tool that you can use to install Windows from a USB storage drive (or "thumbdrive" as they are often called).

But what if you don't have a second PC for setting up that USB storage drive in the first place?

In this tutorial we'll show you how you can set this up from a Mac.

Step 1: Download the Windows 10 ISO file

You can download the ISO file straight from Windows. That's right - everything we're going to do here is 100% legal and sanctioned by Microsoft.

class CircularBuffer<T> {
var bufferMaxSize: Int
var size = 0
var elements = Array<T?>(repeating: nil, count: 8)
var front: T? {
if isEmpty() {
return nil
} else {
@eugenebokhan
eugenebokhan / CGImage+Resize.swift
Last active April 11, 2024 21:28
UIImage + Resize
import CoreGraphics
import Accelerate
import CoreImage
import UIKit
extension CGImage {
public enum Error: Swift.Error {
case imageResizingFailed
case cgContextCreationFailed
@lengocgiang
lengocgiang / animation.swift
Created December 3, 2017 09:52
addSubview and removeFromSuperview animation in Swift 4.0
# addSubview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
self.view.addSubview(view)
}, completion: nil)
# removeFromSuperview
UIView.transition(with: self.view, duration: 0.25, options: [.transitionCrossDissolve], animations: {
subview.removeFromSuperview()
}, completion: nil)
/** A pthread-based recursive mutex lock. */
public class Mutex {
private var mutex: pthread_mutex_t = pthread_mutex_t()
public init() {
var attr: pthread_mutexattr_t = pthread_mutexattr_t()
pthread_mutexattr_init(&attr)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)
let err = pthread_mutex_init(&self.mutex, &attr)
@jkosoy
jkosoy / CGSize+AspectFunctions.swift
Last active June 3, 2023 18:11
Aspect Fill and Aspect Fit calculations in Swift
// port of http://stackoverflow.com/a/17948778/3071224
import UIKit
import Foundation
extension CGSize {
static func aspectFit(aspectRatio : CGSize, var boundingSize: CGSize) -> CGSize {
let mW = boundingSize.width / aspectRatio.width;
let mH = boundingSize.height / aspectRatio.height;
@ajmaradiaga
ajmaradiaga / gist:943582
Created April 27, 2011 01:49
Instance a NSManagedObject without inserting in ManagedObjectContext
//Assuming Accounts = Name of the Entity to instance
BlipAppDelegate *_appDelegate = (BlipAppDelegate *)[[UIApplication sharedApplication] delegate];
NSManagedObjectContext *MOC = [_appDelegate managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Accounts" inManagedObjectContext:MOC];
Accounts *account = (Accounts *)[[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:nil];
//Insert data to account