Skip to content

Instantly share code, notes, and snippets.

View akimach's full-sized avatar
💭
I may be slow to respond.

akimach

💭
I may be slow to respond.
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akimach
akimach / binominal_confidience_interval.ipynb
Created May 30, 2016 07:16
2項分布の母比率の信頼区間
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akimach
akimach / execAfterSec.swift
Last active June 9, 2016 11:31
N秒後に処理を実行する
// n秒後に与えられた処理を行う
func execAfterSec(n: Double, completion: (()->())?) {
let delay = 1.0 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue(), {
completion!()
})
}
@akimach
akimach / insertCell.swift
Created June 8, 2016 09:34
セルの挿入
override func viewDidLoad() {
super.viewDidLoad()
self.timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(NotificationBoardViewController.timerUpdate(_:)), userInfo: nil, repeats: true)
}
func timerUpdate(timer: NSTimer) {
data.append(String(counter))
let indexPath = NSIndexPath(forRow: counter, inSection: 0)
newsTable.insertRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)

UITableViewDataSource Protocol

  • func numberOfSectionsInTableView(tableView: UITableView) -> Int
  • セクション数
  • func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
  • セクションごとのセル数
  • func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String?
  • セクション名
  • func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
  • セルの内容
@akimach
akimach / UICollectionViewDataSource.md
Last active June 9, 2016 06:29
UICollectionViewDataSource

UICollectionViewDataSource

Required

  • func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
  • あるセクションのセル数
  • func collectionView(_ collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
  • セルの内容

Optional

@akimach
akimach / UILocalNotification.md
Last active June 24, 2016 17:17
UILocalNotificationメモ

UserNotification

端末内か端末外から通知を送るかの違いだけで、アプリ側のハンドリングは同じ

  • ローカル通知
  • プッシュ通知
  • Remote Notification

通知の許可を要求する

// http://ja.stackoverflow.com/questions/17801/nsdata%E5%9E%8B%E3%81%8B%E3%82%89%E3%83%90%E3%82%A4%E3%83%88%E9%85%8D%E5%88%97%E3%81%AB
func dataToByte(data: NSDate) -> [Int8] {
var dataBuffer = Array<Int8>(count: data.length, repeatedValue: 0)
data.getBytes(&dataBuffer, length: dataBuffer.count)
return dataBuffer
}
private func textDiff(_ texts: [String]) -> String? {
if texts.count <= 2 {
return nil
}
func diff(str1: String, str2: String) -> String? {
if str2.contains(str1) {
let range = str2.range(of: str1)
if let r = range {
print(r.lowerBound)
#!/usr/bin/env/python
# coding: utf-8
# **[CNN-01]** 必要なモジュールをインポートして、乱数のシードを設定します。
# In[1]:
import time
import tensorflow as tf
import numpy as np