Wednesday, September 29, 2010

Removing wgatray from Windows XP...

1) Stop the process
    - To start Task Manager you need to click on the Start button and from the Start menu select 'Run' and type in 'taskmgr' command. Hit 'OK'.
    - Now you need to click the 'Processes' tab and click on the 'wgatray.exe' process.
    - After the wgatray.exe is highlighted, you have to press 'End Process' and after wgatray.exe is closed, you can close the TaskManager.

2) Delete / Remove wgatray file from your computer
    - Go to 'My Computer' and browse to both 'C > Windows > System32' and 'C > Windows > System > dllcache' folders.
    - Locate the 'wgatray.exe', right-click it and select delete.
    - Now you need to right-click on the Recycle Bin and press 'Empty the Recycle Bin', so that wgatray.exe files are completely deleted.

3) Remove entry from registry
    - Click on Start button and select Run.
    - Type in 'regedit' and hit the OK button.
    - Go to the following registry entry : 'HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows NT > CurrentVersion > Winlogon > Notify'.
    - In here you have to delete the Winlogon folder.
    - Close Registry Editor and Wgatray EXE has been completely removed from your computer.

Tuesday, September 28, 2010

IE9: Microsoft reverse statement...

Question:
When Microsoft releases Internet Explorer 9, will it require Windows 7 Service Pack 1?

Old answer:
Yes. Internet Explorer 9 will require Windows 7 Service Pack 1 (SP1). Therefore, organizations must plan, pilot, and deploy Internet Explorer 9 as part of or after a Windows 7 SP1 deployment.

New answer:
No. Internet Explorer 9 will install on systems that have either Windows 7 RTM or Windows 7 with Service Pack 1 (SP1) installed.

What's next???

More info at arstechnica.com.

Bing Rewards: another attempt to increase search share...

On the heels of canceling its Bing Search Cashback program, Microsoft is trying its hand at another attempt to increase search share using rewards.

The newest program, Bing Rewards, is similar to credit card or airline loyalty programs that offer users points that can be redeemed for products, gift cards or charitable donations, Search Engine Land explained.

Points don’t come cheap, however. To participate,
1) users need to be running Windows
2) to sign up for a Windows Live ID
3) use Internet Explorer
4) and have the Bing Bar toolbar.

No other browsers or operating systems are allowed.

More info at zdnet.com.

Note:
Available for US residents only.

WordPress: default blogging platform for Windows Live...

Microsoft and WordPress.com announced Monday that WordPress will be the default blogging platform for Windows Live.

The partnership will allow Windows Live Spaces customers to upgrade to WordPress.com, let WordPress users notify friends about blog posts via Messenger, and let Windows Live users easily create new blogs on WordPress.com.

"WordPress powers over 8.5 percent of the web, is used on over 26 million sites, and WordPress.com is seen by over 250 million people every month," Microsoft said in a blog post. "So rather than having Windows Live invest in a competing blogging service, we decided the best thing we could do for our customers was to give them a great blogging solution through WordPress.com."

Microsoft currently has 30 million people using its Windows Live Spaces blogging platform. Those users can port their blog posts, comments, and photos to WordPress, and redirect their old Spaces URLs to the new blog, Microsoft said.

More info at pcmag.com.

Friday, September 24, 2010

Transparent box with non-transparent text css...

    div.box
{
/* Any properties you'd want the box to have. */
/* Would probably be position, dimension type stuff. */
border: 1px solid #000000;
width: 500px;
height: 500px;
position: relative;
}

div.box_contents
{
background-color:transparent;
height: 100%;
position: relative;
width: 100%;
z-index: 101;
}

div.box_background
{
background-color: blue;
height: 100%;
opacity: 0.5;
filter:alpha(opacity=50); /* IE's opacity */
position: absolute;
left: 0px;
top: 0px;
width: 100%;
z-index: 100;
}
Opacity effect accross browsers
    opacity: 0.5;
filter:alpha(opacity=50); /* IE's opacity */

Wednesday, September 22, 2010

Kernel exploit on 64-bit Linux...

Linux is well-known for its security advantages over many other operating systems, but that doesn't mean it's immune to problems.

A Linux kernel flaw first discovered earlier this month, for example, gives hackers a way to not just gain root privileges in 64-bit Linux operating systems but also to leave a "back door" open for further exploitation later.

CVE-2010-3081, as the high-profile vulnerability is known, affects virtually all users of 64-bit Linux distributions, including RHEL, CentOS, Debian, Ubuntu, CloudLinux, SuSE and more. It was introduced into the Linux kernel back in 2008, and a hacker by the name of 'Ac1db1tch3z' last week published details on exploiting it.

Click here for more info.

Note:
Text copied from PCWorld news.

Tuesday, September 21, 2010

Using linear gradient effect accross browsers...

    filter: progid:DXImageTransform.Microsoft.gradient(gradienttype=1, startColorstr='#739AC5', endColorstr='#ffffff'); /* for IE */
background: -webkit-gradient(linear, left center, right center, from(#739AC5), to(#fff)); /* for webkit browsers */
background: -moz-linear-gradient(left, #739AC5, #fff); /* for firefox 3.6+ */
Note:
Click here for codes and colour table.

Vulnerability in the ASP.NET encryption...

The Impact of the Vulnerability
ASP.NET uses encryption to hide sensitive data and protect it from tampering by the client. However, a vulnerability in the ASP.NET encryption implementation can allow an attacker to decrypt and tamper with this data.

But what can the attacker do with this capability? Part of the answer depends on the ASP.NET application being attacked. For example, if the ASP.NET application stores sensitive information, such as passwords or database connection strings, in the ViewState object this data could be compromised. The ViewState object is encrypted and sent to the client in a hidden form variable, so it is a possible target of this attack.

If the ASP.NET application is using ASP.NET 3.5 SP1 or above, the attacker could use this encryption vulnerability to request the contents of an arbitrary file within the ASP.NET application. The public disclosure demonstrated using this technique to retrieve the contents of web.config. Any file in the ASP.NET application which the worker process has access to will be returned to the attacker.

How the Vulnerability Works
To understand how this vulnerability works, you need to know about cryptographic oracles. An oracle in the context of cryptography is a system which provides hints as you ask it questions. In this case, there is a vulnerability in ASP.NET which acts as a padding oracle. This allows an attacker to send chosen cipher text to the server and learn if it was decrypted properly by examining which error code was returned by the server.

By making many requests the attacker can learn enough to successfully decrypt the rest of the cipher text. The attacker can then alter the plain text and re-encrypt it as well.

The Workaround - Silencing the Oracle
The workaround for this vulnerability is to use the customErrors feature of ASP.NET to configure applications to return the same error page regardless of the error encountered on the server.

By following the steps in the advisory to map all error messages to a single error page, you make it difficult for the attacker to distinguish between the different types of errors, effectively limiting access to the oracle.

How to Detect Vulnerable ASP.Net Applications
Script can be obtain from the original article.

Note:
Text copied from blogs.technet.com.

The vulnerability affects all versions of .NET Framework. Click here for detail.

Monday, September 20, 2010

64-bit Adobe Flash Player for Linux is back...

Adobe has finally made the announcement a lot of Linux users have been waiting for, a 64-bit version of the Adobe Flash Player is again available. Not only that, it's a significant improvement over previous releases.

This should appease most Linux users and it's clear that Adobe is committed to creating a native 64-bit plugin. A stable version should be coming soon now.

Unfortunately, although part of the announcement was support for hardware acceleration in Internet Explorer 9, there is still no support whatsoever for GPU acceleration on Linux.

Note:
Text copied from Softpedia news.

Wednesday, September 8, 2010

Numeric textbox javascript...

    <input type='text' onkeydown='text_keydown(event)' />

<script language='javascript' type='text/javascript'>
function text_keydown(e)
{
var key;
document.all ? key = e.keyCode /*IE*/ : key = e.which /*FF*/;
if(!(key > 47 && key < 58) && key != 8 && key != 37 && key != 39 && key != 16 && key != 46)
{
cancelevent(e);
}
}

function cancelevent(e)
{
if(window.event) // IE
{
window.event.returnValue = false;
}
else // FF
{
e.preventDefault();
}
}
</script>

Tuesday, September 7, 2010

What's new in Ubuntu 10.10...

1) Simpler Installer.
Ubuntu 10.10 is expected to use a new installer that makes the installation process simpler than ever. Startup options are now placed right in the installer itself, and they include just two options: Try Ubuntu and Install Ubuntu. A simplified partitioner, meanwhile, lets users choose between automatically using the whole disk and manual partitioning, while a new Wireless Network Selection page will be added as well. These features will be particularly helpful for newer Ubuntu users.

My response:
I've started with 6.10 (Edgy Eft) and never felt it's difficult to install Ubuntu (it's the same 6 clicks process, except for the partitioning part might be a little bit tricky for newbie). Overall installing desktop Linux couldn't be more difficult than Windows unless if you're talking about pre Red Hat 7 era in 90s.

2) Processor Support.
It sounds like the Maverick Meerkat will not run on processors older than i686, or anything before Intel's P6 microarchitecture. For most business users this probably won't be an issue, but it could affect some occasional users of older machines.

My response:
I don't need to worry about this because I don't have that kind of old machine. :)

3) Default Environment and Applications.
Ubuntu 10.10 Beta uses version 2.6.35.3 of the Linux kernel, which includes numerous security enhancements over previous versions. It also updates the GNOME desktop environment to version 2.31.

Among application changes, meanwhile, is that Firefox 3.6.8 will be the default, as will OpenOffice 3.2.1, for example. Photo tool F-Spot has been replaced with Shotwell, while a new sound indicator has been enhanced to include music player controls.. The Evolution mail and collaboration software will be updated to the 2.30.2 version, which reportedly is much faster than the one in Ubuntu 10.04 LTS, or Lucid Lynx.

My response:
I never use F-Spot and Evolution mail. For image editing, Gimp is my preference. Sound indicator to include music player controls sounds cool to me.

4) The Ubuntu Software Center
In version 10.10, the Ubuntu Software Center--the tool for browsing, installing and removing software on Ubuntu--will gain "Featured" and "What's New" choice icons on the front page, along with a "History" tab displaying recently installed software. It is also said to be faster and more responsive. Taken together, these improvements promise to make it much easier to track and find new software options.

My response:
This should be interesting. Might change to this instead of Synaptic.

5) Multitouch
Making the biggest splash, of course, will be the new multitouch and gesture capabilities, which will apparently make it possible for basic gestures to be chained, or composed, into more sophisticated "sentences." Toward that end, Canonical has created an open source gesture recognition engine and defined a gesture API that provides a way for applications to respond to users' gestures.

Canonical is currently targeting the Dell XT2 as a development environment for this new feature, but by release it expects it to be compatible with a range of devices from major manufacturers, and with add-ons like Apple's Magic Trackpad. Needless to say, this will pave the way toward a host of new capabilities on the Linux desktop and beyond.

My response:
Unfortunately I don't have any hardware with the capability to benefit this feature.

Note:
Text copied 97% from PCWorld news with a reference to The Fridge.

Monday, September 6, 2010

VB.NET vs C#, why bother? We're .NET developers after all...

I can't believe that people are still debating on this topic. While searching for anonymous methods in VB.NET, I came across to this article "Top 10 reasons VB.NET is better than C#". It was posted on August 23rd 2004 and the last comment was on August 31st 2010!!!

Update:
Did a search further with keyword "vb.net vs c#" and found out that there's another article from the same person on the same day, but this time it's the other way around. "Top 10 reasons C# is better than VB.NET".

Exposing DTO to javascript in ASP.NET...

This post is a continuity from my previous post related to Calling a webservice from javascript in ASP.NET 2.0. Fundamentally it's sharing the same concept. This time I've written the code in ASP.NET 3.5 (Visual Studio 2008). There's no prerequisite required compare to when I did it in ASP.NET 2.0 (Visual Studio 2005).

Once I knew how to call a webservice from javascript in ASP.NET (regardless of version). I've search google to check whether it's possible to pass an object as a parameter to webservice method. Indeed it is possible to do that, but I must make sure that the object should be simple enough without any business logic and with limited behaviour. The object known as Data Transfer Object or in short DTO. Now here's the step by step on how to do it.

1) Using Visual Studio 2008, create new web site. Select ASP.NET Web Site.

2) To create DTO object, add new class under App_Code folder. Lets name it as Student. Paste the code below.
    using System;

///
/// Summary description for Student
///

public class Student
{
public Student()
{
}

public string Id
{
get;
set;
}

public string Name
{
get;
set;
}
}
3) Create new webservice call MyWebService. Add System.Web.Script.Services namespace then add GenerateScriptType and ScriptService attribute to the webservice class. Notice that what I did here is almost the same as my previous post. The only extra code is at line 7 which is to expose Student class to javascript.
    ...
using System.Web.Script.Services;

///
/// Summary description for MyWebService
///

[GenerateScriptType(typeof(Student))]
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class MyWebService : System.Web.Services.WebService
{
...
}
4) Add two methods call GetStudents and TestSubmit. GetStudents method will return a list of students to the caller. Since I want to return it as a JSON object, I've set the ResponseFormat to JSON.
    ...
[WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
public List<Student> GetStudents()
{
var students = new List<Student>();

for (int x = 0; x < 10; x++)
{
students.Add(new Student
{
Id = x.ToString(),
Name = "Name" + x.ToString()
});
}

return students;
}

[WebMethod]
public string TestSubmit(Student student)
{
return String.Format("You've submitted Student object with Id: {0} and Name: {1}", student.Id, student.Name);
}
5) Go to Default.aspx, add ScriptManager (again another same step as my previous post in ASP.NET 2.0).
    ...
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference InlineScript="true" Path="~/MyWebService.asmx" />
</Services>
</asp:ScriptManager>
...
6) Now add the html control
    ...
<div>
<input id="btnLoad" type="button" value="Get Students" onclick="javascript:btnLoad_Click();" />

<input id="txtId" type="text" /><input id="txtName" type="text" />
<input id="btnSubmit" type="button" value="Submit" onclick="javascript:btnSubmit_Click();" />

<table id="myTable" border="1" cellpadding="1" cellspacing="1"></table>
</div>
...
7) and the javascript
    ...
<script language="javascript" type="text/javascript">
function btnLoad_Click()
{
try
{
MyWebService.GetStudents(OnGetStudentsComplete);
}
catch(e)
{
alert("error " + e);
}
}

function OnGetStudentsComplete(result)
{
var htmlVal = "";

for(var x=0; x<result.length; x++)
{
htmlVal += "<tr><td>" + result[x].Id + "</td><td>" + result[x].Name + "</td></tr>";
}

$get("myTable").innerHTML = htmlVal;
}

function btnSubmit_Click()
{
try
{
var stu = new Student();
stu.Id = $get("txtId").value;
stu.Name = $get("txtName").value;

MyWebService.TestSubmit(stu, OnTestSubmitComplete);

var htmlVal = $get("myTable").innerHTML;
htmlVal += "<tr><td>" + stu.Id + "</td><td>" + stu.Name + "</td></tr>";
$get("myTable").innerHTML = htmlVal;
}
catch(e)
{
alert(e);
}
}

function OnTestSubmitComplete(result)
{
alert(result);
}
</script>
Now I have a web site that can call a webservice and passing an object as a parameter via javascript.

Sunday, September 5, 2010

Evolution of data query in C#...

One of the most common operation in programming is data query. In C# 1.2, normally I would use a custom collection class that derived from System.Collections. But for sake of example here, I'll show it with an ArrayList instead.

Here's a class that'll become an element of the collection (yes, I know Auto-Implemented Properties).
    public class Student
{
private int _id;
private string _name;
private string _gender;

public Student()
{
}

public int Id
{
get { return _id; }
set { _id = value; }
}

public string Name
{
get { return _name; }
set { _name = value; }
}

public string Gender
{
get { return _gender; }
set { _gender = value; }
}
}
This is how I normally code in C# 1.2 (.NET Framework 1.1) with an ArrayList.
    private ArrayList SomeFilterMethod(ArrayList myList)
{
ArrayList result = new ArrayList();

for (int x = 0; x < myList.Count; x++)
{
if (((Student)myList[x]).Gender == "Male")
{
result.Add(myList[x]);
}
}

return result;
}
Generic list with action and predicate was introduced in C# 2.0 (.NET Framework 2.0). This is how my code will look like.
    private List<Student> SomeFilterMethod(List<Student> myList)
{
return mylist.FindAll(GetMaleStudents);
}

private bool GetMaleStudents(Student item)
{
return item.Gender == "Male";
}
Not to forget an anonymous methods.
    private List<Student> SomeFilterMethod(List<Student> myList)
{
return mylist.FindAll( delegate(Student item) { return item.Gender == "Male"; } );
}
In C# 3.0 (.NET Framework 3.5), there's LINQ with 2 flavours.
1) Lambda Expression
    private List<Student> SomeFilterMethod(List<Student> myList)
{
return mylist.FindAll( item => item.Gender == "Male" );
}
2) Query Expression
    private List<Student> SomeFilterMethod(List<Student> myList)
{
return (from student in mylist
where student.Gender == "Male"
select student).ToList<Student>();
}
Between the two, personally I prefer the former.

Saturday, September 4, 2010

Huawei modem undetected on Ubuntu 10.04...

Scenario:
Plug-in modem, Ubuntu detect it as data storage only instead of modem. Only happen on Ubuntu 32bit, working as expected on 64-bit version.

Solution:
Install usb-modeswitch package.
    $ sudo apt-get install usb-modeswitch
Note:
Tested on Ubuntu 10.04 32-bit Desktop and Netbook Edition.

Wednesday, September 1, 2010

Calling a webservice from javascript in ASP.NET 2.0...

Prerequisite:
In Visual Studio 2005, to make a web project template available, you need to upgrade to SP1. The "other alternative" is to install VS80-KB915364-X86-ENU.exe and WebApplicationProjectSetup.msi. If you choose SP1 than ignore the "alternative" way.

1) For Ajax-Enabled Web Site, install ASP.NET Ajax 1.0.

2) Create new ASP.NET Ajax-Enabled Web Site.

3) Add reference System.Web.Extensions ver 1.0.61025.0.

4) On server side, create new WebService, add System.Web.Script.Services namespace and add ScripService attribute to your webservice class.
    ...
using System.Web.Script.Services;
...

[ScriptService]
public class MyWebService : WebService
{
public MyWebService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
5) On client side, create new web form and add ScriptManager to the aspx file that pointing to your webservice (MyWebService.asmx).
    ...
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference InlineScript="true" Path="~/MyWebService.asmx" />
</Services>
</asp:ScriptManager>
...
6) Add an html button and its eventhandler.
    ...
<input id="btnOk" type="button" value="Ok" onclick="javascript:btnOk_Click();" />
...

<script language="javascript" type="text/javascript">
function btnOk_Click()
{
try
{
MyWebService.HelloWorld(OnHelloWorldComplete);
}
catch(e)
{
alert("error " + e);
}
}

function OnHelloWorldComplete(result)
{
alert(result);
}
</script>
Done!!! Your first Ajax-Enabled Web Site.

Here's the full source code:
MyWebService.asmx.cs
    using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

///
/// Summary description for MyWebService
///

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class MyWebService : WebService
{
public MyWebService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
Default.aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<!-- to include webservice proxy, set inlinescript=true, it's much more easier compare to adding script src=webservice.asmx/js -->
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference InlineScript="true" Path="~/MyWebService.asmx" />
</Services>
</asp:ScriptManager>

<div>
<input id="btnOk" type="button" value="Ok" onclick="javascript:btnOk_Click();" />
</div>
</form>
</body>
</html>

<script language="javascript" type="text/javascript">
function btnOk_Click()
{
try
{
MyWebService.HelloWorld(OnHelloWorldComplete);
}
catch(e)
{
alert("error " + e);
}
}

function OnHelloWorldComplete(result)
{
alert(result);
}
</script>