VSCO FILM 00 FREE STARTER PACK

本文知乎专栏

VSCOCam 是 iOS 上一款滤镜相机,其最著名的地方就是他们的胶片滤镜。 而其实 VSCO 在这款 APP 之前,就一直在做胶片滤镜,有 OS X 和 WIN 两个平台的版本。最主要的是作为 LightRoom 的插件存在。

阅读更多

enlight VS snapseed2

image

本文知乎专栏地址

在 Enlight 出来之前,Snapseed 曾经是我最主要的修图工具。

当然,Enlight 确实是大而全的一款 App,但是使用中,却让我有了无法忍受的一点。那就是丢失部分图片信息。

导出的时候,Enlight 导出所用的格式是 PNG,而 Snapseed 仍然是 jpg 导出。自然大家都知道 PNG 图片所用的格式是无损的,这就是说,Snapseed 导出的图像相比 Enlight 要小很多,因为 iPhone 默认拍照所保存的都是 jpg 格式,所以即便再导出 PNG 格式,那所增加的部分应该是软件通过算法添加进去的。 而,Enlight 在导出的 PNG 格式图片里,却丢失了相机信息,地理位置信息和更重要的拍照时间信息。照片的时间被导出的时间所代替。

阅读更多

How to set up networkx in Chinese

Problem description

Hi, everynone,

when we use networkx to display Chinese, we will find that Chinese cannot be displayed.

Solution

  1. Download the font in the attachment;

    https://github.com/hivandu/practise/blob/master/resource/SimHei.ttf

  2. Execute in jupyter notebook

1
2
import matplotlib
print(matplotlib.__path__)

Find the path to matplotlib, and then cd to this path, after cd to this path, continue cd, cd to the path map-data/fonts/ttf. Then replace the file DejaVuSans,ttf with the file we just.

1
$ mv SimHei.ttf nx.draw(city_graph, city_location, with_labels = True, node_size = 10).ttf

Among them, the ttf font used. I have uploaded it to everyone.

sketch 中打开高版本文件

sketch 也不知道什么时候开始年费化了,也不能打开高版本文件了。(妈蛋)

据说是为了促进销量和保护版本。

打开包文件,然后打开包内的meta.json

替换头部:

1
{"commit":"335a30073fcb2dc64a0abd6148ae147d694c887d","appVersion":"43.1","build":39012

替换尾部

1
"commit":"335a30073fcb2dc64a0abd6148ae147d694c887d","build":39012,"appVersion":"43.1","variant":"NONAPPSTORE","version":88},"version":88,"saveHistory":["NONAPPSTORE.39012"],"autosaved":0,"variant":"NONAPPSTORE"}

这里实际有几个 key:commit, appVersion, build, version,NONAPPSTORE

value 替换成相应的值就 OK 了。

SQL 练习 1

-- UPPER 是转换大写的函数

1
SELECT emp_name,salary * 12, UPPER(email) FROM employee;

-- 使用别名

1
2
3
4
SELECT e.emp_name AS "姓名",
salary * 12 AS "12 月的工资",
UPPER(email) "电子邮箱"
FROM employee AS e;

-- 无表查询

1
2
3
4
5
6
7
SELECT 1+1;

-- Oracle 实现,dual 只有一个字段且只包含一行数据
SELECT 1+1
FROM dual;

SELECT * FROM employee WHERE emp_name = '刘备';

-- 比较运算符

1
2
3
select * from employee where sex <> '男'
select * from employee where salary BETWEEN 5000 and 7000
select * from employee where emp_name IN('刘备')

-- 一个时间段之后入职

1
2
3
4
5
6
7
select emp_name, hire_date from employee where hire_date > DATE '2018-01-01'

SELECT emp_name,hire_date,manager from employee where manager IS NULL

SELECT emp_name, sex, salary from employee where sex = '女' AND salary > 10000

SELECT emp_name, sex, salary FROM employee WHERE emp_name = '刘备' OR emp_name = '张飞' OR emp_name = '赵云'

-- 短路运算 short-circuit evaluation

1
2
3
4
5
select 'AND' FROM employee WHERE 1 = 0 AND 1/0 = 1;
SELECT 'OR' FROM employee where 1 = 1 OR 1/0 = 1;

-- NOT
select emp_id,emp_name FROM employee WHERE emp_name NOT IN('刘备','张飞','赵云')

-- 运算符优先级

1
2
3
SELECT emp_name,dept_id,bonus
FROM employee
WHERE (dept_id = 2 OR dept_id = 3) AND bonus IS NOT NULL;

-- 去处重复值

1
2
SELECT DISTINCT SEX FROM employee
SELECT DISTINCTROW sex from employee

/ 查找 2018 年 1 月 1 日之后入职,月薪小于 5000,并且奖金小于 1000(包括没有奖金)的员工。 /

1
2
3
4
5
SELECT emp_id,emp_name,salary,hire_date,bonus 
FROM employee
WHERE hire_date > '2018-01-01'
AND salary < 5000
AND (bonus < 1000 OR bonus IS NULL)

-- LIKE 运算符

1
2
3
4
5
6
7
SELECT emp_id,emp_name,sex
FROM employee
WHERE emp_name LIKE '赵%'

SELECT emp_name,email
FROM employee
WHERE email NOT LIKE 'dengzh_@shuguo.com';

-- 转义字符

1
2
3
4
5
6
7
8
9
10
11
CREATE TABLE t_like(c1 VARCHAR(20))
INSERT INTO t_like(c1) VALUES ('进度:25% 已完成')
INSERT INTO t_like(c1) VALUES ('日期:2019 年 5 月 25 日')

SELECT c1
FROM t_like
WHERE c1 LIKE "%25\%%"

SELECT c1
FROM t_like
WHERE c1 LIKE "%25#%%" ESCAPE '#'

-- 大小写匹配

1
2
3
SELECT emp_name,email
FROM employee
WHERE email LIKE 'M%'

-- 正则表达式 判断邮箱

1
2
3
4
5
6
7
8
9
10
11
/*
以字母或者数字开头;
后面是一个或者多个字母、数组或特殊字符( . _ - );
然后是一个 @ 字符;
之后包含一个或者多个字母、数组或特殊字符( . - );
最后是域名,即 . 以及 2 到 4 个字母。
^[a-zA-Z0-9]+[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$
*/

SELECT email FROM t_regexp
WHERE REGEXP_LIKE (email, BINARY '^[a-z0-9]+[a-z0-9._-]+@[a-z0-9.-]+\\.[a-z]{2,4}$','i');

-- 降序排序

1
2
3
4
select emp_name,salary,hire_date
from employee
where dept_id = 4
ORDER BY salary DESC;

-- 多列排序(工资,入职先后)

1
2
3
4
select emp_name,salary,hire_date
FROM employee
where dept_id = 4
ORDER BY salary DESC, hire_date;

-- 按照 SELECT 顺序

1
2
3
4
SELECT emp_name, salary, hire_date
FROM employee
WHERE dept_id = 4
ORDER BY 2 desc, 3

中文排序

-- CONVERT 是一个函数,用于转换数据的字符集编码。以下转换为中文 GBK 字符集

1
2
3
4
SELECT emp_name
from employee
WHERE dept_id = 4
ORDER BY CONVERT(1 USING GBK)

-- 空值排序

1
2
3
4
select emp_name,bonus
from employee
where dept_id = 2
ORDER BY 2

-- 其他空值排序方法

1
2
3
4
5
-- COALESCE 函数将控制转换为一个指定的值
SELECT emp_name, COALESCE(bonus,0) AS bonus
FROM employee
where dept_id = 2
ORDER BY COALESCE(bonus,0);

/ 第六节练习: 查询所有的员工信息,按照员工的总收入(年薪加奖金)从高到低进行排序,总收入相同再按照姓名的拼音顺序排序。 /

1
2
3
4
SELECT emp_name, salary, bonus, (salary+bonus) as sum
FROM employee
WHERE dept_id >= 0
ORDER BY (salary+bonus) DESC, CONVERT(1 USING GBK)

-- TopN 排行榜

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- 标准 FETCH 语法,此语法 MySQL 不支持,Oracle, PostgreSQL 支持
SELECT emp_name, salary
FROM employee
ORDER BY salary DESC
OFFSET 0 ROWS
FETCH FIRST 5 ROWS ONLY;

-- LIMIT 实现 TOPN 排行榜
SELECT emp_name, salary
FROM employee
ORDER BY salary DESC
LIMIT 5 OFFSET 0;

-- 第二种写法
SELECT emp_name,salary
FROM employee
ORDER BY salary DESC
LIMIT 0,5

-- SQL 实现分页查询

1
2
3
4
SELECT emp_name, salary
FROM employee
ORDER BY salary DESC
LIMIT 10,5

-- 员工排名第 3 高

1
2
3
4
5
6
7
8
9
select emp_name,salary 
FROM employee
WHERE salary = (
select salary from employee
ORDER BY salary DESC LIMIT 2,1)

SELECT emp_name,salary
FROM employee
ORDER BY salary desc limit 5 offset 10;

/ 练习:使用 LIMIT 和 OFFSET 找出员工表中月薪排名第三高的所有员工 /

1
2
3
4
5
6
select emp_name, salary 
FROM employee
where salary = (
select salary
FROM employee
ORDER BY salary desc limit 1 offset 2)

AI ability practice

Including core capabilities, BI and algorithm related, Code warehouse: 【AI Basic](https://github.com/hivandu/practise/tree/master/AI-basic)

A Preliminary Study of Machine Learning

Gradient

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def loss(k):
return 3 * (k ** 2) + 7 * k -10

# -b / 2a = -7 / 6

def partial(k):
return 6 * k + 7

k = ramdom.randint(-10, 10)
alpha = 1e-3 # 0.001

for i in range(1000):
k = k + (-1) * partial(k) * alpha
print(k, loss(k))

Introduction to Artificial Intelligence

The code address of this article is: Example 01

The source code is in ipynb format, and the output content can be viewed.

rule based

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
import random 
from icecream import ic


#rules = """
#复合句子 = 句子 , 连词 句子
#连词 = 而且 | 但是 | 不过
#句子 = 主语 谓语 宾语
#主语 = 你| 我 | 他
#谓语 = 吃| 玩
#宾语 = 桃子| 皮球
#
#"""

rules = """
复合句子 = 句子 , 连词 复合句子 | 句子
连词 = 而且 | 但是 | 不过
句子 = 主语 谓语 宾语
主语 = 你| 我 | 他
谓语 = 吃| 玩
宾语 = 桃子| 皮球

"""

def get_grammer_by_description(description):
rules_pattern = [r.split('=') for r in description.split('\n') if r.strip()]
target_with_expend = [(t, ex.split('|')) for t, ex in rules_pattern]
grammer = {t.strip(): [e.strip() for e in ex] for t, ex in target_with_expend}

return grammer

#generated = [t for t in random.choice(grammer['句子']).split()]

#test_v = [t for t in random.choice(grammer['谓语']).split()]


def generate_by_grammer(grammer, target='句子'):
if target not in grammer: return target

return ''.join([generate_by_grammer(grammer, t) for t in random.choice(grammer[target]).split()])

if __name__ == '__main__':

grammer = get_grammer_by_description(rules)

#ic(generated)
#ic(test_v)
#ic(generate_by_grammer(grammer))
ic(generate_by_grammer(grammer, target='复合句子'))

water pouring

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
def water_pouring(b1, b2, goal, start=(0, 0)):
if goal in start:
return [start]

explored = set()
froniter = [[('init', start)]]

while froniter:
path = froniter.pop(0)
(x, y) = path[-1][-1]

for (state, action) in successors(x, y, b1, b2).items():
if state not in explored:
explored.add(state)

path2 = path + [(action, state)]

if goal in state:
return path2
else:
froniter.append(path2)

return []


def successors(x, y, X, Y):
return {
((0, y+x) if x + y <= Y else (x + y - Y, Y)): 'X -> Y',
((x + y, 0) if x + y <= X else (X, x + y - X)): 'X <- Y',
(X, y): '灌满 X',
(x, Y): '灌满 Y',
(0, y): '倒空 X',
(x, 0): '倒空 Y',
}


if __name__ == '__main__':
print(water_pouring(4, 9, 5))
print(water_pouring(4, 9, 5, start=(4, 0)))
print(water_pouring(4, 9, 6))