Skip to content

Instantly share code, notes, and snippets.

View SwiftFoxx's full-sized avatar
💡
Innovating intelligently

Koushik Mudi SwiftFoxx

💡
Innovating intelligently
  • Utah Tech Labs
  • Kolkata, West Bengal, India
View GitHub Profile
@SwiftFoxx
SwiftFoxx / ImageDarkness.swift
Created August 12, 2020 07:56 — forked from adamcichy/ImageDarkness.swift
Determine if a UIImage is generally dark or generally light in Swift 3
extension CGImage {
var isDark: Bool {
get {
guard let imageData = self.dataProvider?.data else { return false }
guard let ptr = CFDataGetBytePtr(imageData) else { return false }
let length = CFDataGetLength(imageData)
let threshold = Int(Double(self.width * self.height) * 0.45)
var darkPixels = 0
for i in stride(from: 0, to: length, by: 4) {
let r = ptr[i]
@emotality
emotality / duplicate_line_xcode.md
Last active August 20, 2025 18:31
Xcode - Duplicate Line key binding

NOTE (2022-07-09): Xcode finally added this functionality in Xcode 14, please see release notes here:

New Features in Xcode 14 Beta 3
When editing code, the Edit > Duplicate menu item and its corresponding keyboard shortcut now duplicate the selected text — or the line that currently contains the insertion point, if no text is selected. (8614499) (FB5618491)


Xcode line duplicate

Bind keys to duplicate lines in Xcode