Skip to content

Instantly share code, notes, and snippets.

@enomoto
enomoto / file0.txt
Created April 27, 2018 07:52
iOSプロジェクトのテストバンドルに存在するファイルを取得する ref: https://qiita.com/enomotok_/items/27d132969b41bcd26187
let path = Bundle.main.path(forResource: "foo", ofType: "json")
let data: NSData? = try? NSData(contentsOfFile: path!, options: .uncached)
@enomoto
enomoto / 1.2.rkt
Last active April 20, 2018 04:10
SICP excercise 1.2
#lang racket
(/ (+ 5 4
(- 2
(- 3
(+ 6
(/ 4 5)))))
(* 3
(- 6 2)
(- 2 7)))
@enomoto
enomoto / FontName.swift
Created March 1, 2017 02:36
find font names for iOS
import UIKit
for fn in UIFont.familyNames {
for font in UIFont.fontNames(forFamilyName: fn) {
print("font: \(font)")
}
}
#import "UserDefaultsUtility.h"
@implementation UserDefaultsUtility
/**
ユーザデフォルトに設定したオブジェクトを取得する
*/
+ (id) objectForKey:(NSString*) key {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSData *encodedObject = [userDefaults objectForKey:key];
@enomoto
enomoto / fizzBuzz.swift
Created September 21, 2015 05:08
FizzBuzz in Swift
func fizzBuzz(num: Int) -> String {
switch num {
case _ where num % 15 == 0:
return "FizzBuzz"
case _ where num % 3 == 0:
return "Fizz"
case _ where num % 5 == 0:
return "Buzz"
default:
return num.description