This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Make Medium Readable Userscript | |
// @namespace http://make.medium.readable.again | |
// @version 0.1 | |
// @description https://github.com/thebaer/MMRA | |
// @author luke3butler (Credits to Matt Baer) | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func showAlert(withTitle title: String, message : String, withActions actions:[UIAlertAction] = [], withCompletion c:(()->())?=nil) { | |
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) | |
if actions.isEmpty{ // default ok action | |
let defaultAction = UIAlertAction(title: "Ok", style: .default) | |
alertController.addAction(defaultAction) | |
} | |
for action in actions{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// can be made dry by adding a alloc/dealloc parameter | |
// add the DEBUGALLOC flag to Active Compilation Conditions -> Debug and use it only when necessary. | |
// note that you should be using Instruments for this, but this helps to catch issues in real time when running the app, and I gnenerally don't recommend following this approach for several reasons. | |
func LogDealloc<T>(from caller:T, filename: String = #file, line: Int = #line, funcname: String = #function){ | |
#if DEBUGALLOC | |
let file = ("\(filename)" as NSString).lastPathComponent as String | |
let objName = String(describing: type(of: caller)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// avoid the whole switch error type set description pattern we were using before (unless custom actions need to be attached or something) | |
// see: https://stackoverflow.com/questions/39176196/how-to-provide-a-localized-description-with-an-error-type-in-swift | |
import Foundation | |
public enum customError:Error{ | |
case NONETWORK | |
case INVALIDJSON | |
case UNEXPECTEDRESPONSE | |
case INVALIDCREDENTIALS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the lldb cli: | |
po [UIFont fontNamesForFamilyName:@"Avenir"] | |
<__NSArrayM 0x608000247ec0>( | |
Avenir-Oblique, | |
Avenir-HeavyOblique, | |
Avenir-Heavy, | |
Avenir-BlackOblique, | |
Avenir-BookOblique, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath) | |
cell.backgroundColor = .clear | |
cell.backgroundView = UIView() | |
cell.selectedBackgroundView = UIView() | |
return cell | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let step: Float = 50; | |
// extra slider initialization. the IBAction func below points to the UISlider we are using. | |
@IBAction func onStrengthChange(sender: UISlider) { | |
let roundedValue = round(sender.value/step) * step | |
sender.value = roundedValue | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Attempts to parse the string into a SK address. | |
* https://en.wikipedia.org/wiki/Addresses_in_South_Korea#Postal_Address | |
* https://en.wikipedia.org/wiki/ISO_3166-2:KR | |
* https://en.wikipedia.org/wiki/Administrative_divisions_of_South_Korea#Gun_.28County.29 | |
* @returns An object of the form {province, city, street, zip} | |
*/ | |
function parseAddress(string) { | |
var address = {}; | |
address.extra = []; |