nodejs命令行執行程序_在NodeJS中編寫命令行應用程序

nodejs命令行執行程序

by Peter Benjamin

彼得·本杰明(Peter Benjamin)

在NodeJS中編寫命令行應用程序 (Writing Command-Line Applications in NodeJS)

With the right packages, writing command-line apps in NodeJS is a breeze.

有了合適的軟件包,用NodeJS編寫命令行應用程序變得輕而易舉。

One package in particular makes it extremely easy: Commander.

一個軟件包特別容易: Commander

Let’s set the stage and walk-through how to write a command-line interface (CLI) app in NodeJS with Commander. Our goal will be to write a CLI app to list files and directories.

讓我們設置階段并逐步講解如何使用Commander在NodeJS中編寫命令行界面(CLI)應用程序。 我們的目標是編寫一個CLI應用程序以列出文件和目錄。

建立 (Setup)

IDEsI love online IDEs. They abstract away a lot of headaches when it comes to dev environment setup. I personally use Cloud9 for the following reasons:

IDE我喜歡在線IDE。 在開發環境設置方面,他們消除了很多麻煩。 我個人出于以下原因使用Cloud9 :

  • The layout is intuitive

    布局直觀
  • The editor is beautiful and easy-to-use

    該編輯器美觀且易于使用
  • Free-tier resources have recently been increased to 1GB RAM and 5GB disk space, which is more than plenty for a decent-sized NodeJS application.

    自由層資源最近已增加到1GB RAM和5GB磁盤空間,對于像樣的NodeJS應用程序來說已經足夠了。
  • Unlimited number of workstations

    工作站數量不限
  • It’s a perfect environment to test or experiment with new projects/ideas without fear of breaking your environment

    這是測試或試驗新項目/想法的理想環境,而不必擔心破壞您的環境

Node/NPM VersionAt the time of writing this article, Node is at version 5.3.0 and NPM is ad version 3.3.12.

節點/ NPM版本在撰寫本文時,Node的版本為5.3.0,NPM的廣告版本為3.3.12。

初始化 (Initialization)

We start by initializing our project, accept all the NPM defaults, and installing the commander package:

我們首先初始化項目,接受所有NPM默認值,然后安裝commander軟件包:

npm initnpm i --save commander

Resulting in:

導致:

Note:

注意:

  • You will have to add bin manually, which tells NodeJS what your CLI app is called and what is the entry point to your app.

    您將必須手動添加bin ,這將告訴NodeJS您的CLI應用程序是什么以及應用程序的入口點是什么。

  • Make sure you do not use a command name that already exists in your system.

    確保您不使用系統中已經存在的命令名稱。

Index.js (Index.js)

Now that we’ve initialized our project and indicated that our entry point is index.js, let’s create index.js:

現在我們已經初始化了項目,并指出我們的入口點是index.js,讓我們創建index.js:

touch index.js

Now, for the actual coding part:

現在,對于實際的編碼部分:

Typically, when executing NodeJS files, we tell the system to use the appropriate interpreter by prefixing node before the file. However, we want to be able to execute our CLI app globally from anywhere in the system, and without having to specify the node interpreter every time.

通常,在執行NodeJS文件時,我們通過在文件之前添加節點前綴來告訴系統使用適當的解釋器。 但是,我們希望能夠從系統中的任何位置全局執行CLI應用程序,而不必每次都指定節點解釋器。

Therefore, our first line is the shebang expression:

因此,我們的第一行是shebang表達式:

#!/usr/bin/env node

This not only tells our system to use the appropriate interpreter, but it also tells our system to use the appropriate version of the interpreter.

這不僅告訴我們的系統使用適當的解釋器,而且還告訴我們的系統使用適當的解釋器版本

From here on out, we write pure JavaScript code.Since I’ll be writing ES6-compliant code, I’ll start with the literal expression:

從現在開始,我們將編寫純JavaScript代碼。由于我將編寫符合ES6的代碼,因此將從文字表達式開始:

'use strict';

This tells the compiler to use a stricter variant of javascript [1] and enables us to write ES6 code on Cloud9.

這告訴編譯器使用javascript [ 1 ]的更嚴格的變體,并使我們能夠在Cloud9上編寫ES6代碼。

Let’s start by requiring the commander package:

讓我們從要求commander包開始:

const program = require('commander');

Now, writing CLI apps with commander is simple, and the documentation is great, but I struggled with a few concepts that I will attempt to clear up here.

現在,使用Commander編寫CLI應用程序是 很簡單,文檔也很棒,但是我在嘗試一些概念時遇到了麻煩,在這里我將嘗試加以澄清。

There seems to be 2 designs for CLI apps. Take ls and git for example.

CLI應用程序似乎有2種設計。 以lsgit為例。

With ls, you pass one or more flags:

使用ls ,您傳遞一個或多個標志:

  • ls -l

    ls -l

  • ls -al

    ls -al

With git, you pass sub-commands, but you also have some flags:

使用git ,您可以傳遞子命令,但也有一些標志:

  • git commit -am <message>

    git commit -am <messa ge>

  • git remote add origin <repo-url>

    git remote add origin <repo-u rl>

We will explore the flexibility Commander gives us to design both types of command-line interfaces.

我們將探索Commander給我們設計兩種命令行界面的靈活性。

指揮官API (Commander API)

The Commander API is straight forward and the documentation is great.

Commander API非常簡單,文檔也很棒。

There are 3 basic ways we can write our program:

我們可以通過3種基本方法來編寫程序:

METHOD #1: Flag-only command-line application

方法1:僅標志命令行應用程序

const program = require('commander');
program  .version('0.0.1')  .option('-o, --option','option description')  .option('-m, --more','we can have as many options as we want')  .option('-i, --input [optional]','optional user input')  .option('-I, --another-input <required>','required user input')  .parse(process.argv); // end with parse to parse through the input

Note:

注意:

  • The short-hand and long-hand options are in the same string (see the bold text in the image above)

    簡寫和長寫選項都在同一字符串中(請參見上圖中的粗體文本)
  • -o and -m will return boolean values when users pass them because we didn’t specify any optional or required user input.

    當用戶傳遞它們時, -o-m將返回布爾值,因為我們沒有指定任何可選必需的用戶輸入。

  • -i and -I will capture user input and pass the values to our CLI app.

    -i-I將捕獲用戶輸入并將值傳遞到我們的CLI應用程序。

  • Any value enclosed in square brackets (e.g. [ ] ) is considered optional. User may or may not provide a value.

    方括號內的任何值(例如[])均視為可選值。 用戶可能會或可能不會提供值。
  • Any value enclosed in angled brackets (e.g. < > ) is considered required. User must provide a value.

    包含在尖括號中的任何值(例如<>)都被認為是必需的。 用戶必須提供一個值。

The example above allows us to implement a flag-only approach to our CLI app. Users will be expected to interact with our app like so:

上面的示例使我們可以對CLI應用程序實施僅標志方法。 預計用戶將與我們的應用程序交互,如下所示:

//Examples:$ cli-app -om -I hello$ cli-app --option -i optionalValue -I requiredValue

METHOD #2: Sub-command and flag-based command-line application

方法2:子命令和基于標志的命令行應用程序

const program = require('commander');
program  .version('0.0.1')  .command('command <req> [optional]')  .description('command description')  .option('-o, --option','we can still have add'l options')  .action(function(req,optional){    console.log('.action() allows us to implement the command');    console.log('User passed %s', req);    if (optional) {      optional.forEach(function(opt){        console.log("User passed optional arguments: %s", opt);      });    }  });
program.parse(process.argv); // notice that we have to parse in a new statement.

Note:

注意:

  • If we utilize .command(‘command…’).description(‘description…’), we must utilize .action() to pass a function and execute our code based on the user’s input. (I point this out because there is an alternative method to utilize .command() that we’ll explore next.)

    如果我們使用.command('command ...')。description('description ...') ,則必須利用.action()傳遞函數并根據用戶輸入執行代碼。 (我指出這一點是因為我們接下來將探討利用.command()的另一種方法。)

  • If we utilize .command(‘command…’), we can no longer just tack on .parse(process.argv) at the end like we did in the previous example. We have to pass parse() in a new statement

    如果我們使用.command('command ...') ,那么我們將不再像前面的示例那樣最后僅附加.parse(process.argv) 。 我們必須在新語句中傳遞parse()

Users are expected to interact with our CLI app like so:

希望用戶與我們的CLI應用程序進行交互,如下所示:

//Example: $ cli-app command requiredValue -o

METHOD #3: Same as METHOD #2 above, but allows for modularized code

方法3:與上述方法2相同,但允許使用模塊化代碼

Finally, we don’t have to bloat our one JavaScript file with all the .command().description().action() logic. We can modularize our CLI project like so:

最后,我們不必使用所有.command()。description()。action()邏輯來膨脹一個JavaScript文件。 我們可以像這樣對CLI項目進行模塊化:

// file: ./cli-app/index.jsconst program = require('commander');
program.version('0.0.1').command('command <req> [optional]','command description').command('command2','command2 description').command('command3','command3 description').parse(process.argv);

Note:

注意:

  • If we utilize .command(‘command’, ‘description’) to pass in the command and the description, we can no longer have .action(). Commander will imply that we have separate files with a specific naming convention where we can handle each command. The naming convention is index-command.js, index-command2.js, index-command3.js. See examples of this on Github (specifically: pm, pm-install, pm-publish files).

    如果我們利用.command('command','description')傳遞命令和描述,我們將不再擁有.action()。 Commander表示我們有單獨的文件,具有特定的命名約定,可以在其中處理每個命令。 命名約定為index-command.jsindex-command2.jsindex-command3.js 。 在Github上查看此示例 (具體是: pmpm-installpm-publish文件)。

  • If we take this route, we can just tack on .parse() at the end.

    如果采用這種方式,則只需在最后添加.parse()即可

回到我們的項目場景… (Back to our project scenario…)

Now that we’ve covered the basics, it’s all downhill from here. We can take a deep breath.

既然我們已經介紹了基礎知識,那么一切都從這里開始。 我們可以深吸一口氣。

*** SIGH ***

*** SIGH ***

All right, now the fun begins.

好吧,現在開始樂趣了。

If we recall our project scenario, we want to write a CLI app to list files and directories. So let’s start writing the code.

如果我們回想起我們的項目場景,我們想編寫一個CLI應用程序以列出文件和目錄。 因此,讓我們開始編寫代碼。

We want to give the user the ability to decide if they want to see “all” files (including hidden ones) and/or if they want to see the long listing format (including the rights/permissions of the files/folders).

我們希望使用戶能夠決定是否要查看“所有”文件(包括隱藏文件)和/或是否要查看長列表格式(包括文件/文件夾的權限/許可)。

So, we start by writing the basic shell of our program to see our incremental progress (we will follow signature of Method #2 for the sake of the demo) :

因此,我們首先編寫程序的基本外殼以查看增量進度(為了演示,我們將遵循方法2的簽名):

#!/usr/bin/env node'use strict';
const program = require('commander');
program  .version('')  .command('')  .description('')  .option('','')  .option('','')  .action('');
program.parse(process.argv);

Let’s start filling the blanks:

讓我們開始填補空白:

#!/usr/bin/env node'use strict';
const program = require('commander');
program  .version('0.0.1')  .command('list [directory]')  .description('List files and folders')  .option('-a, --all','List all files and folders')  .option('-l, --long','')  .action();
program.parse(process.argv);

Note:

注意:

  • We decided to name our command list.

    我們決定命名命令列表

  • Directory argument is optional, so user can simply ignore to pass a directory, in which case we will list files/folders in current directory.

    目錄 參數是可選的,因此用戶可以忽略傳遞目錄,在這種情況下,我們將在當前目錄中列出文件/文件夾。

So, in our scenario, the following calls are valid:

因此,在我們的方案中,以下調用是有效的:

$ cli-app list $ cli-app list -al$ cli-app list --all$ cli-app list --long$ cli-app list /home/user -al

Now, let’s start writing code for our .action().

現在,讓我們開始為.action()編寫代碼。

#!/usr/bin/env node'use strict';
const program = require('commander');
let listFunction = (directory,options) => {  //some code here}
program  .version('0.0.1')  ...  .action(listFunction);
program.parse(process.argv);

We are going to cheat here by using the built-in ls command that’s available in all unix-like operating systems.

我們將使用所有類unix操作系統中可用的內置ls命令來作弊。

#!/usr/bin/env node'use strict';
const program = require('commander'),      exec = require('child_process').exec;
let listFunction = (directory,options) => {const cmd = 'ls';let params = [];if (options.all) params.push('a');if (options.long) params.push('l');let fullCommand = params.length                   ? cmd + ' -' + params.join('')                  : cmdif (directory) fullCommand += ' ' + directory;
};
program  .version('0.0.1')  ...  .action(listFunction);
program.parse(process.argv);

Let’s talk reason about this code.

讓我們談談這段代碼的原因。

  1. First, we require the child_process library to execute shell commands* (*this opens up a big security risk that I will discuss later)

    首先,我們要求child_process庫執行shell命令* ( * 這帶來了很大的安全風險,我將在后面討論 )

  2. We declare a constant variable that holds the root of our command

    我們聲明一個常量變量,該變量保存命令的根
  3. We declare an array that will hold any parameters passed by the user (e.g. -a, -l)

    我們聲明一個數組,該數組將保存用戶傳遞的所有參數(例如-a-l )

  4. We check to see whether the user passed short-hand (-a) or long-hand ( — all) flags. If so, then options.all and/or options.long will evaluate to true, in which case we will push the respective command flag to our array. Our goal is to build the shell command that we will pass later to child_process.

    我們檢查用戶是否通過了短手( -a )或長手(— all )標志。 如果是這樣,則options.all和/或options.long的評估結果為true ,在這種情況下,我們會將相應的命令標志壓入數組。 我們的目標是構建將在以后傳遞給child_process的shell命令。

  5. We declare a new variable to hold the full shell command. If the param array contains any flags, we concatenate the flags to each other and to the root command. Otherwise, if param array is empty, then we use the root command as is.

    我們聲明一個新變量來保存完整的shell命令。 如果param數組包含任何標志,我們將這些標志相互連接并與root命令連接。 否則,如果param數組為空,則按原樣使用root命令。
  6. Finally, we check if user passed any optional directory values. If so, we concatenate it to the fully constructed command.

    最后,我們檢查用戶是否傳遞了任何可選的目錄值。 如果是這樣,我們將其連接到完全構造的命令。

Now, we want to execute the fully constructed command in the shell. Child_Process.exec() gives us the ability to do so and NodeJS docs give us the signature:

現在,我們要在shell中執行完全構造的命令。 Child_Process.exec()使我們能夠這樣做,而NodeJS文檔給我們簽名:

child_process.exec(command, callback(error, stdout, stderr){  //"error" will be returned if exec encountered an error.  //"stdout" will be returned if exec is successful and data is returned.  //"stderr" will be returned if the shell command encountered an error.})

So, let’s use this:

所以,讓我們使用這個:

#!/usr/bin/env node'use strict';
const program = require('commander'),      exec = require('child_process').exec;
let listFunction = (directory,options) => {  const cmd = 'ls';  let params = [];  if (options.all) params.push('a');  if (options.long) params.push('l');  let fullCommand = params.length                   ? cmd + ' -' + params.join('')                  : cmd  if (directory) fullCommand += ' ' + directory;
let execCallback = (error, stdout, stderr) => {    if (error) console.log("exec error: " + error);    if (stdout) console.log("Result: " + stdout);    if (stderr) console.log("shell error: " + stderr);  };
exec(fullCommand, execCallback);
};
program  .version('0.0.1')  ...  .action(listFunction);
program.parse(process.argv);

That’s it!

而已!

Here is the gist of my sample CLI app.

這是我的示例CLI應用程序的要點 。

Of course, we can add a few niceties, like:

當然,我們可以添加一些細節,例如:

  • Coloring the output (I use the chalk library below)

    著色輸出(我使用下面的粉筆庫)

  • Modern CLI apps are smart enough to show the help text when a user calls the program with no parameters or arguments (much like git), so I added that functionality at the very bottom.

    現代的CLI應用程序足夠聰明,可以在用戶不帶任何參數或參數(類似于git )的情況下調用該程序時顯示幫助文本,因此我在最底部添加了該功能。

#!/usr/bin/env node'use strict';/** * Require dependencies * */const program = require('commander'),    chalk = require("chalk"),    exec = require('child_process').exec,    pkg = require('./package.json');/** * list function definition * */let list = (directory,options)  => {    const cmd = 'ls';    let params = [];        if (options.all) params.push("a");    if (options.long) params.push("l");    let parameterizedCommand = params.length                                 ? cmd + ' -' + params.join('')                                 : cmd ;    if (directory) parameterizedCommand += ' ' + directory ;        let output = (error, stdout, stderr) => {        if (error) console.log(chalk.red.bold.underline("exec error:") + error);        if (stdout) console.log(chalk.green.bold.underline("Result:") + stdout);        if (stderr) console.log(chalk.red("Error: ") + stderr);    };        exec(parameterizedCommand,output);    };program    .version(pkg.version)    .command('list [directory]')    .option('-a, --all', 'List all')    .option('-l, --long','Long list format')    .action(list);program.parse(process.argv);// if program was called with no arguments, show help.if (program.args.length === 0) program.help();

Finally, we can take advantage of NPM to symbolic link our CLI application so we can use it globally in our system. Simply, in the terminal, cd into the root of our CLI app and type:

最后,我們可以利用NPM來符號鏈接CLI應用程序,以便可以在系統中全局使用它。 只需在終端中,將cd插入我們的CLI應用程序的根目錄,然后鍵入:

npm link

最后的想法和考慮 (Final thoughts & Considerations)

The code in this project is by no means the best code. I am fully aware that there is always room for improvement, so feedback is welcome!

這個項目中的代碼絕不是最好的代碼。 我完全意識到,總會有改進的余地,因此歡迎反饋!

Also, I want to point out a security flaw in our app. Our code does not sanitize or validate the users’ input. This violates security best practices. Consider the following scenarios where users can pass un-desired input:

另外,我想指出我們應用程序中的安全漏洞。 我們的代碼不清除驗證用戶的輸入。 這違反了安全性最佳做法。 請考慮以下情況,用戶可以傳遞不需要的輸入:

$ cli-app -al ; rm -rf /$ cli-app -al ; :(){ :|: & };:

If you want to write some code that handles this issue, or fixes any other potential issues, be sure to show us your code by leaving a comment.

如果您想編寫一些處理此問題的代碼,或者解決任何其他潛在問題,請確保通過評論向我們展示您的代碼。

翻譯自: https://www.freecodecamp.org/news/writing-command-line-applications-in-nodejs-2cf8327eee2/

nodejs命令行執行程序

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/396430.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/396430.shtml
英文地址,請注明出處:http://en.pswp.cn/news/396430.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

python re findall 效率_python re模塊findall()詳解

今天寫代碼&#xff0c;在寫到鄭澤的時候遇到了一個坑&#xff0c;這個坑是re模塊下的findall()函數。下面我將結合代碼&#xff0c;記錄一下importrestring"abcdefg acbdgef abcdgfe cadbgfe"#帶括號與不帶括號的區別#不帶括號regexre.compile("((\w)\s\w)&quo…

ubuntu16.04配置sonarqube+MySQL

環境&#xff1a;rootubuntu:~# uname -a Linux ubuntu 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux rootubuntu:~# rootubuntu:~# cat /etc/issue Ubuntu 16.04 LTS \n \lrootubuntu:~#安裝配置mysql&#xff1a;1、更新源…

mysql 多表混全_mysql--淺談多表查詢1

這是對自己學習燕十八老師mysql教程的總結&#xff0c;非常感謝燕十八老師。依賴軟件&#xff1a;mysql5.6系統環境&#xff1a;win連接查詢在談連接查詢之前我們需要對數學上的笛卡爾積有一定的了解現在有兩個集合m和nm (m1,m2,.....mx)n (n1,n2,.....ny)m*n得到的笛卡爾積有…

鼠標固定在屏幕中間_無線電競黑科技,雷柏VT950Q游戲鼠標評測

雷柏作為目前小有聲譽的PC外設品牌&#xff0c;其定位高性能游戲領域的VT系列產品&#xff0c;想必大家也比較熟悉了。VT系列的產品除了有超強的性能以及出色的設計感&#xff0c;同時還都是性價比非常高的產品&#xff0c;即便是采用了旗艦級傳感器&#xff0c;定位最為高端的…

談論源碼_5,000名開發人員談論他們的薪水

談論源碼Let’s dive into the most interesting results from the O’Reilly 2016 Salary Survey of 5,000 developers (which excluded managers and students).讓我們來看看OReilly 2016年薪金調查對5,000名開發人員(其中不包括經理和學生)最有趣的結果。 性別工資差距是真…

WebSnapshotsHelper(HTML轉換為圖片)

1 /// <summary>2 /// WebBrowser Url生成圖片3 /// HTML轉圖片4 /// </summary>5 public class WebSnapshotsHelper6 {7 Bitmap m_Bitmap;8 string m_Url;9 int m_BrowserWidth, m_BrowserHeight, m_ThumbnailWidth,…

兩個多項式相乘求解系數數組算法

題目描述&#xff1a; 給出兩個多項式&#xff0c;最高次冪分別為n和m&#xff0c;求解這兩個系數相乘得到的系數數組。 分析&#xff1a; 最高次冪如果是m和n&#xff0c;那么他們相乘得到的系數數組的最高次冪一定是nm&#xff0c;對于其他的系數&#xff0c;不妨設a[],b[]是…

synchronized 和 reentrantlock 區別是什么_JUC源碼系列之ReentrantLock源碼解析

目錄ReentrantLock 簡介ReentrantLock 使用示例ReentrantLock 與 synchronized 的區別ReentrantLock 實現原理ReentrantLock 源碼解析ReentrantLock 簡介ReentrantLock 是 JDK 提供的一個可重入的獨占鎖&#xff0c;獨占鎖&#xff1a;同一時間只有一個線程可以持有鎖可重入&am…

gulp 和npm_為什么我離開Gulp和Grunt去看npm腳本

gulp 和npmI know what you’re thinking. WAT?! Didn’t Gulp just kill Grunt? Why can’t we just be content for a few minutes here in JavaScript land? I hear ya, but…我知道你在想什么 WAT &#xff1f;&#xff01; 古爾普不是殺死了咕unt嗎&#xff1f; 為什么…

mysql8.0遞歸_mysql8.0版本遞歸查詢

1.先在mysql數據庫添加數據DROP TABLE IF EXISTS dept;CREATE TABLE dept (id int(11) NOT NULL,pid int(11) DEFAULT NULL,name varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,date datetime(0) DEFAULT NULL,PRIMARY KEY (id) USING BTREE) ENGINE…

js 輪播插件

flexslider pc插件 個人用過flickerplate 移動端插件 個人用過個人覺得比較好的移動端插件swiper http://www.swiper.com.cn/ 用過個人覺得比較好的pc端插件待定

計算機中的字符編碼

字符編碼 什么是計算機編碼 計算機只能處理二進制的數據&#xff0c;其它的數據都要進行轉換&#xff0c;但轉換必須要有一套字符編碼(是字符與二進制的一個對應關系)。常用的字符&#xff1a;a-z、0-9、其它的符號等&#xff0c;計算機也不能直接處理。 &#xff08;字符編碼類…

致力微商_致力于自己。 致力于公益組織。

致力微商by freeCodeCamp通過freeCodeCamp 致力于自己。 致力于公益組織。 (Commit to Yourself. Commit to a Nonprofit.) In case you missed it, our October Summit was jam-packed with several big announcements about our open source community.如果您錯過了它&#…

應急照明市電檢測_應急照明如何供電? 如何接線? 圖文分析!

對于大部分剛接觸建筑電氣設計的工作者來說&#xff0c;應急照明的強啟原理一直都是很頭疼的問題。由于不知道應急照明的強啟原理&#xff0c;所以&#xff0c;應急燈具應該用多少根線&#xff0c;其實也就無從談起。下面以文字和圖片結合的方式來說明應急燈怎么接線的&#xf…

win10網速慢

升級到win10之后發現網速特別慢&#xff0c;搜了下&#xff0c;網上的解決辦法果然好使&#xff0c;按照如下操作即可。 返回桌面&#xff0c;按WINR鍵組合&#xff0c;運行gpedit.msc 打開組策略 依次展開管理模板-》網絡-》QoS數據計劃程序-》限制可保留寬帶&#xff0c;雙擊…

ubuntu安裝nodejs

下載nodejs https://nodejs.org/dist/v4.6.0/node-v4.6.0-linux-x64.tar.gz 解壓 tar -zxvf node-v4.6.0-linux-x64.tar.gz 移動到/opt/下 mv node-v4.6.0-linux-x64 /opt/ 創建鏈接 ln -s /opt/node-v4.6.0-linux-x64/bin/node /usr/local/bin/node 轉載于:https://www.cnblog…

android實用代碼

Android實用代碼七段&#xff08;一&#xff09; 前言 這里積累了一些不常見確又很實用的代碼&#xff0c;每收集7條更新一次&#xff0c;希望能對大家有用。 聲明 歡迎轉載&#xff0c;但請保留文章原始出處:)     博客園&#xff1a;http://www.cnblogs.com 農民伯伯&…

mysql 全文本檢索的列_排序數據列以檢索MySQL中的最大文本值

為此&#xff0c;您可以將ORDER BY與一些聚合函數right()一起使用。讓我們首先創建一個表-create table DemoTable1487-> (-> StudentCode text-> );使用插入命令在表中插入一些記錄-insert into DemoTable1487 values(560);insert into DemoTable1487 values(789);in…

關于長壽_FreeCodeCamp可以幫助您更長壽

關于長壽by Christopher Phillips克里斯托弗菲利普斯(Christopher Phillips) 免費代碼營可能幫助您長壽 (Free Code Camp Might Help You Live Longer) Since I started my web development journey with Free Code Camp, I’ve felt more awake, more alert, and able to pro…

python世界你好的輸出便攜電源適配器_65W PD輸出,Thinkplus USB-C便攜電源適配器(PA65)開箱評測...

包裝盒底蓋面為紅色&#xff0c;標注了產品的相關參數&#xff1a;型號&#xff1a;PA65&#xff1b;輸入&#xff1a;100V-240V~50/60Hz 1.5A&#xff1b;輸出&#xff1a;5V/3A、9V/3A、12V/3A、15V/3A、20V/3.25A&#xff1b;制造商&#xff1a;南京博蘭得電子科技有限公司&…