Skip to content

Instantly share code, notes, and snippets.

View inickt's full-sized avatar

Nick Thompson inickt

View GitHub Profile
import UIKit
class RootViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let text = "Cute cat"
let image = UIImage(named: "cat.jpg")!
// Note: you can't wrap the text and image into a single "TextImage" object and selectively return both or one as UIActivityItemSource doesn't like holding arrays
@steipete
steipete / FirebaseCoordinator.swift
Created April 13, 2020 13:38
If you're as confused as I am that there's an API for custom options, yet Google still requires a file named GoogleService-Info.plist in your app, here's some swizzling that fixes that for ya. All Swift :)
class FirebaseCoordinator {
static let shared = FirebaseCoordinator()
static let initialize: Void = {
/// We modify Google Firebase (and eventually Analytics) to load the mac-specific plist at runtime.
/// Google enforces that we have a file named "GoogleService-Info.plist" in the app resources.
/// This is unfortunate since we need two different files based on iOS and Mac version
/// One solution is a custom build step that copies in the correct file:
/// https://stackoverflow.com/questions/37615405/use-different-googleservice-info-plist-for-different-build-schemes
/// However, this is basically impossible since Catalyst doesn't set any custom build variables, so detection is extremely difficult.
/// We swizzle to modify the loading times.
@IanColdwater
IanColdwater / twittermute.txt
Last active April 22, 2024 17:26
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@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()
}
@hsjunnesson
hsjunnesson / main.c
Created October 1, 2019 19:06
Embedded Racket in C
#include "scheme.h"
#include "base.c"
static int run(Scheme_Env* e, int argc, char* argv[]) {
scheme_env = e;
declare_modules(e);
scheme_namespace_require(scheme_intern_symbol("racket/base"));
@insdavm
insdavm / WireGuard-site-to-site.md
Last active May 2, 2024 20:10
Accessing a subnet that is behind a WireGuard client using a site-to-site setup

WireGuard Site-to-Site

Accessing a subnet that is behind a WireGuard client using a site-to-site setup

Problem Summary

We want to access a local subnet remotely, but it is behind a NAT firewall and we can't setup port forwarding. Outgoing connections work, but all incoming connections get DROPPED by the ISP's routing policy.

Solution Summary

@fousa
fousa / FairPlayer.swift
Last active June 1, 2023 12:28
Integrate HLS with FairPlay.
class FairPlayer: AVPlayer {
private let queue = DispatchQueue(label: "com.icapps.fairplay.queue")
func play(asset: AVURLAsset) {
// Set the resource loader delegate to this class. The `resourceLoader`'s delegate will be
// triggered when FairPlay handling is required.
asset.resourceLoader.setDelegate(self, queue: queue)
// Load the asset in the player.
@orlando
orlando / mac-setup.md
Last active January 27, 2024 21:18 — forked from todc/mac-setup.md
Fresh Mac OS Setup

1. Run Software Update

Make sure everything is up to date in the App Store

2. Install Homebrew

  1. Open a terminal window and execute the Homebrew install script:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
@phatmann
phatmann / ImageAttachment
Created March 22, 2015 22:23
NSTextAttachment that scales and aligns image
// Created by Tony Mann on 3/22/15.
// Copyright (c) 2015 7Actions. All rights reserved.
//
// Adapted from http://ossh.com.au/design-and-technology/software-development/implementing-rich-text-with-images-on-os-x-and-ios/
import UIKit
class ImageAttachment: NSTextAttachment {
var verticalOffset: CGFloat = 0.0