Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View emadhegab's full-sized avatar

Mohamed Emad Hegab emadhegab

View GitHub Profile
@emadhegab
emadhegab / ci-cd.sh
Last active July 5, 2023 08:12
ci-cd.sh
#!/bin/bash
echo -e "##=====> changing default shell to /bin/bash"
chsh -s /bin/bash
echo -e "##=====> installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
echo -e "##=====> refreshing the environment"
@emadhegab
emadhegab / ImageDownSample
Created December 11, 2020 08:05
Downsampling Image for lowering memory footprint
func downsample(imageAt imageURL: URL,
to pointSize: CGSize,
scale: CGFloat = UIScreen.main.scale) -> UIImage? {
// Create an CGImageSource that represent an image
let imageSourceOptions = [kCGImageSourceShouldCache: false] as CFDictionary
guard let imageSource = CGImageSourceCreateWithURL(imageURL as CFURL, imageSourceOptions) else {
return nil
}
import UIKit
@objc public protocol TimerLabelDelegate {
optional func countdownStarted()
optional func countdownFinished()
}
public extension NSTimeInterval {
var int: Int {
@emadhegab
emadhegab / times
Created March 16, 2016 12:56
extension to make Ruby Like times for swift
extension Int {
func times(b: (Int) -> ()) {
for i in 0..<self {
b(i)
}
}
}
3.times { print($0) }
# Xcode
build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
@emadhegab
emadhegab / Calculator.swift
Created August 22, 2015 17:57
Swift Calculator With @IBDesignable
//
// Calculator.swift
//
// Created by Mohamed Hegab on 8/22/15.
// Copyright (c) 2015 The Dark Dimension. All rights reserved.
//
import UIKit
/// The alignment for drawing an String inside a bounding rectangle.