Skip to content

Instantly share code, notes, and snippets.

local wezterm = require("wezterm")
local config = wezterm.config_builder()
local scheme = "terafox"
local scheme_def = wezterm.color.get_builtin_schemes()[scheme]
config.color_scheme = scheme
config.colors = {
tab_bar = {
background = "none",
active_tab = {
@samwarnick
samwarnick / migrate.swift
Last active January 25, 2023 16:11
Migrate to app group
// In my core data stack
let container = NSPersistentCloudKitContainer(name: "DataModel")
let storeUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupIdentifier)!.appendingPathComponent("DataModel.sqlite")
// Enable history tracking and remote notifications
guard let description = container.persistentStoreDescriptions.first else {
fatalError("###\(#function): Failed to retrieve a persistent store description.")
}
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
@samwarnick
samwarnick / machine.js
Created September 11, 2019 15:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@samwarnick
samwarnick / Segues.swift
Created April 19, 2017 17:32
Programmatic segues
let nextViewController = NextViewController()
nextViewController.modalPresentationStyle = .custom
nextViewController.modalTransitionStyle = .crossDissolve
present(nextViewController, animated: true, completion: nil)
@samwarnick
samwarnick / PageViewControllerGotchas.swift
Created April 19, 2017 16:37
A few lines of code that are necessary to show the page indicator dots
/*
These functions are neccessary for the page indicator dots to show up.
They are optional functions of UIPageViewControllerDataSource, so they do not come up as overrides.
*/
func presentationCount(for pageViewController: UIPageViewController) -> Int {
return orderedViewControllers.count
}
func presentationIndex(for pageViewController: UIPageViewController) -> Int {
return 0
@samwarnick
samwarnick / ExampleConfigureViewsFunction.swift
Created April 19, 2017 16:32
Example configureViews function of a view controller
func configureViews() {
let authorLabel = UILabel()
authorLabel.defaultStlye()
authorLabel.text = "Created by Sam Warnick"
let websiteButton = UIButton(type: .system)
websiteButton.defaultStlye()
websiteButton.setTitle("samwarnick.com", for: .normal)
websiteButton.addTarget(self, action: #selector(STNCreditsViewController.didPressWebisteButton), for: .touchUpInside)
websiteButton.sizeToFit()
@samwarnick
samwarnick / NoStoryboardAppDelegate.swift
Last active April 19, 2017 16:28
What needs to be added to AppDelegate.swift to be able to not use a storyboard
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = YourFirstViewController()
@samwarnick
samwarnick / UIRoundedButtonWithGradientAndShadow.swift
Last active December 26, 2021 16:45
A rounded button with a gradient and shadow written in swift
class UIRoundedButtonWithGradientAndShadow: UIButton {
let gradientColors : [UIColor]
let startPoint : CGPoint
let endPoint : CGPoint
required init(gradientColors: [UIColor],
startPoint: CGPoint = CGPoint(x: 0, y: 0.5),
endPoint: CGPoint = CGPoint(x: 1, y: 0.5)) {
self.gradientColors = gradientColors
:root {
--lightblue: #65def1;
}
.nav-link {
font-size: 20px;
color: #65def1;
color: var(--lighblue);
}
var 😀 = "Hello, World!"
print(😀)