全栈工程师工作总结(二)

news2024/10/7 16:25:52

1. linux允许ROOT登录ftp

# 进入vsftpd目录
cd /etc/vsftpd

# 查看该目录包含的文件
ls

# 进入文件vsftpd.ftpusers,在root前加#注释root
vi  vsftpd.ftpusers

# 进入文件vsftpd.user_list,在root前加#注释root
vi vsftpd.user_list

2. 关于只能IP访问,域名不能访问网站的解决

我买的是腾讯云的服务器Cenos 6.5系统,自己配置的DNS域名服务器,nslookup www.xuefeng66.cn能够正常解析为115.159.201.119(若是非权威解析为该结果证明解析还存在问题,需要更改/etc/resolv.conf中的服务器地址,添加你买的域名服务器地址),解析成功后,发现通过IP可以访问,但是通过域名不能访问,终于发现时tomcat的问题

在这里插入图片描述

​​3. RSA简单加密与解密

import java.io.*;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;


public class RSADemo {
    /*
     * 产生秘钥
     */
    public static void generateKey() {
        try {
            // 指定算法
            KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
            // 确定密钥大小
            kpg.initialize(1024);
            // 产生密钥对
            KeyPair kp = kpg.genKeyPair();
            // 获取公钥
            PublicKey publicKey = kp.getPublic();
            // 获取私钥
            PrivateKey privateKey = kp.getPrivate();

            // 保存公钥
            FileOutputStream f1 = new FileOutputStream("publicKey.dat");
            ObjectOutputStream o1 = new ObjectOutputStream(f1);
            o1.writeObject(publicKey);
            o1.close();
            f1.close();

            // 保存私钥
            FileOutputStream f2 = new FileOutputStream("privateKey.dat");
            ObjectOutputStream o2 = new ObjectOutputStream(f2);
            o2.writeObject(privateKey);
            o2.close();
            f2.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*
     * 加密
     */
    public static void encrypt() {
        // 明文
        String s = "Hello World!";
        try {
            // 获取公钥及参数e,n
            FileInputStream f = new FileInputStream("publicKey.dat");
            ObjectInputStream oos = new ObjectInputStream(f);
            RSAPublicKey publicKey = (RSAPublicKey) oos.readObject();
            BigInteger e = publicKey.getPublicExponent();
            BigInteger n = publicKey.getModulus();
            System.out.println("参数e= " + e);
            System.out.println("参数n= " + n);

            // 获取明文
            byte[] content = s.getBytes("UTF-8");
            BigInteger m = new BigInteger(content);

            // 计算密文
            BigInteger c = m.modPow(e, n);
            System.out.println("密文为:" + c);

            // 保存密文
            String c1 = c.toString();
            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream("encrypt.dat")));
            out.write(c1, 0, c1.length());
            out.close();//一定要记得关闭,否则会出现空指针异常
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void decrypt() {
        try {
            // 读取密文
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    new FileInputStream("encrypt.dat")));
            String content = br.readLine();
            BigInteger c = new BigInteger(content);
            // 读取私钥
            FileInputStream f1 = new FileInputStream("privateKey.dat");
            ObjectInputStream o1 = new ObjectInputStream(f1);
            RSAPrivateKey privateKey = (RSAPrivateKey) o1.readObject();
            // 获取私钥参数及解密
            BigInteger d = privateKey.getPrivateExponent();
            BigInteger n = privateKey.getModulus();
            System.out.println("参数d=" + d);
            System.out.println("参数n=" + n);
            BigInteger m = c.modPow(d, n);

            // 显示解密结果
            byte[] mt = m.toByteArray();
            for (int i = 0; i < mt.length; i++) {
                System.out.print((char) mt[i]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try {
            generateKey();
            encrypt();
            decrypt();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

在这里插入图片描述

4. DES对称密码体系加密解密

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;


public class DESDemo {

    /*
     * 将字节数组转换为十六进制字符串
     */
    public static String byteToHexString(byte[] bytes) {
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < bytes.length; i++) {
            String string = Integer.toHexString(0XFF & bytes[i]);
            if (string.length() == 1) { // 十六进制占四个字节,
                stringBuffer.append(0);
            }
            stringBuffer.append(string.toUpperCase());
        }
        return stringBuffer.toString();
    }

    /*
     * 加密方法
     */
    public static byte[] DES_CBC_Encrypt(byte[] content, byte[] keyBytes) {
        try {
            // 创建一个 DESKeySpec 对象,使用 key 中的前 8 个字节作为 DES 密钥的密钥内容
            DESKeySpec keySpec = new DESKeySpec(keyBytes);
            // 返回转换指定算法的秘密密钥的 SecretKeyFactory 对象
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
            // 根据提供的密钥规范(密钥材料)生成 SecretKey 对象。
            SecretKey key = keyFactory.generateSecret(keySpec);

            // 返回实现指定转换的 Cipher 对象。
            Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            // 用密钥和一组算法参数初始化此 Cipher。
            cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(keySpec.getKey()));
            // 按单部分操作加密数据
            byte[] result = cipher.doFinal(content);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /*
     * 解密方法
     */
    public static byte[] DES_CBC_Decrypt(byte[] content, byte[] keyBytes) {
        try {
            DESKeySpec keySpec = new DESKeySpec(keyBytes);
            SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
            SecretKey key = keyFactory.generateSecret(keySpec);

            Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
            cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(keyBytes));
            byte[] result = cipher.doFinal(content);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


    public static void main(String[] args) {
        String content = "aaaaaaaabbbbbbbbaaaaaaaa";
        String key = "01234567";

        System.out.println("加密前:" + byteToHexString(content.getBytes()));
        byte[] encrypted = DES_CBC_Encrypt(content.getBytes(), key.getBytes());
        System.out.println("加密后:" + byteToHexString(encrypted));
        byte[] decrypted = DES_CBC_Decrypt(encrypted, key.getBytes());
        System.out.println("解密后:" + byteToHexString(decrypted));
    }
}

5. 基于TCP的客户端与服务器端之间的通信

使用说明:把服务器IP地址更改为自己的服务器主机IP地址即可

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;

import javax.swing.JFrame;

public class Chat extends JFrame implements Runnable, ActionListener {

	private Panel topPanel_1, downPanel_1, midPanel_left, midPanel_right;
	private Label ipLabel, localNameLabel;
	private TextField ipTextField, localNameField;
	private Button createServer, searchServer, sendMessage;
	private TextArea text1, text2, text3, text4;
	private ServerSocket server;
	private Socket serverSocket, clientSocket;
	private DataOutputStream outputFromClient, outputFromServer;
	private DataInputStream inputToClient, inputToServer;
	private int scan = 2;// scan:便于区分0客户端与1服务器端的文本内容
	private int lock=0;//0:创建服务器  1:停止服务器
	/***************************** 获取主机IP 与 名称 ******************************/
	public String getIp() {
		String ip = null;
		try {
			InetAddress myLocalHost = InetAddress.getLocalHost();
			ip = myLocalHost.getHostAddress();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return ip;
	}

	public String getName() {
		String name = null;
		try {
			InetAddress myLocalHost = InetAddress.getLocalHost();
			name = myLocalHost.getHostName();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return name;
	}

	/***************************** 事件监听 *****************************/
	public void message() {
		createServer.addActionListener(this);
		searchServer.addActionListener(this);
		sendMessage.addActionListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == createServer && lock==0) {
			text3.setText("");
			text3.append("服务器名称为:" + getName() + "\n");
			text3.append("服务器IP为:" + getIp() + "\n");
			text3.append("端口号为:6666\n");
			text3.append("服务器已经启动,正在监听.......\n");
			this.startServer();
			scan=1;
		} else if(e.getSource() == createServer && lock==1){
			try {
				serverSocket.close();
				text3.setText("");
				text3.append("服务器关闭成功");
				lock=0;
			} catch (IOException e1) {
				text3.append("服务器关闭异常");
				e1.printStackTrace();
			}			
		}else if (e.getSource() == searchServer) {
			text4.setText("");
			text4.append("正在搜索服务器,请稍等.....\n");
			this.startClient();
			scan=0;
		} else if (e.getSource() == sendMessage) {
			if (scan == 1) {// 服务器端
				try {
					outputFromServer = new DataOutputStream(
							serverSocket.getOutputStream());
					String name = getName();
					if (text2.getText().length() > 0) {
						text1.append(name + "说:   " + text2.getText()
								+ "\n");
						outputFromServer.writeUTF(this.getName()+","+text2.getText());// 写入消息
						text2.setText("");
					} else {
						text2.setText("\n\n请输入内容\n\n");
						Thread.sleep(1000);
						text2.setText("");
					}
				} catch (InterruptedException | IOException e1) {
					e1.printStackTrace();
				}
			} else if (scan == 0 ) {// 客户端
				try {
					outputFromClient = new DataOutputStream(
							clientSocket.getOutputStream());
					String name = getName();
					if (text2.getText().length() > 0 ) {
						text1.append(name + "说:   " + text2.getText()+ "\n");
						outputFromClient.writeUTF(this.getName()+","+text2.getText());// 写入消息
						text2.setText("");
					} else if(text2.getText().length() <= 0) {
						text2.setText("\n\n请输入内容\n\n");
						Thread.sleep(1000);
						text2.setText("");
					}
				} catch (InterruptedException | IOException e1) {
					e1.printStackTrace();
				}
			}
		}
	}

	/***************************** 启动服务器 *************************************/
	public void startServer() {
		try {
			if(lock==0){
				server = new ServerSocket(6666);
				serverSocket = server.accept();
				createServer.setLabel("停止服务器");
				lock=1;
			}
		} catch (IOException e) {
			text3.setText("");
			text3.append("服务器启动错误,请重新设置后启动!\n可能是由于:\n");
			text3.append("1.端口被占用。\n");
			text3.append("2.服务器已经启动。\n");
			e.printStackTrace();
		}
	}

	/***************************** 启动客户端 *************************************/
	public void startClient() {
		try {
			clientSocket = new Socket("192.168.31.125",6666);//更改为自己服务器主机的IP地址即可
			text4.append("连接成功 ");
			searchServer.setLabel("断开连接");
		} catch (Exception e) {
			text4.append("无法连接网络");
			e.printStackTrace();
		}
	}

	/******************************* 对话内容互相显示 *****************************/
	public void messageDisplay() throws IOException {
		// 接收消息
		if (scan == 1) {// 客户端
			inputToClient = new DataInputStream(serverSocket.getInputStream());
			String receive = inputToClient.readUTF();
			String[] message=receive.split(",");
			text1.append(message[0]+"说:   "+message[1]+"\n");
		}else if(scan == 0){//服务器端
			inputToServer = new DataInputStream(clientSocket.getInputStream());
			String receive = inputToServer.readUTF();
			String[] message=receive.split(",");
			text1.append(message[0]+"说:   "+message[1]+"\n");
		}
	}

	/***************************** 创建主界面 *************************************/
	private void launchFrame() {
		// /上面部分/
		topPanel_1 = new Panel();
		ipLabel = new Label("IP地址");// 标签
		ipTextField = new TextField(getIp(), 19);
		localNameLabel = new Label("本机名称");
		localNameField = new TextField(getName(), 19);
		createServer = new Button("创建服务器");
		searchServer = new Button("搜索服务器");

		// /中部部分/
		midPanel_left = new Panel();
		midPanel_right = new Panel();
		text1 = new TextArea(20, 68);
		text2 = new TextArea(3, 68);
		text3 = new TextArea(14, 25);
		text4 = new TextArea(9, 25);

		// /底部部分/
		downPanel_1 = new Panel();
		sendMessage = new Button("发送");

		topPanel_1.add(ipLabel);// 加入面板
		topPanel_1.add(ipTextField);
		topPanel_1.add(localNameLabel);
		topPanel_1.add(localNameField);
		topPanel_1.add(createServer);
		topPanel_1.add(searchServer);

		midPanel_left.setLayout(new BorderLayout());
		midPanel_right.setLayout(new BorderLayout());
		midPanel_left.add(text1, BorderLayout.NORTH);
		midPanel_left.add(text2, BorderLayout.SOUTH);
		midPanel_right.add(text3, BorderLayout.NORTH);
		midPanel_right.add(text4, BorderLayout.SOUTH);

		downPanel_1.add(sendMessage);

		Container container = getContentPane();// 布局管理器
		container.setLayout(new BorderLayout());// 布局声明
		container.add(topPanel_1, BorderLayout.NORTH);
		container.add(midPanel_left, BorderLayout.CENTER);
		container.add(midPanel_right, BorderLayout.EAST);
		container.add(downPanel_1, BorderLayout.SOUTH);
		this.pack();// 调整此窗口的大小,以适合其子组件的首选大小和布局。
		setSize(700, 500);// 设置面板宽与高
		setTitle("点星光聊天");// 设置标题
		setResizable(false);// 大小不可变
		setVisible(true);// 设置面板可见
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 关闭时释放资源
	}

	public static void main(String[] args) throws IOException {
		Chat chat = new Chat();
		chat.launchFrame();
		chat.message();
		while(true){
			chat.messageDisplay();
		}
	}

	@Override
	public void run() {
		// TODO 自动生成的方法存根

	}
}

6. 红蓝按钮交替移动

编写一个应用程序,除了主线程外,还有两个线程:first和second。first负责模拟一个红色的按钮从坐标(10,60)运动到(100,60);second负责模拟一个绿色的按钮从坐标(100,60)运动到(200,60)。另外还有一个start按钮,当点击start按钮后,红色按钮平行移动从左边移动到右边,当红色按钮移动到绿色按钮位置后,红色按钮停止在绿色按钮起始位置,然后绿色按钮接着移动。当绿色按钮移动到指定位置后,所有按钮位置重置,然后循环执行上述过程。

public class MoveButton extends JFrame implements Runnable, ActionListener {

    private int distance = 10;
    Thread first, second;
    Button redButton, greenButton, startButton;

    public MoveButton() {

        /*
         * 创建线程
         */
        first = new Thread(this);
        second = new Thread(this);
        setLayout(null); // 清除默认布局


        /*
         * 设置红色按钮的颜色
         * 设置起始位置与大小
         * 加入窗体
         */
        redButton = new Button();
        redButton.setBackground(Color.red);
        redButton.setBounds(10, 60, 15, 15);
        add(redButton);

        /*
         * 设置红色按钮的颜色
         * 设置起始位置与大小
         * 加入窗体
         */
        greenButton = new Button();
        greenButton.setBackground(Color.green);
        greenButton.setBounds(100, 60, 15, 15);
        add(greenButton);
        /*
         * 设置开始按钮的起始位置与大小
         * 添加监听器
         * 加入窗体
         */
        startButton = new Button("start");
        startButton.addActionListener(this);
        startButton.setBounds(10, 100, 30, 30);
        add(startButton);
        setBounds(0, 0, 300, 200);// 设置窗体的起始位置与长宽
        setVisible(true);// 设置窗体可见

        /*
         * 关闭窗时释放内存资源
         */
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    /*
     * 实现按钮的移动
     * synchronized 方法控制对类成员变量的访问
     */

    private synchronized void moveComponent(Button button) {
        if (Thread.currentThread() == first) {
            while (distance > 100 && distance <= 200) {
                try {
                    wait();
                    System.out.println("你好");//线程等待,直到其他线程调用notify或notifyAll方法通知该线程醒来
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            distance += 1;
            button.setLocation(distance, 60);
            if (distance >= 100) {
                if (distance <= 200) {
                    button.setLocation(100, 60);//在蓝色按钮运动期间红色按钮始终位于蓝色按钮最初位置
                } else {
                    button.setLocation(10, 60);//当距离移动距离大于200时,蓝色按钮归位
                }

                notify();//唤醒单个等待的线程(由于约束条件的存在,此程序中势必只有一个等待的线程,故可用此方法替换)
                //notifyAll();//唤起全部等地的线程
            }
        }

        if (Thread.currentThread() == second) {
            while (distance >= 10 && distance < 100) {
                try {
                    wait();//线程等待,直到其他线程调用notify或notifyAll方法通知该线程醒来
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            distance += 1;
            button.setLocation(distance, 60);
            if (distance > 200) {
                button.setLocation(100, 60);//当距离移动距离大于200时,蓝色按钮归位
                distance = 10;//distance置初值
                notify();//
            }
        }
    }


    public void run() {
        while (true) {
            /*
             * 判断当前执行的线程是否为first
             * 如果是,调用moveComponent()方法,移动redButton
             * 线程睡眠20ms
             */
            if (Thread.currentThread() == first) {
                moveComponent(redButton);
                try {
                    Thread.sleep(20);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            /*
             * 判断当前执行的线程是否为second
             * 如果是,调用moveComponent()方法,移动greenButton
             * 线程睡眠10ms
             */
            if (Thread.currentThread() == second) {
                moveComponent(greenButton);
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /*
     * 事件监听,启动线程(由于只对startButton按钮绑定监听器,所以默认监听该按钮)
     */
    public void actionPerformed(ActionEvent e) {
        try {
            first.start();//启动线程
            second.start();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new MoveButton();
    }
}

7. JAVA根据指定URL生成二维码

public class QrCodeUtil {
    public static void main(String[] args) {
        String url = "https://www.baidu.com";
        String path = FileSystemView.getFileSystemView().getHomeDirectory() + File.separator + "testQrcode";
        String fileName = "temp.jpg";
        createQrCode(url, path, fileName);
    }

    public static String createQrCode(String url, String path, String fileName) {
        try {
            Map<EncodeHintType, String> hints = new HashMap<>();
            hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
            BitMatrix bitMatrix = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, 400, 400, hints);
            File file = new File(path, fileName);
            if (file.exists() || ((file.getParentFile().exists() || file.getParentFile().mkdirs()) && file.createNewFile())) {
                writeToFile(bitMatrix, "jpg", file);
                System.out.println("搞定:" + file);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    static void writeToFile(BitMatrix matrix, String format, File file) throws IOException {
        BufferedImage image = toBufferedImage(matrix);
        if (!ImageIO.write(image, format, file)) {
            throw new IOException("Could not write an image of format " + format + " to " + file);
        }
    }

    static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException {
        BufferedImage image = toBufferedImage(matrix);
        if (!ImageIO.write(image, format, stream)) {
            throw new IOException("Could not write an image of format " + format);
        }
    }

    private static final int BLACK = 0xFF000000;
    private static final int WHITE = 0xFFFFFFFF;

    private static BufferedImage toBufferedImage(BitMatrix matrix) {
        int width = matrix.getWidth();
        int height = matrix.getHeight();
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y++) {
                image.setRGB(x, y, matrix.get(x, y) ? BLACK : WHITE);
            }
        }
        return image;
    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1849430.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

[图解]企业应用架构模式2024新译本讲解16-行数据入口2

1 00:00:00,750 --> 00:00:02,470 好&#xff0c;我们来看代码 2 00:00:03,430 --> 00:00:06,070 我们一步一步执行 3 00:00:42,500 --> 00:00:45,000 先初始化数据 4 00:00:52,300 --> 00:00:53,650 创建连接 5 00:00:55,900 --> 00:00:56,970 这里面 6 0…

计算机组成原理笔记-第4章 存储器

第4章 存储器 笔记PDF版本已上传至Github个人仓库&#xff1a;CourseNotes&#xff0c;欢迎fork和star&#xff0c;拥抱开源&#xff0c;一起完善。 该笔记是最初是没打算发网上的&#xff0c;所以很多地方都为了自我阅读方便&#xff0c;我理解了的地方就少有解释&#xff1b…

【ARM】MDK自动备份源文件

【更多软件使用问题请点击亿道电子官方网站】 1、 文档目标 解决MDK在编写文档的时候需要找回上一版代码的问题。 2、 问题场景 目前大部分情况下对于源代码的管理都是使用的Git等第三方的代码管理平台。这样的第三方代码管理平台都是针对与代码的版本更新进行管理。对于本地…

SwiftUI 6.0(iOS 18)ScrollView 全新的滚动位置(ScrollPosition)揭秘

概览 在只有方寸之间大小的手持设备上要想体面的向用户展示海量信息&#xff0c;滚动视图&#xff08;ScrollView&#xff09;无疑是绝佳的“东牀之选”。 在 SwiftUI 历史的长河中&#xff0c;总觉得苹果对于 ScrollView 视图功能的升级是在“挤牙膏”。这不&#xff0c;在本…

【图解IO与Netty系列】Netty源码解析——ChannelPipeline中的责任链模式

Netty源码解析——ChannelPipeline中的责任链模式 ChannelPipeline的作用ChannelPipeline的设计ChannelPipeline源码解析 ChannelPipeline的作用 ChannelPipeline在Netty中的作用&#xff0c;主要是在有事件就绪时&#xff0c;用于处理就绪事件的。我们知道真正处理就绪事件的…

力扣SQL50 每月交易 I 求和 SUM(条件表达式) DATE_FORMAT(日期,指定日期格式)

Problem: 1193. 每月交易 I &#x1f468;‍&#x1f3eb; 参考题解 Code select DATE_FORMAT(trans_date, %Y-%m) AS month,country,count(*) as trans_count,count(if(state approved, 1, NULL)) as approved_count,sum(amount) as trans_total_amount,sum(if(state appr…

5.3 Python len()函数:获取字符串长度或字节数

Python len()函数详解&#xff1a;获取字符串长度或字节数 Python 中&#xff0c;要想知道一个字符串有多少个字符&#xff08;获得字符串长度&#xff09;&#xff0c;或者一个字符串占用多少个字节&#xff0c;可以使用 len 函数。 len 函数的基本语法格式为&#xff1a; …

性能工具之 MySQL OLTP Sysbench BenchMark 测试示例

文章目录 一、前言二、测试环境1、服务器配置2、测试拓扑 三、测试工具安装四、测试步骤1、导入数据2、压测数据3、清理数据 五、结果解析六、最后 一、前言 做为一名性能工程师掌握对 MySQL 的性能测试是非常必要的&#xff0c;本文基于 Sysbench 对MySQL OLTP&#xff08;联…

YOLOv8中的C2f模块

文章目录 一、结构概述二、模块功能 一、结构概述 C2f块:首先由一个卷积块(Conv)组成&#xff0c;该卷积块接收输入特征图并生成中间特征图特征图拆分:生成的中间特征图被拆分成两部分&#xff0c;一部分直接传递到最终的Concat块&#xff0c;另一部分传递到多个Botleneck块进…

uniapp(全端兼容) - 最新详细实现刻度尺组件效果,uni-app实现尺子打分及手指拖动刻度尺打分评分功能,可左右滑动刻度尺改变数值、带刻度尺滑块功能、

效果图 在uniapp微信小程序/手机h5网页网站/安卓app/苹果app/支付宝小程序/nvue等(全平台完美兼容)开发中,实现uniApp各端都兼容的 “刻度尺(横格尺 | 尺子)” 手势左右两侧拖动、手指滑动刻度尺功能,水平刻度尺,支持自定义尺子颜色、大小、刻度、滑动时的步进值、最大…

【Java】已解决java.net.ConnectException异常

文章目录 一、分析问题背景二、可能出错的原因三、错误代码示例四、正确代码示例五、注意事项 已解决java.net.ConnectException异常 在Java的网络编程中&#xff0c;java.net.ConnectException是一个常见的异常&#xff0c;它通常表明在尝试建立网络连接时出现了问题。本文将…

“循环购“:快消品行业的创新商业模式引领者

大家好&#xff0c;我是吴军&#xff0c;来自一家在软件开发与商业模式创新领域享有盛誉的公司。我们专注于为企业提供全方位的商城系统搭建及商业模式定制服务。迄今为止&#xff0c;我们已经成功地为众多企业打造了超过200种独特的商业模式&#xff0c;助力他们实现了显著的商…

如何跳出认知偏差,个人认知能力升级

一、教程描述 什么是认知力&#xff1f;认知力&#xff08;cognitive ability&#xff09;&#xff0c;实际上就是指一个人的认知能力&#xff0c;是指人的大脑加工、储存和提取信息的能力&#xff0c;或者主观对非主观的事物的反映能力&#xff0c;如果变成大白话&#xff0c…

Dev Eco Studio设置中文界面

Settings-Plugins-installed-搜索Chinese

WindTerm软件的本地模式和远程模式

WindTerm作为一个多功能的远程终端控制软件&#xff0c;支持本地模式和远程模式两种键盘输入处理方式&#xff0c;这两种模式的主要区别在于键盘输入的处理逻辑和目标&#xff1a; 本地模式&#xff08;Local Mode&#xff09; 在本地模式下&#xff0c;WindTerm不对键盘输入…

Android设计模式系列--模板方法模式

认识到模板方法的这种思想&#xff0c;父类可以让未知的子类去做它本身可能完成的不好或者根本完成不了的事情&#xff0c;对框架学习大有帮助。 本文以View中的draw方法为例&#xff0c;展开分析。 模板方法&#xff0c;TemplateMethod&#xff0c;光是学习这个模式&#xf…

Flutter第十二弹 Flutter多平台运行

目标&#xff1a; 1.在多平台调试启动Flutter程序运行 一、安卓模拟器 1.1 检查当前Flutter适配的版本 flutter doctor提供了Flutter诊断。 $ flutter doctor --verbose /Users/zhouronghua/IDES/flutter/bin/flutter doctor --verbose [✓] Flutter (Channel master, 2.1…

npm 安装踩坑

1 网络正常&#xff0c;但是以前的老项目安装依赖一直卡住无法安装&#xff1f;哪怕切换成淘宝镜像 解决办法&#xff1a;切换成yarn (1) npm i yarn -g(2) yarn init(3) yarn install在安装的过程中发现&#xff1a; [2/4] Fetching packages... error marked11.1.0:…

2025届阳光保险集团应届生校招社招入职测评真题题库北森自适应测评题库

第1题 人类使用塑料袋的历史很短&#xff0c;但对塑料袋的指责却不绝于耳。全世界每年要消耗5000亿到1万亿个塑料袋。废弃的塑料袋被掩埋会影响农作物吸收营养和水分&#xff0c;污染地下水;焚烧塑料袋则会产生有毒气体&#xff0c;影响人体健康。因此如何处理塑料袋十分重要。…

电路仿真实战设计教程--平均电流控制原理与仿真实战教程

1.平均电流控制原理: 平均电流控制的方块图如下,其由外电路电压误差放大器作电压调整器产生电感电流命令信号,再利用电感电流与电流信号的误差经过一个电流误差放大器产生PWM所需的控制电压,最后由控制电压与三角波比较生成开关管的驱动信号。 2.电流环设计: 根据状态平…