Skip to content

Instantly share code, notes, and snippets.

View superarts's full-sized avatar
💭
Git gud!

Leo superarts

💭
Git gud!
View GitHub Profile
@superarts
superarts / LFTableController
Last active August 29, 2015 14:15
Table controller.
override func viewDidLoad() {
super.viewDidLoad()
lf_actionReload()
}
override func lf_actionReload() {
var array: Array<LTDictStrObj> = [ [
"title": "Title 1",
"desc": "Description",
], [
@superarts
superarts / LFTableController+SearchDisplayController
Created April 30, 2015 02:30
LFTableController+SearchDisplayController
class ICSearchController: LFTableController {
var source_search: LFTableDataSource!
//@IBOutlet var search_controller: UISearchDisplayController!
//@IBOutlet var search_bar: UISearchBar!
override func viewDidLoad() {
super.viewDidLoad()
reload_featured()
reload_search()
@superarts
superarts / Swift Mail Composer
Created June 29, 2015 14:15
Simple Mail Composer in Swift
@IBAction func action_report() {
let composer = SVMailComposer()
composer.present(self, subject:SV.s.report_user_title, body:SV.s.report_user_body)
}
class SVMailComposer: MFMailComposeViewController, MFMailComposeViewControllerDelegate {
func present(controller: UIViewController, subject: String, body: String) {
if MFMailComposeViewController.canSendMail() {
mailComposeDelegate = self
setToRecipients(["leo@superarts.org"])
@superarts
superarts / ambiguous-logger.swift
Created March 1, 2019 14:10
Ambiguous loggers; use clogger and flogger instead
/// TODO: is something like Loggable.Console / Loggable.File possible in Swift - single namespace inside a target?
// A console logger
protocol ConsoleLoggable {
var clogger: ConsoleLoggerProtocol { get }
}
extension ConsoleLoggable {
var clogger: ConsoleLoggerProtocol {
@superarts
superarts / extension-computed-property.swift
Created March 4, 2019 02:43
Extension Computed Property Behavior
// To maintain state of extension computed property, use static variable
// A console logger
protocol ConsoleLoggable {
var logger: ConsoleLoggerProtocol { get }
}
extension ConsoleLoggable {
var logger: ConsoleLoggerProtocol {
@superarts
superarts / test-target.swift
Last active March 4, 2019 03:07
Provide test only feature in Test target
protocol ProductionFeatureProtocol: TestFeature1, TestFeature2 {
}
struct DefaultProductionFeature: ProductionFeatureProtocol {
}
protocol TestFeature1 {
func testOnly1()
@superarts
superarts / struct-in-static-func
Created May 7, 2019 14:10
`static func` in `struct` is not pure
struct TestStruct {
static var staticVar = 1
static func staticFunc() {
staticVar = 2
}
}
@superarts
superarts / pure-func-in-enum
Created May 7, 2019 14:35
Pure Functions in Swift Enum
protocol PureEnumProtocol {
func test()
}
enum PureEnum: PureEnumProtocol {
static var v = 1 // Still possible
//var v = 1 // Enums must not contain stored properties
func test() {
//v = 2 // Impossible
@superarts
superarts / swift-compare-inherited-type
Last active May 30, 2019 15:45
Getting and Comparing Type of Class
class BaseClass: NSObject {
func test() {
let aType = type(of: self)
if aType == dict["My Base"] {
print("this is base")
} else if aType == dict["My Inherited"] {
print("this is inherited")
}
print(aType)
}
@superarts
superarts / 鬼泣5-DMD.md
Last active August 14, 2019 19:59
Devil May Cry 5 DMD

鬼泣5正在慢慢打DMD难度,争取一命过关而且评价B以上。尼禄最简单,空中采花手抓怪空连空投,加上三级蓄力枪,大部分场景都没有风险。重型敌人蓄力枪打出硬直后用投技打出伤害即可,最难的是需要弹反的顺移哥和巨兽。但丁摩托空中风格风格打击风格循环可以无限锁死能挑空的敌人,但是起手比较慢;狗棍弹反瞬移哥难度比较低,但是总体来说控场难度比较大,比如有四五个转转在地上,尼禄在空中一个一个抓过来就好,但丁一不小心就会中招,好在可以开罪魔人解决不少麻烦的场景。V在DMD难度下手累很多,打法也很单一,基本上就是保持中距离挑衅,魔力留着复活使魔。