Skip to content

Instantly share code, notes, and snippets.

View mntone's full-sized avatar
🏠

monotone mntone

🏠
View GitHub Profile
@mntone
mntone / uint16x4_t.h
Created December 25, 2019 12:52
MMXで64-bit処理のためのuint16x4_t作ろうとしたけど命令数足りなさすぎて実用的じゃないので,SSE 128-bit最小単位にするように設計変更。ご自由にどうぞ。 >> under MIT License <<
#ifndef _SIMD_UINT16X4_H
#define _SIMD_UINT16X4_H
#include "simd_base.h"
#ifdef __cplusplus
extern "C" {
#endif
// ---
@mntone
mntone / Array+Median.swift
Created September 18, 2019 02:48
Array+Median.swift under MIT license
// Copyright (C) 2019 mntone. All rights reserved.
// MIT license
extension Array where Array.Element: Numeric & Comparable {
@inlinable
public func medianFast() -> Element {
return sorted(by: <)[count / 2]
}
}
import struct PostoneCore.Settings
#if os(macOS)
import AppKit
public typealias POColor = NSColor
#else
import UIKit
public typealias POColor = UIColor
#endif
import UIKit
final class PageViewControllerSegmentedAdapter: NSObject {
private unowned let pageViewController: UIPageViewController
private unowned let segmentControl: UISegmentedControl
private let viewControllers: [UIViewController]
private var selectedIndex: Int
init(pageViewController: UIPageViewController, segmentControl: UISegmentedControl, viewControllers: [UIViewController], at selectedIndex: Int = 0) {
@mntone
mntone / UIFont+Traits.swift
Created August 15, 2019 05:43
Apply font style (bold / italic) & features (monospaced digit).
import CoreText
import class UIKit.UIFont
import class UIKit.UIFontDescriptor
extension UIFont {
public func asBold() -> UIFont? {
return asTraits(.traitBold)
}
public func asItaric() -> UIFont? {
@mntone
mntone / fps_translation.md
Last active June 19, 2019 09:32
シューティングゲームの報告で使う簡単な言語テンプレートを作ってみた。
English Japanese Korean Simplified Chinese
yes, yeah / positive はい / いいよ
Hai / Īyo
네 / 예
ne / ye
no / negative いいえ / 嫌 (いや)
Īe / Iya
아뇨 / 아니에요
anyo / anieyo
I / my / me 私 (わたし) / 俺 (おれ)
Watashi / Ore

nae

enemy 敵 (てき)
Teki

jeog
敌人
dírén
house 家 (いえ)
Ie

jib

front of ~ 〜の前 (まえ)
no Mae
〜앞 / 〜앞에
ap / ap-e
inside ~ 〜の中 (なか)
no Naka
〜안
an
outside ~ 〜の外 (そと)no Soto 〜밖bakk
// This source is under MIT license.
import UIKit
extension UIAlertAction {
public var isEnabled: Bool {
get { return value(forKey: "enabled") as! Bool }
set { setValue(newValue, forKey: "enabled") }
}
public var isChecked: Bool {
@mntone
mntone / FocusableImageView.swift
Last active March 10, 2019 12:51
[under MIT License] Show image with using focus point.
import SIMDKit
import UIKit
public final class FocusableImageView: UIImageView {
public var isFocusEnabled: Bool = true {
didSet { layer.setNeedsLayout() }
}
public var focus: CGPoint = .zero {
didSet { layer.setNeedsLayout() }
@mntone
mntone / ThemeSegmentedControl.swift
Last active March 6, 2019 05:34
細かい部分の調整
import UIKit
public final class ThemeSegmentedControl: UISegmentedControl {
private var observer: NSObjectProtocol?
private weak var selectedLayer: CALayer!
public override var frame: CGRect {
didSet {
guard let selectedLayer = selectedLayer else { return }
@mntone
mntone / WebPImageSource.m
Created February 25, 2019 07:02
CGImage (RGB) from webp
#import <Foundation/Foundation.h>
#import <ImageIO/ImageIO.h>
#import <UIKit/UIKit.h>
#include "../libwebp/src/webp/types.h"
#include "../libwebp/src/webp/decode.h"
#include "../libwebp/src/webp/demux.h"
#import "WebPImageSource.h"