自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(89)
  • 收藏
  • 关注

原创 Springboot和Angular的CSRF防御

CSRF 是什么跨站请求伪造知乎解答搬运: csrf是什么.Springboot CSRFAngular CSRFAngular官方文档: cross-site-request-forgery.在跨站请求伪造(XSRF 或 CSFR)中,攻击者欺骗用户,让他们访问一个假冒页面(例如 evil.com), 该页面带有恶意代码,秘密的向你的应用程序服务器发送恶意请求(例如 example-bank.com)。假设用户已经在 example-bank.com 登录。用户打开一个邮件,点击里面的链接,

2021-09-07 20:58:25 1301 2

原创 Springboot实现多线程注入bean的工具类

场景: 使用springboot多线程,线程类无法自动注入需要的bean,解决方法: 通过工具类获取需要的bean工具类代码:import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContext;import org.springframework.con...

2018-12-10 14:17:47 2815

原创 CSDN-Markdown编辑器使用方法

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Ma...

2018-12-10 13:57:13 246

原创 罗马数字转阿拉伯数字

public class Main { public static void main(String[] args) { System.out.println("Hello World!"); } public static int transfer(String roma){ //建立一个符号与value对应的数组 int...

2018-10-16 12:03:58 285

原创 二叉树遍历(递归、BFS、DFS)

import java.util.LinkedList;import java.util.Queue;// 0// / \// 1 2// / \// 3 4public class maxDepth{ public static void main(String[] args){ ...

2018-09-05 21:20:52 646

原创 0-1背包问题

问题描述:现有n件物品和一个容量为c的背包。第i件物品的重量是重量为w[i],价值是v[i]。已知对于一件物品必须选择取(用1表示)或者不取(用0表示),且每件物品只能被取一次(这就是“0-1”的含义)。求放置哪些物品进背包,可使这些物品的重量总和不超过背包容量,且价值总和最大。求解思路:假设有5件物品,其重量分别是w={2,2,6,5,4},价值分别是v={6,3,5,4,6},背...

2018-08-29 13:43:38 245

原创 经典笔试题:小q的歌单(背包问题)

小Q有X首长度为A的不同的歌和Y首长度为B的不同的歌,现在小Q想用这些歌组成一个总长度正好为K的歌单,每首歌最多只能在歌单中出现一次,在不考虑歌单内歌曲的先后顺序的情况下,请问有多少种组成歌单的方法。 输入描述: 每个输入包含一个测试用例。 每个测试用例的第一行包含一个整数,表示歌单的总长度K(1<=K<=1000)。 接下来的一行包含四个正整数,分别表示歌的第一种长度A(A...

2018-08-29 13:02:56 394

原创 215. Kth Largest Element in an Array数组中的第K个最大元素

数组中的第K个最大元素 使用PriorityQueueimport java.util.PriorityQueue;class Solution { public int findKthLargest(int[] nums, int k) { PriorityQueue<Integer> queue = new PriorityQueue<&gt...

2018-08-28 21:50:53 167

原创 LeetCode23. 合并K个排序链表

合并K个排序链表 public static ListNode mergeKListNode(List<ListNode> list){ PriorityQueue<ListNode> queue = new PriorityQueue<>(Comparator.comparing(node -> node.val)); ...

2018-08-28 21:34:31 323

原创 Java多线程通信:交替打印ABAB

使用wait()和notify()实现Java多线程通信:两个线程交替打印A和B,如ABABABpublic class Test { public static void main(String[] args) { final PrintAB print = new PrintAB(); new Thread(new Runnable() { ...

2018-08-20 16:35:38 6491 1

原创 Mybatis基本使用

1 mysql数据库操作 SQL脚本:create database mybatis;use mybatis;CREATE TABLE tb_user ( ID INT(11) PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR (18) DEFAULT NULL, SEX CHAR (2) DEFAULT NULL, AGE INT(11)...

2018-07-25 11:12:59 264

原创 MySQL Java 编程Demo

import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class MysqlDemo { public static void main(Str...

2018-07-25 10:53:31 709

原创 MySQL安装

安装环境:windows7/10 安装方式:安装文件直接解压并配置环境变量 说明:以安装MySQL5.7做记录,因MySQL8以上版本编程使用稍有变化,如驱动等。1.1 下载下载地址:https://dev.mysql.com/downloads/mysql/ 默认版本为最新版本,通过图上箭头处更改版本,选择与系统对应的32或64位文件下载。 下载后解压到任意合适的位置。1...

2018-07-25 10:36:38 176

原创 Kafka官方教程(Kafka 1.1 Documentation)

KafkaQuickstart本教程假设你初次使用并且没有存在的Kafka和Zookeeper数据。由于Kafka控制台脚本对于基于Unix平台和windows平台是不同的,在windows平台上要用的 bin\windows* 替代 *bin/, 并且改变扩展名为 .bat.第一步: 下载源码下载1.1.0版本并解压。> tar -xzf kafka_2.11-1...

2018-06-01 16:36:37 1725

原创 apt-get 与 dpkg

apt-get 是从软件仓库中获取软件的一条命令。apt-get 之于 Ubuntu 操作系统,pip 之于 Python,加载第三方的软件(包)方式(在线下载安装托管在某一仓库中的文件)都是一致的。1. apt-get彻底删除sudo apt-get remove --purge **获取包的源码sudo apt-get source-f:–fix-broken更新源列表:s...

2018-05-21 16:46:11 2897

原创 排序算法模板(java)

1 快速排序public class Solution { public void sort(int[] nums){ if (nums == null || nums.length == 0) return; quickSort(nums, 0, nums.legnth-1) } private void quickSort(in...

2018-04-23 09:39:40 487

原创 242. Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false. Note: You may assume ...

2018-04-22 23:48:32 117

原创 162. Find Peak Element

A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that...

2018-04-21 23:17:08 151

原创 33. Search in Rotated Sorted Array

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). You are given a target value to search. If found ...

2018-04-21 22:24:57 549

原创 69. Sqrt(x)

Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer Since the return type is an integer, the decimal digits are truncated and only ...

2018-04-21 21:18:34 132

原创 74. Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each r...

2018-04-21 17:04:31 141

原创 240. Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted in ascending from left to right. Integers in ea...

2018-04-21 16:25:47 102

原创 153. Find Minimum in Rotated Sorted Array

Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. You may assume no duplicat...

2018-04-21 15:41:30 139

原创 189. Rotate Array

Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note: Try to come up as many solutions as you can,...

2018-04-21 13:39:15 118

原创 278. First Bad Version

第一个错误版本 思路:二分法 You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is devel...

2018-04-21 11:53:32 114

原创 226. Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1**反转二叉树 方法一**:引入一个队列进行层序遍历(leetcode时间超过20%的提交)/** * Definition ...

2018-04-13 20:43:51 105

原创 111. Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 题意:找出二叉树的最小深度。/** * Definition for a ...

2018-04-13 19:26:19 88

原创 104. Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example: Given binary tree [3,9,2...

2018-04-13 17:46:36 132

原创 617. Merge Two Binary Trees

Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tree...

2018-04-13 15:55:19 122

原创 669. Trim a Binary Search Tree

Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the re...

2018-04-13 15:49:33 131

原创 637 Average of Levels in Binary Tree

Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 7 Output: [3, 14.5, 11] Exp...

2018-04-13 15:43:52 133

原创 RYU REST API-编程示范

import urllib2 import json def get_all_switches(): url = "http://127.0.0.1:8080/v1.0/topology/switches" req = urllib2.Request(url) res_data = urllib2.urlopen(req) res = res_d

2018-01-03 17:21:31 847

原创 RYU REST API-基本概念

1. Rest API简介REST即表述性状态传递(RepreSentational State Transfer),是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性。表述性状态转移是一组构架约束条件和原则,满足这些约束和原则的应用程序或设计就是RESTful,REST是设计风格而不是标准,它通常基于使用HTTP,URI,XML以及HTML这些现有的广泛流行的协议和标准。

2018-01-03 10:33:38 2331

原创 RYU REST API-应用实践

1.启动Mininet创建并启动任意拓扑2.运行ryu程序,并加载ryu的restapi如: ryu-manager --verbose simple_switch_13.py ofctl_rest.py rest_topology.py3.命令行获取信息• 得到拓扑中的交换机信息 curl http://localhost:8080/stats/switches• 得到交换机的状态描述

2018-01-03 09:43:41 2741 4

原创 Python装饰器

知乎:如何理解Python装饰器?https://www.zhihu.com/question/26930016

2017-11-01 16:09:12 182

原创 Open vSwitch使用命令

Open vSwitch简介Open vSwitch是一款由Nicira Networks主导开发的虚拟交换机,可以在虚拟化平台上运行。并且,Open vSwitch采用与平台无关的C语言开发,充分考虑了不同平台之间的移植性。Open vSwitch运行在虚拟化平台上,可以为动态变化的端点提供二层交换功能,很好的控制虚拟网络中的访问策略、网络隔离、流量监控等。另外,Open vSwitch

2017-09-19 13:47:11 1514

原创 SDN测试工具-iperf、Cbench、sFlow(缺图)

1 iperf简介iperf是一款测试网络性能的工具,基于服务器和客户端模式,可以测试两个虚拟机之间的TCP和UDP带宽质量,提供网络延时抖动、数据包丢失等信息。安装步骤分别在两个虚拟机中安装iperf:sudo apt-get install iperf基本命令服务器端启动服务器端iperf:iperf -s /以服务器的形

2017-09-19 11:32:46 4995

原创 OpenFlow好文集锦-OpenFlow1.0协议解析

OpenFlow1.0协议解析控制器通过Openflow管理、控制交换机,分析wireshark抓到的OpenFlow包就可以大体推测控制器与交换机通信的流程。虽然没有进行任何操作,但是一旦交换机连接控制器,wireshark就能捕捉到很多OpenFlow包。依次是hello消息、feature消息,stats消息,以及packet_in和packet_out。1 Hello控

2017-09-19 11:12:30 1677

原创 RYU控制规则

本文所述的是规划转发路径最重要的部分,也就是控制规则。实现方式将通过一个例子来说明。首先,说明一下这个例子需求:Switch 中的主机可以在学习后,互相沟通主机脱离时,删除有关此主机的规则环境设备Switch:1 台Host:3 台连线情況Host 1 h1-eth0)---(s1-eth1 > SwitchHost 2 h

2017-08-28 16:14:39 3972 1

原创 448. Find All Numbers Disappeared in an Array(java)

Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Coul

2017-08-23 23:15:21 360

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除