This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func processHTML(_ string: String) -> NSAttributedString { | |
let stringData = string.data(using: .utf8)! | |
let attrString = try! NSMutableAttributedString( | |
data: stringData, | |
options: [.documentType: NSAttributedString.DocumentType.html], | |
documentAttributes: nil | |
) | |
var boldRanges: [NSRange] = [] | |
var italicRanges: [NSRange] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Credit to Joel Ekström at Spotify for original creation. | |
# USAGE: | |
# 1. Replace `{ insert repo url here }` at the bottom with your GH repo's URL | |
# 2. `chmod +x open-xcode-selection-in-gh.sh` to make it executable | |
# 3. Create a new Behaviour in Xcode settings. In the bottom, select "Run script", and choose this file | |
# 4. Next to your new behaviour in the list, click the cmd symbol to add to keyboard shortcut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
class MyViewController : UIViewController { | |
override func loadView() { | |
let pillView = UIView(frame: CGRect(x: 64, y: 64, width: 32, height: 128)) | |
pillView.backgroundColor = .white | |
pillView.layer.cornerRadius = pillView.frame.width / 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "WASD Arrow Keys", | |
"rules": [ | |
{ | |
"description": "WASD Mode [Capslock as trigger key]", | |
"manipulators": [ | |
{ | |
"type": "basic", | |
"from": { | |
"key_code": "caps_lock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TurnipCalculator | |
// | |
// Translated from https://gist.github.com/Treeki/85be14d297c80c8b3c0a76375743325b#file-turnipprices-cpp | |
// | |
// TODO: Calculation is slightly off from C++ impl still | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Lighten Blend Filter | |
let lightenFilter = CIFilter(name: "CILightenBlendMode")! | |
let solidDarkColorImage = CIImage(color:CIColor(red: 0.09, green: 0.14, blue: 0.32)) | |
lightenFilter.setValuesForKeys([ | |
"inputImage": multiplyFilter.outputImage!, | |
"inputBackgroundImage": solidDarkColorImage | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Multiply Blend Filter | |
let multiplyFilter = CIFilter(name: "CIMultiplyBlendMode")! | |
let solidLightColorImage = CIImage(color: CIColor(red: 0.33, green: 0.98, blue: 0.25)) | |
multiplyFilter.setValuesForKeys([ | |
"inputImage": grayscaleFilter.outputImage!, | |
"inputBackgroundImage": solidLightColorImage | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: Grayscale Filter | |
let grayscaleFilter = CIFilter(name: "CIPhotoEffectMono")! | |
grayscaleFilter.setValue(CIImage(cgImage: image.cgImage!), forKey: kCIInputImageKey) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController with a single shape drawn inside it. | |
// Tapping on the shape will cause a red minimum-bounding box to be drawn | |
// around the shape's bounds. | |
// | |
// Included as a single monofile for the sake of including it all within a single gist. | |
// Core logic centers around the Flood Fill algorithm with an interative, BFS approach used. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class Generator { | |
private var store = [[""]] | |
func genBalanced(_ n: Int) -> [String] { | |
if n < store.count { | |
return store[n] | |
} |
NewerOlder