分类 编程 下的文章

The easiest way I've found to install pip3 (for python3.x packages) on CentOS 7 is:

$ sudo yum install python34-setuptools
$ sudo easy_install-3.4 pip

You'll need to have the EPEL repository enabled before hand, of course.

You should now be able to run commands like the following to install packages for python3.x:

$ pip3 install foo

axios({
  method: 'get',
  url: '/reports/interval-dates',
  responseType: 'arraybuffer',
  data: dates
}).then(function(response) {
  let blob = new Blob([response.data], { type: 'application/pdf' })
  let link = document.createElement('a')
  link.href = window.URL.createObjectURL(blob)
  link.download = 'Report.pdf'
  link.click()
})

CSS 垂直居中的最简单写法:容器元素设为 flex 布局,子元素只要写 margin: auto 即可。

<header>
    <h1>A secret weapon…</h1>
</header>
header {
  display: flex;
  height: 100px;
}

h1 {
  margin: auto;
}

在 Messenger 应用中打开网页后,如果用户点击分享,那么分享出的链接和内容如何控制呢?

可以通过 Open Graph 来实现:

carbon.png

查看demo:

在Messenger应用中打开此链接并分享:
https://cdn.ijustplay.cn/files/5bc3c1d52024c150581c7651627304b7.html

实际情况下我们注意到如果没有og信息,Messenger 应用依然会抓取用户网站信息。但是这些信息不一定是我们需要的,因此只需要在网站 meta 信息中加入 og 内容即可控制了。如果遇到问题可留言讨论。

messenger-share.jpg

基于远程仓库创建新分支
git branch branch_name remote_name/branch

基于远程仓库创建新分支并且切换到新分支
git checkout -b branch_name remote_name/branch

获取上次提交hash
git rev-parse HEAD --short

一不小心把文件和目录权限弄错了,想恢复回原有的样子,只需要执行一条命令即可恢复:

find folder '(' -type f -exec chmod 644 {} ';' ')' -o '(' -type d -exec chmod 755 {} ';' ')'

这条命令其实是两条命令合成的:

find folder -type d -exec chmod 755 {} \;
find folder -type f -exec chmod 644 {} \;

-o means OR. This command processes all objects in the project tree that are of type “file” or type “directory”, and executes different commands based on which type each object is.

You can make this slightly more efficient by replacing the semicolons (';') with plus signs (+); this tells find to run chmod 644 once, with all the plain files’ names as arguments, and to run chmod 755 once, with all the directories’ names as arguments.

查看原文

Manually remove

First, reboot your System to be sure it is using the latest kernel. Then open terminal and check your current kernel:

uname -r

DO NOT REMOVE THIS KERNEL!

Next, type the command below to view/list all installed kernels on your system.

dpkg --list | grep linux-image

Find all the kernels that lower than your current kernel. When you know which kernel to remove, continue below to remove it. Run the commands below to remove the kernel you selected.

sudo apt-get purge linux-image-x.x.x-x-generic

Finally, run the commands below to update grub2

sudo update-grub2

Reboot your system.

All-in-one command

All-in-one version to remove images and headers (combines the two versions above):

echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge

Question: How do I remove old kernel versions to clean up the boot menu?