Skip to content

Instantly share code, notes, and snippets.

View paxbun's full-sized avatar

Chanjung Kim paxbun

  • Seoul, Republic of Korea
  • 15:36 (UTC +09:00)
  • LinkedIn in/paxbun
View GitHub Profile
@paxbun
paxbun / float32.v
Last active July 7, 2021 17:58
IEEE single-precision floating-point format addition/multiplication implementation (not handling NaN and INF)
module float32_splitter
(
input [31:0] in,
output sgn,
output [8:0] exp,
output [23:0] man
);
assign sgn = in[31];
assign exp[8] = 0;
assign exp[7:1] = in[30:24];
@paxbun
paxbun / Main.cc
Created May 28, 2021 19:27
C++20 string as non-type template argument example
#include <iostream>
struct String
{
const char* str;
constexpr String(const char* str) : str { str } {}
constexpr operator const char*() const
{
return str;
}
@paxbun
paxbun / Program.cs
Last active July 30, 2021 06:26
JS spread operator on C#
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
public record Foo
{
public int Data { get; init; }
public int Data2 { get; init; }
public int Data3 { get; init; }
public int Data4 { get; init; }
@paxbun
paxbun / Function.cc
Last active January 16, 2021 13:32
std::function-like class with operator== implementation
#include <iostream>
#include <typeindex>
template <typename T>
class Function;
template <typename T, typename... Args>
class Function<T(Args...)>
{
private:
@paxbun
paxbun / sleep.rs
Created January 11, 2021 14:52
Rust wasm sleep example
#[wasm_bindgen]
pub fn sleep(ms: i32) -> js_sys::Promise {
js_sys::Promise::new(&mut |resolve, _| {
web_sys::window()
.unwrap()
.set_timeout_with_callback_and_timeout_and_arguments_0(&resolve, ms)
.unwrap();
})
}
@paxbun
paxbun / main.rs
Created January 1, 2021 17:39
rusty_v8 example
use rusty_v8 as v8;
static MODULE_CODE_1: &'static str = r#"
import { foo, bar } from "module_2";
let input = foo(3);
bar(...input);
console.log('foo');
"#;
fn foo(
@paxbun
paxbun / Main.cpp
Last active December 8, 2020 20:47
C++20 coroutine example
#include <coroutine>
#include <iostream>
#include <optional>
size_t buffer[22];
struct my_generator
{
struct promise_type
{
@paxbun
paxbun / Main.asm
Created December 7, 2020 12:16
Windows API example
; Copyright (c) 2020 Chanjung Kim. All rights reserved.
.data
text db "Hello, world!", 0
caption db "My title", 0
.code
extern GetStdHandle: proc
@paxbun
paxbun / no-virtual-wc.cc
Created October 31, 2020 14:20
10월 5주차 튜터링(10월 26일 ~ 11월 1일) 튜터링 때 사용한 코드
#include <iostream>
class Base
{
private:
int _value;
public:
int GetValue() const
{
@paxbun
paxbun / .clang-format
Last active April 7, 2022 09:23
My clang-format configuration file
# Copyright (c) 2020-2022 Chanjung Kim (paxbun). All rights reserved.
# Licensed under the MIT License.
# See Clang 10 documentation for more information.
BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true