Skip to content

Instantly share code, notes, and snippets.

View billymeltdown's full-sized avatar

Billy Gray billymeltdown

View GitHub Profile
@chockenberry
chockenberry / README
Created April 6, 2022 17:32
A simple AppleScript to start up a web server in the folder where the script is located.
1) Add this code to a new file in Script Editor
2) Export the script as "Application" and make sure it's code signed
3) Put "Startup.app" in the root folder of the test website (e.g. where index.html is located)
4) Make sure that "Startup.app" has Full Disk Access in System Preferences > Security & Privacy > Privacy
import UIKit
extension UITextField {
/// Add a trailing placeholder label that tracks the text as it changes
func addTrailingPlaceholder(_ placeholder: String) {
let label = UILabel()
label.text = placeholder
label.alpha = 0.3
label.isHidden = true
let container = UIView()
//: Playground - noun: a place where people can play
import Cocoa
// When you’re downloading objects from the web, it’s common to need to merge changes
// from the server to already-existing local objects. (If your data model allows for
// mutable objects, as with Core Data, that is.)
//
// The below is a Swift translation of how I’ve done this in Objective-C.
// Note that it works just fine in Swift — though it does require NSObject subclasses.
anonymous
anonymous / SpltViewDelegate.m
Created September 27, 2014 21:27
/*Dealing with three-level hierarchy:
Feeds > Timeline > Article
Primary (master) is nav controller with Feeds and Timeline.
Secondary (detail) is nav controller with Article.
I get a reference to primary and secondary navigation controllers when app is launching.
@ijoshsmith
ijoshsmith / main.swift
Last active August 29, 2015 14:04
Nil-coalescing Operator in Swift
//
// UPDATE: This gist was rendered obsolete as of
// Xcode 6 Beta 5, which introduced the nil
// coalescing operator in Swift proper (??).
//
/* Nil-coalescing operator */
infix operator !! {}
func !! <T> (
value: T?,
@nonsensery
nonsensery / page1.md
Created February 15, 2014 19:35
Splitting model objects into several entities

Some thoughts on this blog post by Brent Simmons

From the original:

A VSNote has more than a dozen properties. But the timeline needs only a few of those, and there would be performance and memory-use gains by using a smaller object. … In Core Data I could create two entities: VSTimelineNote and VSExtendedNote. VSTimelineNote would have a to-one relationship to VSExtendedNote. … [But that] means the data isn’t stored using the most natural representation. The data model would be based on the needs of the UI, which is not a good idea.

Putting aside Core Data for a moment, at issue is that each VSNote contains 8 or 10 attributes that are not needed to display the master list of notes; they are only needed to display the detail view for a note. Ideally, when displaying the list, we could load just the attributes used in the list into memory, and then load the rest when displaying the detail view. But realistically, a few bytes for a timestamp here

@orta
orta / network-models.md
Last active August 29, 2015 13:56
Network models

Using a real artsy example from today.

Creating a follow button on a view controller for different types of objects Artist, Profile, Gene

Needs: networking Needs: layout Needs: interface changes based on networking

Networking

@chrisballinger
chrisballinger / gist:7239932
Last active May 14, 2024 18:52
French Encryption Import Compliance

Starting in the first week of July, apps that meet the following criteria are required to comply with French Encryption Laws/Regulations if you intend to distribute your app in France.

This requirement applies to apps that use, access, implement, or incorporate:

  1. Any encryption algorithm that is yet to be standardized by international standard bodies such as IEEE, IETF, ISO, ITU, ETSI, 3GPP, TIA, etc. or not otherwise published; or
  2. Standard (e.g., AES, DES, 3DES, RSA) encryption algorithm(s) instead of or in addition to accessing or using the encryption in iOS and/or Mac OS X

Apple will require you to upload a copy of your approved French declaration when you submit your app to the App Store. Relevant French encryption regulations can be found at: