Skip to content

Instantly share code, notes, and snippets.

View CBeloch's full-sized avatar

Christopher Beloch CBeloch

View GitHub Profile
@phranck
phranck / PlatformVisibility.swift
Last active November 13, 2022 22:40
A Swift view modifier to handle visibility of views for specific platforms
import SwiftUI
public struct Platform: OptionSet {
public var rawValue: UInt8
public static let iOS = Platform(rawValue: 1 << 0)
public static let macOS = Platform(rawValue: 1 << 1)
public static let tvOS = Platform(rawValue: 1 << 2)
public static let watchOS = Platform(rawValue: 1 << 3)
public static let all: Platform = [.iOS, .macOS, .tvOS, .watchOS]
extension Result {
public func `catch`(_ handler: () throws -> Success) -> Result<Success, Error> {
flatMapError { _ in
.init { try handler() }
}
}
public func `catch`(_ handler: (Failure) throws -> Success) -> Result<Success, Error> {
flatMapError { error in
.init { try handler(error) }
@jordansinger
jordansinger / iPod.swift
Created July 27, 2020 21:19
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
@mattt
mattt / UIViewControllerPreview.swift
Last active January 8, 2024 23:09
Generic structures to host previews of UIView and UIViewController subclasses.
import UIKit
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct UIViewControllerPreview<ViewController: UIViewController>: UIViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
}
import Foundation
extension Character {
var isEmoji: Bool {
return unicodeScalars.allSatisfy { $0.properties.isEmoji }
}
}
func recentlyUsedEmoji() -> [Character]? {
#if os(iOS)
@codingdudecom
codingdudecom / 80s-fonts-text-effect-5-css-neon-font-text-effect.markdown
Created July 22, 2019 11:59
80s Fonts Text Effect 5: CSS Neon Font Text Effect
@tunguskha
tunguskha / Gradient shadow in pure CSS.md
Last active May 4, 2023 06:40
Gradient shadow in pure CSS

Gradient shadow in pure CSS

alt text

HTML
<button>Let's Go !</button>
@chadlavi
chadlavi / upload-sketch-to-git.sh
Last active September 10, 2021 10:51
shell script to work as middleware between Sketch and and git repo. syntax: 'upload.sh [filename] "optional commit message"'
#!/bin/sh
# some parts of this forked from https://github.com/blended/sketch-collaboration
# cf. https://github.com/chadlavi/sketch-collaboration
if [ ! `command -v jq` ]; then
echo "you need to install jq. If you use Homebrew, try 'brew install jq'"
exit 1
fi
if [ -z "$1 ]; then
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@kylef
kylef / post-checkout.sh
Last active December 11, 2019 21:09
Git post-checkout hook to install CocoaPods
#!/bin/bash
#
### CocoaPods git-checkout hook
#
# This is a hook which you can install, it will automatically
# run `pod install` when you do a git pull/clone/checkout.
#
# The hook can be used to make CocoaPods usable with Xcode CI.
#
## Installation