Skip to content

Instantly share code, notes, and snippets.

@molind
molind / SortedDictionary.swift
Last active September 7, 2020 11:36
SortedDictionary used to sort contents before JSON serialization
// We have a parent just to pass face control in JSONSerialization
@objc class SortedDictionary: NSDictionary {
let _values: NSMutableArray = []
let _keys: NSMutableOrderedSet = []
override var count: Int {
return _keys.count
}
override func keyEnumerator() -> NSEnumerator {
//
// Copyright (c) 2016, 2018 Nikolai Ruhe. All rights reserved.
//
import Foundation
public extension FileManager {
/// Calculate the allocated size of a directory and all its contents on the volume.
@lukaskollmer
lukaskollmer / hack.m
Created June 21, 2016 15:30
UITextView: Allow tapping links from NSAttributedString, but disallow text selection
/**
Note to self:
This UITextView class extension gets calles every time iOS wants to add a new gesture recognizer to the textView.
It checks for the type of the gesture recognizer (Long Press) and then for the associated action.
Only if the action is ``smallDelayRecognizer:``, the gestuere recognizer will stay enabled.
All otheer long press gestures will be disabled.
Purpose:
Allow user interaction with the links in the attributedText, but disallow text selection
@Coeur
Coeur / README.md
Last active October 18, 2020 21:41 — forked from lopezjurip/README.md
Write to NTFS on OSX Yosemite and El Capitan

Install osxfuse (3.x.x) from https://github.com/osxfuse/osxfuse/releases.

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Update Homebrew formulae:

brew update
@natecook1000
natecook1000 / operatorCharacters.swift
Last active January 3, 2024 21:33
Allowed characters for Swift operators
import Foundation
extension UnicodeScalar : ForwardIndexType {
public func successor() -> UnicodeScalar {
return UnicodeScalar(value + 1)
}
}
var operatorHeads: [UnicodeScalar] = Array("=-+!*%<>&|^~?".unicodeScalars)
operatorHeads += Array("\u{00A1}" ... "\u{00A7}")
@BenziAhamed
BenziAhamed / CGCreatePattern.swift
Last active May 24, 2022 22:24
Demonstration of using CGCreatePattern in Swift
//: Playground - noun: a place where people can play
//: Copy this to one!
import UIKit
// With helpful insights from
// https://forums.developer.apple.com/message/15725#15725 via http://oleb.net/blog/2015/06/c-callbacks-in-swift/
// This is essential the standalone basic definition of a pattern
// that CGCreatePattern requires
@Coeur
Coeur / ARCHelper.h
Created October 11, 2012 08:03 — forked from nicklockwood/ARCHelper.h
ARC Helper
//
// ARC Helper
//
// Version 2.1
//
// Created by Nick Lockwood on 05/01/2012.
// Copyright 2012 Charcoal Design
//
// Distributed under the permissive zlib license
// Get the latest version from here:
@atomicbird
atomicbird / NSObject+setValuesForKeysWithJSONDictionary.h
Created January 11, 2012 02:35
NSObject category for handling JSON dictionaries. Described in detail at http://www.cimgf.com/2012/01/11/handling-incoming-json-redux/
//
// NSObject+setValuesForKeysWithJSONDictionary.h
// SafeSetDemo
//
// Created by Tom Harrington on 12/29/11.
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@nicklockwood
nicklockwood / ARCHelper.h
Last active November 20, 2018 10:02
ARC Helper
//
// ARC Helper
//
// Version 2.2
//
// Created by Nick Lockwood on 05/01/2012.
// Copyright 2012 Charcoal Design
//
// Distributed under the permissive zlib license
// Get the latest version from here:
@Coeur
Coeur / Get iOS MAC address.m
Created November 30, 2011 17:11
Get iOS MAC address #
/* Original source code courtesy John from iOSDeveloperTips.com */
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
+ (NSString *)getMacAddress
{
int mgmtInfoBase[6];