Skip to content

Instantly share code, notes, and snippets.

View paxbun's full-sized avatar

Chanjung Kim paxbun

  • Seoul, Republic of Korea
  • 14:02 (UTC +09:00)
  • LinkedIn in/paxbun
View GitHub Profile
@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
@paxbun
paxbun / Main.cc
Last active May 14, 2021 14:16
Run dynamically generated machine code on runtime
#ifdef _WIN32
# include <Windows.h>
#else
# include <sys/mman.h>
# include <unistd.h>
#endif
#include <array>
#include <cstddef>
#include <cstring>
@paxbun
paxbun / Main.cc
Created October 21, 2020 11:20
DLL calls functions in executable
#include <Windows.h>
#include <stdio.h>
extern "C" __declspec(dllexport) void ExportedFunction(char const* msg)
{
for (int i = 0; i < 5; ++i) printf("%s\n", msg);
}
int main()
{
@paxbun
paxbun / Cargo.toml
Last active July 11, 2020 15:53
C# and Rust interop example
[package]
name = "nok-internal"
version = "0.1.0"
authors = ["Chanjung Kim <freiyer.paxbun@gmail.com>"]
edition = "2018"
[dependencies]
num = "0.3.0"
[lib]
@paxbun
paxbun / Affinity.cc
Created July 8, 2020 01:34
Runs program on specific CPU core on Windows using SetProcessAffinityMask
#include <Windows.h>
#include <ctime>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
HANDLE process = GetCurrentProcess();
@paxbun
paxbun / Euclidean.cc
Created June 29, 2020 11:24
A simple program performing the Euclidean algorithm
#include <assert.h>
#include <iostream>
#include <type_traits>
template <typename I>
struct EuclideanResult
{
static_assert(std::is_integral_v<I>, "I must be integral");
I gcd, x, y, lhs, rhs;
};
@paxbun
paxbun / main.1.a.c
Last active April 21, 2020 14:55
5-7장 과제 2 정답 예시
// 직각삼각형
#include <stdio.h>
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i)
@paxbun
paxbun / main.c
Created March 26, 2020 05:35
5-7장 과제 정답 예시
#include <stdio.h>
int main()
{
int len = 0;
double weights[5], heights[5];
int maxlen = sizeof weights / sizeof(double);
printf("0: Add a member\n");
printf("Other than 0: Calculate BMI\n");
@paxbun
paxbun / index.css
Created November 18, 2019 04:20
Advanced calculator
* {
font-size: large;
}
#input {
padding: 4px;
min-width: 10px;
border-bottom: 1px;
}
@paxbun
paxbun / Calculator.js
Created November 17, 2019 10:19
Simple calculator
const ops = "+-*/";
const nums = "0123456789";
function split(expr) {
let rtn = [];
let stack = '';
for (let i = 0; i < expr.length; ++i) {
if (ops.includes(expr[i])) {
rtn.push(stack);
rtn.push(expr[i]);