Blog Home  Home Feed your aggregator (RSS 2.0)  
kevin Mocha - Monday, January 07, 2008
Bookmarks collected from web.
 
 Monday, January 07, 2008

http://blog.emanuelebartolesi.com/post/2007/12/Log4net-Simple-way-to-use-in-your-Aspnet-application.aspx

Introduction

Log the actions of your applications is very important especially when you develop new features or develop very difficult logical business.
But it is also important when users use your applications to understand the critical issues or problems.
To implement quickly the log operations Apache developed an opensource library for .Net developers.

Download

You can download the latest version of Log4net from this location.

Add reference to your solution

In Visual Studio 2005 select Project -> Add Reference.
In the tab Browse, find and select the dll Log4net.dll in your local folder.

Modify web.config

Into web.config file add this code into the section Configuration->Configsections:
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>

Yet, add the section:

<log4net>

<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

<file value="c:\temp\web.log" />

<appendToFile value="true" />

<maximumFileSize value="1024KB" />

<maxSizeRollBackups value="10" />

<layout type="log4net.Layout.PatternLayout">

<conversionPattern value="%date %level %logger - %message%newline" />

</layout>

</appender>

<root>

<level value="DEBUG" />

<appender-ref ref="RollingFile" />

</root>

</log4net>

In this configuration will create a log file into the folder "c:\temp\" until its size is 1024Kb.
After this size the name of file will be web.log.1 until 10.
At this link you can find another configurations.

Global.asax

In the event "Application_Start" of the file Global.asax add this line:
log4net.Config.XmlConfigurator.Configure();
Begin to log

In every page you want to log something, add the static variable like below:
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

This class has 5 levels of severity to log the operations:

log.Debug("log something at this level")
log.Info("log something at this level")
log.Warn("log something at this level");
log.Error("log something at this level");
log.Fatal("log something at this level");

Simple and fast to use.
You find the official documentation at this link.

Monday, January 07, 2008 10:28:47 PM UTC  #    Comments [0]    |   |  Trackback
Things to think about if you want to be a consultant

http://devlicio.us/blogs/derik_whittaker/archive/2008/01/02/things-to-think-about-if-you-want-to-be-a-consultant.aspx

I was chatting a buddy recently and he was thinking about making the jump to the consulting world (not solo, through a consulting firm).  As he has never been a consultant I gave him my 2cents on questions to ask during the interview as well as things he has to accept before making the jump.

Questions to ask the consulting firm

  • What percent of travel is the norm?
    This is very important to know up front.  Because if you don't want to travel much and they tell you they are 100% travel, then move on. 
    One thing you need to keep in mind, is that they can give you a number, that number is NOT in stone.  It can/will change from client to client.  In my 5 years of consulting, I never left the greater Chicago area.  And for 2+ years I worked out of our home office.
  • What is your bench policy?
    Ask what the policy is for being on the bench?  More importantly ask the billable % expectation is for a consultant.  This can be important because if they expect you to be billable 90% of the year then they may not be able to handle any rough patches.  However, if they expect you to be billable for only 80% then they should be better set for rough patches.
    I also found that if a company has higher expectations about billable %, they may not be willing to provide non-billable training as it eats into the bottom line.
    If you are on the bench, do they have something for you to do?  Can you go to training during that time?  Or can you simply stay home and collect a check (i wish)?
  • What is your training policy?
    Ask what type of training they budget for?  Do they pay for conferences, weekly training classes?  Do they EXPECT you to take some sort of training. 
    A good firm will have a defined budged that will allow for adequate training of all there consultants.  Actually, it is in their best interest to keep you trained as you become more marketable.
  • What is the 'standard' number of billable hours you expect?
    What is the standard number of hours do they expect you to bill for in a giving year?  Is it 1800, is it 2000?  This makes a difference because if they tell you 2000+ then are telling you they EXPECT you to work over time (more on that below).
    A full year with no time off is 2080 hours (52 weeks * 40 hours).  But if you get 2 weeks vacation and 10 paid holidays you are only at 1920 (48 weeks * 40 hours). 
    Again, now keep in mind that the 'standard' number is just a rule of thumb, but it is good to know.  The higher the number, the less room in the budget they may have for when times get tough. 
    Also, keep in mind that during my 5 years consulting, my average work week was about 45-50 hours.  So if you are looking for the 40 hours and go home, you may not want to do consulting.
  • How are bonuses/raises calculated?
    Do they give bonuses/raises?  Are they based on billable hours?  If they are based on billable hours, that can be good and bad. 
    Example.  My old firm would give a flat bonus, but if you worked 200 extra hours a year you got a bump, if you worked 300 you got an extra bump, etc.
    This is good because i knew that the more i billed, the larger my bonus. 
    This was bad because i only got a sliver of the extra billable hours and in the long run did not pay off in the end.
  • How does overtime work?
    Some firms don't do anything special for overtime (as is the case in most salary positions).  However, some will actually pay you extra for your overtime (these places typically don't give bonuses).  Other places bank your overtime and build that into your vacation (worked out well for my buddy).
    But i would say that most common is that nothing happens with your overtime, except the companies profits increase at your expense.

Thing you have to accept as part of the job

  • The tech/environment will change with every new client
    With every new client/project your environment along with the technology will change.  For some people this is a show stopper, for others it is just another chance to learn.
    Keep in mind that if you work on site at the client you will be expected to follow ALL their rules.  So if they are business formal, you will be expected to dress in business formal.  If they say you cannot come in till 9 and must stay till 6, then that is what you must do.
    If you are not willing to accept this, then consulting may not be for you.
  • You may not always be working on 'cool/fun' tech
    Since each project may change technology you may not always be working on 'fun, cool' stuff.  You may go from doing cutting edge development on project to doing report writing on the next one. 
    If you are not willing to accept this, then consulting may not be for you.
  • You are the '***' of the client, at their mercy
    Since you are a 'hired gun' you are the mercy of the client.  Don't expect to have the same treatment as full timers (a lot of places today treat their consultants as part of the family, but not all).  Don't expect to get subsidized meals (if offered) or gym memberships, etc.
    Also, be ready to work in some of the worst spaces you can think of.  On place i worked the consultants all sat in a single 15-20 office.  They basically lined up desks along the wall and filled it with 6 people.  I felt bad for them :).
  • The people you will meet
    The coolest part is the people you will meet, the connections you will make.  This is great because networking is the best way to move ahead in this business.  I have meet some great people and have made some great contacts.

This was my 2cents to him.

Did I miss anything?  Am I wrong?  Let me know

Till next time,

Monday, January 07, 2008 10:27:00 PM UTC  #    Comments [0]    |  Trackback
 Saturday, December 22, 2007

1&1 VPS FAQ

http://www.faq.1and1.com/dedicated_servers/virtual_private_servers/windows_vps/general_information/index.html

 

1. install .Net 3.5, SQL Express 2005, MSSMSE

2. Modify the registry table to remove "mscorlib.tlb could not be loaded" http://kbalertz.com/918685/Error-message-install-Server-could.aspx

3. Open IIS to create the new web site.

4. Change the permission from "no script" to "script only"

5 Open MSSMSE to add "Network Service" login account and customized user login account.

6 Add a new user for the target db (better use the same name with the customized user login created in step 5)

7. Don't forget the grand the permission.

8. connection string for .Net 2.0 and above is like this:

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;

http://www.connectionstrings.com/default.aspx?carrier=sqlserver2005

9. Have to activate the Plesk to create a backup of VPS image manually, which will consume lots of resource though for the $29.99 plan.

Saturday, December 22, 2007 4:47:57 AM UTC  #    Comments [0]    |   |  Trackback
 Thursday, December 20, 2007
Thursday, December 20, 2007 4:23:16 AM UTC  #    Comments [0]    |  Trackback

http://msdn2.microsoft.com/en-us/library/dct97kc3.aspx

Both master pages and content pages can contain event handlers for controls. For controls, events are handled locally—a control in a content page raises an event in the content page, and a control in the master page raises an event in the master page. Controls events are not sent from the content page to the master page. Similarly, you cannot handle an event from a master page control in a content page.

In some cases, the same event is raised in both the content and the master page. For example, both pages raise Init and Load events. The general rule for how events are raised is that the initialization events are raised from the innermost control to the outermost one, and all other events are raised from the outermost control to the innermost one. It is helpful to remember that the master page is merged into the content page and treated as a control in the content page.

The following is the sequence in which events occur when a master page is merged with a content page:

  1. Master page controls Init event.

  2. Content controls Init event.

  3. Master page Init event.

  4. Content page Init event.

  5. Content page Load event.

  6. Master page Load event.

  7. Content controls Load event.

  8. Content page PreRender event.

  9. Master page PreRender event.

  10. Master page controls PreRender event.

  11. Content controls PreRender event.

The sequence of events in master and content pages rarely is important for you as page developer. However, if you are creating event handlers that depend on the availability of certain controls, you will find it helpful to understand the event sequence in master and content pages.

Thursday, December 20, 2007 3:42:19 AM UTC  #    Comments [0]    |   |  Trackback
 Wednesday, December 19, 2007
Wednesday, December 19, 2007 3:34:53 PM UTC  #    Comments [1]    |  Trackback
 Tuesday, December 18, 2007
1.250定律
拉德认为:每一位顾客身后,大体有250名亲朋好友。如果您赢得了一位顾客的好感,
就意味着赢得了250个人的好感;反之,如果你得罪了一名顾客,也就意味着得罪了250
名顾客。 在你的网站访客中,一个访客可能可以带来一群访客,任何网站都有起步和
发展的过程,这个过程中此定律尤其重要。
2.达维多定律
达维多认为,一个企业要想在市场上总是占据主导地位,那么就要做到第一个开发出新
产品,又第一个淘汰自己的老产品。 国内网站跟风太严重,比如前段时间的格子网,
乞讨网,博客网,一个成功了,大家一拥而上。但实际效果是,第一个出名的往往最成
功,所以在网站的定位上,要动自己的脑筋,不是去捡人家剩下的客户。同理,买人家
出售的数据来建站效果是很糟糕的。
3.木桶定律
水桶定律是指,一只水桶能装多少水,完全取决于它最短的那块木板。这就是说任何一
个组织都可能面临的一个共同问题,即构成组织的各个部分往往决定了整个组织的水平
。 注意审视自己的网站,是速度最糟糕?美工最糟糕?宣传最糟糕?你首先要做的,
不是改进你最强的,而应该是你最薄弱的。
4.马太效应
《新约》中有这样一个故事,一个国王远行前,交给三个仆人每人一锭银子,吩咐他们
:“你们去做生意,等我回来时,再来见我。”国王回来时,第一个仆人说: “主人
,你交给我们的一锭银子,我已赚了10锭。”于是国王奖励他10座城邑。第二个仆人报
告说:“主人,你给我的一锭银子,我已赚了5锭。” 于是国王例奖励了他5座城邑。
第三个仆人报告说:“主人,你给我的一锭银子,我一直包在手巾里存着,我怕丢失,
一直没有拿出来。”于是国王命令将第三个仆人的一锭银子也赏给第一个仆人,并且说
:“凡是少的,就连他所有的也要夺过来。凡是多的,还要给他,叫他多多益善。”这
就是马太效应。 在同类网站中,马太效应是很明显的。一个出名的社区,比一个新建
的社区,更容易吸引到新客户。启示是,如果你无法把网站做大,那么你要做专。作专
之后再做大就更容易。
5.手表定理
手表定理是指一个人有一只表时,可以知道现在是几点钟,而当他同时拥有两只表时却
无法确定。一个网站,你只需要关注你特定的用户群需求。不要在意不相干人的看法。
6.不值得定律
不值得定律:不值得做的事情,就不值得做好 不要过度seo,如果你不是想只做垃圾站
。不要把时间浪费在美化再美化页面,优化再优化程序,在你网站能盈利后,这些事情
可以交给技术人员完成。
7.彼得原理
劳伦斯.彼得认为:在各种组织中,由于习惯于对在某个等级上称职的人员进行晋升提
拔,因而雇员总是趋向于晋升到其不称职的地位。不要轻易改变自己网站的定位。如博
客网想变门户,盛大想做娱乐,大家拭目以待吧。
8.零和游戏原理
当你看到两位对弈者时,你就可以说他们正在玩“零和游戏”。因为在大多数情况下,
总会有一个赢,一个输,如果我们把获胜计算为得1分,而输棋为-1分,那么,这两人
得分之和就是:1+(-1)=0 不要把目光一直盯在你的竞争网站上,不要花太多时间抢
它的访客。我们把这些时间用来寻找互补的合作网站,挖掘新访客。
9.华盛顿合作规律
华盛顿合作规律说的是: 一个人敷衍了事,两个人互相推诿, 三个人则永无成事之日
。如果你看准一个方向,你自己干,缺人手就招。不要轻易找同伴一起搞网站,否则你
会发现,日子似乎越过越快了,事情越做越慢了。
10.邦尼人力定律
一个人一分钟可以挖一个洞,六十个人一秒种却挖不了一个洞。合作是一个问题,如何
合作也是一个问题。你需要有计划。
11.牛蛙效应
把一只牛蛙放在开水锅里,牛蛙会很快跳出来;但当你把它放在冷水里,它不会跳出来
,然后慢慢加热,起初牛蛙出于懒惰,不会有什么动作,当水温高到它无法忍受的时候
,想出来,但已经没有了力气。 如果你是soho,注意关注你的财务。不要等到没钱了
再想怎么挣,你会发现那时候挣钱更难。
12.蘑菇管理
蘑菇管理是许多组织对待初出茅庐者的一种管理方法,初学者被置于阴暗的角落(不受
重视的部门,或打杂跑腿的工作),浇上一头大粪(无端的批评、指责、代人受过),
任其自生自灭(得不到必要的指导和提携)。 做网站毕竟要遭遇这样的阶段,搜索引
擎不理你,友情链接找不到,访客不上门。这是磨练。
13.奥卡姆剃刀定律
如无必要,勿增实体。把网站做得简单,再简单,简单到非常实用,而不是花俏。
google的首页为什么比雅虎好?
14.巴莱多定律(Paredo 也叫二八定律)
你所完成的工作里80%的成果,来自于你20%的付出;而80%的付出,只换来20%的成果。
随时衡量你所做的工作,哪些是最有效果的。
15.马蝇效应
林肯少年时和他的兄弟在肯塔基老家的一个农场里犁玉米地,林肯吆马,他兄弟扶犁,
而那匹马很懒,慢慢腾腾,走走停停。可是有一段时间马走得飞快。 林肯感到奇怪,
到了地头,他发现有一只很大的马蝇叮在马身上,他就把马蝇打落了。看到马蝇被打落
了,他兄弟就抱怨说:”哎呀,你为什么要打掉它,正是那家伙使马跑起来的嘛!”
在你心满意足的时候,去寻找你的马蝇。没有firefox,不会有ie7,firefox就是微软
的马蝇之一。马蝇不可怕,怕的是会一口吃掉你的东西,像 ie当初对网景干的那样。
16.最高气温效应
每天最热总是下午2 时左右,我们总认为这个时候太阳最厉害,其实这时的太阳早已偏
西,不再是供给最大热量的时候了。此时气温之所以最高,不过是源于此前的热量积累
。你今天的网站流量,是你一个星期或更长时间前所做的事带来的。
17.超限效应(溢出效应)
刺激过多、过强和作用时间过久而引起心理极不耐烦或反抗的心理现象,称之为“超限
效应”。 别到别人论坛里发太多广告。别在自己网站上放太多广告。别在自己的论坛
里太多地太明显地诱导话题。
18.懒蚂蚁效应
生物学家研究发现,成群的蚂蚁中,大部分蚂蚁很勤劳,寻找、搬运食物争先恐后,少
数蚂蚁却东张西望不干活。当食物来源断绝或蚁窝被破坏时,那些勤快的蚂蚁一筹莫展
。“懒蚂蚁”则“挺身而出”,带领众伙伴向它早已侦察到的新的食物源转移。 不要
把注意力仅仅放在一个网站上,即使这个网站现在为你带来一切。你要给自己一些时间
寻找新的可行的方向,以备万一。
19.长尾理论
ChrisAnderson认为,只要存储和流通的渠道足够大,需求不旺或销量不佳的产品共同
占据的市场份额就可以和那些数量不多的热卖品所占据的市场份额相匹敌甚至更大。
对于搜索引擎,未必你需要一个热门词排在第一位,如果有一千个冷门词排在第一位,
效果不但一样,还会更稳定更长远。
20.破窗理论
栋建筑上的一块玻璃,又没有及时修好,别人就可能受到某些暗示性的纵容,去打碎更
多的玻璃。 管理论坛时,如果你发现第一个垃圾贴,赶紧删掉他吧。想想:落伍现在
为什么那么多××贴?现在控制比最初控制难多了。
21.“羊群效应”,
又称复制原则(Copy Strategy)一个羊群(集体)是一个很散乱的组织,平时大家在一起
盲目地左冲右撞。如果一头羊发现了一片肥沃的绿草地,并在那里吃到了新鲜的青草,
后来的羊群就会一哄而上,争抢那里的青草,全然不顾旁边虎视眈眈的狼,或者看不到
其它地方还有更好的青草。不要轻易跟风,保持自己思考的能力。
22.墨菲定律
如果坏事情有可能发生,不管这种可能性多么小,它总会发生,并引起最大可能的损失
。除非垃圾站,否则不要作弊,对搜索引擎不要,对广告也不要。
23.光环效应
人们对人的某种品质或特点有清晰的知觉,印象比较深刻、突出, 这种强烈的知觉,
就像月晕形式的光环一样,向周围弥漫、扩散,掩盖了对这个人的其他品质或特点的认
识。不要轻易崇拜一个人或者公司、一个概念、一种做法。
24.蝴蝶效应
一只亚马逊河流域热带雨林中的蝴蝶,偶尔扇动几下翅膀,两周后,可能在美国德克萨
斯州引起一场龙卷风。不管你做什么,网站或者其他,你都应该关注新闻。机遇或者灾
难可能就在那。
25.阿尔巴德定理
一个企业经营成功与否,全靠对顾客的要求了解到什么程度。 我赞同别人的点评:看
到了别人的需要,你就成功了一半;满足了别人的需求,你就成功了全部。尤其是做网
站。
26.史密斯原则
如果你不能战胜他们,你就加入到他们之中去。 不要试图做孤胆英雄。如果潮流挡不
住,至少,你要去思考为什么。

Tuesday, December 18, 2007 5:08:09 PM UTC  #    Comments [0]    |   |  Trackback
 Thursday, November 29, 2007
Thursday, November 29, 2007 4:50:40 AM UTC  #    Comments [0]    |   |  Trackback
 Wednesday, November 28, 2007

http://forums.asp.net/t/1127834.aspx

 

you can use the following javascript function to set the active tab: 

function SetActiveTab(tabControl, tabNumber)
{
  var ctrl = $find(tabControl);
  ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);
}

tabControl: ID from the TabContainer Controls
tabNumber: Number of the new Tab (starting at 0)

 

Or

 

$find('<%=TabContainer1.ClientID%>').get_activeTabIndex();

and

$find('<%=TabContainer1.ClientID%>').set_activeTabIndex(2);

Wednesday, November 28, 2007 3:54:46 AM UTC  #    Comments [0]    |  |  |   |  Trackback
 Monday, November 19, 2007
Copyright © 2008 Kevin Mocha. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: