Skip to content

Instantly share code, notes, and snippets.

View mjdescy's full-sized avatar

Michael Descy mjdescy

View GitHub Profile
@ningsuhen
ningsuhen / Regex.swift
Last active April 27, 2019 18:39
Swift extension for Native String class to support Regex match and Regex replace. Credit - http://www.swift-studies.com/blog/2014/6/12/regex-matching-and-template-replacement-operators-in-swift
import Foundation
struct Regex {
var pattern: String {
didSet {
updateRegex()
}
}
var expressionOptions: NSRegularExpressionOptions {
didSet {
#!/bin/tcsh
# Grab user information.
echo "PrivateInternetAccess OpenVPN Setup:"
echo " https://www.privateinternetaccess.com/pages/client-control-panel"
echo " -> PPTP/L2TP/SOCKS Username and Password"
echo -n "User: "
set user = $<
echo -n "Pass: "
set pass = $<
@aclissold
aclissold / NSUserDefaults+UIColor.swift
Created June 1, 2015 14:52
Swift NSUserDefaults UIColor extension
extension NSUserDefaults {
func colorForKey(key: String) -> UIColor? {
var color: UIColor?
if let colorData = dataForKey(key) {
color = NSKeyedUnarchiver.unarchiveObjectWithData(colorData) as? UIColor
}
return color
}