Skip to content

Instantly share code, notes, and snippets.

View 7gano's full-sized avatar

Norihisa Nagano 7gano

View GitHub Profile
//: Playground - noun: a place where people can play
import UIKit
class Hoge: Comparable, Hashable {
let text:String
init(text:String) {
self.text = text
}
//: Playground - noun: a place where people can play
import UIKit
class Hoge: NSObject, Comparable {
let text:String
init(text:String) {
self.text = text
}
@7gano
7gano / AVAssetReaderAudioMixOutput.swift
Created August 1, 2017 04:23
AVAssetReaderAudioMixOutput
let asset = AVAsset(url: sourceFileURL)
let dict = [AVSampleRateKey:44100, AVFormatIDKey:kAudioFormatLinearPCM] as [String : Any]
assetReaderOutput = AVAssetReaderAudioMixOutput(audioTracks: asset.tracks, audioSettings: dict)
do {
assetReader = try AVAssetReader(asset: asset)
if assetReader.canAdd(assetReaderOutput) {
assetReader.add(assetReaderOutput)
assetReader.startReading()
}
@7gano
7gano / 平成.swift
Created September 7, 2016 06:27
今は平成28年だゾ!
let japaneaseCalendar = Calendar(identifier: Calendar.Identifier.japanese)
var dateFormatter = DateFormatter()
dateFormatter.calendar = japaneaseCalendar
dateFormatter.dateFormat = "GGyy"
dateFormatter.locale = Locale(identifier: "ja_JP")
dateFormatter.string(from: Date())
@7gano
7gano / CollectionViewCellに置いたUIButtonがウインクしちゃうよパトラッシュ.swift
Last active February 10, 2016 07:38
CollectionViewCellに置いたUIButtonがウインクしちゃうよパトラッシュ
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! ButtonCollectionViewCell
if let button = cell.button {
//アニメーションオフしてレイアウトしてアニメーションオンにするとOK
UIView.setAnimationsEnabled(false)
button.setTitle(String(indexPath.item), forState: UIControlState.Normal)
button.layoutIfNeeded()
UIView.setAnimationsEnabled(true)
}
@7gano
7gano / hoge.swift
Created February 5, 2016 07:03
NSURLComponentsというのができとってなぁ
let a = NSURLQueryItem(name: "a", value: "yes")
let b = NSURLQueryItem(name: "b", value: "no")
let urlComponents = NSURLComponents(string: "https://hoge.com")
urlComponents!.queryItems = [a, b]
urlComponents!.URL
=> "https://hoge.com?a=yes&b=no"
@7gano
7gano / info.plist
Last active May 12, 2016 03:53
UILaunchImageName 4画面対応版
<key>UILaunchImages</key>
<array>
<dict>
<key>UILaunchImageName</key>
<string>Default</string>
<key>UILaunchImageMinimumOSVersion</key>
<string>7.0</string>
<key>UILaunchImageOrientation</key>
<string>Portrait</string>
<key>UILaunchImageSize</key>
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextAddRect(context, CGRectMake(50, 50, 200, 250));
CGContextAddRect(context, CGRectMake(60, 60, 100, 100));
CGContextSetRGBFillColor(context, 0, 0, 1, 1);
CGContextDrawPath(context, kCGPathEOFill);
}
[ 92%] Generating pyopencv_generated_funcs.h, pyopencv_generated_func_tab.h, pyopencv_generated_types.h, pyopencv_generated_type_reg.h, pyopencv_generated_const_reg.h
Traceback (most recent call last):
File "/Users/nagano/Dropbox/OpenCV/opencv/modules/python/src2/gen2.py", line 896, in <module>
generator.gen(srcfiles, dstdir)
File "/Users/nagano/Dropbox/OpenCV/opencv/modules/python/src2/gen2.py", line 826, in gen
decls = parser.parse(hdr)
File "/Users/nagano/Dropbox/OpenCV/opencv/modules/python/src2/hdr_parser.py", line 733, in parse
linelist = list(f.readlines())
File "/usr/local/Cellar/python3/3.3.3/Frameworks/Python.framework/Versions/3.3/lib/python3.3/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
#import "RCViewController.h"
@import QuartzCore;
@implementation RCViewController
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect rect;