收集、管理和分享有用的代码片段,提高开发效率
EXPLAIN查询计划
EXPLZ� SELECT * FROM users WHERE name = 'John Doe';
useState钩子
import React, { UseState } from 'react';
const Counter = () => {
const [count, setCount] = UseState(0);
return (
<div>
<button onClick={() => setCount(count + 1)}>
Click me ({count})
</button>
</div>
);
};
export default Counter;
Vue Router设置
import { createRouter, createWebHistory } from 'vue-router';
import Home from './Views/Home.vue';
import About from './Views/About.vue';
const routes = [
{ path: '/', component: Home },
{ path: '/about', component: About }
];
const router = createRouter(
{
history: createWebHistory(),
routes
}
);
export default router;
绘制热力图
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
data = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
sns.heatmap(data, annot=True, fmt="d")
plt.show()
基本安全配置
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests(antRequest()
.antRequests()
.permitAll()
.anyRequest())
.formLogin();
}
}
使用nlohmann/json
#include "nlohmann/json.hpp"
#include <iostream>
using namespace std;
using json = nlohmann::json;
int main() {
string jsonStr = "\n {\n \"name\": \"John\",\n \"age\": 30,\n \"city\": \"New York\"\n }\n";
auto j = json::parse(jsonStr);
cout << "Name: " << j["name"] << endl;
cout << "Age: " << j["age"] << endl;
cout << "City: " << j["city"] << endl;
return 0;
}
高效管理您的代码片段,提高开发效率
通过关键字、语言或分类快速查找代码片段,支持模糊搜索和过滤功能
支持多种编程语言的语法高亮,使代码更加清晰易读
随时随地访问您的代码片段库,支持桌面和移动设备
浏览最受欢迎的代码分类