Skip to content

Instantly share code, notes, and snippets.

Avatar

Michel Storms stormychel

View GitHub Profile
View removeSpecialCharacters.swift
import Foundation
extension String {
var withoutPunctuations: String {
return self.components(separatedBy: CharacterSet.punctuationCharacters).joined(separator: "")
}
}
let originalStr:String = "hello, (Nice to- meet 한국 école %&$you all. 123 ! Давай العربية 😀"
@EnesKaraosman
EnesKaraosman / RandomColor.swift
Last active Jul 11, 2021
Generatin random color in SwiftUI & UIKit
View RandomColor.swift
#if canImport(UIKit)
import UIKit
extension UIColor {
static var random: UIColor {
return UIColor(
red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1)
)
@MaciejGad
MaciejGad / NSImageExtensions.swift
Created Mar 24, 2017
NSImage extensions for easy resizing, cropping and saving png images. Version updated for Swift 3. Originally by Raphael Hanneken https://gist.github.com/raphaelhanneken/cb924aa280f4b9dbb480
View NSImageExtensions.swift
extension NSImage {
/// Returns the height of the current image.
var height: CGFloat {
return self.size.height
}
/// Returns the width of the current image.
var width: CGFloat {
return self.size.width
@keithweaver
keithweaver / create-folder.py
Created Mar 10, 2017
Create a folder with Python
View create-folder.py
import os
def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)