Skip to content

Instantly share code, notes, and snippets.

View airglow923's full-sized avatar
🪖
National Service

Hyundeok Park airglow923

🪖
National Service
  • South Korea
  • 16:11 (UTC +09:00)
View GitHub Profile
@airglow923
airglow923 / binary.py
Last active October 13, 2021 03:26
Binary-related code written in Python
# Return a binary representation of an integer with space every 4 bits
def get_binary(x):
binary = bin(x)[2:]
for i in range(len(binary) - 4, 0, -4):
binary = binary[:i] + ' ' + binary[i:]
return binary
# Convert binary floating-point number into decimal
@airglow923
airglow923 / instructions.md
Created July 22, 2021 05:46
AMD64 instructions

I don't have a reliable tool to measure the time taken to execute one or more instructions.

This is just to keep track of the assembly output for different C expressions.

The assembly is in AT&T syntax, but the comments will be written in Intel syntax as GitHub Markdown does not support AT&T syntax.

Arithmetic

Multiplication

@airglow923
airglow923 / deno-to-latex-uri.js
Last active June 10, 2021 09:55
Convert LaTeX code into URI so as to embed it in websites
const latex = Deno.args[0];
const latexRenderer = 'https://latex.codecogs.com/svg.latex?';
if (latex === undefined || typeof latex !== 'string') {
const errMsg = 'Invalid argument';
writeStdStream(errMsg, Deno.stderr);
Deno.exit(1);
}
async function writeStdStream(str, stream = Deno.stdout) {
@airglow923
airglow923 / gen-js-integrity.sh
Created May 7, 2021 10:14
A shell script that generates an integrity for a JavaScript file
#!/bin/sh
usage() {
# additional error messages
if [ "$#" -ne 0 ]; then
printf "$@\n" >&2;
fi
printf "Usage: $0 ALGORITHM JS_FILE\n" >&2;
}
@airglow923
airglow923 / change-from-jfif-to-jpg.bat
Last active May 1, 2021 02:34
A batch script that changes the default extension for jpeg from jfif to jpg
@echo off
REG ADD "HKCR\MIME\Database\Content Type\image/jpeg" /v Extension /t REG_SZ /d .jpg /f
@airglow923
airglow923 / clang-tidy-readability-identifier-naming-gcc.yml
Last active April 29, 2021 07:58
clang-tidy readability-identifier-naming for GCC's naming convention
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: lower_case
- key: readability-identifier-naming.ClassMemberCase
value: lower_case
- key: readability-identifier-naming.ClassMemberPrefix
value: s_
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.EnumConstantCase
@airglow923
airglow923 / libcxx-forward-list-node-impl.h
Last active October 29, 2021 05:12
Simplified version of LLVM libcxx allocator-aware container node implementation
// This header is redistributed under the Apache License v2.0 with LLVM Exceptions.
// The whole license can be found:
// https://releases.llvm.org/12.0.0/LICENSE.TXT
// The entire implementation of forward_list can be found:
// https://github.com/llvm-mirror/libcxx/blob/master/include/forward_list
#include <memory>
#include <type_traits>
using std::allocator_traits;
@airglow923
airglow923 / sources.list-focal
Last active February 29, 2024 20:11
Ubuntu Mirrors sources.list for Focal (20.04), Hirsute (21.04), Impish (21.10) and Jammy (22.04)
deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu focal-proposed main restricted universe multiverse
@airglow923
airglow923 / run-clang-tidy.sh
Last active April 17, 2021 14:16
Run clang-tidy given directories and regex pattern.
#!/bin/bash
usage() {
# additional error messages
if [ "$#" -ne 0 ]; then
printf "$@\n" >&2;
fi
printf "Usage: $0 [ -e REGEX_PATTERN ] DIRECTORY [DIRECTORIES...]\n" >&2;
}
@airglow923
airglow923 / valgrind-command
Created March 31, 2021 17:47
Valgrind detailed command
valgrind \
--leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--verbose \
--log-file=valgrind-out.txt \
./executable