新建窗口: start .打开cmd所在的窗口,或者说open windows Explorer from cmd prompt here.
相反方向的话直接在地址栏中输入cmd.即可打开该窗口对应的cmd窗口。
copy filename1 filename2
以下桌面系统是在默认状态下. Gnome(Ubuntu): 使用命令:
nautil .
Xfce(debian):
xdg-open .
考虑这样一个场景:一个公司围绕一个产品开发了主分支-master,当然,不可能每个 人都在主分支上做开发对不对,好,我们使用PR进行多部门的开发.
请注意,下面2-4步,是基于自己在github建立的git 仓库的事实,如果你想为其他开源软件做贡献,肯定不行,请看 给他人提交pull request
首先要Frok别人的repo,fork, fork.
首先,先克隆一个git仓库,这个不用说太多。我以自己的仓库为例,进行代码演示。
git clone https://github.com/yuzibo/yuzibo.github.io.git
正克隆到 'yuzibo.github.io'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 2931 (delta 2), reused 8 (delta 2), pack-reused 2922
接收对象中: 100% (2931/2931), 1010.61 KiB | 502.00 KiB/s, 完成.
处理 delta 中: 100% (1939/1939), 完成.
当然,这个时候默认为master主分支。
cd yuzibo.github.io/
yubo@debian:~/yuzibo.github.io$ git branch
* master
这个分支就是你自己要开发的分支,记住一点,实时的rebase master分支。
git checkout -b test-pr
git rebase origin/master # 首先在主分支使用fetch
在你开发完成后,为了将自己的工作合并到主分支中,需要产生request pull,让维护人接受你的改变。
这里的使用是标准的git开发流程git add && commit.接下来,在你的开发分支上,使用以下命令,我们可以看到:
git push -u
fatal: 当前分支 test-pr 没有对应的上游分支。
为推送当前分支并建立与远程上游的跟踪,使用
git push --set-upstream origin test-pr
提示的非常明显,第一步,我以github网站为例,首先在网站上合并rp,另外一种是命令行。
上面的提示命令我简写一步:
git push -u origin test-pr
对象计数中: 4, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (4/4), 完成.
写入对象中: 100% (4/4), 624 bytes | 0 bytes/s, 完成.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: Create a pull request for 'test-pr' on GitHub by visiting:
remote: https://github.com/yuzibo/yuzibo.github.io/pull/new/test-pr
remote:
To https://github.com/yuzibo/yuzibo.github.io.git
* [new branch] test-pr -> test-pr
分支 test-pr 设置为跟踪来自 origin 的远程分支 test-pr。
这个提示就说明在网站上有了rp请求,现在我的图床没法使用了,图片就先不适用了。你可以到github的仓库上去看一下,根据提示你应该没问题的,有问题的话,可以再找我咨询。
有人会问这个request pull不一定找得到,根据提示你就可以访问URL即可。 下面我贴一些详细的命令,效果是类似的.
git push --set-upstream origin test-pr
对象计数中: 4, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (4/4), 完成.
写入对象中: 100% (4/4), 1.84 KiB | 0 bytes/s, 完成.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote:
remote: Create a pull request for 'test-pr' on GitHub by visiting:
remote: https://github.com/yuzibo/yuzibo.github.io/pull/new/test-pr
remote:
To https://github.com/yuzibo/yuzibo.github.io.git
* [new branch] test-pr -> test-pr
分支 test-pr 设置为跟踪来自 origin 的远程分支 test-pr。
这里就是更新你的master.其他的分支接着跟进.
git checkout master
git fetch origin master
git rebase origin/master
上面我说了,是基于自己的github账号,没有权限问题,但是他人的git 仓库恐怕不行。这个问题,你需要先fork之后才可以.下面我以自己的例子说明这个操作。
首先在github fork别人的仓库,这样在你的github主页上就会显示fork的仓库。
#1 I forked the https://github.com/netoptimizer/prototype-kernel
#2 prototype-kernel
Forked from netoptimizer/prototype-kernel
Prototyping kernel development work outside mainline
# 或者
yuzibo/prototype-kernel
forked from netoptimizer/prototype-kernel
接着clone 在你github上的forked git 仓库,记住,不是原官方仓库。
https://github.com/yuzibo/prototype-kernel.git
接着创建一个产生pull request
的分支。
git checkout -b test
接下来就是你自己commited自己的修改就可以了。
git push origin -u test
就可以,这时候在你的github(你forked的仓库)上就有了test
分支,此时他会提示你产生pull request
的。
这个提示经常在github上的PR log中见到的问题。也就是比如,你的pull branch需要修改,就会遇到此类的问题。我这里找到一个(网页)[https://blog.adamspiers.org/2015/03/24/why-and-how-to-correctly-amend-github-pull-requests/],介绍的有点过于理论,还可以参考这个网页我是这样操作的:
在已经 pull request的分支上,你的commmit已经保留。然后在位于HEAD的commit
#1 --amend commit
git commit --amend
# --amend不会产生新的commit id,是在原commit上的修改
#2 git add
git add -A
#3 git push
git push -f origin HEAD
对象计数中: 6, 完成.
Delta compression using up to 12 threads.
压缩对象中: 100% (5/5), 完成.
写入对象中: 100% (6/6), 616 bytes | 616.00 KiB/s, 完成.
Total 6 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/yuzibo/connectedhomeip.git
+ 5794aea16...39d62156c HEAD -> fix_install_dep (forced update)
这样,就算你已经push到原git repo,这样的push commit后,新的commit就已经上传到你的pull request上了。
上面的步骤是通过网站,这可能对于有些人来说不是很友好,下面介绍下如何通过命令行进行开发.
首先,这个操作和上面的想法不太一样,来自stackoverflow。思路就是将自己开发分支的特性合并到master上去,让别人审阅master分支,而不是自己的开发分支。如下面这种情况:
A---B---C feature/awesomeFeature
/
D---E---F---G origin/master
master
使用下面的命令即可完成这个工作.
git request-pull origin/master feature/awesomeFeature
对于我的开发来说就是这个样子的:
git request-pull origin/master test-prfatal: 'test-pr' does not appear to be a git repository
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。
warn: No match for commit c3165d2416cdde49be09334f531e58379172567b found at test-pr
warn: Are you sure you pushed 'HEAD' there?
The following changes since commit c3165d2416cdde49be09334f531e58379172567b:
Merge pull request #5 from yuzibo/test-pr (2018-11-02 10:57:30 +0800)
are available in the git repository at:
test-pr
for you to fetch changes up to c3165d2416cdde49be09334f531e58379172567b:
Merge pull request #5 from yuzibo/test-pr (2018-11-02 10:57:30 +0800)
然后你在master分支里,就看到最新的变化了,这样就省掉了网站request pull这一步。但是,如果你的开发分支不在同一个工作区如何操作?比如说两个电脑这种情况?
首先声明一下,我的libvirt是通过源码安装的,如果你在安装的时候没有通过一些正确的设定, 很有可能会导致启动困难。
意思很明确,就是virtlogd-sock文件没有开启,这种情况典型的就是你在源码安装时没有使用daemon进行,每一次机器开关机时都无法自动启动该进程。
这里,应该使用systemctl命令,
sudo systemctl start virtlockd[tab补全]
virtlockd-admin.socket virtlockd.service virtlockd.socket
启动这个socket服务就行了。
针对上面的这个问题,libvirt的维护人说:
we have a systemd unit so you can enable that
Update: 目前不知道为什么我没有开启这个systemd unit,暂时还是使用service
命令。
service libvirtd restart
也可以解决上面的问题
目前,本人的理解的就是系统带来的库工具,目前都放在内核的tools
目录下。
例如,这个bpftools
工具就可以提供一个调试、探视内核中由eBPF
产生的map.
cd ~/git/linux/tools/bpf/bpftool/
sudo make
sudo make install
具体的用法可以在后面具体展示。
$ cd tools/testing/selftests/bpf/
$ make
$ sudo ./test_verifier
如果有问题,说明需要检查kernel config文件是否完全适配
位于tools/lib/bpf
.这个库很明显就是为了加载eBPF程序,当然,FB工程师也维护了一个github
git submodule add https://github.com/libbpf/libbpf/ libbpf
将这个添加到自己练习的项目。后面使用:
git submodule update --init
If you want to learn what type of ebpf program is supported, you can use:
git grep -W 'bpf_prog_type {' include/uapi/linux/bpf.h
in kernel tree source code.
git grep -W 'bpf_map_type {' include/uapi/linux/bpf.h
“-W” is matching the substring in the text.
Listing the drivers the XDP supported:
git grep -l XDP_SETUP_PROG drivers/
git grep 'FN(' include/uapi/linux/bpf.h
Imap协议与Pop3协议相比,还是具有很大的优势,这样就可以实现多个终端管理邮件而且实时同步。
Neomutt是基于mutt的一款开源软件,可以这么说,mutt实现的功能,Neomutt都有;Neomutt实现的功能,mutt不一定具备。
众所周知,Imap与Gmail配合的天衣无缝,后者就在开发者中占有一个重要的地位,那么,国内邮箱126、或者qq邮箱可以实现这样的功能吗?
经过一番探索,mutt也可以使用Imap收发国内邮箱(仅测试126本文).
如果在软件管理器安装Neomutt(或者mutt)是很容易的一件事,但是,如果想要更丰富的特性,则最好从源码安装,在编译的过程中,通过配置,从而得到自己想要的功能。比如:
apt-get install mutt
是无法使用Imap功能的,因为有时候默认不开启Imap协议。
下面我摘自INSTALL.md
To build NeoMutt, you will need, at the very minimum:
A C99 compiler such as gcc or clang
SysV-compatible curses library: ncurses or slang
Some common libraries, such as iconv and regex
DocBook XSL stylesheets and DTDs (for building the docs)
git clone https://github.com/neomutt/neomutt
如果第一次安装Neomutt,还确实有些麻烦,因为它需要一些别的库:
比如,这里面你必须指定ncurses或者slang的安装位置(google),如果要开启Imap功能,--sasl --GNUTLS
也是必不可少的。具体需要哪些选项,你可以通过:
./configure --help
去了解。
下面是我的配置选项,仅能满足我的需要,仅供参考。
./configure --with-ui=slang --with-slang=/usr/local/src/slang-2.2.4 --with-ssl=/usr/lib/ssl/ \
--disable-doc --debug --with-idn=/usr/include/lib/ --sasl --with-gnutls=/usr/include/gnutls/
对了,只要带路径的选项,就是我自己安装的软件包,还可以的。如果你想快速知道自己的配置选项,可以使用neomutt -v
进行查看。
一切Ok的话,make && make install
mutt的方便之处就在于它的配置文件了,这真的好像vim,好消息是,neomutt可以集成vim的内置命令在不久的将来。
在我只用Gmail的时候,配置文件很简单,账号信息与mutt的全局配置变量放在一起就可以,这个文件就是~/.muttrc
,就是这么直接,Neomutt直接就可以把mutt的配置文件拿过来用(不支持的就可以去掉的)。这里Gmail与Imap在mutt的配置网上很多,不必想说。
思路就是把账号信息分离,通过在.muttrc
中把邮箱绑定到不同的Macro上,从而实现Neomutt在不同的邮箱内跳转。
在.muttrc
中:
...
folder-hook '126.com' 'source ~/.mutt/account.126'
folder-hook 'gmail.com' 'source ~/.mutt/account.gmail'
macro index <f5> '<change-folder>imaps://imap.126.com<enter>'
macro index <f6> '<change-folder>imaps://imap.gmail.com<enter>'
那么,你可以仅仅把不同邮箱的账号信息放到~/.mutt/account.*
下,下面我贴一下我的account.126
set use_from=yes
set realname="Bo YU"
set from=[email protected]
set envelope_from=yes
#设置Gmail账户和密码,imap和gmail
set smtp_url = "smtp://[email protected]:25"
set smtp_pass = $imap_pass
#设置远程服务器和文件夹
set imap_user = "[email protected]"
set imap_pass = ""
set folder = "imaps://imap.126.com:993"
set certificate_file=~/Mail/certificates
#set imap_auth_type = "PLAIN"
set ssl_starttls = yes
set ssl_force_tls = yes
set imap_keepalive = 300
set mail_check = 120
set spoolfile = "+收件箱"
#set record = "+[126]/收件箱"
mailboxes = +INBOX
set certificate_file=~/Mail/certificates
好,这就是基本的配置文件了。在相同的配置下,一般情况下,可以登录Gmail,但是不能登录126,奇了怪了。
因为我是使用的Neomutt,所以怀疑是缺少一些必备的软件,所以从包管理器中重新安装了mutt,你也可以试试。
经过上步后,我可以登陆了,但是一直报错:
NO Select Unsafe Login. Please contact [email protected]解决办法
网上一搜,还是有解决办法的。就是网易不相信这种第三方软件导致的。你需要:
http://config.mail.163.com/settings/imap/[email protected]
将上面的163根据你的邮箱(126 or 其他)换成你的,uid是你的邮箱,登录后通过密保手机验证本人后,说:
您可以继续使用当前客户端收发邮件了,请特别注意个人的电子信息安全哦。感谢您对网易邮箱的支持!
就可以了。
参考: https://blog.csdn.net/shanghaojiabohetang/post/details/74486196
还有个问题就是如何知道错误信息呢?
在配置编译选项的时候,加上debug
模式,在打开Neomutt时可以:
neomutt -d5
# or
mutt -d5
就可以了。相关的log会产生在~/.neomuttdebug0
文件中。
本以为像Gmail那样就可以畅快的使用Imap,然而还是自己太年轻啊。是这样的,经过上面的步骤后可以很容易的像Gmail那样收件、查看信件,但是写信、回复信件就悲催了,首先是126报认证错,也就是553,也就是所谓的smtp认证失败,尝试了很多方式,很长时间才搞定的。
set smtp_url = "smtp://[email protected]:25"
一定要写这句,它和Gmail是不一样的,Gmail直接就是smtp://smtp.gmail:456/
,另外还有一点就是根据126的官方介绍,非ssl的加密方式的smtp的端口是25,这里只有25在我的情况下使用,很奇怪。
同理,这个错误也是上面的情形之一,你以为就OK了?Too young too simply.它的smtp又成了587.
qq邮箱的配置文件与126的很像,注意名字就可以了。
如果报: SASL认证失败。很大一部分就是密码错了。
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
int* twoSum(int* nums, int numsSize, int target) {
int* sum = malloc(sizeof(int) * numsSize);
int j,i;
for(i = 0; i < numsSize; ++i){
for(j = i + 1; j < numsSize; ++j){
if (target - nums[i] == nums[j]){
sum[0] = i;
sum[1] = j;
break;
}
}
}
return sum;
}
可以在本地申请,返回到主函数中释放,学习了。不过,这种方法的效率很低很低,还得研究其他的。
Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid.
Because i want to master c, so, c is my first program language.
typedef struct stack{
char c;
struct stack *next;
} Stack;
void create(Stack **ptop)
{
*ptop = NULL;
}
void push(Stack **ptop, char c)
{
Stack *tmp;
tmp = malloc(sizeof(struct stack));
tmp -> c = c;
tmp -> next = *ptop;
*ptop = tmp;
}
void pop(Stack **ptop, char *c)
{
Stack *tmp;
if(! *ptop)
return;
tmp = *ptop;
*c = tmp->c;
*ptop = (*ptop)->next;
free(tmp);
}
int empty(Stack **ptop)
{
return *ptop == NULL;
}
bool isValid(char *s){
Stack *ss;
char c;
create(&ss);
while(*s){
switch(*s){
case '(':
case '[':
case '{':
push(&ss, *s);
break;
case ')':
case ']':
case '}':
if (empty(&ss))
return 0;
pop(&ss, &c);
if(c + 1 != *s && c +2 != *s)
return 0;
break;
default:
break;
}
++s;
}
if(!empty(&ss))
return 0;
return 1;
}
Here i will ask myself some questions:
Why can’t yourself think out it;Why is The Stack
is pointer to pointer?Escriplly,
if(c + 1 != *s && c + 2 != *s)