Skip to content

Instantly share code, notes, and snippets.

View ahmedAlmasri's full-sized avatar

Ahmad Almasri ahmedAlmasri

View GitHub Profile
@ahmedAlmasri
ahmedAlmasri / ImageCompression.swift
Last active August 30, 2023 10:47
ios swift Image compression
//: Playground - noun: a place where people can play
import UIKit
do{
func compressImage(_ img:UIImage) -> UIImage? {
// Reducing file size to a 10th
var actualHeight: CGFloat = img.size.height
var actualWidth: CGFloat = img.size.width
let maxHeight: CGFloat = 1136.0
import Foundation
import UIKit
func getWidth() -> CGFloat{
return UIScreen.main.bounds.width
}
func getHeight() -> CGFloat{
return UIScreen.main.bounds.height
func getPathPayer(arrPathPoints:[CGPoint]) throws -> CAShapeLayer {
enum PathError : Error{
case moreThan2PointsNeeded
}
guard arrPathPoints.count > 2 else {
throw PathError.moreThan2PointsNeeded
}
let lineColor = UIColor.blue
//
// KeychainItemAccessibility.swift
//
// Created by Ahmad AlMasri on 3/7/19.
// Copyright © 2019 Snapics App. All rights reserved.
//
//Ref @URL : https://github.com/twostraws/HackingWithSwift/blob/master/project28/Project28/KeychainItemAccessibility.swift
import Foundation
class SNZoomScrollView: UIScrollView {
// MARK: Class properties
var imageView:UIImageView = UIImageView()
var imageToDisplay:UIImage? = nil{
didSet{
zoomScale = 1.0
minimumZoomScale = 1.0
imageView.image = imageToDisplay
import android.util.Base64;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
//
// BaseUploadOperation.swift
// UHive
//
// Created by Ahmad AlMasri on 6/27/19.
// Copyright © 2019 Genie9. All rights reserved.
//
import Foundation
class TaskCodableModel: Codable {
var id: String?
var createDate: Date?
var name: String
var isFinished: Bool
var subtasks: Int
var weight: Double
var children: [String]?
var description: String?
import Foundation
import GLKit
extension UIImage {
func checkAndCompressImage(image: UIImage?, _ completion: @escaping (Data?) -> Void) {
print("start compress image ....")
DispatchQueue.global(qos: .background).async {
let imagecompress = UIImage.compressImage(image, compressRatio: 0.5)
devices=(
"iPhone 8"
"iPhone 8 Plus"
"iPhone SE"
"iPad Pro (11-inch)"
"iPhone Xʀ")
workspace="test"