上传文件

scp ./upload/path/file.postfix user@host.com:/path/to/file
# 文件夹
scp -r ./upload/path/folder user@host.com:/path/to/folder

下载文件

scp user@host.com:/path/to/file.postfix ./download/path
# 文件夹
scp -r user@host.com:/path/to/folader ./download/path

0.0 PTA实录

0.1.1 最大子列和plus

  • 如何利用语句先后顺序记录上一条信息pre_start_tag
void sum_max_sequence(void)
{
long long int this_sum, max_sum;
int start_tag, end_tag, pre_start_tag, neg_tag;

start_tag = pre_start_tag = end_tag = 0;
this_sum = max_sum = 0;
neg_tag = 1;

for (int i = 0; i < num; i++)
{
if (list[i] >= 0) {
neg_tag = 0;
}
this_sum += list[i];
if (this_sum > max_sum)
{
max_sum = this_sum;
end_tag = i;
pre_start_tag = start_tag; // 我没有想到的代码!
}
if (this_sum < 0)
{
this_sum = 0;
start_tag = i+1;
}
}


if(neg_tag) // 输出0,第一个和最后一个数
printf("%lld %d %d\n", max_sum, list[0], list[num-1]);
else if (max_sum == 0)
{
printf("0 0 0\n");
}

else
printf("%lld %d %d\n", max_sum, list[pre_start_tag], list[end_tag]);
}
阅读全文 »

网络搜索

网站 URL 备注
哔哩哔哩 https://search.bilibili.com/all?keyword={query}
知乎 https://www.zhihu.com/search?type=content&q={query}
百度贴吧 https://tieba.baidu.com/f?ie=utf-8&kw={query}&fr=search 优先搜索吧名
小红书 https://www.xiaohongshu.com/search_result?keyword={query}&source=web_search_result_notes 需要登录
淘宝 https://s.taobao.com/search?q={query}&commend=all&search_type=item&sourceId=tb.index&ie=utf8
京东 https://search.jd.com/Search?keyword={query}&enc=utf-8
咸鱼 https://www.goofish.com/search?q={query}
Yandex https://yandex.com/search/?text={query}
GitHub https://github.com/search?q={query}&type=repositories
tldr https://tldr.inbrowser.app/pages/common/{query} mannual查Linux命令
必应翻译 https://cn.bing.com/translator?ref=TThis&text={query}&from=en&to=zh-Hant 英译中
DeepL翻译 https://www.deepl.com/translator#en/zh/{query} 英译中
Wiki外部网站 https://encyclopedia.thefreedictionary.com/{query}
求闻百科 https://www.qiuwenbaike.cn/wiki/{query}
Wolfram|Alpha https://www.wolframalpha.com/input?i={query}&lang=zh
  • 有时候站内搜索没有搜索引擎准确,可以使用搜索引擎过滤网站
    过滤站点:
http://<ENGINE.URL>/search?text=site%3A<SITE.URL>%20{query}

启动应用

功能 路径 参数
当前目录启动终端 wt.exe -d “{current_folder}”
Golden Dict查词 GoldenDict.exe -s {query}
启动ipython wt.exe ipython
查看网络连接 control.exe ncpa.cpl
编辑环境变量(需要管理员权限) rundll32 sysdm.cpl,EditEnvironmentVariables

信息系统架构

  • 信息化系统:前台 + 后台 + 数据库
  • B/S 模式
  • 前端 -> Server[Apache->PHP(TP6.0)] -> SQL DataBase
  • 运行逻辑:
    • Client发送require请求(http协议),包含header(length、refer信息)、body(数据)
    • Apache接受请求,给PHP做处理
    • PHP读取、处理数据;判断数据是否损毁、是否需要退回
    • 数据更新到前端,并返回结果(success/fail)
阅读全文 »

策略模式

class MallardDuck extends Duck {
public MallardDuck() {
quackBehavior = new Quack();
flyBehavior = new FlyWithWings();
}
}

class ModelDuck extends Duck {
public ModelDuck() {
quackBehavior = new Quack();
flyBehavior = new FlyNoWay(); // 组合不同的方法
}
}

class Main {
public static void main(String[] args) {
Duck real = new MallardDuck();
Duck model = new ModelDuck();

real.fly();
model.fly(); // 调用同样的接口
}
}

识别应用中变化的方面,把它们和不变的方面分开。

针对接口编程,而不是针对实现编程。

// Implement
Dog d = new Dog();
d.bark();

// Interface
Animal dog = new Dog();
dog.makeSound(); // abstract

优先使用组合而不是继承。

summary

策略模式定义了算法族并分别封装。策略让算法变化独立于使用它的客户。

阅读全文 »

DevTools

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>

Spring CLI

可以用Spring Initializr或Spirng CLI来构建项目

spring init -list # 列出参数
# 初始化项目
spring init ( -d || --dependencies ) package1,package2 --build (maven/gradle) ( -p || --package) (war/jar) projectName
# Example
spring init -d web,jpa,security --build maven -p jar basic-project

spring init -d web,mustache,jpa,h2,devtools --package-name=com.example.blog --build maven mybloge
  • Web: API服务
  • JPA: 访问数据库的抽象
    项目结构图
$ tree basic-project/
basic-project/
├── HELP.md
├── mvnw # maven wrapper附带脚本
├── mvnw.cmd
├── pom.xml # maven 构建配置文件
└── src
├── main
│   ├── java
│   │   └── com
│   │   └── example
│   │   └── basic_project
│   │   └── DemoApplication.java # 入口
│   └── resources
│   ├── application.properties # Configuration
│   ├── static # 存放js/css,images
│   └── templates # 存放页面模板
└── test
└── java
└── com
└── example
└── basic_project
└── DemoApplicationTests.java

15 directories, 7 files

Maven

换源

distributionUrl=https://maven.aliyun.com/repository/central/org/apache/maven/apache-maven/(edition.number)/apache-maven-(edition.number)-bin.zip

运行项目

mvn spring-boot:run
# 将会在localhost:8080运行

“When in doubt go to the library.” – J.K.Rowling

Catalog

Article1: What Are You Going to Do With That?

What Are You Going to Do With That?

William Deresiewicz(《国家》杂志撰稿人和《新共和》杂志编辑)在斯坦福大学的演讲

The question my title poses, of course, is the one that is classically aimed at humanities majors. What practical value could there possibly be in studying literature or art or philosophy? So you must be wondering why I’m bothering to raise it here, at Stanford, this renowned citadel of science and technology. What doubt can there be that the world will offer you many opportunities to use your degree?

(学习文学、艺术或哲学能有什么用呢?所以你肯定纳闷,我为什么在在以科技堡垒而闻名的斯坦福提出这个问题呢?在大学学位给人带来众多机会的问题上还有什么可怀疑的吗?)

But that’s not the question I’m asking. By “do” I don’t mean a job, and by “that” I don’t mean your major. We are more than our jobs, and education is more than a major. Education is more than college, more even than the totality of your formal schooling, from kindergarten through graduate school. By “What are you going to do,” I mean, what kind of life are you going to lead? And by “that,” I mean everything in your training, formal and informal, that has brought you to be sitting here today, and everything you’re going to be doing for the rest of the time that you’re in school.

(但那不是我提出的问题。这里的“做”并不是指工作,“那”并不是指你的专业。我们不仅仅是要个工作,教育不仅仅是学一门专业。教育也不仅仅是上大学,甚至也不仅是从幼儿园到研究生院的正规学校教育。我说的“你要做什么”的意思是你要过什么样的生活?我所说的“那”指的是你得到的正规或非正规的任何训练, 那些把你送到这里来的东西,你在学校的剩余时间里将要做的任何事。)

阅读全文 »

Hash

字母异位词

排序每一个单词,就知道是不是异位词。

两数之和

从数组中,找到nums[i] + nums[j] == target,并返回{ i, j }
思路是双重循环,遍历每一个元素,求和是否为target。
然而,双重循环需要O(N2)O(N^2)的复杂度。因此,可以使用一张表,使用containsKey方法识别是否存在当前i的target - nums[i],即可减少一重循环。

关键思想

用Map高效率查找,减少一重循环。

最长连续序列

从乱序数组中,找到最长连续(数组中不一定连续)的序列。要求O(N)O(N)
首先用数组的值存入哈希表,然后遍历数组,判断map.constains(curNum++)
然而,即使这样还是效率不够高。

优化

  1. 中间值不进入循环,序列开始值才进入,使用!contains(curNum - 1)判断是否为序列开始值
  2. 去重,不要哈希表,不需要键值对,使用哈希Set,只存储值。

关键思想

去重;不处理中间值

阅读全文 »

1.0 Bar 柱状图

from pyecharts.charts import Bar

bar = Bar()
bar.add_xaxis(["衬衣", "羊毛衫", "西装", "裤子", "鞋子", "袜子"])
bar.add_yaxis("商家", [5, 20, 40, 10, 70, 90])
# 相当于
bar = (
Bar()
.add_xaxis(["衬衣", "羊毛衫", "西装", "裤子", "鞋子", "袜子"])
.add_yaxis("商家", [5, 20, 40, 10, 70, 90])
.add_yaxis("商家B", [15, 6, 45, 20, 35, 66]) # 支持两个柱子同时生成
.set_global_opts(title_opts=opts.TitleOpts(title="主标题", subtitle="副标题")) # 生成标题
)


bar.render("bar.html") # 渲染为 bar.html,默认是 render.html
  • 效果
阅读全文 »

Author:aatalyk
Origin:Link

Before starting the topic let me introduce myself. I am a Mobile Developer currently working in Warsaw and spending my free time for interview preparations. I started to prepare for interviews two years ago. At that time I should say I could not solve the two sum problem. Easy problems seemed to me like hard ones so most of the time I had to look at editorials and discuss section. Currently, I have solved ~800 problems and time to time participate in contests. I usually solve 3 problems in a contest and sometimes 4 problems. Ok, lets come back to the topic.

Recently I have concentrated my attention on Dynamic Programming cause its one of the hardest topics in an interview prep. After solving ~140 problems in DP I have noticed that there are few patterns that can be found in different problems. So I did a research on that and find the following topics. I will not give complete ways how to solve problems but these patterns may be helpful in solving DP.

Patterns

  1. Minimum (Maximum) Path to Reach a Target
  2. Distinct Ways
  3. Merging Intervals
  4. DP on Strings
  5. Decision Making
阅读全文 »
0%