mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-16 00:21:12 +08:00
commit
af942e2312
20160915 Should Smartphones Do Away with the Headphone Jack Here Are Our Though
published
20160511 4 Container Networking Tools to Know.md20160724 Terminator A Linux Terminal Emulator With Multiple Terminals In One Window.md20160729 Best Password Manager all platform.md20160805 Introducing React Native Ubuntu.md20160811 How to Mount Remote Linux Filesystem or Directory Using SSHFS Over SSH.md20160922 HOW TO USE FTP TO MOVE FILES BETWEEN YOUR COMPUTER AND YOUR ANDROID DEVICE.md20161002 ARCH LINUX MAY SOON BE AVAILABLE ON WINDOWS SUBSYSTEM FOR LINUX.md20161007 Deploy containers with Atomic Host, Ansible, and Cockpit.md
sources
talk
20160915 Should Smartphones Do Away with the Headphone Jack Here Are Our Thoughts.md20161010 Why Linux pioneer Linus Torvalds prefers x86 chips over ARM processors.md
my-open-source-story
tech
20160511 4 Container Networking Tools to Know.md20160512 Python unittest - assertTrue is truthy - assertFalse is falsy.md20160701 CANONICAL CONSIDERING TO DROP 32 BIT SUPPORT IN UBUNTU.md20160729 Best Password Manager all platform.md20160805 Introducing React Native Ubuntu.md20160811 How to Mount Remote Linux Filesystem or Directory Using SSHFS Over SSH.md20160815 The cost of small modules.md20160820 Building your first Atom plugin.md20160901 A Raspberry Pi Hadoop Cluster with Apache Spark on YARN - Big Data 101.md20160921 Rust meets Fedora.md20161002 ARCH LINUX MAY SOON BE AVAILABLE ON WINDOWS SUBSYSTEM FOR LINUX.md20161004 Keeping Linux containers safe and secure.md20161005 Solving the Linux kernel code reviewer shortage.md20161010 A Look At The Most Promising Next-Gen Linux Software Update Mechanisms.md20161011 THIS OPEN SOURCE MINI COMPUTER WILL DELETE DATA IF TEMPERED WITH.md
translated
@ -0,0 +1,66 @@
|
||||
|
||||
|
||||
智能机应该舍弃耳机插口吗?以下是我们的观点
|
||||
====
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/Writers-Opinion-Headphone-Featured.jpg)
|
||||
|
||||
尽管苹果公司将在 iPhone 7 上面取消耳机插口的传言早就有了,但是在上周苹果公司的公告证实了
|
||||
这个消息后,它还是成为了一个热门话题。
|
||||
|
||||
对于那些不知道这个最新消息的人,关于苹果公司已经在手机上面移除了耳机接口,耳机可以通过闪电接口插入手机。如果他们还想在手机上面使用现有的耳机,他们需要一个适配器将耳机通过闪电接口与手机连接。苹果公司也将出售一款新产品:AirPods。它们被戴入你的耳朵后通过无线和手机连接。耳机通过无线和手机连接带来的最大的好处是通过舍弃耳机接口来让手机保持进一步的干燥和防水。
|
||||
|
||||
现在苹果公司将在 iPhone 7 上面取消耳机接口已经是一个重大新闻了,我们询问我们的作者,“你怎么看待智能机取消耳机接口?”
|
||||
|
||||
### 我们的观点
|
||||
|
||||
Derrik 认为“苹果公司的这种取消手机耳机接口的行为将会促使更多昂贵的外围设备不再遵循公开标准。”他也不想每使用五个小时就不得不给 AirPods 充电。尽管他知道 3.5毫米 的耳机接口逐渐过时,但作为一个“发烧友”,他更喜欢一种新的,开放的标准,但“盈利性企业的推动”让他担心设备的自由性。
|
||||
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/headphone-jacks.jpg)
|
||||
|
||||
Damien 在自从有了蓝牙耳机后的这段日子里基本不怎么使用耳机接口了。总之,他讨厌有线耳机的电线,所以他认为“移除手机耳机接口的做法非常好。”当然他也理解 Derrik 抱怨无线耳机耗尽电源后需要充电会带来不方便,但是无线耳机会给他一种“没有东西靠在身上”的感觉。
|
||||
|
||||
Trevor 直接了当地表明自己认为智能手机移除耳机接口是一种非常愚蠢的做法,当他了解到 iPhone 7 无法在给手机充电的同时使用耳机后,更加坚信智能手机移除耳机接口是非常愚蠢的做法。他总是使用有线耳机来听音乐或者看视频,从不用蓝牙耳机。因为蓝牙耳机会加速手机电量的消耗,所以他用有线耳机。
|
||||
|
||||
Simon 并不是有线耳机的忠诚用户。他并没有见过太多为了留出更多空间而移除耳机接口的手机产品。他认为“智能手机是否取消耳机接口应该看消费者是喜欢为了提高手机防水性采用无线耳机 AirPods,还是喜欢耳机通过适配器连接到手机或者将有线耳机通过耳机插口直接和智能手机连接”。他认为不应该这么快就移除智能机的耳机接口,他更喜欢公共的可以适配所有的标准。
|
||||
|
||||
James 认为现在的无线技术已经足够成熟,所以他认为 iPhone 7 移除耳机接口是一个不错的策略,因为这也能够促进苹果公司硬件产品的销量。他偶尔使用过昂贵的有线耳机,所以就个人经历而言他注意到自己的 Xperia 智能手机虽然有耳机插口但是防水性也不差。
|
||||
|
||||
Jeffry 指出“几乎全世界所有在科技领域的过渡性尝试都是在无法受益于这些尝试而产生的强烈的反对意见中开始的。”,他还记得苹果公司因为移除软盘驱动器和不支持 Flash 曾遭到大量的抨击,但现在移除软盘驱动器和不支持 Flash 已经成为行业规范了。他坚信一切都是为了更好的发展而慢慢演变的,智能机移除耳机接口只是步入未来的一小步,而苹果公司这么做是在勇敢的引导未来智能机的一种走向,顺便通过卖无线耳机赚点钱。
|
||||
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/Writers-Opinion-Headphone-Headset.jpg)
|
||||
|
||||
Vamsi 并不介意智能手机耳机接口的移除只要有一个更好的解决方案适用于使用不同类型的耳机和其他的设备与智能手机的连接。他并没有感觉到通过闪电接口使用耳机是一个不错的解决方案,因为这使得几乎所有的其他耳机过时。至于蓝牙耳机,他只是不想再使用另外一个设备。此外,他不想争论使用无线耳机可以提高智能手机的防水性能,因为已经存在不少带有耳机接口的智能手机防水性能也不错。
|
||||
|
||||
Mahesh 更喜欢用带有耳机接口的智能手机,因为这样他可以经常再给手机充电的同时听音乐。他认为我们将会在接下来的几个月看到移除耳机接口的智能手机给用户带来的诸多不方便之处。
|
||||
|
||||
Derrik 也不赞同“移除开放标准的接口,使用专有连接”。你可能认为可以通过适配器来使耳机连接手机,但是雷电接口可以被随时关闭,苹果公司也能够随时停止这些适配器的销售。他也指出AirPods 不会取代蓝牙耳机。
|
||||
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/Writers-Opinion-Headphone-AirPods.jpg)
|
||||
|
||||
至于我,我会在两方面来考虑这个事情:新技术和苹果公司产品的其他方面。自从 iPhone系列 第一款的出售以来,我一直都在使用 iPhone 系列手机。但从 2012 年我用 iPhone 5 开始,我没有对手机进行任何更新,所以我是有些过时的。我会是第一批买 iPhone 7 的人。我讨厌白色的耳机线在我脸旁,这让我感觉看上去会很蠢,所以我可能会选择 AirPods 在某种情况下。我很欣赏手机防水性能变得更好。至于充电时间和通话时间,我并不认为 iPhone 7 续航时间短会影响到我对 iPhone 7 的购买,尽管我的旧 iPhone 5 的续航时间都可以达到 12到20个小时之间。所以我确定这不会影响到我要购买 iPhone 7。
|
||||
|
||||
### 你的观点
|
||||
|
||||
Our writers have given you a lot to think about. What are your thoughts on Smartphones doing away with the headphone jack? Will you miss it? Is it a deal breaker for you? Or do you relish the upgrade in technology? Will you be trying the iPhone 5 or the AirPods? Let us know in the comments below.
|
||||
|
||||
我们的作者已经给了你很多他们对于智能手机移除耳机接口的看法。你怎么看待智能手机移除耳机接口?你会忽略智能手机移除耳机接口可能对你带来的影响吗?智能手机是否移除耳机接口会影响你的智能手机购买选择吗?你是会尝试使用 iPhone 5 还是使用 AirPods?让我们在评论区了解你的看法。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.maketecheasier.com/should-smartphones-do-away-with-the-headphone-jack/?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+maketecheasier
|
||||
|
||||
作者:[Laura Tucker][a]
|
||||
译者:[WangYueScream](https://github.com/WangYueScream) [LemonDemo](https://github.com/LemonDemo)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.maketecheasier.com/author/lauratucker/
|
||||
|
||||
|
||||
|
||||
|
61
published/20160511 4 Container Networking Tools to Know.md
Normal file
61
published/20160511 4 Container Networking Tools to Know.md
Normal file
@ -0,0 +1,61 @@
|
||||
4 个你需要了解的容器网络工具
|
||||
===========
|
||||
|
||||
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/network-crop.jpeg?itok=Na1tb9aR)
|
||||
|
||||
> [Creative Commons Zero][1]
|
||||
|
||||
有如此之多的各种新的云计算技术、工具和技术需要我们跟进,到底从哪里开始学习是一个艰难的决定。这一系列[下一代云计算技术][2]的文章旨在让你快速了解新兴和快速变化领域的重大项目和产品,比如软件定义网络(SDN)、容器,以及其交叉领域:容器网络。
|
||||
|
||||
对于企业容器部署,容器和网络之间的关系仍然是一个挑战。容器需要网络功能来连接分布式应用程序。根据一篇最新的[企业网络星球][3]的文章,一部分的挑战是“以隔离的方式部署容器,在提供隔离自己容器内数据的所需功能的同时,保持有效的连接性”。
|
||||
|
||||
流行的容器平台 [Docker][4],使用了软件定义虚拟网络来连接容器与本地网络。此外,它使用 Linux 的桥接功能和虚拟可扩展局域网(VXLAN)技术,可以在同一 Swarm 或容器集群内互相沟通。Docker 的插件架构也支持其他网络管理工具来管理容器网络,比如下面的提到的工具。
|
||||
|
||||
容器网络上的创新使得容器可以跨主机连接到其他容器上。这使开发人员可以在开发环境中,在一个主机上部署一个容器来运行一个应用,然后可以过渡到测试环境中,进而到生产环境中,使应用可以持续集成,敏捷开发,快速部署。
|
||||
|
||||
容器网络工具有助于实现容器网络的可扩展性,主要是通过:
|
||||
|
||||
1. 使复杂的,多主机系统能够跨多个容器主机进行分发。
|
||||
2. 允许构建跨越多个公有云和私有云平台上的大量主机的容器系统。
|
||||
|
||||
![](https://www.linux.com/sites/lcom/files/styles/floated_images/public/john-willis_k.jpg?itok=lTsH9eqI)
|
||||
|
||||
*John Willis speaking 在 Open Networking Summit 2016.*
|
||||
|
||||
要获取更多信息,查看 [Docker 网络教程][5],是由 Brent Salisbury 和 John Willis 在最近的 [Open Networking Summit (ONS)][6]讲演的。更多关于 ONS 的演讲内容可以在[这里][7]找到。
|
||||
|
||||
你应该知道的容器网络工具和项目包括下述:
|
||||
|
||||
- [Calico][8] -- Calico 项目(源自 [Metaswitch][9])利用边界网关协议(BGP)和集成的云编排系统来保证虚拟机和容器之间的 IP 通信安全。
|
||||
- [Flannel][10] -- Flannel (之前叫 rudder) 源自 [CoreOS][11],它提供了一个覆盖网络,可以作为一个现有的 SDN 解决方案的替代品。
|
||||
- [Weaveworks][12] -- Weaveworks 项目管理容器的工具包括 [Weave Net][13]、Weave Scope、Weave Flux。Weave Net 是一种用于构建和部署 Docker 容器的网络工具。
|
||||
- [Canal][14] -- 就在本周,CoreOS 和 Tigera 宣布了新的开源项目 Canal 的信息。据其声明,Canal 项目旨在结合部分 Calico 和 Flannel,“构造网络安全策略到网络架构和云管理平台之中”。
|
||||
|
||||
你可以通过 Linux 基金会的免费“云基础设施技术”课程来了解更多关于容器管理、软件定义网络和其他下一代云技术,这是一个在 edX 上提供的大规模公开在线课程。[课程注册目前已经开放][15],课程内容于 6 月开放。
|
||||
|
||||
------
|
||||
|
||||
via: https://www.linux.com/news/4-container-networking-tools-know
|
||||
|
||||
作者:[AMBER ANKERHOLZ][a]
|
||||
译者:[Bestony](https://github.com/Bestony)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linux.com/users/aankerholz
|
||||
[1]: https://www.linux.com/licenses/category/creative-commons-zero
|
||||
[2]: https://www.linux.com/news/5-next-gen-cloud-technologies-you-should-know
|
||||
[3]: http://www.enterprisenetworkingplanet.com/datacenter/datacenter-blog/container-networking-challenges-for-the-enterprise.html
|
||||
[4]: https://docs.docker.com/engine/userguide/networking/dockernetworks/
|
||||
[5]: https://youtu.be/Le0bEg4taak
|
||||
[6]: http://events.linuxfoundation.org/events/open-networking-summit
|
||||
[7]: https://www.linux.com/watch-videos-from-ons2016
|
||||
[8]: https://www.projectcalico.org/
|
||||
[9]: http://www.metaswitch.com/cloud-network-virtualization
|
||||
[10]: https://coreos.com/blog/introducing-rudder/
|
||||
[11]: https://coreos.com/
|
||||
[12]: https://www.weave.works/
|
||||
[13]: https://www.weave.works/products/weave-net/
|
||||
[14]: https://github.com/tigera/canal
|
||||
[15]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-cloud-infrastructure-technologies?utm_source=linuxcom&utm_medium=article&utm_campaign=cloud%20mooc%20article%201
|
@ -1,36 +1,35 @@
|
||||
Terminator 一款一个窗口包含多个终端的 Linux 终端仿真器
|
||||
Terminator:一款一个窗口包含多个终端的 Linux 终端仿真器
|
||||
=============================================================================
|
||||
|
||||
![](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/lots-of-terminals-in-terminator_1.jpg?659)
|
||||
|
||||
为了通过命令行和系统互动,每一款 Linux 发行版都有一款默认的终端仿真器。但是,默认的终端应用可能不适合你。为了加快你工作的速度,有好多款终端应用提供给你更多的功能来同时执行更多的任务。这些有用的终端仿真器包括 Terminator,一款 Linux 系统下支持多窗口的免费的终端仿真器。
|
||||
|
||||
为了通过命令行和系统互动,每一款 Linux 发行版都有一款默认的终端仿真器。但是,默认的终端应用可能不适合你。为了大幅提升你工作的速度,有好多款终端应用提供了更多的功能,可以同时执行更多的任务。这些有用的终端仿真器就包括 Terminator,这是一款 Linux 系统下支持多窗口的自由开源的终端仿真器。
|
||||
|
||||
### 什么是 Linux 终端仿真器
|
||||
|
||||
Linux 终端仿真器是一个让你和 shell 交互的程序。所有的 Linux 发行版都会自带一款 Linux 终端应用让你向 shell 传递命令。
|
||||
|
||||
### Terminator,一款免费的 Linux 终端应用
|
||||
### Terminator,一款自由开源的 Linux 终端应用
|
||||
|
||||
Terminator 是一款 Linux 终端模拟器,提供了你的默认的终端应用不支持的多个特性。它提供了在一个窗口创建多个终端的功能,加快你的工作速度。除了多窗口外,它也允许你修改其他特性,例如字体、字体颜色、背景色等等。让我们看看我们如何安装它,并且如何在不同的 Linux 发行版下使用 Terminator。
|
||||
Terminator 是一款 Linux 终端模拟器,提供了你的默认的终端应用不支持的多个特性。它提供了在一个窗口创建多个终端的功能,以加快你的工作速度。除了多窗口外,它也允许你修改其它特性,例如字体、字体颜色、背景色等等。让我们看看我们如何安装它,并且如何在不同的 Linux 发行版下使用 Terminator。
|
||||
|
||||
### 如何在 Linux 下安装Terminator?
|
||||
### 如何在 Linux 下安装 Terminator?
|
||||
|
||||
#### 在基于 Ubuntu 的发行版上安装 Terminator
|
||||
|
||||
Terminator 在默认的 Ubuntu 仓库就可以使用。所以你不需要添加额外的 PPA。只需要使用 APT 或者 软件应用在 Ubuntu 下直接安装。
|
||||
Terminator 在默认的 Ubuntu 仓库就可以使用。所以你不需要添加额外的 PPA。只需要使用 APT 或者“软件应用”在 Ubuntu 下直接安装。
|
||||
|
||||
```
|
||||
sudo apt-get install terminator
|
||||
```
|
||||
|
||||
假如你的默认的仓库中 Terminator 不可使用,只需要使用源码编译 Terminator 即可。
|
||||
假如你的默认的仓库中 Terminator 不可用,只需要使用源码编译 Terminator 即可。
|
||||
|
||||
[下载源码][1]
|
||||
- [下载源码][1]
|
||||
|
||||
下载 Terminator 源码并且解压到你的桌面。现在打开你的默认的终端然后 cd 到解压的目录。
|
||||
下载 Terminator 源码并且解压到你的桌面。现在打开你的默认的终端,然后 `cd` 到解压的目录。
|
||||
|
||||
现在就可以使用下面的命令来安装 Terminator 了 -
|
||||
现在就可以使用下面的命令来安装 Terminator 了:
|
||||
|
||||
```
|
||||
sudo ./setup.py install
|
||||
@ -44,17 +43,17 @@ dnf install terminator
|
||||
|
||||
#### 在 OpenSuse 上安装 Terminator
|
||||
|
||||
[在 OPENSUSE 上安装][2]
|
||||
参见此文:[在 OPENSUSE 上安装][2]。
|
||||
|
||||
### 如何在一个窗口使用多个终端?
|
||||
|
||||
安装好 Terminator 之后,你可以简单的在一个窗口打开多个终端。只需要右键并选择。
|
||||
安装好 Terminator 之后,你可以简单的在一个窗口打开多个终端。只需要右键点击并切分。
|
||||
|
||||
![](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/multiple-terminals-in-terminator_orig.jpg)
|
||||
|
||||
![](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/multiple-terminals-in-terminator-emulator.jpg?697)
|
||||
|
||||
只要你愿意,你可以创建尽可能多的终端,如果你能管理它们的话。
|
||||
只要你愿意,你可以创建尽可能多的终端,只要你能管理得过来。
|
||||
|
||||
![](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/lots-of-terminals-in-terminator.jpg?706)
|
||||
|
||||
@ -68,17 +67,15 @@ dnf install terminator
|
||||
|
||||
### 结论:什么是你最喜欢的终端模拟器
|
||||
|
||||
Terminator 是一款高级的终端模拟器,它让你自定义界面。如果你还没有从你默认的终端模拟器中切换过来的话,你可以尝试一下它。我知道你将会喜欢上它。如果你在使用其他的免费的终端模拟器的话,请让我们知道你最喜欢的那一款。而且不要忘了和你的朋友分享这篇文章。或许你的朋友正在寻找类似的东西。
|
||||
|
||||
|
||||
Terminator 是一款先进的终端模拟器,它可以让你自定义界面。如果你还没有从你默认的终端模拟器中切换过来的话,你可以尝试一下它。我知道你将会喜欢上它。如果你正在使用其他的自由开源的终端模拟器的话,请让我们知道你最喜欢的那一款。不要忘了和你的朋友分享这篇文章。或许你的朋友正在寻找类似的东西。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/mandatory-access-control-with-selinux-or-apparmor-linux/
|
||||
via: http://www.linuxandubuntu.com/home/terminator-a-linux-terminal-emulator-with-multiple-terminals-in-one-window
|
||||
|
||||
作者:[author][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
译者:[yangmingming](https://github.com/yangmingming)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
459
published/20160729 Best Password Manager all platform.md
Normal file
459
published/20160729 Best Password Manager all platform.md
Normal file
@ -0,0 +1,459 @@
|
||||
全平台最佳密码管理工具大全:支持 Windows、Linux、Mac、Android、iOS 以及企业应用
|
||||
===============
|
||||
|
||||
![](https://4.bp.blogspot.com/-uMOdpnxBV9w/V5x4YW54SbI/AAAAAAAAo_E/o-gUmO46UB0Ji2IMzd_xdY5pVsCcJnFwQCLcB/s1600/free-best-password-manager-2016.png)
|
||||
|
||||
当谈到你的网络安全的防护时,从各种网络威胁的角度来看,仅安装一个防病毒软件或运行一个[安全的 Linux 操作系统][1],并不意味你就是足够安全的。
|
||||
|
||||
今天大多数网络用户都容易受到网络攻击,并不是因为他们没有使用最好的防病毒软件或其他安全措施,而是因为他们使用了[弱密码][2]来保护他们自己的网上帐号。
|
||||
|
||||
密码是你抵御网络威胁的最后一道防线。只要回顾一下最近的一些数据泄露和网络攻击,包括大众关注的 [OPM(美国联邦人事管理局)][3]和婚外情网站 [Ashley Madison][4] 的数据泄露,都导致成千上万的记录的网上曝光。
|
||||
|
||||
虽然你不能控制数据泄露,但创建强壮的、可以抵御字典和[暴力破解][5]的密码仍然是重要的。
|
||||
|
||||
你知道,你的密码越长,它越难破解。
|
||||
|
||||
### 如何保证在线服务的安全?
|
||||
|
||||
安全研究人员喋喋不休地劝说在线用户为他们的各种网上账户创建长的、复杂和各异的密码。这样,如果一个网站被攻破,你在其他网站上的帐户是安全的,不会被黑客攻击。
|
||||
|
||||
理想的情况下,你的密码必须至少16个字符长,应该包含数字、符号、大写字母和小写字母,而最重要的是,甚至你都不知道的密码才是最安全的密码。
|
||||
|
||||
密码应该不重复,而且不包含任何字典中的词汇、代词,你的用户名或 ID 号,以及任何其它预定义的字母或数字序列。
|
||||
|
||||
我知道记住这样的复杂的密码字符串是一个实在痛苦的过程,除非我们是一个人型超级计算机,为不同的在线账户记住不同的密码并不是一个轻松的任务。
|
||||
|
||||
问题是,现在人们注册了大量的在线网站和服务,为每一个帐户创建和记住不同的密码通常是很难的。
|
||||
|
||||
不过,幸运的是,我们可以让这个事情变得很轻松,不断涌现的面向桌面计算机和智能电话的口令管理器可以显著地降低你密码记忆难度,从而治愈你设置弱密码的坏毛病。
|
||||
|
||||
### 密码管理器是什么?
|
||||
|
||||
![](https://1.bp.blogspot.com/-LY7pI45tMq0/V5r_XV083RI/AAAAAAAAo6M/MivILg0_4Vs7UgLKZJqM5vhvYujQCCcpgCLcB/s1600/best-password-manager-software.png)
|
||||
|
||||
在过去的几年里,密码管理软件已经取得了长足的进展,它是一个很好的系统,不但可以让你为不同的网站创建复杂的密码,而且能让你记住它们。
|
||||
|
||||
密码管理器是一个为你的个人电脑、网站,应用程序和网络创建、存储和整理密码的软件。
|
||||
|
||||
密码管理器可以生成密码,也可以作为表单填充器,它可以自动在网站的登录表单中输入你的用户名和密码。
|
||||
|
||||
所以,如果你想为你的多个在线帐户设置超级安全的密码,但你又不想全部记住它们,密码管理器是你最好的选择。
|
||||
|
||||
### 密码管理器如何工作?
|
||||
|
||||
通常,密码管理器可以为您生成冗长、复杂,而且更重要的是唯一的密码字符串,然后以加密形式存储它们,以保护该机密数据免受黑客对您的 PC 或移动设备的物理访问。
|
||||
|
||||
加密的文件只能通过“主密码”访问。因此,所有你需要做的只是记住一个“主密码”,用来打开你的密码管理器或保险库,从而解锁你所有的其他密码。
|
||||
|
||||
然而,你需要确保你的主密码是超级安全的,至少 16 个字符。
|
||||
|
||||
### 哪个是最好的密码管理器?如何选择?
|
||||
|
||||
我一直在推荐密码管理器,但大多数读者总是问:
|
||||
|
||||
- 哪个密码管理器最好?
|
||||
- 哪个密码管理器最安全?帮帮我!
|
||||
|
||||
所以,今天我要介绍给你一些最好的密码管理器,它们可在 Windows、Mac、Linux、Android、iOS 和企业中使用。
|
||||
|
||||
在为你的设备选择一个好的密码管理器之前,你应该检查以下功能:
|
||||
|
||||
- 跨平台应用
|
||||
- 零知识模型
|
||||
- 提供双因素认证(或者多因素身份验证)
|
||||
|
||||
注意:一旦采用,就要按照密码管理器的方式来用,因为如果你仍然为你的重要在线帐户使用弱密码的话,没有人可以从恶意黑客那里拯救你。
|
||||
|
||||
### Windows 最佳密码管理工具
|
||||
|
||||
![](https://2.bp.blogspot.com/-8MUEI5RctdA/V5sDM_oCoaI/AAAAAAAAo60/LX4AktoS_f0JeYDORSqmDZMfmsbOa6QnACLcB/s1600/Best-Password-Manager-for-Windows.png)
|
||||
|
||||
Windows 用户最容易受到网络攻击,因为 Windows 操作系统一直是黑客最喜欢的目标。所以,对于 Windows 用户来说,使用一个好的密码管理器是重要的。
|
||||
|
||||
除了下述以外,Windows 其它的密码管理器还有:Password Safe、LockCrypt、1Password。
|
||||
|
||||
#### 1. Keeper 密码管理器(跨平台)
|
||||
|
||||
![](https://1.bp.blogspot.com/-9ISKGyTAX9U/V5xec18I21I/AAAAAAAAo8E/i8IqZXXpDwMGe8wnI6Adj3qduR_Qm5o3ACLcB/s1600/keeper-Password-Manager-for-mac-os-x.png)
|
||||
|
||||
Keeper 是一个安全、易用而稳健的密码管理器,支持 Windows、Mac、iPhone、iPad 和 iPod 设备。
|
||||
|
||||
通过使用军事级 256 位 AES 加密技术,Keeper 密码管理器可以让您的数据安全在窥探之下保持安全。
|
||||
|
||||
它的安全的数字保险柜,用于保护和管理您的密码,以及其他秘密信息。Keeper 密码管理器应用程序支持双因素身份验证,可用于各大主流操作系统。
|
||||
|
||||
它还有一个称为“自毁”的重要的安全功能,启用后,如果不正确的错误地输入主密码达五次以上,它将删除设备中的所有记录!
|
||||
|
||||
但您不必担心,因为此操作不会删除存储在 Keeper 上的云安全保险柜上的备份记录。
|
||||
|
||||
下载 Keeper 密码管理器: [Windows、Linux 和 Mac][6] | [iOS][7] | [Android][8] | [Kindle][9]
|
||||
|
||||
#### 2. Dashlane 密码管理器(跨平台)
|
||||
|
||||
![](https://3.bp.blogspot.com/-2BuFpcAe9K8/V5xjugOWPuI/AAAAAAAAo9A/wpooAjcH74EzxfNJwrFu-Mcn0IkwiRGjACLcB/s1600/Dashlane-Password-Manager-for-Android.png)
|
||||
|
||||
DashLane 密码管理器有点新,但它几乎为每个平台提供了极棒的功能。
|
||||
|
||||
DashLane 密码管理器通过在本地计算机上使用 AES-256 加密技术来加密您的个人信息和帐户密码,然后将其同步到其在线服务器,以便您可以从任何地方访问您的帐户数据库。
|
||||
|
||||
DashLane 最好的一点是它有一个自动密码更改器,可以自动更改您的帐户的密码,而不必自己处理。
|
||||
|
||||
DashLane 密码管理器 Android 版为您的 Android 手机提供了安全的密码管理工具:密码保险库和在线商店及其他网站的表单自动填充器。
|
||||
|
||||
Android 的 DashLane 密码管理器在单个设备上使用完全免费,如要在多个设备上访问,您可以购买该应用的收费的高级版本。
|
||||
|
||||
下载 DashLane 密码管理器: [Windows][10] 和 [Mac][11] | [iOS][12] | [Android][13]
|
||||
|
||||
#### 3. LastPass 密码管理器(跨平台)
|
||||
|
||||
![](https://3.bp.blogspot.com/--o_hWTgXh2M/V5sAjw7FlYI/AAAAAAAAo6U/Ajmvt0rgRAQE3M_YeYurpbsUoLBN8OTLwCLcB/s1600/LastPass-Password-Manager-for-Windows.png)
|
||||
|
||||
LastPass 是 Windows 用户最好的密码管理器之一,它可以通过扩展插件、移动应用程序,甚至桌面应用程序支持所有的浏览器和操作系统。
|
||||
|
||||
LastPass 是一个非常强大的基于云的密码管理器软件,它使用 AES-256 加密技术来加密您的个人信息和帐户密码,甚至提供各种双因素身份验证选项,以确保没有其他人可以登录您的密码保险柜中。
|
||||
|
||||
LastPass 密码管理器是免费的,收费的高级版本支持指纹读取器。
|
||||
|
||||
下载 LastPass 密码管理器: [Windows、Mac 和 Linux][14] | [iOS][15] | [Android][16]
|
||||
|
||||
### Mac OS X 最佳密码管理器
|
||||
|
||||
![](https://2.bp.blogspot.com/-lEim3E-0wcg/V5sFhOVYK7I/AAAAAAAAo7A/z6Lp8_ULdJAD8ErZ1a-FevXPO8nR3JKNACLcB/s1600/Best-Password-Manager-for-mac-os-x.png)
|
||||
|
||||
人们经常说,Mac 电脑比 Windows 更安全,“Mac 没有病毒”,但它是不完全正确的。
|
||||
|
||||
作为证据,你可以阅读我们以前的关于对 Mac 和 iOS 用户进行网络攻击的文章,然后自己决定需要不需要一个密码管理器。
|
||||
|
||||
除了下述以外,Mac OS X 其它的密码管理器还有:1Password,Dashlane,LastPass,OneSafe,PwSafe。
|
||||
|
||||
#### 1. LogMeOnce 密码管理器(跨平台)
|
||||
|
||||
![](https://4.bp.blogspot.com/-fl64fXK2bdA/V5sHL215j_I/AAAAAAAAo7M/fbn4EsrQMkU3tWWfiAsWlTgKKXb0oEzlwCLcB/s1600/LogMeOnce-Password-Manager-for-Mac-os-x.png)
|
||||
|
||||
LogMeOnce 密码管理套件是 Mac OS X 上的最佳密码管理器之一,并且可以在 Windows,iOS 和 Android 设备上同步您的密码。
|
||||
|
||||
LogMeOnce 是最好的收费的企业密码管理软件之一,提供各种功能和选项,包括 Mugshot(嫌犯照片)功能。
|
||||
|
||||
如果您的手机被盗,LogMeOnce Mugshot 功能可以跟踪小偷的位置,并秘密拍摄试图在未经许可访问您的帐户的入侵者的照片。
|
||||
|
||||
LogmeOnce 使用军用级 AES-256 加密技术保护您的密码,并提供双因素身份验证,以确保即使掌握了主密码,窃贼也无法窃取您的帐户。
|
||||
|
||||
下载 LogMeOnce 密码管理器: [Windows and Mac][17] | [iOS][18] | [Android][19]
|
||||
|
||||
#### 2. KeePass 密码管理器(跨平台)
|
||||
|
||||
![](https://4.bp.blogspot.com/-XWwdG1z9sDw/V5sA7azAy6I/AAAAAAAAo6c/dkkfMRuxDoE_gi5OMRvDOUFq15P5NRO6QCLcB/s1600/Keepass-Password-Manager-for-Windows.png)
|
||||
|
||||
虽然 LastPass 是最好的密码管理器之一,有些人不喜欢基于云的密码管理器。
|
||||
|
||||
KeePass 是一个流行的 Windows 密码管理器应用程序,但也有浏览器扩展和 KeePass 的移动应用程序。
|
||||
|
||||
用于 Windows 的 KeePass 密码管理器将您的帐户密码存储在您的 PC 上,因此您仍然可以控制它们,也可以放在 Dropbox 上,因此您可以使用多个设备访问它。
|
||||
|
||||
KeePass 使用当前已知的最安全的加密技术加密您的密码和登录信息:默认情况下为 AES 256 位加密,或可选地用 Twofish 256 位加密技术。
|
||||
|
||||
KeePass 不仅仅是免费的,它也是开源的,这意味着它的代码和完整性可以被任何人检查,从而赢得了更多的信任度。
|
||||
|
||||
下载 KeePass 密码管理器: [Windows 和 Linux][20] | [Mac][21] | [iOS][22] | [Android][23]
|
||||
|
||||
#### 3. 苹果 iCloud 钥匙串
|
||||
|
||||
![](https://4.bp.blogspot.com/-vwY_dmsKIBg/V5xfhIZGxxI/AAAAAAAAo8M/OjPrBsp9GysF-bK3oqHtW74hKNYO61W9QCLcB/s1600/Apple-iCloud-Keychain-Security.png)
|
||||
|
||||
苹果推出了 iCloud 钥匙串密码管理系统,提供了一种方便的、可以在您获准的 Apple 设备(包括 Mac OS X、iPhone 和 iPad)上安全地存储和自动同步所有登录凭据、Wi-Fi 密码和信用卡号码的方式。
|
||||
|
||||
您的钥匙串中的密码数据使用 256 位 AES 加密技术进行加密,并使用椭圆曲线非对称加密和密钥封装。
|
||||
|
||||
此外,iCloud 钥匙串还会生成新的、独特的和强大的密码,用于保护您的计算机和帐户。
|
||||
|
||||
主要限制:钥匙串不能与 Apple Safari 之外的其他浏览器一起使用。
|
||||
|
||||
参阅:[如何设置 iCloud 钥匙串?][24]
|
||||
|
||||
### Linux 最佳密码管理器
|
||||
|
||||
![](https://1.bp.blogspot.com/-2zDAqYEQTQA/V5xgbo_OcQI/AAAAAAAAo8Y/hWzGLW7R4vse3QnpCM5-qmSHLtzK5M1VACLcB/s1600/best-Password-Manager-for-linux.png)
|
||||
|
||||
毫无疑问,一些 Linux 发行版是地球上最安全的操作系统,但正如我上面所说,采用 Linux 不能完全保护您的在线帐户免受黑客攻击。
|
||||
|
||||
有许多跨平台密码管理器可用于在所有设备上同步所有帐户的密码,例如 LastPass、KeePass、RoboForm 密码管理器。
|
||||
|
||||
下面我列出了两个 Linux 上流行和安全的开源密码管理器:
|
||||
|
||||
#### 1. SpiderOak 加密密码管理器(跨平台)
|
||||
|
||||
![](https://4.bp.blogspot.com/-SZkmP7dpXZM/V5xiKeuT4KI/AAAAAAAAo8s/QhvfBz3OX78IUit_HLym0sdKxlz99qFfgCLcB/s1600/SpiderOak-Encryptr-Password-Manager-for-linux.png)
|
||||
|
||||
爱德华·斯诺登推荐的由 SpiderOak 开发的 Encryptr 密码管理器是一个零知识的基于云的密码管理器,使用 Crypton JavaScript 框架加密保护您的密码。
|
||||
|
||||
它是一个跨平台、开源和免费的密码管理器,使用端到端加密,可以完美地工作于 Ubuntu、Debian Linux Mint 和其它 Linux 发行版。
|
||||
|
||||
Encryptr 密码管理器应用程序本身非常简单,带有一些基本功能。
|
||||
|
||||
Encryptr 软件允许您加密三种类型的内容:密码、信用卡号码和常规的键值对。
|
||||
|
||||
下载 Encryptr 密码管理器: [Windows、Linux 和 Mac][25] | [iOS][26] | [Android][27]
|
||||
|
||||
#### 2. EnPass 密码管理器(跨平台)
|
||||
|
||||
![](https://4.bp.blogspot.com/-_IF81t9rL7U/V5xhBIPUSHI/AAAAAAAAo8c/6-kbLXTl2G0EESTH4sP9KvZLzTFlCyypACLcB/s1600/EnPass-Password-Manager-for-Linux.png)
|
||||
|
||||
Enpass 是一个优秀的安全导向的 Linux 密码管理器,在其它平台也能很好地工作。
|
||||
|
||||
Enpass 可让您使用第三方云服务(包括 Google 云端硬盘、Dropbox、OneDrive 或 OwnCloud)备份和恢复存储的密码。
|
||||
|
||||
它确保提供高级别的安全性,并通过主密码保护您的数据,在将备份上传到云上之前,使用开源加密引擎 SQLCipher 的 256 位 AES 加密技术进行加密。
|
||||
|
||||
> “我们不会在我们的服务器上托管您的 Enpass 数据,因此,我们不需要注册,您的数据只存储在您的设备上,”Enpass 说。
|
||||
|
||||
此外,默认情况下,当您离开计算机时,Enpass 会锁定自己,并且每隔 30 秒清除剪贴板内存,以防止您的密码被任何其他恶意软件窃取。
|
||||
|
||||
下载 EnPass 密码管理器: [Windows][28]、[Linux][29] | [Mac][30] | [iOS][31] | [Android][32]
|
||||
|
||||
#### 3. RoboForm 密码管理器(跨平台)
|
||||
|
||||
![](https://3.bp.blogspot.com/-g8Qf9V1EdqU/V5sBkDk614I/AAAAAAAAo6k/5ZTr9LyosU82F16GxajewvU4sWYyJFq5gCLcB/s1600/Roboform-Password-Manager-for-Windows.png)
|
||||
|
||||
你可以很容易地在 Windows 操作系统上找到好的密码管理器,但 RoboForm 免费密码管理器软件不止于此。
|
||||
|
||||
除了创建复杂的密码并记住它们,RoboForm 还提供了一个智能表单填充功能,以节省您在浏览网络的时间。
|
||||
|
||||
RoboForm 使用军用级 AES 加密技术来加密您的登录信息和帐户密码,密钥是通过您的 RoboForm 主密码获得的。
|
||||
|
||||
RoboForm 适用于 IE、Chrome 和 Firefox 等浏览器,以及适用于 iOS、Android 和 Windows Phone 等移动平台。
|
||||
|
||||
下载 RoboForm 密码管理器: [Windows 和 Mac][33] | [Linux][34] | [iOS][35] | [Android][36]
|
||||
|
||||
### Android 最佳密码管理器
|
||||
|
||||
![](https://1.bp.blogspot.com/-1PXI2KDrDEU/V5xigbW8lgI/AAAAAAAAo8w/Zv5hrdOcbSU7LA0kYrNpvJ1rxjg7EoOewCLcB/s1600/best-Password-Manager-for-android.png)
|
||||
|
||||
目前全球有超过一半的人使用 Android 设备,因此 Android 用户保护他们的在线帐户、避免黑客总是试图访问这些设备成为一种必要。
|
||||
|
||||
Android 上一些最好的密码管理器应用程序包括 1Password、Keeper、DashLane、EnPass、OneSafe、mSecure 和 SplashID Safe。
|
||||
|
||||
#### 1. 1Password 密码管理器(跨平台)
|
||||
|
||||
![](https://4.bp.blogspot.com/--w3s9SoWgYA/V5xjJwVRUTI/AAAAAAAAo84/BSucybvPdtUKYYcRtDbn-_2cOz-mfMA9gCLcB/s1600/1password-Password-Manager-for-android.png)
|
||||
|
||||
1Password 密码管理器 Anroid 版是管理你的所有账户密码的最佳应用程序之一。
|
||||
|
||||
1Password 密码管理器为每个帐号创建强大、独特和安全的密码,并为你全部记住,你只需要轻轻一点即可登录。
|
||||
|
||||
1Password 密码管理器软件通过 AES-256 加密技术保护您的登录名和密码,并通过您的 Dropbox 帐户将其同步到所有设备,或者存储在本地,你可以用任何其他应用程序来进行同步。
|
||||
|
||||
最近,Android 版本的 1Password 密码管理器应用程序了添加指纹支持来解锁所有的密码,而不是使用您的主密码。
|
||||
|
||||
下载 1Password 密码管理器: [Windows 和 Mac][37] | [iOS][38] | [Android][39]
|
||||
|
||||
#### 2. mSecure密码管理器(跨平台)
|
||||
|
||||
![](https://4.bp.blogspot.com/-nvjjS2dWfPc/V5xkEdAOYvI/AAAAAAAAo9I/EDGfA5hzacIq46gWG-6BD2UPHwQAHD-pgCLcB/s1600/mSecure-password-manager-for-android.png)
|
||||
|
||||
就像其他流行的密码管理器解决方案,Android 下的 mSecure 密码管理器自动生成安全密码,并使用 256 位Blowfish 加密技术存储它们。
|
||||
|
||||
令人印象深刻的独特功能是 mSecure 密码管理器软件提供了在输入 5、10 或 20 次错误的密码后(根据您的设置)自毁数据库的功能。
|
||||
|
||||
您还可以使用 Dropbox 或通过专用 Wi-Fi 网络同步所有设备。不管什么情况下,无论您的云帐户的安全性如何,您的所有数据都会在设备之间安全而加密地传输。
|
||||
|
||||
下载 mSecure 密码管理软件: [Windows 和 Mac][40] | [iOS][41] | [Android][42]
|
||||
|
||||
### iOS 最佳密码管理器
|
||||
|
||||
![](https://4.bp.blogspot.com/-SOXYw_9mFq0/V5xk6Kl8-DI/AAAAAAAAo9Q/AMbEl_t3HjAJ4ZX7gLVoa33z-myE4bK5wCLcB/s1600/best-Password-Manager-for-ios-iphone.png)
|
||||
|
||||
正如我所说,苹果的 iOS 也很容易发生网络攻击,所以你可以使用一些 iOS 下最好的密码管理器应用程序来保护你的在线帐户,它们包括 Keeper、OneSafe、Enpass、mSecure、LastPass、RoboForm、SplashID Safe 和 LoginBox Pro 。
|
||||
|
||||
#### 1. OneSafe 密码管理器(跨平台)
|
||||
|
||||
![](https://2.bp.blogspot.com/-HPEJpqeOs00/V5xlSh7OUxI/AAAAAAAAo9Y/d5qkOy3BieMSxjGrnrnH4fvzUzAzDqhCgCLcB/s1600/onesafe-password-manager-for-ios.png)
|
||||
|
||||
OneSafe 是 iOS 设备最好的密码管理器应用程序之一,它不仅可以存储您的帐户密码,还可以存储敏感文档、信用卡详细信息、照片等。
|
||||
|
||||
iOS 的 OneSafe 密码管理器应用程序使用 AES-256 加密技术(移动设备上可用的最高级别)和 Touch ID 将您的数据用主密码加密。 你还可以为给定文件夹设置附加密码。
|
||||
|
||||
iOS 的 OneSafe 密码管理器还提供了一个支持自动填充登录的应用内浏览器,因此您无需每次都输入登录详细信息。
|
||||
|
||||
除此之外,OneSafe 还为您的帐户的密码提供了高级安全功能,如自动锁定、入侵检测、自毁模式、诱饵安全和双重保护。
|
||||
|
||||
下载 OneSafe 密码管理器:[iOS][43] | [Mac][44] | [Android][45] | [Windows][46]
|
||||
|
||||
#### 2. SplashID 安全密码管理器(跨平台)
|
||||
|
||||
![](https://1.bp.blogspot.com/-FcNub2p-QNE/V5xmDW7QXvI/AAAAAAAAo9o/23VuGUAMCYYS64kKlUqBcfx3JIfBr5gTgCLcB/s1600/SplashID-Safe-password-manager-for-ios.png)
|
||||
|
||||
SplashID Safe 是 iOS 中最古老、最好的密码管理工具之一,它允许用户将其登录数据和其他敏感信息安全地存储在加密记录中。
|
||||
|
||||
您的所有信息,包括网站登录信息、信用卡和社会保障数据、照片和文件附件,都受到 256 位的加密保护。
|
||||
|
||||
用于 iOS 的 SplashID Safe 密码管理器还提供了网络自动填充选项,这意味着您不必在登录时复制粘贴密码。
|
||||
|
||||
免费版本的 SplashID Safe 具有基本的记录存储功能,但您可以选择收费版本,提供跨设备同步以及其它收费功能。
|
||||
|
||||
下载 SplashID 安全密码管理器:[Windows 和 Mac][47] | [iOS][48] | [Android][49]
|
||||
|
||||
#### 3. LoginBox Pro 密码管理器
|
||||
|
||||
![](https://3.bp.blogspot.com/-4GzhwZFXDHQ/V5xogkDk49I/AAAAAAAAo90/69rmVdKD-VUG0kHJXIqE2x-mVlWZEDrYwCLcB/s1600/LoginBox-Pro-Password-Manager-for-ios.png)
|
||||
|
||||
LoginBox Pro 是另一个 iOS 设备上极棒的密码管理器应用程序。该应用程序提供了一个单击登录到你访问的任何网站的功能,使密码管理器应用程序成为登录密码保护的互联网网站的最安全和最快的方式。
|
||||
|
||||
iOS 的 LoginBox 密码管理器应用程序的把密码管理器和浏览器结合到一起。
|
||||
|
||||
从您下载那一刻起,所有登录操作(包括输入信息、点击按钮、复选框或回答安全提问)都会通过 LoginBox 密码管理器自动完成。
|
||||
|
||||
为了安全起见,LoginBox 密码管理器使用硬件加速的 AES 加密技术和密码来加密您的数据并将其保存在您的设备上。
|
||||
|
||||
下载 LoginBox 密码管理器:[iOS][50] | [Android][51]
|
||||
|
||||
### 最佳在线密码管理器
|
||||
|
||||
使用在线密码管理器工具是保护你的个人和私人信息安全,免于黑客和心怀恶意的人攻击的最简单方法。
|
||||
|
||||
在这里,我列出了一些最好的在线密码管理器,你可以依靠它们保持自己的线上安全:
|
||||
|
||||
#### 1. Google 在线密码管理器
|
||||
|
||||
![](https://2.bp.blogspot.com/-HCSzj5tKgwY/V5xqVjjtfgI/AAAAAAAAo-A/OYcgv-S5wmQlAskF1jrEGQAy98ogMnXTgCLcB/s1600/google-online-password-manager.png)
|
||||
|
||||
你知道 Google 有自己的专用密码管理器吗?
|
||||
|
||||
Google Chrome 有一个内置的密码管理器工具,当你使用 Chrome 登录网站或网络服务时,你可以选择用它保存密码。
|
||||
|
||||
你所储存的所有帐户密码都会与你的 Google 帐户同步,方便你通过同一个 Google 帐户在所有装置上使用。
|
||||
|
||||
Chrome 密码管理器可让你通过网络管理你的所有帐户的密码。
|
||||
|
||||
因此,如果您喜欢使用其他浏览器,例如 Windows 10 上的 Microsoft Edge 或 iPhone 上的 Safari,只需访问[passwords.google.com][52],您就会看到一个列表,其中包含您保存在 Chrome 之中所有密码。Google 的双重身份验证会保护此列表。
|
||||
|
||||
#### 2. Clipperz 在线密码管理器
|
||||
|
||||
![](https://2.bp.blogspot.com/-gs8b_N_k6CA/V5xrvzbUIKI/AAAAAAAAo-M/vsTXHZNErkQu6g8v9V1R2FxLkdppZq_GACLcB/s1600/Clipperz-Online-Password-Manager.png)
|
||||
|
||||
Clipperz 是一个免费的跨平台最佳在线密码管理器,不需要你下载任何软件。Clipperz 在线密码管理器使用书签栏或侧栏来直接登录。
|
||||
|
||||
Clipperz 还提供了其软件的密码管理器的离线版本,允许你将密码下载到一个[加密的磁盘][53]或 USB 盘里面,以便你在旅行时可以随身携带,并在离线时访问你的帐户密码。
|
||||
|
||||
Clipperz 在线密码管理器的一些功能还包括密码强度指示器、应用程序锁定、SSL 安全连接、一次性密码和密码生成器。
|
||||
|
||||
Clipperz 在线密码管理器可以在任何支持 JavaScript 的浏览器上工作。
|
||||
|
||||
#### 3. Passpack 在线密码管理器
|
||||
|
||||
![](https://4.bp.blogspot.com/-ng91nPnzbWI/V5xsarl2mqI/AAAAAAAAo-Q/zJlFK-63vugeoyymDL26c5mPiWNsGQjuACLcB/s1600/Passpack-Free-Online-Password-Manager.png)
|
||||
|
||||
Passpack 是一个优秀的在线密码管理器,拥有一套极具竞争力的功能,可为你的不同在线帐户创建、存储和管理密码。
|
||||
|
||||
PassPack 在线密码管理器还允许你与你的家人或同事安全地共享你的密码,以轻松管理多个项目、团队成员、客户和员工。
|
||||
|
||||
你的各个帐户的用户名和密码使用 PassPack 服务器上的 AES-256 加密技术进行加密,即使黑客访问其服务器也无法读取你的登录信息。
|
||||
|
||||
将 PassPack 在线密码管理器工具栏下载到 Web 浏览器并正常浏览 Web。每当你登录任何受密码保护的网站时,PassPack 会保存你的登录数据,以便你不必在其网站上手动保存你的用户名和密码。
|
||||
|
||||
### 最佳企业密码管理器
|
||||
|
||||
在过去 12 个月的过程中,我们看到了互联网历史上最大的数据泄露,而且这种情况年复一年的增多。
|
||||
|
||||
据统计,大多数员工甚至不知道如何在线保护他们自己,这导致公司的业务处于风险之中。
|
||||
|
||||
为了在组织中保持密码共享机制安全,有一些专门为企业使用而设计的密码管理工具,例如 Vaultier、CommonKey、Meldium、PassWork 和 Zoho Vault。
|
||||
|
||||
#### 1. Meldium 企业密码管理软件
|
||||
|
||||
![](https://3.bp.blogspot.com/-3rKr3KUpuiQ/V5xs8JR7pVI/AAAAAAAAo-c/VF1tmKbwPzoJmNvA3Ym69CizG7_VqM6ywCLcB/s1600/Meldium-Enterprise-Password-Manager.png)
|
||||
|
||||
LogMeIn 的 [Meldium 密码管理工具][54]附带一个一键式单点登录解决方案,可帮助企业安全快速地访问网络应用。
|
||||
|
||||
它会自动将用户记录到应用和网站中,而无需输入用户名和密码,也可以跟踪组织内的密码使用情况。
|
||||
|
||||
Meldium 密码管理器非常适合在您的团队成员内共享帐户,而无需共享实际密码,这有助于组织保护自己免受网络钓鱼攻击。
|
||||
|
||||
#### 2. Zoho Vault 密码管理软件
|
||||
|
||||
![](https://2.bp.blogspot.com/-J-N_1wOYxmI/V5xtrz42QWI/AAAAAAAAo-o/QF4n4QAF7ZMBd7uIRdjM6Hdd1MHwsXWQACLcB/s1600/zoho-vault--Enterprise-Password-Manager.png)
|
||||
|
||||
[Zoho Vault][55] 是企业用户最好的密码管理器之一,可帮助您的团队快速、安全地共享密码和其他敏感信息,同时监控每个用户的使用情况。
|
||||
|
||||
您所有的团队成员需要下载 Zoho 浏览器扩展。 Zoho Vault 密码管理器将自动填充您团队存储在共享保险柜中的密码。
|
||||
|
||||
Zoho Vault 还提供了一些功能,可让您监控团队的密码使用情况和安全级别,以便您可以知道谁在使用哪个登录。
|
||||
|
||||
Zoho Vault 企业级软件包甚至会在更改或访问密码时发出警告。
|
||||
|
||||
### 更多安全性,请使用双重身份验证
|
||||
|
||||
![](https://4.bp.blogspot.com/-jDnJBDoibtQ/V5xuHVHukRI/AAAAAAAAo-w/1Erjgk-IvKs__TXwYDz-8Groz9hWEElZgCLcB/s1600/two-factor-authentication-password-security.png)
|
||||
|
||||
无论你的密码有多强大,黑客仍然有可能找到一些或其他方式侵入你的帐户。
|
||||
|
||||
双因素身份验证旨在解决这个问题。对一个密码取而代之的是,它要求你输入第二个口令,这会通过短信发送到你的手机上,或通过电子邮件发送到你的电子邮件地址上。
|
||||
|
||||
因此,我建议你启用[双因素身份验证][56],并使用密码管理器软件来保护你的在线帐户和敏感信息免受黑客攻击。
|
||||
|
||||
------
|
||||
|
||||
via: https://thehackernews.com/2016/07/best-password-manager.html
|
||||
|
||||
作者:[Swati Khandelwal][a]
|
||||
译者:[Bestony](https://github.com/Bestony)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://thehackernews.com/2016/07/best-password-manager.html#author-info
|
||||
[1]: http://thehackernews.com/2016/03/subgraph-secure-operating-system.html
|
||||
[2]: http://thehackernews.com/2016/01/password-security-manager.html
|
||||
[3]: http://thehackernews.com/2015/09/opm-hack-fingerprint.html
|
||||
[4]: http://thehackernews.com/2015/08/ashley-madison-accounts-leaked-online.html
|
||||
[5]: http://thehackernews.com/2013/05/cracking-16-character-strong-passwords.html
|
||||
[6]: https://keepersecurity.com/download.html
|
||||
[7]: https://itunes.apple.com/us/app/keeper-password-manager-digital/id287170072?mt=8
|
||||
[8]: https://play.google.com/store/apps/details?id=com.callpod.android_apps.keeper
|
||||
[9]: http://www.amazon.com/gp/mas/dl/android?p=com.callpod.android_apps.keeper
|
||||
[10]: https://www.dashlane.com/download
|
||||
[11]: https://www.dashlane.com/passwordmanager/mac-password-manager
|
||||
[12]: https://itunes.apple.com/in/app/dashlane-free-secure-password/id517914548?mt=8
|
||||
[13]: https://play.google.com/store/apps/details?id=com.dashlane&hl=en
|
||||
[14]: https://lastpass.com/misc_download2.php
|
||||
[15]: https://itunes.apple.com/us/app/lastpass-for-premium-customers/id324613447?mt=8&ign-mpt=uo%3D4
|
||||
[16]: https://play.google.com/store/apps/details?id=com.lastpass.lpandroid
|
||||
[17]: https://www.logmeonce.com/download/
|
||||
[18]: https://itunes.apple.com/us/app/logmeonce-free-password-manager/id972000703?ls=1&mt=8
|
||||
[19]: https://play.google.com/store/apps/details?id=log.me.once
|
||||
[20]: http://keepass.info/download.html
|
||||
[21]: https://itunes.apple.com/us/app/kypass-companion/id555293879?ls=1&mt=12
|
||||
[22]: https://itunes.apple.com/de/app/ikeepass/id299697688?mt=8
|
||||
[23]: https://play.google.com/store/apps/details?id=keepass2android.keepass2android
|
||||
[24]: https://support.apple.com/en-in/HT204085
|
||||
[25]: https://spideroak.com/opendownload
|
||||
[26]: https://itunes.apple.com/us/app/spideroak/id360584371?mt=8
|
||||
[27]: https://play.google.com/store/apps/details?id=com.spideroak.android
|
||||
[28]: https://www.enpass.io/download-enpass-for-windows/
|
||||
[29]: https://www.enpass.io/download-enpass-linux/
|
||||
[30]: https://itunes.apple.com/app/enpass-password-manager-best/id732710998?mt=12
|
||||
[31]: https://itunes.apple.com/us/app/enpass-password-manager/id455566716?mt=8
|
||||
[32]: https://play.google.com/store/apps/details?id=io.enpass.app&hl=en
|
||||
[33]: http://www.roboform.com/download
|
||||
[34]: http://www.roboform.com/for-linux
|
||||
[35]: https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=331787573&mt=8
|
||||
[36]: https://play.google.com/store/apps/details?id=com.siber.roboform
|
||||
[37]: https://1password.com/downloads/
|
||||
[38]: https://itunes.apple.com/in/app/1password-password-manager/id568903335?mt=8
|
||||
[39]: https://play.google.com/store/apps/details?id=com.agilebits.onepassword&hl=en
|
||||
[40]: https://www.msecure.com/desktop-app/
|
||||
[41]: https://itunes.apple.com/in/app/msecure-password-manager/id292411902?mt=8
|
||||
[42]: https://play.google.com/store/apps/details?id=com.mseven.msecure&hl=en
|
||||
[43]: https://itunes.apple.com/us/app/onesafe/id455190486?ls=1&mt=8
|
||||
[44]: https://itunes.apple.com/us/app/onesafe-secure-password-manager/id595543758?ls=1&mt=12
|
||||
[45]: https://play.google.com/store/apps/details?id=com.lunabee.onesafe
|
||||
[46]: https://www.microsoft.com/en-us/store/apps/onesafe/9wzdncrddtx9
|
||||
[47]: https://splashid.com/downloads.php
|
||||
[48]: https://itunes.apple.com/app/splashid-safe-password-manager/id284334840?mt=8
|
||||
[49]: https://play.google.com/store/apps/details?id=com.splashidandroid&hl=en
|
||||
[50]: https://itunes.apple.com/app/loginbox-pro/id579954762?mt=8
|
||||
[51]: https://play.google.com/store/apps/details?id=com.mygosoftware.android.loginbox
|
||||
[52]: https://passwords.google.com/
|
||||
[53]: http://thehackernews.com/2014/01/Kali-linux-Self-Destruct-nuke-password.html
|
||||
[54]: https://www.meldium.com/
|
||||
[55]: https://www.zoho.com/vault/password-management-tools.html
|
||||
[56]: http://thehackernews.com/2016/07/two-factor-authentication.html
|
36
published/20160805 Introducing React Native Ubuntu.md
Normal file
36
published/20160805 Introducing React Native Ubuntu.md
Normal file
@ -0,0 +1,36 @@
|
||||
React Native Ubuntu 简介
|
||||
=====================
|
||||
|
||||
在 Canonical 的 Webapps 团队,我们总在寻找可以为开发者所用的 web 和 web 相关技术。我们想让每个人生活更轻松,让 web 开发者更加熟悉工具的使用,并且在 Ubuntu 上提供一个使用它们的简单途径。
|
||||
|
||||
我们提供对 web 应用以及创建和打包 Cordova 应用的支持,这使得在 Ubuntu 上使用任意 web 框架来创造美妙的应用体验成为可能。
|
||||
|
||||
其中一个可以在这些情景中使用的主流框架就是 React.js。React.js 是一个拥有声明式编程模型和强大的组件系统的 UI 框架,它主要侧重于 UI 的构建,所以你可以在你喜欢的任何地方用上它。
|
||||
|
||||
然而这些应用场景太广泛了,有时候你可能需要更高的性能,或者能够直接用原生 UI 组件来开发,但是在一个不太熟悉的场景中使用它可能不合时宜。如果你熟悉 React.js,那么通过 React Native 来开发可以毫不费力地将你所有现有的知识和工具迁移到完全的原生组件开发中。React Native 是 React.js 的姐妹项目,你可以用同样的方式和代码来创建一个直接使用原生组件并且拥有原生级别性能的应用,而且这就和你期待的一样轻松快捷。
|
||||
|
||||
![](http://i.imgur.com/ZsSHWXP.png)
|
||||
|
||||
我们很高兴地宣布随着我们对 HTML5 应用的支持,现在可以在 Ubuntu 平台上开发 React Native 应用了。你可以移植你现有的 iOS 或 Android 版本的 React Native 应用,或者利用你的 web 开发技能来创建一个新的应用。
|
||||
|
||||
你可以在 [这里][1] 找到 React Native Ubuntu 的源代码,要开始使用时,跟随 [README-ubuntu.md][2] 的指导,并创建你的第一个应用吧。
|
||||
|
||||
Ubuntu 的支持包括生成软件包的功能。通过 React Native CLI,构建一个 snap 软件包只需要简单执行 `react-native package-ubuntu --snap` 这样的命令。还可以为 Ubuntu 设备构建一个 click 包,这意味着 React Native Ubuntu 应用从一开始就可以放到 Ubuntu 商店了。
|
||||
|
||||
在不久的将来会有很多关于在 Ubuntu 上开发一个 React Native 应用你所需要了解的东西的博文,例如创建应用、开发流程以及打包并发布到商店等等。还会有一些关于怎样开发新型的可复用的模块的信息,这些模块可以给运行时环境增加额外的功能,并且可以发布为 npm 模块。
|
||||
|
||||
赶快去实践一下吧,看看你能创造出些什么来。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://developer.ubuntu.com/en/blog/2016/08/05/introducing-react-native-ubuntu/
|
||||
|
||||
作者:[Justin McPherson][a]
|
||||
译者:[Mars Wong](https://github.com/OneNewLife)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://developer.ubuntu.com/en/blog/authors/justinmcp/
|
||||
[1]: https://github.com/CanonicalLtd/react-native
|
||||
[2]: https://github.com/CanonicalLtd/react-native/blob/ubuntu/README-ubuntu.md
|
@ -0,0 +1,147 @@
|
||||
如何使用 SSHFS 通过 SSH 挂载远程的 Linux 文件系统或者目录
|
||||
============================
|
||||
|
||||
写这篇文章的主要目的就是提供一步一步的指导,关于如何使用 SSHFS 通过 SSH 挂载远程的 Linux 文件系统或目录。
|
||||
|
||||
这篇文章对于那些无论出于什么目的,希望在他们本地的系统中挂载远程的文件系统的用户或者系统管理员有帮助。我们通过 Linux 系统中的一个安装了 SSHFS 客户端进行实际测试,并且成功的挂载了远程的文件系统。
|
||||
|
||||
在我们进一步安装之前,让我们了解一下 SSHFS 的相关内容,以及它是如何工作的。
|
||||
|
||||
![](http://www.tecmint.com/wp-content/uploads/2012/08/Sshfs-Mount-Remote-Linux-Filesystem-Directory.png)
|
||||
*Sshfs 挂载远程的 Linux 文件系统或者目录*
|
||||
|
||||
### 什么是 SSHFS?
|
||||
|
||||
SSHFS(Secure SHell FileSystem)是一个客户端,可以让我们通过 SSH 文件传输协议(SFTP)挂载远程的文件系统并且在本地机器上和远程的目录和文件进行交互。
|
||||
|
||||
SFTP 是一种通过 SSH 协议提供文件访问、文件传输和文件管理功能的安全文件传输协议。因为 SSH 在网络中从一台电脑到另一台电脑传输文件的时候使用数据加密通道,并且 SSHFS 内置在 FUSE(用户空间的文件系统)内核模块,允许任何非特权用户在不修改内核代码的情况下创建他们自己的文件系统。
|
||||
|
||||
在这篇文章中,我们将会向你展示在任意 Linux 发行版上如何安装并且使用 SSHFS 客户端,在本地 Linux 机器上挂载远程的 Linux 文件系统或者目录。
|
||||
|
||||
#### 步骤1:在 Linux 系统上安装 SSHFS
|
||||
|
||||
默认情况下,sshfs 包不存在所有的主流 Linux 发行版中,你需要在你的 Linux 系统中启用 [epel 仓库][1],在 Yum 命令行的帮助下安装 SSHFS 及其依赖。
|
||||
|
||||
```
|
||||
# yum install sshfs
|
||||
# dnf install sshfs 【在 Fedora 22+ 发行版上】
|
||||
$ sudo apt-get install sshfs 【基于 Debian/Ubuntu 的系统】
|
||||
```
|
||||
|
||||
#### 步骤2:创建 SSHFS 挂载目录
|
||||
|
||||
当你安装 SSHFS 包之后,你需要创建一个挂载点目录,在这儿你将要挂载你的远程文件系统。例如,我们在 /mnt/tecmint 下创建挂载目录。
|
||||
|
||||
```
|
||||
# mkdir /mnt/tecmint
|
||||
$ sudo mkdir /mnt/tecmint 【基于 Debian/Ubuntu 的系统】
|
||||
```
|
||||
|
||||
### 步骤 3:使用 SSHFS 挂载远程的文件系统
|
||||
|
||||
当你已经创建你的挂载点目录之后,现在使用 root 用户运行下面的命令行,在 /mnt/tecmint 目录下挂载远程的文件系统。视你的情况挂载目录可以是任何目录。
|
||||
|
||||
下面的命令行将会在本地的 /mnt/tecmint 目录下挂载一个叫远程的一个 /home/tecmint 目录。(不要忘了使用你的 IP 地址和挂载点替换 x.x.x.x)。
|
||||
|
||||
```
|
||||
# sshfs tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint
|
||||
$ sudo sshfs -o allow_other tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint 【基于 Debian/Ubuntu 的系统】
|
||||
```
|
||||
|
||||
如果你的 Linux 服务器配置为基于 SSH 密钥授权,那么你将需要使用如下所示的命令行指定你的公共密钥的路径。
|
||||
|
||||
```
|
||||
# sshfs -o IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint
|
||||
$ sudo sshfs -o allow_other,IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint 【基于 Debian/Ubuntu 的系统】
|
||||
```
|
||||
|
||||
#### 步骤 4:验证远程的文件系统挂载成功
|
||||
|
||||
如果你已经成功的运行了上面的命令并且没有任何错误,你将会看到挂载在 /mnt/tecmint 目录下的远程的文件和目录的列表
|
||||
|
||||
```
|
||||
# cd /mnt/tecmint
|
||||
# ls
|
||||
[root@ tecmint]# ls
|
||||
12345.jpg ffmpeg-php-0.6.0.tbz2 Linux news-closeup.xsl s3.jpg
|
||||
cmslogs gmd-latest.sql.tar.bz2 Malware newsletter1.html sshdallow
|
||||
epel-release-6-5.noarch.rpm json-1.2.1 movies_list.php pollbeta.sql
|
||||
ffmpeg-php-0.6.0 json-1.2.1.tgz my_next_artical_v2.php pollbeta.tar.bz2
|
||||
```
|
||||
|
||||
#### 步骤 5:使用 df -hT 命令检查挂载点
|
||||
|
||||
如果你运行 df -hT命令,你将会看到远程文件系统的挂载点。
|
||||
|
||||
```
|
||||
# df -hT
|
||||
```
|
||||
|
||||
样本输出:
|
||||
|
||||
```
|
||||
Filesystem Type Size Used Avail Use% Mounted on
|
||||
udev devtmpfs 730M 0 730M 0% /dev
|
||||
tmpfs tmpfs 150M 4.9M 145M 4% /run
|
||||
/dev/sda1 ext4 31G 5.5G 24G 19% /
|
||||
tmpfs tmpfs 749M 216K 748M 1% /dev/shm
|
||||
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
|
||||
tmpfs tmpfs 749M 0 749M 0% /sys/fs/cgroup
|
||||
tmpfs tmpfs 150M 44K 150M 1% /run/user/1000
|
||||
tecmint@192.168.0.102:/home/tecmint fuse.sshfs 324G 55G 253G 18% /mnt/tecmint
|
||||
```
|
||||
|
||||
#### 步骤 6:永久挂载远程文件系统
|
||||
|
||||
为了永久的挂载远程的文件系统,你需要修改一个叫 `/etc/fstab` 的文件。照着做,使用你最喜欢的编辑器打开文件。
|
||||
|
||||
```
|
||||
# vi /etc/fstab
|
||||
$ sudo vi /etc/fstab 【基于 Debian/Ubuntu 的系统】
|
||||
```
|
||||
|
||||
移动到文件的底部并且添加下面的一行,保存文件并退出。下面条目表示使用默认的设置挂载远程的文件系统。
|
||||
|
||||
```
|
||||
sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs defaults 0 0
|
||||
```
|
||||
|
||||
确保服务器之间允许 [SSH 无密码登录][2],这样系统重启之后才能自动挂载文件系统。
|
||||
|
||||
如果你的服务器配置为基于 SSH 密钥的认证方式,请加入如下行:
|
||||
|
||||
```
|
||||
sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs IdentityFile=~/.ssh/id_rsa defaults 0 0
|
||||
```
|
||||
|
||||
接下来,你需要更新 fstab 文件使修改生效。
|
||||
|
||||
```
|
||||
# mount -a
|
||||
$ sudo mount -a 【基于 Debian/Ubuntu 的系统】
|
||||
```
|
||||
|
||||
#### 步骤 7:卸载远程的文件系统
|
||||
|
||||
为了卸载远程的文件系统,只需要发出以下的命令即可。
|
||||
|
||||
```
|
||||
# umount /mnt/tecmint
|
||||
```
|
||||
|
||||
目前为止就这样了,如果你在挂载远程文件系统的时候遇到任何问题或者需要任何帮助,请通过评论联系我们,如果你感觉这篇文章非常有用,请分享给你的朋友们。
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/sshfs-mount-remote-linux-filesystem-directory-using-ssh/
|
||||
|
||||
作者:[Ravi Saive][a]
|
||||
译者:[yangmingming](https://github.com/yangmingming)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.tecmint.com/author/admin/
|
||||
[1]: https://linux.cn/article-2324-1.html
|
||||
[2]: https://linux.cn/article-5444-1.html
|
@ -0,0 +1,78 @@
|
||||
在电脑和安卓设备之间使用 FTP 传输文件
|
||||
====
|
||||
|
||||
[![How to transfer files between Linux and Android using FTP](https://itsfoss.com/wp-content/uploads/2016/09/linux-ftp-android.jpg)](https://itsfoss.com/wp-content/uploads/2016/09/linux-ftp-android.jpg)
|
||||
|
||||
每一个使用安卓设备的人都知道可以[使用 USB 线连接电脑来传输文件](https://itsfoss.com/how-to-connect-kindle-fire-hd-with-ubuntu-12-10/),但是不是所有人都知道可以使用自由开源软件(FOSS 软件)通过无线连接到安卓设备。
|
||||
|
||||
我知道,这并非最简易的方式,但这样做的确很有趣而且感觉很极客。所有,如果你有一些 DIY 精神,让我为你展示如何在 Linux 和 安卓设备之间使用 FTP 来传输文件。
|
||||
|
||||
### 第一步:安装必要的软件
|
||||
|
||||
为了连接你的安卓设备,至少需要:一个 FTP 服务器和一个 FTP 客户端。这两者都有不少的选择,个人比较推荐 [Filezilla](https://filezilla-project.org/) 作为客户端,因为它是开源的,而且支持多种平台。
|
||||
|
||||
我最喜欢的 FOSS 安卓应用商店就是 [F-Droid](https://f-droid.org/)。F-Droid 有两个非常棒的 FTP 服务端应用:[primitive ftpd](https://f-droid.org/repository/browse/?fdfilter=ftp&fdid=org.primftpd) 和 [FTP Server (Free)](https://f-droid.org/repository/browse/?fdfilter=ftp&fdid=be.ppareit.swiftp_free)。这两者都只能运行在安卓 4.0 或者更高的版本中。本文我会集中介绍 primitive ftpd,如果使用 FTP Sever (free) 也是一样的步骤。
|
||||
|
||||
### 第二步:熟悉 FTP 服务器
|
||||
|
||||
安装好 FTP 客户端和服务端之后,就是设置两者之间的连接了。先从安卓设备的 FTP 服务端开始,首先,通过应用启动器打开 primitive ftpd。
|
||||
|
||||
[![android-1](https://itsfoss.com/wp-content/uploads/2016/09/android-1-169x300.png)](https://itsfoss.com/wp-content/uploads/2016/09/android-1.png)
|
||||
|
||||
打开应用之后,你将看到一大串的数字。不用紧张,你可以看到服务端已经分配到一个 IP 地址 (本文是 192.168.1.131)。往下看,将看到 FTP 和 SFTP 服务 (SFTP 是一个截然不同的协议,它通过 SSH 进行连接) 都是还未运行的。再往下就是用户名,本文设置为 user。
|
||||
|
||||
在屏幕顶端有两个按钮,一个用于开启 FTP 服务,另一个则是设置 FTP 服务。启动服务是不言自明的。
|
||||
|
||||
[![android-2](https://itsfoss.com/wp-content/uploads/2016/09/android-2-169x300.png)](https://itsfoss.com/wp-content/uploads/2016/09/android-2.png)
|
||||
|
||||
在设置菜单中,可以改变服务器的用户名、访问密码以及所使用的端口。并且你可以设置当服务器激活是阻止待机、服务开机自启或者变更主题。
|
||||
|
||||
![android-2-2](https://itsfoss.com/wp-content/uploads/2016/09/android-2.2-169x300.png)![android-3](https://itsfoss.com/wp-content/uploads/2016/09/android-3-169x300.png)![android-5](https://itsfoss.com/wp-content/uploads/2016/09/android-5-169x300.png)
|
||||
|
||||
### 第三步:使用 Filezilla
|
||||
|
||||
现在打开对应你所用系统的 Filezilla。使用 Filezilla 有两种方法:在需要传输文件时输入 IP、用户名、密码和端口,或者在 Filezilla 中预先保存这些信息(值得注意的是:基本上,每次你打开 FTP 服务时,IP 都会不同的,所用需要更新保存在 Filezilla 中信息)。我会展示这两种方法。
|
||||
|
||||
如果你想要手动输入,直接在 Filezilla 窗口上方输入必要的信息然后点击“快速连接”即可。
|
||||
|
||||
![filezilla-1-2](https://itsfoss.com/wp-content/uploads/2016/09/filezilla-1.2.png)
|
||||
|
||||
需要预先存储信息的话,点击文件菜单下方的按钮,这会打开“站点管理器”对话框,填写你想要保存的信息即可。通常,我设置“登录类型”为“询问密码”,安全为上。如果使用的是 FTP,保存默认选项即可;但如果使用的是 SFTP,必须在协议下拉选项框中进行协议的选择。
|
||||
|
||||
![filezilla-2](https://itsfoss.com/wp-content/uploads/2016/09/filezilla-2.png)
|
||||
|
||||
点击连接,输入密码即可。你会看到一个连接新主机的警告,这是可以在此验证屏幕上显示的“指纹信息”是否与 Primitive FTPD 上的一致。如果一致 (也应该是一致的),点击确认添加都已知主机列表,之后就不会出现该警告了。
|
||||
|
||||
![filezilla-5](https://itsfoss.com/wp-content/uploads/2016/09/filezilla-5.png)
|
||||
|
||||
### 第四步:传输文件
|
||||
|
||||
现在,你会看到两个框,一个是“本地站点”,一个是“远程站点”,对应的呈现了你电脑和安装设备上的目录和文件信息。然后你就可以在电脑端浏览和传输文件到你的安卓设备上了。个人建议上传文件到你的 Download 文件夹,以便于文件跟踪管理。你可以右击某个文件,在弹出的菜单中选择上传或者下载以及移动操作,或者简单双击也行。
|
||||
|
||||
![filezilla-6](https://itsfoss.com/wp-content/uploads/2016/09/filezilla-6.png)
|
||||
|
||||
### 第五步:停止服务
|
||||
|
||||
当你完成文件的传输之后,你需要做得就是停止安卓设备上的 FTP 服务和关闭 Filezilla,如此简单,不是吗?
|
||||
|
||||
### 结论
|
||||
|
||||
我相信会有人指出,FTP 并不安全。而我认为,本例不需要考虑这个问题,因为连接时间一般很短。并且多数情况下,都是在家庭私有网络环境中进行操作。
|
||||
|
||||
这就是我在 Linux 和安卓设备间最喜欢使用的方法。
|
||||
|
||||
觉得有用吗?或有又没觉得推荐的相似软件?请在评论中告诉我们。
|
||||
|
||||
如果觉得此文有用,清花几分钟分享到你常用的社交站点中。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/use-ftp-linux-android/
|
||||
|
||||
作者:[John Paul][a]
|
||||
译者:[GHLandy](https://github.com/GHLandy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/john/
|
@ -0,0 +1,52 @@
|
||||
Windows 的 Linux 子系统之 Archlinux
|
||||
====
|
||||
|
||||
![Arch Linux on Windows Subsystem](https://itsfoss.com/wp-content/uploads/2016/10/Arch-Linux-on-windows-subsystem.jpg)
|
||||
|
||||
Ubuntu 的制造商 [Canonical](http://www.canonical.com/) 早已和微软进行合作,让我们体验了极具争议的 [Bash on Windows](https://itsfoss.com/bash-on-windows/)。外界对此也是褒贬不一,许多 Linux 重度用户则是质疑其是否有用,以及更进一步认为 [Bash on Windows 是一个安全隐患](https://itsfoss.com/linux-bash-windows-security/)。
|
||||
|
||||
Unix 的 Bash 是通过 WSL (Windows Subsystem for Linux,Windows 的 Linux 子系统) 特性移植到了 Windows 中。早先,我们已经展示过 [安装 Bash 到 Windows](https://itsfoss.com/install-bash-on-windows/)。
|
||||
|
||||
Canonical 和微软合作的 Bash on Windows 也仅仅是 Ubuntu 的命令行而已,并非是正规的图形用户界面。
|
||||
|
||||
不过,有个好现象是 Linux 爱好者开始在上面投入时间和精力,他们在 WSL 做到的成绩甚至让最初的开发者都吃惊,“等等,这真的可以吗?”。
|
||||
|
||||
这个正在逐步实现之中。
|
||||
|
||||
![Ubuntu os Win 10](https://itsfoss.com/wp-content/uploads/2016/09/ubuntu-unity-on-windows-10.jpg)
|
||||
|
||||
没错,上图所示就是运行在 Windows 中的 Ubuntu Unity 桌面。一位名为 Pablo Gonzalez (GitHub ID 为 [Guerra24](https://github.com/Guerra24) )的程序员将这个完美实现了。随着这个实现,他向我们展示了 WSL 已经超越了当初构想之时的功能。
|
||||
|
||||
如果现在可以在 Windows 子系统之中运行 Ubuntu Unity,那么运行其他的 Linux 发行版还会远吗?
|
||||
|
||||
### Arch Linux 版的 Bash on Windows
|
||||
|
||||
在 WSL 本地运行完整的 Linux发行版,迟早是要实现的。而我最希望的就是 [Arch Linux](https://www.archlinux.org/) ([Antergos](https://itsfoss.com/tag/antergos/) 爱好者点击此处)。
|
||||
|
||||
![Arch Linux on Windows](https://itsfoss.com/wp-content/uploads/2016/09/awsl.jpg)
|
||||
|
||||
Hold 住,Hold 住,该项目目前还在测试中。它由“mintxomat”在 GitHub 上开发的,最新为 0.6 版本。第一个稳定版将在今年的 12 月底发布。
|
||||
|
||||
那么,该项目的出台会有什么不同呢?
|
||||
|
||||
你可能早就知道,WSL 仅在 Windows 10 中可用。但是 Windows 的 Linux 子系统之 Arch Linux (AWSL) 早已成功的运行在 Windows 7、Windows 8、Windows 8.1 和 Windows Server 2012(R2),当然还有 Windows 10。
|
||||
|
||||
我靠,他们是怎么做到的?!
|
||||
|
||||
其开发者曾说,AWSL 协议抽象归纳了不同 Windows 版本的各种框架。所以,当 AWSL 发布 1.0 应该会取得更大的成绩。如我们之前提到的移植性,该项目会先向所有 Windows 版本推出 Bash on Windows。
|
||||
|
||||
该项目很有雄心,并且很有看头。如果等不及 12 月底的稳定版,你可以先行尝试其测试版。但要记住,目前还是开发者预览版,此刻并不稳定。但是,我们什么时候停止过折腾的脚步?
|
||||
|
||||
你也可到 GitHub 查看此项目的进度:[Arch on Windows Subsystem](https://github.com/turbo/alwsl)
|
||||
|
||||
分享本文,以便大家都知道 Arch Linux 即将登陆 Windows 子系统。同时,也告诉我们,你希望 WSL 中有什么发行版。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/arch-linux-windows-subsystem/
|
||||
|
||||
作者:[Aquil Roshan][a]
|
||||
译者:[GHLandy](https://github.com/GHLandy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
@ -0,0 +1,86 @@
|
||||
使用原子主机(Atomic Host)、Ansible 和 Cockpit 部署容器
|
||||
==============
|
||||
|
||||
![atomic-ansible-cockpit-containers](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/atomic-ansible-cockpit-containers.jpg?fit=945%2C400&ssl=1)
|
||||
|
||||
我在[红帽](https://www.redhat.com/)工作的期间,每天在 [Fedora Atomic host](https://getfedora.org/en/cloud/download/atomic.html) 上使用 [Docker](https://www.docker.com/) 容器。 来自 [原子项目(Project Atomic)](http://www.projectatomic.io/)的原子主机(Atomic Host)是一个轻量级容器操作系统,可以以 Docker 格式运行 Linux 容器。它专门为提高效率而定制,使其成为用于云环境的 Docker 运行时系统的理想选择。
|
||||
|
||||
幸运的是,我发现一个很好的方式来管理在主机上运行的容器:[Cockpit](http://cockpit-project.org/)。 它是一个具有漂亮的 Web 界面的 GNU/Linux 服务器远程管理工具。它可以帮我管理在主机上运行的服务器和容器。你可以在从之前发布在这里的[这篇概述](https://fedoramagazine.org/cockpit-overview/)中了解 Cockpit 的更多信息。不过,我也希望在主机上可以自动运行容器,我可以使用 [Ansible](https://www.ansible.com/) 来完成这个工作。
|
||||
|
||||
请注意,我们不能在原子主机上使用 dnf 命令。原子主机并没有设计为通用操作系统,而是更适合容器和其他用途。但在原子主机上设置应用程序和服务仍然非常容易。这篇文章向您展示了如何自动化和简化这个过程。
|
||||
|
||||
### 设置组件
|
||||
|
||||
开始之前,请确保你的系统上安装了 Ansible。
|
||||
|
||||
```
|
||||
sudo dnf -y install ansible
|
||||
```
|
||||
|
||||
首先,我们需要在原子主机上运行 cockpit 容器。在你的机器上从 https://github.com/trishnaguha/fedora-cloud-ansible 下载它的源代码。
|
||||
|
||||
```
|
||||
$ git clone https://github.com/trishnaguha/fedora-cloud-ansible.git
|
||||
```
|
||||
|
||||
现在切换到 `cockpit` 的目录,并如下编辑 `inventory` 文件:
|
||||
```
|
||||
$ cd fedora-cloud-ansible
|
||||
$ cd cockpit
|
||||
$ vim inventory
|
||||
```
|
||||
|
||||
完成如下修改:
|
||||
|
||||
1. 使用你的原子主机的 IP 替换掉 `IP_ADDRESS_OF_HOST`。
|
||||
2. 用您的 SSH 私钥文件的路径替换 `ansible_ssh_private_key_file ='PRIVATE_KEY_FILE'` 行中的`PRIVATE_KEY_FILE`。
|
||||
|
||||
然后保存并退出 `inventory` 文件编辑。
|
||||
|
||||
接下来,编辑 ansible 配置文件:
|
||||
|
||||
```
|
||||
$ vim ansible.cfg
|
||||
```
|
||||
|
||||
替换 `remote_user=User` 中 `User` 为你的原子主机上的远程用户名。然后保存并退出文件编辑。
|
||||
|
||||
### 结合起来
|
||||
|
||||
现在是运行 Ansible 的 PlayBook 的时候了。此命令开始运行原子主机上的 Cockpit 容器:
|
||||
|
||||
```
|
||||
$ ansible-playbook cockpit.yml
|
||||
```
|
||||
|
||||
Cockpit 现在运行在原子主机上了。使用浏览器去访问你的实例的公网 IP 的 9090 端口——这是 Cockpit 的默认端口。举个例子,如果该实例的 IP 地址是 192.168.1.4,就去访问 192.168.1.4:9090,你将会看到如下的 Web 界面:
|
||||
|
||||
![Cockpit login screen](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-02-27.jpg?ssl=1)
|
||||
|
||||
### 管理你的容器
|
||||
|
||||
使用原子主机的登录信息或以 root 用户身份登录。然后访问 Cockpit 管理器上的 Containers 部分来查看原子主机上运行的容器。在下面的示例中,您会看到我还设置了其他容器,如 [httpd](https://github.com/trishnaguha/fedora-cloud-ansible/tree/master/httpd) 和 [redis](https://github.com/trishnaguha/fedora-cloud-ansible/tree/master/redis):
|
||||
|
||||
![Cockpit panel for managing containers](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-13-05.jpg?ssl=1)
|
||||
|
||||
注意,该界面允许您直接在 Cockpit 管理器中使用 Run 和 Stop 按钮启动和停止容器。您还可以使用 Cockpit 管理器管理您的原子主机。转到 Tools -> Terminals,在这里里你可以使用原子主机的终端:
|
||||
|
||||
![Cockpit terminal panel](https://i1.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-10-03-12-10-19.jpg?ssl=1)
|
||||
|
||||
如果您打算在原子主机上部署容器化的应用程序,则可以简单地为其编写一个 PlayBook。然后,您可以使用 `ansible-playbook` 命令进行部署,并使用 Cockpit 来管理容器。
|
||||
|
||||
![Running ansible-playbook to deploy multiple containers](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/FotoFlexer_Photo51.jpg?ssl=1)
|
||||
|
||||
欢迎你对这个[仓库](https://github.com/trishnaguha/fedora-cloud-ansible)进行分支或添加容器的 PlayBook。
|
||||
|
||||
------
|
||||
|
||||
via: https://fedoramagazine.org/deploy-containers-atomic-host-ansible-cockpit/
|
||||
|
||||
作者:[trishnag][a]
|
||||
译者:[Bestony](https://github.com/Bestony)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/trishnag/
|
@ -1,61 +0,0 @@
|
||||
Translating by WangYueScream
|
||||
============================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Should Smartphones Do Away with the Headphone Jack? Here Are Our Thoughts
|
||||
====
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/Writers-Opinion-Headphone-Featured.jpg)
|
||||
|
||||
Even though Apple removing the headphone jack from the iPhone 7 has been long-rumored, after the official announcement last week confirming the news, it has still become a hot topic.
|
||||
|
||||
For those not in the know on this latest news, Apple has removed the headphone jack from the phone, and the headphones will now plug into the lightning port. Those that want to still use their existing headphones may, as there is an adapter that ships with the phone along with the lightning headphones. They are also selling a new product: AirPods. These are wireless and are inserted into your ear. The biggest advantage is that by eliminating the jack they were able to make the phone dust and water-resistant.
|
||||
|
||||
Being it’s such a big story right now, we asked our writers, “What are your thoughts on Smartphones doing away with the headphone jack?”
|
||||
|
||||
### Our Opinion
|
||||
|
||||
Derrik believes that “Apple’s way of doing it is a play to push more expensive peripherals that do not comply to an open standard.” He also doesn’t want to have to charge something every five hours, meaning the AirPods. While he understands that the 3.5mm jack is aging, as an “audiophile” he would love a new, open standard, but “proprietary pushes” worry him about device freedom.
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/headphone-jacks.jpg)
|
||||
|
||||
Damien doesn’t really even use the headphone jack these days as he has Bluetooth headphones. He hates that wire anyway, so feels “this is a good move.” Yet he also understands Derrik’s point about the wireless headphones running out of battery, leaving him with “nothing to fall back on.”
|
||||
|
||||
Trevor is very upfront in saying he thought it was “dumb” until he heard you couldn’t charge the phone and use the headphones at the same time and realized it was “dumb X 2.” He uses the headphones/headphone jack all the time in a work van without Bluetooth and listens to audio or podcasts. He uses the plug-in style as Bluetooth drains his battery.
|
||||
|
||||
Simon is not a big fan. He hasn’t seen much reasoning past it leaving more room within the device. He figures “it will then come down to whether or not consumers favor wireless headphones, an adapter, and water-resistance over not being locked into AirPods, lightning, or an adapter”. He fears it might be “too early to jump into removing ports” and likes a “one pair fits all” standard.
|
||||
|
||||
James believes that wireless technology is progressive, so he sees it as a good move “especially for Apple in terms of hardware sales.” He happens to use expensive headphones, so personally he’s “yet to be convinced,” noting his Xperia is waterproof and has a jack.
|
||||
|
||||
Jeffry points out that “almost every transition attempt in the tech world always starts with strong opposition from those who won’t benefit from the changes.” He remembers the flak Apple received when they removed the floppy disk drive and decided not to support Flash, and now both are industry standards. He believes everything is evolving for the better, removing the audio jack is “just the first step toward the future,” and Apple is just the one who is “brave enough to lead the way (and make a few bucks in doing so).”
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/Writers-Opinion-Headphone-Headset.jpg)
|
||||
|
||||
Vamsi doesn’t mind the removal of the headphone jack as long as there is a “better solution applicable to all the users that use different headphones and other gadgets.” He doesn’t feel using headphones via a lightning port is a good solution as it renders nearly all other headphones obsolete. Regarding Bluetooth headphones, he just doesn’t want to deal with another gadget. Additionally, he doesn’t get the argument of it being good for water resistance since there are existing devices with headphone jacks that are water resistant.
|
||||
|
||||
Mahesh prefers a phone with a jack because many times he is charging his phone and listening to music simultaneously. He believes we’ll get to see how it affects the public in the next few months.
|
||||
|
||||
Derrik chimed back in to say that by “removing open standard ports and using a proprietary connection too.,” you can be technical and say there are adapters, but Thunderbolt is also closed, and Apple can stop selling those adapters at any time. He also notes that the AirPods won’t be Bluetooth.
|
||||
|
||||
![](https://maketecheasier-2d0f.kxcdn.com/assets/uploads/2016/09/Writers-Opinion-Headphone-AirPods.jpg)
|
||||
|
||||
As for me, I’m always up for two things: New technology and anything Apple. I’ve been using iPhones since a few weeks past the very first model being introduced, yet I haven’t updated since 2012 and the iPhone 5, so I was overdue. I’ll be among the first to get my hands on the iPhone 7. I hate that stupid white wire being in my face, so I just might be opting for AirPods at some point. I am very appreciative of the phone becoming water-resistant. As for charging vs. listening, the charge on new iPhones lasts so long that I don’t expect it to be much of a problem. Even my old iPhone 5 usually lasts about twenty hours on a good day and twelve hours on a bad day. So I don’t expect that to be a problem.
|
||||
|
||||
### Your Opinion
|
||||
|
||||
Our writers have given you a lot to think about. What are your thoughts on Smartphones doing away with the headphone jack? Will you miss it? Is it a deal breaker for you? Or do you relish the upgrade in technology? Will you be trying the iPhone 5 or the AirPods? Let us know in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.maketecheasier.com/should-smartphones-do-away-with-the-headphone-jack/?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+maketecheasier
|
||||
|
||||
作者:[Laura Tucker][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.maketecheasier.com/author/lauratucker/
|
@ -0,0 +1,68 @@
|
||||
OneNewLife translating
|
||||
|
||||
Why Linux pioneer Linus Torvalds prefers x86 chips over ARM processors
|
||||
=============
|
||||
|
||||
**Torvalds has an affinity for x86 because of the infrastructure and ecosystem**
|
||||
|
||||
![linus torvalds](http://core2.staticworld.net/images/article/2015/08/linus_torvalds-100600260-large.jpg)
|
||||
|
||||
*Linus Torvalds addressed a packed auditorium of Linux enthusiasts during his speech at the LinuxWorld show in San Jose, California, on August 10, 1999. Credit: James Niccolai
|
||||
*
|
||||
|
||||
Linux pioneer Linus Torvalds is a stand-up guy—he says what he feels. There’s no sugarcoating, and he’ll admit to faults, like [recent issues][1] with the Linux 4.8 kernel.
|
||||
|
||||
He was [full of surprises][2] at last week’s Linaro Connect conference, when he was asked about his favorite chip architecture. He didn’t blink before saying it was x86, not ARM.
|
||||
|
||||
It may have been the long history of x86 with PCs that influenced his answer. There’s little fragmentation of software and hardware with x86, and things just work.
|
||||
|
||||
People are too fixated with the instruction set and the CPU core, Torvalds said, but it ultimately is the ecosystem around the architecture that matters more.
|
||||
|
||||
“What matters is all the infrastructure around the instruction set, and x86 has all that infrastructure... at a lot of different levels,” Torvalds said. “It’s opening a way that no other architecture is.”
|
||||
|
||||
A lot of application development happens on PCs with x86 chips from Intel or AMD. Compatibility matters for x86 chips and PCs, which have a unified model around hardware, development, and other infrastructure.
|
||||
|
||||
The same can’t be said about ARM. From hardware vendor perspective, that leads to a fragmented market, Torvalds said.
|
||||
|
||||
“Being compatible just wasn’t as big of a deal for the ARM ecosystem as it has been traditionally for the x86 ecosystem,” Torvalds said during a fireside chat with ARM developers listening on.
|
||||
|
||||
|
||||
ARM dominates the mobile-device market, and a majority of devices use Android, which is based on the Linux kernel. But there are a lot of fragmentation in the ARM ecosystem, and that’s caused support and device issues.
|
||||
|
||||
One problem: It’s not possible to make one build of Android that can be deployed across all mobile devices because of different hardware configurations. Hardware makers tune Android to be compatible with chipsets in their devices. One Android update can’t be delivered to all mobile devices, unlike Windows updates to PCs.
|
||||
|
||||
Intel tried to put its x86 chips in smartphones but has now stopped the effort. One of Intel’s goals was to [deliver Android updates][3] that could be downloaded and installed on all x86 handsets.
|
||||
|
||||
There are also ARM server software development issues. Architectural, networking, and I/O characteristics are different on each chipset, and software has to be written to exploit those features. That has significantly slowed down the adoption of ARM in servers. There isn’t a matching problem with x86, which continues to dominate the server market.
|
||||
|
||||
“I’ve been personally pretty disappointed with ARM as a hardware platform, not as an instruction set, though I’ve had my issues there, too,” Torvalds said. “As a hardware platform, it is still not very pleasant to deal with.”
|
||||
|
||||
When he was growing up, Torvalds programmed on an 8-bit 6502 microprocessor in machine code and loved the architecture because the instructions were pipelined, something no other hardware did at the time. That architecture delivered more on-chip performance.
|
||||
|
||||
“What I wanted to upgrade to was Acorn Archimedes ... the thing that gave ARM its name,” Torvalds said. “That was my dream machine for a while.”
|
||||
|
||||
The [Archimedes][4] was a personal computer based on the first ARM RISC chips from Acorn Computer Group. ARM was formed as an offshoot of Acorn.
|
||||
|
||||
Torvalds liked the Archimedes because it had the 6502-like feature of pipelining with RAM chips to get high-performance. Unfortunately, he couldn’t find the computer.
|
||||
|
||||
He went with an “odd British computer,” [Sinclair QL][5], which was an even bigger failure than Acorn Archimedes, Torvalds said.
|
||||
|
||||
“Finland wasn’t the center of the universe back then,” Torvalds said. “After that, I learned my lesson—never ever go buy into something that doesn’t have infrastructure.”
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.pcworld.com/article/3129300/linux/why-linux-pioneer-linus-torvalds-prefers-x86-over-arm.html
|
||||
|
||||
作者:[Agam Shah][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.pcworld.com/author/Agam-Shah/
|
||||
[1]: http://www.theregister.co.uk/2016/10/05/linus_torvalds_admits_buggy_crap_made_it_into_linux_48/
|
||||
[2]: https://www.youtube.com/watch?v=fuAebQvFnRI
|
||||
[3]: http://www.infoworld.com/article/2908072/android/google-and-intel-vow-to-speed-up-delivery-of-android-updates-to-devices.html
|
||||
[4]: http://www.pcworld.com/article/3097427/hardware/how-arm-set-itself-up-for-a-32-billion-acquisition.html
|
||||
[5]: http://oldcomputers.net/ql.html
|
@ -1,3 +1,5 @@
|
||||
Martin translating
|
||||
|
||||
After a nasty computer virus, sys admin looks to Linux
|
||||
=======================================================
|
||||
|
||||
|
@ -1,64 +0,0 @@
|
||||
[Translating by bestony]
|
||||
4 Container Networking Tools to Know
|
||||
=======================================
|
||||
|
||||
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/network-crop.jpeg?itok=Na1tb9aR)
|
||||
>[Creative Commons Zero][1]
|
||||
|
||||
With so many new cloud computing technologies, tools, and techniques to keep track of, it can be hard to know where to start learning new skills. This series on [next-gen cloud technologies][2] aims to help you get up to speed on the important projects and products in emerging and rapidly changing areas such as software-defined networking (SDN) , containers, and the space where they coincide: container networking.
|
||||
|
||||
The relationship between containers and networks remains challenging for enterprise container deployment. Containers need networking functionality to connect distributed applications. Part of the challenge, according to a recent [Enterprise Networking Planet][3] article, is “to deploy containers in a way that provides the isolation they need to function as their own self-contained data environments while still maintaining effective connectivity.”
|
||||
|
||||
[Docker][4], the popular container platform, uses software-defined virtual networks to connect containers with the local network. Additionally, it uses Linux bridging features and virtual extensible LAN (VXLAN) technology so containers can communicate with each other in the same Swarm, or cluster. Docker’s plug-in architecture also allows other network management tools, such as those listed below, to control containers.
|
||||
|
||||
Innovation in container networking has enabled containers to connect with other containers across hosts. This enables developers to start an application in a container on a host in a development environment and transition it across testing and then into a production environment enabling continuous integration, agility, and rapid deployment.
|
||||
|
||||
Container networking tools help accomplish container networking scalability, mainly by:
|
||||
|
||||
1) enabling complex, multi-host systems to be distributed across multiple container hosts.
|
||||
|
||||
2) enabling orchestration for container systems spanning a tremendous number of hosts across multiple public and private cloud platforms.
|
||||
|
||||
![](https://www.linux.com/sites/lcom/files/styles/floated_images/public/john-willis_k.jpg?itok=lTsH9eqI)
|
||||
>John Willis speaking at Open Networking Summit 2016.
|
||||
|
||||
For more information, check out the [Docker Networking Tutorial][5] video, which was presented by Brent Salisbury and John Willis at the recent [Open Networking Summit (ONS)][6]. This and many other ONS keynotes and presentations can be found [here][7].
|
||||
|
||||
Container networking tools and projects you should know about include:
|
||||
|
||||
[Calico][8] -- The Calico project (from [Metaswitch][9]) leverages Border Gateway Protocol (BGP) and integrates with cloud orchestration systems for secure IP communication between virtual machines and containers.
|
||||
|
||||
[Flannel][10] -- Flannel (previously called rudder) from [CoreOS][11] provides an overlay network that can be used as an alternative to existing SDN solutions.
|
||||
|
||||
[Weaveworks][12] -- The Weaveworks projects for managing containers include [Weave Net][13], Weave Scope, and Weave Flux. Weave Net is a tool for building and deploying Docker container networks.
|
||||
|
||||
[Canal][14] -- Just this week, CoreOS and Tigera announced the formation of a new open source project called Canal. According to the announcement, the Canal project aims to combine aspects of Calico and Flannel, "weaving security policy into both the network fabric and the cloud orchestrator."
|
||||
|
||||
You can learn more about container management, software-defined networking, and other next-gen cloud technologies through The Linux Foundation’s free “Cloud Infrastructure Technologies” course -- a massively open online course being offered through edX. [Registration for this course is open now][15], and course content will be available in June.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/news/4-container-networking-tools-know
|
||||
|
||||
作者:[AMBER ANKERHOLZ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linux.com/users/aankerholz
|
||||
[1]: https://www.linux.com/licenses/category/creative-commons-zero
|
||||
[2]: https://www.linux.com/news/5-next-gen-cloud-technologies-you-should-know
|
||||
[3]: http://www.enterprisenetworkingplanet.com/datacenter/datacenter-blog/container-networking-challenges-for-the-enterprise.html
|
||||
[4]: https://docs.docker.com/engine/userguide/networking/dockernetworks/
|
||||
[5]: https://youtu.be/Le0bEg4taak
|
||||
[6]: http://events.linuxfoundation.org/events/open-networking-summit
|
||||
[7]: https://www.linux.com/watch-videos-from-ons2016
|
||||
[8]: https://www.projectcalico.org/
|
||||
[9]: http://www.metaswitch.com/cloud-network-virtualization
|
||||
[10]: https://coreos.com/blog/introducing-rudder/
|
||||
[11]: https://coreos.com/
|
||||
[12]: https://www.weave.works/
|
||||
[13]: https://www.weave.works/products/weave-net/
|
||||
[14]: https://github.com/tigera/canal
|
||||
[15]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-cloud-infrastructure-technologies?utm_source=linuxcom&utm_medium=article&utm_campaign=cloud%20mooc%20article%201
|
@ -1,3 +1,4 @@
|
||||
Translated by chunyang-wen
|
||||
Python unittest: assertTrue is truthy, assertFalse is falsy
|
||||
===========================
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
CANONICAL CONSIDERING TO DROP 32 BIT SUPPORT IN UBUNTU
|
||||
========================================================
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/Ubuntu-32-bit-goes-for-a-toss-.jpg)
|
||||
|
||||
Yesterday, developer [Dimitri John Ledkov][1] wrote a message on the [Ubuntu Mailing list][2] calling for the end of i386 support by Ubuntu 18.10. Ledkov argues that more software is being developed with 64-bit support. He is also concerned that it will be difficult to provide security support for the aging i386 architecture.
|
||||
|
||||
Ledkov also argues that building i386 images is not free, but takes quite a bit of Canonical’s resources.
|
||||
|
||||
>Building i386 images is not “for free”, it comes at the cost of utilizing our build farm, QA and validation time. Whilst we have scalable build-farms, i386 still requires all packages, autopackage tests, and ISOs to be revalidated across our infrastructure. As well as take up mirror space & bandwidth.
|
||||
|
||||
Ledkov offers a plan where the 16.10, 17.04, and 17.10 versions of Ubuntu will continue to have i386 kernels, netboot installers, and cloud images, but drop i386 ISO for desktop and server. The 18.04 LTS would then drop support for i386 kernels, netboot installers, and cloud images, but still provide the ability for i386 programs to run on 64-bit architecture. Then, 18.10 would end the i386 port and limit legacy 32-bit applications to snaps, containers, and virtual machines.
|
||||
|
||||
Ledkov’s plan had not been accepted yet, but it shows a definite push toward eliminating 32-bit support.
|
||||
|
||||
### GOOD NEWS
|
||||
|
||||
Don’t despair yet. this will not affect the distros used to resurrect your old system. [Martin Wimpress][3], the creator of [Ubuntu MATE][4], revealed during a discussion on Googl+ that these changes will only affect mainline Ubuntu.
|
||||
|
||||
>The i386 archive will continue to exist into 18.04 and flavours can continue to elect to build i386 isos. There is however a security concern, in that some larger applications (Firefox, Chromium, LibreOffice) are already presenting challenges in terms of applying some security patches to older LTS releases. So flavours are being asked to be mindful of the support period they can reasonably be expected to support i386 versions for.
|
||||
|
||||
### THOUGHTS
|
||||
|
||||
I understand why they need to make this move from a security standpoint, but it’s going to make people move away from mainline Ubuntu to either one of the flavors or a different architecture. Thankfully, we have alternative [lightweight Linux distributions][5].
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/ubuntu-32-bit-support-drop/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+ItsFoss+%28Its+FOSS%21+An+Open+Source+Blog%29
|
||||
|
||||
作者:[John Paul][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/john/
|
||||
[1]: https://plus.google.com/+DimitriJohnLedkov
|
||||
[2]: https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2016-June/016661.html
|
||||
[3]: https://twitter.com/m_wimpress
|
||||
[4]: http://ubuntu-mate.org/
|
||||
[5]: https://itsfoss.com/lightweight-linux-beginners/
|
@ -1,459 +0,0 @@
|
||||
Best Password Manager — For Windows, Linux, Mac, Android, iOS and Enterprise
|
||||
==============================
|
||||
|
||||
![](https://4.bp.blogspot.com/-uMOdpnxBV9w/V5x4YW54SbI/AAAAAAAAo_E/o-gUmO46UB0Ji2IMzd_xdY5pVsCcJnFwQCLcB/s1600/free-best-password-manager-2016.png)
|
||||
|
||||
When it comes to safeguarding your Internet security, installing an antivirus software or running a [Secure Linux OS][1] on your system does not mean you are safe enough from all kinds of cyber-threats.
|
||||
|
||||
Today majority of Internet users are vulnerable to cyber attacks, not because they aren't using any best antivirus software or other security measures, but because they are using [weak passwords][2] to secure their online accounts.
|
||||
|
||||
Passwords are your last lines of defense against online threats. Just look back to some recent data breaches and cyber attacks, including high-profile [data breach at OPM][3] (United States Office of Personnel Management) and the extra-marital affair site [Ashley Madison][4], that led to the exposure of hundreds of millions of records online.
|
||||
|
||||
Although you can not control data breaches, it is still important to create strong passwords that can withstand dictionary and [brute-force attacks][5].
|
||||
|
||||
You see, the longer and more complex your password is, the much harder it is crack.
|
||||
|
||||
### How to Stay Secure Online?
|
||||
|
||||
Security researchers have always advised online users to create long, complex and different passwords for their various online accounts. So, if one site is breached, your other accounts on other websites are secure enough from being hacked.
|
||||
|
||||
Ideally, your strong password should be at least 16 characters long, should contain a combination of digits, symbols, uppercase letters and lowercase letters and most importantly the most secure password is one you don't even know.
|
||||
|
||||
The password should be free of repetition and not contain any dictionary word, pronoun, your username or ID, and any other predefined letter or number sequences.
|
||||
|
||||
I know this is a real pain to memorize such complex password strings and unless we are human supercomputers, remembering different passwords for several online accounts is not an easy task.
|
||||
|
||||
The issue is that today people subscribe to a lot of online sites and services, and it's usually hard to create and remember different passwords for every single account.
|
||||
|
||||
But, Luckily to make this whole process easy, there's a growing market for password managers for PCs and phones that can significantly reduce your password memorizing problem, along with the cure for your bad habit of setting weak passwords.
|
||||
|
||||
### What is Password Manager?
|
||||
|
||||
![](https://1.bp.blogspot.com/-LY7pI45tMq0/V5r_XV083RI/AAAAAAAAo6M/MivILg0_4Vs7UgLKZJqM5vhvYujQCCcpgCLcB/s1600/best-password-manager-software.png)
|
||||
|
||||
Password Manager software has come a very long way in the past few years and is an excellent system that both allows you to create complex passwords for different sites and remember them.
|
||||
|
||||
A password manager is just software that creates, stores and organizes all your passwords for your computers, websites, applications and networks.
|
||||
|
||||
Password managers that generate passwords and double as a form filler are also available in the market, which has the ability to enter your username and password automatically into login forms on websites.
|
||||
|
||||
So, if you want super secure passwords for your multiple online accounts, but you do not want to memorize them all, Password Manager is the way to go.
|
||||
|
||||
### How does a Password Manager work?
|
||||
|
||||
Typically, Password Manager software works by generating long, complex, and, most importantly, unique password strings for you, and then stores them in encrypted form to protect the confidential data from hackers with physical access to your PC or mobile device.
|
||||
|
||||
The encrypted file is accessible only through a master password. So, all you need to do is remember just one master password to open your password manager or vault and unlock all your other passwords.
|
||||
|
||||
?
|
||||
|
||||
However, you need to make sure your master password is extra-secure of at least 16 characters long.
|
||||
|
||||
### Which is the Best Password Manager? How to Choose?
|
||||
|
||||
I've long recommended password managers, but most of our readers always ask:
|
||||
|
||||
- Which password manager is best?
|
||||
- Which password manager is the most secure? Help!
|
||||
|
||||
So, today I'm introducing you some of the best Password Manager currently available in the market for Windows, Linux, Mac, Android, iOS and Enterprise.
|
||||
|
||||
Before choosing a good password manager for your devices, you should check these following features:
|
||||
|
||||
- Cross-Platform Application
|
||||
- Works with zero-knowledge model
|
||||
- Offers two-factor authentication (multi-factor authentication)
|
||||
|
||||
Note: Once adopted, start relying on your password manager because if you are still using weak passwords for your important online accounts, nobody can save you from malicious hackers.
|
||||
|
||||
### Best Password Managers for Windows
|
||||
|
||||
![](https://2.bp.blogspot.com/-8MUEI5RctdA/V5sDM_oCoaI/AAAAAAAAo60/LX4AktoS_f0JeYDORSqmDZMfmsbOa6QnACLcB/s1600/Best-Password-Manager-for-Windows.png)
|
||||
|
||||
Windows users are most vulnerable to cyber attacks because Windows operating system has always been the favorite target of hackers. So, it is important for Windows users to make use of a good password manager.
|
||||
|
||||
Some other best password manager for windows: Keeper, Password Safe, LockCrypt, 1Password, and Dashlane.
|
||||
|
||||
- 1. Keeper Password Manager (Cross-Platform)
|
||||
|
||||
![](https://1.bp.blogspot.com/-9ISKGyTAX9U/V5xec18I21I/AAAAAAAAo8E/i8IqZXXpDwMGe8wnI6Adj3qduR_Qm5o3ACLcB/s1600/keeper-Password-Manager-for-mac-os-x.png)
|
||||
|
||||
Keeper is a secure, easy-to-use and robust password manager for your Windows, Mac, iPhone, iPad, and iPod devices.
|
||||
|
||||
Using military-grade 256-bit AES encryption, Keeper password manager keeps your data safe from prying eyes.
|
||||
|
||||
It has a secure digital vault for protecting and managing your passwords, as well as other secret information. Keeper password manager application supports Two-factor authentication and available for every major operating system.
|
||||
|
||||
There is also an important security feature, called Self-destruct, which if enabled, will delete all records from your device if the incorrect master password is entered more than five times incorrectly.
|
||||
|
||||
But you don't need worry, as this action will not delete the backup records stored on Keeper's Cloud Security Vault.
|
||||
|
||||
Download Keeper Password Manager: [Windows, Linux and Mac][6] | [iOS][7] | [Android][8] | [Kindle][9]
|
||||
|
||||
- 2. Dashlane Password Manager (Cross-Platform)
|
||||
|
||||
![](https://3.bp.blogspot.com/-2BuFpcAe9K8/V5xjugOWPuI/AAAAAAAAo9A/wpooAjcH74EzxfNJwrFu-Mcn0IkwiRGjACLcB/s1600/Dashlane-Password-Manager-for-Android.png)
|
||||
|
||||
DashLane Password Manager software is a little newer, but it offers great features for almost every platform.
|
||||
|
||||
DashLane password manager works by encrypting your personal info and accounts' passwords with AES-256 encryption on a local machine, and then syncs your details with its online server, so that you can access your accounts database from anywhere.
|
||||
|
||||
The best part of DashLane is that it has an automatic password changer that can change your accounts' passwords for you without having to deal with it yourself.
|
||||
|
||||
DashLane Password Manager app for Android gives you the secure password management tools right to your Android phone: your password vault and form auto-filler for online stores and other sites.
|
||||
|
||||
DashLane Password Manager app for Android is completely free to use on a single device and for accessing multiple devices, you can buy a premium version of the app.
|
||||
|
||||
Download DashLane Password Manager: [Windows][10] and [Mac][11] | [iOS][12] | [Android][13]
|
||||
|
||||
- 3. LastPass Password Manager (Cross-Platform)
|
||||
|
||||
![](https://3.bp.blogspot.com/--o_hWTgXh2M/V5sAjw7FlYI/AAAAAAAAo6U/Ajmvt0rgRAQE3M_YeYurpbsUoLBN8OTLwCLcB/s1600/LastPass-Password-Manager-for-Windows.png)
|
||||
|
||||
LastPass is one of the best Password Manager for Windows users, though it comes with the extension, mobile app, and even desktop app support for all the browsers and operating systems.
|
||||
|
||||
LastPass is an incredibly powerful cloud-based password manager software that encrypts your personal info and accounts' passwords with AES-256 bit encryption and even offers a variety of two-factor authentication options in order to ensure no one else can log into your password vault.
|
||||
|
||||
LastPass Password Manager comes for free as well as a premium with a fingerprint reader support.
|
||||
|
||||
Download LastPass Password Manager: [Windows, Mac, and Linux][14] | [iOS][15] | [Android][16]
|
||||
|
||||
### Best Password Manager for Mac OS X
|
||||
|
||||
![](https://2.bp.blogspot.com/-lEim3E-0wcg/V5sFhOVYK7I/AAAAAAAAo7A/z6Lp8_ULdJAD8ErZ1a-FevXPO8nR3JKNACLcB/s1600/Best-Password-Manager-for-mac-os-x.png)
|
||||
|
||||
People often say that Mac computers are more secure than Windows and that "Macs don't get viruses," but it is not entirely correct.
|
||||
|
||||
As proof, you can read our previous articles on cyber attacks against Mac and iOs users, and then decide yourself that you need a password manager or not.
|
||||
|
||||
Some other best password manager for Mac OS X: 1Password, Dashlane, LastPass, OneSafe, PwSafe.
|
||||
|
||||
- 1. LogMeOnce Password Manager (Cross-Platform)
|
||||
|
||||
![](https://4.bp.blogspot.com/-fl64fXK2bdA/V5sHL215j_I/AAAAAAAAo7M/fbn4EsrQMkU3tWWfiAsWlTgKKXb0oEzlwCLcB/s1600/LogMeOnce-Password-Manager-for-Mac-os-x.png)
|
||||
|
||||
LogMeOnce Password Management Suite is one of the best password manager for Mac OS X, as well as syncs your passwords across Windows, iOS, and Android devices.
|
||||
|
||||
LogMeOnce is one of the best Premium and Enterprise Password Management Software that offers a wide variety of features and options, including Mugshot feature.
|
||||
|
||||
If your phone is ever stolen, LogMeOnce Mugshot feature tracks the location of the thief and also secretly takes a photo of the intruder when trying to gain access to your account without permission.
|
||||
|
||||
LogmeOnce protects your passwords with military-grade AES-256 encryption technology and offers Two-factor authentication to ensure that even with the master password in hand, a thief hacks your account.
|
||||
|
||||
Download LogMeOnce Password Manager: [Windows and Mac][17] | [iOS][18] | [Android][19]
|
||||
|
||||
- 2. KeePass Password Manager (Cross-Platform)
|
||||
|
||||
![](https://4.bp.blogspot.com/-XWwdG1z9sDw/V5sA7azAy6I/AAAAAAAAo6c/dkkfMRuxDoE_gi5OMRvDOUFq15P5NRO6QCLcB/s1600/Keepass-Password-Manager-for-Windows.png)
|
||||
|
||||
Although LastPass is one of the best password manager, some people are not comfortable with a cloud-based password manager.
|
||||
|
||||
KeePass is a popular password manager application for Windows, but there are browser extensions and mobile apps for KeePass as well.
|
||||
|
||||
KeePass password manager for Windows stores your accounts' passwords on your PC, so you remain in control of them, and also on Dropbox, so you can access it using multiple devices.
|
||||
|
||||
KeePass encrypts your passwords and login info using the most secure encryption algorithms currently known: AES 256-bit encryption by default, or optional, Twofish 256-bit encryption.
|
||||
|
||||
KeePass is not just free, but it is also open source, which means its code and integrity can be examined by anyone, adding a degree of confidence.
|
||||
|
||||
Download KeePass Password Manager: [Windows and Linux][20] | [Mac][21] | [iOS][22] | [Android][23]
|
||||
3. Apple iCloud Keychain
|
||||
|
||||
![](https://4.bp.blogspot.com/-vwY_dmsKIBg/V5xfhIZGxxI/AAAAAAAAo8M/OjPrBsp9GysF-bK3oqHtW74hKNYO61W9QCLcB/s1600/Apple-iCloud-Keychain-Security.png)
|
||||
|
||||
Apple introduced the iCloud Keychain password management system as a convenient way to store and automatically sync all your login credentials, Wi-Fi passwords, and credit card numbers securely across your approved Apple devices, including Mac OS X, iPhone, and iPad.
|
||||
|
||||
Your Secret Data in Keychain is encrypted with 256-bit AES (Advanced Encryption Standard) and secured with elliptic curve asymmetric cryptography and key wrapping.
|
||||
|
||||
Also, iCloud Keychain generates new, unique and strong passwords for you to use to protect your computer and accounts.
|
||||
|
||||
Major limitation: Keychain doesn't work with other browsers other than Apple Safari.
|
||||
|
||||
Also Read: [How to Setup iCloud Keychain][24]?
|
||||
Best Password Manager for Linux
|
||||
|
||||
![](https://1.bp.blogspot.com/-2zDAqYEQTQA/V5xgbo_OcQI/AAAAAAAAo8Y/hWzGLW7R4vse3QnpCM5-qmSHLtzK5M1VACLcB/s1600/best-Password-Manager-for-linux.png)
|
||||
|
||||
No doubt, some Linux distributions are the safest operating systems exist on the earth, but as I said above that adopting Linux doesn't completely protect your online accounts from hackers.
|
||||
|
||||
There are a number of cross-platform password managers available that sync all your accounts' passwords across all your devices, such as LastPass, KeePass, RoboForm password managers.
|
||||
|
||||
Here below I have listed two popular and secure open source password managers for Linux:
|
||||
|
||||
- 1. SpiderOak Encryptr Password Manager (Cross-Platform)
|
||||
|
||||
![](https://4.bp.blogspot.com/-SZkmP7dpXZM/V5xiKeuT4KI/AAAAAAAAo8s/QhvfBz3OX78IUit_HLym0sdKxlz99qFfgCLcB/s1600/SpiderOak-Encryptr-Password-Manager-for-linux.png)
|
||||
|
||||
SpiderOak's Encryptr Password Manager is a zero-knowledge cloud-based password manager that encrypts protect your passwords using Crypton JavaScript framework, developed by SpiderOak and recommended by Edward Snowden.
|
||||
|
||||
It is a cross-platform, open-Source and free password manager that uses end-to-end encryption and works perfectly for Ubuntu, Debian Linux Mint, and other Linux distributions.
|
||||
|
||||
Encryptr Password Manager application itself is very simple and comes with some basic features.
|
||||
|
||||
Encryptr software lets you encrypt three types of files: Passwords, Credit Card numbers and general any text/keys.
|
||||
|
||||
Download Encryptr Password Manager: [Windows, Linux and Mac][25] | [iOS][26] | [Android][27]
|
||||
|
||||
2. EnPass Password Manager (Cross-Platform)
|
||||
|
||||
![](https://4.bp.blogspot.com/-_IF81t9rL7U/V5xhBIPUSHI/AAAAAAAAo8c/6-kbLXTl2G0EESTH4sP9KvZLzTFlCyypACLcB/s1600/EnPass-Password-Manager-for-Linux.png)
|
||||
|
||||
Enpass is an excellent security oriented Linux password manager that works perfectly with other platforms too. Enpass offers you to backup and restores stored passwords with third-party cloud services, including Google Drive, Dropbox, OneDrive, or OwnCloud.
|
||||
|
||||
It makes sure to provide the high levels of security and protects your data by a master password and encrypted it with 256-bit AES using open-source encryption engine SQLCipher, before uploading backup onto the cloud.
|
||||
"We do not host your Enpass data on our servers. So, no signup is required for us. Your data is only stored on your device," EnPass says.
|
||||
Additionally, by default, Enpass locks itself every minute when you leave your computer unattended and clears clipboard memory every 30 seconds to prevent your passwords from being stolen by any other malicious software.
|
||||
|
||||
Download EnPass Password Manager: [Windows][28], [Linux][29] | [Mac][30] | [iOS][31] | [Android][32]
|
||||
|
||||
3. RoboForm Password Manager (Cross-Platform)
|
||||
|
||||
![](https://3.bp.blogspot.com/-g8Qf9V1EdqU/V5sBkDk614I/AAAAAAAAo6k/5ZTr9LyosU82F16GxajewvU4sWYyJFq5gCLcB/s1600/Roboform-Password-Manager-for-Windows.png)
|
||||
|
||||
You can easily find good password managers for Windows OS, but RoboForm Free Password Manager software goes a step further.
|
||||
|
||||
Besides creating complex passwords and remembering them for you, RoboForm also offers a smart form filler feature to save your time while browsing the Web.
|
||||
|
||||
RoboForm encrypts your login info and accounts' passwords using military grade AES encryption with the key that is obtained from your RoboForm Master Password.
|
||||
|
||||
RoboForm is available for browsers like Internet Explorer, Chrome, and Firefox as well as mobile platforms with apps available for iOS, Android, and Windows Phone.
|
||||
|
||||
Download RoboForm Password Manager: [Windows and Mac][33] | [Linux][34] | [iOS][35] | [Android][36]
|
||||
|
||||
### Best Password Manager for Android
|
||||
|
||||
![](https://1.bp.blogspot.com/-1PXI2KDrDEU/V5xigbW8lgI/AAAAAAAAo8w/Zv5hrdOcbSU7LA0kYrNpvJ1rxjg7EoOewCLcB/s1600/best-Password-Manager-for-android.png)
|
||||
|
||||
More than half of the world's population today is using Android devices, so it becomes necessary for Android users to secure their online accounts from hackers who are always seeking access to these devices.
|
||||
|
||||
Some of the best Password Manager apps for Android include 1Password, Keeper, DashLane, EnPass, OneSafe, mSecure and SplashID Safe.
|
||||
|
||||
- 1. 1Password Password Manager (Cross-Platform)
|
||||
|
||||
![](https://4.bp.blogspot.com/--w3s9SoWgYA/V5xjJwVRUTI/AAAAAAAAo84/BSucybvPdtUKYYcRtDbn-_2cOz-mfMA9gCLcB/s1600/1password-Password-Manager-for-android.png)
|
||||
|
||||
1Password Password Manager app for Android is one of the best apps for managing all your accounts' passwords.
|
||||
|
||||
1Password password manager app creates strong, unique and secure passwords for every account, remembers them all for you, and logs you in with just a single tap.
|
||||
|
||||
1Password password manager software secures your logins and passwords with AES-256 bit encryption, and syncs them to all of your devices via your Dropbox account or stores locally for any other application to sync if you choose.
|
||||
|
||||
Recently, the Android version of 1Password password manager app has added Fingerprint support for unlocking all of your passwords instead of using your master password.
|
||||
|
||||
Download 1Password Password Manager: [Windows and Mac][37] | [iOS][38] | [Android][39]
|
||||
|
||||
- 2. mSecure Password Manager (Cross-Platform)
|
||||
|
||||
![](https://4.bp.blogspot.com/-nvjjS2dWfPc/V5xkEdAOYvI/AAAAAAAAo9I/EDGfA5hzacIq46gWG-6BD2UPHwQAHD-pgCLcB/s1600/mSecure-password-manager-for-android.png)
|
||||
|
||||
Like other popular password manager solutions, mSecure Password Manager for Android automatically generates secure passwords for you and stores them using 256-bit Blowfish encryption.
|
||||
|
||||
The catchy and unique feature mSecure Password Manager software provides its ability to self-destruct database after 5, 10, or 20 failed attempts (as per your preference) to input the right password.
|
||||
|
||||
You can also sync all of your devices with Dropbox, or via a private Wi-Fi network. In either case, all your data is transmitted safely and securely between devices regardless of the security of your cloud account.
|
||||
|
||||
Download mSecure Password Manager software: [Windows and Mac][40] | [iOS][41] | [Android][42]
|
||||
|
||||
### Best Password Manager for iOS
|
||||
|
||||
![](https://4.bp.blogspot.com/-SOXYw_9mFq0/V5xk6Kl8-DI/AAAAAAAAo9Q/AMbEl_t3HjAJ4ZX7gLVoa33z-myE4bK5wCLcB/s1600/best-Password-Manager-for-ios-iphone.png)
|
||||
|
||||
As I said, Apple's iOS is also prone to cyber attacks, so you can use some of the best password manager apps for iOS to secure your online accounts, including Keeper, OneSafe, Enpass, mSecure, LastPass, RoboForm, SplashID Safe and LoginBox Pro.
|
||||
|
||||
- 1. OneSafe Password Manager (Cross-Platform)
|
||||
|
||||
![](https://2.bp.blogspot.com/-HPEJpqeOs00/V5xlSh7OUxI/AAAAAAAAo9Y/d5qkOy3BieMSxjGrnrnH4fvzUzAzDqhCgCLcB/s1600/onesafe-password-manager-for-ios.png)
|
||||
|
||||
OneSafe is one of the best Password Manager apps for iOS devices that lets you store not only your accounts' passwords but also sensitive documents, credit card details, photos, and more.
|
||||
|
||||
OneSafe password manager app for iOS encrypts your data behind a master password, with AES-256 encryption — the highest level available on mobile — and Touch ID. There is also an option for additional passwords for given folders.
|
||||
|
||||
OneSafe password manager for iOS also offers an in-app browser that supports autofill of logins, so that you don't need to enter your login details every time.
|
||||
|
||||
Besides this, OneSafe also provides advanced security for your accounts' passwords with features like auto-lock, intrusion detection, self-destruct mode, decoy safe and double protection.
|
||||
|
||||
Download OneSafe Password Manager: [iOS][43] | [Mac][44] | [Android][45] | [Windows][46]
|
||||
|
||||
- 2. SplashID Safe Password Manager (Cross-Platform)
|
||||
|
||||
![](https://1.bp.blogspot.com/-FcNub2p-QNE/V5xmDW7QXvI/AAAAAAAAo9o/23VuGUAMCYYS64kKlUqBcfx3JIfBr5gTgCLcB/s1600/SplashID-Safe-password-manager-for-ios.png)
|
||||
|
||||
SplashID Safe is one of the oldest and best password manager tools for iOS that allows users to securely store their login data and other sensitive information in an encrypted record.
|
||||
|
||||
All your information, including website logins, credit card and social security data, photos and file attachments, are protected with 256-bit encryption.
|
||||
|
||||
SplashID Safe Password Manager app for iOS also provides web autofill option, meaning you will not have to bother copy-pasting your passwords in login.
|
||||
|
||||
The free version of SplashID Safe app comes with basic record storage functionality, though you can opt for premium subscriptions that provide cross-device syncing among other premium features.
|
||||
|
||||
Download SplashID Safe Password Manager: [Windows and Mac][47] | [iOS][48] | [Android][49]
|
||||
|
||||
3. LoginBox Pro Password Manager
|
||||
|
||||
![](https://3.bp.blogspot.com/-4GzhwZFXDHQ/V5xogkDk49I/AAAAAAAAo90/69rmVdKD-VUG0kHJXIqE2x-mVlWZEDrYwCLcB/s1600/LoginBox-Pro-Password-Manager-for-ios.png)
|
||||
|
||||
LoginBox Pro is another great password manager app for iOS devices. The app provides a single tap login to any website you visit, making the password manager app as the safest and fastest way to sign in to password-protected internet sites.
|
||||
|
||||
LoginBox Password Manager app for iOS combines a password manager as well as a browser.
|
||||
|
||||
From the moment you download it, all your login actions, including entering information, tapping buttons, checking boxes, or answering security questions, automatically completes by the LoginBox Password Manager app.
|
||||
|
||||
For security, LoginBox Password Manager app uses hardware-accelerated AES encryption and passcode to encrypt your data and save it on your device itself.
|
||||
|
||||
Download LoginBox Password Manager: [iOS][50] | [Android][51]
|
||||
|
||||
### Best Online Password Managers
|
||||
|
||||
Using an online password manager tool is the easiest way to keep your personal and private information safe and secure from hackers and people with malicious intents.
|
||||
|
||||
Here I have listed some of the best online password managers that you can rely on to keep yourself safe online:
|
||||
|
||||
- 1. Google Online Password Manager
|
||||
|
||||
![](https://2.bp.blogspot.com/-HCSzj5tKgwY/V5xqVjjtfgI/AAAAAAAAo-A/OYcgv-S5wmQlAskF1jrEGQAy98ogMnXTgCLcB/s1600/google-online-password-manager.png)
|
||||
|
||||
Did you know Google has its homebrew dedicated password manager?
|
||||
|
||||
Google Chrome has a built-in password manager tool that offers you an option to save your password whenever you sign in to a website or web service using Chrome.
|
||||
|
||||
All of your stored accounts' passwords are synced with your Google Account, making them available across all of your devices using the same Google Account.
|
||||
|
||||
Chrome password manager lets you manage all your accounts' passwords from the Web.
|
||||
|
||||
So, if you prefer using a different browser, like Microsoft Edge on Windows 10 or Safari on iPhone, just visit [passwords.google.com][52], and you'll see a list of all your passwords you have saved with Chrome. Google's two-factor authentication protects this list.
|
||||
|
||||
- 2. Clipperz Online Password Manager
|
||||
|
||||
![](https://2.bp.blogspot.com/-gs8b_N_k6CA/V5xrvzbUIKI/AAAAAAAAo-M/vsTXHZNErkQu6g8v9V1R2FxLkdppZq_GACLcB/s1600/Clipperz-Online-Password-Manager.png)
|
||||
|
||||
Clipperz is a free, cross-platform best online password manager that does not require you to download any software. Clipperz online password manager uses a bookmarklet or sidebar to create and use direct logins.
|
||||
|
||||
Clipperz also offers an offline password manager version of its software that allows you to download your passwords to an [encrypted disk][53] or a USB drive so you can take them with you while traveling and access your accounts' passwords when you are offline.
|
||||
|
||||
Some features of Clipperz online password manager also includes password strength indicator, application locking, SSL secure connection, one-time password and a password generator.
|
||||
|
||||
Clipperz online password manager can work on any computer that runs a browser with a JavaScript browser.
|
||||
|
||||
- 3. Passpack Online Password Manager
|
||||
|
||||
![](https://4.bp.blogspot.com/-ng91nPnzbWI/V5xsarl2mqI/AAAAAAAAo-Q/zJlFK-63vugeoyymDL26c5mPiWNsGQjuACLcB/s1600/Passpack-Free-Online-Password-Manager.png)
|
||||
|
||||
Passpack is an excellent online password manager with a competitive collection of features that creates, stores and manages passwords for your different online accounts.
|
||||
|
||||
PassPack online password manager also allows you to share your passwords safely with your family or coworkers for managing multiple projects, team members, clients, and employees easily.
|
||||
|
||||
Your usernames and passwords for different accounts are encrypted with AES-256 Encryption on PassPack's servers that even hackers access to its server can not read your login information.
|
||||
|
||||
Download the PassPack online password manager toolbar to your web browser and navigate the web normally. Whenever you log into any password-protected site, PassPack saves your login data so that you do not have to save your username and password manually on its site.
|
||||
|
||||
### Best Enterprise Password Manager
|
||||
|
||||
Over the course of last 12 months, we've seen some of the biggest data breaches in the history of the Internet and year-over-year the growth is heating up.
|
||||
|
||||
According to statistics, a majority of employees even don't know how to protect themselves online, which led company’s business at risk.
|
||||
|
||||
To keep password sharing mechanism secure in an organization, there exist some password management tools specially designed for enterprises use, such as Vaultier, CommonKey, Meldium, PassWork, and Zoho Vault.
|
||||
|
||||
- 1. Meldium Enterprise Password Manager Software
|
||||
|
||||
![](https://3.bp.blogspot.com/-3rKr3KUpuiQ/V5xs8JR7pVI/AAAAAAAAo-c/VF1tmKbwPzoJmNvA3Ym69CizG7_VqM6ywCLcB/s1600/Meldium-Enterprise-Password-Manager.png)
|
||||
|
||||
LogMeIn's Meldium password management tool comes with a one-click single sign-on solution that helps businesses access to web apps securely and quickly.
|
||||
|
||||
It automatically logs users into apps and websites without typing usernames and passwords and also tracks password usage within your organization.
|
||||
|
||||
Meldium password manager is perfect for sharing accounts within your team member without sharing the actual password, which helps organizations to protect themselves from phishing attacks.
|
||||
|
||||
- 2. Zoho Vault Password Management Software
|
||||
|
||||
![](https://2.bp.blogspot.com/-J-N_1wOYxmI/V5xtrz42QWI/AAAAAAAAo-o/QF4n4QAF7ZMBd7uIRdjM6Hdd1MHwsXWQACLcB/s1600/zoho-vault--Enterprise-Password-Manager.png)
|
||||
|
||||
Zoho Vault is one of the best Password Manager for Enterprise users that helps your team share passwords and other sensitive information fast and securely while monitoring each user's usage.
|
||||
|
||||
All your team members need to download is the Zoho browser extension. Zoho Vault password manager will automatically fill passwords from your team's shared vault.
|
||||
|
||||
Zoho Vault also provides features that let you monitor your team's password usage and security level so that you can know who is using which login.
|
||||
|
||||
The Zoho Vault enterprise-level package even alerts you whenever a password is changed or accessed.
|
||||
|
||||
### For Extra Security, Use 2-Factor Authentication
|
||||
|
||||
![](https://4.bp.blogspot.com/-jDnJBDoibtQ/V5xuHVHukRI/AAAAAAAAo-w/1Erjgk-IvKs__TXwYDz-8Groz9hWEElZgCLcB/s1600/two-factor-authentication-password-security.png)
|
||||
|
||||
No matter how strong your password is, there still remains a possibility for hackers to find some or the other way to hack into your account.
|
||||
|
||||
Two-factor authentication is designed to fight this issue. Instead of just one password, it requires you to enter the second passcode which is sent either to your mobile number via an SMS or to your email address via an email.
|
||||
|
||||
So, I recommend you to enable two-factor authentication now along with using a password manager software to secure your online accounts and sensitive information from hackers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://thehackernews.com/2016/07/best-password-manager.html
|
||||
|
||||
作者:[Swati Khandelwal][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://thehackernews.com/2016/07/best-password-manager.html#author-info
|
||||
|
||||
[1]: http://thehackernews.com/2016/03/subgraph-secure-operating-system.html
|
||||
[2]: http://thehackernews.com/2016/01/password-security-manager.html
|
||||
[3]: http://thehackernews.com/2015/09/opm-hack-fingerprint.html
|
||||
[4]: http://thehackernews.com/2015/08/ashley-madison-accounts-leaked-online.html
|
||||
[5]: http://thehackernews.com/2013/05/cracking-16-character-strong-passwords.html
|
||||
[6]: https://keepersecurity.com/download.html
|
||||
[7]: https://itunes.apple.com/us/app/keeper-password-manager-digital/id287170072?mt=8
|
||||
[8]: https://play.google.com/store/apps/details?id=com.callpod.android_apps.keeper
|
||||
[9]: http://www.amazon.com/gp/mas/dl/android?p=com.callpod.android_apps.keeper
|
||||
[10]: https://www.dashlane.com/download
|
||||
[11]: https://www.dashlane.com/passwordmanager/mac-password-manager
|
||||
[12]: https://itunes.apple.com/in/app/dashlane-free-secure-password/id517914548?mt=8
|
||||
[13]: https://play.google.com/store/apps/details?id=com.dashlane&hl=en
|
||||
[14]: https://lastpass.com/misc_download2.php
|
||||
[15]: https://itunes.apple.com/us/app/lastpass-for-premium-customers/id324613447?mt=8&ign-mpt=uo%3D4
|
||||
[16]: https://play.google.com/store/apps/details?id=com.lastpass.lpandroid
|
||||
[17]: https://www.logmeonce.com/download/
|
||||
[18]: https://itunes.apple.com/us/app/logmeonce-free-password-manager/id972000703?ls=1&mt=8
|
||||
[19]: https://play.google.com/store/apps/details?id=log.me.once
|
||||
|
||||
[20]: http://keepass.info/download.html
|
||||
[21]: https://itunes.apple.com/us/app/kypass-companion/id555293879?ls=1&mt=12
|
||||
[22]: https://itunes.apple.com/de/app/ikeepass/id299697688?mt=8
|
||||
[23]: https://play.google.com/store/apps/details?id=keepass2android.keepass2android
|
||||
[24]: https://support.apple.com/en-in/HT204085
|
||||
[25]: https://spideroak.com/opendownload
|
||||
[26]: https://itunes.apple.com/us/app/spideroak/id360584371?mt=8
|
||||
[27]: https://play.google.com/store/apps/details?id=com.spideroak.android
|
||||
[28]: https://www.enpass.io/download-enpass-for-windows/
|
||||
[29]: https://www.enpass.io/download-enpass-linux/
|
||||
[30]: https://itunes.apple.com/app/enpass-password-manager-best/id732710998?mt=12
|
||||
[31]: https://itunes.apple.com/us/app/enpass-password-manager/id455566716?mt=8
|
||||
[32]: https://play.google.com/store/apps/details?id=io.enpass.app&hl=en
|
||||
[33]: http://www.roboform.com/download
|
||||
[34]: http://www.roboform.com/for-linux
|
||||
[35]: https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=331787573&mt=8
|
||||
[36]: https://play.google.com/store/apps/details?id=com.siber.roboform
|
||||
[37]: https://1password.com/downloads/
|
||||
[38]: https://itunes.apple.com/in/app/1password-password-manager/id568903335?mt=8
|
||||
[39]: https://play.google.com/store/apps/details?id=com.agilebits.onepassword&hl=en
|
||||
[40]: https://www.msecure.com/desktop-app/
|
||||
[41]: https://itunes.apple.com/in/app/msecure-password-manager/id292411902?mt=8
|
||||
[42]: https://play.google.com/store/apps/details?id=com.mseven.msecure&hl=en
|
||||
[43]: https://itunes.apple.com/us/app/onesafe/id455190486?ls=1&mt=8
|
||||
[44]: https://itunes.apple.com/us/app/onesafe-secure-password-manager/id595543758?ls=1&mt=12
|
||||
[45]: https://play.google.com/store/apps/details?id=com.lunabee.onesafe
|
||||
[46]: https://www.microsoft.com/en-us/store/apps/onesafe/9wzdncrddtx9
|
||||
[47]: https://splashid.com/downloads.php
|
||||
[48]: https://itunes.apple.com/app/splashid-safe-password-manager/id284334840?mt=8
|
||||
[49]: https://play.google.com/store/apps/details?id=com.splashidandroid&hl=en
|
||||
[50]: https://itunes.apple.com/app/loginbox-pro/id579954762?mt=8
|
||||
[51]: https://play.google.com/store/apps/details?id=com.mygosoftware.android.loginbox
|
||||
[52]: https://passwords.google.com/
|
||||
[53]: http://thehackernews.com/2014/01/Kali-linux-Self-Destruct-nuke-password.html
|
||||
|
@ -1,41 +0,0 @@
|
||||
OneNewLife Translating
|
||||
|
||||
Introducing React Native Ubuntu
|
||||
=====================
|
||||
|
||||
In the Webapps team at Canonical, we are always looking to make sure that web and near-web technologies are available to developers. We want to make everyone's life easier, enable the use of tools that are familiar to web developers and provide an easy path to using them on the Ubuntu platform.
|
||||
|
||||
We have support for web applications and creating and packaging Cordova applications, both of these enable any web framework to be used in creating great application experiences on the Ubuntu platform.
|
||||
|
||||
One popular web framework that can be used in these environments is React.js; React.js is a UI framework with a declarative programming model and strong component system, which focuses primarily on the composition of the UI, so you can use what you like elsewhere.
|
||||
|
||||
While these environments are great, sometimes you need just that bit more performance, or to be able to work with native UI components directly, but working in a less familiar environment might not be a good use of time. If you are familiar with React.js, it's easy to move into full native development with all your existing knowledge and tools by developing with React Native. React Native is the sister to React.js, you can use the same style and code to create an application that works directly with native components with native levels of performance, but with the ease of and rapid development you would expect.
|
||||
|
||||
|
||||
![](http://i.imgur.com/ZsSHWXP.png)
|
||||
|
||||
We are happy to announce that along with our HTML5 application support, it is now possible to develop React Native applications on the Ubuntu platform. You can port existing iOS or Android React Native applications, or you can start a new application leveraging your web-dev skills.
|
||||
|
||||
You can find the source code for React Native Ubuntu [here][1],
|
||||
|
||||
To get started, follow the instructions in [README-ubuntu.md][2] and create your first application.
|
||||
|
||||
The Ubuntu support includes the ability to generate packages. Managed by the React Native CLI, building a snap is as easy as 'react-native package-ubuntu --snap'. It's also possible to build a click package for Ubuntu devices; meaning React Native Ubuntu apps are store ready from the start.
|
||||
|
||||
Over the next little while there will be blogs posts on everything you need to know about developing a React Native Application for the Ubuntu platform; creating the app, the development process, packaging and releasing to the store. There will also be some information on how to develop new reusable modules, that can add extra functionality to the runtime and be distributed as Node Package Manager (npm) modules.
|
||||
|
||||
Go and experiment, and see what you can create.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://developer.ubuntu.com/en/blog/2016/08/05/introducing-react-native-ubuntu/?utm_source=javascriptweekly&utm_medium=email
|
||||
|
||||
作者:[Justin McPherson][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://developer.ubuntu.com/en/blog/authors/justinmcp/
|
||||
[1]: https://github.com/CanonicalLtd/react-native
|
||||
[2]: https://github.com/CanonicalLtd/react-native/blob/ubuntu/README-ubuntu.md
|
@ -1,145 +0,0 @@
|
||||
How to Mount Remote Linux Filesystem or Directory Using SSHFS Over SSH
|
||||
============================
|
||||
|
||||
The main purpose of writing this article is to provide a step-by-step guide on how to mount remote Linux file system using SSHFS client over SSH.
|
||||
|
||||
This article is useful for those users and system administrators who want to mount remote file system on their local systems for whatever purposes. We have practically tested by installing SSHFS client on one of our Linux system and successfully mounted remote file systems.
|
||||
|
||||
Before we go further installation let’s understand about SSHFS and how it works.
|
||||
|
||||
![](http://www.tecmint.com/wp-content/uploads/2012/08/Sshfs-Mount-Remote-Linux-Filesystem-Directory.png)
|
||||
>Sshfs Mount Remote Linux Filesystem or Directory
|
||||
|
||||
### What Is SSHFS?
|
||||
|
||||
SSHFS stands for (Secure SHell FileSystem) client that enable us to mount remote filesystem and interact with remote directories and files on a local machine using SSH File Transfer Protocol (SFTP).
|
||||
|
||||
SFTP is a secure file transfer protocol that provides file access, file transfer and file management features over Secure Shell protocol. Because SSH uses encryption while transferring files over the network from one computer to another computer and SSHFS comes with built-in FUSE (Filesystem in Userspace) kernel module that allows any non-privileged users to create their file system without modifying kernel code.
|
||||
|
||||
In this article, we will show you how to install and use SSHFS client on any Linux distribution to mount remote Linux filesystem or directory on a local Linux machine.
|
||||
|
||||
#### Step 1: Install SSHFS Client in Linux Systems
|
||||
|
||||
By default sshfs packages does not exists on all major Linux distributions, you need to enable [epel repository][1] under your Linux systems to install sshfs with the help of Yum command with their dependencies.
|
||||
|
||||
```
|
||||
# yum install sshfs
|
||||
# dnf install sshfs [On Fedora 22+ releases]
|
||||
$ sudo apt-get install sshfs [On Debian/Ubuntu based systems]
|
||||
```
|
||||
|
||||
#### Step 2: Creating SSHFS Mount Directory
|
||||
|
||||
Once the sshfs package installed, you need to create a mount point directory where you will mount your remote file system. For example, we have created mount directory under /mnt/tecmint.
|
||||
|
||||
```
|
||||
# mkdir /mnt/tecmint
|
||||
$ sudo mkdir /mnt/tecmint [On Debian/Ubuntu based systems]
|
||||
```
|
||||
|
||||
### Step 3: Mounting Remote Filesystem with SSHFS
|
||||
|
||||
Once you have created your mount point directory, now run the following command as a root user to mount remote file system under /mnt/tecmint. In your case the mount directory would be anything.
|
||||
|
||||
The following command will mount remote directory called /home/tecmint under /mnt/tecmint in local system. (Don’t forget replace x.x.x.x with your IP Address and mount point).
|
||||
|
||||
```
|
||||
# sshfs tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint
|
||||
$ sudo sshfs -o allow_other tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint [On Debian/Ubuntu based systems]
|
||||
```
|
||||
|
||||
If your Linux server is configured with SSH key based authorization, then you will need to specify the path to your public keys as shown in the following command.
|
||||
|
||||
```
|
||||
# sshfs -o IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint
|
||||
$ sudo sshfs -o allow_other,IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint [On Debian/Ubuntu based systems]
|
||||
```
|
||||
|
||||
#### Step 4: Verifying Remote Filesystem is Mounted
|
||||
|
||||
If you have run the above command successfully without any errors, you will see the list of remote files and directories mounted under /mnt/tecmint.
|
||||
|
||||
```
|
||||
# cd /mnt/tecmint
|
||||
# ls
|
||||
[root@ tecmint]# ls
|
||||
12345.jpg ffmpeg-php-0.6.0.tbz2 Linux news-closeup.xsl s3.jpg
|
||||
cmslogs gmd-latest.sql.tar.bz2 Malware newsletter1.html sshdallow
|
||||
epel-release-6-5.noarch.rpm json-1.2.1 movies_list.php pollbeta.sql
|
||||
ffmpeg-php-0.6.0 json-1.2.1.tgz my_next_artical_v2.php pollbeta.tar.bz2
|
||||
```
|
||||
|
||||
#### Step 5: Checking Mount Point with df -hT Command
|
||||
|
||||
If you run df -hT command you will see the remote file system mount point.
|
||||
|
||||
```
|
||||
# df -hT
|
||||
```
|
||||
|
||||
Sample Output
|
||||
|
||||
```
|
||||
Filesystem Type Size Used Avail Use% Mounted on
|
||||
udev devtmpfs 730M 0 730M 0% /dev
|
||||
tmpfs tmpfs 150M 4.9M 145M 4% /run
|
||||
/dev/sda1 ext4 31G 5.5G 24G 19% /
|
||||
tmpfs tmpfs 749M 216K 748M 1% /dev/shm
|
||||
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
|
||||
tmpfs tmpfs 749M 0 749M 0% /sys/fs/cgroup
|
||||
tmpfs tmpfs 150M 44K 150M 1% /run/user/1000
|
||||
tecmint@192.168.0.102:/home/tecmint fuse.sshfs 324G 55G 253G 18% /mnt/tecmint
|
||||
```
|
||||
|
||||
#### Step 6: Mounting Remote Filesystem Permanently
|
||||
|
||||
To mount remote filesystem permanently, you need to edit the file called /etc/fstab. To do, open the file with your favorite editor.
|
||||
|
||||
```
|
||||
# vi /etc/fstab
|
||||
$ sudo vi /etc/fstab [On Debian/Ubuntu based systems]
|
||||
```
|
||||
|
||||
Go to the bottom of the file and add the following line to it and save the file and exit. The below entry mount remote server file system with default settings.
|
||||
|
||||
```
|
||||
sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs defaults 0 0
|
||||
```
|
||||
|
||||
Make sure you’ve [SSH Passwordless Login][2] in place between servers to auto mount filesystem during system reboots..
|
||||
|
||||
```
|
||||
sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs IdentityFile=~/.ssh/id_rsa defaults 0 0
|
||||
```
|
||||
|
||||
Next, you need to update the fstab file to reflect the changes.
|
||||
|
||||
```
|
||||
# mount -a
|
||||
$ sudo mount -a [On Debian/Ubuntu based systems]
|
||||
```
|
||||
|
||||
#### Step 7: Unmounting Remote Filesystem
|
||||
|
||||
To unmount remote filesystem, jun issue the following command it will unmount the remote file system.
|
||||
|
||||
```
|
||||
# umount /mnt/tecmint
|
||||
```
|
||||
|
||||
That’s all for now, if you’re facing any difficulties or need any help in mounting remote file system, please contact us via comments and if you feel this article is much useful then share it with your friends.
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/sshfs-mount-remote-linux-filesystem-directory-using-ssh/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+tecmint+%28Tecmint%3A+Linux+Howto%27s+Guide%29
|
||||
|
||||
作者:[Ravi Saive][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.tecmint.com/author/admin/
|
||||
[1]: http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/
|
||||
[2]: http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/
|
@ -1,222 +0,0 @@
|
||||
Translating by Yinr
|
||||
|
||||
The cost of small modules
|
||||
====
|
||||
|
||||
About a year ago I was refactoring a large JavaScript codebase into smaller modules, when I discovered a depressing fact about Browserify and Webpack:
|
||||
|
||||
> “The more I modularize my code, the bigger it gets. ”– Nolan Lawson
|
||||
|
||||
Later on, Sam Saccone published some excellent research on [Tumblr](https://docs.google.com/document/d/1E2w0UQ4RhId5cMYsDcdcNwsgL0gP_S6SDv27yi1mCEY/edit) and [Imgur](https://github.com/perfs/audits/issues/1)‘s page load performance, in which he noted:
|
||||
|
||||
> “Over 400ms is being spent simply walking the Browserify tree.”– Sam Saccone
|
||||
|
||||
In this post, I’d like to demonstrate that small modules can have a surprisingly high performance cost depending on your choice of bundler and module system. Furthermore, I’ll explain why this applies not only to the modules in your own codebase, but also to the modules within dependencies, which is a rarely-discussed aspect of the cost of third-party code.
|
||||
|
||||
### Web perf 101
|
||||
|
||||
The more JavaScript included on a page, the slower that page tends to be. Large JavaScript bundles cause the browser to spend more time downloading, parsing, and executing the script, all of which lead to slower load times.
|
||||
|
||||
Even when breaking up the code into multiple bundles – Webpack [code splitting](https://webpack.github.io/docs/code-splitting.html), Browserify[factor bundles](https://github.com/substack/factor-bundle), etc. – the cost is merely delayed until later in the page lifecycle. Sooner or later, the JavaScript piper must be paid.
|
||||
|
||||
Furthermore, because JavaScript is a dynamic language, and because the prevailing[CommonJS](http://www.commonjs.org/) module system is also dynamic, it’s fiendishly difficult to extract unused code from the final payload that gets shipped to users. You might only need jQuery’s $.ajax, but by including jQuery, you pay the cost of the entire library.
|
||||
|
||||
The JavaScript community has responded to this problem by advocating the use of [small modules](http://substack.net/how_I_write_modules). Small modules have a lot of [aesthetic and practical benefits](http://dailyjs.com/2015/07/02/small-modules-complexity-over-size/) – easier to maintain, easier to comprehend, easier to plug together – but they also solve the jQuery problem by promoting the inclusion of small bits of functionality rather than big “kitchen sink” libraries.
|
||||
|
||||
So in the “small modules” world, instead of doing:
|
||||
|
||||
```
|
||||
var _ = require('lodash')
|
||||
_.uniq([1,2,2,3])
|
||||
```
|
||||
|
||||
You might do:
|
||||
|
||||
```
|
||||
var uniq = require('lodash.uniq')
|
||||
uniq([1,2,2,3])
|
||||
```
|
||||
|
||||
### Packages vs modules
|
||||
|
||||
It’s important to note that, when I say “modules,” I’m not talking about “packages” in the npm sense. When you install a package from npm, it might only expose a single module in its public API, but under the hood it could actually be a conglomeration of many modules.
|
||||
|
||||
For instance, consider a package like [is-array](https://www.npmjs.com/package/is-array). It has no dependencies and only contains[one JavaScript file](https://github.com/retrofox/is-array/blob/d79f1c90c824416b60517c04f0568b5cd3f8271d/index.js#L6-L33), so it has one module. Simple enough.
|
||||
|
||||
Now consider a slightly more complex package like [once](https://www.npmjs.com/package/once), which has exactly one dependency:[wrappy](https://www.npmjs.com/package/wrappy). [Both](https://github.com/isaacs/once/blob/2ad558657e17fafd24803217ba854762842e4178/once.js#L1-L21) [packages](https://github.com/npm/wrappy/blob/71d91b6dc5bdeac37e218c2cf03f9ab55b60d214/wrappy.js#L6-L33) contain one module, so the total module count is 2\. So far, so good.
|
||||
|
||||
Now let’s consider a more deceptive example: [qs](https://www.npmjs.com/package/qs). Since it has zero dependencies, you might assume it only has one module. But in fact, it has four!
|
||||
|
||||
You can confirm this by using a tool I wrote called [browserify-count-modules](https://www.npmjs.com/package/browserify-count-modules), which simply counts the total number of modules in a Browserify bundle:
|
||||
|
||||
```
|
||||
$ npm install qs
|
||||
$ browserify node_modules/qs | browserify-count-modules
|
||||
4
|
||||
```
|
||||
|
||||
This means that a given package can actually contain one or more modules. These modules can also depend on other packages, which might bring in their own packages and modules. The only thing you can be sure of is that each package contains at least one module.
|
||||
|
||||
### Module bloat
|
||||
|
||||
How many modules are in a typical web application? Well, I ran browserify-count-moduleson a few popular Browserify-using sites, and came up with these numbers:
|
||||
|
||||
* [requirebin.com](http://requirebin.com/): 91 modules
|
||||
* [keybase.io](https://keybase.io/): 365 modules
|
||||
* [m.reddit.com](http://m.reddit.com/): 1050 modules
|
||||
* [Apple.com](http://images.apple.com/ipad-air-2/): 1060 modules (Added. [Thanks, Max!](https://twitter.com/denormalize/status/765300194078437376))
|
||||
|
||||
For the record, my own [Pokedex.org](https://pokedex.org/) (the largest open-source site I’ve built) contains 311 modules across four bundle files.
|
||||
|
||||
Ignoring for a moment the raw size of those JavaScript bundles, I think it’s interesting to explore the cost of the number of modules themselves. Sam Saccone has already blown this story wide open in [“The cost of transpiling es2015 in 2016”](https://github.com/samccone/The-cost-of-transpiling-es2015-in-2016#the-cost-of-transpiling-es2015-in-2016), but I don’t think his findings have gotten nearly enough press, so let’s dig a little deeper.
|
||||
|
||||
### Benchmark time!
|
||||
|
||||
I put together [a small benchmark](https://github.com/nolanlawson/cost-of-small-modules) that constructs a JavaScript module importing 100, 1000, and 5000 other modules, each of which merely exports a number. The parent module just sums the numbers together and logs the result:
|
||||
|
||||
```
|
||||
// index.js
|
||||
var total = 0
|
||||
total += require('./module_0')
|
||||
total += require('./module_1')
|
||||
total += require('./module_2')
|
||||
// etc.
|
||||
console.log(total)
|
||||
|
||||
|
||||
// module_1.js
|
||||
module.exports = 1
|
||||
```
|
||||
|
||||
I tested five bundling methods: Browserify, Browserify with the [bundle-collapser](https://www.npmjs.com/package/bundle-collapser) plugin, Webpack, Rollup, and Closure Compiler. For Rollup and Closure Compiler I used ES6 modules, whereas for Browserify and Webpack I used CommonJS, so as not to unfairly disadvantage them (since they would need a transpiler like Babel, which adds its own overhead).
|
||||
|
||||
In order to best simulate a production environment, I used Uglify with the --mangle and--compress settings for all bundles, and served them gzipped over HTTPS using GitHub Pages. For each bundle, I downloaded and executed it 15 times and took the median, noting the (uncached) load time and execution time using performance.now().
|
||||
|
||||
### Bundle sizes
|
||||
|
||||
Before we get into the benchmark results, it’s worth taking a look at the bundle files themselves. Here are the byte sizes (minified but ungzipped) for each bundle ([chart view](https://nolanwlawson.files.wordpress.com/2016/08/min.png)):
|
||||
|
||||
| | 100 modules | 1000 modules | 5000 modules |
|
||||
| --- | --- | --- | --- |
|
||||
| browserify | 7982 | 79987 | 419985 |
|
||||
| browserify-collapsed | 5786 | 57991 | 309982 |
|
||||
| webpack | 3954 | 39055 | 203052 |
|
||||
| rollup | 671 | 6971 | 38968 |
|
||||
| closure | 758 | 7958 | 43955 |
|
||||
|
||||
| | 100 modules | 1000 modules | 5000 modules |
|
||||
| --- | --- | --- | --- |
|
||||
| browserify | 1649 | 13800 | 64513 |
|
||||
| browserify-collapsed | 1464 | 11903 | 56335 |
|
||||
| webpack | 693 | 5027 | 26363 |
|
||||
| rollup | 300 | 2145 | 11510 |
|
||||
| closure | 302 | 2140 | 11789 |
|
||||
|
||||
The way Browserify and Webpack work is by isolating each module into its own function scope, and then declaring a top-level runtime loader that locates the proper module whenever require() is called. Here’s what our Browserify bundle looks like:
|
||||
|
||||
```
|
||||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
|
||||
```
|
||||
|
||||
Whereas the Rollup and Closure bundles look more like what you might hand-author if you were just writing one big module. Here’s Rollup:
|
||||
|
||||
```
|
||||
(function () {
|
||||
'use strict';
|
||||
var total = 0
|
||||
total += 0
|
||||
total += 1
|
||||
total += 2
|
||||
// etc.
|
||||
```
|
||||
|
||||
If you understand the inherent cost of functions-within-functions in JavaScript, and of looking up a value in an associative array, then you’ll be in a good position to understand the following benchmark results.
|
||||
|
||||
### Results
|
||||
|
||||
I ran this benchmark on a Nexus 5 with Android 5.1.1 and Chrome 52 (to represent a low- to mid-range device) as well as an iPod Touch 6th generation running iOS 9 (to represent a high-end device).
|
||||
|
||||
Here are the results for the Nexus 5 ([tabular results](https://gist.github.com/nolanlawson/e84ad060a20f0cb7a7c32308b6b46abe)):
|
||||
|
||||
[![Nexus 5 results](https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_5.png?w=570&h=834)](https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_5.png)
|
||||
|
||||
And here are the results for the iPod Touch ([tabular results](https://gist.github.com/nolanlawson/45ed2c7fa53da035dfc1e153763b9f93)):
|
||||
|
||||
[![iPod Touch results](https://nolanwlawson.files.wordpress.com/2016/08/modules_ipod.png?w=570&h=827)](https://nolanwlawson.files.wordpress.com/2016/08/modules_ipod.png)
|
||||
|
||||
At 100 modules, the variance between all the bundlers is pretty negligible, but once we get up to 1000 or 5000 modules, the difference becomes severe. The iPod Touch is hurt the least by the choice of bundler, but the Nexus 5, being an aging Android phone, suffers a lot under Browserify and Webpack.
|
||||
|
||||
I also find it interesting that both Rollup and Closure’s execution cost is essentially free for the iPod, regardless of the number of modules. And in the case of the Nexus 5, the runtime costs aren’t free, but they’re still much cheaper for Rollup/Closure than for Browserify/Webpack, the latter of which chew up the main thread for several frames if not hundreds of milliseconds, meaning that the UI is frozen just waiting for the module loader to finish running.
|
||||
|
||||
Note that both of these tests were run on a fast Gigabit connection, so in terms of network costs, it’s really a best-case scenario. Using the Chrome Dev Tools, we can manually throttle that Nexus 5 down to 3G and see the impact ([tabular results](https://gist.github.com/nolanlawson/6269d304c970174c21164288808392ea)):
|
||||
|
||||
[![Nexus 5 3G results](https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_53g.png?w=570&h=834)](https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_53g.png)
|
||||
|
||||
Once we take slow networks into account, the difference between Browserify/Webpack and Rollup/Closure is even more stark. In the case of 1000 modules (which is close to Reddit’s count of 1050), Browserify takes about 400 milliseconds longer than Rollup. And that 400ms is no small potatoes, since Google and Bing have both noted that sub-second delays have an[appreciable impact on user engagement](http://radar.oreilly.com/2009/06/bing-and-google-agree-slow-pag.html).
|
||||
|
||||
One thing to note is that this benchmark doesn’t measure the precise execution cost of 100, 1000, or 5000 modules per se, since that will depend on your usage of require(). Inside of these bundles, I’m calling require() once per module, but if you are calling require()multiple times per module (which is the norm in most codebases) or if you are callingrequire() multiple times on-the-fly (i.e. require() within a sub-function), then you could see severe performance degradations.
|
||||
|
||||
Reddit’s mobile site is a good example of this. Even though they have 1050 modules, I clocked their real-world Browserify execution time as much worse than the “1000 modules” benchmark. When profiling on that same Nexus 5 running Chrome, I measured 2.14 seconds for Reddit’s Browserify require() function, and 197 milliseconds for the equivalent function in the “1000 modules” script. (In desktop Chrome on an i7 Surface Book, I also measured it at 559ms vs 37ms, which is pretty astonishing given we’re talking desktop.)
|
||||
|
||||
This suggests that it may be worthwhile to run the benchmark again with multiplerequire()s per module, although in my opinion it wouldn’t be a fair fight for Browserify/Webpack, since Rollup/Closure both resolve duplicate ES6 imports into a single hoisted variable declaration, and it’s also impossible to import from anywhere but the top-level scope. So in essence, the cost of a single import for Rollup/Closure is the same as the cost of n imports, whereas for Browserify/Webpack, the execution cost will increase linearly with n require()s.
|
||||
|
||||
For the purposes of this analysis, though, I think it’s best to just assume that the number of modules is only a lower bound for the performance hit you might feel. In reality, the “5000 modules” benchmark may be a better yardstick for “5000 require() calls.”
|
||||
|
||||
### Conclusions
|
||||
|
||||
First off, the bundle-collapser plugin seems to be a valuable addition to Browserify. If you’re not using it in production, then your bundle will be a bit larger and slower than it would be otherwise (although I must admit the difference is slight). Alternatively, you could switch to Webpack and get an even faster bundle without any extra configuration. (Note that it pains me to say this, since I’m a diehard Browserify fanboy.)
|
||||
|
||||
However, these results clearly show that Webpack and Browserify both underperform compared to Rollup and Closure Compiler, and that the gap widens the more modules you add. Unfortunately I’m not sure [Webpack 2](https://gist.github.com/sokra/27b24881210b56bbaff7) will solve any of these problems, because although they’ll be [borrowing some ideas from Rollup](http://www.2ality.com/2015/12/webpack-tree-shaking.html), they seem to be more focused on the[tree-shaking aspects](http://www.2ality.com/2015/12/bundling-modules-future.html) and not the scope-hoisting aspects. (Update: a better name is “inlining,” and the Webpack team is [working on it](https://github.com/webpack/webpack/issues/2873#issuecomment-240067865).)
|
||||
|
||||
Given these results, I’m surprised Closure Compiler and Rollup aren’t getting much traction in the JavaScript community. I’m guessing it’s due to the fact that (in the case of the former) it has a Java dependency, and (in the case of the latter) it’s still fairly immature and doesn’t quite work out-of-the-box yet (see [Calvin’s Metcalf’s comments](https://github.com/rollup/rollup/issues/552) for a good summary).
|
||||
|
||||
Even without the average JavaScript developer jumping on the Rollup/Closure bandwagon, though, I think npm package authors are already in a good position to help solve this problem. If you npm install lodash, you’ll notice that the main export is one giant JavaScript module, rather than what you might expect given Lodash’s hyper-modular nature (require('lodash/uniq'), require('lodash.uniq'), etc.). For PouchDB, we made a similar decision to [use Rollup as a prepublish step](http://pouchdb.com/2016/01/13/pouchdb-5.2.0-a-better-build-system-with-rollup.html), which produces the smallest possible bundle in a way that’s invisible to users.
|
||||
|
||||
I also created [rollupify](https://github.com/nolanlawson/rollupify) to try to make this pattern a bit easier to just drop-in to existing Browserify projects. The basic idea is to use imports and exports within your own project ([cjs-to-es6](https://github.com/nolanlawson/cjs-to-es6) can help migrate), and then use require() for third-party packages. That way, you still have all the benefits of modularity within your own codebase, while exposing more-or-less one big module to your users. Unfortunately, you still pay the costs for third-party modules, but I’ve found that this is a good compromise given the current state of the npm ecosystem.
|
||||
|
||||
So there you have it: one horse-sized JavaScript duck is faster than a hundred duck-sized JavaScript horses. Despite this fact, though, I hope that our community will eventually realize the pickle we’re in – advocating for a “small modules” philosophy that’s good for developers but bad for users – and improve our tools, so that we can have the best of both worlds.
|
||||
|
||||
### Bonus round! Three desktop browsers
|
||||
|
||||
Normally I like to run performance tests on mobile devices, since that’s where you see the clearest differences. But out of curiosity, I also ran this benchmark on Chrome 52, Edge 14, and Firefox 48 on an i7 Surface Book using Windows 10 RS1\. Here are the results:
|
||||
|
||||
Chrome 52 ([tabular results](https://gist.github.com/nolanlawson/4f79258dc05bbd2c14b85cf2196c6ef0))
|
||||
|
||||
[![Chrome results](https://nolanwlawson.files.wordpress.com/2016/08/modules_chrome.png?w=570&h=831)](https://nolanwlawson.files.wordpress.com/2016/08/modules_chrome.png)
|
||||
|
||||
Edge 14 ([tabular results](https://gist.github.com/nolanlawson/726fa47e0723b45e4ee9ecf0cf2fcddb))
|
||||
|
||||
[![Edge results](https://nolanwlawson.files.wordpress.com/2016/08/modules_edge.png?w=570&h=827)](https://nolanwlawson.files.wordpress.com/2016/08/modules_edge.png)
|
||||
|
||||
Firefox 48 ([tabular results](https://gist.github.com/nolanlawson/7eed17e6ffa18752bf99a9d4bff2941f))
|
||||
|
||||
[![Firefox results](https://nolanwlawson.files.wordpress.com/2016/08/modules_firefox.png?w=570&h=830)](https://nolanwlawson.files.wordpress.com/2016/08/modules_firefox.png)
|
||||
|
||||
The only interesting tidbits I’ll call out in these results are:
|
||||
|
||||
1. bundle-collapser is definitely not a slam-dunk in all cases.
|
||||
2. The ratio of network-to-execution time is always extremely high for Rollup and Closure; their runtime costs are basically zilch. ChakraCore and SpiderMonkey eat them up for breakfast, and V8 is not far behind.
|
||||
|
||||
This latter point could be extremely important if your JavaScript is largely lazy-loaded, because if you can afford to wait on the network, then using Rollup and Closure will have the additional benefit of not clogging up the UI thread, i.e. they’ll introduce less jank than Browserify or Webpack.
|
||||
|
||||
Update: in response to this post, JDD has [opened an issue on Webpack](https://github.com/webpack/webpack/issues/2873). There’s also [one on Browserify](https://github.com/substack/node-browserify/issues/1379).
|
||||
|
||||
Update 2: [Ryan Fitzer](https://github.com/nolanlawson/cost-of-small-modules/pull/5) has generously added RequireJS and RequireJS with [Almond](https://github.com/requirejs/almond) to the benchmark, both of which use AMD instead of CommonJS or ES6.
|
||||
|
||||
Testing shows that RequireJS has [the largest bundle sizes](https://gist.github.com/nolanlawson/511e0ce09fed29fed040bb8673777ec5) but surprisingly its runtime costs are [very close to Rollup and Closure](https://gist.github.com/nolanlawson/4e725df00cd1bc9673b25ef72b831c8b). Here are the results for a Nexus 5 running Chrome 52 throttled to 3G:
|
||||
|
||||
[![Nexus 5 (3G) results with RequireJS](https://nolanwlawson.files.wordpress.com/2016/08/2016-08-20-14_45_29-small_modules3-xlsx-excel.png?w=570&h=829)](https://nolanwlawson.files.wordpress.com/2016/08/2016-08-20-14_45_29-small_modules3-xlsx-excel.png)
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://nolanlawson.com/2016/08/15/the-cost-of-small-modules/?utm_source=javascriptweekly&utm_medium=email
|
||||
|
||||
作者:[Nolan][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://nolanlawson.com/
|
@ -1,757 +0,0 @@
|
||||
Building your first Atom plugin
|
||||
=====
|
||||
|
||||
>Authored by [GitHub Campus Expert][1] @NickTikhonov.
|
||||
|
||||
This tutorial will teach you how to write your first package for the Atom text editor. We'll be building a clone of [Sourcerer][2], a plugin for finding and using code snippets from StackOverflow. By the end of this tutorial you will have written a plugin that converts programming problems written in English into code snippets pulled from StackOverflow:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759382/836dd780-64ab-11e6-8f6a-329f66f01fd7.gif)
|
||||
|
||||
### What you need to know
|
||||
|
||||
Atom is written using web technologies. Our package will be built entirely using the EcmaScript 6 standard for JavaScript. You will need to be familiar with:
|
||||
|
||||
- Using the command line
|
||||
- JavaScript programming
|
||||
- Promises
|
||||
- HTTP
|
||||
|
||||
### Tutorial repository
|
||||
|
||||
You can follow this tutorial step-by-step or check out the [supplementary repository on GitHub][3], which contains the plugin source code. The repository history contains one commit for each step outlined here.
|
||||
|
||||
### Getting Started
|
||||
|
||||
#### Installing Atom
|
||||
|
||||
Download Atom by following the instructions on the [Atom website][4]. We will also need to install apm, the Atom Package Manager command line tool. You can do this by opening Atom and navigating to Atom > Install Shell Commands in the application menu. Check that apm was installed correctly by opening your command line terminal and running apm -v, which should print the version of the tool and related environments:
|
||||
|
||||
```
|
||||
apm -v
|
||||
> apm 1.9.2
|
||||
> npm 2.13.3
|
||||
> node 0.10.40
|
||||
> python 2.7.10
|
||||
> git 2.7.4
|
||||
```
|
||||
|
||||
#### Generating starter code
|
||||
|
||||
Let's begin by creating a new package using a utility provided by Atom.
|
||||
|
||||
- Launch the editor and press Cmd+Shift+P (on MacOS) or Ctrl+Shift+P (on Windows/Linux) to open the Command Palette.
|
||||
|
||||
- Search for "Package Generator: Generate Package" and click the corresponding item on the list. You will see a prompt where you can enter the name of the package - "sourcefetch".
|
||||
|
||||
- Press enter to generate the starter package, which should automatically be opened in Atom.
|
||||
|
||||
If you don't see package files appear in the sidebar, press Cmd+K Cmd+B (on MacOS) or Ctrl+K Ctrl+B (on Windows/Linux).
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759387/8387a354-64ab-11e6-97db-ea469f008bef.gif)
|
||||
|
||||
The Command Palette lets you find and run package commands using fuzzy search. This is a convenient way to run commands without navigating menus or remembering shortcuts. We will be using it throughout this tutorial.
|
||||
|
||||
#### Running the starter code
|
||||
|
||||
Let's try out the starter package before diving into the code itself. We will first need to reload Atom to make it aware of the new package that was added. Open the Command Palette again and run the "Window: Reload" command.
|
||||
|
||||
Reloading the current window ensures that Atom runs the latest version of our source code. We will be running this command every time we want to test the changes we make to our package.
|
||||
|
||||
Run the package toggle command by navigating to Packages > sourcefetch > Toggle using the editor menu, or run sourcefetch: Toggle using the Command Palette. You should see a black box appear at the top of the screen. Hide it by running the command again.
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759386/83799fc0-64ab-11e6-9f0c-0df9b1dbff8b.gif)
|
||||
|
||||
#### The "toggle" command
|
||||
|
||||
Let's open lib/sourcefetch.js, which contains the package logic and defines the toggle command.
|
||||
|
||||
```
|
||||
toggle() {
|
||||
console.log('Sourcefetch was toggled!');
|
||||
return (
|
||||
this.modalPanel.isVisible() ?
|
||||
this.modalPanel.hide() :
|
||||
this.modalPanel.show()
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
toggle is a function exported by the module. It uses a ternary operator to call show and hide on the modal panel based on its visibility. modalPanel is an instance of Panel, a UI element provided by the Atom API. We declare modalPanel inside export default, which lets us access it as an instance variable with this.
|
||||
|
||||
```
|
||||
this.subscriptions.add(atom.commands.add('atom-workspace', {
|
||||
'sourcefetch:toggle': () => this.toggle()
|
||||
}));
|
||||
```
|
||||
|
||||
The above statement tells Atom to execute toggle every time the user runs sourcefetch:toggle. We subscribe an anonymous function, () => this.toggle(), to be called every time the command is run. This is an example of event-driven programming, a common paradigm in JavaScript.
|
||||
|
||||
#### Atom Commands
|
||||
|
||||
Commands are nothing more than string identifiers for events triggered by the user, defined within a package namespace. We've already used:
|
||||
|
||||
- package-generator:generate-package
|
||||
- window:reload
|
||||
- sourcefetch:toggle
|
||||
|
||||
Packages subscribe to commands in order to execute code in response to these events.
|
||||
|
||||
### Making your first code change
|
||||
|
||||
Let's make our first code change—we're going to change toggle to reverse text selected by the user.
|
||||
|
||||
#### Change "toggle"
|
||||
|
||||
- Change the toggle function to match the snippet below.
|
||||
|
||||
```
|
||||
toggle() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
let reversed = selection.split('').reverse().join('')
|
||||
editor.insertText(reversed)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Test your changes
|
||||
|
||||
- Reload Atom by running Window: Reload in the Command Palette
|
||||
|
||||
- Navigate to File > New to create a new file, type anything you like and select it with the cursor.
|
||||
|
||||
- Run the sourcefetch:toggle command using the Command Palette, Atom menu, or by right clicking and selecting "Toggle sourcefetch"
|
||||
|
||||
The updated command will toggle the order of the selected text:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759381/836acd60-64ab-11e6-84dc-4ef4471a361f.gif)
|
||||
|
||||
See all code changes for this step in the [sourcefetch tutorial repository][4].
|
||||
|
||||
### The Atom Editor API
|
||||
|
||||
The code we added uses the TextEditor API to access and manipulate the text inside the editor. Let's take a closer look.
|
||||
|
||||
```
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) { /* ... */ }
|
||||
```
|
||||
|
||||
The first two lines obtain a reference to a TextEditor instance. The variable assignment and following code is wrapped in a conditional to handle the case where there is no text editor instance available, for example, if the command was run while the user was in the settings menu.
|
||||
|
||||
```
|
||||
let selection = editor.getSelectedText()
|
||||
```
|
||||
|
||||
Calling getSelectedText gives us access to text selected by the user. If no text is currently selected, the function returns an empty string.
|
||||
|
||||
```
|
||||
let reversed = selection.split('').reverse().join('')
|
||||
editor.insertText(reversed)
|
||||
```
|
||||
|
||||
Our selected text is reversed using [JavaScript String methods][6] . Finally, we call insertText to replace the selected text with the reversed counterpart. You can learn more about the different TextEditor methods available by reading the [Atom API documentation][5].
|
||||
|
||||
### Exploring the starter package
|
||||
|
||||
Now that we've made our first code change, let's take a closer look at how an Atom package is organized by exploring the starter code.
|
||||
|
||||
#### The main file
|
||||
|
||||
The main file is the entry-point to an Atom package. Atom knows where to find the main file from an entry in package.json:
|
||||
|
||||
```
|
||||
"main": "./lib/sourcefetch",
|
||||
```
|
||||
|
||||
The file exports an object with lifecycle functions which Atom calls on certain events.
|
||||
|
||||
- activate is called when the package is initially loaded by Atom. This function is used to initialize objects such as user interface elements needed by the package, and to subscribe handler functions to package commands.
|
||||
|
||||
- deactivate is called when the package is deactivated, for example, when the editor is closed or refreshed by the user.
|
||||
|
||||
- serialize is called by Atom to allow you to save the state of the package between uses. The returned value is passed as an argument to activate when the package is next loaded by Atom.
|
||||
|
||||
We are going to rename our package command to fetch, and remove user interface elements we won't be using. Update the file to match the version below:
|
||||
|
||||
```
|
||||
'use babel';
|
||||
|
||||
import { CompositeDisposable } from 'atom'
|
||||
|
||||
export default {
|
||||
|
||||
subscriptions: null,
|
||||
|
||||
activate() {
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
|
||||
this.subscriptions.add(atom.commands.add('atom-workspace', {
|
||||
'sourcefetch:fetch': () => this.fetch()
|
||||
}))
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this.subscriptions.dispose()
|
||||
},
|
||||
|
||||
fetch() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
selection = selection.split('').reverse().join('')
|
||||
editor.insertText(selection)
|
||||
}
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### Activation commands
|
||||
|
||||
To improve performance, Atom packages can be lazy loading. We can tell Atom to load our package only when certain commands are run by the user. These commands are called activation commands and are defined in package.json:
|
||||
|
||||
```
|
||||
"activationCommands": {
|
||||
"atom-workspace": "sourcefetch:toggle"
|
||||
},
|
||||
```
|
||||
|
||||
Update this entry to make fetch an activation command.
|
||||
|
||||
```
|
||||
"activationCommands": {
|
||||
"atom-workspace": "sourcefetch:fetch"
|
||||
},
|
||||
```
|
||||
|
||||
Some packages, such as those which modify Atom's appearance need to be loaded on startup. In those cases, activationCommands can be omitted entirely.
|
||||
|
||||
### Triggering commands
|
||||
|
||||
#### Menu items
|
||||
|
||||
JSON files inside the menus folder specify which menu items are created for our package. Let's take a look at `menus/sourcefetch.json`:
|
||||
|
||||
```
|
||||
"context-menu": {
|
||||
"atom-text-editor": [
|
||||
{
|
||||
"label": "Toggle sourcefetch",
|
||||
"command": "sourcefetch:toggle"
|
||||
}
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
The context-menu object lets us define new items in the right-click menu. Each item is defined by a label to be displayed in the menu and a command to run when the item is clicked.
|
||||
|
||||
```
|
||||
"context-menu": {
|
||||
"atom-text-editor": [
|
||||
{
|
||||
"label": "Fetch code",
|
||||
"command": "sourcefetch:fetch"
|
||||
}
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
The menu object in the same file defines custom application menu items created for the package. We're going to rename this entry as well:
|
||||
|
||||
```
|
||||
"menu": [
|
||||
{
|
||||
"label": "Packages",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "sourcefetch",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Fetch code",
|
||||
"command": "sourcefetch:fetch"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### Keyboard shortcuts
|
||||
|
||||
Commands can also be triggered with keyboard shortcuts, defined with JSON files in the keymaps directory:
|
||||
|
||||
```
|
||||
{
|
||||
"atom-workspace": {
|
||||
"ctrl-alt-o": "sourcefetch:toggle"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The above lets package users call toggle with Ctrl+Alt+O on Windows/Linux or Cmd+Alt+O on MacOS.
|
||||
|
||||
Rename the referenced command to fetch:
|
||||
|
||||
```
|
||||
"ctrl-alt-o": "sourcefetch:fetch"
|
||||
```
|
||||
|
||||
Reload Atom by running the Window: Reload command. You should see that the application and right-click menus are updated, and the reverse functionality should work as before.
|
||||
|
||||
See all code changes for this step in the [sourcefetch tutorial repository][7].
|
||||
|
||||
### Using NodeJS modules
|
||||
|
||||
Now that we've made our first code change and learned about Atom package structure, let's introduce our first dependency—a module from Node Package Manager (npm). We will use the request module to make HTTP requests and download the HTML of a website. This functionality will be needed later, to scrape StackOverflow pages.
|
||||
|
||||
#### Installing dependencies
|
||||
|
||||
Open your command line application, navigate to your package root directory and run:
|
||||
|
||||
```
|
||||
npm install --save request@2.73.0
|
||||
apm install
|
||||
```
|
||||
|
||||
These commands add the request Node module to our dependencies list and install the module into the node_modules directory. You should see a new entry in package.json. The @ symbol tells npm to install the specific version we will be using for this tutorial. Running apm install lets Atom know to use our newly installed module.
|
||||
|
||||
```
|
||||
"dependencies": {
|
||||
"request": "^2.73.0"
|
||||
}
|
||||
```
|
||||
|
||||
#### Downloading and logging HTML to the Developer Console
|
||||
|
||||
Import request into our main file by adding an import statement to the top of lib/sourcefetch.js:
|
||||
|
||||
```
|
||||
import { CompositeDisposable } from 'atom'
|
||||
import request from 'request'
|
||||
```
|
||||
|
||||
Now, add a new function, download to the module's exports, below fetch:
|
||||
|
||||
```
|
||||
export default {
|
||||
|
||||
/* subscriptions, activate(), deactivate() */
|
||||
|
||||
fetch() {
|
||||
...
|
||||
},
|
||||
|
||||
download(url) {
|
||||
request(url, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
console.log(body)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This function uses request to download the contents of a web page and logs the output to the Developer Console. When the HTTP request completes, our callback function will be called with the response as an argument.
|
||||
|
||||
The final step is to update fetch so that it calls download:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
this.download(selection)
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
Instead of reversing the selected text, fetch now treats the selection as a URL, passing it to download. Let's see our changes in action:
|
||||
|
||||
- Reload Atom by running the Window: Reload command.
|
||||
|
||||
- Open the Developer Tools. To do this, navigate to View > Developer > Toggle Developer Tools in the menu.
|
||||
|
||||
- Create a new file, navigate to File > New.
|
||||
|
||||
- Enter and select a URL, for example, http://www.atom.io.
|
||||
|
||||
- Run our package command in any of the three ways previously described:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759384/836ea91c-64ab-11e6-8fbe-7d15fb482c6d.gif)
|
||||
|
||||
>Developer Tools make it easy to debug Atom packages. Any console.log statement will print to the interactive console, and you can use the Elements tab to explore the visual structure of the whole applicatio—which is just an HTML [Document Object Model (DOM)][8].
|
||||
|
||||
See all code changes for this step in the [sourcefetch tutorial repository][9].
|
||||
|
||||
### Using Promises to insert downloaded HTML into the editor
|
||||
|
||||
Ideally, we would like our download function to return the HTML as a string instead of just printing page contents into the console. Returning body won't work, however, since we get access to body inside of the callback rather than download itself.
|
||||
|
||||
We will solve this problem by returning a Promise rather than the value itself. Let's change download to return a Promise:
|
||||
|
||||
```
|
||||
download(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(url, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
resolve(body)
|
||||
} else {
|
||||
reject({
|
||||
reason: 'Unable to download page'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
Promises allow us to return values obtained asynchronously by wrapping asynchronous logic in a function that provides two callbacks— resolve for returning a value successfully, and reject for notifying the caller of an error. We call reject if an error is returned by request, and resolve the HTML otherwise.
|
||||
|
||||
Let's change fetch to work with the Promise returned by download:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
this.download(selection).then((html) => {
|
||||
editor.insertText(html)
|
||||
}).catch((error) => {
|
||||
atom.notifications.addWarning(error.reason)
|
||||
})
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
In our new version of fetch, we get access to the HTML by calling then on the Promise returned by download. This lets us insert the HTML into the editor. We also accept and handle any errors returned by calling catch. We handle errors by displaying a warning notification using the Atom Notification API.
|
||||
|
||||
Let's see what changed. Reload Atom and run the package command on a selected URL:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759379/8357bb08-64ab-11e6-9bd2-6f63b8f50dcc.gif)
|
||||
|
||||
If the command is run on an invalid URL, a warning notification will be displayed:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759378/833ab09e-64ab-11e6-9896-2f874b0fdc8a.gif)
|
||||
|
||||
See all code changes for this step in the [sourcefetch tutorial repository][10].
|
||||
|
||||
#### Building a scraper to extract code snippets from StackOverflow HTML
|
||||
|
||||
The next step involves extracting code snippets from the HTML of a StackOverflow page we obtained in the previous step. In particular, we're interested in code from the accepted answer—an answer chosen to be correct by the question author. We can greatly simplify our package implementation by assuming any such answer to be relevant and correct.
|
||||
|
||||
#### Constructing a query using jQuery and Chrome Developer Tools
|
||||
|
||||
This section assumes you are using the Chrome web browser. You may be able to follow along using another browser, but instructions may change.
|
||||
|
||||
Let's take a look at a typical StackOverflow page that contains an accepted answer with a code snippet. We are going to explore the HTML using Chrome Developer Tools:
|
||||
|
||||
- Open Chrome and navigate to any StackOverflow page containing an accepted answer with code, such as this hello world example in Python or this question about reading text from a file in C.
|
||||
|
||||
- Scroll down to the accepted answer and highlight a section of the code snippet.
|
||||
|
||||
- Right click and select Inspect
|
||||
|
||||
- Inspect the location of the code snippet within the HTML code using the Elements browser.
|
||||
|
||||
Note that the document has the following structure:
|
||||
|
||||
```
|
||||
<div class="accepted-answer">
|
||||
...
|
||||
...
|
||||
<pre>
|
||||
<code>
|
||||
...snippet elements...
|
||||
</code>
|
||||
</pre>
|
||||
...
|
||||
...
|
||||
</div>
|
||||
```
|
||||
|
||||
- The accepted answer is denoted by a div with class accepted-answer
|
||||
|
||||
- Block code snippets are located inside a pre element
|
||||
|
||||
- Elements that render the code snippet itself sit inside a code tag
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759380/83689a90-64ab-11e6-89b2-7172c03baae7.gif)
|
||||
|
||||
Now let's construct a jQuery statement for extracting code snippets:
|
||||
|
||||
- Click the Console tab within Developer Tools to access the JavaScript console.
|
||||
|
||||
- Type $('div.accepted-answer pre code').text() into the console and press Enter.
|
||||
|
||||
You should see the accepted answer code snippets printed out in the console. The code we just ran uses a special $ function provided by jQuery. $ accepts a query string to select and return certain HTML elements from the website. Let's take a look at how this code works by considering a couple of intermediate example queries:
|
||||
|
||||
```
|
||||
$('div.accepted-answer')
|
||||
> [<div id="answer-1077349" class="answer accepted-answer" ... ></div>]
|
||||
```
|
||||
|
||||
The above query will match all <div> elements that contain the class accepted-answer, in our case - just one div.
|
||||
|
||||
```
|
||||
$('div.accepted-answer pre code')
|
||||
> [<code>...</code>]
|
||||
```
|
||||
|
||||
Building upon the previous, this query will match any `<code>` element that is inside a `<pre>` element contained within the previously matched `<div>`.
|
||||
|
||||
```
|
||||
$('div.accepted-answer pre code').text()
|
||||
> "print("Hello World!")"
|
||||
```
|
||||
|
||||
The text function extracts and concatenates all text from the list of elements that would otherwise be returned by the previous query. This also strips out elements used for syntax highlighting purposes from the code.
|
||||
|
||||
### Introducing Cheerio
|
||||
|
||||
Our next step involves using the query we created to implement a scraping function using Cheerio, a jQuery implementation for server-side applications.
|
||||
|
||||
#### Install Cheerio
|
||||
|
||||
Open your command line application, navigate to your package root directory and run:
|
||||
|
||||
```
|
||||
npm install --save cheerio@0.20.0
|
||||
apm install
|
||||
```
|
||||
|
||||
#### Implement the scraping function
|
||||
|
||||
- Add an import statement for cheerio in lib/sourcefetch.js:
|
||||
|
||||
```
|
||||
import { CompositeDisposable } from 'atom'
|
||||
import request from 'request'
|
||||
import cheerio from 'cheerio'
|
||||
```
|
||||
|
||||
- Now create a new function that extracts code snippets given StackOverflow HTML, called scrape:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
...
|
||||
},
|
||||
|
||||
scrape(html) {
|
||||
$ = cheerio.load(html)
|
||||
return $('div.accepted-answer pre code').text()
|
||||
},
|
||||
|
||||
download(url) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
- Finally, let's change fetch to pass downloaded HTML to scrape instead of inserting it into the editor:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
let self = this
|
||||
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
this.download(selection).then((html) => {
|
||||
let answer = self.scrape(html)
|
||||
if (answer === '') {
|
||||
atom.notifications.addWarning('No answer found :(')
|
||||
} else {
|
||||
editor.insertText(answer)
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
atom.notifications.addWarning(error.reason)
|
||||
})
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
Our scraping function is implemented in just two lines because cheerio does all of the work for us! We create a $ function by calling load with our HTML string, and use this function to run our jQuery statement and return the results. You can explore the entire Cheerio API in their developer documentation.
|
||||
|
||||
### Testing the updated package
|
||||
|
||||
- Reload Atom and run soucefetch:fetch on a selected StackOverflow URL to see the progress so far.
|
||||
|
||||
If we run the command on a page with an accepted answer, it will be inserted into the editor:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759383/836e26b8-64ab-11e6-9f16-321903470ce2.gif)
|
||||
|
||||
If we run the command on a page with no accepted answer, a warning notification will be displayed instead:
|
||||
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759388/838d3864-64ab-11e6-8091-b4d15bd56025.gif)
|
||||
|
||||
Our new iteration of fetch gives us the code snippet within a StackOverflow page instead of the entire HTML contents. Note that our updated fetch function checks for the absence of an answer and displays a notification to alert the user.
|
||||
|
||||
See all code changes for this step in the [sourcefetch tutorial repository][11].
|
||||
|
||||
### Implementing Google search to find relevant StackOverflow URLs
|
||||
|
||||
Now that we can turn StackOverflow URLs into code snippets, let's implement our final function, search, which will return a relevant URL given the description of a snippet, such as "hello world" or "quicksort". We will be using Google search via the unofficial google npm module, which allows us to search programmatically.
|
||||
|
||||
#### Installing the Google npm module
|
||||
|
||||
- Install google by opening your command line application at the package root directory, and run:
|
||||
|
||||
```
|
||||
npm install --save google@2.0.0
|
||||
apm install
|
||||
```
|
||||
|
||||
#### Importing and configuring the module
|
||||
|
||||
Add an import statement for google at the top of lib/sourcefetch.js:
|
||||
|
||||
```
|
||||
import google from "google"
|
||||
```
|
||||
|
||||
We will configure the library to limit the number of results returned during search. Add the following line below the import statement to limit returned results to just the top one.
|
||||
|
||||
```
|
||||
google.resultsPerPage = 1
|
||||
```
|
||||
|
||||
#### Implementing the search function
|
||||
|
||||
Next, let's implement our search function itself:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
...
|
||||
},
|
||||
|
||||
search(query, language) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let searchString = `${query} in ${language} site:stackoverflow.com`
|
||||
|
||||
google(searchString, (err, res) => {
|
||||
if (err) {
|
||||
reject({
|
||||
reason: 'A search error has occured :('
|
||||
})
|
||||
} else if (res.links.length === 0) {
|
||||
reject({
|
||||
reason: 'No results found :('
|
||||
})
|
||||
} else {
|
||||
resolve(res.links[0].href)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
scrape() {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
The code above searches Google for a StackOverflow page relevant to the given query and programming language, returning the URL of the top result. Let's take a look at how it works:
|
||||
|
||||
```
|
||||
let searchString = `${query} in ${language} site:stackoverflow.com`
|
||||
```
|
||||
|
||||
We construct the search string using the query entered by the user and the current language selected. For example, if the user types "hello world" while editing Python, the query will be hello world in python site:stackoverflow.com. The final part of the string is a filter provided by Google Search that lets us limit results to those linked to StackOverflow.
|
||||
|
||||
```
|
||||
google(searchString, (err, res) => {
|
||||
if (err) {
|
||||
reject({
|
||||
reason: 'A search error has occured :('
|
||||
})
|
||||
} else if (res.links.length === 0) {
|
||||
reject({
|
||||
reason: 'No results found :('
|
||||
})
|
||||
} else {
|
||||
resolve(res.links[0].href)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
We wrap the call to google inside a Promise so that we can return our URL asynchronously. We propagate any errors returned by the library, also returning an error when there are no results available. We resolve the URL of the top result otherwise.
|
||||
|
||||
### Updating fetch to use search
|
||||
|
||||
Our final step is to update fetch to use search:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
let self = this
|
||||
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let query = editor.getSelectedText()
|
||||
let language = editor.getGrammar().name
|
||||
|
||||
self.search(query, language).then((url) => {
|
||||
atom.notifications.addSuccess('Found google results!')
|
||||
return self.download(url)
|
||||
}).then((html) => {
|
||||
let answer = self.scrape(html)
|
||||
if (answer === '') {
|
||||
atom.notifications.addWarning('No answer found :(')
|
||||
} else {
|
||||
atom.notifications.addSuccess('Found snippet!')
|
||||
editor.insertText(answer)
|
||||
}
|
||||
}).catch((error) => {
|
||||
atom.notifications.addWarning(error.reason)
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Let's take a look at what changed:
|
||||
|
||||
- Our selected text is now treated as the query entered by the user.
|
||||
|
||||
- We obtain the language of the current editor tab using the TextEditor API
|
||||
|
||||
- We call search to obtain a URL, which we access by calling then on the resulting Promise
|
||||
|
||||
Instead of calling then on the Promise returned by download, we instead return the Promise itself and chain another then call onto the original call. This helps us avoid callback hell
|
||||
|
||||
See all code changes for this step in the [sourcefetch tutorial repository][12].
|
||||
|
||||
### Testing the final plugin
|
||||
|
||||
And we're done! See the final plugin in action by reloading Atom and running our package command on a problem description, and don't forget to select a language in the bottom-right corner.
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759382/836dd780-64ab-11e6-8f6a-329f66f01fd7.gif)
|
||||
|
||||
### Next steps
|
||||
|
||||
Now that you know the basics of hacking Atom, feel free to practice what you've learned [by forking the sourcefetch repository and adding your own features][13].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://github.com/blog/2231-building-your-first-atom-plugin
|
||||
|
||||
作者:[NickTikhonov][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://github.com/NickTikhonov
|
||||
[1]: https://education.github.com/experts
|
||||
[2]: https://github.com/NickTikhonov/sourcerer
|
||||
[3]: https://github.com/NickTikhonov/sourcefetch-guide
|
||||
[4]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/89e174ab6ec6e270938338b34905f75bb74dbede
|
||||
[5]: https://atom.io/docs/api/latest/TextEditor
|
||||
[6]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
[7]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/aa3ec5585b0aa049393351a30be14590df09c29a
|
||||
[8]: https://www.wikipedia.com/en/Document_Object_Model
|
||||
[9]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/85992043e57c802ca71ff6e8a4f9c477fbfd13db
|
||||
[10]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/896d160dca711f4a53ff5b182018b39cf78d2774
|
||||
[11]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/039a1e1e976d029f7d6b061b4c0dac3eb4a3b5d2
|
||||
[12]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/aa9d0b5fc4811a70292869730e0f60ddf0bcf2aa
|
||||
[13]: https://github.com/NickTikhonov/sourcefetch-tutorial
|
@ -1,3 +1,4 @@
|
||||
Translated by chunyang-wen
|
||||
A Raspberry Pi Hadoop Cluster with Apache Spark on YARN: Big Data 101
|
||||
======
|
||||
|
||||
|
69
sources/tech/20160921 Rust meets Fedora.md
Normal file
69
sources/tech/20160921 Rust meets Fedora.md
Normal file
@ -0,0 +1,69 @@
|
||||
### [Rust meets Fedora](https://fedoramagazine.org/rust-meets-fedora/)
|
||||
|
||||
### ![rust](https://i2.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/rust.jpg?fit=945%2C400&ssl=1)
|
||||
|
||||
### What is Rust?
|
||||
|
||||
Rust is a system programming language which runs blazingly fast, and prevents almost all crashes, [segfaults](https://wikipedia.org/wiki/Segmentation_fault), and data races. You might wonder exactly why yet another programming language is useful, since there are already so many of them. This article aims to explain why.
|
||||
|
||||
### Safety vs. control
|
||||
|
||||
[![Why Rust?](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-09-12-08-29-02.png?resize=300%2C210&ssl=1)](https://i0.wp.com/cdn.fedoramagazine.org/wp-content/uploads/2016/09/Screenshot-from-2016-09-12-08-29-02.png?ssl=1)
|
||||
|
||||
You may have seen a diagram of the above spectrum. On one side there’s C/C++, which has more control of the hardware it’s running on. Therefore it lets the developer optimize performance by executing finer control over the generated machine code. However, this isn’t very safe; it’s easier to cause a segfault, or security bugs like [Heartbleed](https://fedoramagazine.org/update-on-cve-2014-0160-aka-heartbleed/).
|
||||
|
||||
On the other hand, there are languages like Python, Ruby, and JavaScript where the developer has little control but creates safer code. The code can’t generate a segfault, although it can generate exceptions which are fairly safe and contained.
|
||||
|
||||
Somewhere in the middle, there’s Java and a few other languages which are a mixture of these characteristics. They offer some control of the hardware they run on but try to minimize vulnerabilities.
|
||||
|
||||
Rust is a bit different, and doesn’t fall in this spectrum. Instead it gives the developer both safety and control.
|
||||
|
||||
### Specialties of Rust
|
||||
|
||||
Rust is a system programming language like C/C++, except that it gives the developer fine grained control over memory allocations. A garbage collector is not required. It has a minimal runtime, and runs very close to the bare metal. The developer has greater guarantees about the performance of the code. Furthermore, anyone who knows C/C++ can understand and write code for this language.
|
||||
|
||||
Rust runs blazingly fast, since it’s a compiled language. It uses LLVM as the compiler backend and can tap into a large suite of optimizations. In many areas it can perform better than C/C++. Like JavaScript, Ruby, and Python, it’s safe by default, meaning it doesn’t cause segfaults, dangling pointers, or null pointers.
|
||||
|
||||
Another important feature is the elimination of data races. Nowadays, most computers have multiple cores and many threads running in parallel. However it’s tough for developers to write good parallel code, so this feature removes that necessity. There are two key concepts Rust uses to eliminate data races:
|
||||
|
||||
* Ownership. Each variable is moved to a new location, and prevents the previous location from using it. There is only oneowner of each piece of data.
|
||||
* Borrowing. Owned values can be borrowed to allow usage for a certain period of time.
|
||||
|
||||
### Rust in Fedora 24 and 25
|
||||
|
||||
To get started, just install the package:
|
||||
|
||||
```
|
||||
sudo dnf install rust
|
||||
```
|
||||
|
||||
```
|
||||
fn main() {
|
||||
println!("Hello, Rust is running on Fedora 25 Alpha!");
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
rustc helloworld.rs
|
||||
./helloworld
|
||||
```
|
||||
|
||||
Run the following command to install the latest testing version on Fedora:
|
||||
|
||||
```
|
||||
sudo dnf --enablerepo=updates-testing --refresh --best install rust
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/rust-meets-fedora/
|
||||
|
||||
作者:[Sumantro Mukherjee][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/sumantrom/
|
@ -1,58 +0,0 @@
|
||||
ARCH LINUX MAY SOON BE AVAILABLE ON WINDOWS SUBSYSTEM FOR LINUX
|
||||
====
|
||||
|
||||
[![Arch Linux on Windows Subsystem](https://itsfoss.com/wp-content/uploads/2016/10/Arch-Linux-on-windows-subsystem.jpg)](https://itsfoss.com/wp-content/uploads/2016/10/Arch-Linux-on-windows-subsystem.jpg)
|
||||
|
||||
Ubuntu’s makers [Canonical](http://www.canonical.com/) had worked with Microsoft to bring you the much debated [Bash on Windows](https://itsfoss.com/bash-on-windows/). Although the same has had mixed reviews, many hardcore Linux users questioned its usability and some even considered [Bash on Windows a security risk](https://itsfoss.com/linux-bash-windows-security/).
|
||||
|
||||
Unix’s Bash shell was ported to Windows using a new feature called the “Windows Subsystem for Linux” or the WSL. We already saw how you can [install Bash on Windows](https://itsfoss.com/install-bash-on-windows/) easily.
|
||||
|
||||
The Bash on Windows from Canonical and Microsoft is simply the command line version of Ubuntu, not the regular graphical user interface.
|
||||
|
||||
Well, the good thing about Linux enthusiasts is that give them some time and they’ll do things on Windows Subsystem for Linux for which even the original developers will react with, “Wait, we can do that?”.
|
||||
|
||||
That’s precisely what is happening out there.
|
||||
|
||||
![Ubuntu os Win 10](https://itsfoss.com/wp-content/uploads/2016/09/ubuntu-unity-on-windows-10.jpg)
|
||||
|
||||
Yes. IT IS Ubuntu’s Unity shell running on Windows! Pablo Gonzalez, a programmer who goes by the name [Guerra24](https://github.com/Guerra24?tab=overview&from=2016-08-01&to=2016-08-31&utf8=%E2%9C%93) on GitHub has put together this beauty. With this, he has shown that what we can do with the Windows Subsystem for Linux is much more than what it previously was conceived for.
|
||||
|
||||
Now if Ubuntu Unity can be put on Windows subsystem, why not some other Linux distribution?
|
||||
|
||||
### ARCH LINUX FOR BASH ON WINDOWS
|
||||
|
||||
Full fledged distros running natively on WSL. Well, sooner or later it was bound to happen. I’m happier it’s [Arch Linux](https://www.archlinux.org/) though ([Antergos](https://itsfoss.com/tag/antergos/) Lover here).
|
||||
|
||||
![Arch Linux on Windows](https://itsfoss.com/wp-content/uploads/2016/09/awsl.jpg)
|
||||
|
||||
Hold on, hold on there. The project is still in beta. It is being developed by “mintxomat” on GitHub and is currently is on version 0.6\. The first stable version will be released in late December this year.
|
||||
|
||||
Well, what’s the distinguishing point this project brings to the table?
|
||||
|
||||
You might already know that the Windows Subsystem for Linux is available on Windows 10 exclusively. But Arch Linux on Windows Subsystem for Linux (AWSL) has been successfully tested on windows7, Windows 8, Windows 8.1, Windows Server 2012(R2) and Windows 10 of course.
|
||||
|
||||
Whoa, how did they do it?
|
||||
|
||||
The developer says that AWSL protocol achieves this kind of portability by abstracting different frameworks available on different versions of Windows. So it’s the next level when AWSL finally hits 1.0\. And as we discussed the portability stuff already, this project will be the first to bring Bash on all versions of Windows.
|
||||
|
||||
This project is ambitious and promising. If You can’t wait till December then go ahead and give it a try. Just remember it’s a developers preview which is unstable at the moment. But hey, when’s that stopped us?
|
||||
|
||||
You can check out the project on GitHub:
|
||||
|
||||
[Arch on Windows Subsystem](https://github.com/turbo/alwsl)
|
||||
|
||||
[](https://itsfoss.com/10-funny-jokes-pictures-windows-mac-linux/)
|
||||
|
||||
Do share the article and let people know Arch Linux is going to land on Windows soon. Also, let us know which dbistro you want to see on WSL next. Cheers.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/arch-linux-windows-subsystem/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+ItsFoss+%28Its+FOSS%21+An+Open+Source+Blog%29
|
||||
|
||||
作者:[Aquil Roshan][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
@ -0,0 +1,70 @@
|
||||
translating by Bestony
|
||||
|
||||
Keeping Linux containers safe and secure
|
||||
====
|
||||
|
||||
![Interview with Andy Cathrow of Anchore](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/bus-containers2.png?itok=rG1pTnZ4)
|
||||
|
||||
>Image credits : [Lucarelli](http://commons.wikimedia.org/wiki/User:Lucarelli) via [Wikimedia Commons](http://commons.wikimedia.org/wiki/File:Containers_Livorno.jpg). CC-BY-SA 3.0
|
||||
|
||||
Linux containers are helping to change the way that IT operates. In place of large, monolithic virtual machines, organizations are finding effective ways to deploy their applications inside Linux containers, providing for faster speeds, greater density, and increased agility in their operations.
|
||||
|
||||
While containers can bring a number of advantages from a security perspective, they come with their own set of security challenges as well. Just as with traditional infrastructure, it is critical to ensure that the system libraries and components running within a container are regularly updated in order to avoid vulnerabilities. But how do you know what is running inside of your containers? To help manage the full set of security challenges facing container technologies, a startup named[Anchore](https://anchore.com/) is developing an [open source](https://github.com/anchore/anchore)[ project](https://github.com/anchore/anchore) of the same name to bring visibility inside of Linux containers.
|
||||
|
||||
To learn more about Anchore, I caught up with Andrew Cathrow, Anchore's vice president of products and marketing, to learn more about the open source project and the company behind it.
|
||||
|
||||
![](https://opensource.com/sites/default/files/images/life/Interview%20banner%20Q%26A.png)
|
||||
|
||||
### In a nutshell, what is Anchore? How does the toolset work?
|
||||
|
||||
Anchore's goal is to provide a toolset that allows developers, operations, and security teams to maintain full visibility of the 'chain of custody' as containers move through the development lifecycle, while providing the visibility, predictability, and control needed for production deployment. The Anchore engine is comprised of pluggable modules that can perform analysis (extraction of data and metadata from an image), queries (allowing reporting against the container), and policy evaluation (where policies can be specified that govern the deployment of images).
|
||||
|
||||
While there are a number of scanning tools on the market, most are not open source. We believe that security and compliance products should be open source, otherwise, how could you trust them?
|
||||
|
||||
Anchore, in addition to being open source, has two other major differentiators that set it apart from the commercial offerings in the market.
|
||||
|
||||
First, we look beyond the operating system image. Scanning tools today concentrate on operating system packages, e.g. "Do you have any CVEs (security vulnerabilities) in your RPMs or DEB packages?" While that is certainly important, you don't want vulnerable packages in your image, the operating system packages are just the foundation on which the rest of the image is built. All layers need to be validated, including configuration files, language modules, middleware, etc. You can have all the latest packages, but with even one configuration file wrong, insecurity sets in. A second differentiator is the ability to extend the engine by adding users' own data, queries or policies.
|
||||
|
||||
### What is driving the need for an inspection and analytics tool for containers? What problems are operators facing that this helps to solve?
|
||||
|
||||
A primary concern for enterprises adopting Docker today is security, in particular, the governance and compliance of the containers they are deploying. It's almost too easy to pull an application image from a public registry, run it, and within seconds deploy an application in production without even knowing what's under the covers. End users must have confidence that when they deploy applications they will be secure, performant and easily maintained.
|
||||
|
||||
Containers are opaque in that they are deployable ‘black boxes' that contain applications. While it's easy to treat these images as "just packaged applications," they include operating system images with up to hundreds of packages and thousands of files. As with all operating systems on physical servers, virtual machines, or in the cloud, images need to be maintained. The images may contain unpatched security vulnerabilities, outdated software that contains bugs, or may be misconfigured.
|
||||
|
||||
To have confidence in your container deployments you need to know what's under the covers to analyze and make decisions based on the contents of your container images.
|
||||
|
||||
### The innovation around containers today is almost entirely happening in open source. Why do you think that is? What's driving the desire for openness?
|
||||
|
||||
Over the past 20 years organizations have experienced the advantages open source brings to cost savings, reduced lock-in, improved security and faster innovation. Containers, and Docker specifically, are great examples. The team at Docker Inc. would not have been able to create this innovative new software deployment paradigm on top of a proprietary system. They would not have been able to make the required modifications to the code in a proprietary system, nor be able to work cooperatively with industry leaders such as Google, IBM, Intel, and Red Hat—all working toward a common goal. Open source and Linux have always enabled innovation and positive industry disruption. In the past, delivering a big idea required a big team and lots of resources. In the open source world, a small company with big ideas can work in the wider community and benefit from shared intellectual horsepower to collaboratively deliver real enterprise IT innovation.
|
||||
|
||||
To illustrate the deep adoption of open source, the Anchore team recently returned from LinuxCon in Toronto, where it was incredible to see Microsoft as a diamond level sponsor presenting a growing portfolio of their products that work with or on Linux! Linus Torvalds once said, "If Microsoft ever does applications for Linux it means I've won." I'd amend that statement to read "Open has won."
|
||||
|
||||
### The days of common standards in the container space are still very young, and there are still many competing visions for nearly every part of the stack. What challenges does that create for a startup in this space?
|
||||
|
||||
It is important to remember that without open standards and open source we wouldn't have seen the innovation that is driving rapid container adoption and changing the industry landscape. The Open Container Initiative (OCI), comprised of industry leaders from the Linux and Container industries, is doing great work setting standards for both the runtime and image formats that will allow us to see even more innovation. Anchore is proud to be a new member of the OCI and we look forward to helping form the standards.
|
||||
|
||||
### How are you working to build an open source community around the Anchore project?
|
||||
|
||||
The Anchore team has a rich history of building and working within open source communities, with leaders from Ansible, Eucalyptus Systems, and Red Hat. From the start, Anchore began building a strong open source community and we are applying lessons learned in the open source world. The first lesson, of course, is to release early and often. We open sourced our inspection and analysis engine back in June, far in advance of our commercial offering, to ensure that the open source project can stand on its own with features that make it useful to many end-users without having to purchase Anchore's commercial offering. There will always be opportunities to add more value with support, services, and enhanced data feeds with a commercial offering, but if the open source engine is not useful in itself then we will not see an active community.
|
||||
|
||||
We built Anchore to be modular to allow analysis, reporting and policy plugins to be added without requiring changes to the core engine. We want to ensure that anyone can create plugins, so we chose Python as the base language for the project because it is widely used by developers and sysadmins alike. But even if you are not well versed in Python you can still create plugins using whatever language or scripting environment you prefer. If you can create a bash script then you can create an Anchore plugin. Our goal is to enable the broadest possible community to attract participation. While we encourage our users to pass these contributions back to the community we've architected and licensed the project to ensure that private plugins/modules can be created and maintained independently.
|
||||
|
||||
### The promise of containers is not just greater application density on servers or greater speed on the technical side, but a combination of different tools that together provide a different way of approaching the way developers and operators work together. As a company working in this space, how are you providing a message that resonates with both developers and operators?
|
||||
|
||||
The container ecosystem is evolving rapidly with a growing number of runtime, orchestration, monitoring and integration products. So the first consideration we had to factor into our architecture was to not be prescriptive about Anchore deployment and usage, we need to ensure that we can fit into any CI/CD pipeline whether it's on-premise or deployed in the cloud. A common question we are asked is if Anchore will provide a container registry that includes image scanning and analysis. While this would simplify our work considerably, it would force customers into specific deployment architectures and limit customers' ability to deploy their own best-of-breed stack. We've made sure that Anchore works with all leading registries, runtime platforms, CI/CD platforms and orchestration tools.
|
||||
|
||||
Some developers are adding operations skills and moving to DevOps roles, and we see sysadmin/operations teams that are learning more about development as they take DevOps roles. We also see teams with mixed skills. We designed Anchore to be used by development operations and security teams so they can work together to define rules and policies that can be evaluated at any point in the development cycle. Another example is the architecture of the plugins/module interface that enables anyone to easily create a module in their favorite environment—whether it is Python, Go, Perl, C or even a bash script.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/business/16/10/interview-andy-cathrow-anchore
|
||||
|
||||
作者:[Jason Baker][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jason-baker
|
@ -0,0 +1,58 @@
|
||||
Solving the Linux kernel code reviewer shortage
|
||||
====
|
||||
|
||||
Operating system security is [top of mind right now](http://www.infoworld.com/article/3124432/linux/is-the-linux-kernel-a-security-problem.html), and Linux is a big part of that discussion. One of the questions to be solved is: How do we ensure that patches going upstream are properly reviewed?
|
||||
|
||||
Wolfram Sang has been a Linux kernel developer since 2008, and frequently talks at Linux conferences around the world, like[LinuxCon Berlin 2016](https://linuxconcontainerconeurope2016.sched.org/event/7oA4/kernel-development-i-still-think-we-have-a-scaling-problem-wolfram-sang-consultant), about ways to improve kernel development practices.
|
||||
|
||||
Let's get his point of view.
|
||||
|
||||
![](https://opensource.com/sites/default/files/images/life/Interview%20banner%20Q%26A.png)
|
||||
|
||||
### In 2013, you warned the ELCE audience in Edinburgh about subsystem latencies and other issues that may arise if things don't change. Did things change? Did some of the things you warned about end up happening?
|
||||
|
||||
Yes, to some extent. Of course, the Linux kernel is a very heterogeneous project, so subsystems with more focus are in a slightly better position. However, there are enough subsystems which are "just a piece of the puzzle" and for them latency has not improved, generally speaking.
|
||||
|
||||
### You've pointed out that the number of reviewers is a problem. Why do you think the kernel development community doesn't have enough reviewers?
|
||||
|
||||
One thing is that some people prefer to actually write code and not so much read code. This is OK. It just shows that not everyone is a reviewer, so we should really encourage everyone who likes to do that.
|
||||
|
||||
Another thing I see is when we ask people to join our community, it is first mostly about contributing patches. This is natural, I think, and worked well in the beginning when contributions were fewer. But as more and more have joined, especially companies, we've hit this review resource problem. Don't get me wrong, having so many contributions is awesome! I think that we now need to point out that taking part in the community also means more, like to take over some responsibility as a next step. It happens in some parts, but it is not enough to scale yet.
|
||||
|
||||
### Do you think more reviewer training or incentivization of reviewing would help?
|
||||
|
||||
One key point for me is to speak out about there being a problem. Yes, we are doing great so far, but that doesn't mean all is well. We also have problems like this scalability issue. Let people know so maybe some parties get interested and join. I don't think we need special training, though. Most reviewers I know are pretty good or talented, they are just too few or have too little time.
|
||||
|
||||
What you should have is this intrinsic motivation. For the rest, learning-by-doing works great in this field. This is one of the advantages I like to point out: Reviewing patches makes you a better coder.
|
||||
|
||||
### In your opinion, are there large, popular projects that you think are doing a really great job at scaling that we might borrow some ideas from?
|
||||
|
||||
I don't know one, but am open to hearing about them if there are.
|
||||
|
||||
I am very focused on the Linux kernel, so it might be plain bias. However, in my opinion the kernel is indeed special in terms of size, number of contributions, and diversity. So while I think looking at other projects to get inspiration for workflow improvements is always healthy, our scalability problems are pretty unique currently. I find it most useful to look what other subsystems in the kernel are doing.
|
||||
|
||||
### You've mentioned security issues as something that could come up. What should users be doing to avoid or ameliorate the severity of security issues?
|
||||
|
||||
My talk at LinuxCon Berlin this year is targeted at the development level. The security implications could come from patches going in without proper review. I don't want to have users deal with that, I rather want such issues to never happen. This will never work perfectly, but it is still my preferred way to tackle things.
|
||||
|
||||
### I'm wondering how the wider community could help. Are there certain kinds of bug reports that you wish people would file more often? Particular areas that need regular attention but don't get it for some reason?
|
||||
|
||||
We are not short on bug reports. What I am more afraid of is that the shortage of reviewers will lead to more bug reports due to incomplete patches going in. So, we then we'll not only have to deal with the huge amount of contributions, but also with more bugs and regressions.
|
||||
|
||||
### Is there anything else you wish our readers knew about your work?
|
||||
|
||||
With all the specialities around the Linux kernel, it often helps me to remember that at the bottom, it is just code.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/business/16/10/linux-kernel-review
|
||||
|
||||
作者:[Deb Nicholson][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/eximious
|
@ -0,0 +1,34 @@
|
||||
GHlandy Translating
|
||||
|
||||
A Look At The Most Promising Next-Gen Linux Software Update Mechanisms
|
||||
====
|
||||
|
||||
![OPERATING SYSTEMS -- ](http://phoronix.com/assets/categories/operatingsystems.jpg)
|
||||
|
||||
With traditional software package management solutions like APT and Yum showing their age and not adapting well to the embedded world and the slew of new areas for Linux like IoT, a new generation of atomic-based Linux software update solutions continue to be worked on. Matt Porter of the Konsulko Group is presenting at this week's Embedded Linux Conference Europe 2016 with a comparison of these update technologies.
|
||||
|
||||
Incremental atomic updates have been what's being pursued by multiple Linux software vendors for delivering more reliable distribution updates, smaller sized updates via binary deltas, and generally allow rollbacks in case of problems. Some of the new distribution update mechanisms covered included SWUpdate, Mender, OSTree, and swupd. Interestingly, not mentioned in the slide deck is Ubuntu's Snappy.
|
||||
|
||||
SWUpdate is a single/dual image update framework that's modular, supports signed images, makes use of Kconfig for configurations, can handle local or remote updates, etc. [SWUpdate](https://github.com/sbabic/swupdate) is particularly designed for embedded systems.
|
||||
|
||||
[Mender](https://github.com/mendersoftware/mender) meanwhile is a solution aimed at over-the-air software updates. Mender is written in the Go programming language and is a dual-image update framework.
|
||||
|
||||
One of the most well known talked about in this presentation is [OSTree](https://github.com/ostreedev/ostree) for incremental atomic upgrades. OSTree is Git-like and is used by Fedora / Red Hat and GNOME's container system Flatpak also makes use of OSTree.
|
||||
|
||||
Talked about lastly was swupd, the update system spearheaded by Intel's Clear Linux distribution. Swupd is hosted on [GitHub](https://github.com/clearlinux/swupd-client) with its client and server portions hosted by Clear Linux. Swupd is similar to OSTree but does not require reboots to activate bundles.
|
||||
|
||||
For those not in Berlin for the Embedded Linux Conference Europe, you can learn more about these different software update mechanisms with a focus on embedded Linux via [these PDF slides](http://events.linuxfoundation.org/sites/events/files/slides/Comparison%20of%20Linux%20Software%20Update%20Technologies.pdf).
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://phoronix.com/scan.php?page=news_item&px=ELC2016-Software-Updates
|
||||
|
||||
作者:[Michael Larabel][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.michaellarabel.com/
|
@ -0,0 +1,61 @@
|
||||
THIS OPEN SOURCE MINI COMPUTER WILL DELETE DATA IF TEMPERED WITH
|
||||
===========
|
||||
|
||||
[](https://twitter.com/share?original_referer=https%3A%2F%2Fitsfoss.com%2F&source=tweetbutton&text=This+Open+Source+Mini+Computer+Will+Delete+Data+If+Tempered+With&url=https%3A%2F%2Fitsfoss.com%2Forwl-physically-secure-computer%2F&via=%40itsfoss)[](https://www.linkedin.com/cws/share?url=https://itsfoss.com/orwl-physically-secure-computer/)[](http://pinterest.com/pin/create/button/?url=https://itsfoss.com/orwl-physically-secure-computer/&description=This+Open+Source+Mini+Computer+Will+Delete+Data+If+Tempered+With&media=https://itsfoss.com/wp-content/uploads/2016/10/ORWL-ultimate-physically-secured-computer.jpg)
|
||||
|
||||
[![ORWL Open source physically secure computer](https://itsfoss.com/wp-content/uploads/2016/10/ORWL-ultimate-physically-secured-computer.jpg)](https://itsfoss.com/wp-content/uploads/2016/10/ORWL-ultimate-physically-secured-computer.jpg)
|
||||
|
||||
In this era of information, the security is paramount. Nobody would possibly want their important data to fall into wrong hands. But even though unsecured hardware possesses no lesser threat, most of the time people take security measures only on the software end. ORWL is here to change that.
|
||||
|
||||
### [WHAT IS ORWL?](http://www.design-shift.com/orwl/)
|
||||
|
||||
Well, ORWL is the computer which claims to be “the most secure home computer ever built”, around the community. It is a small saucer shaped computer designed with complete physical security in mind. And physical security matters because it’s a truism among the information security professionals that once someone gains physical access to your machine, it’s game over.
|
||||
|
||||
![ORWL and the Secure Key Fob](https://itsfoss.com/wp-content/uploads/2016/10/ORWL-fob.jpg)
|
||||
>ORWL and the Secure Key Fob</figcaption
|
||||
|
||||
ORWL basic specs include Intel Skylake M3 processor, USB-C & micro HDMI ports, 8GB memory, 120GB Solid State Drive, Bluetooth, Wifi and NFC technology. Currently it supports Ubuntu 16.04, Qubes OS and Windows 10 out-of-the-box. All you need is a monitor, keyboard and mouse to get started.
|
||||
|
||||
### ORWL IS OPEN SOURCE
|
||||
|
||||
ORWL is totally open source. It means that the schematic and layout files, software, firmware, everything is up for grab if anyone wants to make one themselves or make improvements.
|
||||
|
||||
![ORWL Teardown](https://itsfoss.com/wp-content/uploads/2016/10/ORWL-teardown.jpg)
|
||||
>ORWL Teardown
|
||||
|
||||
### HOW DOES ORWL WORK?
|
||||
|
||||
ORWL uses a self encrypting SSD. A secure microcontroller integrated into its motherboard to generate and store the cryptographic encryption key. Once it verifies the integrity of the system and authenticated user, it uses the key to decrypt the SSD. In case of any type of tampering with ORWL the key is instantly erased rendering the SSD data useless.
|
||||
|
||||
For authentication purpose, ORWL has a key fob using the technology similar to smart-cards. It uses NFC technology to authenticate user, while using Bluetooth to check whether the user is within the range. The ORWL will be automatically locked if the user is not nearby.
|
||||
|
||||
![ORWL Block Diagram](https://itsfoss.com/wp-content/uploads/2016/10/ORWL-block-diagram.jpg)
|
||||
>ORWL Block Diagram
|
||||
|
||||
The whole ORWL system is encased within an active clamshell mesh with pressure switches all over. The secure micro-controller constantly monitors a dedicated inertial measurement unit, the active mesh, the internal temperature and input power voltage for detecting tampering. This prevents access to the internal components as trying to breach the clamshell will trigger the secure microcontroller to erase the encryption key. Moreover, the DRAM is soldered with the shell for security reason.
|
||||
|
||||
That’s not all. There is much more detailed measurement to ensure complete physical security of the device, including protection from Cold Boot, DMA attacks etc.
|
||||
|
||||
More information can be found on the [ORWL landing page](https://www.orwl.org/). Here is a quick video about it’s working:
|
||||
|
||||
### IS ORWL THE ULTIMATE ANSWER TO INFORMATION SECURITY?
|
||||
|
||||
Sadly, no. Of course not. ORWL only provides physical security to the computer. And though that is robust and totally ninja, there are a lot of other vectors an attack on your system may come from. Nevertheless, it does provide a boost in the overall security.
|
||||
|
||||
[](https://itsfoss.com/maru-os-linux/)
|
||||
|
||||
What do you think about it? Let us know by commenting your thoughts.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/orwl-physically-secure-computer/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+ItsFoss+%28Its+FOSS%21+An+Open+Source+Blog%29
|
||||
|
||||
作者:[ Munif Tanjim][a]
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/munif/
|
776
translated/20160820 Building your first Atom plugin.md
Normal file
776
translated/20160820 Building your first Atom plugin.md
Normal file
@ -0,0 +1,776 @@
|
||||
OneNewLife translated
|
||||
|
||||
制作你的第一个 Atom 插件
|
||||
=====
|
||||
|
||||
>作者: [GitHub 校园专家][1] @NickTikhonov。
|
||||
|
||||
这篇教程将会教你怎么制作你的第一个 Atom 插件。我们将会制作一个山寨的 [Sourcerer][2]——一个查询并使用 StackOverflow 的代码片段的插件。到教程结束时,你将会制作好一个将编程问题(用英语描述的)转换成获取自 StackOverflow 的代码片段的插件,像这样:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759382/836dd780-64ab-11e6-8f6a-329f66f01fd7.gif)
|
||||
|
||||
### 教程须知
|
||||
|
||||
Atom 是用 web 技术创造出来的。我们将完全使用 JavaScript 的 EcmaScript 6 规范来制作插件。你需要熟悉以下内容:
|
||||
|
||||
- 使用命令行
|
||||
- JavaScript 编程
|
||||
- [Promises][14]
|
||||
- [HTTP][16]
|
||||
|
||||
### 教程仓库
|
||||
|
||||
你可以跟着教程一步一步走,或者看看 [GitHub 上的补充仓库][3],这里有插件的源代码。这个仓库的历史提交记录标注有每一步的大纲。
|
||||
|
||||
### 开始
|
||||
|
||||
#### 安装 Atom
|
||||
|
||||
根据 [Atom 官网][16] 的说明来下载 Atom。我们同时还要装上 `apm`(Atom 包管理器的命令行工具)。你可以打开 Atom并在应用菜单中导航到 `Atom > Install Shell Commands`。通过打开你的命令行终端,运行 `apm -v` 来检查 `apm` 是否已经正确安装好,安装成功的话打印出来的工具版本和相关环境信息应该是像这样的:
|
||||
|
||||
```
|
||||
apm -v
|
||||
> apm 1.9.2
|
||||
> npm 2.13.3
|
||||
> node 0.10.40
|
||||
> python 2.7.10
|
||||
> git 2.7.4
|
||||
```
|
||||
|
||||
#### 生成启动包
|
||||
|
||||
让我们通过使用 Atom 提供的一个实用工具创建一个新的 **package**(软件包)来开始这篇教程。
|
||||
|
||||
- 启动编辑器,按下 `Cmd+Shift+P`(MacOS)或者 `Ctrl+Shift+P`(Windows/Linux)来打开 **Command Palette**(命令面板)。
|
||||
|
||||
- 搜索“Package Generator: Generate Package”并点击列表中选中的条目,你会看到一个弹窗,输入软件包的名称——“sourcefetch”。
|
||||
|
||||
- 按下回车键来生成这个启动包,它会自动在 Atom 中打开。
|
||||
|
||||
如果你在侧边栏没有看到软件包的文件,依次按下 `Cmd+K` `Cmd+B`(MacOS)或者 `Ctrl+K` `Ctrl+B`(Windows/Linux)。
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759387/8387a354-64ab-11e6-97db-ea469f008bef.gif)
|
||||
|
||||
命令面板可以让你通过模糊搜索来找到并运行软件包。这是一个执行命令比较方便的途径,你不用去找导航菜单,也不用刻意去记快捷键。我们将会在整篇教程中使用这个方法。
|
||||
|
||||
#### 运行启动包
|
||||
|
||||
在开始编程前让我们来试用一下这个启动包。我们首先需要重启 Atom,这样它才可以识别我们新增的软件包。再次打开命令面板,执行 `Window: Reload` 命令。
|
||||
|
||||
重新加载当前窗口以确保 Atom 执行的是我们最新的源代码。每当需要测试对软件包的改动的时候,我们就需要运行这条命令。
|
||||
|
||||
通过导航到编辑器菜单的 `Packages > sourcefetch > Toggle` 或者在命令面板执行 `sourcefetch: Toggle` 来运行软件包的 `toggle` 命令。你应该会看到屏幕的顶部出现了一个小黑窗。再次运行这条命令就可以隐藏它。
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759386/83799fc0-64ab-11e6-9f0c-0df9b1dbff8b.gif)
|
||||
|
||||
#### “toggle”命令
|
||||
|
||||
打开 `lib/sourcefetch.js`,这个文件包含有软件包的逻辑和 `toggle` 命令的定义。
|
||||
|
||||
```
|
||||
toggle() {
|
||||
console.log('Sourcefetch was toggled!');
|
||||
return (
|
||||
this.modalPanel.isVisible() ?
|
||||
this.modalPanel.hide() :
|
||||
this.modalPanel.show()
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
`toggle` 是这个模块导出的一个函数。根据模态面板的可见性,它通过一个 [三目运算符][17] 来调用 `show` 和 `hide` 方法。`modalPanel` 是 [Panel][18](一个由 Atom API 提供的 UI 元素) 的一个实例。我们需要在 `export default` 内部声明 `modalPanel` 才可以让我们通过一个实例变量 `this` 来访问它。
|
||||
|
||||
```
|
||||
this.subscriptions.add(atom.commands.add('atom-workspace', {
|
||||
'sourcefetch:toggle': () => this.toggle()
|
||||
}));
|
||||
```
|
||||
|
||||
上面的语句让 Atom 在用户运行 `sourcefetch:toggle` 的时候执行 `toggle` 方法。我们订阅了一个 [匿名函数][19] `() => this.toggle()`,每次执行这条命令的时候都会执行这个函数。这是 [事件驱动编程][20](一种常用的 JavaScript 模式)的一个范例。
|
||||
|
||||
#### Atom 命令
|
||||
|
||||
命令只是用户触发事件时使用的一些字符串标识符,它在软件包的一个命名空间内定义。我们已经用过的命令有:
|
||||
|
||||
- `Package-Generator: Generate-Package`
|
||||
- `Window: Reload`
|
||||
- `sourcefetch:toggle`
|
||||
|
||||
软件包通过订阅命令来执行代码以达到响应事件的目的。
|
||||
|
||||
### 进行你的第一次代码更改
|
||||
|
||||
让我们来进行第一次代码更改——我们将通过改变 `toggle` 函数来实现逆转用户选中文本的功能。
|
||||
|
||||
#### 改变“toggle”函数
|
||||
|
||||
- 更改 `toggle` 函数以匹配下面的代码段。
|
||||
|
||||
```
|
||||
toggle() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
let reversed = selection.split('').reverse().join('')
|
||||
editor.insertText(reversed)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 测试你的改动
|
||||
|
||||
- 通过在命令面板运行 `Window: Reload` 来重新加载 Atom
|
||||
|
||||
- 通过导航到 `File > New` 来创建一个新文件,随便写点什么并通过光标选中它。
|
||||
|
||||
- 通过命令面板、Atom 菜单或者右击文本然后选中 `Toggle sourcefetch` 来运行 `sourcefetch:toggle` 命令
|
||||
|
||||
更新后的命令将会改变选中文本的顺序:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759381/836acd60-64ab-11e6-84dc-4ef4471a361f.gif)
|
||||
|
||||
在 [sourcefetch 教程仓库][4] 查看这一步所有的代码更改。
|
||||
|
||||
### Atom 编辑器 API
|
||||
|
||||
我们添加的代码通过用 [TextEditor API][21] 来访问编辑器内的文本并进行操作。让我们来仔细看看。
|
||||
|
||||
```
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) { /* ... */ }
|
||||
```
|
||||
|
||||
头两行代码获取了 [TextEditor][5] 实例的一个引用。变量的赋值和后面的代码被包在一个条件结构里,这是为了处理没有可用的编辑器实例的情况,例如,当用户在设置菜单中运行命令时。
|
||||
|
||||
```
|
||||
let selection = editor.getSelectedText()
|
||||
```
|
||||
|
||||
调用 `getSelectedText` 方法可以让我们访问到用户选中的文本。如果当前没有文本被选中,函数将返回一个空字符串。
|
||||
|
||||
```
|
||||
let reversed = selection.split('').reverse().join('')
|
||||
editor.insertText(reversed)
|
||||
```
|
||||
|
||||
我们选中的文本通过一个 [JavaScript 字符串方法][6] 来逆转。最后,我们调用 `insertText` 方法来将选中的文本替换为逆转后的文本副本。通过阅读 [Atom API 文档][5],你可以学到更多关于 TextEditor 的不同的方法。
|
||||
|
||||
### 浏览启动包
|
||||
|
||||
现在我们已经完成第一次代码更改了,让我们浏览启动包的代码来深入了解一下 Atom 的软件包是怎样构成的。
|
||||
|
||||
#### 主文件
|
||||
|
||||
主文件是 Atom 软件包的入口文件。Atom 通过 `package.json` 里的条目设置来找到主文件的位置:
|
||||
|
||||
```
|
||||
"main": "./lib/sourcefetch",
|
||||
```
|
||||
|
||||
这个文件导出一个带有生命周期函数(Atom 在特定的事件发生时调用的处理函数)的对象。
|
||||
|
||||
- **activate** 会在 Atom 初次加载软件包的时候调用。这个函数用来初始化一些诸如软件包所需的用户界面元素的对象,以及订阅软件包命令的处理函数。
|
||||
|
||||
- **deactivate** 会在软件包停用的时候调用,例如,当用户关闭或者刷新编辑器的时候。
|
||||
|
||||
- **serialize** 会在使用软件包的过程中被 Atom 调用以保存软件包的当前状态。它的返回值会在 Atom 下一次加载软件包的时候作为一个参数传递给 `activate`。
|
||||
|
||||
我们将会重命名我们的软件包命令为 `fetch`,并移除一些我们不再需要的用户界面元素。更改主文件以匹配下面这个版本:
|
||||
|
||||
```
|
||||
'use babel';
|
||||
|
||||
import { CompositeDisposable } from 'atom'
|
||||
|
||||
export default {
|
||||
|
||||
subscriptions: null,
|
||||
|
||||
activate() {
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
|
||||
this.subscriptions.add(atom.commands.add('atom-workspace', {
|
||||
'sourcefetch:fetch': () => this.fetch()
|
||||
}))
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this.subscriptions.dispose()
|
||||
},
|
||||
|
||||
fetch() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
selection = selection.split('').reverse().join('')
|
||||
editor.insertText(selection)
|
||||
}
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### 启用命令
|
||||
|
||||
为了提升性能,Atom 软件包可以懒加载。我们可以让 Atom 在用户执行特定的命令的时候加载我们的软件包。这些命令被称为 **启用命令**,它们在 `package.json` 中定义:
|
||||
|
||||
```
|
||||
"activationCommands": {
|
||||
"atom-workspace": "sourcefetch:toggle"
|
||||
},
|
||||
```
|
||||
|
||||
更新一下条目设置,让 `fetch` 成为一个启用命令。
|
||||
|
||||
```
|
||||
"activationCommands": {
|
||||
"atom-workspace": "sourcefetch:fetch"
|
||||
},
|
||||
```
|
||||
|
||||
有一些软件包需要在 Atom 启动的时候被加载,例如那些改变 Atom 外观的软件包。在那样的情况下,`activationCommands` 会被完全忽略。
|
||||
|
||||
### 触发命令
|
||||
|
||||
#### 菜单项
|
||||
|
||||
`menus` 目录下的 JSON 文件指定了哪些菜单项是为我们的软件包而建的。让我们看看 `menus/sourcefetch.json`:
|
||||
|
||||
```
|
||||
"context-menu": {
|
||||
"atom-text-editor": [
|
||||
{
|
||||
"label": "Toggle sourcefetch",
|
||||
"command": "sourcefetch:toggle"
|
||||
}
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
这个 `context-menu` 对象可以让我们定义右击菜单的一些新条目。每一个条目都是通过一个决定显示内容的 `label` 属性和一个决定点击后执行的命令的 `command` 属性来定义的。
|
||||
|
||||
```
|
||||
"context-menu": {
|
||||
"atom-text-editor": [
|
||||
{
|
||||
"label": "Fetch code",
|
||||
"command": "sourcefetch:fetch"
|
||||
}
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
同一个文件中的这个 `menu` 对象用来定义插件的自定义应用菜单。我们同样要重命名它的条目:
|
||||
|
||||
```
|
||||
"menu": [
|
||||
{
|
||||
"label": "Packages",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "sourcefetch",
|
||||
"submenu": [
|
||||
{
|
||||
"label": "Fetch code",
|
||||
"command": "sourcefetch:fetch"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### 键盘快捷键
|
||||
|
||||
命令还可以通过键盘快捷键来触发。快捷键通过 `keymaps` 目录的 JSON 文件来定义:
|
||||
|
||||
```
|
||||
{
|
||||
"atom-workspace": {
|
||||
"ctrl-alt-o": "sourcefetch:toggle"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
以上代码可以让用户通过 `Ctrl+Alt+O`(Windows/Linux) 或 `Cmd+Alt+O`(MacOS) 来触发 `toggle` 命令。
|
||||
|
||||
重命名引用的命令为 `fetch`:
|
||||
|
||||
```
|
||||
"ctrl-alt-o": "sourcefetch:fetch"
|
||||
```
|
||||
|
||||
通过执行 `Window: Reload` 命令来重启 Atom。你应该会看到 Atom 的右击菜单更新了,并且逆转文本的功能应该还可以像之前一样使用。
|
||||
|
||||
在 [sourcefetch 教程仓库][7] 查看这一步所有的代码更改。
|
||||
|
||||
### 使用 NodeJS 模块
|
||||
|
||||
现在我们已经完成了第一次代码更改并且了解了 Atom 软件包的结构,让我们介绍一下 [Node 包管理器(npm)][22] 中的第一个依赖项模块。我们将使用 **request** 模块发 HTTP 请求来下载网站的 HTML 文件。稍后将会用到这个功能来扒 StackOverflow 的页面。
|
||||
|
||||
#### 安装依赖
|
||||
|
||||
打开你的命令行工具,切换到你的软件包的根目录并运行:
|
||||
|
||||
```
|
||||
npm install --save request@2.73.0
|
||||
apm install
|
||||
```
|
||||
|
||||
这两条命令将 `request` 模块添加到我们软件包的依赖列表并将模块安装到 `node_modules` 目录。你应该会在 `package.json` 看到一个新条目。`@` 符号的作用是让 npm 安装我们这篇教程需要用到的特定版本的模块。运行 `apm install` 是为了让 Atom 知道使用我们新安装的模块。
|
||||
|
||||
```
|
||||
"dependencies": {
|
||||
"request": "^2.73.0"
|
||||
}
|
||||
```
|
||||
|
||||
#### 下载 HTML 并将记录打印在开发者控制台
|
||||
|
||||
通过在 `lib/sourcefetch.js` 的顶部添加一条引用语句引入 `request` 模块到我们的主文件:
|
||||
|
||||
```
|
||||
import { CompositeDisposable } from 'atom'
|
||||
import request from 'request'
|
||||
```
|
||||
|
||||
现在,在 `fetch` 函数下面添加一个新函数 `download` 作为模块的导出项:
|
||||
|
||||
```
|
||||
export default {
|
||||
|
||||
/* subscriptions, activate(), deactivate() */
|
||||
|
||||
fetch() {
|
||||
...
|
||||
},
|
||||
|
||||
download(url) {
|
||||
request(url, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
console.log(body)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
这个函数用 `request` 模块来下载一张页面的内容并将记录输出到控制台。当 HTTP 请求完成之后,我们的 [回调函数][23] 会将响应体作为参数来被调用。
|
||||
|
||||
最后一步是更新 `fetch` 函数以调用 `download` 函数:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
this.download(selection)
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
`fetch` 函数现在的功能是将 selection 当作一个 URL 传递给 `download` 函数,而不再是逆转选中的文本了。让我们来看看这次的更改:
|
||||
|
||||
- 通过执行 `Window: Reload` 命令来重新加载 Atom。
|
||||
|
||||
- 打开开发者工具。为此,导航到菜单中的 `View > Developer > Toggle Developer Tools`。
|
||||
|
||||
- 新建一个文件,导航到 `File > New`。
|
||||
|
||||
- 输入一个 URL 并选中它,例如:`http://www.atom.io`。
|
||||
|
||||
- 用上述的任意一种方法执行我们软件包的命令:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759384/836ea91c-64ab-11e6-8fbe-7d15fb482c6d.gif)
|
||||
|
||||
**开发者工具** 让 Atom 软件包的调试更轻松。任意 `console.log` 语句都可以将信息打印到交互控制台,你还可以使用 `Elements` 选项卡来浏览整个应用的可视化结构——即 HTML 的 [文本对象模型(DOM)][8]。
|
||||
|
||||
在 [sourcefetch 教程仓库][9] 查看这一步所有的代码更改。
|
||||
|
||||
### 用 Promises 来将下载好的 HTML 插入到编辑器中
|
||||
|
||||
理想情况下,我们希望 download 函数可以将 HTML 作为一个字符串来返回,而不仅仅是将页面的内容打印到控制台。然而,`返回体` 是无法实现的,因为我们要在回调函数里面访问 `返回体` 而不是在 `download` 函数那里。
|
||||
|
||||
我们会通过返回一个 [Promise][24] 来解决这个问题,而不再是返回一个值。让我们改动 `download` 函数来返回一个 Promise:
|
||||
|
||||
```
|
||||
download(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(url, (error, response, body) => {
|
||||
if (!error && response.statusCode == 200) {
|
||||
resolve(body)
|
||||
} else {
|
||||
reject({
|
||||
reason: 'Unable to download page'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
Promises 允许我们通过将异步逻辑封装在一个提供两个回调方法(`resolve` 用来处理请求成功的返回值,`reject` 用来向使用者报错)的函数里来返回获得的值。如果请求返回了错误我们就调用 `reject`,否则就用 `resolve` 来处理 HTML。
|
||||
|
||||
让我们更改 `fetch` 函数来使用 `download` 返回的 Promise:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
this.download(selection).then((html) => {
|
||||
editor.insertText(html)
|
||||
}).catch((error) => {
|
||||
atom.notifications.addWarning(error.reason)
|
||||
})
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
在我们新版的 `fetch` 函数里,我们通过在 `download` 返回的 Promise 调用 `then` 方法来对 HTML 进行操作。这会将 HTML 插入到编辑器中。我们同样会通过调用 `catch` 方法来接收并处理所有的错误。我们通过用 [Atom Notification API][25] 来显示警告的形式来处理错误。
|
||||
|
||||
看看发生了什么变化。重新加载 Atom 并在一个选中的 URL 上执行软件包命令:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759379/8357bb08-64ab-11e6-9bd2-6f63b8f50dcc.gif)
|
||||
|
||||
如果这个 URL 是无效的,一个警告通知将会弹出来:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759378/833ab09e-64ab-11e6-9896-2f874b0fdc8a.gif)
|
||||
|
||||
在 [sourcefetch 教程仓库][10] 查看这一步所有的代码更改。
|
||||
|
||||
#### 编写一个爬虫来提取 StackOverflow 页面的代码片段
|
||||
|
||||
下一步涉及用我们前面扒到的 StackOverflow 的页面的 HTML 来提取代码片段。我们尤其关注那些来自采纳答案(提问者选择的一个正确答案)的代码。我们可以在假设这类答案都是相关且正确的前提下大大简化我们这个软件包的实现。
|
||||
|
||||
#### 使用 jQuery 和 Chrome 开发者工具来构建查询
|
||||
|
||||
这一部分假设你使用的是 [Chrome][26] 浏览器。你接下来可以使用其它浏览器,但是提示可能会不一样。
|
||||
|
||||
让我们先看看一张典型的包含采纳答案和代码片段的 StackOverflow 页面。我们将会使用 Chrome 开发者工具来浏览 HTML:
|
||||
|
||||
- 打开 Chrome 并跳到任意一张带有采纳答案和代码的 StackOverflow 页面,比如像这个用 Python 写的 [hello world][27] 的例子或者这个关于 [用 `C` 来读取文本内容的问题][28]。
|
||||
|
||||
- 滚动窗口到采纳答案的位置并选中一部分代码。
|
||||
|
||||
- 右击选中文本并选择 `检查`。
|
||||
|
||||
- 使用元素侦察器来检查代码片段在 HTML 中的位置。
|
||||
|
||||
注意文本结构应该是这样的:
|
||||
|
||||
```
|
||||
<div class="accepted-answer">
|
||||
...
|
||||
...
|
||||
<pre>
|
||||
<code>
|
||||
...snippet elements...
|
||||
</code>
|
||||
</pre>
|
||||
...
|
||||
...
|
||||
</div>
|
||||
```
|
||||
|
||||
- 采纳答案通过一个 class 为 `accepted-answer` 的 `div` 来表示
|
||||
|
||||
- 代码块位于 `pre` 元素的内部
|
||||
|
||||
- 呈现代码片段的元素就是里面那一对 `code` 标签
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759380/83689a90-64ab-11e6-89b2-7172c03baae7.gif)
|
||||
|
||||
现在让我们写一些 `jQuery` 代码来提取代码片段:
|
||||
|
||||
- 在开发者工具那里点击 **Console** 选项卡来访问 Javascript 控制台。
|
||||
|
||||
- 在控制台中输入 `$('div.accepted-answer pre code').text()` 并按下回车键。
|
||||
|
||||
你应该会看到控制台中打印出采纳答案的代码片段。我们刚刚运行的代码使用了一个 jQuery 提供的特别的 `$` 函数。`$` 接收要选择的 **查询字符串** 并返回网站中的某些 HTML 元素。让我们通过思考几个查询案例看看这段代码的工作原理:
|
||||
|
||||
```
|
||||
$('div.accepted-answer')
|
||||
> [<div id="answer-1077349" class="answer accepted-answer" ... ></div>]
|
||||
```
|
||||
|
||||
上面的查询会匹配所有 class 为 `accepted-answer` 的 `<div>` 元素,在我们的案例中只有一个 div。
|
||||
|
||||
```
|
||||
$('div.accepted-answer pre code')
|
||||
> [<code>...</code>]
|
||||
```
|
||||
|
||||
在前面的基础上改造了一下,这个查询会匹配所有在之前匹配的 `<div>` 内部的 `<pre>` 元素内部的 `<code>` 元素。
|
||||
|
||||
```
|
||||
$('div.accepted-answer pre code').text()
|
||||
> "print("Hello World!")"
|
||||
```
|
||||
|
||||
`text` 函数提取并连接原本将由上一个查询返回的元素列表中的所有文本。这也从代码中去除了用来使语法高亮的元素。
|
||||
|
||||
### 介绍 Cheerio
|
||||
|
||||
我们的下一步涉及使用我们创建好的查询结合 [Cheerio][29](一个服务器端实现的 jQuery)来实现扒页面的功能。
|
||||
|
||||
#### 安装 Cheerio
|
||||
|
||||
打开你的命令行工具,切换到你的软件包的根目录并执行:
|
||||
|
||||
```
|
||||
npm install --save cheerio@0.20.0
|
||||
apm install
|
||||
```
|
||||
|
||||
#### 实现扒页面的功能
|
||||
|
||||
- 在 `lib/sourcefetch.js` 为 `cheerio` 添加一条引用语句:
|
||||
|
||||
```
|
||||
import { CompositeDisposable } from 'atom'
|
||||
import request from 'request'
|
||||
import cheerio from 'cheerio'
|
||||
```
|
||||
|
||||
- 现在创建一个新函数 `scrape`,它用来提取 StackOverflow HTML 里面的代码片段:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
...
|
||||
},
|
||||
|
||||
scrape(html) {
|
||||
$ = cheerio.load(html)
|
||||
return $('div.accepted-answer pre code').text()
|
||||
},
|
||||
|
||||
download(url) {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
- 最后,让我们更改 `fetch` 函数以传递下载好的 HTML 给 `scrape` 而不是将其插入到编辑器:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
let self = this
|
||||
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let selection = editor.getSelectedText()
|
||||
this.download(selection).then((html) => {
|
||||
let answer = self.scrape(html)
|
||||
if (answer === '') {
|
||||
atom.notifications.addWarning('No answer found :(')
|
||||
} else {
|
||||
editor.insertText(answer)
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.log(error)
|
||||
atom.notifications.addWarning(error.reason)
|
||||
})
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
我们扒取页面的功能仅仅用两行代码就实现了,因为 cheerio 已经替我们做好了所有的工作!我们通过调用 `load` 方法加载 HTML 字符串来创建一个 `$` 函数,然后用这个函数来执行 jQuery 语句并返回结果。你可以在官方 [开发者文档][30] 查看完整的 `Cheerio API`。
|
||||
|
||||
### 测试更新后的软件包
|
||||
|
||||
- 重新加载 Atom 并在一个选中的 StackOverflow URL 上运行 `soucefetch:fetch` 以查看到目前为止的进度。
|
||||
|
||||
如果我们在一个有采纳答案的页面上运行这条命令,代码片段将会被插入到编辑器中:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759383/836e26b8-64ab-11e6-9f16-321903470ce2.gif)
|
||||
|
||||
如果我们在一个没有采纳答案的页面上运行这条命令,将会弹出一个警告通知:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759388/838d3864-64ab-11e6-8091-b4d15bd56025.gif)
|
||||
|
||||
我们最新的 `fetch` 函数给我们提供了一个 StackOverflow 页面的代码片段而不再是整个 HTML 内容。要注意我们更新的 `fetch` 函数会检查有没有答案并显示通知以提醒用户。
|
||||
|
||||
在 [sourcefetch 教程仓库][11] 查看这一步所有的代码更改。
|
||||
|
||||
### 实现用来查找相关的 StackOverflow URL 的谷歌搜索功能
|
||||
|
||||
现在我们已经将 StackOverflow 的 URL 转化为代码片段了,让我们来实现最后一个函数——`search`,它应该要返回一个相关的 URL 并附加一些像“hello world”或者“快排”这样的描述。我们会通过一个非官方的 `google` npm 模块来使用谷歌搜索功能,这样可以让我们以编程的方式来搜索。
|
||||
|
||||
#### 安装 Google npm 模块
|
||||
|
||||
- 通过在软件包的根目录打开命令行工具并执行命令来安装 `google` 模块:
|
||||
|
||||
```
|
||||
npm install --save google@2.0.0
|
||||
apm install
|
||||
```
|
||||
|
||||
#### 引入并配置模块
|
||||
|
||||
在 `lib/sourcefetch.js` 的顶部为 `google` 模块添加一条引用语句:
|
||||
|
||||
```
|
||||
import google from "google"
|
||||
```
|
||||
|
||||
我们将配置一下 `google` 以限制搜索期间返回的结果数。将下面这行代码添加到引用语句下面以限制搜索返回最热门的那个结果。
|
||||
|
||||
```
|
||||
google.resultsPerPage = 1
|
||||
```
|
||||
|
||||
#### 实现 search 函数
|
||||
|
||||
接下来让我们来实现我们的 `search` 函数:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
...
|
||||
},
|
||||
|
||||
search(query, language) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let searchString = `${query} in ${language} site:stackoverflow.com`
|
||||
|
||||
google(searchString, (err, res) => {
|
||||
if (err) {
|
||||
reject({
|
||||
reason: 'A search error has occured :('
|
||||
})
|
||||
} else if (res.links.length === 0) {
|
||||
reject({
|
||||
reason: 'No results found :('
|
||||
})
|
||||
} else {
|
||||
resolve(res.links[0].href)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
scrape() {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
以上代码通过谷歌来搜索一张和指定的关键词以及编程语言相关的 StackOverflow 页面,并返回一个最热门的 URL。让我们看看这是怎样来实现的:
|
||||
|
||||
```
|
||||
let searchString = `${query} in ${language} site:stackoverflow.com`
|
||||
```
|
||||
|
||||
我们使用用户输入的查询和当前所选的语言来构造搜索字符串。比方说,当用户在写 Python 的时候输入“hello world”,查询语句就会变成 `hello world in python site:stackoverflow.com`。字符串的最后一部分是谷歌搜索提供的一个过滤器,它让我们可以将搜索结果的来源限制为 StackOverflow。
|
||||
|
||||
```
|
||||
google(searchString, (err, res) => {
|
||||
if (err) {
|
||||
reject({
|
||||
reason: 'A search error has occured :('
|
||||
})
|
||||
} else if (res.links.length === 0) {
|
||||
reject({
|
||||
reason: 'No results found :('
|
||||
})
|
||||
} else {
|
||||
resolve(res.links[0].href)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
我们将 `google` 方法放在一个 `Promise` 里面,这样我们可以异步地返回我们的 URL。我们会传递由 `google` 返回的所有错误并且会在没有可用的搜索结果的时候返回一个错误。否则我们将通过 `resolve` 来解析最热门结果的 URL。
|
||||
|
||||
### 更新 fetch 来使用 search
|
||||
|
||||
我们的最后一步是更新 `fetch` 函数来使用 `search` 函数:
|
||||
|
||||
```
|
||||
fetch() {
|
||||
let editor
|
||||
let self = this
|
||||
|
||||
if (editor = atom.workspace.getActiveTextEditor()) {
|
||||
let query = editor.getSelectedText()
|
||||
let language = editor.getGrammar().name
|
||||
|
||||
self.search(query, language).then((url) => {
|
||||
atom.notifications.addSuccess('Found google results!')
|
||||
return self.download(url)
|
||||
}).then((html) => {
|
||||
let answer = self.scrape(html)
|
||||
if (answer === '') {
|
||||
atom.notifications.addWarning('No answer found :(')
|
||||
} else {
|
||||
atom.notifications.addSuccess('Found snippet!')
|
||||
editor.insertText(answer)
|
||||
}
|
||||
}).catch((error) => {
|
||||
atom.notifications.addWarning(error.reason)
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
让我们看看发生了什么变化:
|
||||
|
||||
- 我们选中的文本现在变成了用户输入的 `query`
|
||||
|
||||
- 我们使用 [TextEditor API][21] 来获取当前编辑器选项卡使用的 `language`
|
||||
|
||||
- 我们调用 `search` 方法来获取一个 URL,然后通过在得到的 Promise 上调用 `then` 方法来访问这个 URL
|
||||
|
||||
我们不在 `download` 返回的 Promise 上调用 `then` 方法,而是在前面 `search` 方法本身链式调用的另一个 `then` 方法返回的 Promise 上面接着调用 `then` 方法。这样可以帮助我们避免 [回调地狱][31]
|
||||
|
||||
在 [sourcefetch 教程仓库][12] 查看这一步所有的代码更改。
|
||||
|
||||
### 测试最终的插件
|
||||
|
||||
大功告成了!重新加载 Atom,对一个问题描述运行软件包的命令来看看我们最终的插件,不要忘了在编辑器右下角选择一种语言。
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/6755555/17759382/836dd780-64ab-11e6-8f6a-329f66f01fd7.gif)
|
||||
|
||||
### 下一步
|
||||
|
||||
现在你知道怎么去“hack” Atom 的基本原理了,通过 [fork sourcefetch 这个仓库并添加你的特性][13] 来随心所欲地实践你所学到的知识。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
编译自: https://github.com/blog/2231-building-your-first-atom-plugin
|
||||
|
||||
作者:[NickTikhonov][a]
|
||||
译者:[OneNewLife](https://github.com/OneNewLife)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://github.com/NickTikhonov
|
||||
[1]: https://education.github.com/experts
|
||||
[2]: https://github.com/NickTikhonov/sourcerer
|
||||
[3]: https://github.com/NickTikhonov/sourcefetch-guide
|
||||
[4]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/89e174ab6ec6e270938338b34905f75bb74dbede
|
||||
[5]: https://atom.io/docs/api/latest/TextEditor
|
||||
[6]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
|
||||
[7]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/aa3ec5585b0aa049393351a30be14590df09c29a
|
||||
[8]: https://www.wikipedia.com/en/Document_Object_Model
|
||||
[9]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/85992043e57c802ca71ff6e8a4f9c477fbfd13db
|
||||
[10]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/896d160dca711f4a53ff5b182018b39cf78d2774
|
||||
[11]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/039a1e1e976d029f7d6b061b4c0dac3eb4a3b5d2
|
||||
[12]: https://github.com/NickTikhonov/sourcefetch-tutorial/commit/aa9d0b5fc4811a70292869730e0f60ddf0bcf2aa
|
||||
[13]: https://github.com/NickTikhonov/sourcefetch-tutorial
|
||||
[14]: https://developers.google.com/web/fundamentals/getting-started/primers/promises
|
||||
[15]: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
|
||||
[16]: https://atom.io/
|
||||
[17]: https://en.wikipedia.org/wiki/%3F:
|
||||
[18]: https://atom.io/docs/api/v1.9.4/Panel
|
||||
[19]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
|
||||
[20]: https://en.wikipedia.org/wiki/Event-driven_programming
|
||||
[21]: https://atom.io/docs/api/v1.11.1/TextEditor
|
||||
[22]: https://www.npmjs.com/
|
||||
[23]: http://recurial.com/programming/understanding-callback-functions-in-javascript/
|
||||
[24]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
||||
[25]: https://atom.io/docs/api/v1.11.1/NotificationManager
|
||||
[26]: https://www.google.com/chrome/
|
||||
[27]: http://stackoverflow.com/questions/1077347/hello-world-in-python
|
||||
[28]: http://stackoverflow.com/questions/3463426/in-c-how-should-i-read-a-text-file-and-print-all-strings
|
||||
[29]: https://www.npmjs.com/package/cheerio
|
||||
[30]: https://github.com/cheeriojs/cheerio
|
||||
[31]: http://callbackhell.com/
|
@ -0,0 +1,42 @@
|
||||
CANONICAL 正考虑移除 Ubuntu 的 32 位支持
|
||||
========================================================
|
||||
|
||||
![](https://itsfoss.com/wp-content/uploads/2016/06/Ubuntu-32-bit-goes-for-a-toss-.jpg)
|
||||
|
||||
昨天(LCTT 译注:原文是 2016 年 07 月 01 日发布,这里的“昨天”就是 06 月 30 日),[Dimitri John Ledkov][1] 在 [Ubuntu 邮件列表][2] 发送了一则消息,即将在 Ubuntu 18.10 中取消 32 位支持。他说现在的多少软件都已经开发出了 64 位支持,并且为 32 位架构提供安全支持将变得更加困难。
|
||||
|
||||
Ledkov 同时表示,构建 32 位镜像并不免费,又会耗费 Canonical 不少的资源。
|
||||
Ledkov also argues that building i386 images is not free, but takes quite a bit of Canonical’s resources.
|
||||
|
||||
>Building i386 images is not “for free”, it comes at the cost of utilizing our build farm, QA and validation time. Whilst we have scalable build-farms, i386 still requires all packages, autopackage tests, and ISOs to be revalidated across our infrastructure. As well as take up mirror space & bandwidth.(以后将不会“免费”构建 32 位镜像,因为会耗费我们较多我们的构建资源、QA 和校验时间。尽管我我们有可扩展的构建条件,但 32 位支持还需要所有的包、对自动生成包校验和测试 ISO 在基础硬件上的兼容性。同时这还会占据大量的镜像空间和带宽。)
|
||||
|
||||
Ledkov 计划着,Ubuntu 16.10、17.04、17.10 还会继续提供 32 位内核、网络安装器和云镜像,但移除桌面版和服务器版的 32 位 ISO 镜像。18.04 LTS 将会移除 32 位内核、网络安装器和云镜像,但在 64 位架构中兼容运行 32 位程序。然后在 18.10 中结束 32 位支持,并将传统的 32 位应用现在在 snap、容器和虚拟机中。
|
||||
|
||||
但是,Ledkov 的这份计划还未被大家接受,但它表明了 32 位支持迟早要被遗弃。
|
||||
|
||||
### 好消息
|
||||
|
||||
当然,使用 32 位系统的用户也不必伤心。这个并不会英雄旧版 32 位系统的使用。[Ubuntu MATE][4] 的创建者 [Martin Wimpress][3] 在 Googl+ 的讨论中透露,这些改变这是影响着主线上的 Ubuntu 而已。
|
||||
|
||||
>The i386 archive will continue to exist into 18.04 and flavours can continue to elect to build i386 isos. There is however a security concern, in that some larger applications (Firefox, Chromium, LibreOffice) are already presenting challenges in terms of applying some security patches to older LTS releases. So flavours are being asked to be mindful of the support period they can reasonably be expected to support i386 versions for.(18.04 将继续存在 32 位架构支持,用户可以投票是否构建 32 位镜像。但还是会存在安全隐患,一些大体积应用,如 Firefox、Chromium、LibreOffice,在一些旧版的 LTS 中更新安全补丁早已问题突出。所以,需要用户投票决定一个合理的 32 位支持期限)
|
||||
|
||||
### 思考
|
||||
|
||||
从安全的角度,我可以理解他们为什么要移除 32 位支持,但是这可能会导致一部分人离开主线 Ubuntu 而投入另一个喜爱的发行版或者另一种架构的怀抱。值得庆幸的是,我们还可以选择 [轻量级 Linux 发行版][5].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/ubuntu-32-bit-support-drop/
|
||||
|
||||
作者:[John Paul][a]
|
||||
译者:[GHLandy](https://github.com/GHLandy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/john/
|
||||
[1]: https://plus.google.com/+DimitriJohnLedkov
|
||||
[2]: https://lists.ubuntu.com/archives/ubuntu-devel-discuss/2016-June/016661.html
|
||||
[3]: https://twitter.com/m_wimpress
|
||||
[4]: http://ubuntu-mate.org/
|
||||
[5]: https://itsfoss.com/lightweight-linux-beginners/
|
273
translated/tech/20160815 The cost of small modules.md
Normal file
273
translated/tech/20160815 The cost of small modules.md
Normal file
@ -0,0 +1,273 @@
|
||||
小模块的开销
|
||||
====
|
||||
|
||||
大约一年之前,我在将一个大型 JavaScript 代码库重构为小模块时发现了 Browserify 和 Webpack 中一个令人沮丧的事实:
|
||||
|
||||
> “代码越模块化,代码体积就越大。”- Nolan Lawson
|
||||
|
||||
过了一段时间,Sam Saccone 发布了一些关于 [Tumblr][1] 和 [Imgur][2] 页面加载性能的出色的研究。其中指出:
|
||||
|
||||
> “超过 400 ms 的时间单纯的花费在了遍历 Browserify 树上。”- Sam Saccone
|
||||
|
||||
在本篇文章中,我将演示小模块可能会根据你选择的打包器(bundler)和模块系统(module system)而出现高得惊人的性能开销。此外,我还将解释为什么这种方法不但影响你自己代码的模块,也会影响依赖项中的模块,这也正是第三方代码在性能开销上很少提及的方面。
|
||||
|
||||
### 网页性能(Web perf 101)
|
||||
|
||||
一个页面中包含的 JavaScript 脚本越多,页面加载也将越慢。庞大的 JavaScript 包会导致浏览器花费更多的时间去下载、解析和执行,这些都将加长载入时间。
|
||||
|
||||
即使当你使用如 Webpack [code splitting][3]、Browserify [factor bundles][4] 等工具将代码分解为多个包,时间的花费也仅仅是被延迟到页面生命周期的晚些时候。JavaScript 迟早都将有一笔开销。
|
||||
|
||||
此外,由于 JavaScript 是一门动态语言,同时流行的 [CommonJS][5] 模块也是动态的,所以这就使得在最终分发给用户的代码中剔除无用的代码变得异常困难。譬如你可能只使用到 jQuery 中的 $.ajax,但是通过载入 jQuery 包,你将以整个包为代价。
|
||||
|
||||
JavaScript 社区对这个问题提出的解决办法是提倡 [小模块][6] 的使用。小模块不仅有许多 [美好且实用的好处][7] 如易于维护,易于理解,易于集成等,而且还可以通过鼓励包含小巧的功能而不是庞大的库来解决之前提到的 jQuery 的问题。
|
||||
|
||||
所以在小模块下,你将不需要这样:
|
||||
|
||||
```
|
||||
var _ = require('lodash')
|
||||
_.uniq([1,2,2,3])
|
||||
```
|
||||
|
||||
而是可以如此:
|
||||
|
||||
```
|
||||
var uniq = require('lodash.uniq')
|
||||
uniq([1,2,2,3])
|
||||
```
|
||||
|
||||
### 包与模块
|
||||
|
||||
需要强调的是这里我提到的“模块”并不同于 npm 中的“包”的概念。当你从 npm 安装一个包时,它会将该模块通过公用 API 展现出来,但是在这之下其实是一个许多模块的聚合物。
|
||||
|
||||
例如,我们来看一个包 [is-array][8],它没有别的依赖,并且只包含 [一个 JavaScript 文件][9],所以它只有一个模块。这算是足够简单的。
|
||||
|
||||
现在来看一个稍微复杂一点的包,如 [once][10]。它有一个依赖的包 [wrappy][11]。[两][12] [个][13] 包都各自包含一个模块,所以总模块数为 2。至此,也还算好。
|
||||
|
||||
现在来一起看一个更为令人迷惑的例子:[qs][14]。因为它没有依赖的包,所以你可能就认为它只有一个模块,然而事实上,它有四个模块!
|
||||
|
||||
你可以用一个我写的工具 [browserify-count-modules][15] 来统计一个 Browserify 包的总模块数:
|
||||
|
||||
```
|
||||
$ npm install qs
|
||||
$ browserify node_modules/qs | browserify-count-modules
|
||||
4
|
||||
```
|
||||
|
||||
这说明了一个包可以包含一个或者多个模块。这些模块也可以依赖于其他的包,而这些包又将附带其自己所依赖的包与模块。由此可以确定的事就是任何一个包将包含至少一个模块。
|
||||
|
||||
### 模块膨胀
|
||||
|
||||
一个典型的网页应用中会包含多少个模块呢?我在一些流行的使用 Browserify 的网站上运行 browserify-count-moduleson 并且得到了以下结果:
|
||||
|
||||
* [requirebin.com][16]: 91 个模块
|
||||
* [keybase.io][17]: 365 个模块
|
||||
* [m.reddit.com][18]: 1050 个模块
|
||||
* [Apple.com][19]: 1060 个模块 (新增。 [感谢 Max!][20])
|
||||
|
||||
顺带一提,我写过的最大的开源站点 [Pokedex.org][21] 包含了 4 个包,共 311 个模块。
|
||||
|
||||
让我们先暂时忽略这些 JavaScript 包的实际大小,我认为去探索一下一定数量的模块本身开销会事一件有意思的事。虽然 Sam Saccone 的文章 [“2016 年 ES2015 转译的开销”][22] 已经广为流传,但是我认为他的结论还未到达足够深度,所以让我们挖掘的稍微再深一点吧。
|
||||
|
||||
### 测试环节!
|
||||
|
||||
我构造了一个能导入 100、1000 和 5000 个其他小模块的测试模块,其中每个小模块仅仅导出一个数字。而父模块则将这些数字求和并记录结果:
|
||||
|
||||
```
|
||||
// index.js
|
||||
var total = 0
|
||||
total += require('./module_0')
|
||||
total += require('./module_1')
|
||||
total += require('./module_2')
|
||||
// etc.
|
||||
console.log(total)
|
||||
|
||||
|
||||
// module_1.js
|
||||
module.exports = 1
|
||||
```
|
||||
|
||||
我测试了五种打包方法:Browserify, 带 [bundle-collapser][24] 插件的 Browserify, Webpack, Rollup 和 Closure Compiler。对于 Rollup 和 Closure Compiler 我使用了 ES6 模块,而对于 Browserify 和 Webpack 则用的 CommonJS,目的是为了不涉及其各自缺点而导致测试的不公平(由于它们可能需要做一些转译工作,如 Babel 一样,而这些工作将会增加其自身的运行时间)。
|
||||
|
||||
为了更好地模拟一个生产环境,我将带 -mangle 和 -compress 参数的 Uglify 用于所有的包,并且使用 gzip 压缩后通过 GitHub Pages 用 HTTPS 协议进行传输。对于每个包,我一共下载并执行 15 次,然后取其平均值,并使用 performance.now() 函数来记录载入时间(未使用缓存)与执行时间。
|
||||
|
||||
### 包大小
|
||||
|
||||
在我们查看测试结果之前,我们有必要先来看一眼我们要测试的包文件。一下是每个包最小处理后但并未使用 gzip 压缩时的体积大小(单位:Byte):
|
||||
|
||||
| | 100 个模块 | 1000 个模块 | 5000 个模块 |
|
||||
| --- | --- | --- | --- |
|
||||
| browserify | 7982 | 79987 | 419985 |
|
||||
| browserify-collapsed | 5786 | 57991 | 309982 |
|
||||
| webpack | 3954 | 39055 | 203052 |
|
||||
| rollup | 671 | 6971 | 38968 |
|
||||
| closure | 758 | 7958 | 43955 |
|
||||
|
||||
| | 100 个模块 | 1000 个模块 | 5000 个模块 |
|
||||
| --- | --- | --- | --- |
|
||||
| browserify | 1649 | 13800 | 64513 |
|
||||
| browserify-collapsed | 1464 | 11903 | 56335 |
|
||||
| webpack | 693 | 5027 | 26363 |
|
||||
| rollup | 300 | 2145 | 11510 |
|
||||
| closure | 302 | 2140 | 11789 |
|
||||
|
||||
Browserify 和 Webpack 的工作方式是隔离各个模块到各自的函数空间,然后声明一个全局载入器,并在每次 require() 函数调用时定位到正确的模块处。下面是我们的 Browserify 包的样子:
|
||||
|
||||
```
|
||||
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
|
||||
```
|
||||
|
||||
而 Rollup 和 Closure 包看上去则更像你亲手写的一个大模块。这是 Rollup 打包的包:
|
||||
|
||||
```
|
||||
(function () {
|
||||
'use strict';
|
||||
var total = 0
|
||||
total += 0
|
||||
total += 1
|
||||
total += 2
|
||||
// etc.
|
||||
```
|
||||
|
||||
如果你清楚在 JavaScript 中使用嵌套函数与在关联数组查找一个值的固有开销, 那么你将很容易理解出现以下测试的结果的原因。
|
||||
|
||||
### 测试结果
|
||||
|
||||
我选择在搭载 Android 5.1.1 与 Chrome 52 的 Nexus 5(代表中低端设备)和运行 iOS 9 的第 6 代 iPod Touch(代表高端设备)上进行测试。
|
||||
|
||||
这是 Nexus 5 下的测试结果([查看表格][26]):
|
||||
|
||||
[![Nexus 5 结果][27]](https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_5.png)
|
||||
|
||||
这是 iPod Touch 下的测试结果([查看表格][28]):
|
||||
|
||||
[![iPod Touch 结果][29]](https://nolanwlawson.files.wordpress.com/2016/08/modules_ipod.png)
|
||||
|
||||
在 100 个模块时,各包的差异是微不足道的,但是一旦模块数量达到 1000 个甚至 5000 个时,差异将会变得非常巨大。iPod Touch 在不同包上的差异并不明显,而对于具有一定年代的 Nexus 5 来说,Browserify 和 Webpack 明显耗时更多。
|
||||
|
||||
与此同时,我发现有意思的是 Rollup 和 Closure 的运行开销对于 iPod 而言几乎可以忽略,并且与模块的数量关系也不大。而对于 Nexus 5 来说,运行的开销并非完全可以忽略,但它们仍比 Browserify 或 Webpack 低很多。后者若未在几百毫秒内完成加载则将会占用主线程的好几帧的时间,这就意味着用户界面将冻结并且等待直到模块载入完成。
|
||||
|
||||
值得注意的是前面这些测试都是在千兆网速下进行的,所以在网络情况来看,这只是一个最理想的状况。借助 Chrome 开发者工具,我们可以认为地将 Nexus 5 的网速限制到 3G 水平,然后来看一眼这对测试产生的影响([查看表格][30]):
|
||||
|
||||
[![Nexus 5 3G 结果][31]](https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_53g.png)
|
||||
|
||||
一旦我们将网速考虑进来,Browserify/Webpack 和 Rollup/Closure 的差异将变得更为显著。在 1000 个模块规模(接近于 Reddit 1050 个模块的规模)时,Browserify 花费的时间比 Rollup 长大约 400 毫秒。然而 400 毫秒已经不是一个小数目了,正如 Google 和 Bing 指出的,亚秒级的延迟都会 [对用户的参与产生明显的影响][32] 。
|
||||
|
||||
还有一件事需要指出,那就是这个测试并非测量 100 个、1000 个或者 5000 个模块的每个模块的精确运行时间。因为这还与你对 require() 函数的使用有关。在这些包中,我采用的是对每个模块调用一次 require() 函数。但如果你每个模块调用了多次 require() 函数(这在代码库中非常常见)或者你多次动态调用 require() 函数(例如在子函数中调用 require() 函数),那么你将发现明显的性能退化。
|
||||
|
||||
Reddit 的移动站点就是一个很好的例子。虽然该站点有 1050 个模块,但是我测量了它们使用 Browserify 的实际执行时间后发现比“1000 个模块”的测试结果差好多。当使用那台运行 Chrome 的 Nexus 5 时,我测出 Reddit 的 Browserify require() 函数耗时 2.14 秒。而那个“1000 个模块”脚本中的等效函数只需要 197 毫秒(在搭载 i7 处理器的 Surface Book 上的桌面版 Chrome,我测出的结果分别为 559 毫秒与 37 毫秒,虽然给出桌面平台的结果有些令人惊讶)。
|
||||
|
||||
这结果提示我们有必要对每个模块使用多个 require() 函数的情况再进行一次测试。不过,我并不认为这对 Browserify 和 Webpack 会是一个公平的测试,因为 Rollup 和 Closure 都会将重复的 ES6 库导入处理为一个的顶级变量声明,同时也阻止了顶层空间以外的其他区域的导入。所以根本上来说,Rollup 和 Closure 中一个导入和多个导入的开销是相同的,而对于 Browserify 和 Webpack,运行开销随 require() 函数的数量线性增长。
|
||||
|
||||
为了我们这个分析的目的,我认为最好假设模块的数量是性能的短板。而事实上,“5000 个模块”也是一个比“5000 个 require() 函数调用”更好的度量标准。
|
||||
|
||||
### 结论
|
||||
|
||||
首先,bundle-collapser 对 Browserify 来说是一个非常有用的插件。如果你在产品中还没使用它,那么你的包将相对来说会略大且运行略慢(虽然我得承认这之间的差异非常小)。另一方面,你还可以转换到 Webpack 以获得更快的包而不需要额外的配置(其实我非常不愿意这么说,因为我是个顽固的 Browserify 粉)。
|
||||
|
||||
不管怎样,这些结果都明确地指出 Webpack 和 Browserify 相较 Rollup 和 Closure Compiler 而言表现都稍差,并且性能差异随着模块大小的增大而增大。不幸的是,我并不确定 [Webpack 2][33] 是否能解决这些问题,因为尽管他们将 [从 Rollup 中借鉴一些想法][34],但是看起来他们的关注点更多在于 [tree-shaking 方面][35] 而不是在于 scope-hoisting 方面。(更新:一个更好的名字称为内联(inlining),并且 Webpack 团队 [正在做这方面的工作][36]。)
|
||||
|
||||
给出这些结果之后,我对 Closure Compiler 和 Rollup 在 JavaScript 社区并没有得到过多关注而感到惊讶。我猜测或许是因为(前者)需要依赖 Java,而(后者)仍然相当不成熟并且未能做到开箱即用(详见 [Calvin’s Metcalf 的评论][37] 中作的不错的总结)。
|
||||
|
||||
即使没有足够数量的 JavaScript 开发者加入到 Rollup 或 Closure 的队伍中,我认为 npm 包作者们也已准备好了去帮助解决这些问题。如果你使用 npm 安装 lodash,你将会发其现主要的导入是一个巨大的 JavaScript 模块,而不是你期望的 Lodash 的超模块(hyper-modular)特性(require('lodash/uniq'),require('lodash.uniq') 等等)。对于 PouchDB,我们做了一个类似的声明以 [使用 Rollup 作为预发布步骤][38],这将产生对于用户而言尽可能小的包。
|
||||
|
||||
同时,我创建了 [rollupify][39] 来尝试将这过程变得更为简单一些,只需拖动到已存在的 Browserify 工程中即可。其基本思想是在你自己的项目中使用导入(import)和导出(export)(可以使用 [cjs-to-es6][40] 来帮助迁移),然后使用 require() 函数来载入第三方包。这样一来,你依旧可以在你自己的代码库中享受所有模块化的优点,同时能导出一个适当大小的大模块来发布给你的用户。不幸的是,你依旧得为第三方库付出一些代价,但是我发现这是对于当前 npm 生态系统的一个很好的折中方案。
|
||||
|
||||
所以结论如下:一个大的 JavaScript 包比一百个小 JavaScript 模块要快。尽管这是事实,我依旧希望我们社区能最终发现我们所处的困境————提倡小模块的原则对开发者有利,但是对用户不利。同时希望能优化我们的工具,使得我们可以对两方面都有利。
|
||||
|
||||
### 福利时间!三款桌面浏览器
|
||||
|
||||
通常来说我喜欢在移动设备上运行性能测试,因为在这里我们能更清楚的看到差异。但是出于好奇,我也分别在一台搭载 i7 的 Surface Book 上的 Chrome 52、Edge 14 和 Firefox 48 上运行了测试。这分别是它们的测试结果:
|
||||
|
||||
Chrome 52 ([查看表格][41])
|
||||
|
||||
[![Chrome 结果][42]](https://nolanwlawson.files.wordpress.com/2016/08/modules_chrome.png)
|
||||
|
||||
Edge 14 ([查看表格][43])
|
||||
|
||||
[![Edge 结果][44]](https://nolanwlawson.files.wordpress.com/2016/08/modules_edge.png)
|
||||
|
||||
Firefox 48 ([查看表格][45])
|
||||
|
||||
[![Firefox 结果][46]](https://nolanwlawson.files.wordpress.com/2016/08/modules_firefox.png)
|
||||
|
||||
我在这些结果中发现的有趣的地方如下:
|
||||
|
||||
1. bundle-collapser 总是与 slam-dunk 完全不同。
|
||||
2. Rollup 和 Closure 的下载时间与运行时间之比总是非常高,它们的运行时间基本上微不足道。ChakraCore 和 SpiderMonkey 运行最快,V8 紧随其后。
|
||||
|
||||
如果你的 JavaScript 非常大并且是延迟加载,那么第二点将非常重要。因为如果你可以接受等待网络下载的时间,那么使用 Rollup 和 Closure 将会有避免界面线程冻结的优点。也就是说,它们将比 Browserify 和 Webpack 更少出现界面阻塞。
|
||||
|
||||
更新:在这篇文章的回应中,JDD 已经 [给 Webpack 提交了一个 issue][47]。还有 [一个是给 Browserify 的][48]。
|
||||
|
||||
更新 2:[Ryan Fitzer][49] 慷慨地增加了 RequireJS 和包含 [Almond][50] 的 RequireJS 的测试结果,两者都是使用 AMD 而不是 CommonJS 或者 ES6。
|
||||
|
||||
测试结果表明 RequireJS 具有 [最大的包大小][51] 但是令人惊讶的是它的运行开销 [与 Rollup 和 Closure 非常接近][52]。这是在运行 Chrome 52 的 Nexus 5 下限制网速为 3G 的测试结果:
|
||||
|
||||
[![Nexus 5 (3G) RequireJS 结果][53]](https://nolanwlawson.files.wordpress.com/2016/08/2016-08-20-14_45_29-small_modules3-xlsx-excel.png)
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://nolanlawson.com/2016/08/15/the-cost-of-small-modules/?utm_source=javascriptweekly&utm_medium=email
|
||||
|
||||
作者:[Nolan][a]
|
||||
译者:[Yinr](https://github.com/Yinr)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://nolanlawson.com/
|
||||
[1]: https://docs.google.com/document/d/1E2w0UQ4RhId5cMYsDcdcNwsgL0gP_S6SDv27yi1mCEY/edit
|
||||
[2]: https://github.com/perfs/audits/issues/1
|
||||
[3]: https://webpack.github.io/docs/code-splitting.html
|
||||
[4]: https://github.com/substack/factor-bundle
|
||||
[5]: http://www.commonjs.org/
|
||||
[6]: http://substack.net/how_I_write_modules
|
||||
[7]: http://dailyjs.com/2015/07/02/small-modules-complexity-over-size/
|
||||
[8]: https://www.npmjs.com/package/is-array
|
||||
[9]: https://github.com/retrofox/is-array/blob/d79f1c90c824416b60517c04f0568b5cd3f8271d/index.js#L6-L33
|
||||
[10]: https://www.npmjs.com/package/once
|
||||
[11]: https://www.npmjs.com/package/wrappy
|
||||
[12]: https://github.com/isaacs/once/blob/2ad558657e17fafd24803217ba854762842e4178/once.js#L1-L21
|
||||
[13]: https://github.com/npm/wrappy/blob/71d91b6dc5bdeac37e218c2cf03f9ab55b60d214/wrappy.js#L6-L33
|
||||
[14]: https://www.npmjs.com/package/qs
|
||||
[15]: https://www.npmjs.com/package/browserify-count-modules
|
||||
[16]: http://requirebin.com/
|
||||
[17]: https://keybase.io/
|
||||
[18]: http://m.reddit.com/
|
||||
[19]: http://images.apple.com/ipad-air-2/
|
||||
[20]: https://twitter.com/denormalize/status/765300194078437376
|
||||
[21]: https://pokedex.org/
|
||||
[22]: https://github.com/samccone/The-cost-of-transpiling-es2015-in-2016#the-cost-of-transpiling-es2015-in-2016
|
||||
[23]: https://github.com/nolanlawson/cost-of-small-modules
|
||||
[24]: https://www.npmjs.com/package/bundle-collapser
|
||||
[25]: https://nolanwlawson.files.wordpress.com/2016/08/min.png
|
||||
[26]: https://gist.github.com/nolanlawson/e84ad060a20f0cb7a7c32308b6b46abe
|
||||
[27]: https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_5.png?w=570&h=834
|
||||
[28]: https://gist.github.com/nolanlawson/45ed2c7fa53da035dfc1e153763b9f93
|
||||
[29]: https://nolanwlawson.files.wordpress.com/2016/08/modules_ipod.png?w=570&h=827
|
||||
[30]: https://gist.github.com/nolanlawson/6269d304c970174c21164288808392ea
|
||||
[31]: https://nolanwlawson.files.wordpress.com/2016/08/modules_nexus_53g.png?w=570&h=834
|
||||
[32]: http://radar.oreilly.com/2009/06/bing-and-google-agree-slow-pag.html
|
||||
[33]: https://gist.github.com/sokra/27b24881210b56bbaff7
|
||||
[34]: http://www.2ality.com/2015/12/webpack-tree-shaking.html
|
||||
[35]: http://www.2ality.com/2015/12/bundling-modules-future.html
|
||||
[36]: https://github.com/webpack/webpack/issues/2873#issuecomment-240067865
|
||||
[37]: https://github.com/rollup/rollup/issues/552
|
||||
[38]: http://pouchdb.com/2016/01/13/pouchdb-5.2.0-a-better-build-system-with-rollup.html
|
||||
[39]: https://github.com/nolanlawson/rollupify
|
||||
[40]: https://github.com/nolanlawson/cjs-to-es6
|
||||
[41]: https://gist.github.com/nolanlawson/4f79258dc05bbd2c14b85cf2196c6ef0
|
||||
[42]: https://nolanwlawson.files.wordpress.com/2016/08/modules_chrome.png?w=570&h=831
|
||||
[43]: https://gist.github.com/nolanlawson/726fa47e0723b45e4ee9ecf0cf2fcddb
|
||||
[44]: https://nolanwlawson.files.wordpress.com/2016/08/modules_edge.png?w=570&h=827
|
||||
[45]: https://gist.github.com/nolanlawson/7eed17e6ffa18752bf99a9d4bff2941f
|
||||
[46]: https://nolanwlawson.files.wordpress.com/2016/08/modules_firefox.png?w=570&h=830
|
||||
[47]: https://github.com/webpack/webpack/issues/2873
|
||||
[48]: https://github.com/substack/node-browserify/issues/1379
|
||||
[49]: https://github.com/nolanlawson/cost-of-small-modules/pull/5
|
||||
[50]: https://github.com/requirejs/almond
|
||||
[51]: https://gist.github.com/nolanlawson/511e0ce09fed29fed040bb8673777ec5
|
||||
[52]: https://gist.github.com/nolanlawson/4e725df00cd1bc9673b25ef72b831c8b
|
||||
[53]: https://nolanwlawson.files.wordpress.com/2016/08/2016-08-20-14_45_29-small_modules3-xlsx-excel.png?w=570&h=829
|
@ -0,0 +1,140 @@
|
||||
Antergos – 初学者基于 Arch 的最好发行版,想要尝试 Arch 的绝对值得一试
|
||||
=====
|
||||
|
||||
众所周知,Arch Linux 是最好的 Linux 发行版之一,我们可以随心所欲的进行定制。我们可以滚动式更新最新的软件,但安装和配置的过程对于初学者则相对困难。现在就让我来为你展示如何安装 Antergos——初学者基于 Arch最好的发行版,要尝试 Arch 的用户可以试一试,我保证绝对值得一试。
|
||||
|
||||
Antergos 是一个滚动式更新的发行版,基于 Arch Linux 提供桌面环境,集现代化、高雅和高效率于一体的操作系统。想要挑战一下安装 Arch Linux 的用户,都可以先试一试 Antergos。
|
||||
|
||||
由于是滚动式更新,当上游发布更新,你的整个系统 (包括系统组件和你已安装的应用) 就会升级到最新的滚动版本,延期一段时间在更新可以确保系统的稳定。
|
||||
|
||||
Antergos 有多个语言版本,包括英语、西班牙语等版本,在安装是你可以在语言栏选择预置语言。默认的配置确保了开箱即用,不需要安装额外的软件就可以直接浏览网页、听音乐、看视频以及做任何你想做的事情。
|
||||
|
||||
Antergos 项目最初以 Cinnarch 名义,并且只提供一个桌面环境。现在它有多个桌面环境(包括Cinnamon、Gnome、KDE、MATE、Openbox 和 Xfce)以供用户在安装之时进行选择。同时,它还默认包含了著名的Numix GTK 主题和 Icon 主题。
|
||||
|
||||
#### 下载 Antergos Linux
|
||||
|
||||
访问 [Antergos][1] 下载页面,然后下载最新的 Live ISO 镜像。任何人都可以免费获取 Antergos 镜像,烧录到 CD/DVD 或者写到 USB 设备,开始 Antergos 之旅。
|
||||
|
||||
#### 创建可启动 USB
|
||||
|
||||
现在好最新的 Antergos Live ISO 镜像之后,你需要使用命令行或者图形界面的方法来制作一个可启动媒介。
|
||||
|
||||
#### 使用 Antergos 安装媒介启动电脑
|
||||
|
||||
使用 Antergos 安装媒介来启动电脑。成功启动到 Live ISO 之后,你会看到与下图相似的界面。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-1.png)
|
||||
|
||||
点击 `Install It(立即安装)` 按钮开始 Angergos 的安装进程。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-2.png)
|
||||
|
||||
#### 选择语系
|
||||
|
||||
Antergos 的易用性图形安装器非常的好用。此处选择你需要选用的语系并点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-3.png)
|
||||
|
||||
#### 系统检测
|
||||
|
||||
请确保你有足够的磁盘空间,连接好电源以及连接到网络,点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-4.png)
|
||||
|
||||
#### 选择位置
|
||||
|
||||
选择位置可以帮助决定系统使用 locale。通常是选择你所属的国家即可。这里有一个基于你选择的位置短列表。点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-5.png)
|
||||
|
||||
#### 选择时区
|
||||
|
||||
选择使用的时区,然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-6.png)
|
||||
|
||||
#### 选择键盘布局
|
||||
|
||||
选择你选用的键盘布局,然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-7.png)
|
||||
|
||||
#### 选择桌面环境
|
||||
|
||||
Antergos 通过了多个选择(包括Cinnamon、Gnome、KDE、MATE、Openbox 和 Xfce),根据你的喜好进行选择即可。然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-8.png)
|
||||
|
||||
#### Gnome – 特性选择
|
||||
|
||||
这里我选择了默认的 Gnome 桌面环境,此处你可以选择需要额外安装的软件以及要安装系统的驱动器。然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-10.png)
|
||||
|
||||
#### 安装类型
|
||||
|
||||
初次安装可以选择第一个选项。然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-11.png)
|
||||
|
||||
#### 自动安装模式
|
||||
|
||||
这里会有一个檫除硬盘的警告,并选择安装 `Grub` 启动器,然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
>WARNING ! This will overwrite everything currently on your drive !
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-12.png)
|
||||
|
||||
#### 安装设置综述
|
||||
|
||||
确认最后的安装设置概览,如位置、时区、键盘布局、桌面环境和特性,然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-14.png)
|
||||
|
||||
#### 创建你的用户名
|
||||
|
||||
此时需要为你的系统创建一个新用户名和对应的密码,然后点击 `Next` 按钮继续下一步。
|
||||
|
||||
- 你的昵称
|
||||
- 电脑名称
|
||||
- 用户名
|
||||
- 设置密码
|
||||
- 密码二次确认
|
||||
- 选择“需要密码登录系统”
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-15.png)
|
||||
|
||||
#### 安装进程
|
||||
|
||||
此时就是等待 Antergos 安装完成。安装好之后,移除安装介质在点击“立刻重启”按钮。
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-16.png)
|
||||
|
||||
#### 输入用户名和密码
|
||||
|
||||
这是欢迎界面,输入密码即可登录:
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-17.png)
|
||||
|
||||
发行信息截图:
|
||||
|
||||
![](http://www.2daygeek.com/wp-content/uploads/2016/08/antergos-linux-gnome-desktop-installation-steps-with-screenshots-18.png)
|
||||
|
||||
我们还会提供了一些列循序渐进的 Linux 系统管理的相关文章。如果本文对你有用,请花费几分钟分享你得想法到评论区。
|
||||
|
||||
请于我们保持联系,祝君好运!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.2daygeek.com/how-to-install-antergos-linux/
|
||||
|
||||
作者:[MAGESH MARUTHAMUTHU][a]
|
||||
|
||||
译者:[GHLandy](https://github.com/GHLandy)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.2daygeek.com/author/magesh/
|
||||
[1]: https://antergos.com/try-it/
|
Loading…
Reference in New Issue
Block a user