Skip to content

Instantly share code, notes, and snippets.

Dan Leonard MacMeDan

Block or report user

Report or block MacMeDan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MacMeDan
MacMeDan / validChars.swift
Last active Mar 6, 2018
String extension that filters out invalid characters for enum case names.
View validChars.swift
extension String {
// created by - Dan Leonard 3/6/2018
// https://gist.github.com/MacMeDan/ef9e49dfbab19f084da5cb43d48a77b0
// NOTE: does not account for individual numbers
var validChars: String {
return String(describing: filter { String($0).rangeOfCharacter(from: .alphanumerics) != nil })
}
}
@MacMeDan
MacMeDan / camelCased.swift
Last active Mar 6, 2018
Take a string and make a camelCased version of it.
View camelCased.swift
extension String {
// created by - Dan Leonard 3/6/2018
// https://gist.github.com/MacMeDan/491fbe1361bafaa009adce6bf549f5d5
/// lowercased to start and Capitalised each segment that fallows.
/// if there are more then 10 words in the sentence
var camelCased: String {
var componets = self.components(separatedBy: " ")
guard let first = componets.first?.lowercased() else { fatalError("Invalid string for enum generation") }
if componets.count == 1 { return "\(first)"}
let rest = componets.dropFirst().flatMap{ $0.capitalized }.joined()
View Keybase.md

Keybase proof

I hereby claim:

  • I am macmedan on github.
  • I am macmedan (https://keybase.io/macmedan) on keybase.
  • I have a public key ASBmUfgfucVoU0MNe7QCDNrzAxCLCJZ-qq9NNs1uM2I4Igo

To claim this, I am signing this object:

You can’t perform that action at this time.