Skip to content

Instantly share code, notes, and snippets.

@bright23
bright23 / CodePiece.swift
Created November 12, 2016 04:31
swiftのerrorってこれで出せるんやぁ。 catch のとこで補完出してほしい... #swift #CodePiece
```
do {
try jsonData.write(toFile: url.path, atomically: true, encoding: String.Encoding.utf8)
} catch let error as NSError {
print("error:::\(error)")
fatalError()
}
```
/**
* UIStoryboard (InstantiateViewController)
*/
UIKIT_STATIC_INLINE __kindof UIViewController *InstantiateViewControllerOnStoryboard(NSString *storyboardName, NSString *identifier) {
return [[UIStoryboard storyboardWithName:storyboardName bundle:nil] instantiateViewControllerWithIdentifier:identifier];
}
UIKIT_STATIC_INLINE __kindof UIViewController *InstantiateInitialViewControllerOnStoryboard(NSString *storyboardName) {
return [[UIStoryboard storyboardWithName:storyboardName bundle:nil] instantiateInitialViewController];
}
dic = Hash.new(0)
while line = ARGF.gets
line.downcase!
while line.sub!(/[a-z]+/,"")
word = $&
dic[word] += 1
end
end
p dic.sort{|a,b|b[1] <=> a[1]}[0...5]
curl -X GET "https://" -O \
-H "Accept:" \
-H "Authorization:Bearer "
var Excel = require('exceljs')
var fs = require('fs')
var util = require('util')
var targetExcelPath = "リスト.xlsx"
// ワークブック指定
var workbook = new Excel.Workbook();
// ファイルを読み込み
Bleacon = require('bleacon');
//uuidgenで生成したID(ハイフン除く)を記述する
var uuid = 'C6094E809AE04186A2288EC79D7DA8B0';
var major = 0;
var minor = 0;
var measuredPower = -59;
Bleacon.startAdvertising(uuid,major,minor,
measuredPower);
console.log('ble running ....')
var http = require('http')
var url = 'http://itunes.apple.com/jp/rss/topsongs/limit=100/xml';
var rss = '';
var req = http.get(url, function (res) {
// テキストファイルの場合は、エンコード指定は重要!
res.setEncoding('utf8');
@bright23
bright23 / DeviceConst.swift
Created November 26, 2016 05:34
DeviceConst.swift
//
// AppConst.swift
// AdBlockSample
//
// Created by bright on 2016/11/26.
// Copyright © 2016年 bright. All rights reserved.
//
import Foundation
import UIKit
// 1. Declare outside class definition (or in its own file).
// 2. UIKit must be included in file where this code is added.
// 3. Extends UIDevice class, thus is available anywhere in app.
//
// Usage example:
//
// if UIDevice().type == .simulator {
// print("You're running on the simulator... boring!")
// } else {
// print("Wow! Running on a \(UIDevice().type.rawValue)")
//
// EnumEnumerable+count.swift
// AdBlockSample
//
// Created by bright on 2016/11/08.
// Copyright © 2016年 bright. All rights reserved.
//
import Foundation