Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mikesteele on github.
  • I am mikesteele (https://keybase.io/mikesteele) on keybase.
  • I have a public key whose fingerprint is B845 3308 202C 5152 06EA 6FC9 24A6 B169 9877 0560

To claim this, I am signing this object:

.grid {
display: grid;
grid-template-columns: repeat(n, 1fr);
}
@mikesteele
mikesteele / hashStringToColor.swift
Last active June 12, 2018 15:19
Hash string to UIColor in Swift
func hashStringToColor(string: String) -> UIColor {
var hash: Int = string.hashValue
var r: Int = (hash & 0xFF0000) >> 16
var g: Int = (hash & 0x00FF00) >> 8
var b: Int = (hash & 0x0000FF)
return rgbaToUIColor(r: r, g: g, b: b, a: 1.0)
}
func rgbaToUIColor(#r: Int, #g: Int, #b: Int, #a: Float) -> UIColor {
let floatRed = CGFloat(r) / 255.0
@mikesteele
mikesteele / unescape.swift
Last active May 27, 2022 14:36
Unescape HTML special characters of String in Swift
func convertSpecialCharacters(string: String) -> String {
var newString = string
var char_dictionary = [
"&": "&",
"&lt;": "<",
"&gt;": ">",
"&quot;": "\"",
"&apos;": "'"
];
for (escaped_char, unescaped_char) in char_dictionary {