Skip to content

Instantly share code, notes, and snippets.

View yujinqiu's full-sized avatar
💭
🚀

yujinqiu

💭
🚀
View GitHub Profile
@yujinqiu
yujinqiu / WeatherView.swift
Created November 8, 2023 03:30 — forked from unixzii/WeatherView.swift
A demo of implementing iOS Weather card in SwiftUI.
import SwiftUI
struct HeaderView: View {
var body: some View {
HStack {
Image(systemName: "info.circle.fill")
.resizable()
.frame(width: 12, height: 12)
Text("Section Header")
.font(.system(size: 13))
@yujinqiu
yujinqiu / gist:f266ab137b6f3ee6f7a1e7a253fbb014
Created January 22, 2022 03:16 — forked from andrewgrant/gist:477c7037b1fc0dd7275109d3f2254ea9
Example changes for automake to support x86 & arm64 plus universal binaries
# configure.ac
# add an --enable-macos-universal-binary flag that when building for mac
# create a universal x86_64 / arm64 binary
AC_ARG_ENABLE([macos-universal-binary],
[AS_HELP_STRING([--enable-macos-universal-binary],
[Create an universal x86_64+arm64 binary when building for macos)])],,
[enable_macos_universal_binary=no])
# Determine if we're building for macos/darwin by checking for macos & darwin
@yujinqiu
yujinqiu / CombineMockClient.swift
Last active April 2, 2021 04:15 — forked from stinger/CombineMockClient.swift
Mock data loader using Combine
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknownError
case unknownURL
case unknownData
case parserError(reason: String)
case apiError(reason: String)
@yujinqiu
yujinqiu / CombineFetcherAndDecoder.swift
Created April 1, 2021 07:12 — forked from stinger/CombineFetcherAndDecoder.swift
Combine - fetching and decoding JSON data
import Foundation
import Combine
enum APIError: Error, LocalizedError {
case unknown, apiError(reason: String), parserError(reason: String)
var errorDescription: String? {
switch self {
case .unknown:
return "Unknown error"
@yujinqiu
yujinqiu / Settings.swift
Created February 22, 2021 10:51 — forked from jordansinger/Settings.swift
iOS 6 Settings built in SwiftUI
//
// Settings.swift
// Settings
//
// Created by Jordan Singer on 2/20/21.
//
import SwiftUI
struct Settings: View {
//
// ContentView.swift
//
//
// Created by Bernstein, Joel on 7/4/20.
//
import SwiftUI
struct ElementModel: Identifiable
@yujinqiu
yujinqiu / iPod.swift
Created September 25, 2020 05:18 — forked from jordansinger/iPod.swift
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
@yujinqiu
yujinqiu / SearchView.swift
Created September 25, 2020 02:44
mac os SearchView
import SwiftUI
extension NSTextField {
open override var focusRingType: NSFocusRingType {
get { .none }
set { }
}
}
@yujinqiu
yujinqiu / formatBytes.swift
Created September 9, 2020 06:58 — forked from mminer/formatBytes.swift
Formats bytes into a more human-readable form (e.g. MB).
import Foundation
func format(bytes: Double) -> String {
guard bytes > 0 else {
return "0 bytes"
}
// Adapted from http://stackoverflow.com/a/18650828
let suffixes = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
let k: Double = 1000
@yujinqiu
yujinqiu / service-checklist.md
Created December 22, 2016 04:05 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?