Skip to content

Instantly share code, notes, and snippets.

View shakemno's full-sized avatar

Manolis Pahlke shakemno

View GitHub Profile
extension UIViewController {
func recursiveDescription() -> String {
let description = view.perform(Selector(("recursiveDescription")))?.takeUnretainedValue() as! String
return description
}
}
@shakemno
shakemno / embed-debug-only-framework.sh
Created July 27, 2020 10:31 — forked from kenthumphries/embed-debug-only-framework.sh
Script to be called as part of an Xcode Run Script build phase. This will ensure that script Input File is copied (and code signed) to script Output File.
#!/bin/sh
# This script embeds (and codesigns) a framework within an iOS app binary, but only when the configuration is Debug.
# It must be called from, or copied into an Xcode Run Script build phase with following setup:
# Input Files:
# - Path to framework within project folder (source path)
# - For example: $(SRCROOT)/ThirdPartyFrameworks/SimulatorStatusMagiciOS.framework
# Output Files:
# - Desired path to framework within ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH} (destination path)
# - For example: ${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/SimulatorStatusMagiciOS.framework
@shakemno
shakemno / Darwin
Created April 29, 2020 17:46 — forked from axldyb/Darwin
Darwin notifications listen and send for iOS
#import <Foundation/Foundation.h>
typedef void (^DarwinNotificationBlock)(NSString *identifier);
@interface Darwin : NSObject
+ (Darwin *)sharedInstance;
- (void)startListening:(DarwinNotificationBlock)block;
- (void)test;
@shakemno
shakemno / flavor.rb
Created April 24, 2020 07:50 — forked from ttscoff/flavor.rb
Quick wrapper to convert Markdown to HTML via Github API
#!/usr/bin/ruby
# Convert a Markdown README to HTML with Github Flavored Markdown
# Github and Pygments styles are included in the output
#
# Requirements: json gem (`gem install json`)
#
# Input: STDIN or filename
# Output: STDOUT
# Arguments: "-c" to copy to clipboard (or "| pbcopy"), or "> filename.html" to output to a file
# cat README.md | flavor > README.html
@shakemno
shakemno / NSViewControllerPreview.swift
Created April 8, 2020 08:44 — forked from MainasuK/NSViewControllerPreview.swift
Generic structures to host previews of UIView and UIViewController subclasses. Also NSView and NSViewController
import Cocoa
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct NSViewControllerPreview<ViewController: NSViewController>: NSViewControllerRepresentable {
let viewController: ViewController
init(_ builder: @escaping () -> ViewController) {
viewController = builder()
@shakemno
shakemno / MacEditorTextView.swift
Created April 8, 2020 08:43 — forked from unnamedd/MacEditorTextView.swift
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI
@shakemno
shakemno / HTML_to_NSAttributedString.swift
Created April 8, 2020 07:26 — forked from maltalef/HTML_to_NSAttributedString.swift
converting HTML to NSAttributedString "pseudo-asynchronously"
import UIKit
extension NSAttributedString {
static func fromHTML(_ html: String, execute: @escaping (NSAttributedString?) -> Void) {
DispatchQueue.main.async {
let options = [NSAttributedString.DocumentReadingOptionKey.documentType: NSAttributedString.DocumentType.html]
// only run on main queue
let result = try? NSAttributedString(data: Data(html.utf8), options: options, documentAttributes: nil)
@shakemno
shakemno / Combine+Ext.swift
Created March 3, 2020 16:38 — forked from juliancadi/Combine+Ext.swift
Combine side effect
extension Publisher {
public func on(_ f: @escaping (Self.Output) -> Void) -> AnyPublisher<Self.Output, Self.Failure> {
self.map {
f($0)
return $0
}.eraseToAnyPublisher()
}
}
@shakemno
shakemno / TimeFormatter.swift
Created March 2, 2020 21:32 — forked from srmds/TimeFormatter.swift
TimeFormatter Swift 2.0 - Convert milliseconds to a formatted output string of hours:minutes:seconds with applied padding
//
// TimeFormatter.swift
// ElectroDeluxe-Swift2.0
//
// Convert milliseconds to a formatted output string containing hours:minutes:seconds
// with padding zero.
//
// Created by c0d3r on 21/08/15.
// Copyright © 2015 srmds. All rights reserved.
//
@shakemno
shakemno / NotesApp.swift
Created February 27, 2020 22:38 — forked from jnewc/NotesApp.swift
A notes app written in >100 lines of swift using SwiftUI
//
// ContentView.swift
// Listomania
//
// Created by Jack Newcombe on 05/06/2019.
// Copyright © 2019 Jack Newcombe. All rights reserved.
//
import SwiftUI