git命令行查看图形化的分支信息与commit 缩写id

李魔佛 发表了文章 • 0 个评论 • 107 次浏览 • 2020-06-21 16:56 • 来自相关话题

在命令行下面,有时候需要可视化的观察git的分支情况以及commit id的缩写值。
可以使用 git log 加若干参数
 
git log --graph --pretty=oneline --abbrev-commit
效果是这样的:





 
而实际在source tree中是这样的:





 
  查看全部
在命令行下面,有时候需要可视化的观察git的分支情况以及commit id的缩写值。
可以使用 git log 加若干参数
 
git log --graph --pretty=oneline --abbrev-commit

效果是这样的:

img1.PNG

 
而实际在source tree中是这样的:

2.png

 
 

docker run 和 create 区别

李魔佛 发表了文章 • 0 个评论 • 1243 次浏览 • 2019-11-25 13:49 • 来自相关话题

Technically, docker run = docker create + docker start . 
docker create command creates a writeable container from the image and prepares it for running. 
docker run command creates the container (same as docker create ) and starts it.
 
  查看全部
Technically, docker run = docker create + docker start
docker create command creates a writeable container from the image and prepares it for running. 
docker run command creates the container (same as docker create ) and starts it.
 
 

用docker编译go代码

李魔佛 发表了文章 • 0 个评论 • 558 次浏览 • 2019-11-25 13:45 • 来自相关话题

如果偶尔需要编译go代码,但是又不想要安装一堆乱七八糟的依赖和Go编译器,可以利用docker来实现。 应该是解决起来话费时间最小的。
1. 用文本编辑你的go代码,现在以hello world为例:
 package main import "fmt" func main() {
/* 这是我的第一个简单的程序 */
fmt.Println("Hello, World!")
}
 
2. 然后直接使用docker执行编译。docker首先会自动去下载go的编译器,顺便把所有的依赖给解决掉

docker run --rm -v "$(pwd)":/usr/src/hello -w /usr/src/hello golang:1.3 go build -v
 
最后会在本地生成一个编译好的hello静态文件。
上述docker命令的具体含义就是把当前路径挂在到docker容器里头,然后切换到改到改路径下,然后进行编译。 查看全部

如果偶尔需要编译go代码,但是又不想要安装一堆乱七八糟的依赖和Go编译器,可以利用docker来实现。 应该是解决起来话费时间最小的。
1. 用文本编辑你的go代码,现在以hello world为例:
 
package main import "fmt" func main() {
/* 这是我的第一个简单的程序 */
fmt.Println("Hello, World!")
}

 
2. 然后直接使用docker执行编译。docker首先会自动去下载go的编译器,顺便把所有的依赖给解决掉

docker run --rm -v "$(pwd)":/usr/src/hello -w /usr/src/hello golang:1.3 go build -v
 
最后会在本地生成一个编译好的hello静态文件。
上述docker命令的具体含义就是把当前路径挂在到docker容器里头,然后切换到改到改路径下,然后进行编译。

docker实战 代码勘误

李魔佛 发表了文章 • 0 个评论 • 390 次浏览 • 2019-11-25 11:24 • 来自相关话题

作者在官网刊登的勘误记录:
 
看这本书的作者一定要看,不然坑挺多的。
一路采坑过来的哭着说。Last updated August 21, 2016
In an effort to offer continued support beyond publication, we have listed many updates to code due to version updates.

[code - omission] Page 18

The command to start the "mailer" is missing a line. Where the book reads:
docker run -d \
--name mailer \
the proper command should read:
docker run -d \
--name mailer \
dockerinaction/ch2_mailer

[code - regression] Page 68

Newer versions of Docker have changed the structure of the JSON returned by the docker inspect subcommand. If the following command does not work then use the replacement. Original:
docker inspect --format "{{json .Volumes}}" reader
Replacement:
docker inspect --format "{{json .Mounts}}" reader

[code - regression] Page 69

Newer versions of Docker have changed the structure of the JSON returned by the docker inspect subcommand. If the following command does not work then use the replacement. Original:
docker inspect --format "{{json .Volumes}}" student
Replacement:
docker inspect --format "{{json .Mounts}}" student

[code - regression] Page 74

The alpine image entrypoint has changed since original publication and has been unset. The last command on the page should now read:
docker run --rm \
--volumes-from tools \
--entrypoint /bin/sh \
alpine:latest \
-c 'ls /operations/*'
[code - regression] Page 75

The docker exec example on the top of page 75 was printed with the wrong tool name. The correct command is:
docker exec important_application /operations/tools/diagnostics

[code - regression] Page 86

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--hostname barker \
busybox:1 \
nslookup barker

[code - regression] Page 87 (top)

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--dns 8.8.8.8 \
busybox:1 \
nslookup docker.com

[code - regression] Page 87 (bottom)

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--dns-search docker.com \
busybox:1 \
nslookup registry.hub

[code - regression] Page 88 (bottom)

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--add-host test:10.10.10.255 \
busybox:1 \
nslookup test

[code - regression] Page 106

There are a few new problems with this example. First, the named repository (dockerfile/mariadb) no longer exists. You can use mariadb:5.5 as replacement. However, the second problem is that containers created from the mariadb image perform certain initialization at startup. That initialization work requires certain capabilities and to be started with the default user. The system should instead drop permissions after the initialization work is complete. Note that the real value of this example is in demonstrating different resource isolation mechanisms. It is not so important that you get it working. You can start the database with the following command:
docker run -d --name ch6_mariadb \
--memory 256m \
--cpu-shares 1024 \
--cap-drop net_raw \
-e MYSQL_ROOT_PASSWORD=test \
mariadb:5.5

[code - regression] Page 107

Containers created from the wordpress:4.1 image perform certain initialization at startup and expect certain environment variables. That initialization work requires certain capabilities and to be started with the default user. The system should instead drop permissions after the initialization work is complete. Note that the real value of this example is in demonstrating different resource isolation mechanisms. It is not so important that you get it working. You can start wordpress with the following command:
docker run -d -P --name ch6_wordpress \
--memory 512m \
--cpu-shares 512 \
--cap-drop net_raw \
-e WORDPRESS_DB_PASSWORD=test \
mariadb:5.5

[code - typo] Page 109

The device access example is missing the "run" subcommand. The command listed as:
docker -it --rm \
--device /dev/video0:/dev/video0 \
ubuntu:latest ls -al /dev
should have been written as:
docker run -it --rm \
--device /dev/video0:/dev/video0 \
ubuntu:latest ls -al /dev

[code - typo] Page 110 - 111

Several commands are missing the "run" subcommand. In each case the command begins with
docker -d ...
and should have been written as:
docker run -d ...

[code - regression] Page 115 (bottom)

The busybox and alpine images have been updated to fix the problem described in the paragraph below. The 'su' command does not have the SUID bit set and will not provide any automatic privilege escalation.

[command correction] Page 116

Boot2Docker has been discontinued and rolled into a newer project called Docker Machine. Because a reader is unlikely to have the boot2docker command installed, the command at the top of this page should be changed from:
boot2docker ssh
to the Docker Machine equivalent:
docker-machine ssh default
where default is the name of the machine you created.

[code - regression] Page 119

The ifconfig command has since been removed from ubuntu:latest. Instead of using the ubuntu:latest image for these examples use ubuntu:trusty. The example using ifconfig should look like:
docker run --rm \
--privileged \
ubuntu:trusty ifconfig
[Illustration Mistake] Page 136
Image layer ced2 on the left side of the illustration is listed at c3d2 on the right side. These two layers should represent the same item.

[code - typo] Page 140

Containers need not be in a running state in order to export their file system. The first command on page 140 uses the "run" subcommand but the command listed will never be able to start. Replace "run" with "create." The command should appear as follows:
docker create --name export-test \
dockerinaction/ch7_packed:latest ./echo For Export

[code - missing line] Page 146

In the example Dockerfile near the top of the page the line with the RUN directive is missing part of the instruction. That line should read:
RUN apt-get update && apt-get install -y git

[code - evolution] Page 215

The registry:2 configuration file now requires the population of additional fields under "maintenance > uploadpurging." The example should currently look like:
# Filename: s3-config.yml
version: 0.1
log:
level: debug
fields:
service: registry
environment: development
storage:
cache:
layerinfo: inmemory
s3:
accesskey:
secretkey:
region:
bucket:
encrypt: true
secure: true
v4auth: true
chunksize: 5242880
rootdirectory: /s3/object/name/prefix
maintenance:
uploadpurging:
enabled: true
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
http:
addr: :5000
secret: asecretforlocaldevelopment
debug:
addr: localhost:5001

[code - evolution] Page 216

The registry:2 configuration file now requires the population of additional fields under "maintenance > uploadpurging." The example should currently look like:
# Filename: rados-config.yml
version: 0.1
log:
level: debug
fields:
service: registry
environment: development
storage:
cache:
layerinfo: inmemory
rados:
poolname: radospool
username: radosuser
chunksize: 4194304
maintenance:
uploadpurging:
enabled: false
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
http:
addr: :5000
secret: asecretforlocaldevelopment
debug:
addr: localhost:5001

[code - evolution] Page 218

The registry:2 configuration file now requires the population of additional fields under "maintenance > uploadpurging." The example should currently look like:
# Filename: redis-config.yml
version: 0.1
log:
level: debug
fields:
service: registry
environment: development
http:
addr: :5000
secret: asecretforlocaldevelopment
debug:
addr: localhost:5001
storage:
cache:
blobdescriptor: redis
s3:
accesskey:
secretkey:
region:
bucket:
encrypt: true
secure: true
v4auth: true
chunksize: 5242880
rootdirectory: /s3/object/name/prefix
maintenance:
uploadpurging:
enabled: true
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
redis:
addr: redis-host:6379
password: asecret
dialtimeout: 10ms
readtimeout: 10ms
writetimeout: 10ms
pool:
maxidle: 16
maxactive: 64
idletimeout: 300s
[code - typo] Page 220

The name of the file shown should be scalable-config.yml as in previous examples. This example also requires the addition of the newer uploadpurging attributes. The mainenance section of the file should be as follows:
maintenance:
uploadpurging:
enabled: true
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
[text - typo] Page 240

In the second paragraph the reader is instructed to, "Open ./coffee/api/api.py" this is not the correct location of the file. The correct file location is at, "./coffee/app/api.py."
[text - typo] Page 262

The refere nce to "flock.json" in the first sentence of the third paragraph should be "flock.yml."
[code - typo] Page 270

The git clone command uses the ssh protocol instead of https. The command should read as follows:
git clone https://github.com/dockerinact ... i.git 查看全部
作者在官网刊登的勘误记录:
 
看这本书的作者一定要看,不然坑挺多的。
一路采坑过来的哭着说。
Last updated August 21, 2016
In an effort to offer continued support beyond publication, we have listed many updates to code due to version updates.

[code - omission] Page 18

The command to start the "mailer" is missing a line. Where the book reads:
docker run -d \
--name mailer \
the proper command should read:
docker run -d \
--name mailer \
dockerinaction/ch2_mailer

[code - regression] Page 68

Newer versions of Docker have changed the structure of the JSON returned by the docker inspect subcommand. If the following command does not work then use the replacement. Original:
docker inspect --format "{{json .Volumes}}" reader
Replacement:
docker inspect --format "{{json .Mounts}}" reader

[code - regression] Page 69

Newer versions of Docker have changed the structure of the JSON returned by the docker inspect subcommand. If the following command does not work then use the replacement. Original:
docker inspect --format "{{json .Volumes}}" student
Replacement:
docker inspect --format "{{json .Mounts}}" student

[code - regression] Page 74

The alpine image entrypoint has changed since original publication and has been unset. The last command on the page should now read:
docker run --rm \
--volumes-from tools \
--entrypoint /bin/sh \
alpine:latest \
-c 'ls /operations/*'
[code - regression] Page 75

The docker exec example on the top of page 75 was printed with the wrong tool name. The correct command is:
docker exec important_application /operations/tools/diagnostics

[code - regression] Page 86

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--hostname barker \
busybox:1 \
nslookup barker

[code - regression] Page 87 (top)

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--dns 8.8.8.8 \
busybox:1 \
nslookup docker.com

[code - regression] Page 87 (bottom)

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--dns-search docker.com \
busybox:1 \
nslookup registry.hub

[code - regression] Page 88 (bottom)

It appears that nslookup behavior in the alpine image has changed. To run the example use the busybox:1 image.
docker run --rm \
--add-host test:10.10.10.255 \
busybox:1 \
nslookup test

[code - regression] Page 106

There are a few new problems with this example. First, the named repository (dockerfile/mariadb) no longer exists. You can use mariadb:5.5 as replacement. However, the second problem is that containers created from the mariadb image perform certain initialization at startup. That initialization work requires certain capabilities and to be started with the default user. The system should instead drop permissions after the initialization work is complete. Note that the real value of this example is in demonstrating different resource isolation mechanisms. It is not so important that you get it working. You can start the database with the following command:
docker run -d --name ch6_mariadb \
--memory 256m \
--cpu-shares 1024 \
--cap-drop net_raw \
-e MYSQL_ROOT_PASSWORD=test \
mariadb:5.5

[code - regression] Page 107

Containers created from the wordpress:4.1 image perform certain initialization at startup and expect certain environment variables. That initialization work requires certain capabilities and to be started with the default user. The system should instead drop permissions after the initialization work is complete. Note that the real value of this example is in demonstrating different resource isolation mechanisms. It is not so important that you get it working. You can start wordpress with the following command:
docker run -d -P --name ch6_wordpress \
--memory 512m \
--cpu-shares 512 \
--cap-drop net_raw \
-e WORDPRESS_DB_PASSWORD=test \
mariadb:5.5

[code - typo] Page 109

The device access example is missing the "run" subcommand. The command listed as:
docker -it --rm \
--device /dev/video0:/dev/video0 \
ubuntu:latest ls -al /dev
should have been written as:
docker run -it --rm \
--device /dev/video0:/dev/video0 \
ubuntu:latest ls -al /dev

[code - typo] Page 110 - 111

Several commands are missing the "run" subcommand. In each case the command begins with
docker -d ...
and should have been written as:
docker run -d ...

[code - regression] Page 115 (bottom)

The busybox and alpine images have been updated to fix the problem described in the paragraph below. The 'su' command does not have the SUID bit set and will not provide any automatic privilege escalation.

[command correction] Page 116

Boot2Docker has been discontinued and rolled into a newer project called Docker Machine. Because a reader is unlikely to have the boot2docker command installed, the command at the top of this page should be changed from:
boot2docker ssh
to the Docker Machine equivalent:
docker-machine ssh default
where default is the name of the machine you created.

[code - regression] Page 119

The ifconfig command has since been removed from ubuntu:latest. Instead of using the ubuntu:latest image for these examples use ubuntu:trusty. The example using ifconfig should look like:
docker run --rm \
--privileged \
ubuntu:trusty ifconfig
[Illustration Mistake] Page 136
Image layer ced2 on the left side of the illustration is listed at c3d2 on the right side. These two layers should represent the same item.

[code - typo] Page 140

Containers need not be in a running state in order to export their file system. The first command on page 140 uses the "run" subcommand but the command listed will never be able to start. Replace "run" with "create." The command should appear as follows:
docker create --name export-test \
dockerinaction/ch7_packed:latest ./echo For Export

[code - missing line] Page 146

In the example Dockerfile near the top of the page the line with the RUN directive is missing part of the instruction. That line should read:
RUN apt-get update && apt-get install -y git

[code - evolution] Page 215

The registry:2 configuration file now requires the population of additional fields under "maintenance > uploadpurging." The example should currently look like:
# Filename: s3-config.yml
version: 0.1
log:
level: debug
fields:
service: registry
environment: development
storage:
cache:
layerinfo: inmemory
s3:
accesskey:
secretkey:
region:
bucket:
encrypt: true
secure: true
v4auth: true
chunksize: 5242880
rootdirectory: /s3/object/name/prefix
maintenance:
uploadpurging:
enabled: true
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
http:
addr: :5000
secret: asecretforlocaldevelopment
debug:
addr: localhost:5001

[code - evolution] Page 216

The registry:2 configuration file now requires the population of additional fields under "maintenance > uploadpurging." The example should currently look like:
# Filename: rados-config.yml
version: 0.1
log:
level: debug
fields:
service: registry
environment: development
storage:
cache:
layerinfo: inmemory
rados:
poolname: radospool
username: radosuser
chunksize: 4194304
maintenance:
uploadpurging:
enabled: false
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
http:
addr: :5000
secret: asecretforlocaldevelopment
debug:
addr: localhost:5001

[code - evolution] Page 218

The registry:2 configuration file now requires the population of additional fields under "maintenance > uploadpurging." The example should currently look like:
# Filename: redis-config.yml
version: 0.1
log:
level: debug
fields:
service: registry
environment: development
http:
addr: :5000
secret: asecretforlocaldevelopment
debug:
addr: localhost:5001
storage:
cache:
blobdescriptor: redis
s3:
accesskey:
secretkey:
region:
bucket:
encrypt: true
secure: true
v4auth: true
chunksize: 5242880
rootdirectory: /s3/object/name/prefix
maintenance:
uploadpurging:
enabled: true
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
redis:
addr: redis-host:6379
password: asecret
dialtimeout: 10ms
readtimeout: 10ms
writetimeout: 10ms
pool:
maxidle: 16
maxactive: 64
idletimeout: 300s
[code - typo] Page 220

The name of the file shown should be scalable-config.yml as in previous examples. This example also requires the addition of the newer uploadpurging attributes. The mainenance section of the file should be as follows:
maintenance:
uploadpurging:
enabled: true
age: 168h
interval: 24h
dryrun: false
readonly:
enabled: false
[text - typo] Page 240

In the second paragraph the reader is instructed to, "Open ./coffee/api/api.py" this is not the correct location of the file. The correct file location is at, "./coffee/app/api.py."
[text - typo] Page 262

The refere nce to "flock.json" in the first sentence of the third paragraph should be "flock.yml."
[code - typo] Page 270

The git clone command uses the ssh protocol instead of https. The command should read as follows:
git clone https://github.com/dockerinact ... i.git

crontab定时运行图形程序

李魔佛 发表了文章 • 0 个评论 • 653 次浏览 • 2019-08-26 15:56 • 来自相关话题

默认情况不会显示任何图形的界面,需要在程序前添加 
export DISPLAY=:0;* * * * * export DISPLAY=:0; gedit 
附一个linux下桌面提醒GUI程序,定时提醒你休息哈:
 
import pyautogui as pag
import datetime

def neck_rest():
f = open('neck_record.txt', 'a')
ret = pag.prompt("Rest! Protect your neck !")
if ret == 'rest':
f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
f.write('\t')
f.write('Rest')
f.write('\n')
else:
f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
f.write('\t')
f.write('Failed to rest')
f.write('\n')
f.close()

neck_rest()
程序保存为task.py
然后设定crontab任务:

* * * * * export DISPLAY=:0; python task.py 
即可

  查看全部
默认情况不会显示任何图形的界面,需要在程序前添加 
export DISPLAY=:0;
* * * * * export DISPLAY=:0; gedit
 
附一个linux下桌面提醒GUI程序,定时提醒你休息哈:
 
import pyautogui as pag
import datetime

def neck_rest():
f = open('neck_record.txt', 'a')
ret = pag.prompt("Rest! Protect your neck !")
if ret == 'rest':
f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
f.write('\t')
f.write('Rest')
f.write('\n')
else:
f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
f.write('\t')
f.write('Failed to rest')
f.write('\n')
f.close()

neck_rest()

程序保存为task.py
然后设定crontab任务:

* * * * * export DISPLAY=:0; python task.py 
即可

 

alias别名 等号后面不用

李魔佛 发表了文章 • 0 个评论 • 631 次浏览 • 2019-08-12 14:17 • 来自相关话题

alias sync="git commit -m 'update' -a && git push origin master"
alias fetch="git fetch origin"
alias dj="python manage.py runserver 0.0.0.0"
alias py2="python2"
alias py3="python3"
alias ggg="cd ~/git" 查看全部
alias sync="git commit -m 'update' -a && git push origin master"
alias fetch="git fetch origin"
alias dj="python manage.py runserver 0.0.0.0"
alias py2="python2"
alias py3="python3"
alias ggg="cd ~/git"

python执行shell命令时报错: -/bin/sh: 命令:not found的解决办法

李魔佛 发表了文章 • 0 个评论 • 2350 次浏览 • 2019-07-29 15:13 • 来自相关话题

file='test.txt'
cmd = f'rsync -av {file} root@10.18.6.46:/home/cjw/'

p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,executable="/bin/bash")
output, error = p.communicate()
if p.returncode != 0:
print("Error while running - %s" % cmd)
print(error)
print(output) 
用sublime3 运行的时候一直报错。
后来发现,这个是sublime3的运行环境问题, 直接用shell执行 python main.py 执行上面的代码,命令可以正常运行。
/bin/sh: 1: rsync: not found 查看全部
     file='test.txt'
cmd = f'rsync -av {file} root@10.18.6.46:/home/cjw/'

p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,executable="/bin/bash")
output, error = p.communicate()
if p.returncode != 0:
print("Error while running - %s" % cmd)
print(error)
print(output)
 
用sublime3 运行的时候一直报错。
后来发现,这个是sublime3的运行环境问题, 直接用shell执行 python main.py 执行上面的代码,命令可以正常运行。
/bin/sh: 1: rsync: not found

ubuntu/linux shell根据进程名杀死进程 一句搞定

李魔佛 发表了文章 • 0 个评论 • 1076 次浏览 • 2019-04-19 23:15 • 来自相关话题

ps -ef | grep "进程名" | grep -v grep | cut -c 10-16 | xargs kill -9 
比如我要杀死python的进程,就使用
 

ps -ef | grep "python" | grep -v grep | cut -c 10-16 | xargs kill -9
 
来使用。
 
grep -v grep 因为 ps 会把grep python这个进程也打印出来,所以-v 是反转的意思,不匹配的才打印出来,然后cut 是找出10到16位的字符,这里需要大家根据自己的用户名来调整。
一般ps -ef输出是 前面 用户名,然后空格, 接着是进程号。 如果你的用户名很长,可以调整10-16的位置来适应。
 
后面就是把进程号传递给kill作为参数,-9 是强制杀死。
 
  查看全部
ps -ef | grep "进程名" | grep -v grep | cut -c 10-16 | xargs kill -9
 
比如我要杀死python的进程,就使用
 

ps -ef | grep "python" | grep -v grep | cut -c 10-16 | xargs kill -9
 
来使用。
 
grep -v grep 因为 ps 会把grep python这个进程也打印出来,所以-v 是反转的意思,不匹配的才打印出来,然后cut 是找出10到16位的字符,这里需要大家根据自己的用户名来调整。
一般ps -ef输出是 前面 用户名,然后空格, 接着是进程号。 如果你的用户名很长,可以调整10-16的位置来适应。
 
后面就是把进程号传递给kill作为参数,-9 是强制杀死。
 
 

树莓派 vim代码高亮

李魔佛 发表了文章 • 0 个评论 • 797 次浏览 • 2019-04-09 09:38 • 来自相关话题

首先安装vim 
sudo apt-get install-y vim
 
然后默认没有高亮语法的:

在~目录下面新建.vimrc文件可以实现1
 
然后编辑.vimrc文件
 

set nu
syntax on
set tabstop=4
 
然后就可以生效了。
如果还木有生效,记得重启下,或者注销。 查看全部
首先安装vim 
sudo apt-get install-y vim
 
然后默认没有高亮语法的:

在~目录下面新建.vimrc文件可以实现1
 
然后编辑.vimrc文件
 

set nu
syntax on
set tabstop=4
 
然后就可以生效了。
如果还木有生效,记得重启下,或者注销。

centos 7 自带的jdk路径

李魔佛 发表了文章 • 0 个评论 • 1216 次浏览 • 2018-11-19 14:46 • 来自相关话题

centos7自带java,但如果显示JAVA_HOME路径的时候,会显示为空,因为环境变量并没有把JAVA_HOME写进去。
需要自己去输入
jdk路径如下:
/etc/alternatives/java_sdk_1.8.0_openjdk
 
然后创建环境变量:
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0_openjdk
 
这样省去了到官网下载JDK和配置的时间了。
  查看全部
centos7自带java,但如果显示JAVA_HOME路径的时候,会显示为空,因为环境变量并没有把JAVA_HOME写进去。
需要自己去输入
jdk路径如下:
/etc/alternatives/java_sdk_1.8.0_openjdk
 
然后创建环境变量:
export JAVA_HOME=/etc/alternatives/java_sdk_1.8.0_openjdk
 
这样省去了到官网下载JDK和配置的时间了。
 

Python推送到kindle问题。多谢

李魔佛 回复了问题 • 2 人关注 • 2 个回复 • 1571 次浏览 • 2018-10-26 11:32 • 来自相关话题

ubuntu samba连接斐讯天天链N1 提示 Host is down.

李魔佛 发表了文章 • 0 个评论 • 2936 次浏览 • 2018-06-02 16:48 • 来自相关话题

配置:
斐讯天天链N1 + 斐讯硬盘H1
ubuntu 和天天链在同一个内网中。
 平时个人在ubuntu下使用的mount命令不管用。 提示 Host is down
如果直接用gui连接,是没问题的(打开文件夹,选择连接服务器,然后服务器地址填 smb://192.168.1.1 ) 然后就可以访问天天链的硬盘。 
但是为什么使用mount命令就不行了呢 ?
 
通过不断更改参数,发现问题出在斐讯samba的版本用的是老旧的vers 1.0. 这时需要你在mount命令中制定版本。
 sudo mount -t cifs -o username=root,password=xxxxx,uid=1000,gid=1000,vers=1.0,_netdev //192.168.1.88/HDisk /home/use/net
通过上述的命令, 就可以把斐讯的硬盘mount到本地,并且有权限可以读写。
记得加上
uid=1000,gid=1000, 不然会没有权限读写,只能一直使用sudo 才能读写哦。
 
 
原创文章
转载请注明出处:http://30daydo.com/article/317
  查看全部
配置:
斐讯天天链N1 + 斐讯硬盘H1
ubuntu 和天天链在同一个内网中。
 平时个人在ubuntu下使用的mount命令不管用。 提示 Host is down
如果直接用gui连接,是没问题的(打开文件夹,选择连接服务器,然后服务器地址填 smb://192.168.1.1 ) 然后就可以访问天天链的硬盘。 
但是为什么使用mount命令就不行了呢 ?
 
通过不断更改参数,发现问题出在斐讯samba的版本用的是老旧的vers 1.0. 这时需要你在mount命令中制定版本。
 
sudo mount -t cifs -o username=root,password=xxxxx,uid=1000,gid=1000,vers=1.0,_netdev //192.168.1.88/HDisk /home/use/net

通过上述的命令, 就可以把斐讯的硬盘mount到本地,并且有权限可以读写。
记得加上
uid=1000,gid=1000, 不然会没有权限读写,只能一直使用sudo 才能读写哦。
 
 
原创文章
转载请注明出处:http://30daydo.com/article/317
 

linux的crontab中每隔一段时间是以什么为准

李魔佛 发表了文章 • 0 个评论 • 2621 次浏览 • 2018-05-07 19:37 • 来自相关话题

*/10 * * * * date >> /home/user/test.log 
比如上面的语句, 每个10分钟运行一次,这个大家都知道(不知道的可以google),可是在运行中,这个10分钟是什么开始的呢? 
从上面运行的test.log记录的文件来看,这个10分钟是以当前的时钟,从0点开始算起的10分钟,比如你刚刚设定的crontab的时间是1点15分,那么脚本运行的时间是1点20分,因为这个时间间隔是0,10,20,30,40,50,0分这种规律执行的,并不是在你配置后crontab的时间(1点15分+10分钟,即1点25分)。所以如果你设定的是
*/40 * * * * date >> /home/user/test.log
那么执行的结果是0点40分,1点20分,2点,2点40分,3点20分。。。。这样的执行顺序。
有点奇葩。 查看全部
*/10 * * * * date >> /home/user/test.log
 
比如上面的语句, 每个10分钟运行一次,这个大家都知道(不知道的可以google),可是在运行中,这个10分钟是什么开始的呢? 
从上面运行的test.log记录的文件来看,这个10分钟是以当前的时钟,从0点开始算起的10分钟,比如你刚刚设定的crontab的时间是1点15分,那么脚本运行的时间是1点20分,因为这个时间间隔是0,10,20,30,40,50,0分这种规律执行的,并不是在你配置后crontab的时间(1点15分+10分钟,即1点25分)。所以如果你设定的是
*/40 * * * * date >> /home/user/test.log

那么执行的结果是0点40分,1点20分,2点,2点40分,3点20分。。。。这样的执行顺序。
有点奇葩。

ubuntu输入密码后一直无法进入系统,继续返回在登录界面

李魔佛 发表了文章 • 0 个评论 • 2404 次浏览 • 2018-04-29 15:31 • 来自相关话题

之前一直好好的,突然一直无法登录,密码是正确的。然后按照网上的大部分教程那样,通过Ctrl+Alt +F6 进入命令行模式,可以正常登录。
然后也尝试修改.Xauthority的权限,给个777. 重启后还是不行,然后尝试把这个文件直接删除,还是无法登录图形界面。 好多人也说是显卡驱动问题,可是我根本没有修改任何的图形的设置,或者安装过显卡的驱动。
然后在GRUB启动菜单中,进入其他的内核版本。
居然用一个旧的内核版本,居然可以进入系统的图形界面。linux-4.2.0.38,而最新的4.2.0.39会一直出现问题。
所以问题就解决了。
 
但是不能每次开机都要手动选择一次grub的菜单,然后进入到ubuntu advanced菜单中选择里面的低内核版本。
 
然后按照网上的套路,修改/boot/grub/grub.cfg, 可是这文件是系统文件,一直是只读状态,无法修改。 尝试进入recovery模式的root用户下,也改不了。
 
所以想到可以把内核4.2.0.39给删除掉。
 
apt remove linux-4.2.0.39-XXXXX  (后面的一串字符忘记了,你可以打开grub.cfg里面找到的)
 
结果,在卸载内核的同时,居然还给我升级到了linux-4.2.0.40内核版本,实在无语。。 而尝试通过这个最新的linux-4.2.0.40内核版本进入系统,可是老问题依然存在,无法登录系统。
 
于是只好再手工删除这个linux-4.2.0.40内核。
 
最后,所有内核自身一个linux-4.2.0.38. 然后update-grub, 默认就会进入linux-4.2.0.38的内核的ubuntu,然后就可以登录ubuntu的图形界面的了。
 
  查看全部
之前一直好好的,突然一直无法登录,密码是正确的。然后按照网上的大部分教程那样,通过Ctrl+Alt +F6 进入命令行模式,可以正常登录。
然后也尝试修改.Xauthority的权限,给个777. 重启后还是不行,然后尝试把这个文件直接删除,还是无法登录图形界面。 好多人也说是显卡驱动问题,可是我根本没有修改任何的图形的设置,或者安装过显卡的驱动。
然后在GRUB启动菜单中,进入其他的内核版本。
居然用一个旧的内核版本,居然可以进入系统的图形界面。linux-4.2.0.38,而最新的4.2.0.39会一直出现问题。
所以问题就解决了。
 
但是不能每次开机都要手动选择一次grub的菜单,然后进入到ubuntu advanced菜单中选择里面的低内核版本。
 
然后按照网上的套路,修改/boot/grub/grub.cfg, 可是这文件是系统文件,一直是只读状态,无法修改。 尝试进入recovery模式的root用户下,也改不了。
 
所以想到可以把内核4.2.0.39给删除掉。
 
apt remove linux-4.2.0.39-XXXXX  (后面的一串字符忘记了,你可以打开grub.cfg里面找到的)
 
结果,在卸载内核的同时,居然还给我升级到了linux-4.2.0.40内核版本,实在无语。。 而尝试通过这个最新的linux-4.2.0.40内核版本进入系统,可是老问题依然存在,无法登录系统。
 
于是只好再手工删除这个linux-4.2.0.40内核。
 
最后,所有内核自身一个linux-4.2.0.38. 然后update-grub, 默认就会进入linux-4.2.0.38的内核的ubuntu,然后就可以登录ubuntu的图形界面的了。
 
 

ubuntu安装ta-lib后出错

李魔佛 发表了文章 • 0 个评论 • 3299 次浏览 • 2018-04-07 19:18 • 来自相关话题

>>> import talib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "talib/__init__.py", line 43, in <module>
    from ._ta_lib import (
ImportError: No module named _ta_lib
 
安装教程按照:https://blog.csdn.net/fortiy/article/details/76531700
安装完成后在终端运行python,
然后在python的终端下尝试导入talib
import talib
 
于是就出现上面的错误信息。
 
 
后来在pycharm IDE中却可以正常运行。 后来重新打开一个终端,重新运行python然后import talib,然后能够正常导入。
原来上面的操作都在同一个终端terminal中执行,安装完talib,一些环境变量没有及时生效,需要在新的终端下才会生效。 查看全部
>>> import talib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "talib/__init__.py", line 43, in <module>
    from ._ta_lib import (
ImportError: No module named _ta_lib
 
安装教程按照:https://blog.csdn.net/fortiy/article/details/76531700
安装完成后在终端运行python,
然后在python的终端下尝试导入talib
import talib
 
于是就出现上面的错误信息。
 
 
后来在pycharm IDE中却可以正常运行。 后来重新打开一个终端,重新运行python然后import talib,然后能够正常导入。
原来上面的操作都在同一个终端terminal中执行,安装完talib,一些环境变量没有及时生效,需要在新的终端下才会生效。