Skip to content

Instantly share code, notes, and snippets.

View omochi's full-sized avatar
🏠
Working from home

omochimetaru omochi

🏠
Working from home
  • Qoncept, Inc
  • Yokohama
View GitHub Profile
class A {
val a = 3
fun aaa() {
val x = object {
val b = 4
fun bbb() {
println(b) // thisはobject
println(a) // thisはA
}
void CopyImageYv12(const ImageFormat & format,
const uint8_t * src, int src_stride,
uint8_t * dest, int dest_stride)
{
CopyImageRows(format.height(), src, src_stride, dest, dest_stride, &src, &dest);
CopyImageRows(format.height() / 2, src, src_stride / 2, dest, dest_stride / 2, &src, &dest);
CopyImageRows(format.height() / 2, src, src_stride / 2, dest, dest_stride / 2, &src, &dest);
}
void CopyImageNv12(const ImageFormat & format,
namespace sptt {
template <typename F>
struct FuncTrait :
public FuncTrait<decltype(&F::operator())> {};
template <typename F, typename R, typename ...Args>
struct FuncTrait<R (F::*)(Args...) const> :
public FuncTrait<R (F::*)(Args...)> {};
protocol A {
func po()
}
protocol B : A {
}
protocol Base {
var module: A { get }
}
import Foundation
func dump(_ p: UnsafeRawPointer, _ size: Int) {
let addr = unsafeBitCast(p, to: UInt64.self)
let p = p.bindMemory(to: UInt8.self, capacity: size)
for i in 0..<size {
if i % 8 == 0 {
if i != 0 {
print()
}
import Foundation
let str = "abcαβγあいう😀"
print(str.unicodeScalars.map { $0.value }
.map { String(format: "0x%02x", $0) }
.joined(separator: ", "))
print(str.utf8.map { String(format: "0x%02x", $0) }
.joined(separator: ", "))
// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript
// https://ja.wikipedia.org/wiki/UTF-8
// https://ja.wikipedia.org/wiki/UTF-16
export function unicodesToUtf8(array: number[]): number[] {
const ret: number[] = [];
for (let uc of array) {
if (uc < 0x80) {
ret.push(uc);
continue;
// a.ts
import { B } from "./B";
export class A {
    createB(): B {
        return new B();
    }
}
// staticメソッド制約
protocol Creatable {
static func create() -> Self
}
// 既存の型にその制約を適用
extension Int : Creatable {
static func create() -> Int {
return 3
}
protocol PA {
func paStr() -> [String]
}
protocol PB {
func pbStr() -> String
}
protocol PX : PA, PB {
}