Skip to content

Instantly share code, notes, and snippets.

View Alfex4936's full-sized avatar
✏️
I may be slow to respond.

seok Alfex4936

✏️
I may be slow to respond.
View GitHub Profile
@Alfex4936
Alfex4936 / wcongnamul.go
Created April 3, 2024 11:13
WGS84 coordinates to WCONGNAMUL (korea)
// ConvertWGS84ToWCONGNAMUL converts coordinates from WGS84 to WCONGNAMUL.
func ConvertWGS84ToWCONGNAMUL(lat, long float64) WCONGNAMULCoord {
x, y := transformWGS84ToKoreaTM(6378137, 0.0033528106647474805, 500000, 200000, 1, 38, 127, lat, long)
x = math.Round(x * 2.5)
y = math.Round(y * 2.5)
return WCONGNAMULCoord{X: x, Y: y}
}
// transformWGS84ToKoreaTM conversion
func transformWGS84ToKoreaTM(d, e, h, f, c, l, m, lat, lon float64) (float64, float64) {
@Alfex4936
Alfex4936 / downloader.py
Created December 12, 2023 10:41
Download Josen dynasty annals
import re
import requests
import urllib3
from selectolax.parser import HTMLParser
urllib3.disable_warnings()
def cleanup(tree):
@Alfex4936
Alfex4936 / main.rs
Created May 12, 2023 08:28
Korean jeongseong replace (한글 종성 변경) in Rust
use std::collections::HashMap;
fn get_jongseong_index(jongseong: char) -> Option<u16> {
let jongseong_map: HashMap<char, u16> = [
(' ', 0), ('ㄱ', 1), ('ㄲ', 2), ('ㄳ', 3),
('ㄴ', 4), ('ㄵ', 5), ('ㄶ', 6), ('ㄷ', 7),
('ㄹ', 8), ('ㄺ', 9), ('ㄻ', 10), ('ㄼ', 11),
('ㄽ', 12), ('ㄾ', 13), ('ㄿ', 14), ('ㅀ', 15),
('ㅁ', 16), ('ㅂ', 17), ('ㅄ', 18), ('ㅅ', 19),
('ㅆ', 20), ('ㅇ', 21), ('ㅈ', 22), ('ㅊ', 23),
@Alfex4936
Alfex4936 / pdf.py
Created September 20, 2021 10:21
Python: Merge all images into one pdf
> python pdf.py -f 1.png 2.png 3.png
> python pdf.py -f 1.png 2.png -n outname
@Alfex4936
Alfex4936 / args.c
Created March 7, 2021 09:17
C: how to use command line arguments
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc < 1)
return 0;
int i;
@Alfex4936
Alfex4936 / smp.py
Created January 9, 2021 09:23
Python smptlib example (HTML + img)
import smtplib
import time
from datetime import datetime
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import requests
from bs4 import BeautifulSoup
from pytz import timezone
@Alfex4936
Alfex4936 / terminal.sh
Created December 31, 2020 05:23
Confluent Kafka Connect Connection Check (From Zero to Hero with Kafka Connect)
bash -c ' \
echo -e "\n\n=============\nWaiting for Kafka Connect to start listening on localhost\n=============\n"
while [ $(curl -s -o /dev/null -w %{http_code} http://localhost:8083/connectors) -ne 200 ] ; do
echo -e "\t" $(date) " Kafka Connect listener HTTP state: " $(curl -s -o /dev/null -w %{http_code} http://localhost:8083/connectors)
" (waiting for 200)"
sleep 5
done
echo -e $(date) "\n----------\n\o/ Kafka Connect is ready! Listener HTTP state: " $(curl -s -o /dev/null -w %{http_code} http://localhost:8083/connectors) "\n----------\n"
'
@Alfex4936
Alfex4936 / fastavro.py
Created December 24, 2020 00:26
Python: Confluent Kafka + FastAvro (Producer + Consumer)
from io import BytesIO
from fastavro import parse_schema, schemaless_reader, writer
# a data to send
message = {
"id": 10000,
"title": "[FastAVRO] title",
"date": "20.12.23",
"link": "https://somelink",
@Alfex4936
Alfex4936 / result.py
Last active December 23, 2020 01:43
Python: solving Water Area problem in most bizaare and inefficient way
heights = [0, 8, 0, 0, 5, 0, 0, 10, 0, 0, 1, 1, 0, 3]
"""Result
(0 for void, 1 for a pillar, 2 for water)
[[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0],
[0, 1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0],
@Alfex4936
Alfex4936 / tarjan.py
Created November 23, 2020 13:13
Tarjan's Algorithm to find strongly connected componenets in directed graph in Python
from collections import defaultdict
UNVISITED = -1
class Graph:
global UNVISITED
def __init__(self, vertices):
self.v = vertices