Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
extension Color {
public static func fromHexString (_ hex: String) -> Color {
let hexString = prepareHexString(hex)
guard hexString.count == 6 else { return Color.gray }
return Color(makeUIColorFromRgbValue(makeHexInteger(hexString)))
}
private static func prepareHexString(_ hexString: String) -> String {
@zs40x
zs40x / iterm2-solarized.md
Created March 8, 2021 05:21 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

using System;
using System.Threading;
using System.Threading.Tasks;
namespace AsyncTest
{
class Program
{
static void Main(string[] args)
{
extension Collection where Indices.Iterator.Element == Index {
subscript (safe index: Index) -> Generator.Element? {
return indices.contains(index) ? self[index] : nil
}
}
class ArrayLookup {
private let array = ["Hello", "World"]
import UIKit
@IBDesignable
class BorderedButton: UIButton {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setup()
}
guard let settingsURL = URL.init(string: UIApplicationOpenSettingsURLString) else { return }
guard UIApplication.shared.canOpenURL(settingsURL) else { return }
UIApplication.shared.open(settingsURL, completionHandler: nil )
class List<T> {
private let listItems: [T]
init() {
self.listItems = [T]()
}
init(listItems: [T]) {
self.listItems = listItems
}
class ImmutableList<T> {
private let listItems: [T]
init() {
self.listItems = [T]()
}
init(listItems: [T]) {
self.listItems = listItems
}
var sensorValid =
new Valid.Sensor("TemSensor 2", new List<double> { 12.4D, 77.2D, 88.1D });
var reportGenerator =
new Valid.SensorReportGenerator(
new FileSystem(),
new PlainTextSensorReportGenerator(sensorValid)
);
reportGenerator.GenerateAndStoreReport("Report_2.txt");
[TestFixture]
public class Valid
{
[Test]
public void TestReportGeneration()
{
var sensorName = "TempSensor 1";
var sensor = new Sensor(sensorName, new List<double>() { 1.0D });
var expectedContent =