Archive

Posts Tagged ‘ACT’

Free SEO Tool from Microsoft

May 19th, 2010 Bali No comments

SEO的站内优化部分,基本目的就是让搜索引擎上的爽。长久以来,到底搜索引擎喜欢什么样子的网站,大多来自于“SEO专家”newletter中的只言片语。其实是有迹可寻的,搜索引擎说白了,就是一堆机器,是人告诉它如何去运转的。

曾经想过要开发一个网站SEO水平的静态分析工具的。现在好了,MS已经推出免费供分析工具了。

http://www.microsoft.com/web/spotlight/seo.aspx

大概试了一下,基本的功能还都有了。

ms seo tool screenshot 2

Categories: Chinese - 中文 Tags: ,

Polymorphism/inheritance pop quiz about Java

October 14th, 2009 Bali No comments

前面几篇都是关于THINK的。Well,动动嘴皮子总是很容易的,虽然在某些情况下吹牛也是一项必备的技能。其实,我一直很hands-on,而且enjoy hands-on, 每天都写code。也许我哪天做了CEO还是会写的,就因为喜欢。听说Intel SSG的前老大叫(什么什么来着),一人之下的位子,兴致来了,还会连上debugger,帮你调程序,呵呵。

好,上code,开始ACT。有两个class A, B,B is inherited from A. 问在下列几种情况下,会出现什么结果,并解释为什么。

public class B extends A {

      public int foo(int t) {

            return 0;

      }

}

(1)

public class A {

      public void foo(int t) {

            return;

      }

}

(2)

public class A {

      public int foo(int t) {

            return 1;

      }

}

(3)

public class A {

      private int foo(int t) {

            return 1;

      }

}

(4)

public class A {

      public int foo(int t, int s) {

            return 1;

      }

}

尤其是将要面试的同学,如果这个东西还没搞清楚,那么…除非你算法很强。另外,哪位同学知道,如何贴code吗?格式要保持Eclipse那样,非图片。

Categories: Chinese - 中文 Tags: ,

在线拍卖系统

September 30th, 2009 Bali 1 comment

早上,习惯性地打开新浪,小心地在广告链接中穿行,点新闻看。一则关于淘宝一元秒杀的新闻,很有意思。故事大概是:9/25日晚8时,淘宝将价值数千元的商品,以一元标价在淘宝上拍卖,庆祝成立6周年。结果搞砸了。很多用户还未看到开始页面就结束了,还有人用作弊器同时拍到了多个商品。

此事从商务角度来说,淘宝是毫无疑问的赢家。此次拍卖的目的并非真的拍卖,而是赚人气,赚眼球。尚不清楚,淘宝是否真的故意造成争议话题,让大家去议论,正如电影拍摄中常常传出男女主角的桃色新闻一样。从技术角度来说,如果要较完善设计此系统的话,至少有几点值得商榷。

(1)Use server push instead of client pull. 有淘宝用户留言,

我从19:50开始,不断刷新页面,都是显示“即将开始”,再刷新,活动已经结束!MLGB…

在线拍卖讲究的就是时效性,大家都想以最低的价格得到某样商品,所以非常想知道最新的价格,这时候就疯狂刷页面,造成服务器压力很大。另外一种做法是Server Push, “你们都不要刷了,有消息会告诉你们的,回家等着吧。” 这种东东就叫做Server Push。也不是什么新的概念,用Java applet等插件N年前都能实现,但让每个人都装这么个插件显然代价太大。现在的SilverLight, Flex也能实现类似功能,但需要安装插件。Dojo的Comet很好地解决了这个问题。code在这里。不用装插件,可以穿越防火墙,而且scalability很好,也可以做cluster。淘宝的兄弟们真应该考虑一下这个东西。对Java天然支持。很可能将是Servlet 3.0的一部分,HTML5中也有类似的概念了。Server Push的应用范围主要在Server需要主动传递信息给client的情况,如在线拍卖,聊天,股票报价等。下面是一个介绍的slide,有兴趣的朋友,仔细看看。5分钟就可以用maven弄一个玩玩。

(2)用一点anti-spamming技术吧,在这里就是验证码(CAPTCHA)。只有人能拍,程序不能拍。

(3)防一下DoS攻击,把疯狂刷页面的同学的IP暂时放入黑名单,或者弹出一个验证码页面。

Open source my Facebook app

September 5th, 2009 Bali No comments

http://balionweb.googlecode.com/svn/trunk/TellYouTruth/

Code如上。php写的。

tell-you-truth

tell-you-truth

Facebook.com在国内被GFW了,但毫无疑问它引领了Open API的潮流,与至于国内的很多公司直接抄CSS, JS,实在山寨得可以。这些code写于一年多前,是受42friends团队中的David同学的感召,写来玩玩的。它的功能也非常简单,模仿在blog一度非常流行的游戏:A回答B的问卷,然后A再加上一个问题,将这个新问卷发给他的5个好友。如此循环。大家约定要如实回答问题。问题不加限制,常常是很囧那种,如你被外星人带走怎么办只类的。故此命名为TellYouTruth.

写好后,我还给该App加过广告链接,推广给好友。3个月大约赚到1美元,然后就不玩了。

体会下来,SNS的App有几个特点:

1)非常简单。如果15秒内用户搞不清楚这东西是干嘛的,他就不想玩了。

2)偏重娱乐性。大家上SNS最主要的目的就是“扎堆,聊天,Kill time”(貌似是mayi的麦田说的?)。一本正经地弄出Business App一般很少有人问津。有人说LinkedIn就很严肃啊,Well,他那个人气和盈利模式你也知道。

3)SNS的价值。很多人说,SNS要变成这个,要变成那个。但我个人觉得,没那么复杂。很大程度上是投资人背后的吹打手写的貌似中立的文章罢了。人们互相认识可以在酒吧,但谈生意还是更喜欢去咖啡厅或高尔夫球场。SNS光靠广告盈利貌似前途渺茫,和搜索不同。甚至我认为SNS作为单个实体去盈利就是很难的,可以和其他的东西结合起来。很多硬件公司(如Intel)做的软件都是亏钱的,号称无私地去贡献code给开源社区,还听说Oracle用Intel的compiler的话,Intel甚至要付钱给Oracle。为什么这样做?左手亏钱,右手补。用Intel软件的优化出来的软件,在Intel的硬件平台上会有比竞争对手更好(如AMD)更好的表现,那最终用户就喜欢Intel的平台咯。

所以,天下没有免费的午餐的,但有共赢。

他们把这种事情不叫development, 也不叫marketing,叫做”enabling”。中文应该译作叫“推动”?

一句话,SNS有价值,但还没有被充分发掘。

Categories: Chinese - 中文 Tags: ,

Calling SQL Server Stored Procedures with ADO.NET in 5 minutes

August 2nd, 2009 Bali No comments

A stored procedure is an already written SQL statement that is saved in the database. It can take parameters; return objects you specified, just like what happens in any other programming languages you are familiar with.

Why stored procedures instead of random SQL? For me:

1. Modular Programming- Stored procedures allow developers to encapsulate business functionality and provide callers with a simple interface. Once interfaces are settled down, caller and callee coding work can be assigned to different team/persons.

2. Security Enhancement- Users can be granted permission to execute a stored procedure. Use parameterized queries—not string concatenation—to build queries.

3. Reduce network traffic – Benefits can be easily noticed if you have frequently called T-SQL code of hundreds of lines.

4. Performance – Stored procedures are registered at servers, and as a result DBAs/servers get more change to optimize them.

Coding time now. Firstly, you need run below SQL script in SQL2005.

SQL Script

– Create a test DB

USE [master]

GO

CREATE DATABASE SpTestDB

GO

USE SpTestDB

GO

– Create a test Table

CREATE TABLE dbo.TestTable (

id [nvarchar](50) NULL,

SomeValue [int] NULL

)

GO

– Create read SP

CREATE PROCEDURE dbo.ReadData

@id nvarchar (50)

AS

BEGIN

SELECT * FROM dbo.TestTable

WHERE id = @id;

END

GO

– Create write SP

CREATE PROCEDURE dbo.WriteData

@id nvarchar (50),

@SomeValue int

AS

BEGIN

INSERT INTO dbo.TestTable (id, SomeValue)

VALUES (@id, @SomeValue);

END

GO

Next, you can call in ADO.NET.

ADO.NET C# code

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.SqlClient;

namespace ConsoleApplication4

{

class Program

{

// NOTICE: You MUST replace ‘localhost\baligoal’ with your own DB instance name

const string ConnString = @”Data Source=localhost\baligoal;Initial Catalog=SpTestDB;Integrated Security=True”;

/// <summary>

/// Write a record to DB with stored procedure “WriteData”,

/// and then read it out with stored procedure “ReadData”

/// </summary>

/// <param name=”args”></param>

static void Main(string[] args)

{

const string TestID = “firstid”;

const int TestValue = 500;

// Firstly, write a record with store procedure

using (SqlConnection conn = new SqlConnection(ConnString))

{

// Specify ‘WriteData’ procedure in the params

using (SqlCommand cmd = new SqlCommand(“WriteData”, conn))

{

cmd.CommandType = System.Data.CommandType.StoredProcedure;

// The param names are exactly the same with SP WriteData’s

cmd.Parameters.AddWithValue(“@id”, TestID);

cmd.Parameters.AddWithValue(“@SomeValue”, TestValue);

cmd.Connection.Open();

cmd.ExecuteNonQuery();

}

}

// If you set BP here, and check you DB table, you should find ‘firstid, 500′ there

Console.WriteLine(“Write: done.”);

// Next, read it out with store procedure

using (SqlConnection conn = new SqlConnection(ConnString)) {

// Specify ‘ReadData’ procedure in the params

using (SqlCommand cmd = new SqlCommand(“ReadData”, conn)) {

cmd.CommandType = System.Data.CommandType.StoredProcedure;

// The param names is exactly the same with SP ReadData’s

cmd.Parameters.AddWithValue(“@id”, TestID);

cmd.Connection.Open();

using (SqlDataReader reader = cmd.ExecuteReader())

{

if (reader.Read()) {

Console.WriteLine(“read: id – “ + Convert.ToString(reader[0]));

Console.WriteLine(“read: SomeValue – “ + Convert.ToInt32(reader[1]));

}

}

}

}

// End for bp

Console.WriteLine(“exit”);

}

}

}

That is it.

Categories: English - 英文 Tags: ,