Skip to content

Instantly share code, notes, and snippets.

View carson-katri's full-sized avatar

Carson Katri carson-katri

View GitHub Profile
@carson-katri
carson-katri / Firmware-API-Support.md
Last active January 24, 2018 03:39
RebbleOS support for Pebble APIs wiki page

Thanks to @Helco's pbw_api_info we can make a list of supported/unsupported APIs in RebbleOS.

Download the SQLite database (thanks to @jwise for making the original database). Unfortunately, the list of supported APIs is incomplete, but will be improved over time.

To figure out which top Pebble APIs are already implemented, you can run:

SELECT apis.name, rebbleapis.name, COUNT(*)
FROM apirefs
JOIN apis ON apirefs.api=apis.id
@carson-katri
carson-katri / Dockerfile
Last active April 24, 2018 12:16
Dockerfile for RebbleOS
FROM ubuntu:16.04
# Based on the Dockerfile by André Dumas
# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
python2.7-dev \
python-pip \
libfreetype6 \
func combineWords() -> TupleView<(Text, Text)> {
let _a = Text("Hello")
let _b = Text("World")
return ViewBuilder.buildBlock(_a, _b)
}
@carson-katri
carson-katri / view-builder.swift
Last active July 16, 2019 00:34
Stack Builder Example
@ViewBuilder
func combineWords() -> TupleView<(Text, Text)> {
Text("Hello")
Text("World")
}
combineWords()
@_functionBuilder
struct GreetingBuilder {
static func buildBlock(_ items: String...) -> [String] {
return items.map { "Hello \($0)" }
}
}
NSAttributedString {
"Hello "
.color(.red)
"World"
.color(.blue)
.underline(.blue)
}
@carson-katri
carson-katri / list.swift
Last active July 26, 2019 16:45
List in SwiftUI
List(todos, id: \.id) { todo in
HStack {
Image(systemName: "checkmark.circle\(todo.completed ? ".fill" : "")")
Text(todo.title)
}
}
extension NSAttributedString {
convenience init(@AttributedStringBuilder _ content: () -> NSAttributedString) {
self.init(attributedString: content())
}
}
extension String {
func colored(_ color: UIColor) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.foregroundColor : color])
}
func background(_ color: UIColor) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.backgroundColor: color])
}
func underline(_ color: UIColor, style: NSUnderlineStyle = .single) -> NSAttributedString {
NSAttributedString(string: self, attributes: [.underlineColor: color, .underlineStyle: style.rawValue])
}
NSAttributedString {
"Hello "
.foregroundColor(.red)
.font(UIFont.systemFont(ofSize: 10.0))
"World"
.foregroundColor(.green)
.underline(.orange, style: .thick)
}