This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController, UITextFieldDelegate { | |
@IBOutlet weak var textField: UITextField! | |
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { | |
view.endEditing(true) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
var Item, ItemRepository, User, addOnloadHandler, corsRequest, getElementsByClassName, main, setIframeHeight, setInnerText, template; | |
Item = (function() { | |
function Item(item) { | |
var tag, _i, _len, _ref; | |
this.title = item.title; | |
this.url = item.url; | |
this.tags = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func deleteEvent(event: EKEvent) { | |
do { | |
try eventStore.removeEvent(event, span: .ThisEvent) | |
} catch let error { | |
print(error) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//現在時刻 | |
let now = NSDate() | |
let cal = NSCalendar(identifier: NSCalendarIdentifierGregorian)! | |
//10日後 | |
let in10days = cal.dateByAddingUnit(.Day, value: 10, toDate: now, options: NSCalendarOptions()) | |
//2日前 | |
let ago2days = cal.dateByAddingUnit(.Day, value: -2, toDate: now, options: NSCalendarOptions()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert("hoge"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## ファイル名の取得 | |
puts File.basename(__FILE__) | |
## 拡張子を除くファイル名 | |
puts File.basename(__FILE__, File.extname(__FILE__)) | |
## 拡張子 | |
puts File.extname(__FILE__) | |
## テキストファイルを読み込む |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSTask *task = [[NSTask alloc] init]; | |
// 標準出力用 | |
NSPipe *outPipe = [NSPipe pipe]; | |
[task setStandardOutput:outPipe]; | |
// 標準エラー用 | |
// 標準出力用と同じNSPipeをsetしても良いけど、分けておくと結果がエラーになったかどうかが分かる。 | |
NSPipe *errPipe = [NSPipe pipe]; | |
[task setStandardError:errPipe]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 配列から指定した条件に合致する要素を抜き出す | |
a = [1,2,3,4,5] | |
a.select{|x| x%2 == 0 } => [2,4] | |
## 要素の追加 | |
a = [1, 2, 3,] | |
a << 99 #=> [1,2,3,4,5,99] | |
a.unshift(99) #=> [99,1,2,3,4,5,99] | |
a = [1, 2, 3, 4, 5] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 文字列中に変数を指定する | |
a = "hoge" | |
b = "fuga" | |
puts "#{a}と#{b}はほげふがです" | |
# 置換 | |
s = "Apple Banana Apple Orange" | |
p s.sub("Apple", "Pine") #=> "Pine Banana Apple Orange" | |
p s.gsub("Apple", "Pine") #=> "Pine Banana Pine Orange" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## while文 | |
while 条件式 do | |
実行する処理1 | |
実行する処理2 | |
end | |
## for文 | |
for 変数 in オブジェクト do | |
実行する処理1 | |
実行する処理2 |
NewerOlder