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
Array has moveForMin. | |
It is find min from <from> index <br/>**- from was bad choice. i thought -** | |
<br/>and move to <moveTo> | |
```objc | |
extension Array where Element: Comparable{ | |
mutating func moveForMin(offset: Int = 0, moveTo to: Int) { | |
let subArray = self[offset..<self.count] | |
guard let minValue = subArray.min(isOrderedBefore: <) else { |
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 | |
@IBDesignable | |
class CharacterView: UIView { | |
let pathLayer = CAShapeLayer() | |
override func didMoveToSuperview() { | |
if nil != superview { | |
if pathLayer.superlayer != self.layer { | |
self.layer.addSublayer(pathLayer) |
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 -<T: Equatable> (lhs: Array<T>, rhs: Array<T>) -> Array<T> { | |
return lhs.filter({ (lv) -> Bool in | |
return false == rhs.contains(lv) | |
}) | |
} | |
func |<T: Equatable> (lhs: [T], rhs: [T]) -> [T] { | |
return lhs + rhs.filter({ (rv) -> Bool in | |
return false == lhs.contains(rv) | |
}) |
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 -=<O: OptionSetType where O.RawValue == UInt32>(inout lhs: O, rhs: O) { | |
lhs = O(rawValue: lhs.rawValue ^ rhs.rawValue) | |
} | |
func +=<O: OptionSetType where O.RawValue == UInt32>(inout lhs: O, rhs: O) { | |
lhs = O(rawValue: lhs.rawValue | rhs.rawValue) | |
} | |
func +<O: OptionSetType where O.RawValue == UInt32>(lhs: O, rhs: O) -> O { | |
return O(rawValue: lhs.rawValue | rhs.rawValue) | |
} | |
func -<O: OptionSetType where O.RawValue == UInt32>(lhs: O, rhs: O) -> O { |
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
protocol PatternComparable {} | |
struct Pattern<C: Comparable>: PatternComparable { | |
let op: (lhs: C, rhs: C) -> Bool | |
let to: C | |
func compare(from: C) -> Bool { | |
return op(lhs: from, rhs: to) | |
} | |
} |
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
protocol Castable {} | |
protocol UnsafePointerProtocol: NilLiteralConvertible { | |
associatedtype Memory | |
init(nilLiteral: ()) | |
init<Memory>(_ from: UnsafeMutablePointer<Memory>) | |
init<Memory>(_ from: UnsafePointer<Memory>) | |
var memory: Memory { get } | |
func mutable<M>() -> UnsafeMutablePointer<M> |
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
defer { | |
avcodec_send_packet(avctx, NULL) | |
while true { | |
if AVERROR_EOF == avcodec_receive_packet(avctx, frame) { | |
break | |
} | |
} | |
} | |
while 0 <= av_read_frame(avctx, packet) { | |
// avcodec_decode_video2[audio4](...)を下のコードに変更します。 |
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
typedef struct AVFrame { | |
... | |
uint8_t *data[AV_NUM_DATA_POINTERS]; // AV_NUM_DATA_POINTERS = 8 | |
... |
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 audioContext: UnsafeMutablePointer<AVCodecContext> | |
// プレイするサウンドの基本設定 | |
let audioFormat: AVAudioFormat( | |
commonFormat: .pcmFormatFloat32, | |
sampleRate: Double(audioContext.pointee.sample_rate), | |
channels: 2, // サウンドシステムのoutputチャンネルを超えたらクラッシューが発生されます。 | |
interleaved: false) |
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
#!/bin/bash | |
abort() | |
{ | |
echo >&2 ' ABORTED ' | |
exit 1 | |
} | |
trap 'abort' 0 |
OlderNewer