只有程序员才了解的真相

真相#1

  “你所不知道的是,很多我们每天都使用的关键软件(如Mac OS X和Facebook),作为一个整体虽然可以正常工作,但是实际上它们的背后充斥了各种的弊端和缺陷。这就像是你兴致勃勃地拆开了一架全新的747飞机,但是却发现燃料线是由衣架固定的,起落架是用胶带粘贴的。” ——Ben Cherry

这其实是非常有意思的一件事:网页和程序外观精美、运行流畅,但是却很有可能只是完美在前端上(用户所能看到的那一部分)。它们的背后其实千疮百孔、满是错误,不过因为某些神奇的原因,居然也可以正常工作。

真相#2

  “编写应用程序时,大概25%的时间是花在思考最终用户将会做哪些蠢事上的。”——Brian Humes

不过,25%这个数值会根据开发人员和程序员的作为而上下浮动。每次构建产品时,我们都需要坐下来思考最终用户将会如何把这个程序搞的一团乱。他们会点击什么,他们会写什么,问题的措辞,使用的语言,以及我们的写法所造成的不同理解。如果不注意这一点,那么就会出现很多问题,这是因为虽然我们知道程序是如何工作的,但是最终用户是不懂的。

真相#3

  “程序员不是修电脑的。” ——Ritesh Kumar Gupta

程序员是搞算法和设计原则的,不是一个修电脑的。我们知道电脑的内部工作原理,代码是如何协作的,但是,我们并不知道如何修理硬件,不知道为什么每次打开浏览器就崩溃,也不知道为什么电脑发热过度。请不要用一种“这种事对你们而言就是小菜一碟”的眼光看待我们。

真相#4

  “编程是一种思想,而不是敲代码。” ——Casey Patton

编程并不是说,只要你安安静静地坐下来,写个上千行代码,发布程序或应用程序的意思,编程其实是一种思想,一种解决问题的方法。而放松则是思考出方法的关键。

真相#5

  从零开始计算,而不是从一开始。

我们是从0开始计数的,所以你的“1”是我的“0”,你的“10”是我的“9”。之所以这么做,是因为这可以大规模地改善效率。

真相#6

  “一旦进入状态,编程就犹如神助——这种全神贯注的状态能让任何问题都变得小菜一碟。”——Morgan Johansson

知道为什么程序员被称为夜猫子吗?知道为什么我们常常熬夜吗?因为这样能让我们进入一种专注的状态,而不必担心会被其他人打断——因为他们都睡着了,这些烦人的家伙终于闭上了他们唧唧歪歪的嘴。真是一个伟大的编程时间啊!

真相#7

  告诉你个秘密,带着问题睡觉,实际上可以解决这个问题。

很多时候,我遇到那种花了几个小时都解决不了的问题,我就会去睡一觉。通过20分钟,一小时,六小时,十二小时的睡眠,醒来之后,问题答案就自然而然地出来了。

真相#8

  分配下来的任务却不再需要,就像父母杀掉孩子。

我们写的程序其实都类似于这样的层次结构。Parent管理它下面的Child。

现实中,如果父母不想要孩子,会去做流产。而在程序中,如果不再需要需要某些任务,那么会切断其与服务器的联系,杀掉这个孩子。

最后,真相#9

  当我们吹嘘我们有多么了解电脑时,你通常会不削一顾,同样的,你的自吹自擂也让我们觉得好烦。

老实说,这真的很烦,我们真的一点也不关心你对于计算机的了解。如果你说“我对于计算机不是很懂”,或者“我对计算机编程不是很感兴趣”那还是可以理解的,但是自吹自擂,鲁班门前弄大斧就会让我们厌烦了。请规避这种行为吧。

Flash Actionscript 3.0 位图九宫格切片代码

来源:http://bbs.9ria.com/thread-235526-1-1.html

package cn.flashk.controls.support{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	* <p>Scale9GridBitmap 用来创建位图的九宫格缩放。(因为flash本身的九宫格缩放并不支持位图,只支持矢量)</p>
	* 
	* 要使用位图的九宫格,请先传递原始的图像到sourceBitmapData属性,scale9GridBitmap.sourceBitmapData = bitmapData实例
	* 然后直接设置width和height属性。(此时scaleX和scaleY始终为1,set width和set height函数已经被重写)。
	* 虽然你仍然可以设置scale横向缩放和竖向缩放,不过不建议使用设置scaleX和scaleY属性缩放。要使用scaleX而又要开启九宫格,请使用 b.width = b.width 乘以 b.scaleX这样的语法。
	*/

	public class Scale9GridBitmap extends Bitmap {
		/**
		* 九宫格左边竖线与0坐标的距离
		*/
		public var leftLineSpace:uint = 8;
		/**
		* 九宫格右边竖线与图像最右像素的距离
		*/
		public var rightLineSpace:uint = 8;
		/**
		* 九宫格上面横线与0坐标的距离
		*/
		public var topLineSpace:uint = 6;
		/**
		* 九宫格下面横线与图像最下像素的距离
		*/
		public var bottomLineSpace:uint = 6;
		/**
		* 控制再拉伸九宫格位图时是否对中间的部分开启平滑处理,默认关闭,开启将获得更好的渐变效果,设置为 true 的情况下绘制位图要比在设置为 false 的情况下执行相同操作更为缓慢,请注意此参数与smoothing属性的区别,smoothing是指控制在整个位图缩放时是否进行平滑处理。
		* smoothing在这里只影响小数坐标时是否平滑处理,因为Scale9GridBitmap的在重设宽高时scaleX和scaleY始终为1(set width和set height函数已经被重写,但你仍然可以自己设置scaleX,此时smoothing会有效果)
		* 
		* <p>修改scaleSmoothing只会在下一次更改宽高时生效,并不会立即刷新图像,如果需要立即刷新,请调用update函数</p>
		* 
		* @see #update()
		*/
		public var scaleSmoothing:Boolean = false;

		protected var sourceBD:BitmapData;
		protected var _width:uint=0;
		protected var _height:uint=0;
		protected var bd:BitmapData;

		public function Scale9GridBitmap() {
		}

		/**
		* 设置Scale9GridBitmap的原始未缩放的源数据,可以与其他 Bitmap 共用一个 Bitmapdata。因为Scale9GridBitmap在重设宽高需要重新计算bitmapdata数据,需要以此属性的数据做参考,Scale9GridBitmap并不会修改此属性中的像素数据。只会修改自身bitmapdata属性的数据。
		*/
		public function set sourceBitmapData(value:BitmapData):void {
			sourceBD = value;
			this.bitmapData = sourceBD;
			if (_height==0) {
				_height = sourceBD.height;
			}
			if (_width == 0) {
				_width = sourceBD.width;
			}
		}

		public function useSourceSize():void {
			this.bitmapData = sourceBD;
			_height = sourceBD.height;
			_width = sourceBD.width;
		}

		/**
		* 更改Scale9GridBitmap的宽度,修改此值将重新计算Scale9GridBitmap的bitmapData数据,如果height值与源图像相同,只修改width将采用3分法加速
		* 
		* @see #scaleGrid3()
		* @see #update()
		*/
		override public function set width(value:Number):void {
			if (uint(value) == _width) {
				return;
			}
			_width = uint(value);
			if (sourceBD == null) {
				return;
			}
			if (_width == sourceBD.width && _height == sourceBD.height) {
				this.bitmapData = sourceBD;
				return;
			}
			if (_height == sourceBD.height) {
				scaleGrid3();
			} else {
				scaleGrid9();
			}
		}

		/**
		* 更改Scale9GridBitmap的高度,修改此值将重新计算Scale9GridBitmap的bitmapData数据,如果width值与源图像相同,只修改height将采用3分法加速
		* 
		* @see #scaleGrid3V()
		* @see #update()
		*/
		override public function set height(value:Number):void {
			if (uint(value) == _height) {
				return;
			}
			_height = uint(value);
			if (_width == sourceBD.width && _height == sourceBD.height) {
				this.bitmapData = sourceBD;
				return;
			}
			if (_width == sourceBD.width) {
				scaleGrid3V();
			} else {
				scaleGrid9();
			}
		}

		/**
		* 立即重新计算图像,如果sourceBitmapData的数据有更新,调用此方法立即刷新Scale9GridBitmap与sourceBitmapData同步,请注意Scale9GridBitmap的bitmapData始终与sourceBitmapData是两份不同的数据和对象
		*/
		public function update():void {
			if (sourceBD && _width == sourceBD.width && _height == sourceBD.height) {
				this.bitmapData = sourceBD;
				return;
			}
			if (sourceBD && _width == sourceBD.width) {
				scaleGrid3V();
			} else if (sourceBD && _height == sourceBD.height) {
				scaleGrid3();
			} else {
				scaleGrid9();
			}
		}

		/**
		* 横向3分格启用加速
		*/
		protected function scaleGrid3():void {
			if (bd != null) {
				bd.dispose();
			}
			bd = new BitmapData(_width,_height,true,0);
			bd.copyPixels( sourceBD,new Rectangle(0,0,leftLineSpace,_height),new Point(0,0) );
			var tmpBD:BitmapData;
			tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,sourceBD.height,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,0,tmpBD.width,tmpBD.height),new Point(0,0) );
			var mat:Matrix = new Matrix();
			var sca:Number = (_width-leftLineSpace-rightLineSpace)/(sourceBD.width-leftLineSpace-rightLineSpace);
			mat.scale(sca,1);
			mat.tx = leftLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,0,_width-leftLineSpace-rightLineSpace,_height),scaleSmoothing );
			bd.copyPixels( sourceBD,new Rectangle(sourceBD.width-rightLineSpace,0,rightLineSpace,_height),new Point(_width-rightLineSpace,0) );
			this.bitmapData = bd;
			tmpBD.dispose();
		}

		/**
		* 竖向3分格启用加速
		*/
		protected function scaleGrid3V():void {
			if (bd != null) {
				bd.dispose();
			}
			bd = new BitmapData(_width,_height,true,0);
			bd.copyPixels( sourceBD,new Rectangle(0,0,_width,_height),new Point(0,0) );
			var tmpBD:BitmapData;
			tmpBD = new BitmapData(sourceBD.width,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(0,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			var mat:Matrix = new Matrix();
			var sca:Number = (_height-topLineSpace-bottomLineSpace)/(sourceBD.height-topLineSpace-bottomLineSpace);
			mat.scale(1,sca);
			mat.ty = topLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(0,topLineSpace,_width,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			bd.copyPixels( sourceBD,new Rectangle(0,sourceBD.height-bottomLineSpace,_width,bottomLineSpace),new Point(0,_height-bottomLineSpace) );
			this.bitmapData = bd;
			tmpBD.dispose();
		}

		protected function scaleGrid9():void {
			if (bd != null) {
				bd.dispose();
			}
			var tmpBD:BitmapData;
			bd = new BitmapData(_width,_height,true,0);
			var scaX:Number=(_width-leftLineSpace-rightLineSpace)/(sourceBD.width-leftLineSpace-rightLineSpace);
			var scaY:Number = (_height-topLineSpace-bottomLineSpace)/(sourceBD.height-topLineSpace-bottomLineSpace);
			var mat:Matrix;
			tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,topLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,0,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat= new Matrix();
			mat.scale(scaX,1);
			mat.tx = leftLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,0,_width-leftLineSpace-rightLineSpace,topLineSpace),scaleSmoothing );
			if (bottomLineSpace == topLineSpace) {
				tmpBD.fillRect(new Rectangle(0,0,tmpBD.width,tmpBD.height),0);
			} else {
				tmpBD.dispose();
				tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,bottomLineSpace,true,0);
			}
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,sourceBD.height-bottomLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.ty = _height-bottomLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,_height-bottomLineSpace,_width-leftLineSpace-rightLineSpace,bottomLineSpace),scaleSmoothing );
			mat= new Matrix();
			mat.scale(1,scaY);
			tmpBD.dispose();
			tmpBD = new BitmapData(leftLineSpace,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(0,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.ty = topLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(0,topLineSpace,leftLineSpace,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			if (rightLineSpace == leftLineSpace) {
				tmpBD.fillRect(new Rectangle(0,0,tmpBD.width,tmpBD.height),0);
			} else {
				tmpBD.dispose();
				tmpBD = new BitmapData(rightLineSpace,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			}
			tmpBD.copyPixels(sourceBD,new Rectangle(sourceBD.width-rightLineSpace,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.tx = _width-rightLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(_width-rightLineSpace,topLineSpace,rightLineSpace,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			mat = new Matrix();
			mat.scale(scaX,scaY);
			tmpBD.dispose();
			tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.tx = leftLineSpace;
			mat.ty = topLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,topLineSpace,_width-leftLineSpace-rightLineSpace,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			tmpBD.dispose();
			bd.copyPixels(sourceBD,new Rectangle(0,0,leftLineSpace,topLineSpace),new Point(0,0) );
			bd.copyPixels(sourceBD,new Rectangle(0,sourceBD.height-bottomLineSpace,leftLineSpace,bottomLineSpace),new Point(0,_height-bottomLineSpace) );
			bd.copyPixels(sourceBD,new Rectangle(sourceBD.width-rightLineSpace,0,rightLineSpace,topLineSpace),new Point(_width-rightLineSpace,0) );
			bd.copyPixels(sourceBD,new Rectangle(sourceBD.width-rightLineSpace,sourceBD.height-bottomLineSpace,rightLineSpace,bottomLineSpace),new Point(_width-rightLineSpace,_height-bottomLineSpace) );
			this.bitmapData = bd;
		}

	}
}

 

WIN8 错误代码:720

来源:http://tieba.baidu.com/p/3261639822

在系统运行中使用 CMD 打开命令行模式。
使用REGEDIT 打开注册表编辑器。
找到以下注册表子项:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
请逐个查找每个子项,找到在右侧“DriverDesc”值数据为 “WAN微型端口(网络监视器)”的子项。(同理找到IP,IPV6)
将每个找到的子项中的“Characteristics” 值数据从29修改为9。(注意你要找到3个进行修改,因为你有三个感叹号)
此时,在系统设备管理器中就可以将问题项卸掉了。
再点击扫描,感叹号消失,拨号错误720也没有了

注:可能需要重启