Skip to content

Instantly share code, notes, and snippets.

View zihluwang's full-sized avatar

Zihlu Wang zihluwang

View GitHub Profile
@zihluwang
zihluwang / KeyLoader.java
Last active July 6, 2024 01:30
A loader for EC Key Pair
public class KeyLoader {
private static ECPrivateKey loadPrivateKey() throws NoSuchAlgorithmException, InvalidKeySpecException {
// generate key: openssl ecparam -genkey -name secp521r1 -noout -out private_key.pem
// parse key: openssl pkcs8 -topk8 -in .\private_key.pem -out pkcs8_rsa_private_key.pem -nocrypt
var privateKey = "key string";
var keyBytes = Base64.getDecoder().decode(privateKey);
var spec = new PKCS8EncodedKeySpec(keyBytes);
var kf = KeyFactory.getInstance("EC");
var key = kf.generatePrivate(spec);
if (key instanceof ECPrivateKey pk) {
@zihluwang
zihluwang / settings.xml
Created June 6, 2024 06:21
Maven user settings.
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
-->
@zihluwang
zihluwang / base.user.css
Created June 6, 2024 06:15
Typora User Settings
#write .CodeMirror-wrap .CodeMirror-code pre {
font-family: MonoLisa, Menlo, 'Cascadia Code', Consolas;
}
.md-fences,
code,
tt {
font-family: MonoLisa, Menlo, 'Cascadia Code', Consolas;
}
@zihluwang
zihluwang / repository.init.gradle.kts
Last active June 6, 2024 06:16
Gradle initialise settings for repository.
allprojects {
repositories {
mavenLocal()
maven("https://maven.proxy.ustclug.org/maven2/")
maven("https://maven.aliyun.com/repository/public/")
mavenCentral()
}
}
@zihluwang
zihluwang / .prettierrc.yaml
Last active June 6, 2024 06:17
Prettier personal settings.
printWidth: 80
tabWidth: 2
useTabs: false
semi: false
singleQuote: false
quoteProps: as-needed
jsxSingleQuote: false
trailingComma: es5
bracketSpacing: true
bracketSameLine: true
@zihluwang
zihluwang / spring.xml
Created May 30, 2022 15:56
SSM Spring Config
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="cn.vorbote.demo" use-default-filters="false">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
@zihluwang
zihluwang / dispatcher-servlet.xml
Created May 30, 2022 15:55
Spring Dispatcher Servlet
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
@zihluwang
zihluwang / web.xml
Created May 30, 2022 15:54
Java Dynamic Web Full Configuration File
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:container.xml</param-value>
</context-param>
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="COLOURFUL_OUTPUT" value="%black(%date{'dd MMM, yyyy HH:mm:ss', Asia/Hong_Kong, en-UK}) %highlight(%-5level) %black(---) %black([%10.10t]) %cyan(%-20.20logger{20}) %black(:) %msg%n"/>
<property name="STANDARD_OUTPUT" value="%date{'dd MMM, yyyy HH:mm:ss', Asia/Hong_Kong, en-UK} %-5level %black(---) [%10.10t] %-20.20logger{20} : %msg%n"/>
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${COLOURFUL_OUTPUT}</pattern>
</encoder>