刚刚装了MyEclipse 8.5,安装特别慢,但是启动特别快,进度条刚走一点就打开了。
嗯,没啥了,留下注册码,利人利己。 阅读全文>>

四月三十号在公司吃完中午饭就下班了,公司多放半天假,嘿嘿。刚好回去搬家,说是搬家,其实很简单,就是换了一间房子,一个人跑了三个来回就搬完了,还不到10分钟。完了打扫了一下新房间,躺床上听着beyond和black head的歌,想着三天怎么过,晚上吃了碗凉皮,洗洗睡了。 阅读全文>>

继续玩JavaScript CanvasRenderingContext2D。前面画出来的都是“死”的,下面结合前面两个例子做一个“动”态时钟。当然还是得先了解一下即将用到的一些新属性及方法。 阅读全文>>

可别看这张脸简单啊,你要知道这里面可是用了平面几何中的圆啊!(π值你能背到第几位?)所以必须得知道圆的定义:1.平面上到定点的距离等于定长的点的集合叫圆,2.平面上一条线段,绕它的一端旋转360°,留下的轨迹叫圆,另外还得知道坐标系以及CanvasRenderingContext2D提供的方法。 阅读全文>>

看到旁边的图,如果要问是怎么画的,估计第一反应是Photoshop,其实这是用JavaScript在canvas标签上通过CanvasRenderingContext2D对象画出来的。接下来看看如果通过JavaScript画出这张图来。
首先需要了解以下知识:
HTML中用于脚本画图的canvas元素
目前Firefox 1.5, Safari 1.3,及Opera 9以上版本都支持此元素,鸟IE都出8了,还是不支持,想在IE上看可以安装http://excanvas.sourceforge.net来模拟效果。
- 属性
- height默认值300
- width默认值300
- 方法
- getContext()返回一个CanvasRenderingContext2D对象用于在canvas上绘图,你必须传入字符串参数“2d”
CanvasGradient
可以将该对象赋值给CanvasRenderingContext2D对象的strokeStyle及fillStyle属性。CanvasRenderingContext2D对象的createLinearGradient()及createRadialGradient()返回类型均为CanvasGradient。
该对象的addColorStop(float offset, String color)方法可以改变指定点的颜色。该方法至少要使用一次,否则绘图将是透明的。
CanvasRenderingContext2D.createRadialGradient( )
- 方法介绍
- CanvasGradient createRadialGradient(float xStart, float yStart, float radiusStart, float xEnd, float yEnd, float radiusEnd)
- 参数
- xStart, yStart
- 起始圆圆心坐标
- radiusStart
- 起始圆半径
- xEnd, yEnd
- 结束圆圆心坐标
- radiusEnd
- 结束圆半径
- xStart, yStart
- 返回值
- 一个CanvasGradient对象
样例
以下是实现上图效果的JavaScript代码:
var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); var radial = ctx.createRadialGradient(60, 75, 0, 100, 75, 60); radial.addColorStop(0, '#000'); radial.addColorStop(0.5, 'red'); radial.addColorStop(1, '#999'); ctx.fillStyle = radial; ctx.stroke(); ctx.fillRect(0, 0, 200, 150);

你觉得你是真正的程序员吗?这里有一个针对Java程序员的在线测试网站。随机给出一道题让你在自己电脑的IDE中进行调试,完成后将整个代码提交上去,如果编译出错,它会给出错误信息,成功的话就进入下一题,题目的难度系数会不断增加,共计5道题(没有特殊要求的话,不需要考虑程序优化,实现即可)。
在答题时,它会提示出完成该题的推荐时间,最长时间并记录你所消耗的时间。打完所有题后它会给你颁发一个证书,不过,这个证书并不能证明什么。有很多“程序员”知道Java的语法及库但不会简单算法或者拿出一个像样的设计。第一题往往比较简单,可别错过了。
传送门:better programmer点击“Take the Test”开始测试。
目前首页排名中还没有中国人进入前30,基本上都是印度阿三。有位杭州的Alek Wang排名41,不过看了一下时间,貌似这个榜单不是动态刷新的。
我获得的证书(说我比93%的所有参加测试的人强 n:-hd ):http://www.betterprogrammer.com/certificate/BP12P03N2
每次的题目都不一样,偶尔会出现重复的,但是至少每轮5道题是不重复的。就像上面介绍的那样,这些题目多是算法和设计实现,感觉挺有意思的,没事的时候可以上去做做题,动动脑。
题都答对了,得了93%,我估计是因为作答时间的问题,因为题目是英文,光审题理解题意就花了不少时间。汗一个~
以下是我做过的题及答案,可别偷看哦! n:-wx (貌似最多的就是关于递归的题)
getUniqueElements
Please implement this method to return a set of elements that can be found only in set a or set b,but not in both Sets.The method should not change the content of the parameters.
public static Set<Object> getUniqueElements(Set<Object> a, Set<Object> b) { Set<Object> objs = new HashSet<Object>(); for (Object o : b) { if(!a.contains(o)){ objs.add(o); } } for (Object o : a) { if(!b.contains(o)){ objs.add(o); } } return objs; }
getAverage
Please implement this method to return the average of all node values (Node.getValue()) in the tree.
public class BetterProgrammerTaska { private static double sum = 0; // Please do not change this interface public static interface Node { int getValue(); List<Node> getChildren(); } public static double getAverage(Node root) { /* Please implement this method to return the average of all node values (Node.getValue()) in the tree. */ if(root != null){ if(root.getChildren() != null && root.getChildren().size() > 0){ for(int i=0;i<root.getChildren().size();i++){ getAverage(root.getChildren().get(i)); } }else{ sum += root.getValue(); } } return sum; } public static void main(String[] args){ Node root = new Node(){ public List<Node> getChildren() { // TODO Auto-generated method stub return null; } public int getValue() { // TODO Auto-generated method stub return 100; }}; System.out.println(getAverage(root)); } }
countWaysToJump(这个题对我有点难度啊!)
A set of stairs has N steps.
You can jump either 1 or 2 steps at a time.
For example, if the stairs is N=4 steps, you can reach the end in 5 possible ways:
1-1-1-1, or 1-2-1 or 1-1-2 or 2-1-1 or 2-2
Please implement this method to
return the count of the different ways to reach the end of the stairs with N steps.
public class BetterProgrammerTaskb { public static int countWaysToJump(int N) { switch(N) { case 1: return 1; case 2: return 2; case 3: return 3; default: return countWaysToJump(N-2) + countWaysToJump(N-1); } } public static void main(String[] args){ System.out.println(countWaysToJump(5)); } }
getSumOfNumbers
Please implement this method to
return the sum of all integers found in the parameter String. You can assume that
integers are separated from other parts with one or more spaces (‘ ‘ symbol).
For example, s=”12 some text 3 7″, result: 22 (12+3+7=22)
public static int getSumOfNumbers(String s) { int sum = 0; for(int i=0;i<s.length();i++){ int j = (int)s.charAt(i); if(j >= 48 && j <= 57){ sum += j - 48; } } return sum; }
getBinaryRepresentation
Please implement this method to
return a String with the binary representation of any number n, where n >= 0.
Example: “101″ is a binary representation of 5
public static String getBinaryRepresentation(int n) { String a = ""; while(n != 1){ a += n % 2; n /= 2; } a += n; String b = ""; for(int i = a.length()-1; i >= 0; i--){ b += a.charAt(i); } return b; }
![]()
又出现了一个JS库,是基于jQuery的,名为jQuery EasyUI。看官方上方的预览图,首先联想到的是ExtJS。 n:-bz
jQuery EasyUI帮助你很容易的建立网页。
- jQuery EasyUI是基于jQuery的UI集合。
- 基于jQuery EasyUI你不需要写过多的JavaScript代码,只需要定义一些HTML标记的界面。
- jQuery EasyUI简单而又强大。
目前包括以下组件:
- Menu and Button
- DataGrid and Tree










