Skip to content

Instantly share code, notes, and snippets.

View BasixKOR's full-sized avatar

Sung Jeon BasixKOR

View GitHub Profile
@BasixKOR
BasixKOR / index.js
Last active October 28, 2021 17:25
@node-rs/xxhash webpack reproduction
const { xxh32 } = require('@node-rs/xxhash-win32-x64-msvc'); // change it if you use another platform
xxh32('1');
@BasixKOR
BasixKOR / README.md
Last active May 7, 2023 03:16
Unlisted on GitHub
@BasixKOR
BasixKOR / Image.tsx
Created November 6, 2020 17:30
Trying to mix Img and next/image
import { Img, HTMLChakraProps } from '@chakra-ui/core';
import NextImage from 'next/image';
import { forwardRef, Ref } from 'react';
type NextImageProps = Parameters<typeof NextImage>[0]; // should be replaced with import from next when it exports its type
export type ImageProps = Omit<
HTMLChakraProps<'img'>,
'src' | 'srcSet' | 'ref' | 'width' | 'height' | 'loading' | 'w' | 'h' // TODO let it work with Chakra width/height props
> &
NextImageProps;
@BasixKOR
BasixKOR / main.rs
Created February 25, 2020 13:59
Fibonacci iterator
struct Fibonacci(usize, usize);
impl Iterator for Fibonacci {
type Item = usize;
fn next(&mut self) -> Option<Self::Item> {
let second = self.1;
self.1 = self.0 + self.1;
self.0 = second;
Some(self.1)
}
}
@BasixKOR
BasixKOR / main.rs
Created February 23, 2020 01:27
Buffered Standard I/O Quickstart
use std::io::{stdin, stdout, BufRead, BufWriter, Write};
fn main() {
let stdin = stdin();
let mut stdin = stdin.lock();
let stdout = stdout();
let mut stdout = BufWriter::new(stdout.lock());
// your code here
}
@BasixKOR
BasixKOR / gcd.rs
Last active February 23, 2020 09:49
Euclidean algorithm
/// Recursive
fn gcd<T>(a: T, b: T) -> T where T: std::ops::Rem<Output = T> + Eq + From<u8> + Copy {
if b == T::from(0u8) {
a
} else {
gcd(b, a % b)
}
}
/// Iterated
@BasixKOR
BasixKOR / README.md
Last active February 15, 2020 07:55
Handling codepage

Normalizing Codepage in Node.js

Only tested in CP-949.

Note

  • This will only work on the codepages below.
    • Windows codepages: 874, 1250-1258
    • IBM codepages: 437, 737, 775, 808, 850, 852, 855-858, 860-866, 869, 922, 1046, 1124, 1125, 1129, 1133, 1161-116
  • Multi-byte: 932, 936, 949, 950
@BasixKOR
BasixKOR / styled.ts
Last active January 6, 2020 08:05
linaria styled patch for Preact
import { styled as original } from 'linaria/react'
import { JSX, ComponentType, FunctionComponent } from 'preact'
//
// Preact Types
// Literally copied from Preact source code.
// see https://github.com/preactjs/preact/blob/master/src/index.d.ts
// The MIT License (MIT), Copyright (c) 2015-present Jason Miller
// -----------------------------------
@BasixKOR
BasixKOR / README.md
Last active November 28, 2019 06:56
CSV2JSON

This C code recieves a CSV data from stdin, and returns the result via stdout. You can pipe your data to put and extract both input and output.

Features

  • Supports automatic numberic conversion. (decimal only)
  • Supports real-time output right from stdout.

Limitations

  • Does not support double quoted items (therefore not RFC 4180 compatiable)
@BasixKOR
BasixKOR / a.js
Created June 14, 2019 05:55
Azur Lane Wiki Parsing
[...document.querySelectorAll('table.wikitable.col-7-center td[style="background-color:PowderBlue"]')]
.map(e => `'${e.textContent.slice(0, -1)}': { small: ${e.nextElementSibling.textContent.slice(0, -1)}, medium: ${e.nextElementSibling.nextElementSibling.textContent.slice(0, -1)}, `
+ `large: ${e.nextElementSibling.nextElementSibling.nextElementSibling.textContent.slice(0, -1)}, boss: ${e.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.textContent.slice(0, -1)}}`)
// https://azurlane.koumakan.jp/Experience