create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
double a, b, c, determinant, root1,root2, realPart, imaginaryPart; | |
printf("Enter coefficients a, b and c: "); | |
scanf("%lf %lf %lf",&a, &b, &c); |
extension UIColor { | |
convenience init(rgb: Int, alpha: CGFloat) { | |
let r = CGFloat((rgb & 0xFF0000) >> 16)/255 | |
let g = CGFloat((rgb & 0xFF00) >> 8)/255 | |
let b = CGFloat(rgb & 0xFF)/255 | |
self.init(red: r, green: g, blue: b, alpha: alpha) | |
} | |
convenience init(red: Int, green: Int, blue: Int) { | |
self.init(red: CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: 1.0) |
TAGS="TODO:|FIXME:" | |
ERRORTAG="DANGER:|ERROR:" | |
find "${SRCROOT}" \( -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/" | |
#find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/" | perl -p -e "s/($ERRORTAG)/ error: \$1/" |
@discardableResult | |
func customActivityIndicatory(_ viewContainer: UIView, startAnimate:Bool? = true) -> UIActivityIndicatorView { | |
let mainContainer: UIView = UIView(frame: viewContainer.frame) | |
mainContainer.center = viewContainer.center | |
mainContainer.backgroundColor = UIColor.init(netHex: 0xFFFFFF) | |
mainContainer.alpha = 0.5 | |
mainContainer.tag = 789456123 | |
mainContainer.isUserInteractionEnabled = false | |
let viewBackgroundLoading: UIView = UIView(frame: CGRect(x:0,y: 0,width: 80,height: 80)) |
func getAssetThumbnail(asset: PHAsset, size: CGFloat) -> UIImage { | |
let retinaScale = UIScreen.main.scale | |
let retinaSquare = CGSize(width: size * retinaScale, height: size * retinaScale)//(size * retinaScale, size * retinaScale) | |
let cropSizeLength = min(asset.pixelWidth, asset.pixelHeight) | |
let square = CGRect(x:0, y: 0,width: CGFloat(cropSizeLength),height: CGFloat(cropSizeLength)) | |
let cropRect = square.applying(CGAffineTransform(scaleX: 1.0/CGFloat(asset.pixelWidth), y: 1.0/CGFloat(asset.pixelHeight))) | |
let manager = PHImageManager.default() | |
let options = PHImageRequestOptions() | |
var thumbnail = UIImage() | |
options.isSynchronous = true |
let albumsPhoto:PHFetchResult<PHAssetCollection> = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .albumRegular, options: nil) | |
albumsPhoto.enumerateObjects({(collection, index, object) in | |
if collection.localizedTitle == "Screenshots"{ | |
let photoInAlbum = PHAsset.fetchAssets(in: collection, options: nil) | |
print(photoInAlbum.count) //Screenshots albums count | |
} | |
}) |
create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
/** | |
Scroll to make the the given section header visible. | |
The function scrollToItemAtIndexPath will scroll to the item and hide the section header. | |
Swift 3. | |
*/ | |
func scrollToSection(_ section:Int) { | |
if let cv = self.collectionView { | |
let indexPath = IndexPath(item: 1, section: section) | |
if let attributes = cv.layoutAttributesForSupplementaryElement(ofKind: UICollectionElementKindSectionHeader, at: indexPath) { | |
let cell = collectionView.cellForItem(at: indexPath) | |
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 5, options: [], | |
animations: { | |
cell!.transform = CGAffineTransform(scaleX: 0.9, y: 0.9) | |
}, | |
completion: { finished in | |
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 5, options: .curveEaseInOut, | |
animations: { |