王培顺的博客&WangPeishun’s Blog

wangpeishun 发布的文章

系统应用程序
calc - 启动计算器
charmap - 启动字符映射表
chkdsk - Chkdsk磁盘检查
cleanmgr - 磁盘清理
clipbrd - 剪贴板查看器
cmd.exe - CMD命令提示符
dvdplay - DVD播放器
dxdiag - DirectX诊断工具
eudcedit - 造字程序(专用字符编辑程序)
explorer - 资源管理器
iexpress - 木马捆绑工具,系统自带
magnify - 放大镜
mplayer2 - 简易widnows media
player msconfig - 系统配置
mspaint - 画图板
mstsc - 远程桌面连接
narrator - 屏幕“讲述人”
notepad - 打开记事本
nslookup - IP地址侦测器
osk - 打开屏幕键盘
regedit - 注册表编辑器
regedt32 - 注册表编辑器
sndrec32 - 录音机
sndvol32 - 音量控制程序
taskmgr - 任务管理器
winchat - XP自带局域网聊天
write - 写字板
dcomcnfg - 系统组件服务
ddeshare - DDE共享设置
nslookup - 网络管理的工具向导
ntbackup - 系统备份和还原
mobsync - 同步中心
winmsd - 系统信息
winver - 检查Windows版本
wiaacmgr - 扫描仪和照相机向导
wscript - windows脚本宿主设置
wupdmgr - windows更新程序

管理控制台管理单元文件
mmc - 管理控制台
certmgr.msc - 证书管理
ciadv.msc - 索引服务程序
comexp.msc - 组件服务
compmgmt.msc - 计算机管理
devmgmt.msc - 设备管理器
dfrg.msc - 磁盘碎片整理程序
diskmgmt.msc - 磁盘管理
eventvwr.msc - 事件查看器
fsmgmt.msc - 共享文件夹管理器
gpedit.msc - 组策略管理器(本地组策略编辑器)
lusrmgr.msc - 本机用户和组
ntmsmgr.msc - 移动存储管理器
ntmsoprq.msc - 移动存储管理员操作请求
perfmon.msc - 性能监视器
rsop.msc - 组策略结果集
secpol.msc - 本地安全策略
services.msc - 本地服务设置
wmimgmt.msc - windows管理体系结构WMI(控制台根节点\WMI控件)
————————————————
原文链接:https://blog.csdn.net/u012995964/article/details/52549778

Dream It Possible

一首很励志的歌,很动人的调子。很美的词。

I will run, I will climb, I will soar.
我奔跑,我攀爬,我会飞翔。
I'm undefeated
永不言败
Jumping out of my skin, pull the chord
跳出我的皮肤,拨弄琴弦
Yeah I believe it
哦,我相信。
The past, is everything we were don't make us who we are
往昔,逝去的光阴不会决定现在
So I'll dream, until I make it real, and all I see is stars
所以我们梦想,直到变成真,看到满天星光
It's not until you fall that you fly
不怕跌倒,所以飞翔
When you dreams come alive you're unstoppable
当你的梦想成真,你是不可阻挡
Take a shot, chase the sun, find the beautiful
挥着翅膀,追逐太阳,寻找美丽
We will glow in the dark turning dust to gold
在黑暗中闪耀点石成金
And we'll dream it possible
我们会梦想成真
I will chase, I will reach, I will fly
我追逐,我奔驰,我要飞翔
Until I'm breaking, until I'm breaking
直到坠落,直到崩溃
Out of my cage, like a bird in the night
走出我的囚笼,像在黑夜里的莺
I know I'm changing, I know I'm changing
我知道我在变化,在蜕变
In,into something big, better than before
变成无比强大,从未有过
And if it takes, takes a thousand lives
如果需要牺牲,需要无数的生命
Then it's worth fighting for
那值得去奋斗
It's not until you fall that you fly
不怕跌倒,所以飞翔
When you dreams come alive you're unstoppable
当你的梦想成真,你是不可阻挡
Take a shot, chase the sun, find the beautiful
挥着翅膀,追逐太阳,寻找美丽
We will glow in the dark turning dust to gold
在黑暗中闪耀点石成金
And we'll dream it possible
我们会梦想成真
From the bottom to the top
从山谷到巅峰
We're sparking wild fire's
我们正在迸发野火
Never quit and never stop
永不放弃,永不停止
The rest of our lives
点燃未来
From the bottom to the top
从山谷到巅峰
We're sparking wild fire's
我们正在迸发野火
Never quit and never stop
永不放弃,永不停止
It's not until you fall that you fly
不怕跌倒,所以飞翔
When you dreams come alive you're unstoppable
当你的梦想成真,你是不可阻挡
Take a shot, chase the sun, find the beautiful
挥着翅膀,追逐太阳,寻找美丽
We will glow in the dark turning dust to gold
在黑暗中闪耀点石成金
And we'll dream it possible
我们会梦想成真

字符串的首字母大写,不能使用:

  1. toUpperCase()
  2. toLowerCase()

例子:

"string".capitalize() === "String" "hello World".capitalize() === "Hello World" "i love codewars".capitalize() === "I love codewars" "This sentence is already capitalized".capitalize() === "This sentence is already capitalized" "0123the first character of this sentence is not a letter".capitalize() === "0123the first character of this sentence is not a letter"

这次依旧没有我的答案。
1.

String.prototype.capitalize = function () {
let c = this.charCodeAt(0);
if (97 <= c && c <= 122) c -= 32;
return String.fromCharCode(c) + this.slice(1);
}

2.

String.prototype.capitalize = function(){
var map = {
a : 'A',
b : 'B',
c : 'C',
d : 'D',
e : 'E',
f : 'F',
g : 'G',
h : 'H',
i : 'I',
j : 'J',
k : 'K',
m : 'M',
n : 'N',
o : 'O',
p : 'P',
q : 'Q',
r : 'R',
s : 'S',
t : 'T',
u : 'U',
v : 'V',
w : 'W',
x : 'X',
y : 'Y',
z : 'Z'
};
return map[this[0]] ? map[this[0]] + this.slice(1) : this.toString();
};

3.

String.prototype.capitalize = function() {
return this.replace(/^[a-z]/, c => String.fromCharCode(c.charCodeAt(0)-32))
}

4.

String.prototype.capitalize = function() {
return /^[a-z]/.test(this) ? this.replace(this.charAt(0), String.fromCharCode(this.charCodeAt(0) - 32)) :
this.toString();
}

5.

String.prototype.capitalize = function()
{
var searchArray = 'abcdefghijklmnopqrstuvwxyz';
var replaceArray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var array = this.split('');
var index = searchArray.indexOf(array[0]);
if (index > -1) array[0] = replaceArray[index];
return array.join('');
}

6.

String.prototype.capitalize = function() {
var alf = 'abcdefghijklmnopqrstuvwxyz';
var alfC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var self = this.split('');
if (alf.indexOf(self[0]) != -1) {
self[0] = alfC[alf.indexOf(self[0])];
}
return self.join('');
}

7.

String.prototype.capitalize = function() {
if (this.charCodeAt(0) >= 97 && this.charCodeAt(0) <= 122) {
return (String.fromCharCode(this.charCodeAt(0) - 32) + this.slice(1));
}

return this.toString();
}

8.

String.prototype.capitalize = function() {
if (this.charCodeAt() < 97 || this.charCodeAt() > 122) return this.toString();
return String.fromCharCode(this.charCodeAt() - 32) + this.substring(1);
};

反向顺序输出字符串(单个单词不反向)

reverse('Hello World') === 'World Hello'
reverse('Hi There.') === 'There. Hi'

My Answer:

function reverse(string){
var mystr = string.split(' ');
var result = [];
for(var i =0;i<mystr.length;i++){
result[i] = mystr[mystr.length-1-i];
}
return result.join(' ');
}

Others:

1.

function reverse(string){
return string.split(' ').reverse().join(' ');
}

2.

reverse = s => s.split(' ').reverse().join(' ')

3.

function reverse(string){
var original = string;
var rev = original.split(' ').reverse().join(' ');
return rev;
}

4.

const reverse = words => words.split(' ').reverse().join(' ')

5.

function reverse(string){
return string.replace(/\s+/g, ' ').split(' ').reverse().join(' ');
}

6.

function reverse(string){
// validate input
if (typeof(string) !== 'string') throw new Error('reverse: parameter is not a string!');
// just use the dumb way out since it's jabbascripps
return string.split(' ').reverse().join(' ');
}

7.

function reverse(string){
if(typeof string === 'string')
{
var result = '';
string = string.split(' ');
for(var i = string.length ; i > 0; i--)
(i != 1 ? (result = result + string[i - 1] + ' '):(result = result + string[i - 1]));
}
return result;
}

字符串字母大小写反向输出
altERnaTIng cAsE <=> ALTerNAtiNG CaSe

这里分享的都是大家比较认可的几个方案:
1.

String.prototype.toAlternatingCase = function () {
return this.split("").map(a =&gt; a === a.toUpperCase()? a.toLowerCase(): a.toUpperCase()).join('')
}

2.

const isLowerCase = (char) =&gt; char.toLowerCase() === char;
const swapCase = (char) =&gt; isLowerCase(char) ? char.toUpperCase() : char.toLowerCase();

String.prototype.toAlternatingCase = function() {
return [...this].map(swapCase).join('');
};

3.

String.prototype.toAlternatingCase = function () {
return this.replace(/./g, function (match) {
return /[a-z]/.test(match) ? match.toUpperCase() : match.toLowerCase();
});
}

4.

String.prototype.toAlternatingCase = function () {
return this.replace(/[A-Za-z]/g, x =&gt; x &gt; "Z" ? x.toUpperCase() : x.toLowerCase())
}

5.

String.prototype.toAlternatingCase = function(){
return this.split("").map(letter =&gt; {
var newLetter = letter.toUpperCase();
return letter == newLetter ? letter.toLowerCase() : newLetter;
}).join("");
}

6.

String.prototype.toAlternatingCase = function () {
return this.replace(/[a-zA-Z]/g, function (ltr) {
return ltr === ltr.toUpperCase() ? ltr.toLowerCase() : ltr.toUpperCase();
});
};

7.

String.prototype.toAlternatingCase = function () {
return this.split('').map(i =&gt; {
if (/[a-z]/i.test(i)) {
return i.toUpperCase() === i ? i.toLowerCase() : i.toUpperCase();
} else {
return i;
}
}).join('');
}

8.

String.prototype.toAlternatingCase = function () {
new_str = "";
for(var i = 0; i &lt; this.length; i++) { if(this[i] === this[i].toUpperCase()) { new_str += this[i].toLowerCase(); } else { new_str += this[i].toUpperCase(); } } return new_str; } [/code] [code] String.prototype.toAlternatingCase = function () { return this.split('').map(function(x){ if(x &gt;= 'A' &amp;&amp; x &lt;= 'Z') return x.toLowerCase(); if(x &gt;= 'a' &amp;&amp; x &lt;= 'z') return x.toUpperCase();
return x;
}).join('');
}

9.

String.prototype.toAlternatingCase = function () {
var letter, idx = 0, alt ='';
while (idx &lt; this.length) { letter = this[idx]; if (letter === letter.toUpperCase()) { alt += letter.toLowerCase(); } else { alt += letter.toUpperCase(); } idx++; } return alt; }; [/code] [code] String.prototype.toAlternatingCase = function () {  return this.split('').map(char =&gt; char === char.toUpperCase() ? char.toLowerCase() : char.toUpperCase()).join('');
}

10.

String.prototype.toAlternatingCase = function () {
let isUpper = function(c) {
if(c === c.toUpperCase()) return true;
return false;
};

let out = '';
for(let i = 0; i &lt; this.length; ++i) {
if(isUpper(this[i])) {
out += this[i].toLowerCase();
}
else {
out += this[i].toUpperCase();
}
}
return out;
}

返回一个字符串中最短单词的字母数量。

例如:"bitcoin take over the world maybe who knows perhaps" ,返回3。

我的:

function mysort(a,b){
return a-b;
}
function findShort(s){
var shorNum =0;
var myarr = s.split(' ');
for(var i=0;i&lt;myarr.length;i++){
myarr[i] = myarr[i].length;
}
myarr.sort(mysort);
return myarr[0];
}

人家的:

1.

function findShort(s){
return Math.min.apply(null, s.split(' ').map(w =&gt; w.length));
}

2.

function findShort(s){
var arr = s.split(' ');
var smallest = arr[0];
for (var i = 0; i &lt; arr.length; i++) {
if(arr[i].length &lt; smallest.length){ smallest = arr[i]; } } return smallest.length; } [/code] [code] function findShort(s){ return Math.min(...s.split(" ").map (s =&gt; s.length));
}

3.

const findShort = (s) =&gt; s
.split(' ')
.sort((a, b) =&gt; b.length - a.length)
.pop()
.length;

昨天看了一个BBC的纪录片《未来的地球》(Future Earth)。

BBC的水准一直很高,是我们应该学习的。

通过这个纪录片,我了解一个几个数据:

  1. 甲烷的温室效应比二氧化碳高出20多倍。
  2. 畜牧业是甲烷产生的主要行业。牛体内产生的甲烷,5%是由放屁排放出来的,95%是通过鼻孔排放的。
  3. 四分之一的二氧化碳是火力发电产生的。
  4. 近250年终,地球气温升高1度。
  5. 全球气温升高1度,看似幅度不大,对自然生态的影响确实巨大,甚至是致命的。
  6. 5500万年前,出现过地球气温高3度的情况,引起一系列恶性循环,导致地球气温短时间内增加6度,海洋生物大量灭绝。地球通过10万年的时间才恢复。

科学家的几个预测:

  1. 到本世纪末年,全球气温比工业革命前要高3度。
  2. 自然灾害发生率比之前高出很多,百年一遇的灾害,可能会变成二十年一遇。
  3. 北冰洋将无冰,北极永久冻土层将解冻,微生物会分解冻土层理的有机物,进而转换成二氧化碳排放到大气层。
  4. “地球之肺”亚马逊雨林可能因干旱和山火而消失,变成热带草原。
  5. 温暖适宜的地中海气候将不再存在。
  6. 北极、南极冰川融化,海平面将升高,部分地势较低的国家和地区将消失。
  7. 南极陆地将露出冰面,缺少冰川的反射,陆地会吸收太阳光的大部分热量,导致地球问题上升。
  8. 剧烈的气候变化将失控,形成恶性循环,地球生态崩溃。
  9. 干旱、缺水、饥饿、冲突、动乱、文明崩塌等侵袭人类。

科学家的努力:

  1. 二氧化碳收集和存放。
  2. 人造肉,减少畜牧业。为动物服用“绿色抗生素”。
  3. 人造树,模拟植物吸收二氧化碳,但“人造树”不能分解二氧化碳,
  4. 冰岛的地热发电、伦敦的风力发电、西班牙的光伏发电,葡萄牙的潮汐发电、法国的核电站,印度的沼气发电。
  5. 中国上海的悬磁浮列车。
  6. 将建筑外观刷成白色,发射阳光。
  7. 向太空发射大量带有微型电脑的镜子发射阳光,为地球降温。造价太高,目前不现实。
  8. 将硫酸盐发射入大气中,形成一个发射层,从而达到降温效果。但可能对臭氧层等地球保护层产生一些不确定的影响。

科学家的研究方法:

  1. 深钻地下,分析冰层,土层的物质、元素含量。
  2. 对野生动物做跟踪研究。
  3. 对某种现象做原因分析。

我的不解:

  1. 有一条数据,中国每一个月就新增2个火力发电站。这个是真实的吗,我在媒体上看到的是中国政府一直在关停火力发电厂呀。
  2. 中国的光伏产业那么牛,为了人类未来,为了地球,你们欧美还搞什么壁垒?
  3. 北极熊应该是没有国籍吧,“近水楼台先得月”,谁有能力逮着它研究就能研究吗?

(完)

定义一个hello函数,参数传递名字时,返回hello,名字,参数为空时,返回hello,world。

hello "john" => "Hello, John!" 
hello "aliCE" => "Hello, Alice!" 
hello => "Hello, World!" # name not given 
hello ' ' => "Hello, World!" # name is an empty String

我的(我承认,是第二次做这个题目啦,自我感觉逻辑思维是硬伤!!!)

第一次:

function hello(name) { 
if (name != null){
if(name == ""){ return "Hello, World!"; }
else{ var array = name.toLowerCase().split(" "); 
for (i=0;i<array.length;i++) { 
array[i] = array[i][0].toUpperCase() + array[i].substring(1, array[i].length); } 
var string = array.join(" "); 
return "Hello, "+ string +"!"; } 
} 
else { return"Hello, World!"; } 
}

第二次:

function hello(name) { 
if(name){ 
var say = name.substr(0,1).toUpperCase()+name.substring(1).toLowerCase(); return "Hello, "+say+"!"; }
else{ return 'Hello, World!'; } 
}

人家的:

function hello(name){ 
if (name){ return "Hello, " + name.substring(0,1).toUpperCase() + name.substring(1).toLowerCase() + '!'; } else { return "Hello, World!"; } 
}

function hello(name) { 
if (name === undefined || name === '') { return 'Hello, World!'; } 
else { return 'Hello, ' + name.substring(0,1).toUpperCase() + name.substring(1).toLowerCase() + '!'; } 
} 

function hello(name) {
if (!(name)) { return 'Hello, World!'; } 
else { name = name.replace(name.charAt(0), name.charAt(0).toUpperCase()); name = name.replace(name.charAt(name.length - 1), name.charAt(name.length - 1).toLowerCase()); } 
return 'Hello, ' + name +'!'; 
} 

function hello(name = "World") { 
if (!name) name = "World" return "Hello, " + name.charAt(0).toUpperCase() + name.slice(1).toLowerCase() + "!"; 
}


判断n是不是正整数若是整数求和。

函数f(n)

function f(n) { return (parseInt(n) === n && n > 0) ? n*(n+1)/2 : false; }; 

function f(n) { return Number.isInteger(n) && n > 0 ? n * (n + 1) / 2 : false; };

function f(n) { if(typeof n != 'number' || n <= 0 || Math.floor(n) != n) return false; return n * (n + 1) / 2; };

function f(n) { if(isNaN(n) || n <= 0 || ~~n !== n) return false; var x = 0; while(n>0) { x += n; n--; } return x; };

最近玩编程游戏觉得很有意思,个人觉得有两款值得为新手推荐。

1.CodeCombat。www.codecombat.cn

2.Codewars。   www.codewars.com

自己觉得codewars低级别的题目都比较难。值得自己去学习,这里在今后一段时间可能会list几个题目来强化记忆。


编写accum函数,实现如下功能:

accum(“abcd”) –> “A-Bb-Ccc-Dddd”

accum(“RqaEzty”) –> “R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy”

accum(“cwAt”) –> “C-Ww-Aaa-Tttt”

我的函数:

function accum(s) {
var start_str = s;
var resurt_str = "";
for(var i=0;i<start_str.length;i++){
var mystr = start_str.substr(i,1).toUpperCase();
for(var j=i;j>0;j--){
mystr += start_str.substr(i,1).toLowerCase();
}
if(i != start_str.length-1){
mystr += '-';
}
resurt_str += mystr;
}
return resurt_str;
}

人家的函数

function accum(str) {

var letters = str.split(“ ”);
var result = [];
for (var i = 0; i < letters.length; i++) {
result.push(letters[i].toUpperCase() + Array(i + 1).join(letters[i].toLowerCase()));
}
return result.join('-');
}