Skip to content

Instantly share code, notes, and snippets.

@sebjvidal
sebjvidal / SceneDelegate.swift
Created June 27, 2023 18:14
Custom UINavigationBar Height
// MARK: - SceneDelegate
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let navigationController = UINavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil)
(navigationController.navigationBar as! NavigationBar).preferredHeight = 88
navigationController.setViewControllers([ViewController()], animated: false)
@LeonardoCardoso
LeonardoCardoso / SyntaxProtocol+Extension.swift
Last active August 19, 2023 16:54
A SyntaxProtocol extension that simplifies the casting of all SyntaxProtocol derived entities.
import SwiftSyntax
// swift-syntax v509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-08-15-a
extension SyntaxProtocol {
var token: TokenSyntax? { self.as(TokenSyntax.self) }
var accessorBlock: AccessorBlockSyntax? { self.as(AccessorBlockSyntax.self) }
var accessorDeclList: AccessorDeclListSyntax? { self.as(AccessorDeclListSyntax.self) }
var accessorDecl: AccessorDeclSyntax? { self.as(AccessorDeclSyntax.self) }
var accessorEffectSpecifiers: AccessorEffectSpecifiersSyntax? { self.as(AccessorEffectSpecifiersSyntax.self) }
var accessorParameters: AccessorParametersSyntax? { self.as(AccessorParametersSyntax.self) }
@tylerstillwater
tylerstillwater / FeatureVoterTallyAPI.swift
Last active December 12, 2023 14:07
FeatureVoter Implementation using Tally instead of CountAPI
//
// FeatureVoter.swift
// Mutaclip
//
// Created by Tyler Stillwater on 5/10/23.
//
// Custom voter implementation for: https://github.com/AvdLee/Roadmap
// Note: will not work until this PR is merged: https://github.com/AvdLee/Roadmap/pull/71
@mobilinked
mobilinked / gist:9b6086b3760bcf1e5432932dad0813c0
Last active February 9, 2024 13:03
SwiftUI - prevent auto dismiss the sheet by drag down
//
// Created by https://quickplan.app on 2020/11/8.
//
import SwiftUI
/// Control if allow to dismiss the sheet by the user actions
/// - Drag down on the sheet on iPhone and iPad
/// - Tap outside the sheet on iPad
/// No impact to dismiss programatically (by calling "presentationMode.wrappedValue.dismiss()")
@diamantidis
diamantidis / 1_SFSymbols.scpt
Last active December 8, 2023 22:46
How to use AppleScript to generate an enum for the SF Symbols
activate application "SF Symbols"
tell application "System Events"
tell process "SF Symbols"
-- Click the “list” radio button.
click radio button 2 of radio group 1 of group 3 of toolbar 1 of window 0
tell outline 1 of scroll area 1 of splitter group 1 of window 0
select (row 1 where value of static text 1 of UI element 1 starts with "All")
@RoLYroLLs
RoLYroLLs / DeviceConstant.swift
Created December 31, 2019 19:03
A list of all Apple device names easily accessible through enums. particularly useful for PreviewProvider in Swift
//
// DeviceConstants.swift
// SampleApp
//
// Created by RoLY roLLs on 12/31/19.
// Copyright © 2019 RoLYroLLs Enterprises, LLC. All rights reserved.
//
/// Taken from https://developer.apple.com/documentation/swiftui/securefield/3289399-previewdevice
@LeonardoCardoso
LeonardoCardoso / feed.xml
Last active January 1, 2020 19:00
Jekyll XML RSS Feed
---
layout: null
permalink: /feed.xml
---
{% assign feed_url = page.url | absolute_url %}<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ site.title }}</title>
<subtitle>By {{ site.author.name }}</subtitle>
<link rel="alternate" type="text/html" href="{{ site.url }}" />
<link rel="self" type="application/atom+xml" href="{{ feed_url }}" />
@mxcl
mxcl / detweet.swift
Last active December 23, 2023 23:22
Delete all tweets and favorites older than two months ago. Instructions in comment.
#!/usr/bin/swift sh
import Foundation
import PromiseKit // @mxcl ~> 6.5
import Swifter // @mattdonnelly == b27a89
let swifter = Swifter(
consumerKey: "FILL",
consumerSecret: "ME",
oauthToken: "IN",
oauthTokenSecret: "https://developer.twitter.com/en/docs/basics/apps/overview.html"
@LeonardoCardoso
LeonardoCardoso / simulatorFullScreen.sh
Last active November 25, 2019 23:40
iOS Simulator Full screen
defaults write com.apple.iphonesimulator AllowFullscreenMode -bool YES
#!/usr/bin/env bash
PRODUCTS_PATH=$1
PROJECT_NAME=$2
VERSION=$3
if (( $# != 3 )); then
echo "Wrong usage. Please pass the correct arguments.
>> ./bind-frameworks PRODUCTS_PATH PROJECT_NAME VERSION"
else