Skip to content

Instantly share code, notes, and snippets.

View honwhy's full-sized avatar
💭
I may be slow to respond.

Honwhy Wang honwhy

💭
I may be slow to respond.
View GitHub Profile
@honwhy
honwhy / after-build.md
Created September 15, 2024 04:14
你是一位资深Nodejs开发工程师,请写一段代码将zip压缩包里面的server/index.js文件内容替换为新的内容。

作为Node.js开发方面具有专业知识的工程师,我可以提供一个示例代码段,展示如何替换zip压缩包中的特定文件内容。你需要使用Node.js的adm-zip库来处理zip文件。以下是一个示例实现:

在Node.js中,你可以使用adm-zip库来处理ZIP文件的读取、修改和写入。以下是一个示例代码,展示了如何读取一个ZIP文件,替换其中的server/index.js文件内容,并保存更改。

首先,你需要安装adm-zip库:

npm install adm-zip
@honwhy
honwhy / TrieTreeNode.java
Last active January 16, 2023 14:28
TrieTreeNode v2
package org.example;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
public class TrieTreeNode {
private char ch;
private Set<Long> ids = new HashSet<>();
LinkedHashMap<Character, TrieTreeNode> children = new LinkedHashMap<>();
@honwhy
honwhy / App.java
Created December 31, 2022 16:12
Java 8 CompletableFuture Suggestions
package org.example;
import java.util.*;
import java.util.concurrent.*;
/**
* Hello world!
*/
public class App {
static BlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<>(200);
@honwhy
honwhy / AnnotatedMap.java
Created June 12, 2022 09:23
copy Annotation to Map
package com.example.br;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
@MyTable("t_table")
public class AnnotatedMap<K, V> extends HashMap<K,V> {
public AnnotatedMap() {
@honwhy
honwhy / MyFTP.java
Created January 12, 2020 08:13
用nio写ftpclient(未完)
package org.example;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
@honwhy
honwhy / vue-crypto-js.html
Created January 1, 2020 14:29
vue-crypto-js.html
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
</body>
<div id="app">
<textarea v-model="input">
</textarea>
@honwhy
honwhy / TcpTimeClient.java
Created December 17, 2019 15:54
selector in client side(sorry forget the link from stackoverflow)
package com.honey;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
@honwhy
honwhy / ConsumerQueueDemo.java
Created October 20, 2019 10:45
ConcurrentLinkedQueue vs BlockingQueue
package com.honey;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.*;
public class ConsumerQueueDemo {
public static void main(String[] args) {
//making hot spot code
@honwhy
honwhy / AesDemo.java
Created October 18, 2019 17:08
aes cbc demo
package com.honey;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Random;
public class AesDemo {
@honwhy
honwhy / MultiThreadHashMap.java
Created March 17, 2019 08:48
MultiThreadHashMap
public class MultiThreadHashMap {
private static final Object PRESENT = new Object();
public static void main(String[] args) throws InterruptedException, BrokenBarrierException {
final Map<String,Object> map = new HashMap<>(); //let map do resize multiple times
int N = 1000;
final CyclicBarrier cyclicBarrier = new CyclicBarrier(N+1);
for (int i = 0; i < N; i++) {
new Thread(new Runnable() {
@Override
public void run() {