我曾经说过,程序员不是一般的人,是具有某种超能里的人。但问题是,程序员往往意识不到自己的这种特异功能,在他们的眼里,会认为自己很普通,跟常人一样,所以,程序员能做到的事情,其他人——比如他们的客户/软件用户——也应该很容易做到。但事实上,由于大部分人——绝大部分人(包括软件开发公司的客户/购买软件的用户)——都是电脑小白(对电脑知识/计算机知识/软件知识知之甚少的人)。一个对于程序员来说很显而易见的软件操作,换成让用户来操作,就会出现各种各样奇怪的事情。这让程序员非常痛苦。
记得有一次,一个客户打电话给我,说他电脑桌面上的大e找不到了,我没听懂,什么大e找不到了?客户解释说:就是那个长的像大个儿的英文字母e的图标找不到了。我倒。终于明白了他指的是桌面上的 IE 浏览器的图标不见了。
还有一次,有个客户提出一个需求,要求在页面上增加一个搜索功能,我问它,系统里有搜索功能,为什么还要在这个地方新增一个搜索功能,他说他要的不是那个搜索,他要的是在这个页面上搜在某个关键词。经过进一步的沟通,我明白了,他要的是浏览器上的快捷键 CTRL+F 的功能。
因为用户的这些特征,导致了程序员认为完美的程序,到了客户的手里,却变成极其难用的软件,投诉电话如乡下骂街的泼妇似的响个不停。而事后分析发现,根本原因都是应为程序员高估了用户对软件的掌控能力,低估了自己对软件的创造能力,于是导致了他们看这些客户使用他们开发的软件时,都是那样一种可笑的行为,如下图:
在程序员的眼里,用户是这样使用他们开发的软件的
如果是脾气暴躁的程序员,遇到这种情况,难免会对着客户发一顿牢骚,而且,程序员的脾气一般都不是很好,所以,通常跟客户沟通时,项目经理一般都是跟着一起,以免事态激化。
用户虽然给程序员带来很多麻烦,但其实程序员的所有荣耀感都来自客户,因为只有客户用得满意,程序员才会有成就感。比如像下面这几个客户在使用一个新款软件时显露出来的表情,足够让一个处在北京重度雾霾的下午的程序员也能露出笑容:
用户在使用一款新软件时的样子
程序员虽然脾气不好,但他们都是为工作着想,不带任何个人恩怨。当开发软件有紧急任务时,他们都是任劳任怨的加班加点,当在已经发布的软件中出现了重大 bug 时,他们都会深深在自责,会连夜赶制出紧急修复 bug,如果不能在第一时间让用户满意,他们会茶不思、饭不想、觉不睡。即使在实在没有短期内完整的补救措施的情况下,他们也会想出一些歪招,但也是行之有效的方案,让用户暂时度过难关。比如,下面就是一个紧急修复补丁:
紧急修复补丁
用户应该体谅程序员。程序员的生活实际处在一种十分矛盾的状态中。编程不像其它行业,比如泥瓦匠砌砖,砌一层砖,墙就会高一次。但编程不一样,有时候一个程序员写了一天的代码,急得满头大汗,但开发进度未必就有所进展,有时候甚至还会倒退。软件编程是一个亦虚亦实的世界,有时候你搞不清一段代码为什么好用,有时候也会诧异由那样的代码构成的软件也能跑起来,正如下面这张图片中所示:
软件中有鬼
最后,说一下跟程序员打交道的一些注意事项。程序员因为整天和编程逻辑打交道,所以对因果关系特别敏感。如果你的话语的因果关系不是很明确,这会让他们感到疑惑,如果你的话语的因果关系不完整,这会让他们办错事。如果你的话中有if
,最好后面用then
做结束,或者用else
给出选择,主语要明晰。如果不明晰,就会出现下图中出现的事故:
程序员是这样理解这个指示牌上的话的
如果你是一个程序员,你会理解我说的话。
javascript:null and undefined
声明而没有赋值的变量是undefined
没有返回值的函数返回的是undefined
var a;//undefined console.log(a);//undefined console.log(typeof a);//undefined console.log(typeof a == undefined)//false console.log(typeof a == "undefined")//true console.log(typeof a === undefined)//false console.log(typeof a === "undefined")//true console.log(a==null);//true console.log(a==undefined);//true console.log(a===null);//false console.log(a===undefined);//true console.log("*******************"); var b = null;//null console.log(b);//null console.log(typeof b);//object console.log(typeof b == undefined)//false console.log(typeof b == "undefined")//false console.log(typeof b === undefined)//false console.log(typeof b === "undefined")//false console.log(b==null);//true console.log(b==undefined);//true console.log(b===null);//true console.log(b===undefined);//false
iis 7 – IIS7 URL Rewrite – Add "www" prefix
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<!--<rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="test.com" />
</conditions>
<action type="Redirect" url="http://www.test.com/{R:0}" />
</rule>-->
<rule name="Add www" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^test.com$" />
</conditions>
<action type="Redirect" url="http://www.test.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
How to Create a Javascript Console in Sublime Text – wikiHow
Two Methods:Using JSC (Mac OS X)Using Node.js
Javascript consoles are very handy for debugging and getting live results from your script. Although Sublime Text comes with build systems for many other scripting languages, it does not come with a built-in Javascript build system. Many sources will tell you to create a .html page with a link to the .js file, then use a web browser console to see the results of your code. This equates to constant window-switching and browser reloading; leading to frustration, heartache, and ultimately inefficiency.
Fortunately, constructing your own Javascript build system for Sublime Text is quick and easy!
Method 1 of 2: Using JSC (Mac OS X)
JSC is a command-line Javascript runner, cooked directly into Mac OS X. Because your Mac already contains everything you need to run the script, creating the build system in Sublime Text is incredibly easy. (If you have a Windows computer, see the directions for Node.js below.)
Creating The Build System
-
1
Launch Sublime Text.
-
2
Go to “Tools > Build System > New Build System” in the top bar.
-
3
Paste this code into the resulting new tab that Sublime Text opened, replacing anything else in it:
{ "cmd":["/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc","$file"], "selector":"source.js" }
-
4
Save the file as “JSC.sublime-build” in the default “user” folder.?Now you have created your build system!
Usage
-
1
Open the Javascript file that you want to run in Sublime Text.
-
2
Use?
debug()
?instead of?console.log()
?in your script. -
3
Go to “Tools > Build System” in the top bar and select “JSC”.?This is the build system that you just created.
-
4
Build the Javascript file, using either the shortcut ?B, or by choosing “Build” from the “Tools” menu.?A console will now appear in a pane at the bottom of the window, showing the results of your script!
Method 2 of 2: Using Node.js
Node.js (Node) is a platform built to allow Javascript to run on a server. However, it can also be installed on your local computer, providing a relatively simple way to run Javascript and get the results without using a browser.
-
1
Download the Node installer from the?project’s homepage?and run it.?Simply use the default settings.
-
2
Go to “Tools > Build System > New Build System” in the top bar.
-
3
Paste this code into the resulting new tab that Sublime Text opened, replacing anything else in it:
{ "cmd":["node","$file"], "selector":"source.js" }
-
4
Save the file as “node.sublime-build” in the default “user” folder.?Now you have created your build system!
Usage
-
1
Open the Javascript file that you want to run in Sublime Text.
-
2
Go to “Tools > Build System” in the top bar and select “node”.?This is the build system that you just created.
-
3
Build the Javascript file, using either the build shortcut (Ctrl + B for Windows, and ? + B for Mac), or by choosing “Build” from the “Tools” menu.?A console will now appear in a pane at the bottom of the window, showing the results of your script!
DataTableSerializer datatable序列化成对象 datatable to entity serialization
public class DataTableSerializer
{
public static List ToList(DataTable dt)
{
var list = new List();
if (dt == null || dt.Rows.Count == 0)
return list;//return empty list instead of null object
list.AddRange(from DataRow row in dt.Rows select ToEntity(row));
return list;
}
public static T ToEntity( DataRow row)
{
var objType = typeof(T);
var obj = Activator.CreateInstance();
foreach (DataColumn column in row.Table.Columns)
{
var property = objType.GetProperty(column.ColumnName,
BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
if (property == null || !property.CanWrite)
{
continue;
}
var value = row[column.ColumnName];
if (value == DBNull.Value)
{
value = null;
}
else
{
//add what you need.
//if (column.DataType == typeof (DateTime))
//{
// value = ((DateTime)value).ToString("yyyy-MM-dd");
//}
}
property.SetValue(obj, value, null);
}
return obj;
}
}
颜色渐变的文字样式css – JSFiddle
javascript – how can we use $compile outside a directive in Angularjs
VisualStudio.gitignore
JavaScript中模块模式的应用
模块模式是JavaScript中使用最广泛的模式,模块利用了闭包的特性
Module模式的基本特征:
- 模块化,可重用
- 封装了变量和function,和全局的namaspace不接触,松耦合
- 只暴露可用public的方法,其它私有方法全部隐藏
//自执行函数(immediately invoked function)
(function(){
}());
//这样也可以(this works too)
(function(){})();
//增加参数(add params to first)
(function(my){
}(variable));
//增加返回值(add return)
(function(my){//
return my;
}(variable));
//这样MODULE就是返回的my(give my to MODULE)
//js加载完就会运行这个函数,并且把返回值赋予MODULE
var MODULE = (function(my){//
return my;
}(variable));
//把自执行函数的参数换成返回的变量(change immediately invoked function parameter)
var MODULE = (function(my){//
return my;
}(MODULE || {}));
//你可以在其他任意地方这样定义MODULE
//所有的方法都会可以用MODULE来调用
//now you can define MODULE anywhere you like,
//all the functions inside will be extended to others
// 增加功能(add capabilities)
var MODULE = (function (my) {
//you cannot access inner variable
var variable = {};
// this is inner function, you cannot call it outside of the MODULE
function innerFun(){
console.log(variable);//you can access inner variable here
}
//this function will be exported, you can call it outside
my.someFun = function(){
//you can call inner variable and function here
console.log(variable);
innerFun();
};
return my;
}(MODULE || {}));
//MODULE || {} is the parameter passed to this MODULE,
//equals "my" inside MODULE
//you can define MODULE anywhere else
AngularJS中使用filter显示数字的千分位号
点击Result查看效果。