Skip to content

Instantly share code, notes, and snippets.

🐢
on going

yoh yohhoy

🐢
on going
Block or report user

Report or block yohhoy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View TypeSafeBridge.md
// callee.m iOS Native(Objective-C) class
@interface NativeType
- (void)method:(int)arg;
@end

@implementation NativeType
// ...
@end
@yohhoy
yohhoy / invokeObjC.c
Created Jun 14, 2019
invoke Obj-C from pure-C
View invokeObjC.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <objc/message.h>
SEL sel_propSetter(Class clazz, const char* pname)
{
char* attr = property_copyAttributeValue(class_getProperty(clazz, pname), "S");
@yohhoy
yohhoy / ver.cpp
Created Apr 18, 2019
compiler version snippet
View ver.cpp
#if defined(__clang__)
#pragma message "Clang " __VERSION__
#elif defined(__GNUC__)
#pragma message "GCC " __VERSION__
#elif defined(_MSC_VER)
// https://qiita.com/yumetodo/items/8c112fca0a8e6b47072d
#define STR(s) #s
#define DUMP(s) #s "=" STR(s)
#pragma message ("MSVC " DUMP(_MSC_VER) " " DUMP(_MSC_FULL_VER))
#endif
View loop1.rs
// for i in 0..v.len() {sum += v[i];}
// https://play.rust-lang.org/?version=stable&mode=release&edition=2015&gist=a234fd242a39e0e33d1775ba986a7f50
playground::main:
pushq %r14
pushq %rbx
subq $152, %rsp
movq $0, 16(%rsp)
movl $800000000, %edi
movl $8, %esi
callq __rust_alloc@PLT
@yohhoy
yohhoy / yuvrgb.md
Last active Dec 4, 2018
RGB <=> YCbCr(YPbPr) color space conversion
View yuvrgb.md
Y  = a * R + b * G + c * B
Cb = (B - Y) / d
Cr = (R - Y) / e
BT.601 BT.709 BT.2020
a 0.299 0.2126 0.2627
b 0.587 0.7152 0.6780
View unscoped_enum.rs
//--------------------------------------------------------
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[repr(u8)]
enum UnscopedEnum {
AAA = 1,
BBB = 2,
CCC = 3,
}
const AAA: UnscopedEnum = UnscopedEnum::AAA;
@yohhoy
yohhoy / as_num.rs
Created Jul 6, 2018
Numeric cast (as operator) in generics
View as_num.rs
trait FromU32 {
fn from_u32(v: u32) -> Self;
}
macro_rules! impl_from_u32 {
($($ty:ty)*) => {
$(
impl FromU32 for $ty {
#[inline]
fn from_u32(v: u32) -> $ty {
View so45180.py
#!/usr/bin/env python3
# https://ja.stackoverflow.com/questions/45180/
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.colors as colors
n = 10
x_list = np.array(list(range(n*2)))
t_list = np.array(list(range(n*2)))
@yohhoy
yohhoy / m2tsdump.sh
Created Jun 6, 2018
hexdump MPEG-2 TS/PAT
View m2tsdump.sh
# PAT(PID=0x0000)
xxd -s ${offset} -c 188 -ps input.ts | grep -E "^47[46]000"
@yohhoy
yohhoy / sleepsort2.cpp
Last active Aug 10, 2019
"Sleep Sort" implementation with C++ Coroutines TS
View sleepsort2.cpp
#include <condition_variable>
#include <chrono>
#include <iostream>
#include <mutex>
#include <thread>
#include <utility>
#include <vector>
#include <experimental/coroutine>
You can’t perform that action at this time.