Skip to content

Instantly share code, notes, and snippets.

View kentyeh's full-sized avatar

Kent Yeh kentyeh

View GitHub Profile
@kentyeh
kentyeh / OilPrice.html
Last active June 2, 2022 06:14
油價計算器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>油價計算機</title>
<style>
table{
border:1px solid black;
}
@kentyeh
kentyeh / ReactorMain.java
Last active August 13, 2021 05:50
Test Reactor Async threading
import java.io.IOException;
import java.io.InputStream;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
import org.apache.logging.log4j.core.layout.PatternLayout;
/**
public static boolean isValidIDorRCNumber(String ID) {
if (ID == null || ID.trim().isEmpty() || !ID.matches("[A-Za-z][A-Da-d1289]\\d{8}")) {
return false;
}
String head = "ABCDEFGHJKLMNPQRSTUVXYWZIO";
char[] id = ID.toUpperCase().toCharArray();
int chksum = (head.indexOf(id[0]) + 10) / 10
+ (head.indexOf(id[0]) + 10) % 10 * 9 % 10;
chksum += (id[1] > '@' && id[1] < 'E') ? ((head.indexOf(id[1]) + 10) % 10) * 8 % 10
: (id[1] - 48) * 8 % 10;
@kentyeh
kentyeh / ResizeImage
Created January 14, 2020 06:47
重新調整影像大小
import java.awt.image.BufferedImage;
import java.awt.Image;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
public class ResizeImage {
public static void resize(BufferedImage bufferedImage, int maxEdge, OutputStream os) throws IOException {
int w = bufferedImage.getWidth();
@kentyeh
kentyeh / ZhBigNum.java
Last active March 4, 2024 08:48
數值轉中文大寫
import java.util.regex.Pattern;
/**
* @author Kent Yeh
*/
public class ZhBigNum {
public static final Pattern ZEROP = Pattern.compile("\\x{96F6}{2,}");
public static void main(String[] args) {
@kentyeh
kentyeh / ConvertMp3toWav
Created January 7, 2020 08:17
轉換Mp3為Wav
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import javax.sound.sampled.AudioFormat;
@kentyeh
kentyeh / Proj4j.java
Created October 24, 2018 08:26
TWD97座標轉經緯度
import org.osgeo.proj4j.CRSFactory;
import org.osgeo.proj4j.CoordinateReferenceSystem;
import org.osgeo.proj4j.CoordinateTransform;
import org.osgeo.proj4j.CoordinateTransformFactory;
import org.osgeo.proj4j.ProjCoordinate;
public class Proj4j {
/**
* https://search.maven.org/search?q=a:proj4j 找出proj4j轉案
* http://www.sunriver.com.tw/taiwanmap/grid_tm2_convert.php#a03 線上轉換(參考範本)
@kentyeh
kentyeh / rolling3images.svg
Last active February 23, 2017 16:15
svg to rolling images
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import java.math.BigInteger;
import java.util.UUID;
/** Code from
* https://github.com/cchigoriwa/jaxcsd/blob/master/jaxcsd-api/src/main/java/zw/co/hitrac/jaxcsd/api/util/UUIDBasedOID.java
*/
public class UUIDBasedOID {
protected static final String OID_PREFIX = "2.25"; // {joint-iso-itu-t uuid(25) <uuid-single-integer-value>}