一些总结

Git 取消上传文件

  1. 放弃对文件的修改 git checkout

  2. 假定没有修改文件 git update-index –assume-unchanged sdk_version.properties

SQLite notice

index 从 1 开始

fresco多图加载,缩略图预览

1
2
3
4
5
6
7
8
9
10
ImageRequest request = ImageRequestBuilder
.newBuilderWithSource(Uri.fromFile(new File(fileName)))
.setLocalThumbnailPreviewsEnabled(true)
.setResizeOptions(new ResizeOptions(DensityUtil.dip2px(context,120), DensityUtil.dip2px(context,120)))
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(mSimpleDraweeView.getController())
.build();
mSimpleDraweeView.setController(controller);

重点在于缩放

1
setResizeOptions(new ResizeOptions(DensityUtil.dip2px(context,120), DensityUtil.dip2px(context,120)))

Git多用户配置

Git

公司配置了自己的私有gitlab ssh,同时学校有课题需要协作,于是参考一些文档做了多用户配置。

在.ssh/文件夹下生成github.com对应的私钥公钥

执行命令 ssh-keygen -t rsa -C id_rsa_github 创建github对应的sshkey

1
ssh-keygen -t rsa -C id_rsa_github

同样的方式生产gitlab的私钥公钥

执行命令ssh-keygen -t rsa -C id_rsa_gitlab 创建gitlab对应的sshkey

1
ssh-keygen -t rsa -C id_rsa_gitlab

把github对应的公钥和gitlab对应的公钥上传到服务器

略略略

在.ssh目录创建config文本文件并完成相关配置

1
2
3
4
HostName         这个是真实的域名地址
IdentityFile         这里是id_rsa的地址
PreferredAuthentications 配置登录时用什么权限认证--可设为publickey,password publickey,keyboard-interactive等
User            配置使用用户名

例如下

1
2
3
4
5
6
7
8
9
10
11
12
13
# 配置github.com
Host github.com
HostName github.com
IdentityFile C:\\Users\\popfisher\\.ssh\\id_rsa_github
PreferredAuthentications publickey
User username1
# 配置git.oschina.net
Host gitlab.com
HostName gitlab.com
IdentityFile C:\\Users\\popfisher\\.ssh\\id_rsa_gitlab
PreferredAuthentications publickey
User username2

测试命令测试是否配置成功

1

常见问题

出现Could not open a connection to your authentication agent

解决方法有三种

(a) 先输入ssh-agent bash,然后再输入ssh-add ~/.ssh/id_rsa_hason;

(b)先输入eval $(ssh-agent),然后输入ssh-add ~/.ssh/id_rsa_hason;

(c)使用Git GUI生成密钥,密钥会自动被加进ssh-agent中;

Git

leedcode Combination Sum

Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.

The same repeated number may be chosen from C unlimited number of times.

Note:
All numbers (including target) will be positive integers.
The solution set must not contain duplicate combinations.
For example, given candidate set [2, 3, 6, 7] and target 7,
A solution set is:

1
2
3
4
[
[7],
[2, 2, 3]
]

code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Solution:
def DFS(self, candidates, target, start, valuelist):
length = len(candidates)
if target == 0:
return Solution.ret.append(valuelist)
for i in range(start, length):
if target < candidates[i]:
return
self.DFS(candidates, target - candidates[i], i, valuelist + [candidates[i]])
def combinationSum(self, candidates, target):
candidates.sort()
Solution.ret = []
self.DFS(candidates, target, 0, [])
return Solution.ret

leedcode Count and Say

Count and Say

The count-and-say sequence is the sequence of integers with the first five terms as following:

1
2
3
4
5
1. 1
2. 11
3. 21
4. 1211
5. 111221

1 is read off as “one 1” or 11.
11 is read off as “two 1s” or 21.
21 is read off as “one 2, then one 1” or 1211.
Given an integer n, generate the nth term of the count-and-say sequence.

code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Solution:
# @return a string
def count(self,s):
t=''; count=0; curr='#'
for i in s:
if i!=curr:
if curr!='#':
t+=str(count)+curr
curr=i
count=1
else:
count+=1
t+=str(count)+curr
return t
def countAndSay(self, n):
s='1'
for i in range(2,n+1):
s=self.count(s)
return s

leedcode Regular Expression Matching

Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

You may assume no duplicates in the array.

Here are few examples.
[1,3,5,6], 5 → 2
[1,3,5,6], 2 → 1
[1,3,5,6], 7 → 4
[1,3,5,6], 0 → 0

code

1
2
3
4
5
6
7
8
9
10
11
12
class Solution(object):
def searchInsert(self, A, target):
left = 0; right = len(A) - 1
while left <= right:
mid = ( left + right ) / 2
if A[mid] < target:
left = mid + 1
elif A[mid] > target:
right = mid - 1
else:
return mid
return left

线代 范数

在机器学习中,经常使用范数函数衡量向量。

表示为||x||(略去了下标)。直观理解是点x到原点的距离。

其中,L2范数又可以称为欧几里得距离。

当下标为无穷时,表示向量中具有最大增幅的元素的值。