树莓派更换apt-get源

1、树莓派的Raspbian系统是基于debian的嵌入式Linux系统,查看当前debian版本命令:

2、以10.0为例,更换apt-get源

注意:网址末尾的raspbian重复两次是必须的。因为Raspbian的仓库中除了APT软件源还包含其他代码。APT软件源不在仓库的根目录,而在raspbian/子目录下。

编辑镜像站后,请使用sudo apt-get update命令,更新软件源列表,同时检查您的编辑是否正确。

来自清华的镜像源:https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/

[……]

继续阅读

关于Cocoapods速度慢的问题,更换国内镜像源

CocoaPods 是一个 Cocoa 和 Cocoa Touch 框架的依赖管理器,具体原理和 Homebrew 有点类似,都是从 GitHub 下载索引,然后根据索引下载依赖的源代码。

对于旧版的 CocoaPods 可以使用如下方法使用 tuna 的镜像:

新版的 CocoaPods 不允许用pod repo add直接添加master库了,但是依然可以:

最后进入自己的工程,在自己工程的podFile第一行加上:

来自清华的链接:https://mirrors.tuna.tsinghua.edu.cn/help/CocoaPods/

[……]

继续阅读

随机存储实现动态数组ArrayList

1、List

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.yusian;
 
public interface List<e> {
 
	static final int ELEMENT_NOT_FOUND = -1;
	/**
	 * 获取数组长度
	 * @return 数组长度
	 */
	public int size();
 
	/**
	 * 是否为空
	 * @return true / false
	 */
	public boolean isEmpty();
 
	/**
	 * 是否包含某元素
	 * @param element
	 * @return true / false
	 */
	public boolean contains(E element);
 
	/**
	 * 添加元素,默认添加到末尾位置
	 * @param element
	 */
	public void add(E element);
 
	/**
	 * 获取元素
	 * @param index 索引
	 * @return 值
	 */
	public E get(int index);
 
	/**
	 * 替换元素
	 * @param index 索引
	 * @param element 元素
	 * @return 原元素内容
	 */
	public E set(int index, E element);
 
	/**
	 * 添加元素
	 * @param index 索引
	 * @param element 元素值
	 */
	public void add(int index, E element);
 
	/**
	 * 移除元素
	 * @return 返回被移除元素
	 */
	public E remove(int index);
 
	/**
	 * 获取元素索引
	 * @param element
	 * @return 索引
	 */
	public int indexOf(E element);
 
	/**
	 * 清除数组
	 */
	public void clear();
}
 
</e>

2、AbstractList


[……]

继续阅读

MySQL的基本优化

1、查询执行速度慢的sql语句

  • 查看当前“慢语句”标准:show variables like ‘%long%’
    mysql> show variables like '%long_query_time%';
    +-----------------+----------+
    | Variable_name   | Value    |
    +-----------------+----------+
    | long_query_time | 10.00000 |
    +-----------------+----------+
    1 row in set (0.00 sec)
    
    mysql> show variables like '%slow%';
    +---------------------------+--------------------------------+
    | Variable_name             | Value                          |
    +---------------------------+--------------------------------+
    | log_slow_admin_statements | OFF                            |
    | log_slow_slave_statements | OFF                            |
    | slow_launch_time          | 2                              |
    | slow_query_log            | ON                             |
    | slow_query_log_file       | /var/lib/mysql/ubuntu-slow.log |
    +---------------------------+--------------------------------+
    5 rows in set (0.00 sec)
    
  • 开启日志:set global slow_query_log = on;
  • 修改时间标准:set long_query_time = 0.5;
  • slow_query_log_file为日志文件所在路径;
  • 查看日志
    [……]

    继续阅读

索引

0、索引类型

  • 普通索引:index、key
  • 唯一索引:uniqe
  • 主键索引:primary key
  • 全文索引:fulltext(MyISAM引擎或InnoDB引擎v5.7及以上版本支持)

1、查看当前表创建

  • show create table user;
mysql> show create table user;
+-------+-------------------------------------------------------------------------------------------------------------------------[......]

继续阅读