Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mrackwitz's full-sized avatar

Marius Rackwitz mrackwitz

View GitHub Profile
@mrackwitz
mrackwitz / ChristmasTodoListRiddleApp.swift
Created December 24, 2020 21:17
Christmas Todo List App
import SwiftUI
// MARK: - App
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
@mrackwitz
mrackwitz / AutoHeightLabelView.swift
Created October 27, 2020 19:53
A UILabel-based SwiftUI view which auto-expands to the width of the container, and only expand to render the full height of the label.
struct AutoHeightLabelView: View {
var attributedString: NSAttributedString
var body: some View {
HorizontalGeometryReader { width in
UILabelView(
attributedString: attributedString,
preferredMaxLayoutWidth: width
)
}
@mrackwitz
mrackwitz / Debounced.swift
Created October 2, 2020 19:41 — forked from nerdsupremacist/Debounced.swift
Debounced Property Wrapped
import SwiftUI
import Combine
@propertyWrapper
struct Debounced<Value>: DynamicProperty {
private class Box: ObservableObject {
let value = PassthroughSubject<Value, Never>()
@Published
private(set) var debounced: Value
@mrackwitz
mrackwitz / Dates.swift
Created November 4, 2017 19:15
Dates around DST end
import Foundation
let calendar = Calendar(identifier: .gregorian)
// Daylight Saving Time ends in 2017 on Nov 5th, 2:00 AM in the United States.
// Let's instantiate some `Date`s around that.
let nov4_1am = calendar.date(from: DateComponents(year: 2017, month: 11, day: 4, hour: 1))!
let nov4_2am = calendar.date(from: DateComponents(year: 2017, month: 11, day: 4, hour: 2))!

Keybase proof

I hereby claim:

  • I am mrackwitz on github.
  • I am mrackwitz (https://keybase.io/mrackwitz) on keybase.
  • I have a public key ASApegb3sa4x4fXpvI2BzyiPyoryjA9sc6HwWNxh_X9uTwo

To claim this, I am signing this object:

@mrackwitz
mrackwitz / pod-env.sh
Created February 24, 2016 18:47
Poor man's pod env
# Note: This script makes compromises.
# Default to `pod env` if available.
# If you use Bundler, run it with `bundle exec`.
INDENT=' '
function indent() {
sed "2,\$s/^/$INDENT/"
}
function repos {
@mrackwitz
mrackwitz / README.md
Last active February 10, 2016 20:27
Swift 2 Error Handling Demo

Swift 2 Error Handling Demo

This small example is a little CLI tool to demonstrate how you can make use of the new error handling of Swift 2. It was part of my talk "Swift 2 - Error Handling".

Build & Run

  1. Clone the gist.
  2. Compile by xcrun -sdk macosx swiftc main.swift.
  3. Run the executable and pass the amount as first argument. (./main AMOUNT)
@mrackwitz
mrackwitz / Podfile.rb
Last active June 14, 2018 13:13
Force Duplicate Pod Targets by Pre Install Hook
# This will enforce that the pods with the names in the list below will be duplicated.
targets_to_duplicate = %w(AFNetworking)
pre_install do |installer|
pod_targets = installer.pod_targets.flat_map do |pod_target|
targets_to_duplicate.include?(pod_target.name) ? pod_target.scoped : pod_target
end
installer.aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets = pod_targets.select do |pod_target|
pod_target.target_definitions.include?(aggregate_target.target_definition)
end
@mrackwitz
mrackwitz / inspect.rb
Last active August 29, 2015 14:21
Inspection of usage of xcconfig values in podspecs in the CocoaPods master repo
require 'pathname'
require 'json'
def xcconfigs_merge(json, xcconfig)
(json['xcconfig'] || {}).each do |key,value|
(xcconfig[key] ||= []) << value
end
(json['subspecs'] || []).each do |subspec|
xcconfigs_merge(subspec, xcconfig)
end
@mrackwitz
mrackwitz / buildFacebookSdk.sh
Last active August 29, 2015 14:01
Script for iOS Projects to build and cache Facebook SDK when included as submodule/subtree
#!/bin/sh
# buildFacebookSdk.sh
#
# This can be included as a build phase in Xcode.
# It will ensure that the Facebook-SDK is built, when your project was
# originally checked out and whenever the commit pointer was changed.
# Furthermore you can use it with your CI. It will integrate seamlessly with
# the xctool output.
#