Skip to content

Instantly share code, notes, and snippets.

@foorenxiang
foorenxiang / fix_exfat_drive.md
Last active March 17, 2023 07:09 — forked from scottopell/fix_exfat_drive.md
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
@zthxxx
zthxxx / Activate Office 2019 for macOS VoL.md
Last active May 6, 2024 13:00
crack activate Office on mac with license file
@adamcichy
adamcichy / ImageDarkness.swift
Created March 15, 2017 15:28
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]
@khanlou
khanlou / Fonts.swift
Created October 6, 2016 21:10
Print all fonts in Swift 3
UIFont.familyNames.forEach({ familyName in
let fontNames = UIFont.fontNames(forFamilyName: familyName)
print(familyName, fontNames)
})
@Bhavdip
Bhavdip / sketch-never-ending.md
Created October 6, 2016 15:53
Modify Sketch to never ending trial

###Sketch trial non stop

Open hosts files:

$ open /private/etc/hosts

Edit the file adding:

127.0.0.1 backend.bohemiancoding.com

127.0.0.1 bohemiancoding.sketch.analytics.s3-website-us-east-1.amazonaws.com

@stinger
stinger / Swift3Base64.swift
Created June 17, 2016 14:58
Swift 3: Base64 encoding and decoding strings
//: # Swift 3: Base64 encoding and decoding
import Foundation
extension String {
//: ### Base64 encoding a string
func base64Encoded() -> String? {
if let data = self.data(using: .utf8) {
return data.base64EncodedString()
}
return nil
Plug Ins :-
1. https://github.com/rickytan/RTImageAssets
2. https://github.com/nomad/shenzhen
Loding Indicators :-
1. https://github.com/mobitar/Starburst
2. https://github.com/jdg/MBProgressHUD
3. https://github.com/Marxon13/M13ProgressSuite
4. https://github.com/danielamitay/DACircularProgress
@bgreenlee
bgreenlee / UIImage+Resize.swift
Created November 23, 2015 05:24
Swift port of UIImage+Resize, UIImage+Alpha, and UIImage+RoundedCorner, from http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
//
// UIImage+Resize.swift
// Port of UIImage+Resize.m
// from http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
//
import Foundation
import UIKit
extension UIImage {
@jmcd
jmcd / Foo.swift
Last active February 22, 2018 07:10
MKMapView contested annotation location handling in Swift
import UIKit
import MapKit
/**
* Define behaviour of app through its lifetime
*/
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
@dhavaln
dhavaln / ViewController.swift
Created September 4, 2015 10:13
Swift / iOS - Extract Color from Image
func extractColor(image: UIImage){
let pixel = UnsafeMutablePointer<CUnsignedChar>.alloc(4)
let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue)
let context = CGBitmapContextCreate(pixel, 1, 1, 8, 4, colorSpace, bitmapInfo)
CGContextDrawImage(context, CGRectMake(0, 0, 1, 1), image.CGImage)
var color: UIColor? = nil
if pixel[3] > 0 {