Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MrSmart00
MrSmart00 / Enemy.cs
Last active August 29, 2015 14:06
Unity4.6オープンβでチュートリアルのShoothing Game作ってみる ref: http://qiita.com/MrSmart/items/b7e4eeebd1435fe8861b
using UnityEngine;
using System.Collections;
public class Enemy : Spaceship {
// ヒットポイント
public int hp = 1;
// 弾を撃つかどうか
public bool canShot;
@MrSmart00
MrSmart00 / UIColor.extension.swift
Last active December 3, 2018 06:16
UIColor Extension: create with a hex string @Swift4.2
extension UIColor {
convenience init(hex: String) {
let hexStr = hex.lowercased().replacingOccurrences(of: "0x", with: "")
let hexmap = hexStr.map { String($0) }
+ Array(repeating: "0", count: max(6 - hexStr.count, 0))
+ Array(repeating: "f", count: max(8 - max(6, hexStr.count), 0))
let split = stride(from: 0, to: hexmap.count, by: 2)
.map { hexmap[$0..<$0+2]
.reduce(into: String()) { $0 += $1 } }
@MrSmart00
MrSmart00 / MyExtension.extension.swift
Last active January 23, 2019 09:22
How to use a Modern swifty extensions
public class MyExtension<T> {
let obj: T
public init(base: T) {
self.obj = base
}
}
@MrSmart00
MrSmart00 / PublishRelay+PropertyWrapper.swift
Created June 4, 2020 09:45
PublishRelay with Property Wrapper
import Foundation
import RxSwift
import RxCocoa
@propertyWrapper
struct WrappedPublishRelay<Value> {
private let value: AnyObserver<Value>
private let observable: Observable<Value>
init(_ relay: PublishRelay<Value> = .init()) {
@MrSmart00
MrSmart00 / Publisher+Materialize.swift
Created June 30, 2020 04:10
Swift Combine: Add Materialize Publisher with separatable function on Publishers. And add ignore Nil operation on Publisher.
import Foundation
import Combine
public extension Publishers {
enum Event<T, E: Error> {
case value(T)
case failure(E)
case finished
var value: T? {
@MrSmart00
MrSmart00 / EscapingExams.swift
Last active June 11, 2021 06:48
Escaping内のキャプチャ挙動確認用 via Playground
import UIKit
import UIKit
class HogeClass {
let text = "weak"
func print(handler: @escaping (String) -> Void) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
handler(self?.text ?? "")
}
@MrSmart00
MrSmart00 / Optional+extension.swift
Created June 28, 2021 08:55
Confotable Optional Extension
public extension Optional {
var isNil: Bool {
if case .some = self {
return false
} else {
return true
}
}
func compact(_ where: (Wrapped) -> Void) {
@MrSmart00
MrSmart00 / bootstrap_prod.sh
Last active August 24, 2021 06:57
Xcode Project handling with XcodeGen and an environment value.
#!/bin/sh
# DEVELOPMENT / STAGING / PRODUCTION
export ENVIRONMENT=PRODUCTION
export DISPLAY_NAME=Sample
export BUNDLE_IDENTIFIER=com.example.sample
export PROVISIONING_PROFILE=Sample\ Provisioning\(Adhoc\)
# Generate Project
mint run xcodegen generate
@MrSmart00
MrSmart00 / PULL_REQUEST_TEMPLATE.md
Created October 8, 2021 03:07
Pull Request Template

WHY

この PR で実現したいことを記載してください

WHAT

この PR でやったことを記載してください