Skip to content

Instantly share code, notes, and snippets.

View magnuskahr's full-sized avatar

Magnus Kahr Jensen magnuskahr

View GitHub Profile
import UIKit
import QuartzCore
class ConfettiView: UIView {
public var colors: [UIColor]!
public var intensity: Float!
private(set) var active: Bool!
override public class var layerClass: Swift.AnyClass {
import Foundation
// We provide some json and transform it to Data-type
let json = """
[{
"name": "John",
"startingTime": 581167640.06502903
}, {
"name": "Mark",
"startingTime": 582031640.06502903
@magnuskahr
magnuskahr / AlertActivityIndicator.swift
Created May 29, 2019 10:55
Showing an ActivityIndicator in a Alert
let alert = UIAlertController(title: "Sender ...", message: nil, preferredStyle: .alert)
let activityIndicator = UIActivityIndicatorView(style: .gray)
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
activityIndicator.isUserInteractionEnabled = false
activityIndicator.startAnimating()
alert.view.addSubview(activityIndicator)
alert.view.heightAnchor.constraint(equalToConstant: 95).isActive = true
activityIndicator.centerXAnchor.constraint(equalTo: alert.view.centerXAnchor, constant: 0).isActive = true
@magnuskahr
magnuskahr / projectbook.ipynb
Last active November 25, 2019 21:05
projectbook_v6 UNET.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@magnuskahr
magnuskahr / untitled8.ipynb
Last active December 6, 2019 14:56
Untitled8.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@magnuskahr
magnuskahr / bingo-python.ipynb
Created December 13, 2019 13:10
Bingo Ticket Isolation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@magnuskahr
magnuskahr / EnumPicker.swift
Last active May 24, 2024 23:52
A simple picker to pick a enum.
import SwiftUI
struct EnumPicker<T: Hashable & CaseIterable, V: View>: View {
@Binding var selected: T
var title: String? = nil
let mapping: (T) -> V
var body: some View {
@magnuskahr
magnuskahr / AnimateableView.swift
Created May 13, 2021 21:21
Rolling animatable view
struct AnimateableView<ContentView: View, Value: VectorArithmetic>: View {
let value: Value
@ViewBuilder let builder: (Value) -> ContentView
var body: some View {
builder(value)
.modifier(Animation<ContentView, Value>(value: value, builder: builder))
}
@magnuskahr
magnuskahr / IntegerField.swift
Created August 2, 2021 18:54
An integer field in swiftui
struct IntegerField: View {
@Binding var value: Int
@State private var stringValue: String
init(value binding: Binding<Int>) {
self._value = binding
self._stringValue = State(wrappedValue: binding.wrappedValue.formatted())
}
@magnuskahr
magnuskahr / View+pulsating.swift
Created October 3, 2021 08:25
SwiftUI View pulsating effect
//
// View+pulsating.swift
//
// Created by Magnus Jensen on 02/10/2021.
//
import SwiftUI
extension View {
func pulsating() -> some View {