Skip to content

Instantly share code, notes, and snippets.

🐢
on going

yoh yohhoy

View GitHub Profile
@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
Created Apr 14, 2018
"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>
@yohhoy
yohhoy / delayqueue.cpp
Last active Apr 12, 2018
C++ delay queue - unbound blocking queue with delay of element deque (like Java's java.util.concurrent.DelayQueue)
View delayqueue.cpp
#include <chrono>
#include <condition_variable>
#include <mutex>
#include <utility>
#include <vector>
struct closed_queue : std::exception {};
template <typename T, typename Clock = std::chrono::system_clock>
@yohhoy
yohhoy / sleepsort.cpp
Created Apr 11, 2018
"Sleep Sort" implementation with C++ Coroutines TS
View sleepsort.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.