总体思路

  1. 设计数据库
  2. 创建Entity
  3. 创建Mapper定义增删查改

“When in doubt go to the library.” – J.K.Rowling

Catalog

Article1: What Are You Going to Do With That?

What Are You Going to Do With That?

William Deresiewicz(《国家》杂志撰稿人和《新共和》杂志编辑)在斯坦福大学的演讲

The question my title poses, of course, is the one that is classically aimed at humanities majors. What practical value could there possibly be in studying literature or art or philosophy? So you must be wondering why I’m bothering to raise it here, at Stanford, this renowned citadel of science and technology. What doubt can there be that the world will offer you many opportunities to use your degree?

(学习文学、艺术或哲学能有什么用呢?所以你肯定纳闷,我为什么在在以科技堡垒而闻名的斯坦福提出这个问题呢?在大学学位给人带来众多机会的问题上还有什么可怀疑的吗?)

But that’s not the question I’m asking. By “do” I don’t mean a job, and by “that” I don’t mean your major. We are more than our jobs, and education is more than a major. Education is more than college, more even than the totality of your formal schooling, from kindergarten through graduate school. By “What are you going to do,” I mean, what kind of life are you going to lead? And by “that,” I mean everything in your training, formal and informal, that has brought you to be sitting here today, and everything you’re going to be doing for the rest of the time that you’re in school.

(但那不是我提出的问题。这里的“做”并不是指工作,“那”并不是指你的专业。我们不仅仅是要个工作,教育不仅仅是学一门专业。教育也不仅仅是上大学,甚至也不仅是从幼儿园到研究生院的正规学校教育。我说的“你要做什么”的意思是你要过什么样的生活?我所说的“那”指的是你得到的正规或非正规的任何训练, 那些把你送到这里来的东西,你在学校的剩余时间里将要做的任何事。)

阅读全文 »

1.0 第一件事git config

  • git config --list --show-origin查看所有git配置以及所在文件
  • 使用git config --global可以设置git的基本信息(如用户名、邮箱),使用--unset取消设置
    1. 配置你的名称、邮箱以及编辑器
git config --global user.name "191220000-Zhang San" 
# 全局设置名称
git config --global user.email "zhang3@email.com"
git config --global core.editor vim

2.0 初始化仓库

  1. 本地仓库:git init创建一个新的 git 仓库,其数据会存放在一个名为 .git 的目录下
    删除仓库:删除 .git 文件夹
git add <文件名字,*表示全部>
git commit -m 'initial project version'
# 提交到暂存区,并附上注释
  1. 远程仓库:git clone克隆远端仓库
git clone <网址> <仓库存放文件夹名>
# 使用http克隆
阅读全文 »

所有的Java云平台都能够使用基于JAR的打包方式,WAR文件只在一些云平台上能够运行。

Pom.xml 更换 Maven 源

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.springframework.quoters</groupId>
<artifactId>quoters-incorporated</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>quoters-incorporated</name>
<description>REST service to support the guides</description>

<developers>
<developer>
<id>gturnquist</id>
<name>Greg Turnquist</name>
<email>gturnquist at vmware.com</email>
<organization>VMware, Inc.</organization>
<roles>
<role>Project Lead</role>
</roles>
</developer>
</developers>

<organization>
<name>VMware, Inc.</name>
<url>https://spring.io</url>
</organization>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
<comments>
Copyright 2011 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the License for the specific language governing permissions and
limitations under the License.
</comments>
</license>
</licenses>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<!-- 配置阿里云仓库 -->
<repositories>
<repository>
<id>aliyun-repos</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-repos</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

Tight Coupling 紧耦合

在Spring框架以前,使用排序算法需要将算法实例化

public class ComplexBusinessService {
SortAlgorithm sortAlgorithm = new BubbleSortAlgorithm;
}
public class BubbleSortAlgorithm implements SortAlgorithm {...}

Good code has loose coupling.

移除依赖项的实例化可以移除紧耦合

public class ComplexBusinessService {
SortAlgorithm sortAlgorithm; // = new BubbleSortAlgorithm();

public ComplexBusinessService(SortAlgorithm sortAlgorithm) { // 创建构造函数
this.sortAlgorithm = sortAlgorithm;
}

public classBubbleSortAlgorithm implements SortAlgorithm {...}

Spring Framework instantiates objects and populates the dependencies.

阅读全文 »

Hash

字母异位词

排序每一个单词,就知道是不是异位词。

两数之和

从数组中,找到nums[i] + nums[j] == target,并返回{ i, j }
思路是双重循环,遍历每一个元素,求和是否为target。
然而,双重循环需要O(N2)O(N^2)的复杂度。因此,可以使用一张表,使用containsKey方法识别是否存在当前i的target - nums[i],即可减少一重循环。

关键思想

用Map高效率查找,减少一重循环。

最长连续序列

从乱序数组中,找到最长连续(数组中不一定连续)的序列。要求O(N)O(N)
首先用数组的值存入哈希表,然后遍历数组,判断map.constains(curNum++)
然而,即使这样还是效率不够高。

优化

  1. 中间值不进入循环,序列开始值才进入,使用!contains(curNum - 1)判断是否为序列开始值
  2. 去重,不要哈希表,不需要键值对,使用哈希Set,只存储值。

关键思想

去重;不处理中间值

阅读全文 »

一号标题

Title 2

三号标题

Title 4

五号标题
Title 6

标题 标题 标题
左对齐 两端对齐 右对齐
  • Unordered List
    • Unordered List
  1. Ordered List
    2. Ordered List
  • [x] TO-DO List
  • [] TO-DO List

Delete Line
Blod
Italic
Code
E=MC2E = MC^2
Link

[1]Hello, World!

public static void main(String[] args) {
System.out.println("Hello World!");
}
--- auto_detect: ture
+++ auto_detect: false

No Silver Bullet

By Brooks

[!NOTE]
Note that it is a note.

[!WARNING]
WARNING!

[!DANGER]
Notice the DANGER!

[!SUCCESS]
Now it is SUCCESS.

[!INFO]
Here is some INFO.

primary 提示块标签


  1. Hello World! ↩︎

策略模式

class MallardDuck extends Duck {
public MallardDuck() {
quackBehavior = new Quack();
flyBehavior = new FlyWithWings();
}
}

class ModelDuck extends Duck {
public ModelDuck() {
quackBehavior = new Quack();
flyBehavior = new FlyNoWay(); // 组合不同的方法
}
}

class Main {
public static void main(String[] args) {
Duck real = new MallardDuck();
Duck model = new ModelDuck();

real.fly();
model.fly(); // 调用同样的接口
}
}

识别应用中变化的方面,把它们和不变的方面分开。

针对接口编程,而不是针对实现编程。

// Implement
Dog d = new Dog();
d.bark();

// Interface
Animal dog = new Dog();
dog.makeSound(); // abstract

优先使用组合而不是继承。

summary

策略模式定义了算法族并分别封装。策略让算法变化独立于使用它的客户。

阅读全文 »

1.0 Bar 柱状图

from pyecharts.charts import Bar

bar = Bar()
bar.add_xaxis(["衬衣", "羊毛衫", "西装", "裤子", "鞋子", "袜子"])
bar.add_yaxis("商家", [5, 20, 40, 10, 70, 90])
# 相当于
bar = (
Bar()
.add_xaxis(["衬衣", "羊毛衫", "西装", "裤子", "鞋子", "袜子"])
.add_yaxis("商家", [5, 20, 40, 10, 70, 90])
.add_yaxis("商家B", [15, 6, 45, 20, 35, 66]) # 支持两个柱子同时生成
.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) # 生成标题
)


bar.render("bar.html") # 渲染为 bar.html,默认是 render.html
  • 效果
阅读全文 »

Author:aatalyk
Origin:Link

Before starting the topic let me introduce myself. I am a Mobile Developer currently working in Warsaw and spending my free time for interview preparations. I started to prepare for interviews two years ago. At that time I should say I could not solve the two sum problem. Easy problems seemed to me like hard ones so most of the time I had to look at editorials and discuss section. Currently, I have solved ~800 problems and time to time participate in contests. I usually solve 3 problems in a contest and sometimes 4 problems. Ok, lets come back to the topic.

Recently I have concentrated my attention on Dynamic Programming cause its one of the hardest topics in an interview prep. After solving ~140 problems in DP I have noticed that there are few patterns that can be found in different problems. So I did a research on that and find the following topics. I will not give complete ways how to solve problems but these patterns may be helpful in solving DP.

Patterns

  1. Minimum (Maximum) Path to Reach a Target
  2. Distinct Ways
  3. Merging Intervals
  4. DP on Strings
  5. Decision Making
阅读全文 »
0%