Skip to content

Instantly share code, notes, and snippets.

@chriswill0w
chriswill0w / AppStoryboard.swift
Created July 26, 2018 08:49 — forked from Gurdeep0602/AppStoryboard.swift
AppStoryboard enumeration
//
// AppStoryboards.swift
// AppStoryboards
//
// Created by Gurdeep on 15/12/16.
// Copyright © 2016 Gurdeep. All rights reserved.
//
import Foundation
import UIKit
@chriswill0w
chriswill0w / Fonts.swift
Last active September 20, 2018 10:48 — forked from khanlou/Fonts.swift
Print all fonts in Swift 4 UIFont
for family in UIFont.familyNames {
let sName: String = family as String
print("family: \(sName)")
for name in UIFont.fontNames(forFamilyName: sName) {
print("name: \(name as String)")
}
}
@chriswill0w
chriswill0w / macos-recovery-server.md
Created February 20, 2018 23:51
Fixing "The recovery server could not be contacted" in MacOS High Sierra

I was trying to reinstall High Sierra on an older MacBook Air using internet recovery and I kept on getting an error message when trying to reinstall High Sierra.

The recovery server could not be contacted

It appears that this has to do with the time on the machine not being synchronized, so when the MacBook tries to reach out to the recovery server the certificates do not validate and we get this useless error message.

To fix this.

  1. Open up a Terminal from the utilities menu
  2. Enter the following command
@chriswill0w
chriswill0w / discardableThumbnail.swift
Created November 14, 2017 00:27 — forked from benbahrenburg/discardableThumbnail.swift
UIImage that implements NSDiscardableContent
final class discardableThumbnail: NSDiscardableContent {
var thumbnail: UIImage!
var accessCounter: Int = 0
init(image: UIImage) {
thumbnail = image
}
func beginContentAccess() -> Bool {
if !(self.thumbnail != nil) {
@chriswill0w
chriswill0w / sns-publish
Created October 25, 2017 12:47 — forked from jeremypruitt/sns-publish
AWS Lambda function to publish to SNS topic
console.log('Loading function');
var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
exports.handler = function(event, context) {
console.log("\n\nLoading handler\n\n");
var sns = new AWS.SNS();
sns.publish({
@chriswill0w
chriswill0w / aws-sns-example.js
Created October 25, 2017 12:47 — forked from tmarshall/aws-sns-example.js
aws-sdk sns example, in Node.js
var AWS = require('aws-sdk');
AWS.config.update({
accessKeyId: '{AWS_KEY}',
secretAccessKey: '{AWS_SECRET}',
region: '{SNS_REGION}'
});
var sns = new AWS.SNS();
@chriswill0w
chriswill0w / Obfuscator.swift
Last active February 17, 2021 07:49 — forked from DejanEnspyra/Obfuscator.swift
Obfuscation of hard-coded security-sensitive strings.
protocol ObfuscatorProtocol {
#if DEBUG
func bytesByObfuscatingString(_ string: String) -> [UInt8]
#endif
func reveal(_ key: [UInt8]) -> String
}
class Obfuscator: ObfuscatorProtocol {
// MARK: - Variables