Skip to content

Instantly share code, notes, and snippets.

View Ilesh's full-sized avatar
:octocat:
Learn | Build | Test | 🚀

Ile$h Ilesh

:octocat:
Learn | Build | Test | 🚀
View GitHub Profile
@Ilesh
Ilesh / Podfile
Last active February 11, 2020 12:55 — forked from arturgrigor/Podfile
Sample Podfile for silencing warnings for CocoaPods dependencies
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target '%TargetName%' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for %TargetName%
# pod 'FBSDKCoreKit'
end
public protocol RichTextEditorDelegate: class {
func textDidChange(text: String)
func heightDidChange()
}
fileprivate class WeakScriptMessageHandler: NSObject, WKScriptMessageHandler {
weak var delegate: WKScriptMessageHandler?
init(delegate: WKScriptMessageHandler) {
self.delegate = delegate
@Ilesh
Ilesh / UIButton+AddTargetClosure.swift
Created January 4, 2019 05:22 — forked from jackywang135/UIButton+AddTargetClosure.swift
Add UIButton targets using closure
import UIKit
typealias UIButtonTargetClosure = UIButton -> ()
class ClosureWrapper: NSObject {
let closure: UIButtonTargetClosure
init(_ closure: UIButtonTargetClosure) {
self.closure = closure
}
}
@IBDesignable class GridView: UIView {
var numberOfColumns: Int = 2
var numberOfRows: Int = 2
var lineWidth: CGFloat = 1.0
var lineColor: UIColor = UIColor.white
override func draw(_ rect: CGRect) {
if let context = UIGraphicsGetCurrentContext() {
@Ilesh
Ilesh / Blurable.swift
Created January 23, 2019 12:56 — forked from NikhilManapure/Blurable.swift
Blurable extension with blur and unBlur function
extension UIView {
func blur() {
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.addSubview(blurEffectView)
}
func unBlur() {
@Ilesh
Ilesh / NormalizingOrientation.swift
Created January 23, 2019 12:56 — forked from NikhilManapure/NormalizingOrientation.swift
Code for making image's orientation as .up
func imageByNormalizingOrientation() -> UIImage {
if imageOrientation == .up {
return self
}
UIGraphicsBeginImageContextWithOptions(size, false, scale)
draw(in: CGRect(origin: CGPoint.zero, size: size))
let normalizedImage: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return normalizedImage!
}
class SpinView: UIView {
private var animating: Bool = false
private func spin(with options: UIViewAnimationOptions) {
// this spin completes 360 degrees every 2 seconds
UIView.animate(withDuration: 0.5, delay: 0, options: options, animations: {() -> Void in
self.transform = self.transform.rotated(by: .pi / 2)
}, completion: {(_ finished: Bool) -> Void in
if finished {
if self.animating {
// MARK: - KVO
var observedPaths: [String] = []
// Usage - observeKVO(keyPath: #keyPath(camera.inputCamera.whiteBalanceMode))
func observeKVO(keyPath: String) -> Bool {
if shouldObserveKVO {
if self.classForCoder.automaticallyNotifiesObservers(forKey: keyPath) {
observedPaths.append(keyPath)
addObserver(self, forKeyPath: keyPath, options: [.old, .new], context: nil)
@Ilesh
Ilesh / README-Template.md
Created January 24, 2019 06:00 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@Ilesh
Ilesh / testflight.sh
Created February 13, 2019 06:17 — forked from keith/testflight.sh
Upload an ipa to testflight using altool
#!/bin/bash
set -e
set -u
altool="$(dirname "$(xcode-select -p)")/Applications/Application Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Support/altool"
ipa="path/to/foo.ipa"
echo "Validating app..."
time "$altool" --validate-app --type ios --file "$ipa" --username "$ITC_USER" --password "$ITC_PASSWORD"