Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1cdc78e
add 算法和数据结构
Sep 5, 2018
8156c42
add
Sep 5, 2018
d38ec3f
Merge pull request #400 from zhaozhengcoder/master
CyC2018 Sep 5, 2018
5fe72c3
Update README.md
CyC2018 Sep 5, 2018
9aebc46
单例模式添加枚举实现
peiel Sep 5, 2018
a015b11
auto commit
CyC2018 Sep 5, 2018
4fa8a6b
Update and rename notes/计算机操作系统.md to notes/计算机操作系统.md
yugandharbandi Sep 5, 2018
4ee1497
Update 计算机操作系统.md
yugandharbandi Sep 5, 2018
59fda4c
Update 计算机操作系统.md
haonanya1 Sep 6, 2018
6e61d32
the difference of new and malloc
Sep 6, 2018
dba7855
Merge pull request #405 from 1980744819/master
CyC2018 Sep 6, 2018
990efe2
Merge pull request #404 from duang123/patch-1
CyC2018 Sep 6, 2018
4ad7755
Merge pull request #401 from peierlong/master
CyC2018 Sep 6, 2018
ed2a71f
Merge pull request #403 from yugandharbandi/master
CyC2018 Sep 6, 2018
1365bc4
auto commit
CyC2018 Sep 6, 2018
cb1f030
Merge branch 'master' of https://github.com/CyC2018/Interview-Notebook
CyC2018 Sep 6, 2018
3c08c15
auto commit
CyC2018 Sep 6, 2018
bd7d42b
修复代码运行报错
peiel Sep 6, 2018
f439ed1
Merge branch 'master' into master
CyC2018 Sep 6, 2018
8674be4
Merge pull request #407 from peierlong/master
CyC2018 Sep 6, 2018
941f8e3
auto commit
CyC2018 Sep 6, 2018
f82b21b
remove submodule
CyC2018 Sep 6, 2018
7324207
auto commit
CyC2018 Sep 7, 2018
187f0bd
auto commit
CyC2018 Sep 7, 2018
24c4864
Update 设计模式.md
peiel Sep 7, 2018
e69d324
Merge pull request #408 from peierlong/patch-5
CyC2018 Sep 7, 2018
0fbafac
auto commit
CyC2018 Sep 7, 2018
0b5be89
fix: fix several typos in 'Java 容器.md'
fractalists Sep 7, 2018
f6e6808
auto commit
CyC2018 Sep 7, 2018
cedbf9f
Merge branch 'master' of https://github.com/CyC2018/InterviewNotes
CyC2018 Sep 7, 2018
22e77f0
Merge pull request #409 from JacobChengZhang/master
CyC2018 Sep 7, 2018
90440d8
auto commit
CyC2018 Sep 8, 2018
8a9b8b1
Merge branch 'master' of https://github.com/CyC2018/Interview-Notebook
CyC2018 Sep 8, 2018
5c5c056
Update Java 基础.md
blueblueblueblueblueblue Sep 10, 2018
59ca4ee
Merge pull request #412 from blueblueblueblueblueblue/patch-1
CyC2018 Sep 10, 2018
e697abd
auto commit
CyC2018 Sep 10, 2018
3c6be1a
auto commit
CyC2018 Sep 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<a href="other/Group.md"> <img src="https://img.shields.io/badge/>-group-4ab8a1.svg"></a> <a href="https://legacy.gitbook.com/book/cyc2018/interview-notebook/details"> <img src="https://img.shields.io/badge/_-gitbook-4ab8a1.svg"></a>
</div>

<!-- [![](https://img.shields.io/badge/>-gitter-blue.svg)](https://gitter.im/CyC2018-Interview-Notebook/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link) [![](https://img.shields.io/badge/_-gitbook-4ab8a1.svg)](https://legacy.gitbook.com/book/cyc2018/interview-notebook/details) -->

### :pencil2: 算法

- [剑指 Offer 题解](https://github.com/CyC2018/InnterviewNotes/blob/master/notes/剑指%20offer%20题解.md)
Expand Down
19 changes: 6 additions & 13 deletions notes/HTTP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
* [实体首部字段](#实体首部字段)
* [五、具体应用](#五具体应用)
* [Cookie](#cookie)
* [6. Secure](#6-secure)
* [缓存](#缓存)
* [连接管理](#连接管理)
* [内容协商](#内容协商)
Expand All @@ -40,7 +39,6 @@
* [认证](#认证)
* [完整性保护](#完整性保护)
* [HTTPs 的缺点](#https-的缺点)
* [配置 HTTPs](#配置-https)
* [七、HTTP/2.0](#七http20)
* [HTTP/1.x 缺陷](#http1x-缺陷)
* [二进制分帧层](#二进制分帧层)
Expand Down Expand Up @@ -369,19 +367,19 @@ document.cookie = "tasty_cookie=strawberry";
console.log(document.cookie);
```

### 6. HttpOnly
### 6. HttpOnly

标记为 HttpOnly 的 Cookie 不能被 JavaScript 脚本调用。跨站脚本攻击 (XSS) 常常使用 JavaScript 的 `Document.cookie` API 窃取用户的 Cookie 信息,因此使用 HttpOnly 标记可以在一定程度上避免 XSS 攻击。

```html
Set-Cookie: id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT; Secure; HttpOnly
```

## 6. Secure
### 7. Secure

标记为 Secure 的 Cookie 只能通过被 HTTPS 协议加密过的请求发送给服务端。但即便设置了 Secure 标记,敏感信息也不应该通过 Cookie 传输,因为 Cookie 有其固有的不安全性,Secure 标记也无法提供确实的安全保障。

### 7. Session
### 8. Session

除了可以将用户信息通过 Cookie 存储在用户浏览器中,也可以利用 Session 存储在服务器端,存储在服务器端的信息更加安全。

Expand All @@ -396,11 +394,11 @@ Session 可以存储在服务器上的文件、数据库或者内存中。也可

应该注意 Session ID 的安全性问题,不能让它被恶意攻击者轻易获取,那么就不能产生一个容易被猜到的 Session ID 值。此外,还需要经常重新生成 Session ID。在对安全性要求极高的场景下,例如转账等操作,除了使用 Session 管理用户状态之外,还需要对用户进行重新验证,比如重新输入密码,或者使用短信验证码等方式。

### 8. 浏览器禁用 Cookie
### 9. 浏览器禁用 Cookie

此时无法使用 Cookie 来保存用户信息,只能使用 Session。除此之外,不能再将 Session ID 存放到 Cookie 中,而是使用 URL 重写技术,将 Session ID 作为 URL 的参数进行传递。

### 9. Cookie 与 Session 选择
### 10. Cookie 与 Session 选择

- Cookie 只能存储 ASCII 码字符串,而 Session 则可以存取任何类型的数据,因此在考虑数据复杂性时首选 Session;
- Cookie 存储在浏览器中,容易被恶意查看。如果非要将一些隐私数据存在 Cookie 中,可以将 Cookie 值进行加密,然后在服务器进行解密;
Expand Down Expand Up @@ -720,11 +718,6 @@ HTTPs 的报文摘要功能之所以安全,是因为它结合了加密和认

- 因为需要进行加密解密等过程,因此速度会更慢;
- 需要支付证书授权的高额费用。

## 配置 HTTPs

[Nginx 配置 HTTPS 服务器](https://aotu.io/notes/2016/08/16/nginx-https/index.html)

# 七、HTTP/2.0

## HTTP/1.x 缺陷
Expand Down Expand Up @@ -849,7 +842,7 @@ DELETE /idX/delete HTTP/1.1 -> Returns 404

# 九、HTTP/1.0 与 HTTP/1.1 的区别

> 详细内容请见上文
详细内容请见上文

- HTTP/1.1 默认是长连接

Expand Down
10 changes: 7 additions & 3 deletions notes/Java IO.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,17 @@ public static void listAllFiles(File dir) {

```java
public static void copyFile(String src, String dist) throws IOException {

FileInputStream in = new FileInputStream(src);
FileOutputStream out = new FileOutputStream(dist);

byte[] buffer = new byte[20 * 1024];
int cnt;

// read() 最多读取 buffer.length 个字节
// 返回的是实际读取的个数
// 返回 -1 的时候表示读到 eof,即文件尾
while (in.read(buffer, 0, buffer.length) != -1) {
out.write(buffer);
while ((cnt = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, cnt);
}

in.close();
Expand Down Expand Up @@ -182,8 +183,10 @@ public static void readFileContent(String filePath) throws IOException {

```java
public static void main(String[] args) throws IOException, ClassNotFoundException {

A a1 = new A(123, "abc");
String objectFile = "file/a1";

ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(objectFile));
objectOutputStream.writeObject(a1);
objectOutputStream.close();
Expand All @@ -195,6 +198,7 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio
}

private static class A implements Serializable {

private int x;
private String y;

Expand Down
17 changes: 9 additions & 8 deletions notes/Java 基础.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ String 不可变性天生具备线程安全,可以在多个线程中安全地

## String Pool

字符串常量池(String Poll)保存着所有字符串字面量(literal strings),这些字面量在编译时期就确定。不仅如此,还可以使用 String 的 intern() 方法在运行过程中将字符串添加到 String Poll 中。
字符串常量池(String Pool)保存着所有字符串字面量(literal strings),这些字面量在编译时期就确定。不仅如此,还可以使用 String 的 intern() 方法在运行过程中将字符串添加到 String Pool 中。

当一个字符串调用 intern() 方法时,如果 String Poll 中已经存在一个字符串和该字符串值相等(使用 equals() 方法进行确定),那么就会返回 String Poll 中字符串的引用;否则,就会在 String Poll 中添加一个新的字符串,并返回这个新字符串的引用。
当一个字符串调用 intern() 方法时,如果 String Pool 中已经存在一个字符串和该字符串值相等(使用 equals() 方法进行确定),那么就会返回 String Pool 中字符串的引用;否则,就会在 String Pool 中添加一个新的字符串,并返回这个新字符串的引用。

下面示例中,s1 和 s2 采用 new String() 的方式新建了两个不同字符串,而 s3 和 s4 是通过 s1.intern() 方法取得一个字符串引用。intern() 首先把 s1 引用的字符串放到 String Pool 中,然后返回这个字符串引用。因此 s3 和 s4 引用的是同一个字符串。

Expand All @@ -219,7 +219,7 @@ String s6 = "bbb";
System.out.println(s4 == s5); // true
```

在 Java 7 之前,String Poll 被放在运行时常量池中,它属于永久代。而在 Java 7,String Poll 被移到堆中。这是因为永久代的空间有限,在大量使用字符串的场景下会导致 OutOfMemoryError 错误。
在 Java 7 之前,String Pool 被放在运行时常量池中,它属于永久代。而在 Java 7,String Pool 被移到堆中。这是因为永久代的空间有限,在大量使用字符串的场景下会导致 OutOfMemoryError 错误。

- [StackOverflow : What is String interning?](https://stackoverflow.com/questions/10578984/what-is-string-interning)
- [深入解析 String#intern](https://tech.meituan.com/in_depth_understanding_string_intern.html)
Expand Down Expand Up @@ -685,34 +685,34 @@ protected void finalize() throws Throwable {}

**1. 等价关系**

(一)自反性
自反性

```java
x.equals(x); // true
```

(二)对称性
对称性

```java
x.equals(y) == y.equals(x); // true
```

(三)传递性
传递性

```java
if (x.equals(y) && y.equals(z))
x.equals(z); // true;
```

(四)一致性
一致性

多次调用 equals() 方法结果不变

```java
x.equals(y) == x.equals(y); // true
```

(五)与 null 的比较
与 null 的比较

对任何不是 null 的对象 x 调用 x.equals(null) 结果都为 false

Expand Down Expand Up @@ -741,6 +741,7 @@ System.out.println(x == y); // false

```java
public class EqualExample {

private int x;
private int y;
private int z;
Expand Down
6 changes: 3 additions & 3 deletions notes/Java 容器.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* [HashMap](#hashmap)
* [ConcurrentHashMap](#concurrenthashmap)
* [LinkedHashMap](#linkedhashmap)
* [WeekHashMap](#weekhashmap)
* [WeakHashMap](#weakhashmap)
* [附录](#附录)
* [参考资料](#参考资料)
<!-- GFM-TOC -->
Expand Down Expand Up @@ -974,7 +974,7 @@ void afterNodeAccess(Node<K,V> e) { // move node to last

### afterNodeInsertion()

在 put 等操作之后执行,当 removeEldestEntry() 方法返回 ture 时会移除最晚的节点,也就是链表首部节点 first。
在 put 等操作之后执行,当 removeEldestEntry() 方法返回 true 时会移除最晚的节点,也就是链表首部节点 first。

evict 只有在构建 Map 的时候才为 false,在这里为 true。

Expand Down Expand Up @@ -1034,7 +1034,7 @@ public static void main(String[] args) {
[3, 1, 4]
```

## WeekHashMap
## WeakHashMap

### 存储结构

Expand Down
Loading