g++ main.cpp
For C++11
g++ -std=c++11 main.cpp
# Append image horizontally | |
magick image1.png image2.png +append -gravity center -undercolor clear out.png | |
# Add annotation | |
magick -font helvetica -gravity north -fill red -undercolor white -pointsize 24 -annotate +0+8 image.png "Text" out.png | |
# Put screenshots in bezel | |
magick -background none -gravity center screenshot.png -extent 1400x2700 bezel.png -composite out.png |
# Generate Swift source files from a `.xcdatamodeld` file. | |
xcrun momc \ | |
--action generate \ | |
--swift-version 5.0 \ | |
/path/to/MyModel.xcdatamodeld \ | |
~/path/to/output/dir |
struct NSLocalizedString { | |
enum Bundle { | |
case main | |
} | |
var key: String | |
var value: String | |
var comment: String | |
init(_ key: String, tableName: Int?, bundle: Bundle?, value: String, comment: String) { |
#!/usr/bin/env swift | |
// swift aina.swift <n> | |
import Foundation | |
func p(_ n: Int) -> [String] { | |
if n == 0 { return ["A"] } | |
let p1 = [" A ", "A A", "AAA", "A A", "A A"] |
iOS Simlator Commands | |
# Uninstall an app from simulator | |
xcrun simctl uninstall <device_id> <app_identifier> | |
# Example: | |
# xcrun simctl uninstall 0BFBAE3C-DD58-4DD7-8F24-E9D9674A4004 com.apple.App | |
# Screenshot | |
xcrun simctl io booted screenshot </path/to/save.png> |
#!/usr/bin/env swift | |
CommandLine.arguments // Get command-line arguments in the form of Swift array | |
print(_:separator:terminator) // Print to stdout | |
while let line = readLine() { … } // Read from stdin line-by-line |
import PlaygroundSupport | |
class Node: CustomStringConvertible { | |
var name = "" | |
var edges = [Edge]() | |
init(_ name: String) { | |
self.name = name | |
} |
```swift | |
⭕️ | |
observable1.flatMap { [weak self] ... in | |
print(self?.value) | |
return observable2.flatMap { ... in in | |
print(self?.value) | |
} | |
} | |
⭕️ |
extension NSAttributedString { | |
convenience init?(htmlString: String) { | |
guard let data = htmlString.data(using: .unicode) else { return nil } | |
let options: [NSMutableAttributedString.DocumentReadingOptionKey: Any] = [.documentType: NSAttributedString.DocumentType.html] | |
do { | |
try self.init(data: data, options: options, documentAttributes: nil) | |
} catch { | |
return nil | |
} | |
} |