Skip to content

Instantly share code, notes, and snippets.

Kenta Enomoto k-enomoto

Block or report user

Report or block k-enomoto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
k-enomoto / PlaygroundDrivenDevelopment1.swift
Last active May 9, 2019
Playground Driven Development (Xcode 10.2.1, Swift 5)
View PlaygroundDrivenDevelopment1.swift
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
class MyViewController : UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white
k-enomoto / RoundedCornersLabel.swift
Last active May 9, 2019
UILabel with rounded corners (Swift 5, Xcode 10.2)
View RoundedCornersLabel.swift
public final class RoundedCornersLabel: UILabel {
public override init(frame: CGRect) {
super.init(frame: frame)
public required init?(coder: NSCoder) {
super.init(coder: coder)
k-enomoto / stride.swift
Last active Apr 7, 2019
replacement of C style for loop in Swift 5(Xcode 10.2)
View stride.swift
// for var i = 0; i < 5; i += 1
for i in stride(from: 0, to: 5, by: 1) {
print(i) // 0, 1, 2, 3, 4
View FooRequestSpec.swift
import Foundation
@testable import Foobar
import Quick
import Nimble
import Mockingjay
import APIKit
final class FooRequestSpec: QuickSpec {
override func spec() {
describe("FooRequest") {
k-enomoto / XCTestCase+Stub.swift
Last active Jan 30, 2019
Xcode 10.1, Swift 4.1, install [Mockingjay]( with Cocoapods
View XCTestCase+Stub.swift
// XCTestCase+Stub.swift
import Foundation
import XCTest
import Mockingjay
extension XCTestCase {
/// Web API のリクエストをテストプロジェクトの json でスタブする
/// - Parameters:
k-enomoto /
Created Jan 24, 2019
This script bumps iOS app version numbers. (Python 3.7.1)
# update version numbers
current_ver_str = '1.0.0' # 現在のバージョン番号
new_ver_str = '1.1.0' # 新しいバージョン番号
# plist file names
file_names = [
class Solution:
def twoSum(self, nums, target):
:type nums: List[int]
:type target: int
:rtype: List[int]
for i, num in enumerate(nums):
for j, num2 in enumerate(nums):
if i == j:
k-enomoto / LocaleExtension.swift
Last active Aug 28, 2018
Change locale in XCTestCase
View LocaleExtension.swift
private extension MyTests {
private func setLocaleAsJP() {
let original = class_getClassMethod(NSLocale.self, #selector(getter: NSLocale.current))!
let swizzled = class_getClassMethod(NSLocale.self, #selector(NSLocale.myCurrentLocale))!
method_exchangeImplementations(original, swizzled)
fileprivate extension NSLocale {
k-enomoto / UserDefaultsAndStructArray.swift
Created Jul 17, 2018
save array of struct to UserDefaults
View UserDefaultsAndStructArray.swift
import Foundation
struct Book: Codable {
let title: String
let author: String
let KeyForUserDefaults = "myKey"
func save(_ books: [Book]) {
View swiftc_help.txt
OVERVIEW: Swift compiler
USAGE: swiftc [options] <inputs>
-dump-ast Parse and type-check input file(s) and dump AST(s)
-dump-parse Parse input file(s) and dump AST(s)
-dump-scope-maps <expanded-or-list-of-line:column>
Parse and type-check input file(s) and dump the scope map(s)
You can’t perform that action at this time.