Skip to content

Instantly share code, notes, and snippets.

View Kanishka3's full-sized avatar

Kanishka C Kanishka3

View GitHub Profile
@pawan-preet
pawan-preet / AutolayoutHelper.swift
Last active August 5, 2019 11:19
Helper Class to ease Constraints when adding Programatically.
//
// AutolayoutHelper.swift
//
// Created by Pawan on 30/07/19.
// Copyright © 2019 Pawan. All rights reserved.
//
import Foundation
view.subviews.compactMap({ $0 as? UITextField }).forEach { textfield in
if let text = textfield.text, text.isEmpty {
textfield.backgroundColor = .yellow // highlight
} else {
textfield.backgroundColor = .white // default
}
}
@netgfx
netgfx / AudioPlayer.swift
Created February 23, 2018 21:26
A basic audio player with observers and extra features. Based on AVFoundation and AVQueuePlayer
//
// AudioPlayer.swift
//
// Created by MDobekidis
//
import Foundation
import AVFoundation
import UIKit
import Signals
@JadenGeller
JadenGeller / Matrix Examples.swift
Last active August 10, 2023 10:03
Matrices in Swift
// Numerical matrix examples
let x: Matrix = [[10, 9, 8], [3, 2, 1]]
let y: Matrix = [[1, 2, 3], [4, 5, 6]]
let z: Matrix = [[1, 2], [3, 4], [5, 6]]
x + y // [[11, 11, 11], [7, 7, 7]]
x * y // [[10, 18, 24], [12, 10, 6]]
2 * x // [[20, 18, 16], [6, 4, 2]]
y ** z // [[22, 28], [49, 64]]