diff --git a/Coding language/C/Basic_C_note.html b/Coding language/C/Basic_C_note.html new file mode 100755 index 0000000..6d1cfa3 --- /dev/null +++ b/Coding language/C/Basic_C_note.html @@ -0,0 +1,564 @@ + + + + + + + + + + + + Basic C note — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+

Basic C note

+ +
+ +
+
+ + + + +
+ +
+

Basic C note#

+
+

一、 文本显示#

+
    +
  • printf用于输出文字

  • +
+
#include <stdio.h>
+int main()
+{
+    printf("我是小仙女,\n我长得很漂亮。\n");
+    return 0;
+}
+
+
+
+
+

二、数据类型#

+
//standard io标准流输出
+#include <studio.h>
+int main()
+{
+	//char 字符类型,主要用来显示给人看
+   //int 整型, 整数型数字, 可以用来计算。
+   printf("hello\n");
+   printf("%d\n",1);
+   printf("%d大于%d",2,1); //2替换第一个%d,1替换第二个%d
+}
+
+
+
    +
  • 要显示字符型,我们只要直接写在两个引号里就可以了,写了什么就显示什么。

  • +
  • +
+
+
+

三、变量存储#

+
#include <stdio.h>
+int main()
+{
+    int weight; //定义一个变量weight
+    weight = 170; //给weight赋值为170
+    printf("%d\n",weight); //显示weight的值。
+    weight = weight+10;
+    printf("%d\n",weight);
+}
+
+
+
+1_memory +
+

Fig. 5 内存#

+
+
+
+2_variable +
+

Fig. 6 变量#

+
+
+
+3_pointer +
+

Fig. 7 指针#

+
+
+
+
+ + + + +
+ + + + + + +
+ + + +
+ + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Coding language/JAVA/Java.html b/Coding language/JAVA/Java.html new file mode 100755 index 0000000..1eed66e --- /dev/null +++ b/Coding language/JAVA/Java.html @@ -0,0 +1,618 @@ + + + + + + + + + + + + 关于Java类中数组对象创建的疑问 — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+

关于Java类中数组对象创建的疑问

+ +
+
+ +
+
+
+ + + + +
+ +
+
+

关于Java类中数组对象创建的疑问#

+
public class Mix4{
+  int counter = 0;
+  public static void main(String[] args){
+    int count = 0;
+    Mix4 [] m4a = new Mix4[20];
+    int x = 0;
+    while(x<9){
+      m4a[x] = new Mix4();
+      m4a[x].counter = m4a[x].counter + 1;
+      count = count + 1;
+      count = count + m4a[x].maybeNew(x);
+      x = x + 1;
+    }
+  System.out.println(count+" "+m4a[1].counter);
+  }
+  
+  public int maybeNew(int index){
+      if(index<5){
+        Mix4 m4 = new Mix4();
+        m4.counter = m4.counter + 1;
+        return 1;
+      }
+      return 0;
+    }
+
+}
+
+
+

这是Head First Java 中的一个习题, 在解答的过程中发现自己不了解以下几个知识点:

+
    +
  • 类实例变量的初始化

  • +
  • 数组对象的创建

  • +
+

对于第一个问题,类实例变量的初始化,在可视化的过程中我有了新的理解,先放上整个过程的结果。 +代码执行的图示

+

下面写下我在执行这个程序中遇到并解决的一些问题

+
    +
  1. 程序是从main()开始的 +(这点我之前一直默认自己知道,但是程序真正执行起来,才发觉自己对这点的疏忽,还是需要谦虚些,默认自己什么都不知道,每个点都要踏踏实实扣下去) +在这里插入图片描述

  2. +
  3. 数组是一个对象, 无论被声明来承载的是primitive主类型数据或对象引用,数组永远是对象。 +数组对象可以有primitive主数据类型的元素,但数组本身绝对不会是primitive主数据类型, 不管数组带有什么, 它一定是对象。

  4. +
+

这句话的理解,在我看来可以这样解释: +在这里插入图片描述

+
Mix4 [] m4a = new Mix4[20];
+
+
+

这段程序可以分为三部分

+
    +
  1. 对象的声明

  2. +
  3. 对象的创建

  4. +
  5. 赋值

  6. +
+
    +
  • 对象的声明

  • +
+
Mix4[] m4a
+
+
+

声明了一个类型为Mix4[]的数组变量, 它的名称是m4a.

+

这里补充一下,java注重类型, 声明变量必须有类型和名称(variables must have a type, variables must have a name)

+

to be continued….

+
    +
  • 对象的创建

  • +
+
new Mix4[20]
+
+
+

创建大小为20的数组(这有着20个存储空间整体,为一个Mix4数组对象) +而这20个存储空间可以用来存储类型为Mix4的对象

+

这里只保存着Mix4的引用 +相当于只声明了对象,没有创建实际的Mix4对象。

+
+

可以这么理解

+
+
Mix4 m4a[0];
+
+
+
+

数组中第一个索引里存放的是Mix4的引用
+要创建Mix4对象的话 还要

+
+
m4a[0] = new Mix4();
+
+
+
    +
  • 赋值 +连接对象和引用, 将Mix4[20]这个大小为20的数组,赋值给之前声明为Mix4[]的数组变量m4a.

  • +
+

在这里插入图片描述 +从上图中, 我们看到m4a这个数组变量,相当于一个遥控器,它指向了数组对象(也就是Mix4[20]),这个数组变量也称引用变量。

+

我们可以把变量看做杯子,变量用来装东西,也就是往杯子中装东西。 +比如:

+
bype x = 7;
+
+
+

就是代表数值7的字节(00000111)被放进变量中。

+

只不过这个引用变量装的东西比较特别,它放的东西代表取得Mix4[20]对象的方法以字节形式放进变量中,也就相当于一个遥控器, 这个引用变量可以通过 圆点“.”运算符来引用对象的方法和实例变量。

+

在数组中,对数组的操作可以不需要变量名称。只需要数组索引(位置)就可以操作特定对象:

+
Mix4 [] m4a = new Mix4[20];
+m4a[0] = new Mix4();
+m4a[0].counter = m4a[0].counter + 1;
+
+
+

这段代码代表了程序第一次执行while循环时,x=0情况下,Mix4数组变量m4a[0]对Mix4对象的操作。 +在这里插入图片描述 +注意: +Mix4[20]数组中存放的仅仅是对Mix对象的引用, 还需要创建实际的Mix对象

+
new Mix4()
+
+
+

,并把它赋值给数组的元素

+
m4a[0] = new Mix4()
+
+
+

我理解错误的点主要在于对类实例变量的理解。 +我把实例变量counter看做每个对象都可以进行修改的值,错误的把counter进行了累加。

+

实际上,每个类是对象的蓝图。 创建一个对象就是对类的实例化。 这个对象会有自己的实例变量和方法。

+

对象本身一致的事物被称为:实例变量(instance variable) +对象可以执行的动作称为:方法(methods) +在这里插入图片描述 +可以看到程序进行到第8行时,new Mix4()创建了一个Mix4类型的对象, 它执行了两次初始化<init:2>, 并且这个对象根据Mix4这个类的蓝图, 初始化了自己的实例变量counter = 0.

+

之后将这个初始化了的对象赋值给了引用变量m4a[0] +在这里插入图片描述

+

所以每一个数组引用变量都会有一个Mix4对象, 这些对象虽然是同一个类, 但每个都有自己独立的实例变量, 也就是counter. 而这个counter在创建对象时都会被赋值为0.

+

在这里插入图片描述

+
Mix4 [] m4a = new Mix4[20];
+m4a[x] = new Mix4();
+m4a[x].counter = m4a[x].counter + 1;
+
+
+

现在重看这行代码, 你是否能有新的理解呢

+
+

如有错误地方,请大家指正。 +共同学习,共同进步,期待大家的issue~

+
+ + + + +
+ + + + + + +
+ + + + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Coding language/JAVA/Java_Design_pattern.html b/Coding language/JAVA/Java_Design_pattern.html new file mode 100755 index 0000000..bdc71b0 --- /dev/null +++ b/Coding language/JAVA/Java_Design_pattern.html @@ -0,0 +1,510 @@ + + + + + + + + + + + + Java Design Pattern — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+

Java Design Pattern

+ +
+
+ +
+

Contents

+
+ +
+
+
+ + + + +
+ +
+

Java Design Pattern#

+
+

To be continue…#

+

单例模式: +只有一个对象

+
+
+ + + + +
+ + + + + + +
+ + + +
+ + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Coding language/JAVA/Java_static_final.html b/Coding language/JAVA/Java_static_final.html new file mode 100755 index 0000000..abfab98 --- /dev/null +++ b/Coding language/JAVA/Java_static_final.html @@ -0,0 +1,691 @@ + + + + + + + + + + + + Java中静态(static)变量、方法与实例变量、方法的规范 — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+

Java中静态(static)变量、方法与实例变量、方法的规范

+ +
+
+ +
+
+
+ + + + +
+ +
+

Java中静态(static)变量、方法与实例变量、方法的规范#

+

Head First java第十章的静态变量与方法一节中, 规定了许多规则, 通过这几道有疑问的习题来加深印象。

+

已增加书籍连接(中英版), 在文末附上链接

+
    +
  1. 能否在非静态方法中存取静态变量?

  2. +
+
//在非静态方法中调用静态变量
+//结果:通过编译
+public class Foo{
+    static int x;
+    public void go(){
+	System.out.println(x + "success");
+}
+public static void main(String[] args){
+//	Foo.go(); 静态方法不能引用非静态方法
+}
+}
+
+
+

+结果: 通过编译 +结论1: 可以在非静态方法中读取静态变量

+
+

A non-static method in a class can always call a static method in the class or access a static variable of the class.

+
+

译:一个类中的非静态方法能够调用这个类的静态方法或存取这个类的静态变量

+
    +
  1. 能否在静态方法中调用实例变量

  2. +
+
//静态方法中调用实例变量
+public class Foo2{
+    int x;
+    public static void go(){
+        System.out.println(x);
+}
+    public static void main(String[] args){
+
+}
+}
+
+
+

+结果: 出现编译错误 +结论2: 无法从静态方法中调用非静态变量

+
    +
  1. 非静态方法能否存取(access)final变量

  2. +
+
// 非静态方法能否存取(access)final变量
+public class Foo3{
+    final int x;
+    public void go(){
+        System.out.print(x);
+}
+public static void main(String[] args){}
+}
+
+
+

+结果: 编译错误, final变量必须初始化

+
    +
  • 尝试初始化

  • +
+
    +
  1. 声明时初始化

  2. +
+
// 非静态方法能否存取(access)final变量
+public class Foo3{
+    final int x = 0;  //初始化为0
+    public void go(){
+        System.out.print(x);
+}
+public static void main(String[] args){}
+}
+
+
+

+结果: 编译通过

+
    +
  1. 在静态初始化程序中 初始化

  2. +
+
// 非静态方法能否存取(access)final变量
+public class Foo3{
+ 
+    final int x ;
+       static { //静态初始化程序
+        x = 0;
+}
+    public void go(){
+        System.out.print(x);
+}
+public static void main(String[] args){}
+
+}
+
+
+

+出错, static没有把final变量初始化了,又尝试修改, 这次增加了static关键字在final变量中。 +try again:

+
// 非静态方法能否存取(access)final变量
+public class Foo3{
+ 
+   static final int x ;  //变为静态final变量
+       static {
+        x = 0;
+}
+    public void go(){
+        System.out.print(x);
+}
+public static void main(String[] args){}
+
+}
+
+
+

+结果: 编译成功

+

结论3: 非静态方法能够存取final变量, 但是final变量必须被初始化。 final变量初始化方式有两种: +第一种: 声明时初始化 +第二种: 将其声明为静态final变量, 使用static{}静态初始化程序进行初始化(她会在其他程序可以使用该类之前就执行)

+
    +
  1. 非静态方法是否可以存取静态final变量

  2. +
+
public class Foo4{
+    static final int x = 12;
+    public void go(){
+        System.out.print(x);
+}
+}
+
+
+

+结果: 编译通过

+

试着破坏(改变)这个代码: +比如,

+
    +
  • 把它的变量初始化值去掉:

  • +
+
public class Foo4{
+    static final int x ;
+    public void go(){
+        System.out.print(x);
+}
+}
+
+
+

+果然出错了, 从上一个例子我们知道是因为final变量必须初始化

+
    +
  • 再试着把static去掉

  • +
+
public class Foo4{
+    final int x = 12;
+    public void go(){
+        System.out.print(x);
+}
+}
+
+
+

+编译成功, 这说明在非静态方法中可以存取final变量 +结论4:非静态方法中可以存取静态 [static]final变量和final变量

+
    +
  1. 非静态方法参数中的final变量能否被该方法存取

  2. +
+
public class Foo5{
+    static final int x = 12; //静态final变量, 相当于常数
+    public void go(final int x){  //方法形式参数, final变量
+        System.out.print(x);
+}
+
+public static void main(String[] args){
+    Foo5 foo = new Foo5();
+    foo.go(5); //传入5
+}
+}
+
+
+

这个类中, 非静态方法go的参数为final的int型变量, 它被输出语句输出。 +注意这里输出的 x为 调用go方法的对象foo传入的实际参数5, 而不是实例变量中的12. + +结论5: 非静态方法参数中的final变量能被该方法存取

+
    +
  1. 静态 方法参数中的final变量能否被该方法存取

  2. +
+
public class Foo6{
+    int x = 12;
+    public static void go(final int x){ 
+        System.out.println(x);  
+}
+public static void main(String[] args){ //静态方法可以调用静态方法
+    Foo6 foo = new Foo6();
+    foo.go(5);
+}
+}
+
+
+

+结果: 编译成功 +结论6:静态方法参数中的final变量能被该方法存取

+
    +
  • life和scope的差别 +在方法中, +作用域(scope)范围内的变量不受方法外部的实例变量影响(即使同名)。 这个被称为局部变量, 可以把参数也看作是一个局部变量, 它们跟随着方法 从被调用 到 执行完而被丢弃(调用栈弹出)

  • +
+

局部变量的范围(scope)只限于声明它的方法之内。 当此方法调用别的方法时, 该变量还活着(In life’s perspective is alive),但不在目前的范围内(scope)。执行其他方法完毕返回时, 范围也就跟着回来。

+

方法还有一个life(生命周期), 只要变量的堆栈块还在堆栈上, 局部变量就算活着, 它会活到方法执行完毕为止。

+

当局部变量还活着(life层面)的时候, 它的状态会被保存。

+

只要go()还在堆栈上, x变量就会保存它的值, 但x变量只能在go()方法待在栈顶时才能使用。 也就是说, 局部变量只能在声明它的方法 在执行中 才能被使用。

+

链接 中文版: +提取码:pi8j

+

链接 英文版 +提取码:olvs

+
+ + + + +
+ + + + + + +
+ + + + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Coding language/basic_cmd.html b/Coding language/basic_cmd.html new file mode 100755 index 0000000..5eb84a5 --- /dev/null +++ b/Coding language/basic_cmd.html @@ -0,0 +1,594 @@ + + + + + + + + + + + + Basic cmd command: — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + +
+ +
+

Basic cmd command:#

+

用于记录日常用到的cmd命令

+
    +
  1. +
+
+

查看端口情况#

+
+
netstat -ano
+
+
+
    +
  1. +
+
+

查看进程号#

+
+
netstat -ano|findstr "端口号"
+
+
+
    +
  1. +
+
+

查看IP地址#

+
+
ipconfig
+
+
+
    +
  1. +
+
+

查看网络包情况#

+
+
ping
+
+
+
    +
  1. +
+
+

自行查看帮助#

+
+
help
+
+
+
    +
  1. +
+
+

画图#

+
+
mspaint
+
+
+
    +
  1. +
+
+

笔记本#

+
+
notepad
+
+
+
    +
  1. +
+
+

删除服务#

+
+
sc delete mysql
+
+
+

dir +md +rd +cd(change directory) +cd
+cd.. +echo text >> dir name(将text写入名字为name的directory) +cat dir name(查看文件内容) +一个 > : 只显示新写入的内容,旧内容全部删除 +两个 >> :追加,旧内容不会删除

+
+ + + + +
+ + + + + + +
+ + + + + + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Coding language/computer_repair.html b/Coding language/computer_repair.html new file mode 100755 index 0000000..4525acf --- /dev/null +++ b/Coding language/computer_repair.html @@ -0,0 +1,510 @@ + + + + + + + + + + + + Computer repair — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+

Computer repair

+ +
+
+ +
+
+
+ + + + +
+ +
+

Computer repair#

+

此篇文章用于记录日常遇到的软件安装问题,包括各种路径冲突、盘符扩充等等

+

This article used to record the problem that I faced in my daily development life.

+
    +
  1. How to enlarge the C partion space. +如何扩充C盘空间?

  2. +
+

重装系统后, 所有的软件都需要重新下载, 但是C盘分区时分的过小,导致许多软件的系统配置文件无法安装到C盘。

+

搜索一番后,找到一款很棒的分区软件MiniTool Partition Wizard

+

具体操作可参考链接

+
    +
  1. MySQL reload.s +Navicat连接mysql8.0.1版本出现1251–Client does not support authentication protocol requested by server的解决

  2. +
  3. MYSQL The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone

  4. +
+

Solution +时区问题,只需更改时区即可 +Reference

+
mysql -uroot -p
+pw:123123
+
+set global time_zone = ‘+8:00‘; ##修改mysql全局时区为北京时间,即我们所在的东8区
+set time_zone = ‘+8:00‘; ##修改当前会话时区
+flush privileges; #立即生效
+
+
+
    +
  1. 重装Mysql +重装mysql

  2. +
+
+ + + + +
+ + + + + + +
+ + + + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Coding language/git_basic.html b/Coding language/git_basic.html new file mode 100755 index 0000000..4a60a0b --- /dev/null +++ b/Coding language/git_basic.html @@ -0,0 +1,669 @@ + + + + + + + + + + + + Git的三个工作区和四种状态 — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + +
+ +
+

Git的三个工作区和四种状态#

+

Git帮助手册 git命令全面介绍

+

创建一个版本控制的文件, 用到的这些git指令, 可以对照着手册进行阅读

+
    +
  • git init

  • +
  • git add

  • +
  • git commit

  • +
  • git push

  • +
+

今天尝试git commit, 提示我有untracked file +在这里插入图片描述 +有些疑惑, 于是去查看了git帮助手册 +在第一章1.3 git basics 中, 了解到了git的三种状态

+
    +
  • committed(已提交)

  • +
  • modified(已修改)

  • +
  • staged(已暂存) +下面看看手册中如何解释这三个状态

  • +
  • Committed means that the data is safely stored in your local database. +committed意味着数据被安全的存储在你的本地数据库中

  • +
  • Modified means that you have changed the file but have not committed it to your database yet. +modified意味着你已经改变了你的文件但是还没有把改变提交到你的数据库中

  • +
  • Staged means that you have marked a modified file in its current version to go into your next commit snapshot. +staged意味着对一个已修改文件的当前版本做了标记,使之包含在下次提交的快照中。(个人理解, 就是修改的文件准备好要被提交(commit)了)

  • +
+

由此引入 Git 项目的三个工作区域的概念:Git 仓库(the Git directory,) 工作目录( the working tree)以及暂存区域(the staging area.)。 +在这里插入图片描述

+
    +
  • The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer. +git directory 是 Git 用来保存项目的元数据和对象数据库的地方。 这是 Git 中最重要的部分,从其它计算机克隆仓库时,拷贝的就是这里的数据。

  • +
  • The working tree is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. +working tree(工作目录)是对项目的某个版本独立提取出来的内容。 这些从 Git 仓库的压缩数据库中提取出来的文件,放在磁盘上供你使用或修改。(我理解为自己电脑上本地磁盘上的文件)

  • +
  • The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. Its technical name in Git parlance is the “index”, but the phrase “staging area” works just as well. +(staging area)暂存区域是一个文件,它保存了下次将提交(commit)的文件列表信息,一般在 git directory中。 有时候也被称作`‘索引(index)’’,不过一般说法还是叫暂存区域(staging area)。

  • +
+

The basic Git workflow goes something like this: +基本的 Git 工作流程如下:

+

You modify files in your working tree. +你修改的文件在working tree(工作目录)中 (也就是你在本地磁盘上想要版本控制的那个文件)

+

You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the staging area. +选择暂存那些你想放到下一次提交(commit)的改变,将文件快照(也就是改变后的文件)

+

You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. +提交更新,找到暂存区域(staging area)的文件,将快照永久性存储到 Git 仓库目录。(git directory)

+

If a particular version of a file is in the Git directory, it’s considered committed. +如果 Git 目录中保存着的特定版本文件,就属于已提交状态(committed)。

+

If it has been modified and was added to the staging area, it is staged. +如果作了修改并已放入暂存区域,就属于已暂存状态(staged)。

+

And if it was changed since it was checked out but has not been staged, it is modified. +如果自上次取出后,作了修改但还没有放到暂存区域,就是已修改状态。(modified)

+

回到刚刚我遇到的问题,提示我nothing added to commit but untracked files present +没有被加到提交(commit)中的文件, 但是有untraked(未跟踪)的文件 +为了知道这个未跟踪是什么意思, 我又找到了另一节内容。

+

第二节内容大致概括了Git的大部分操作, 推荐初学者看。

+

2.1 Git Basics - Getting a Git Repository +2.2 Git Basics - Recording Changes to the Repository +在这里插入图片描述

+
+

1. Getting a Git Repository#

+

有两种取得 Git 项目仓库的方法。

+
    +
  • 第一种是在现有项目或目录下导入所有文件到 Git 中; +You can take a local directory that is currently not under version control, and turn it into a Git repository, or

  • +
  • 第二种是从一个服务器克隆一个现有的 Git 仓库。 +You can clone an existing Git repository from elsewhere.

  • +
+
+

Initializing a Repository in an Existing Directory#

+

如果你打算使用 Git 来对现有的项目进行管理,你只需要进入该项目目录并输入:

+
$ git init
+
+
+

注意现在是在GitTest这个上级目录中做版本控制, 所以要在GitTest上右键,点击 git bush. +.git目录 +该命令将创建一个名为 .git 的子目录,这个子目录含有你初始化的 Git 仓库中所有的必须文件,这些文件是 Git 仓库的骨干。 但是,在这个时候,我们仅仅是做了一个初始化的操作,你的项目里的文件还没有被跟踪。 +This creates a new subdirectory named .git that contains all of your necessary repository files — a Git repository skeleton. At this point, nothing in your project is tracked yet.

+

所以这里推断出, nothing added to commit but untracked files present 是因为我做了修改的东西没有添加到暂存区域(staging area) +【之后会说到这个暂存区域, 大家多看上面两张图, 就可以理解清楚Git的基本操作原理】

+

如果你是在一个已经存在文件的文件夹(而不是空文件夹)中初始化 Git 仓库来进行版本控制的话,你应该开始跟踪这些文件并提交。 你可通过 git add 命令来实现对指定文件的跟踪,然后执行 git commit 提交: +If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit. You can accomplish that with a few git add commands that specify the files you want to track, followed by a git commit:

+
$ git add gittest
+$ git commit -m 'initial project version'
+
+
+

如下图, 执行git add后, 我的名为gittest的文件就会被跟踪(track), 也就是把它状态变为staged, 也就把它放入了staging area(暂存区域). +track gittest dir +三种工作目录与四种文件状态 +四种文件状态 +进入staging 工作区

+

稍后我们再逐一解释每一条指令的意思。现在,你已经得到了一个实际维护(或者说是跟踪)着若干个文件的 Git 仓库。 +We’ll go over what these commands do in just a minute. At this point, you have a Git repository with tracked files and an initial commit.

+

Git 建立 Local Repository

+
$ mkdir project; cd project #或者手动创建一个本地文件夹, 用右键git bush
+$ git init
+$ echo "hello" > hello.txt
+$ git add .             #将修改(modified)过的文件添加到暂存区(staging area)
+$ git commit -m 'initial' #提交commit, 初始化提交信息。
+
+
+

发现一个比较详细的git命令举例:link +> 和 >> 的 区别: What is difference between > and >>

+
+
+

Cloning an Existing Repository#

+

如果你想获得一份已经存在了的 Git 仓库的拷贝,比如说,你想为某个开源项目贡献自己的一份力,这时就要用到 git clone 命令。 如果你对其它的 VCS 系统(比如说Subversion)很熟悉,请留心一下你所使用的命令是”clone”而不是”checkout”。 这是 Git 区别于其它版本控制系统的一个重要特性,Git 克隆的是该 Git 仓库服务器上的几乎所有数据,而不是仅仅复制完成你的工作所需要文件。 当你执行 git clone 命令的时候,默认配置下远程 Git 仓库中的每一个文件的每一个版本都将被拉取下来。 事实上,如果你的服务器的磁盘坏掉了,你通常可以使用任何一个克隆下来的用户端来重建服务器上的仓库(虽然可能会丢失某些服务器端的挂钩设置,但是所有版本的数据仍在。

+

克隆仓库的命令格式是

+
git clone [url] 。
+
+
+

以Girls In AI 项目为例: +在这里插入图片描述 +在这里插入图片描述 +之后在命令行输入

+
git clone https://github.com/Jane-QinJ/Girls-In-AI.git
+
+
+

Git 支持多种数据传输协议。 上面的例子使用的是 https:// 协议,不过你也可以使用 git:// 协议或者使用 SSH 传输协议,比如 user@server:path/to/repo.git 。

+
+
+

Recording Changes to the Repository#

+

记录每次更新到仓库

+

这个算是版本控制最常用的功能了, 就是记录你的每一次修改。 你还可以为每一次修改添加必要的批注, 每一次的修改都会以快照的形式记录, 所以随时可以恢复成上一状态。

+

再回顾上面的图,使用 Git 时文件的生命周期如下: +The life cycle of Git's file +下面详细介绍一下这几个Git中的文件状态:

+

Remember that each file in your working directory can be in one of two states: tracked or untracked. +请记住,你工作目录下的每一个文件都不外乎这两种状态:*已跟踪或未跟踪。

+
    +
  • Tracked files are files that were in the last snapshot; they can be unmodified, modified, or staged. In short, tracked files are files that Git knows about. +已跟踪(Tracked )的文件是指那些被纳入了版本控制的文件,在上一次快照中有它们的记录,在工作一段时间后,它们的状态可能处于未修改(unmodified),已修改(modified)或已放入暂存区(staged)。

  • +
  • Untracked files are everything else — any files in your working directory that were not in your last snapshot and are not in your staging area. When you first clone a repository, all of your files will be tracked and unmodified because Git just checked them out and you haven’t edited anything. +工作目录中除已跟踪文件以外的所有其它文件都属于未跟踪文件(untracked),它们既不存在于上次快照的记录中,也没有放入暂存区。 初次克隆某个仓库的时候,工作目录中的所有文件都属于已跟踪文件,并处于未修改状态。

  • +
+

As you edit files, Git sees them as modified, because you’ve changed them since your last commit. As you work, you selectively stage these modified files and then commit all those staged changes, and the cycle repeats. +编辑(edit)过某些文件之后,由于自上次提交后你对它们做了修改,Git 将它们标记为已修改文件(modified)。 我们逐步将这些修改过的文件放入暂存区(staging area),然后提交(commit)所有暂存了的修改,如此反复。所以使用 Git 时文件的生命周期如上图。

+

简而言之, 当你增加一个没有进行git add的文件, 它就是untracked状态。 +而如果你修改了一个你已经跟踪(tracked)的文件, 它就会变为modified状态。 进一步, 你将这个修改过的文件通过git add【文件名】 加入了staging area, 这时它就可以被提交(commit)了。 +最后, 你要将这个提交, push到你的GitHub上, 用git push.

+
+

Checking the Status of Your Files(检查当前文件状态)#

+

以上各种文件状态, 都是可以查看的, 用到的Git命令为:

+
$ git status
+
+
+

以我的为例 + +我的Git跟踪文件目前没有修改, 所以nothing to commit, working tree clean. +没有要提交的内容, working tree(工作目录)很干净。

+

现在我们新建一个文件, 它就是未被跟踪的(untracked) + +熟悉的问题, 看来我之前出现的问题就是在这里。 我新添加的文件仅仅在我本地的工作目录上(working dictionary), 但它要被提交到git directory才可以被Git控制。

+

推荐大家继续将Git的工作目录和Git的状态结合起来看。 + +现在更加理解了, 我们工作的地方在本地文件夹, 也就是working directory. 而Git要对我们的文件夹进行监控与控制, 是在git directory,

+

再重新回顾一下这三个工作区域的概念, 相信你会更加理解。

+
+
+
+
+ + + + +
+ + + + + + +
+ + + + + + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Computer Science/process_thread.html b/Computer Science/process_thread.html new file mode 100755 index 0000000..699fee7 --- /dev/null +++ b/Computer Science/process_thread.html @@ -0,0 +1,517 @@ + + + + + + + + + + + + Processes and threads: naming things the right way — Jane Qin Space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + +
+
+ + + +
+ + + +
+ +
+
+ +
+
+ +
+ +
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+ + + +
+

Processes and threads: naming things the right way

+ +
+ +
+
+ + + + +
+ +

线程知识介绍

+

介绍了process(进程)与thread(线程) +概要:(稍后汉译加深理解)

+
+

Processes and threads: naming things the right way#

+

Modern operating systems can run multiple programs at the same time. That’s why you can read this article in your browser (a program)(进程) while listening to music on your media player (another program). Each program is known as a process that is being executed. The operating system knows many software tricks to make a process run along with others, as well as taking advantage from the underlying hardware. Either way, the final outcome is that you sense all your programs to be running simultaneously.

+

Running processes in an operating system is not the only way to perform several operations at the same time. Each process is able to run simultaneous sub-tasks within itself, called threads(线程). You can think of a thread as a slice of the process itself. Every process triggers at least one thread on startup, which is called the main thread. Then, according to the program/programmer’s needs, additional threads may be started or terminated. Multithreading(多线程) is about running multiple threads withing a single process.

+

For example, it is likely that your media player runs multiple threads: one for rendering the interface — this is usually the main thread, another one for playing the music and so on.

+

You can think of the operating system as a container that holds multiple processes, where each process is a container that holds multiple threads. In this article I will focus on threads only, but the whole topic is fascinating and deserves more in-depth analysis in the future.

+

1. Operating systems can be seen as a box that contains processes, which in turn contain one or more threads.

+
+
+

The differences between processes and threads#

+

Each process has its own chunk of memory assigned by the operating system. By default that memory cannot be shared with other processes: your browser has no access to the memory assigned to your media player and vice versa[/ˌvaɪsə ˈvə..sə/ adv. 反过来也一样]. The same thing happens if you run two instances of the same process, that is if you launch your browser twice. The operating system treats each instance as a new process with its own separate portion of memory assigned. So, by default, two or more processes have no way to share data, unless they perform advanced tricks — the so-called [inter-process communication (IPC).] +(https://en.wikipedia.org/wiki/Inter-process_communication) +Unlike processes, threads share the same chunk of memory assigned to their parent process by the operating system: data in the media player main interface can be easily accessed by the audio engine and vice versa. Therefore is easier for two threads to talk to eachother. On top of that(最重要的是), threads are usually lighter than a process: they take less resources and are faster to create, that’s why they are also called lightweight processes.

+

Threads are a handy(便利的) way to make your program perform multiple operations at the same time. Without threads you would have to write one program per task, run them as processes and synchronize them through the operating system. This would be more difficult (IPC is tricky) and slower (processes are heavier than threads).

+
+
+

Green threads, of fibers#

+

Threads mentioned so far are an operating system thing: a process that wants to fire a new thread has to talk to the operating system. Not every platform natively support threads, though. Green threads, also known as fibers are a kind of emulation that makes multithreaded programs work in environments that don’t provide that capability. For example a virtual machine might implement green threads in case the underlying operating system doesn’t have native thread support.

+

Green threads are faster to create and to manage because they completely bypass the operating system, but also have disadvantages. I will write about such topic in one of the next episodes.

+

The name “green threads” refers to the Green Team at Sun Microsystem that designed the original Java thread library in the 90s. Today Java no longer makes use of green threads: they switched to native ones back in 2000. Some other programming languages — Go, Haskell or Rust to name a few — implement equivalents of green threads instead of native ones.

+
+
+

What threads are used for#

+

Why should a process employ multiple threads? As I mentioned before, doing things in parallel greatly speed up things. Say you are about to render a movie in your movie editor. The editor could be smart enough to spread the rendering operation across multiple threads, where each thread processes a chunk of the final movie. So if with one thread the task would take, say, one hour, with two threads it would take 30 minutes; with four threads 15 minutes, and so on.

+

Is it really that simple? There are three important points to consider:

+
    +
  1. not every program needs to be multithreaded. If your app performs sequential operations or often waits on the user to do something, multithreading might not be that beneficial;

  2. +
  3. you just don’t throw more threads to an application to make it run faster: each sub-task has to be thought and designed carefully to perform parallel operations;

  4. +
  5. it is not 100% guaranteed that threads will perform their operations truly in parallel, that is at the same time: it really depends on the underlying hardware. +The last one is crucial: if your computer doesn’t support multiple operations at the same time, the operating system has to fake them. We will see how in a minute. For now let’s think of concurrency as the perception of having tasks that run at the same time, while true parallelism as tasks that literally run at the same time.

  6. +
+
+ + + + +
+ + + + +
+ +
+ +
+
+
+ +
+ +
+ +
+ + + + + + +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/Kyoto University/Related information.html b/Kyoto University/Related information.html index 3b36406..3f8dc8d 100755 --- a/Kyoto University/Related information.html +++ b/Kyoto University/Related information.html @@ -156,6 +156,14 @@

Daily Life

+

Coding language

+ diff --git a/Life/diary.html b/Life/diary.html index 7d4bffa..11b2180 100755 --- a/Life/diary.html +++ b/Life/diary.html @@ -65,6 +65,7 @@ + @@ -155,6 +156,22 @@

Daily Life

+

Coding language

+ +

Java

+ +

C

+ @@ -349,6 +366,7 @@

Contents

@@ -382,6 +400,25 @@

工作生活日记2023.12.13 大雪 赴日前生活准备资料搜寻

+
+

2023.12.14 小雪 生活整理#

+

这几天重新搭个人网站,正好借机会梳理了自己的生活。昨天看了以前自己的日记,认真又努力,每次学新东西都很开心激动,每天自己鼓励自己,还蛮可爱的。 +虽然现在心态有所变化,对新鲜事物也没有那么兴奋,但好奇心还在,性格更加沉稳了,想的东西更多了,也蛮好的。 +每天写写日记有助于我的心变平静,这是这两天的明显感觉,可能是通过记录,发现每天的生活都是有迹可循的吧,给了自己一些实在的存在感,于是决定继续多写。 +昨天下午寸姐叫我们早些回家了,看来确实是弹性的上下班了一下,蛮开心感谢的。回家路上发现道路很干净,应该是撒了融雪剂。最近越来越能看到别人的劳动了,可能是开始参加工作,跟别人合作的机会多了,于是看到更多的东西,变得更谦虚感谢。之后做饭吃,陈老师最近加班比较累,抱抱、吃点小零食、一起吃吃辣条、看了一集神秘博士,想让她尽可能的放松一下。 +人累、紧张的时候反而会忘记怎么放松,但最需要放松。这时候身边的人帮助调整休息一下就好,现在对陈老师越来越熟悉了,能从她的小习惯、说话语气看出她今天心情怎么样。感觉她对我也是一样的。还是很神奇,我自己有时候陷入思维无法感知到自己的情绪好坏,但她一下就能知道我在生气还是开心。跟她在一起每天真是很幸福,希望能每天在一起。也许每天在身边比较难,但是只要她存在在这个世界上,都感觉多了一份很有意思的希望。

+

昨天还帮忙了亲戚家的妹妹挑选方向,大学生时候都对未来有所迷茫,因为还没有步入社会,对什么都不太清楚,想来当时的我也是那样的。帮助别人还是蛮开心的,说明这些年我都在成长吧。想来人的一生都是如此,不断的在成长,新陈更替、万物更新,大自然的法则如此,于是我还是得向前走才行。只是偶尔看看后来人,帮助提携一下,就像当时帮助我的温柔的人们一般。每每想到那些时刻,内心都很温暖,靠着这份温暖,还是继续扛着可能会越来越重的东西前行吧。

+

另外,也趁此机会回顾了下以往的计算机知识,人总会遗忘,以往的知识细节已经记不清了,但记得大体的框架,什么时候需要就再去学。最近的开发工作要我把以往的知识捡回来,熟练运用,于是还是得耐住性子重新看看才行。说来工作确实没什么意思,因为要求我变成一个对某部分功能重复熟练的部件,有固定输入和产出,可量化,重复注定没什么趣味,人性如此。但可能自己还是想成为一个社会上靠谱的人吧,贡献自己的绵薄之力,所以还是忍耐住了。跟年轻人接触一下也有助于自己自省,调整油滑的态度,哈哈。

+

最近我也有在学新知识,日语的学习进度虽然较慢,但一直在坚持。每天读读课文,坚持老师当时说的“少食多餐”,多重复就会记忆住。调整了生活作息之后,每晚抽出半小时到一小时的时间读课文、做例题。已经到了认清现实的年纪,人类社会发展到如今都是一步步积累而来的,每天踏踏实实学吧。每天把自己看一遍、把自己当成人类看一遍,自己待一会,放到社会中待一会。

+

劳逸结合,生活平衡。

+

爱自己,爱世界。

+
+20231214_化雪了 +
+

Fig. 4 暴雪道路也很干净(感谢劳动)#

+
+
+

2023.11.17 forget 病気#

今日は木曜日です。もうすぐ休みになりそうだ。 @@ -432,6 +469,15 @@

2023.11.17 forget 病気京都大学相关资讯

+ +
+

next

+

Git的三个工作区和四种状态

+
+ +
@@ -451,6 +497,7 @@

2023.11.17 forget 病気 diff --git a/_images/1_memory.png b/_images/1_memory.png new file mode 100755 index 0000000..fb871ee Binary files /dev/null and b/_images/1_memory.png differ diff --git "a/_images/20231214_\345\214\226\351\233\252\344\272\206.jpg" "b/_images/20231214_\345\214\226\351\233\252\344\272\206.jpg" new file mode 100755 index 0000000..a698cfb Binary files /dev/null and "b/_images/20231214_\345\214\226\351\233\252\344\272\206.jpg" differ diff --git a/_images/2_variable.png b/_images/2_variable.png new file mode 100755 index 0000000..1a76682 Binary files /dev/null and b/_images/2_variable.png differ diff --git a/_images/3_pointer.png b/_images/3_pointer.png new file mode 100755 index 0000000..f53cfb1 Binary files /dev/null and b/_images/3_pointer.png differ diff --git a/_sources/Coding language/C/Basic_C_note.md b/_sources/Coding language/C/Basic_C_note.md new file mode 100755 index 0000000..5119be3 --- /dev/null +++ b/_sources/Coding language/C/Basic_C_note.md @@ -0,0 +1,70 @@ +--- +title: Basic C note +date: 2019-7-5 +tags: +- learning note + +categories: learning note +--- +# Basic C note + +## 一、 文本显示 + +- printf用于输出文字 +``` +#include +int main() +{ + printf("我是小仙女,\n我长得很漂亮。\n"); + return 0; +} +``` +## 二、数据类型 + +``` +//standard io标准流输出 +#include +int main() +{ + //char 字符类型,主要用来显示给人看 + //int 整型, 整数型数字, 可以用来计算。 + printf("hello\n"); + printf("%d\n",1); + printf("%d大于%d",2,1); //2替换第一个%d,1替换第二个%d +} +``` +- 要显示字符型,我们只要直接写在两个引号里就可以了,写了什么就显示什么。 +- %d是占位符,显示的时候,逗号后面的内容会替换%d。 + +## 三、变量存储 + +``` +#include +int main() +{ + int weight; //定义一个变量weight + weight = 170; //给weight赋值为170 + printf("%d\n",weight); //显示weight的值。 + weight = weight+10; + printf("%d\n",weight); +} +``` + +:::{figure-md} markdown-fig +![1_memory](./images/1_memory.png) + +内存 +::: + + +:::{figure-md} markdown-fig +![2_variable](./images/2_variable.png) + +变量 +::: + +:::{figure-md} markdown-fig +![3_pointer](./images/3_pointer.png) + +指针 +::: \ No newline at end of file diff --git a/_sources/Coding language/JAVA/Java.md b/_sources/Coding language/JAVA/Java.md new file mode 100755 index 0000000..785079f --- /dev/null +++ b/_sources/Coding language/JAVA/Java.md @@ -0,0 +1,169 @@ +--- +title: 关于Java类中数组对象创建的疑问 +date: 2019-01-11 21:04:05 +tags: +- java + +categories: Java +--- + + +--- +# 关于Java类中数组对象创建的疑问 + + + +```java +public class Mix4{ + int counter = 0; + public static void main(String[] args){ + int count = 0; + Mix4 [] m4a = new Mix4[20]; + int x = 0; + while(x<9){ + m4a[x] = new Mix4(); + m4a[x].counter = m4a[x].counter + 1; + count = count + 1; + count = count + m4a[x].maybeNew(x); + x = x + 1; + } + System.out.println(count+" "+m4a[1].counter); + } + + public int maybeNew(int index){ + if(index<5){ + Mix4 m4 = new Mix4(); + m4.counter = m4.counter + 1; + return 1; + } + return 0; + } + +} +``` +这是Head First Java 中的一个习题, 在解答的过程中发现自己不了解以下几个知识点: + +- 类实例变量的初始化 +- 数组对象的创建 + +对于第一个问题,**类实例变量的初始化**,在可视化的过程中我有了新的理解,先放上整个过程的结果。 +![代码执行的图示](https://raw.githubusercontent.com/Jane-QinJ/Jane-QinJ.github.io/master/images/1.png) + +下面写下我在执行这个程序中遇到并解决的一些问题 +1. **程序是从main()开始的** + (这点我之前一直默认自己知道,但是程序真正执行起来,才发觉自己对这点的疏忽,还是需要谦虚些,默认自己什么都不知道,每个点都要踏踏实实扣下去) + ![在这里插入图片描述](https://img-blog.csdnimg.cn/20190113151016479.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1FpbnFpblRheWxvcg==,size_16,color_FFFFFF,t_100) + +2. **数组是一个对象**, 无论被声明来承载的是primitive主类型数据或对象引用,数组永远是对象。 +数组对象可以有primitive主数据类型的元素,但数组本身绝对不会是primitive主数据类型, 不管数组带有什么, 它一定是对象。 + + + +这句话的理解,在我看来可以这样解释: +![在这里插入图片描述](https://img-blog.csdnimg.cn/20190113151905260.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1FpbnFpblRheWxvcg==,size_16,color_FFFFFF,t_70) + + + +``` +Mix4 [] m4a = new Mix4[20]; +``` + +这段程序可以分为三部分 +1. 对象的声明 +2. 对象的创建 +3. 赋值 + +- 对象的声明 + +``` +Mix4[] m4a +``` + +声明了一个**类型**为Mix4[]的**数组变量**, 它的名称是m4a. + +这里补充一下,java注重类型, 声明变量必须有类型和名称(variables must have a type, variables must have a name) + +to be continued.... + +- 对象的创建 + +``` +new Mix4[20] +``` +创建大小为20的数组(这有着20个存储空间整体,为一个Mix4数组对象) +而这20个存储空间可以用来存储类型为Mix4的对象 + +这里只保存着Mix4的引用 +相当于只声明了对象,没有创建实际的Mix4对象。 +>可以这么理解 +``` +Mix4 m4a[0]; +``` +>数组中第一个索引里存放的是Mix4的引用 +>要创建Mix4对象的话 还要 +``` +m4a[0] = new Mix4(); +``` + +- 赋值 +连接对象和引用, 将Mix4[20]这个大小为20的数组,赋值给之前声明为Mix4[]的数组变量m4a. + +![在这里插入图片描述](https://img-blog.csdnimg.cn/20190113154401235.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1FpbnFpblRheWxvcg==,size_16,color_FFFFFF,t_70) +从上图中, 我们看到m4a这个数组变量,相当于一个遥控器,它指向了数组对象(也就是Mix4[20]),这个数组变量也称引用变量。 + +我们可以把变量看做杯子,变量用来装东西,也就是往杯子中装东西。 +比如: +``` +bype x = 7; +``` +就是代表数值7的字节(00000111)被放进变量中。 + +只不过这个引用变量装的东西比较特别,它放的东西代表**取得Mix4[20]对象的方法**以字节形式放进变量中,也就相当于一个遥控器, 这个引用变量可以通过 圆点“.”运算符来引用对象的方法和实例变量。 + +在数组中,对数组的操作可以不需要变量名称。只需要数组索引(位置)就可以操作特定对象: +``` +Mix4 [] m4a = new Mix4[20]; +m4a[0] = new Mix4(); +m4a[0].counter = m4a[0].counter + 1; +``` +这段代码代表了程序第一次执行while循环时,x=0情况下,Mix4数组变量m4a[0]对Mix4对象的操作。 +![在这里插入图片描述](https://img-blog.csdnimg.cn/20190113160332134.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1FpbnFpblRheWxvcg==,size_16,color_FFFFFF,t_70) +注意: +Mix4[20]数组中存放的仅仅是对Mix对象的引用, 还需要创建实际的Mix对象 + +``` +new Mix4() +``` +,并把它赋值给数组的元素 +``` +m4a[0] = new Mix4() +``` + +我理解错误的点主要在于对类实例变量的理解。 +我把实例变量counter看做每个对象都可以进行修改的值,错误的把counter进行了累加。 + +实际上,每个类是对象的蓝图。 创建一个对象就是对类的实例化。 这个对象会有自己的实例变量和方法。 + +对象本身一致的事物被称为:实例变量(instance variable) +对象可以执行的动作称为:方法(methods) +![在这里插入图片描述](https://img-blog.csdnimg.cn/20190113161209191.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1FpbnFpblRheWxvcg==,size_16,color_FFFFFF,t_70) +可以看到程序进行到第8行时,new Mix4()创建了一个Mix4类型的对象, 它执行了两次初始化\, 并且这个对象根据Mix4这个类的蓝图, 初始化了自己的实例变量counter = 0. + +之后将这个初始化了的对象赋值给了引用变量m4a[0] +![在这里插入图片描述](https://img-blog.csdnimg.cn/20190113161432105.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1FpbnFpblRheWxvcg==,size_16,color_FFFFFF,t_70) + +所以每一个数组引用变量都会有一个Mix4对象, 这些对象虽然是同一个类, 但每个都有自己独立的实例变量, 也就是counter. 而这个counter在创建对象时都会被赋值为0. + +![在这里插入图片描述](https://img-blog.csdnimg.cn/20190113162729536.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1FpbnFpblRheWxvcg==,size_16,color_FFFFFF,t_70) + +``` +Mix4 [] m4a = new Mix4[20]; +m4a[x] = new Mix4(); +m4a[x].counter = m4a[x].counter + 1; +``` +现在重看这行代码, 你是否能有新的理解呢 + +--- + +如有错误地方,请大家指正。 +共同学习,共同进步,期待大家的issue~ \ No newline at end of file diff --git a/_sources/Coding language/JAVA/Java_Design_pattern.md b/_sources/Coding language/JAVA/Java_Design_pattern.md new file mode 100755 index 0000000..a05b8ad --- /dev/null +++ b/_sources/Coding language/JAVA/Java_Design_pattern.md @@ -0,0 +1,11 @@ +--- +title: Java Design Pattern + +--- + +# Java Design Pattern + +### To be continue... + +单例模式: +只有一个对象 \ No newline at end of file diff --git a/_sources/Coding language/JAVA/Java_static_final.md b/_sources/Coding language/JAVA/Java_static_final.md new file mode 100755 index 0000000..209ec57 --- /dev/null +++ b/_sources/Coding language/JAVA/Java_static_final.md @@ -0,0 +1,218 @@ +--- +title: Java中静态(static)变量、方法与实例变量、方法的规范 +tags: +- java + +categories: Java +--- + +# Java中静态(static)变量、方法与实例变量、方法的规范 + +Head First java第十章的静态变量与方法一节中, 规定了许多规则, 通过这几道有疑问的习题来加深印象。 + +已增加书籍连接(中英版), 在文末附上链接 + + + +1. 能否在非静态方法中存取静态变量? +```java +//在非静态方法中调用静态变量 +//结果:通过编译 +public class Foo{ + static int x; + public void go(){ + System.out.println(x + "success"); +} +public static void main(String[] args){ +// Foo.go(); 静态方法不能引用非静态方法 +} +} +``` +![](https://img-blog.csdnimg.cn/20190129220155138.png) +**结果: 通过编译** +**结论1: 可以在非静态方法中读取静态变量** + +> A non-static method in a class can always call a static method in the class or access a static variable of the class. + +译:一个类中的**非静态方法**能够调用这个类的**静态方法**或存取这个类的**静态变量** + + + +2. 能否在静态方法中调用实例变量 +```java +//静态方法中调用实例变量 +public class Foo2{ + int x; + public static void go(){ + System.out.println(x); +} + public static void main(String[] args){ + +} +} +``` +![](https://img-blog.csdnimg.cn/20190129221508213.png) +**结果: 出现编译错误** +**结论2: 无法从静态方法中调用非静态变量** + +3. 非静态方法能否存取(access)final变量 +```java +// 非静态方法能否存取(access)final变量 +public class Foo3{ + final int x; + public void go(){ + System.out.print(x); +} +public static void main(String[] args){} +} +``` +![](https://img-blog.csdnimg.cn/20190129222705355.png) +**结果: 编译错误, final变量必须初始化** +- **尝试初始化** +1. 声明时初始化 +```java +// 非静态方法能否存取(access)final变量 +public class Foo3{ + final int x = 0; //初始化为0 + public void go(){ + System.out.print(x); +} +public static void main(String[] args){} +} +``` +![](https://img-blog.csdnimg.cn/20190129223031163.png) +**结果:** 编译通过 + +2. 在静态初始化程序中 初始化 +```java +// 非静态方法能否存取(access)final变量 +public class Foo3{ + + final int x ; + static { //静态初始化程序 + x = 0; +} + public void go(){ + System.out.print(x); +} +public static void main(String[] args){} + +} +``` +![](https://img-blog.csdnimg.cn/20190129223517288.png) +出错, static没有把final变量初始化了,又尝试修改, 这次增加了static关键字在final变量中。 +try again: +```java +// 非静态方法能否存取(access)final变量 +public class Foo3{ + + static final int x ; //变为静态final变量 + static { + x = 0; +} + public void go(){ + System.out.print(x); +} +public static void main(String[] args){} + +} +``` +![](https://img-blog.csdnimg.cn/2019012922395150.png) +**结果: 编译成功** + +**结论3: 非静态方法能够存取final变量, 但是final变量必须被初始化。 final变量初始化方式有两种: +第一种: 声明时初始化 +第二种: 将其声明为静态final变量, 使用static{}静态初始化程序进行初始化(她会在其他程序可以使用该类之前就执行)** + +4. 非静态方法是否可以存取静态final变量 +```java +public class Foo4{ + static final int x = 12; + public void go(){ + System.out.print(x); +} +} +``` +![](https://img-blog.csdnimg.cn/20190129224836892.png) +**结果: 编译通过** + +试着破坏(改变)这个代码: +比如, +- 把它的变量初始化值去掉: +```java +public class Foo4{ + static final int x ; + public void go(){ + System.out.print(x); +} +} +``` +![](https://img-blog.csdnimg.cn/20190129225013264.png) +果然出错了, 从上一个例子我们知道是因为**final变量必须初始化** +- 再试着把static去掉 +```java +public class Foo4{ + final int x = 12; + public void go(){ + System.out.print(x); +} +} +``` +![](https://img-blog.csdnimg.cn/20190129225228266.png) +编译成功, 这说明在**非静态方法中可以存取final变量** +**结论4:非静态方法中可以存取静态 [static]final变量和final变量** + +5. 非静态方法参数中的final变量能否被该方法存取 +```java +public class Foo5{ + static final int x = 12; //静态final变量, 相当于常数 + public void go(final int x){ //方法形式参数, final变量 + System.out.print(x); +} + +public static void main(String[] args){ + Foo5 foo = new Foo5(); + foo.go(5); //传入5 +} +} +``` +这个类中, 非静态方法go的参数为final的int型变量, 它被输出语句输出。 +注意这里输出的 x为 调用go方法的对象foo传入的实际参数5, 而不是实例变量中的12. +![](https://img-blog.csdnimg.cn/201901292304488.png) +**结论5: 非静态方法参数中的final变量能被该方法存取** + +6. 静态 方法参数中的final变量能否被该方法存取 +```java +public class Foo6{ + int x = 12; + public static void go(final int x){ + System.out.println(x); +} +public static void main(String[] args){ //静态方法可以调用静态方法 + Foo6 foo = new Foo6(); + foo.go(5); +} +} +``` + +![](https://img-blog.csdnimg.cn/20190129231008281.png) +结果: 编译成功 +**结论6:静态方法参数中的final变量能被该方法存取** + +- **life和scope的差别** +在方法中, +作用域(scope)范围内的变量不受方法外部的实例变量影响(即使同名)。 这个被称为局部变量, 可以把参数也看作是一个局部变量, 它们跟随着方法 从被调用 到 执行完而被丢弃(调用栈弹出) + +局部变量的范围(scope)只限于声明它的方法之内。 当此方法调用别的方法时, 该变量还活着(In **life's** perspective is **alive**),但不在目前的范围内(scope)。执行其他方法完毕返回时, 范围也就跟着回来。 + +方法还有一个life(生命周期), 只要变量的堆栈块还在堆栈上, 局部变量就算活着, 它会活到方法执行完毕为止。 + +当局部变量还活着(life层面)的时候, 它的状态会被保存。 + +只要go()还在堆栈上, x变量就会保存它的值, 但x变量只能在go()方法待在栈顶时才能使用。 也就是说, 局部变量只能在声明它的方法 在执行中 才能被使用。 + +[链接 中文版:](https://pan.baidu.com/s/1cHSUNy0OgffOrCd38UaDSw) +提取码:pi8j + +[链接 英文版](https://pan.baidu.com/s/1-tSXcvp8Z_qEk7pUYo0ZOg) +提取码:olvs diff --git a/_sources/Coding language/basic_cmd.md b/_sources/Coding language/basic_cmd.md new file mode 100755 index 0000000..709365f --- /dev/null +++ b/_sources/Coding language/basic_cmd.md @@ -0,0 +1,57 @@ +--- +title: basic cmd +tags: +- cmd +- learning note +--- + +# Basic cmd command: + +用于记录日常用到的cmd命令 + +1. ## 查看端口情况 +``` +netstat -ano +``` +2. ## 查看进程号 +``` +netstat -ano|findstr "端口号" +``` + +4. ## 查看IP地址 +``` +ipconfig +``` +5. ## 查看网络包情况 +``` +ping +``` + +6. ## 自行查看帮助 +``` +help +``` + +7. ## 画图 +``` +mspaint +``` +8. ## 笔记本 +``` +notepad +``` + +9. ## 删除服务 +``` +sc delete mysql +``` +dir +md +rd +cd(change directory) +cd\ +cd.. +echo text >> dir name(将text写入名字为name的directory) +cat dir name(查看文件内容) +一个 > : 只显示新写入的内容,旧内容全部删除 +两个 >> :追加,旧内容不会删除 \ No newline at end of file diff --git a/_sources/Coding language/computer_repair.md b/_sources/Coding language/computer_repair.md new file mode 100755 index 0000000..2bcc938 --- /dev/null +++ b/_sources/Coding language/computer_repair.md @@ -0,0 +1,44 @@ +--- +title: Computer repair +date: +tags: +- software repair + +categories: +- daily repair +--- +# Computer repair + +此篇文章用于记录日常遇到的软件安装问题,包括各种路径冲突、盘符扩充等等 + +This article used to record the problem that I faced in my daily development life. + +1. How to enlarge the C partion space. + 如何扩充C盘空间? + +重装系统后, 所有的软件都需要重新下载, 但是C盘分区时分的过小,导致许多软件的系统配置文件无法安装到C盘。 + +搜索一番后,找到一款很棒的分区软件[MiniTool Partition Wizard](http://www.partitionwizard.com/ ) + +具体操作可参考[链接](https://blog.csdn.net/a1b2c3d4123456/article/details/49763883) + +2. MySQL reload.s +[Navicat连接mysql8.0.1版本出现1251--Client does not support authentication protocol requested by server的解决](https://blog.csdn.net/qq_42152399/article/details/80360817) + +3. MYSQL **The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone** + +**Solution** +时区问题,只需更改时区即可 +[Reference](http://www.cnblogs.com/wangdianqian/p/9927406.html) + +``` +mysql -uroot -p +pw:123123 + +set global time_zone = ‘+8:00‘; ##修改mysql全局时区为北京时间,即我们所在的东8区 +set time_zone = ‘+8:00‘; ##修改当前会话时区 +flush privileges; #立即生效 +``` + +4. 重装Mysql +[重装mysql](https://www.cnblogs.com/jpfss/p/6652701.html) \ No newline at end of file diff --git a/_sources/Coding language/git_basic.md b/_sources/Coding language/git_basic.md new file mode 100755 index 0000000..dcb4549 --- /dev/null +++ b/_sources/Coding language/git_basic.md @@ -0,0 +1,173 @@ +# Git的三个工作区和四种状态 + +[Git帮助手册](https://git-scm.com/book/en/v2) git命令全面介绍 + + + +创建一个版本控制的文件, 用到的这些git指令, 可以对照着手册进行阅读 +- git init +- git add +- git commit +- git push + +今天尝试git commit, 提示我有untracked file +![在这里插入图片描述](https://camo.githubusercontent.com/776d307b33003093c6613b437c82193ffda0d5dc/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133303231313535353130312e706e67) +有些疑惑, 于是去查看了git帮助手册 +在第一章1.3 git basics 中, 了解到了git的三种状态 +- committed(已提交) +- modified(已修改) +- staged(已暂存) +下面看看手册中如何解释这三个状态 +- Committed means that the data is safely stored in your local database. +committed意味着数据被安全的存储在你的本地数据库中 +- Modified means that you have changed the file but have not committed it to your database yet. +modified意味着你已经改变了你的文件但是还没有把改变提交到你的数据库中 +- Staged means that you have marked a modified file in its current version to go into your next commit snapshot. +staged意味着对一个已修改文件的当前版本做了标记,使之包含在下次提交的快照中。(个人理解, 就是修改的文件准备好要被提交(commit)了) + +由此引入 Git 项目的三个工作区域的概念:Git 仓库(the Git directory,) 工作目录( the working tree)以及暂存区域(the staging area.)。 +![在这里插入图片描述](https://camo.githubusercontent.com/28a645732cce079b4f4ab0a2a0cf005eb512055d/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f323031393031333032313333323733332e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) +- The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer. +git directory 是 Git 用来保存项目的元数据和对象数据库的地方。 这是 Git 中最重要的部分,从其它计算机克隆仓库时,拷贝的就是这里的数据。 +- The working tree is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. +working tree(工作目录)是对项目的某个版本独立提取出来的内容。 这些从 Git 仓库的压缩数据库中提取出来的文件,放在磁盘上供你使用或修改。(我理解为自己电脑上本地磁盘上的文件) +- The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. Its technical name in Git parlance is the “index”, but the phrase “staging area” works just as well. +(staging area)暂存区域是一个文件,它保存了下次将提交(commit)的文件列表信息,一般在 git directory中。 有时候也被称作`‘索引(index)’',不过一般说法还是叫暂存区域(staging area)。 + +The basic Git workflow goes something like this: +基本的 Git 工作流程如下: + +You modify files in your working tree. +你修改的文件在working tree(工作目录)中 (也就是你在本地磁盘上想要版本控制的那个文件) + +You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the staging area. +选择暂存那些你想放到下一次提交(commit)的改变,将文件快照(也就是改变后的文件) + +You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory. +提交更新,找到暂存区域(staging area)的文件,将快照永久性存储到 Git 仓库目录。(git directory) + +If a particular version of a file is in the Git directory, it’s considered committed. +如果 Git 目录中保存着的特定版本文件,就属于已提交状态(committed)。 + +If it has been modified and was added to the staging area, it is staged. +如果作了修改并已放入暂存区域,就属于已暂存状态(staged)。 + +And if it was changed since it was checked out but has not been staged, it is modified. +如果自上次取出后,作了修改但还没有放到暂存区域,就是已修改状态。(modified) + + +回到刚刚我遇到的问题,提示我nothing added to commit but untracked files present +没有被加到提交(commit)中的文件, 但是有untraked(未跟踪)的文件 +为了知道这个未跟踪是什么意思, 我又找到了另一节内容。 + +第二节内容大致概括了Git的大部分操作, 推荐初学者看。 + +**2.1 Git Basics - Getting a Git Repository** +**2.2 Git Basics - Recording Changes to the Repository** +![在这里插入图片描述](https://camo.githubusercontent.com/c3137f535e5e76e5ac01828c0a7ff95612e3fca4/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313137313430313834372e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) +## 1. Getting a Git Repository + +有两种取得 Git 项目仓库的方法。 +- 第一种是在现有项目或目录下导入所有文件到 Git 中; + You can take a local directory that is currently not under version control, and turn it into a Git repository, or + +- 第二种是从一个服务器克隆一个现有的 Git 仓库。 +You can clone an existing Git repository from elsewhere. + +#### Initializing a Repository in an Existing Directory +如果你打算使用 Git 来对现有的项目进行管理,你只需要进入该项目目录并输入: +``` +$ git init +``` +注意现在是在GitTest这个上级目录中做版本控制, 所以要在GitTest上右键,点击 git bush. +![.git目录](https://camo.githubusercontent.com/3db741358b1310b2fec34aec092537a080d70e68/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313137323934343839362e706e67) +该命令将创建一个名为 .git 的子目录,这个子目录含有你初始化的 Git 仓库中所有的必须文件,这些文件是 Git 仓库的骨干。 但是,在这个时候,我们仅仅是做了一个**初始化**的操作,你的**项目里的文件还没有被跟踪**。 +This creates a new subdirectory named .git that contains all of your necessary repository files — a Git repository skeleton. At this point, **nothing in your project is tracked yet**. + +*所以这里推断出, nothing added to commit but untracked files present 是因为我做了修改的东西没有添加到暂存区域(staging area)* +【之后会说到这个暂存区域, 大家多看上面两张图, 就可以理解清楚Git的基本操作原理】 + +如果你是在一个已经存在文件的文件夹(而不是空文件夹)中初始化 Git 仓库来进行版本控制的话,你应该开始跟踪这些文件并提交。 你可通过 git add 命令来实现对指定文件的跟踪,然后执行 git commit 提交: +If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit. You can accomplish that with a few git add commands that specify the files you want to track, followed by a git commit: +``` +$ git add gittest +$ git commit -m 'initial project version' +``` +如下图, 执行**git add**后, 我的名为gittest的文件就会被跟踪(track), 也就是把它状态变为staged, 也就把它放入了staging area(暂存区域). +![track gittest dir](https://camo.githubusercontent.com/d8bd7012a385e33f8b87a8dbbd836c43768242e3/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313137333731323835362e706e67) +三种工作目录与四种文件状态 +![四种文件状态](https://camo.githubusercontent.com/b12d0caea3f77cf44b79aff879e833c8cc64c241/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f323031393031333131373338333938342e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) +![进入staging 工作区](https://camo.githubusercontent.com/8e2e448308bd55cd141e78cfce5d7e1b676aa2be/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313137333932373439382e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) + +稍后我们再逐一解释每一条指令的意思。现在,你已经得到了一个实际维护(或者说是跟踪)着若干个文件的 Git 仓库。 +We’ll go over what these commands do in just a minute. At this point, you have a Git repository with tracked files and an initial commit. + + +**Git 建立 Local Repository** +``` +$ mkdir project; cd project #或者手动创建一个本地文件夹, 用右键git bush +$ git init +$ echo "hello" > hello.txt +$ git add . #将修改(modified)过的文件添加到暂存区(staging area) +$ git commit -m 'initial' #提交commit, 初始化提交信息。 +``` +发现一个比较详细的git命令举例:[link](https://blog.longwin.com.tw/2009/05/git-learn-test-command-2009/) +\> 和 >> 的 区别: [What is difference between > and >>](https://stackoverflow.com/questions/39024073/using-echo-what-is-difference-between-and) +#### Cloning an Existing Repository +如果你想获得一份**已经存在了的 Git 仓库的拷贝**,比如说,你想为某个开源项目贡献自己的一份力,这时就要用到 git clone 命令。 如果你对其它的 VCS 系统(比如说Subversion)很熟悉,请留心一下你所使用的命令是"clone"而不是"checkout"。 这是 Git 区别于其它版本控制系统的一个重要特性,Git 克隆的是该 Git 仓库服务器上的几乎所有数据,而不是仅仅复制完成你的工作所需要文件。 当你执行 git clone 命令的时候,默认配置下远程 Git 仓库中的每一个文件的每一个版本都将被拉取下来。 事实上,如果你的服务器的磁盘坏掉了,你通常可以使用任何一个克隆下来的用户端来重建服务器上的仓库(虽然可能会丢失某些服务器端的挂钩设置,但是所有版本的数据仍在。 + +克隆仓库的命令格式是 +``` +git clone [url] 。 +``` +以Girls In AI 项目为例: +![在这里插入图片描述](https://camo.githubusercontent.com/e50df43a1233954e575e82a94dce10bc6ed5fdd7/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313137353130323635352e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) +![在这里插入图片描述](https://camo.githubusercontent.com/a320bfcdb7088ba14549af3564542001abb066de/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313137353230303534362e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) +之后在命令行输入 +``` +git clone https://github.com/Jane-QinJ/Girls-In-AI.git +``` +Git 支持多种数据传输协议。 上面的例子使用的是 https:// 协议,不过你也可以使用 git:// 协议或者使用 SSH 传输协议,比如 user@server:path/to/repo.git 。 + +### Recording Changes to the Repository +记录每次更新到仓库 + +这个算是版本控制最常用的功能了, 就是记录你的每一次修改。 你还可以为每一次修改添加必要的批注, 每一次的修改都会以快照的形式记录, 所以随时可以恢复成上一状态。 + +再回顾上面的图,使用 Git 时文件的生命周期如下: +![The life cycle of Git's file](https://camo.githubusercontent.com/20b4bc002beaec8811d3b373d75ad677b57e43b2/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313138303030373232372e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) +下面详细介绍一下这几个Git中的文件状态: + +Remember that each file in your **working directory** can be in one of two states: **tracked or untracked.** +请记住,你工作目录下的每一个文件都不外乎这两种状态:**已跟踪或未跟踪。* +- Tracked files are files that were in the last snapshot; they can be unmodified, modified, or staged. In short, tracked files are files that Git knows about. +已跟踪(Tracked )的文件是指那些被纳入了版本控制的文件,在上一次快照中有它们的记录,在工作一段时间后,它们的状态可能处于未修改(unmodified),已修改(modified)或已放入暂存区(staged)。 +- Untracked files are everything else — any files in your working directory that were not in your last snapshot and are not in your staging area. When you first clone a repository, all of your files will be tracked and unmodified because Git just checked them out and you haven’t edited anything. +工作目录中除已跟踪文件以外的所有其它文件都属于未跟踪文件(untracked),它们既不存在于上次快照的记录中,也没有放入暂存区。 初次克隆某个仓库的时候,工作目录中的所有文件都属于已跟踪文件,并处于未修改状态。 + +As you edit files, Git sees them as modified, because you’ve changed them since your last commit. As you work, you selectively stage these modified files and then commit all those staged changes, and the cycle repeats. +编辑(edit)过某些文件之后,由于自上次提交后你对它们做了修改,Git 将它们标记为已修改文件(modified)。 我们逐步将这些修改过的文件放入暂存区(staging area),然后提交(commit)所有暂存了的修改,如此反复。所以使用 Git 时文件的生命周期如上图。 + +简而言之, 当你增加一个没有进行git add的文件, 它就是untracked状态。 +而如果你修改了一个你已经跟踪(tracked)的文件, 它就会变为modified状态。 进一步, 你将这个修改过的文件通过**git add【文件名】** 加入了staging area, 这时它就可以被提交(commit)了。 +最后, 你要将这个提交, push到你的GitHub上, 用git push. + +#### Checking the Status of Your Files(检查当前文件状态) +以上各种文件状态, 都是可以查看的, 用到的Git命令为: +``` +$ git status +``` +以我的为例 +![](https://camo.githubusercontent.com/5bfbba2994911c9120da638afe43416f2a639115/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313138313434323935342e706e67) +我的Git跟踪文件目前没有修改, 所以nothing to commit, working tree clean. +没有要提交的内容, working tree(工作目录)很干净。 + +现在我们新建一个文件, 它就是未被跟踪的(untracked) +![](https://camo.githubusercontent.com/5bbeb8c1de9c8d0c6060d7e1f3f452af6b8244bd/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f32303139303133313138313831303738302e706e67) +熟悉的问题, 看来我之前出现的问题就是在这里。 我新添加的文件仅仅在我本地的工作目录上(working dictionary), 但它要被提交到git directory才可以被Git控制。 + +推荐大家继续将Git的工作目录和Git的状态结合起来看。 +![](https://camo.githubusercontent.com/efc719d9d82bffa50cb9bb630fe97bf3cfce0758/68747470733a2f2f696d672d626c6f672e6373646e696d672e636e2f323031393031333131383232323931392e706e673f782d6f73732d70726f636573733d696d6167652f77617465726d61726b2c747970655f5a6d46755a33706f5a57356e6147567064476b2c736861646f775f31302c746578745f6148523063484d364c7939696247396e4c6d4e7a5a473475626d56304c314670626e4670626c52686557787663673d3d2c73697a655f31362c636f6c6f725f4646464646462c745f3730) +现在更加理解了, 我们工作的地方在本地文件夹, 也就是working directory. 而Git要对我们的文件夹进行监控与控制, 是在git directory, + +再重新回顾一下这三个工作区域的概念, 相信你会更加理解。 diff --git a/_sources/Computer Science/process_thread.md b/_sources/Computer Science/process_thread.md new file mode 100755 index 0000000..c9b0180 --- /dev/null +++ b/_sources/Computer Science/process_thread.md @@ -0,0 +1,45 @@ +--- +title: A gentle introduction to multithreading +date: 2019-01-13 19:19:18 +tags: +- multithreading +- learning note +--- +[线程知识介绍](https://www.internalpointers.com/post/gentle-introduction-multithreading) + +介绍了process(进程)与thread(线程) +概要:(稍后汉译加深理解) +### Processes and threads: naming things the right way +Modern operating systems can run multiple programs at the same time. That's why you can read this article in your browser (a program)(进程) while listening to music on your media player (another program). Each program is known as a process that is being executed. The operating system knows many software tricks to make a process run along with others, as well as taking advantage from the underlying hardware. Either way, the final outcome is that you sense all your programs to be running simultaneously. + +Running processes in an operating system is not the only way to perform several operations at the same time. Each process is able to run simultaneous sub-tasks within itself, called **threads**(线程). You can think of a thread as a slice of the process itself. Every process triggers at least one thread on startup, which is called the main thread. Then, according to the program/programmer's needs, additional threads may be started or terminated. **Multithreading**(多线程) is about running multiple threads withing a single process. + +For example, it is likely that your media player runs multiple threads: one for rendering the interface — this is usually the main thread, another one for playing the music and so on. + +You can think of the operating system as a container that holds multiple processes, where each process is a container that holds multiple threads. In this article I will focus on threads only, but the whole topic is fascinating and deserves more in-depth analysis in the future. + +![1. Operating systems can be seen as a box that contains processes, which in turn contain one or more threads.](https://raw.githubusercontent.com/monocasual/internalpointers-files/master/2019/02/processes-threads.png) + +### The differences between processes and threads +Each process has its own chunk of memory assigned by the operating system. By default that memory cannot be shared with other processes: your browser has no access to the memory assigned to your media player and vice versa[/ˌvaɪsə ˈvə..sə/ adv. 反过来也一样]. The same thing happens if you run two instances of the same process, that is if you launch your browser twice. The operating system treats each instance as a new process with its own separate portion of memory assigned. So, by default, **two or more processes have no way to share data**, unless they perform advanced tricks — the so-called [inter-process communication (IPC).] +(https://en.wikipedia.org/wiki/Inter-process_communication) +Unlike processes, **threads share the same chunk of memory** assigned to their parent process by the operating system: data in the media player main interface can be easily accessed by the audio engine and vice versa. Therefore is easier for two threads to talk to eachother. On top of that(最重要的是), **threads are usually lighter than a process**: they take less resources and are faster to create, that's why they are also called *lightweight processes.* + +Threads are a handy(便利的) way to make your program perform multiple operations at the same time. Without threads you would have to write one program per task, run them as processes and synchronize them through the operating system. This would be more difficult (IPC is tricky) and slower (processes are heavier than threads). + +### Green threads, of fibers +Threads mentioned so far are an operating system thing: a process that wants to fire a new thread has to talk to the operating system. Not every platform natively support threads, though. Green threads, also known as fibers are a kind of emulation that makes multithreaded programs work in environments that don't provide that capability. For example a virtual machine might implement green threads in case the underlying operating system doesn't have native thread support. + +Green threads are faster to create and to manage because they completely bypass the operating system, but also have disadvantages. I will write about such topic in one of the next episodes. + +The name "green threads" refers to the Green Team at Sun Microsystem that designed the original Java thread library in the 90s. Today Java no longer makes use of green threads: they switched to native ones back in 2000. Some other programming languages — Go, Haskell or Rust to name a few — implement equivalents of green threads instead of native ones. + +### What threads are used for +Why should a process employ multiple threads? As I mentioned before, doing things in parallel greatly speed up things. Say you are about to render a movie in your movie editor. The editor could be smart enough to spread the rendering operation across multiple threads, where each thread processes a chunk of the final movie. So if with one thread the task would take, say, one hour, with two threads it would take 30 minutes; with four threads 15 minutes, and so on. + +Is it really that simple? There are three important points to consider: + +1. not every program needs to be multithreaded. If your app performs sequential operations or often waits on the user to do something, multithreading might not be that beneficial; +2. you just don't throw more threads to an application to make it run faster: each sub-task has to be thought and designed carefully to perform parallel operations; +3. it is not 100% guaranteed that threads will perform their operations truly in parallel, that is at the same time: it really depends on the underlying hardware. +The last one is crucial: if your computer doesn't support multiple operations at the same time, the operating system has to fake them. We will see how in a minute. For now let's think of concurrency as the perception of having tasks that run at the same time, while true parallelism as tasks that literally run at the same time. \ No newline at end of file diff --git a/_sources/Life/diary.md b/_sources/Life/diary.md index cb5d3aa..6e33f2c 100755 --- a/_sources/Life/diary.md +++ b/_sources/Life/diary.md @@ -12,6 +12,7 @@ 独立是我小时候的期望,慢慢实现的过程确实蛮难,却是必经之路吧。 时间还长,慢慢来好了。 take care. + :::{figure-md} markdown-fig 2023.12.13_0 @@ -20,7 +21,28 @@ take care. [](section-label) +## 2023.12.14 小雪 生活整理 +这几天重新搭个人网站,正好借机会梳理了自己的生活。昨天看了以前自己的日记,认真又努力,每次学新东西都很开心激动,每天自己鼓励自己,还蛮可爱的。 +虽然现在心态有所变化,对新鲜事物也没有那么兴奋,但好奇心还在,性格更加沉稳了,想的东西更多了,也蛮好的。 +每天写写日记有助于我的心变平静,这是这两天的明显感觉,可能是通过记录,发现每天的生活都是有迹可循的吧,给了自己一些实在的存在感,于是决定继续多写。 +昨天下午寸姐叫我们早些回家了,看来确实是弹性的上下班了一下,蛮开心感谢的。回家路上发现道路很干净,应该是撒了融雪剂。最近越来越能看到别人的劳动了,可能是开始参加工作,跟别人合作的机会多了,于是看到更多的东西,变得更谦虚感谢。之后做饭吃,陈老师最近加班比较累,抱抱、吃点小零食、一起吃吃辣条、看了一集神秘博士,想让她尽可能的放松一下。 +人累、紧张的时候反而会忘记怎么放松,但最需要放松。这时候身边的人帮助调整休息一下就好,现在对陈老师越来越熟悉了,能从她的小习惯、说话语气看出她今天心情怎么样。感觉她对我也是一样的。还是很神奇,我自己有时候陷入思维无法感知到自己的情绪好坏,但她一下就能知道我在生气还是开心。跟她在一起每天真是很幸福,希望能每天在一起。也许每天在身边比较难,但是只要她存在在这个世界上,都感觉多了一份很有意思的希望。 + +昨天还帮忙了亲戚家的妹妹挑选方向,大学生时候都对未来有所迷茫,因为还没有步入社会,对什么都不太清楚,想来当时的我也是那样的。帮助别人还是蛮开心的,说明这些年我都在成长吧。想来人的一生都是如此,不断的在成长,新陈更替、万物更新,大自然的法则如此,于是我还是得向前走才行。只是偶尔看看后来人,帮助提携一下,就像当时帮助我的温柔的人们一般。每每想到那些时刻,内心都很温暖,靠着这份温暖,还是继续扛着可能会越来越重的东西前行吧。 + +另外,也趁此机会回顾了下以往的计算机知识,人总会遗忘,以往的知识细节已经记不清了,但记得大体的框架,什么时候需要就再去学。最近的开发工作要我把以往的知识捡回来,熟练运用,于是还是得耐住性子重新看看才行。说来工作确实没什么意思,因为要求我变成一个对某部分功能重复熟练的部件,有固定输入和产出,可量化,重复注定没什么趣味,人性如此。但可能自己还是想成为一个社会上靠谱的人吧,贡献自己的绵薄之力,所以还是忍耐住了。跟年轻人接触一下也有助于自己自省,调整油滑的态度,哈哈。 + +最近我也有在学新知识,日语的学习进度虽然较慢,但一直在坚持。每天读读课文,坚持老师当时说的“少食多餐”,多重复就会记忆住。调整了生活作息之后,每晚抽出半小时到一小时的时间读课文、做例题。已经到了认清现实的年纪,人类社会发展到如今都是一步步积累而来的,每天踏踏实实学吧。每天把自己看一遍、把自己当成人类看一遍,自己待一会,放到社会中待一会。 + +劳逸结合,生活平衡。 +爱自己,爱世界。 + +:::{figure-md} markdown-fig +20231214_化雪了 + +暴雪道路也很干净(感谢劳动) +::: ## 2023.11.17 forget 病気 diff --git a/about me/Publications.html b/about me/Publications.html index 309c88a..1d91a15 100755 --- a/about me/Publications.html +++ b/about me/Publications.html @@ -154,6 +154,14 @@

Daily Life

+

Coding language

+ diff --git a/about me/short cv.html b/about me/short cv.html index d18d72c..42eae1d 100755 --- a/about me/short cv.html +++ b/about me/short cv.html @@ -154,6 +154,14 @@

Daily Life

+

Coding language

+ diff --git a/genindex.html b/genindex.html index 9256b11..c4d978c 100755 --- a/genindex.html +++ b/genindex.html @@ -153,6 +153,22 @@

Daily Life

+

Coding language

+ +

Java

+ +

C

+ diff --git a/intro.html b/intro.html index f951cb5..b6742fd 100755 --- a/intro.html +++ b/intro.html @@ -155,6 +155,22 @@

Daily Life

+

Coding language

+ +

Java

+ +

C

+ @@ -364,6 +380,28 @@

Welcome to JaneQin Space工作生活日记 + + +
+

C

+ +