推荐5个开源项目,152k加星

本书作者:测试开发刚哥,文章版权归个人所有,未经授权请勿转载。 1、mindsdb 加星数:26.4k 技术栈:python,SDK (Golang, js, ruby, rust, C#, java, Cli) GitHub地址:https://github.com/mindsdb/mindsdb 项目介绍:MindsDB是一个开源的机器学习平台,旨在简化AI模型的创建、训练和部署过程。它允许开发者使用熟悉的SQL查询语言来构建和操作机器学习模型,从而降低了AI开发的门槛。 2、Mattermost 加星数:30.3k 技术栈:TypeScript, Golang GitHub地址:https://github.com/mattermost/mattermost 项目介绍:Mattermost是一个强大的开源协作平台,特别适合软件开发团队。它提供了丰富的功能和高度的可定制性,确保团队在整个软件开发生命周期中能够高效、安全地协作。通过自托管,用户可以完全控制他们的数据和平台的运行环境。 3、Kong 加星数:39k 技术栈:Lua, Perl, Raku, Starlark, Shell, Python GitHub地址:https://github.com/Kong/kong 项目介绍:Kong API Gateway是一个功能强大且高度可扩展的API网关,适用于各种环境。它以高性能和丰富的功能集(如安全性、负载均衡和监控)而著称。通过插件系统,Kong可以轻松扩展其功能,满足不同用户的需求。此外,Kong还提供了高级的AI功能,支持多种大语言模型,帮助用户实现智能化的API管理和优化。 4、Taipy 加星数:12.5k 技术栈:python, typescript GitHub地址:https://github.com/avaiga/taipy 项目介绍:Taipy是一个强大的工具,专为数据科学家和机器学习工程师设计,帮助他们构建数据和AI的Web应用程序。通过简化开发和部署流程,Taipy使用户能够专注于数据和AI算法的开发。其仅需Python语言的特点,使得用户无需学习新的编程语言,从而降低了使用门槛。Taipy还提供了强大的UI生成和场景/数据管理功能,进一步简化了项目的开发和管理。 5、appwrite 加星数:44.1k 技术栈:TypeScript, php GitHub地址:https://github.com/appwrite/appwrite 项目介绍:Appwrite是一个强大的端到端后端服务器,专为Web、移动、原生或后端应用程序设计。通过抽象复杂性和提供一整套现成的API和工具,Appwrite使开发者能够更快地构建安全的应用程序。其Docker微服务架构还使得部署和扩展变得更加方便。 参考资料: https://dev.to/rohan_sharma/top-open-source-reposprojects-to-contribute-hacktoberfest-edition--273o

字符集其实很简单

字符集其实是个很简单的东西,但很多人当时看懂了,过了就忘了。

OkHttp学习笔记

本书作者:测试开发刚哥,文章版权归个人所有,未经授权请勿转载。 OkHttp是什么 OkHttp是一个HTTP客户端,它不只是简单的发送请求和接收响应,还包含了失败重试、响应缓存等特性功能,并且能支持同步和异步请求。 OkHttp的语法相当简洁,比如Get: OkHttpClient client = new OkHttpClient(); String run(String url) throws IOException { Request request = new Request.Builder() .url(url) .build(); try (Response response = client.newCall(request).execute()) { return response.body().string(); } } 比如Post: public static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); OkHttpClient client = new OkHttpClient(); String post(String url, String json) throws IOException { RequestBody body = RequestBody.create(json, JSON); Request request = new Request.Builder() .url(url) .post(body) .build(); try (Response response = client.newCall(request).execute()) { return response.body().string(); } } 常见用法 Get(同步) private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { Request request = new Request.Builder() .url("https://publicobject.com/helloworld.txt") .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); Headers responseHeaders = response.headers(); for (int i = 0; i < responseHeaders.size(); i++) { System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i)); } System.out.println(response.body().string()); } } Get(异步) private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { Request request = new Request.Builder() .url("http://publicobject.com/helloworld.txt") .build(); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { e.printStackTrace(); } @Override public void onResponse(Call call, Response response) throws IOException { try (ResponseBody responseBody = response.body()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); Headers responseHeaders = response.headers(); for (int i = 0, size = responseHeaders.size(); i < size; i++) { System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i)); } System.out.println(responseBody.string()); } } }); } 访问Header private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { Request request = new Request.Builder() .url("https://api.github.com/repos/square/okhttp/issues") .header("User-Agent", "OkHttp Headers.java") .addHeader("Accept", "application/json; q=0.5") .addHeader("Accept", "application/vnd.github.v3+json") .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println("Server: " + response.header("Server")); System.out.println("Date: " + response.header("Date")); System.out.println("Vary: " + response.headers("Vary")); } } Post JSON public static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); OkHttpClient client = new OkHttpClient(); String post(String url, String json) throws IOException { RequestBody body = RequestBody.create(json, JSON); Request request = new Request.Builder() .url(url) .post(body) .build(); try (Response response = client.newCall(request).execute()) { return response.body().string(); } } Post字符串 public static final MediaType MEDIA_TYPE_MARKDOWN = MediaType.parse("text/x-markdown; charset=utf-8"); private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { String postBody = "" + "Releases\n" + "--------\n" + "\n" + " * _1.0_ May 6, 2013\n" + " * _1.1_ June 15, 2013\n" + " * _1.2_ August 11, 2013\n"; Request request = new Request.Builder() .url("https://api.github.com/markdown/raw") .post(RequestBody.create(MEDIA_TYPE_MARKDOWN, postBody)) .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } } Post Streaming public static final MediaType MEDIA_TYPE_MARKDOWN = MediaType.parse("text/x-markdown; charset=utf-8"); private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { RequestBody requestBody = new RequestBody() { @Override public MediaType contentType() { return MEDIA_TYPE_MARKDOWN; } @Override public void writeTo(BufferedSink sink) throws IOException { sink.writeUtf8("Numbers\n"); sink.writeUtf8("-------\n"); for (int i = 2; i <= 997; i++) { sink.writeUtf8(String.format(" * %s = %s\n", i, factor(i))); } } private String factor(int n) { for (int i = 2; i < n; i++) { int x = n / i; if (x * i == n) return factor(x) + " × " + i; } return Integer.toString(n); } }; Request request = new Request.Builder() .url("https://api.github.com/markdown/raw") .post(requestBody) .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } } Post文件 public static final MediaType MEDIA_TYPE_MARKDOWN = MediaType.parse("text/x-markdown; charset=utf-8"); private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { File file = new File("README.md"); Request request = new Request.Builder() .url("https://api.github.com/markdown/raw") .post(RequestBody.create(MEDIA_TYPE_MARKDOWN, file)) .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } } Post parameters private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { RequestBody formBody = new FormBody.Builder() .add("search", "Jurassic Park") .build(); Request request = new Request.Builder() .url("https://en.wikipedia.org/w/index.php") .post(formBody) .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } } Post multipart /** * The imgur client ID for OkHttp recipes. If you're using imgur for anything other than running * these examples, please request your own client ID! https://api.imgur.com/oauth2 */ private static final String IMGUR_CLIENT_ID = "..."; private static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png"); private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { // Use the imgur image upload API as documented at https://api.imgur.com/endpoints/image RequestBody requestBody = new MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("title", "Square Logo") .addFormDataPart("image", "logo-square.png", RequestBody.create(MEDIA_TYPE_PNG, new File("website/static/logo-square.png"))) .build(); Request request = new Request.Builder() .header("Authorization", "Client-ID " + IMGUR_CLIENT_ID) .url("https://api.imgur.com/3/image") .post(requestBody) .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } } 解析JSON响应为Java对象 private final OkHttpClient client = new OkHttpClient(); private final Moshi moshi = new Moshi.Builder().build(); private final JsonAdapter<Gist> gistJsonAdapter = moshi.adapter(Gist.class); public void run() throws Exception { Request request = new Request.Builder() .url("https://api.github.com/gists/c2a7c39532239ff261be") .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); Gist gist = gistJsonAdapter.fromJson(response.body().source()); for (Map.Entry<String, GistFile> entry : gist.files.entrySet()) { System.out.println(entry.getKey()); System.out.println(entry.getValue().content); } } } static class Gist { Map<String, GistFile> files; } static class GistFile { String content; } 响应缓存 private final OkHttpClient client; public CacheResponse(File cacheDirectory) throws Exception { int cacheSize = 10 * 1024 * 1024; // 10 MiB Cache cache = new Cache(cacheDirectory, cacheSize); client = new OkHttpClient.Builder() .cache(cache) .build(); } public void run() throws Exception { Request request = new Request.Builder() .url("http://publicobject.com/helloworld.txt") .build(); String response1Body; try (Response response1 = client.newCall(request).execute()) { if (!response1.isSuccessful()) throw new IOException("Unexpected code " + response1); response1Body = response1.body().string(); System.out.println("Response 1 response: " + response1); System.out.println("Response 1 cache response: " + response1.cacheResponse()); System.out.println("Response 1 network response: " + response1.networkResponse()); } String response2Body; try (Response response2 = client.newCall(request).execute()) { if (!response2.isSuccessful()) throw new IOException("Unexpected code " + response2); response2Body = response2.body().string(); System.out.println("Response 2 response: " + response2); System.out.println("Response 2 cache response: " + response2.cacheResponse()); System.out.println("Response 2 network response: " + response2.networkResponse()); } System.out.println("Response 2 equals Response 1? " + response1Body.equals(response2Body)); } 取消调用 private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { Request request = new Request.Builder() .url("http://httpbin.org/delay/2") // This URL is served with a 2 second delay. .build(); final long startNanos = System.nanoTime(); final Call call = client.newCall(request); // Schedule a job to cancel the call in 1 second. executor.schedule(new Runnable() { @Override public void run() { System.out.printf("%.2f Canceling call.%n", (System.nanoTime() - startNanos) / 1e9f); call.cancel(); System.out.printf("%.2f Canceled call.%n", (System.nanoTime() - startNanos) / 1e9f); } }, 1, TimeUnit.SECONDS); System.out.printf("%.2f Executing call.%n", (System.nanoTime() - startNanos) / 1e9f); try (Response response = call.execute()) { System.out.printf("%.2f Call was expected to fail, but completed: %s%n", (System.nanoTime() - startNanos) / 1e9f, response); } catch (IOException e) { System.out.printf("%.2f Call failed as expected: %s%n", (System.nanoTime() - startNanos) / 1e9f, e); } } 超时 private final OkHttpClient client; public ConfigureTimeouts() throws Exception { client = new OkHttpClient.Builder() .connectTimeout(10, TimeUnit.SECONDS) .writeTimeout(10, TimeUnit.SECONDS) .readTimeout(30, TimeUnit.SECONDS) .build(); } public void run() throws Exception { Request request = new Request.Builder() .url("http://httpbin.org/delay/2") // This URL is served with a 2 second delay. .build(); try (Response response = client.newCall(request).execute()) { System.out.println("Response completed: " + response); } } Per-call Configuration private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { Request request = new Request.Builder() .url("http://httpbin.org/delay/1") // This URL is served with a 1 second delay. .build(); // Copy to customize OkHttp for this request. OkHttpClient client1 = client.newBuilder() .readTimeout(500, TimeUnit.MILLISECONDS) .build(); try (Response response = client1.newCall(request).execute()) { System.out.println("Response 1 succeeded: " + response); } catch (IOException e) { System.out.println("Response 1 failed: " + e); } // Copy to customize OkHttp for this request. OkHttpClient client2 = client.newBuilder() .readTimeout(3000, TimeUnit.MILLISECONDS) .build(); try (Response response = client2.newCall(request).execute()) { System.out.println("Response 2 succeeded: " + response); } catch (IOException e) { System.out.println("Response 2 failed: " + e); } } 处理认证鉴权 private final OkHttpClient client; public Authenticate() { client = new OkHttpClient.Builder() .authenticator(new Authenticator() { @Override public Request authenticate(Route route, Response response) throws IOException { if (response.request().header("Authorization") != null) { return null; // Give up, we've already attempted to authenticate. } System.out.println("Authenticating for response: " + response); System.out.println("Challenges: " + response.challenges()); String credential = Credentials.basic("jesse", "password1"); return response.request().newBuilder() .header("Authorization", credential) .build(); } }) .build(); } public void run() throws Exception { Request request = new Request.Builder() .url("http://publicobject.com/secrets/hellosecret.txt") .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } } 跳过重试: ...

80道高频算法题Python版

80道高频算法题来源于牛客网,这些答案都经过了我验证,可以复制粘贴后提交通过:

Git比较分支差异的3个命令

查看本地分支

80道高频算法题Java版

80道常考算法题,逢考必过,剑指offer。

为什么Kafka这么快

Apache Kafka是一个开源的分布式事件流处理平台,主要用于高性能数据管道、流式分析、数据集成和关键任务应用。

一文搞懂Cookie,Session,Token,JWT

HTTP协议是无状态的,无状态意味着,服务器无法给不同的客户端响应不同的信息。这样一些交互业务就无法支撑了。Cookie应运而生。

5分钟轻松学正则表达式

本书作者:测试开发刚哥,文章版权归个人所有,未经授权请勿转载。 正则表达式是什么? 正则表达式,是一个表达式,用少量的简单字符,来表示复杂的长字符串。 实际工作用到很多,比如日志搜索、查找替换、JMeter 响应数据提取等。 先看一个例子,用户名包含字符、数字、下划线和连字符,并限制字符的个数: 这个表达式可以接受 john_doe、jo-hn_doe、john12_as,但是无法匹配到 Jo,因为它包含了大写的字母而且太短了。 字符匹配 正则表达式之所以强大,是因为通过一些特殊字符,能让它匹配到更多字符串。 表达式. 匹配任意单个字符除了换行符。 例:.ar => The car parked in the garage. 表达式[] 字符集。匹配方括号内的任意字符。并且字符是无先后顺序的。 例:[Tt]he => The car parked in the garage. 方括号的句号就表示句号。 例:ar[.] => A garage is a good place to park a car. 表达式[^] 否定的字符集。匹配除了方括号里的任意字符。 例:[^c]ar => The car parked in the garage. 表达式* 匹配 >= 0 个重复的在 * 号之前的字符。 例:a* => babaa123. 例:[a-z]* => The car parked in the garage #21. ...

RabbitMQ消息队列官方教程Java学习笔记

本书作者:测试开发刚哥,文章版权归个人所有,未经授权请勿转载。 消息队列 RabbitMQ是一个消息队列,它能够接收和转发消息。这个过程就像寄快递一样,把物件打包给快递小哥,快递小哥会负责把物件派送到正确的地址。 生产者和消费者 生产者就是用来生产消息(发送消息)的: 消费者就是用来消费消息(接收消息)的: 在生产者和消费者之间的就是消息队列: 它相当于消息缓冲区,最多能存储多少数据只受限于机器的内存和磁盘。多个生产者可以发送消息给同一个队列,多个消费者也可以从同一个队列接收消息。 Windows安装RabbitMQ 参考mall商城学习教程的RabbitMQ部分内容: http://www.macrozheng.com/#/architect/mall_arch_09?id=rabbitmq 原文中rabbitmq-server-3.7.14.exe下载地址失效了,改从这里下载: https://github.com/rabbitmq/rabbitmq-server/releases/tag/v3.7.14 安装完成后,确认服务已开启: 进入RabbitMQ安装目录下的sbin目录: 在地址栏输入cmd并回车启动命令行,然后输入以下命令启动管理功能: rabbitmq-plugins enable rabbitmq_management RabbitMQ运行在本地机器上: http://localhost:15672/ 默认用户名密码为guest / guest: Java客户端 amqp-client-5.7.1.jar是RabbitMQ官方提供的Java客户端: https://www.rabbitmq.com/tutorials/tutorial-one-java.html 既可以直接下载jar包,也可以在Maven中添加依赖: <dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-client</artifactId> <version>5.14.2</version> </dependency> 生产消息 导包: import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.Connection; import com.rabbitmq.client.Channel; 创建类Send,定义队列名为hello: public class Send { private final static String QUEUE_NAME = "hello"; public static void main(String[] argv) throws Exception { ... } } 建立连接: ...