Skip to content

Instantly share code, notes, and snippets.

View michaelevensen's full-sized avatar

Michael Nino Evensen michaelevensen

View GitHub Profile
struct OverflowLayout: Layout {
var spacing = CGFloat(10)
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
let containerWidth = proposal.replacingUnspecifiedDimensions().width
let sizes = subviews.map { $0.sizeThatFits(.unspecified) }
return layout(sizes: sizes, containerWidth: containerWidth).size
}
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
@MihailCosmin
MihailCosmin / cuda_11.8_installation_on_Ubuntu_22.04
Last active July 14, 2024 07:39 — forked from primus852/cuda_11.7_installation_on_Ubuntu_22.04
Instructions for CUDA v11.8 and cuDNN 8.7 installation on Ubuntu 22.04 for PyTorch 2.0.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@yagudaev
yagudaev / src_main_index.ts
Last active February 5, 2024 11:39
Firebase with Figma Storage Example
figma.ui.onmessage = async (msg, props) => {
if (originalOnMessage && isArray(msg)) {
originalOnMessage.apply(null, [msg, props])
return
}
switch (msg.type) {
case "req-read-local-storage":
await readLocalStorage(msg.data)
// figma.closePlugin()
@bjhomer
bjhomer / cross-view-lines.swift
Last active November 5, 2022 05:31
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI
@pd95
pd95 / NumberTextField.swift
Created March 28, 2022 08:27
An implementation of a `NumberTextField` based on `TextField` which should work with any `BinaryInteger` based type.
import SwiftUI
struct NumberTextField<NumberType: BinaryInteger>: View {
private let title: LocalizedStringKey
private let range: ClosedRange<NumberType>?
private let format: IntegerFormatStyle<NumberType>
@Binding private var value: NumberType?
@State private var valueString: String = ""
@myawesomehub
myawesomehub / VoiceViewModel.swift
Created February 13, 2021 15:12
This Snippet of Code Includes the Start Recording and Stop Feature
import Foundation
import AVFoundation
class VoiceViewModel : NSObject , ObservableObject , AVAudioPlayerDelegate {
var audioRecorder : AVAudioRecorder!
var audioPlayer : AVAudioPlayer!
@Published var isRecording : Bool = false
@gromwel
gromwel / Example.swift
Last active December 8, 2022 12:19
Decoding and encoding JSON with dynamic keys.
import Foundation
struct Film: Codable {
let actor: String
let year: Int
let key: String
// Объявляем ключи только для тех которые внутри модели
enum CodingKeys: CodingKey {
case actor
@pd95
pd95 / ContentView.swift
Last active September 9, 2022 09:02
InstaFilter main logic for CoreImage filter application
//
// ContentView.swift
// Project13
//
// Created by Paul Hudson on 17/02/2020.
// Copyright © 2020 Paul Hudson. All rights reserved.
//
import CoreImage
import CoreImage.CIFilterBuiltins
import UIKit
import AVFoundation
import Photos
import MobileCoreServices
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
startVideoToGIFProcess()
@calda
calda / EvolutionProposalPlayground.swift
Created February 23, 2020 22:58
Swift Nested JSON Decoding example
import Foundation
struct EvolutionProposal: Codable {
var id: String
var title: String
var reviewStartDate: Date
var reviewEndDate: Date
enum CodingKeys: String, CodingKey {