Skip to content

Instantly share code, notes, and snippets.

View shakemno's full-sized avatar

Manolis Pahlke shakemno

View GitHub Profile
//
// WatchSessionManager.swift
// WatchConnectivityDemo
//
// Created by Natasha Murashev on 9/3/15.
// Copyright © 2015 NatashaTheRobot. All rights reserved.
//
import WatchConnectivity
@shakemno
shakemno / ScrollableView.swift
Created January 26, 2020 00:09 — forked from jfuellert/ScrollableView.swift
A scrollable SwiftUI view, UIScrollView wrapper. ScrollableView lets you read and write content offsets for scrollview in SwiftUI, with and without animations.
import SwiftUI
struct ScrollableView<Content: View>: UIViewControllerRepresentable {
// MARK: - Type
typealias UIViewControllerType = UIScrollViewController<Content>
// MARK: - Properties
var offset: Binding<CGPoint>
var animationDuration: TimeInterval
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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;