Skip to content

Instantly share code, notes, and snippets.

View SpectralDragon's full-sized avatar
🎯
Focusing

Vladislav Prusakov SpectralDragon

🎯
Focusing
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active May 1, 2024 21:23
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@rileytestut
rileytestut / ExportIPA.swift
Last active March 4, 2024 09:36
Export Swift Playgrounds .ipa
import Foundation
// Export running app as .ipa, then return path to exported file.
// Returns String because app crashes when returning URL from async function for some reason...
func exportIPA() async throws -> String
{
// Path to app bundle
let bundleURL = Bundle.main.bundleURL
// Create Payload/ directory
@mugbug
mugbug / AssertEquals+Diff.swift
Created June 10, 2021 20:29
XCTestCase wrapper for asserting equatable structs with formatted error diff message
import XCTest
// Credits: https://github.com/pointfreeco/swift-composable-architecture
//swiftlint:disable empty_string force_cast force_unwrapping unused_closure_parameter function_body_length
class MyCustomTestCase: XCTestCase {
func assertEqual<T: Equatable>(
expected: T,
actual: T
) {
@atimca
atimca / iOS Interview Questions
Created April 14, 2020 14:49
iOS interview questions to interviewer from candidate
Question set for interviews
Developer
Tech
- [ ] How many projects do you have
- [ ] Which architectures approaches do you use
- [ ] Which swift version / legacy objc, c what are you going to do with it.
- [ ] Do you do layout in xibs or in code?
- [ ] What do you think about reactive programming (RxSwift)

Debugging the Swift Toolchain

Use these steps to debug components of the Swift toolchain. This allows you to see Swift's source code from the debugger – instead of disassembly. The debugger can also provide some variable names and values. This has been initially tested with libswiftCore.dylib.

These instructions were updated as of Swift 5.2.1.

Prerequisites

@kean
kean / _DynamicProperty.swift
Last active February 23, 2020 22:47
_DynamicProperty
// A speculative _ViewRendererHost implementation which uses Mirror (Swift reflection) to find all
// of the dynamic properties (`DynamicProperty`) associated with a given view (`View`), observe
// the changes to these properties and automatically refresh the view whenever any of these property change.
protocol _DynamicProperty {
var objectWillChange: AnyPublisher<Void, Never> { get }
}
extension ObservedObject: _DynamicProperty {
var objectWillChange: AnyPublisher<Void, Never> {
@dsabanin
dsabanin / enable-xcode-debug-menu.sh
Last active November 7, 2022 16:17
Enable internal Xcode debug menu in Xcode 11
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES
sudo mkdir -p /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode
sudo touch /Applications/Xcode.app/Contents/Developer/AppleInternal/Library/Xcode/AppleInternal.plist
# Don't forget to restart Xcode
@Amzd
Amzd / UIKitTabView.swift
Last active March 16, 2024 10:40
UIKitTabView. SwiftUI tab bar view that respects navigation stacks when tabs are switched (unlike the TabView implementation)
/// An iOS style TabView that doesn't reset it's childrens navigation stacks when tabs are switched.
public struct UIKitTabView: View {
private var viewControllers: [UIHostingController<AnyView>]
private var selectedIndex: Binding<Int>?
@State private var fallbackSelectedIndex: Int = 0
public init(selectedIndex: Binding<Int>? = nil, @TabBuilder _ views: () -> [Tab]) {
self.viewControllers = views().map {
let host = UIHostingController(rootView: $0.view)
host.tabBarItem = $0.barItem
import Foundation
extension Character {
var isEmoji: Bool {
return unicodeScalars.allSatisfy { $0.properties.isEmoji }
}
}
func recentlyUsedEmoji() -> [Character]? {
#if os(iOS)
@YannisDC
YannisDC / Apple Card Demo
Created September 20, 2019 14:06
Simple Apple Card Combined Radial Gradient Demo
import SwiftUI
struct ContentView: View {
@State var show = false
var body: some View {
VStack{
ZStack{
Rectangle()
.fill(Color.white)