从好玩到好用:程序员用AI提效的那些事儿

好玩,程序员,ai,那些,事儿 · 浏览次数 : 6

小编点评

## Case Study 1: Resource Scheduling with ChatGPT **Problem:** * How can we automate the scheduling of tasks across multiple days? **Solution:** * Use ChatGPT to analyze the task dependencies and generate the optimal schedule. * This can be achieved by splitting the scheduling process into separate days and providing ChatGPT with the necessary information about the tasks. **Steps:** 1. Define a function to represent the task dependencies. 2. Pass the task dependencies to ChatGPT. 3. ChatGPT will generate the optimal schedule. 4. Return the schedule as a string. **Benefits:** * The solution is highly flexible and can handle complex task dependencies. * ChatGPT's ability to generate natural language descriptions can improve communication and understanding between team members. ## Case Study 2: Regular Expression Explanation **Problem:** * How can we understand the meaning of a regular expression in the context of code? **Solution:** * Use ChatGPT to analyze the regular expression and provide a detailed explanation. * This can be achieved by passing the regular expression to ChatGPT and specifying the programming language. **Benefits:** * ChatGPT's ability to explain complex concepts can help developers better understand and implement regular expressions. * This can lead to improved code quality and maintenance. ## Case Study 3: CSV Data Splitting **Problem:** * How can we write a program that splits a large CSV file into multiple parts based on a given number of rows? **Solution:** * Use ChatGPT to generate a program that can handle this task. * This can be achieved by providing ChatGPT with the following inputs: * The total number of rows in the CSV file. * The number of rows to split the file into. * The delimiter used in the CSV file. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability. ## Case Study 4: JavaBean to JSON Conversion **Problem:** * How can we generate a JavaBean object from a JSON string using ChatGPT? **Solution:** * Use ChatGPT to generate a JavaBean class with the correct fields and properties. * This can be achieved by providing ChatGPT with the JSON string and the JavaBean class template. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability. ## Case Study 5: Annotate and Generate Java Class **Problem:** * How can we generate a JavaBean class annotated with specific annotations using ChatGPT? **Solution:** * Use ChatGPT to generate a Java class annotated with the desired annotations. * This can be achieved by providing ChatGPT with the class name and the annotations as strings. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability. ## Case Study 6: Annotate and Generate Java Method **Problem:** * How can we generate a Java method annotated with specific annotations using ChatGPT? **Solution:** * Use ChatGPT to generate a Java method annotated with the desired annotations. * This can be achieved by providing ChatGPT with the method name and the annotations as strings. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability. ## Case Study 7: Formatting and Compressing JSON String **Problem:** * How can we format and compress a JSON string using ChatGPT? **Solution:** * Use ChatGPT to generate a program that can handle this task. * This can be achieved by providing ChatGPT with the JSON string and the desired format and compression settings. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability. ## Case Study 8: JSON String to Java Bean Conversion **Problem:** * How can we convert a JSON string to a Java Bean using ChatGPT? **Solution:** * Use ChatGPT to generate a Java Bean class from the JSON string. * This can be achieved by providing ChatGPT with the JSON string and the Java Bean class template. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability. ## Case Study 9: Stream Analysis Error Log Analysis **Problem:** * How can we analyze error logs from a stream using ChatGPT? **Solution:** * Use ChatGPT to analyze the error logs and provide a detailed summary of the issues. * This can be achieved by providing ChatGPT with the error logs as a stream. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability. ## Case Study 10: Log Analysis and Troubleshooting **Problem:** * How can we analyze and troubleshoot log files using ChatGPT? **Solution:** * Use ChatGPT to analyze the log files and provide a detailed report of the issues. * This can be achieved by providing ChatGPT with the log files as a text or a URL. **Benefits:** * ChatGPT's ability to generate code can save developers time and effort. * This can lead to improved code quality and maintainability.

正文

本片内容是【AI思维空间】ChatGPT纵横编程世界,点亮智慧火花的续作,主要记录组内开发小伙伴儿们在开发过程中的实际应用案例,记录典型案例,尽量不要和其他人重复,以解决开发过程中的实际问题为主,设计、方案、编码、测试、集成、部署等等;

目的:贡献最佳实践,分享心得,共同成长!

Prompt提问万能公式

案例1 基于ChatGPT进行资源排期

1、首先进行拆分,分为周一到周五和周六周日

2、引导chatGPT进行排班

案例2 让chatGpt帮忙看下正则表达式的含义

在看代码的过程中,发现有个地方使用了正则表达式进行规则匹配,但是没有注释标明规则含义,所以使用chatGpt帮忙看下规则含义。

chatGpt不仅返回的了匹配的规则含义,还详细介绍了每个字符具体含义,very nice。

案例3 基于chatGpt写分段写入csv文件的程序

给chatgpt提要求,要求10000行数据放在一个csv文件中,并将文件名称进行编号处理。

变更条件,事先不知道总行数有多少条,让chatGpt重新写一段程序实现。

案例4:基于ChatGPT辅助开发

告诉ChatGPT,我想开发一个JavaBean转JSON的IDEA插件,让ChatGPT给出详细的步骤和代码。

案例5: 提问者需要具备鉴别能力

狼牙山五壮士的姓名

chatgpt可以一本正经的胡说八道,提问者不能全信。

案例6: spring ioc框架学习

太复杂了,尽然无法支持,就来一个简单的

再完善下,并帮忙写一个测试案例测试下看

亲自验证测试是否正确,能否跑起来

虽然能够跑起来,但是测试结果和其预期不一致,分析错误产生的原因是注解inject使用错误,正确使用时需要对注解添加元注解@Retention,其作用可以简单理解为设置注解的生命周期。

@Retention 注解传入的是 RetentionPolicy 枚举,该枚举有三个常量,分别是 SOURCE、CLASS 和 RUNTIME

三者区别如下:

SOURCE 代表着注解仅保留在源级别中,编译器将Java文件编译成class文件时将之遗弃。

CLASS 代表着注解被保留在class文件中,JVM加载class文件时将之遗弃。

RUNTIME 代表着标记的注解会由JVM保留,因此运行时环境可以使用它。

总结:chat-gpt对于技术细节可能无法把控,但是总体的程序框架及逻辑验证还是没有问题的。

案例7:字符处理、文本格式化

JOSN 串的格式化与压缩:

案例8:JSON串转JAVA Bean 集成lombok

提示词迭代过程如下:

以下Json串给生成 JAVA实体类,要求使用lombok 简化代码,并添加明确的代码注释,以Markdown语法出 {

“migrateTime”: 1689609010640, //迁移时间

“sourceProductId”: 1000000000, //迁移源productId

“targetProductIdAndSkuIdsMap”: {//迁移目标productId与skuId的关系

“2000000”: [//目标product1, skuIds

1,

2,

3

],

“3000000”: [//目标product2, skuIds

4,

5

]

}

“venderId”:100, //商家ID

“categoryId”:123 //三级类目ID

}

结果输出如下(对尾行注释并不满意,继续优化试试):

去除尾行注释输出结果:

案例9:JAVA8 流语法扁平化处理流

以下提示词目的是收集map的所有value里面对应的 long 类型的值集合。

提示词:在JAVA8 中如何通过流,将Map<Long, Set> targetProductIdAndSkuIdsMap 中的 value 收集到一个 set 集合里面,JAVA代码请以Markdown输出

结果输出如下: 在Java 8中,不能直接使用`flatmap`将集合的元素合并到一个集合中,因为`flatMap`操作是将多个流合并成一个流,而不是将元素合并到一个集合中。实际上,我们需要使用`flatMap`将每个集合的元素映射到单独的流,然后再使用`collect`操作将这些流合并到一个集合中。

以下是修正后的Java代码示例:

import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Map<Long, Set<Long>> targetProductIdAndSkuIdsMap = ...; // 初始化 targetProductIdAndSkuIdsMap

        Set<Long> skuIds = targetProductIdAndSkuIdsMap.values()
                .stream()
                .flatMap(Set::stream)
                .collect(Collectors.toSet());

        System.out.println(skuIds);
    }
}


这个代码可还行?_

案例10: 行云流水线错误日志分析

已落地平台,针对流水线运行错误日志,选中错误内容右键进行智能分析,输出分析结果,辅助解决错误问题,节省平台运营成本。

作者:京东零售 王英杰

来源:京东云开发者社区 转载请注明来源

与从好玩到好用:程序员用AI提效的那些事儿相似的内容:

从好玩到好用:程序员用AI提效的那些事儿

本片内容是【AI思维空间】ChatGPT纵横编程世界,点亮智慧火花的续作,主要记录组内开发小伙伴儿们在开发过程中的实际应用案例,记录典型案例,尽量不要和其他人重复,以解决开发过程中的实际问题为主,设计、方案、编码、测试、集成、部署等等; 目的:贡献最佳实践,分享心得,共同成长! Prompt提问万能

我在京东做研发 | 京东云算法科学家解析爆火的ChatGPT

令人惊艳的ChatGPT横空出世 背后有怎样的前沿技术支撑 走向大规模产品应用又有何局限 深耕对话式AI技术十余年 京东云算法科学家将带您一同走进技术世界 解析ChatGPT的技术亮点与局限 分享下一代对话式AI技术趋势 从好玩到好用 探讨对话式AI的落地实践

从k8s 的声明式API 到 GPT的 提示语

命令式命令式有时也称为指令式,命令式的场景下,计算机只会机械的完成指定的命令操作,执行的结果就取决于执行的命令是否正确。GPT 之前的人工智能就是这种典型的命令式,通过不断的炼丹,告诉计算机要怎么做,计算机只是机械的完成指定场景下的任务。声明式声明式也称为描述式或者申明式,这种方式告诉计算机想要的,

从图灵机到量子计算机,计算机可以解决所有问题吗?

本文已收录到 GitHub · AndroidFamily,有 Android 进阶知识体系,欢迎 Star。技术和职场问题,请关注公众号 [彭旭锐] 进 Android 面试交流群。 前言 大家好,我是小彭。 今天,我们正式开启一个新专栏 —— 计算机组成原理。 计算机组成原理是计算机科学中最基础

从零实现的Chrome扩展

# 从零实现的Chrome扩展 `Chrome`扩展是一种可以在`Chrome`浏览器中添加新功能和修改浏览器行为的软件程序,例如我们常用的`TamperMonkey`、`Proxy SwitchyOmega`、`AdGuard`等等,这些拓展都是可以通过`WebExtensions API`来修改

从kafka与Flink的事务原理来看二阶段提交与事务日志的结合使用

两阶段提交的成立要基于以下假设: - 该分布式系统中,存在一个节点作为协调者,其他节点作为参与者,且节点之间可以进行网络通信。 - 所有节点都采用预写式日志,且日志被写入后即被保存在可靠的存储设备上,即使节点损坏也不会导致日志数据的丢失。 - 所有节点不会永久性损坏,即使损坏后也可以恢复。 ###

从优秀源码中学到的两个技巧

设计一个不能被using的对象 在实际开发中为了避免命名空间污染,一般都不会using namespace std。但是如果一个对象写起来比较复杂,用using能大幅度地简化操作。现在假设我们要设计一个函数,它在一个作用域里面,使用它只能以A::B::C()这种形式。思考一下,如果我们放在命名空间下

从源码彻底理解 Prometheus/VictoriaMetrics 中的 relabel_configs/metric_relabel_configs 配置

背景 最近接手维护了公司的指标监控系统,之后踩到坑就没站起来过。。 本次问题的起因是我们配置了一些指标的删除策略没有生效: - action: drop_metrics regex: "^envoy_.*|^url\_\_\_\_.*|istio_request_bytes_sum" 与这两个容易引

从 Pulsar Client 的原理到它的监控面板

![image.png](https://s2.loli.net/2023/08/02/GipDPSlbycQxqFd.png) # 背景 前段时间业务团队偶尔会碰到一些 Pulsar 使用的问题,比如消息阻塞不消费了、生产者消息发送缓慢等各种问题。 虽然我们有个监控页面可以根据 topic 维度查

从 Uber 数据泄露事件我们可以学到什么?

Uber 数据泄露始于一名黑客从暗网市场购买属于一名 Uber 员工的被盗凭证。最初尝试使用这些凭据连接到 Uber 的网络失败,因为该帐户受 MFA 保护。为了克服这一安全障碍,黑客通过 What's App 联系了 Uber 员工,并假装是 Uber 的安全人员,要求该员工批准将 MFA 通知发