Skip to content

Instantly share code, notes, and snippets.

View interstateone's full-sized avatar
👋

Brandon Evans interstateone

👋
View GitHub Profile
@marcboquet
marcboquet / gist:340c240c50aed6c71a1e
Created August 8, 2014 15:37
Create empty Swift playground files
#! /usr/bin/ruby
require 'pathname'
platform = "iphonesimulator" # or "macosx"
contents_xcplayground = <<XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='1.0' sdk='#{platform}'>
<sections>
<code source-file-name='section-1.swift'/>
</sections>
@MarkVillacampa
MarkVillacampa / JavaScriptCore.m
Last active December 27, 2015 19:49
Trying to add methods at runtime for the JSExport protocol in JavaScriptCore. As-is, the method is not called from Javascript. Uncomment lines 7-8 and the end of 11, comment line 65, and run. The method is now called from JavaSript. Any idea why?
#import <Foundation/Foundation.h>
#import <JavaScriptCore/JavaScriptCore.h>
#import <objc/runtime.h>
const char *_protocol_getMethodTypeEncoding(Protocol *, SEL, BOOL isRequiredMethod, BOOL isInstanceMethod);
//@protocol MyProtocol <JSExport>
// -(void)one:(id)one;
//@end
@cbarrett
cbarrett / Reducer.swift
Last active August 22, 2017 00:19
Some fun with Reducers
// type State = ...
// infix operator <>: AdditionPrecedence
// enum Either<A, B> { ...
struct Reducer<Action> {
let reduce: (Action, State) -> State
init(_ f: @escaping (Action, State) -> State) {
reduce = f
}
}
//
// main.swift
// OptionParser
//
// Created by Chris Eidhof on 28.02.19.
// Copyright © 2019 objc.io. All rights reserved.
//
import Foundation
@hujunfeng
hujunfeng / ios7statusbar.md
Last active March 20, 2019 14:20
About iOS 7 Status Bar Style

UIStatusBarStyle in iOS 7

  • The status bar in iOS 7 is transparent, the view behind it shows through.

  • The style of the status bar refers to the appearances of its content. In iOS 7, the status bar content is either dark (UIStatusBarStyleDefault) or light (UIStatusBarStyleLightContent). Both UIStatusBarStyleBlackTranslucent and UIStatusBarStyleBlackOpaque are deprecated in iOS 7.0. Use UIStatusBarStyleLightContent instead.

How to change UIStatusBarStyle

  • If below the status bar is a navigation bar, the status bar style will be adjusted to match the navigation bar style (UINavigationBar.barStyle):
import Cocoa
class DeveloperToolsController {
let commandController: CommandController
init(commandController: CommandController) {
self.commandController = commandController
}
#if DEBUG
@3noch
3noch / keybase+git-crypt.md
Last active February 16, 2020 20:55
How to add a Keybase user to your repo using git-crypt
keybase pgp pull <keybase.io user>
gpg --edit-key <keybase.io user>
  > lsign
  > save
git-crypt add-gpg-user <keybase.io user>
@interstateone
interstateone / uiappearance-selector.md
Last active April 7, 2020 14:39 — forked from mattt/uiappearance-selector.md
A list of methods and properties conforming to `UIAppearance` as of iOS 13.4

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@xcodereleases
xcodereleases / main.m
Last active June 15, 2020 04:29
Extract beta information from a local copy of Xcode
#import <Cocoa/Cocoa.h>
@protocol FilePath <NSObject>
+ (instancetype)filePathForPathString:(NSString *)path;
@end
@protocol NamedVersion <NSObject>
- (NSString *)name;
@end
@DeFrenZ
DeFrenZ / AppDelegate.swift
Created November 14, 2020 23:59
Dependency Injection a-la SwiftUI.Environment style by (ab)using the responder chain
import UIKit
@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
private let testService: TestService = .init()
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions) -> UISceneConfiguration