Skip to content

Instantly share code, notes, and snippets.

View salabaha's full-sized avatar

Roman Salabay salabaha

View GitHub Profile
@Sorix
Sorix / UIView+round.swift
Created August 24, 2016 18:39
Round specified corners of UIView
// Example: view.round([.TopLeft, .TopRight], radius: 15)
extension UIView {
/**
Rounds the given set of corners to the specified radius
- parameter corners: Corners to round
- parameter radius: Radius to round to
*/
func round(corners: UIRectCorner, radius: CGFloat) {
@onmyway133
onmyway133 / requestForDuplicatedObjects.swift
Created October 30, 2015 11:46
requestForDuplicatedObjects.swift
func requestForDuplicatedObjects(moc: NSManagedObjectContext) -> NSFetchRequest {
let objectsToKeepRequest = NSFetchRequest(entityName: "Recipe")
// Fetch object IDs representing objects to keep
let ed = NSExpressionDescription()
ed.expression = NSExpression.expressionForEvaludatedObject()
ed.name = "SELF"
ed.expressionResultType = .ObjectIDAttributeType
objectsToKeepRequest.propertiesToFetch = [ed]
@preble
preble / DateRange.swift
Last active July 16, 2019 14:06
Experimenting with creating a SequenceType for iterating over a range of dates. Blogged here: http://adampreble.net/blog/2014/09/iterating-over-range-of-dates-swift/
import Foundation
func > (left: NSDate, right: NSDate) -> Bool {
return left.compare(right) == .OrderedDescending
}
extension NSCalendar {
func dateRange(startDate startDate: NSDate, endDate: NSDate, stepUnits: NSCalendarUnit, stepValue: Int) -> DateRange {
let dateRange = DateRange(calendar: self, startDate: startDate, endDate: endDate, stepUnits: stepUnits, stepValue: stepValue, multiplier: 0)
return dateRange