Skip to content

Instantly share code, notes, and snippets.

View nolili's full-sized avatar
:octocat:

NORITAKA KAMIYA nolili

:octocat:
View GitHub Profile
for i in stride(from: 0, to: 100, by: 25){
// 0, 25, 50, 75
println(i)
}
for i in stride(from: 0, through: 100, by: 25){
// 0, 25, 50, 75, 100
println(i)
@nolili
nolili / gist:122c5a524761dbbf613d
Last active August 29, 2015 14:05
Travis CI メモ
Travis CI メモ
オープンソース向けのCIツール
githubからソースをpull、スクリプトを動作させ、結果を通知する。
Xcodeのプロジェクトがビルドできる。(OS XのVMが走っている?未確認)
Publicリポジトリであれば無料。
https://travis-ci.org
Privateリポジトリを扱う場合は、有料のプラン契約が必要。
月額129USD(13000JPY程度)
@nolili
nolili / gist:2bf1a701df1015ed6488
Created August 23, 2014 23:53
SwiftのArray(バイト列)からNSDataへ変換
import UIKit
var str = "Hello, playground"
// Swiftの配列からNSDataへ変換
var rawArray:[UInt8] = [0x01, 0x02, 0x03];
let data = NSData(bytes: &rawArray, length: rawArray.count)
print(data)
// バイト列からNSDataに変換
@nolili
nolili / ViewController.swift
Created September 11, 2014 13:56
Counter-Swift
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var display: UILabel?
@IBAction func add(sender: UIButton) {
count++
}
@nolili
nolili / AsyncTests.swift
Created September 11, 2014 14:12
asynchronous unit test
import UIKit
import XCTest
class AsyncTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
@nolili
nolili / gist:a583ea045dafafebb17f
Last active June 22, 2020 01:41
Heart Rate Monitor Example(Swift)
import UIKit
import CoreBluetooth
class ViewController: UIViewController, CBCentralManagerDelegate, CBPeripheralDelegate {
let centralManager:CBCentralManager!
var connectingPeripheral:CBPeripheral!
required init(coder aDecoder: NSCoder) {
@nolili
nolili / gist:8d76128bb70d2263cb5a
Created November 15, 2014 08:28
CBCharacteristicからデータ取り出し
- (void) peripheral:(CBPeripheral *)aPeripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
// 長さチェック、エラーチェックなどは省略している
NSData *data = characteristic.value;
uint8_t value[2] = {0x00, 0x00};
[data getBytes:value length:2];
}
@nolili
nolili / gist:302a1d512f09781ae3be
Created February 9, 2015 14:25
CBCentralManagerStateDescription
extension CBCentralManagerState:Printable{
public var description: String { get {
switch self {
case .Unknown:
return "Unknown"
case .Resetting:
return "Resetting"
case .Unsupported:
@nolili
nolili / gist:6e209065d172945cb2a8
Created February 10, 2015 08:02
Swift 1.2 if let...
var hello:String? = "Hello"
var goodbye:String? = "Goodbye"
// Swift 1.2
if let a = hello, b = goodbye {
println(a + " ," + b)
}
// Swift 1.1
if let a = hello {