创建了适用于 hexo 的一个主题 mls

之前用的主题是基于 landscape, 虽然这确实是一个不错的主题,使用上也没什么不便,但毕竟这是一个他人贡献的主题。我一直想试着自己做一个主题。之前也尝试在 landscape 上改,修改了一些颜色,对 CSS 做了一些简单修改,但布局没变,整体一眼还是能看出这是 landscape,并且因为我当时不熟悉 EJS 模板,对 Sass 及 CSS3 不是特别熟悉,所以有些功能的实现也完全不知道怎么做,比如一些透明效果的动画。

最近一段时间,相对以前来说稍微不忙了点,所以趁这个机会试着做一个主题了。

sort some list elements into an descreasing ones in js

Intro

Sort is a prevalent topic in programing. Although the sort operation mostly is handled by the back-end like PHP, Java and so on, occasionaly some are occured in front-end. Here are some simple instances I dealt with recently.

Bubble-like Sort

Suppose some list elements ordered as follows:

1
2
3
4
5
6
<ul id="demo">
<li>2</li>
<li>1</li>
<li>4</li>
<li>3</li>
</ul>

Every time I filter through the nodes to get the smallest-value one from 1st one to 4nd one, and then I put it to the tail of lists. Next, I still filter to get the smallest-value one but from 1st one to 3nd one, and still put it to the tail to the lists. Now, two elements are sorted, and still two ones stay idle. The operation continues until all the elements have been sorted.
The produceres can be illustrated as follows:

2 1 4 3 -> 2 4 3 1 -> 4 3 1 2 -> 4 1 2 3 -> 1 2 3 4

在JS中实现静态变量/函数

静态变量/方法

静态变量/方法,一般来说是独立於对象的存在,它不属於任何一个具体的对象,它属於每一特定类的所有对象。也可以认为是属於一个类的。静态变量一般用於常数,或者存储某一类的所有对象需要共有的变量。
学JS的时候发现,与JAVA,C++相比,JS并没有明确定义静态的声明或使用方法。虽然没有说,但仍然需要,比如一个很经典的需要就时用静态变量统计一个类被实例化了几次。

在初学JS时犯的一些错误

表示最近在学JS, 相对个人以前学的Python, JAVA之类的语言, JS的语言确实有一些”奇葩”. 把初学时的一些语法错误记录下来,方便自己以后查阅, 如果能帮助到读这篇文章的你自然就更好了.

number 与 string 相加/减/乘/除

Example 1:

1
2
var a  = "5" + 2;   // the result is "52"
var b = 2 + "5"; // the result is "25"