Posts

Showing posts from 2009

JQuery binding / unbinding event in Firebug

This article provides a good overview of what's going on in Jquery during bind/unbind of an event in firebug.
http://ajaxian.com/archives/jquery-bondage#comments

WCF: This collection already contains an address with http scheme.

User control event/viewstate missing during postback

User control event/viewstate missing during postback Question : Some of your web control's events goes missing or cannot be caught when you load it in a user control?Answer: Always use the Control.UniqueID generated for you by ASP.Net when assigning it to a NAME property of your control. The complete Control.UniqueId is available when you assess this in OnPreRender stage. Check your Control.UniqueID which is render into the NAME property of your control on a HTML page. ASP.Net keeps track of the control using Control.UniqueID which makes events / viewstate works. If you override your UniqueID (for javascript manipulation) you might get this problem.
Why does it work on your Page but not in user control? On a page, when your control is renders, it probably use name like “MyControl” but in user control this is automatically change to “ctl$_MyControl”. ASP.Net is no longer able to resolve your control id if you override your Control.ID. For example, I created a control and this is …

ASP.Net and JQuery

Anyone looking to get JQuery working on ASP.net can try this link :

http://blog.dreamlabsolutions.com/post/2009/02/24/jQuery-document-ready-and-ASP-NET-Ajax-asynchronous-postback.aspx

It describes everything you need to know to get it working together.

Using JQuery to retrieve elements outside of IFrame

Let's say you have a AJAX-enabled Dialog box and you used IFrame to load a page (php / aspx) . Retrieving any element outside of this page requires asking JQuery to go out of its scope.
You can use the following code to retrieve element outside of your IFrame.
$("#myDiv", top.window)

ASP.net ListView

The following examples give an overview of how to use ListView.
Simple ListView

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JL.aspx.cs" Inherits="JL" %>
<%@ Register Assembly="SystemCore.CommonAppControls" Namespace="SystemCore.CommonAppControls" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:ListView ID="ListView1" runat="server"> <LayoutTemplate> <asp:PlaceHolder ID="itemPlaceholder" runat="server" /> </LayoutTemplate> <I…

SSIS package throwing "the type initializer for 'System.Data.SqlClient.SqlConnection'

SSIS package throwing "the type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception"
I'm running SSIS package which references an assembly which calls a WCF web service. Everytime i run it, i get this weird "the type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception".
So i decided to check on app.config setting in the following files located in C:\Program Files\Microsoft SQL Server\90\DTS\Binn folder.
a) DTExec.exe.config
b) DtsDebugHost.exe.config
c) dtshost.exe.config
It has nothing to do with these configurations.
Solution
Try installing Microsoft .Net Framework 3.0 (in my case) and it solve my issue.



TransactionScopeOption vs TransactionScopeOptions

TransactionScopeOption in System.Transaction

What is the differences between TransactionScopeOptions when we use it to create TransactionScope. We have the following option at our disposal.

1. TransactionScopeOption.Required

TransactionScope created here is dependent on the root TransactionScope.

2. TransactionScopeOption.RequiresNew

Creates an entirely new TransactionScope

3. TransactionScopeOption.Suppress

TransactionScope created here is independent of root TransactionScope.

Code below shows an example of how transactionScope takes effect when you stop your application in s1.Complete();
Data gets committed in TransactionScopeMixRequiresNew and TransactionScopeMixSupress method but not TransactionScopeMixRequires.


using (TransactionScope s1 = new TransactionScope(TransactionScopeOption.Required))
{
TransactionScopeMixRequires();

TransactionScopeMixRequiresNew();

TransactionScopeMixSupress();

/// if you stop your application here
/// TransactionScopeMixRequiresNew and TransactionScopeMixSupress…

Testing Code Contracts

Normally you would add reference to System.System.Diagnostics.Contracts to define your code contracts. To test it, here's how you do it.
Download Contract checker from the following url http://research.microsoft.com/en-us/downloads/4ed7dd5f-490b-489e-8ca8-109324279968/default.aspx
Install it and then open your Visual Studio 2010, goto Project Explorer's Properties. You are able to locate "Code Contracts" you're good to go :)

Nunit2.5 giving System.NullReferenceException when you're trying to add assembly?

Create your NUnit GUI project, ("C:\Program Files\NUnit 2.5\bin\net-2.0\nunit.exe") and then drag + drop your assembly into NUnit. That should do it. :) It is that easy.

Ferdinand : Scalable Query Result Caching for Web Applications

Summary : Uses disk caching method to enhance performance for database application.
Users connect directly to a proxy. Each proxy consist of STATIC web cache. These servers are connected to each other via DHT and commmuicate with each other using publish / subscribe infrastructure.
If a request is in the cache, it is retrieve immediately. If not, it is query from database. Cache is expected to be huge, therefore disk caching method is used.
Ferdinand uses database template request and offline analysis to gurantee consistency of data in database. Notification is sent to master group and everybody synchronize their data.
Prototype implementation
Apache as the web server.
MySQL - webservier
Ferdinand - custom JDBC driver
Pastry - DHT's related task.
Scribed - Publish / Subscribe component

Cloud computing and Data Analysis.

Daniel Abadi in Data Management In the Cloud concludes that cloud computing is more suitable for large scale data analysis as oppose to transactional based system. Thus more research is expected in this area.
Part of the reason why are as follows:-
1. Transactional application does not necessarily adopt a share nothing model.
2. Maintaining ACID properties for transaction over cloud is complex.

More research in cloud computing's database evolve around the following areas: a) fault tolerance - continue query execution in the advent of failure b) heterogeneous cluster c) easy of use


Installing PHP on Apache 2.2.11 (Win32) PHP/5.2.5

Please download your Apache server and PHP. I'm assuming you installed your PHP into C:\PHP folder.

Please modify your httpd.conf file located in your conf folder with the following settings.
LoadModule php5_module "c:/php/php5apache2_2.dll" AddType application/x-httpd-php .php
Restart your server. That's it.

Apache Configuration
Sample using Redirect
Redirect /myservice http://localhost:8080/service Sample using Alias
Alias /svc c:/test/appfolder Allow from all



Building Hadoop on Windows

Hadoop requires the following application :-

1) Ant (unzip and set PATH to point to this folder)

2) JDK (unzip and set PATH to point to this folder). I'm using JDK 1.6 Update 14 for this build.

3) Cygwin (svn + openssh)

Download hadoop source code using svn from the following url:

http://svn.apache.org/repos/asf/hadoop/core/trunk

Go to the folder that you've download and build by typing

ant (Press enter)

That's all.

Configure PHP on Window 7 IIS

Assuming that you have downloaded and unzip php-5.2.9-2-Win32.zip to c:\php5.

Here's how you configure PHP

1. Start IIS -- Start->Run->Inetmgr

2. Switch to Feature View, then click on Handler Mappings.

3. Add Script Map and use the following configuration

a) Request Path = *.php
b) Executable = C:\php5\php5isapi.dll
c) Name : PHP_SCRIPT (You can use other name if you want)

4. Try running your PHP. That's it. (You might want to do a iisreset).


I've enable ALL World Wide Web Services ---> Application Development Features ---> ISAPI Extension & ISAPI Filters ON in Turn Windows features on or off.


If you face issue connecting to mysql :-

a) Try troubleshoot using phpinfo(); Try to see if you have configure mysql correctly.

b) you can copy php_mysql.dll & php_mysqli.dll to c:\windows\system32;

DataTable does not have AsEnumerable

I have problem locating my AsEnumerable extension method in my DataTabe (System.Data). Thank god for this post by Angel
(http://blogs.msdn.com/angelsb/archive/2007/02/23/does-not-contain-a-definition-for.aspx)

I was able to find this method once i have added reference to the following assembly.

C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll

Try to do a dummy Build and you should be able to get it.

Building IKVM Source

Building IKVM Source

Setup

1. Download IKVM source code from http://sourceforge.net/project/showfiles.php?group_id=69637
2. Download classpath-0.95 from (http://www.frijters.net/classpath-0.95-stripped.zip)
3. Download openjdk6-b12 from (http://www.frijters.net/openjdk6-b12-stripped.zip)

Unzip openjdk6-b12 and classpath-0.95 into the unzipped IKVM Source. For example

ikvm-0.38.0.2
--- classpath-0.95
--- openjdk6-b12

Tool required (Other version of these tools might work) :-

1. Nant (i used 0.86 Beta1)

2. JDK 1.6 Update 13 (or lower)

3. VS 2008 or 2005

4. .Net Framework in particular (cl - vc compiler, ilasm)


To Compile
----------------------------------
1. Run nant to compile the required assembly

2. Use VS2008 to build IKVM source (CTRL + Shift + B)

That's it.

Example JQuery event when posting Form using multipart/form-data

JQuery event to use once your form is fully posted to the server


$(document).ready(function()
{
$("#target_upload").load(function ()
{
//// Put in code to execute after the iframe is loaded or posted ////
});

});

Sample of your Form :-


<form id="uploadPhotoFrm" enctype="multipart/form-data" action="upLoaderPhoto.php" method="POST" onsubmit="return true;" target="target_upload">

<iframe id='target_upload' name='target_upload' src='' style='width:1px;height:1px;border:0'></iframe>

<li> <input id="uploadedfile" type="file" title="Upload a file to showcase your portfolio" size="20" name="uploadedfile"/>
</li>

<li> <input type="submit" name="subBtn" class="standardButton" value="Upload" onclick="uploadImageCmd();">…

Unity - Dependency Injection Types

You can use RegisterType or App.config to achieve the same objectives.

static void Main(string[] args)
{
IUnityContainer container = new UnityContainer();
UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
section.Containers.Default.Configure(container);


//// You can override with container.RegisterType();


CoreService svc = container.Resolve();
svc.ExecuteService();
}


Sample Service classes



public class CoreService
{
[Dependency]
public IService MyService { get; set; }

public void ExecuteService()
{
MyService.SayHello("Jeremy");
}

}

public class CustomerService : IService
{

string IService.SayHello(string Username)
{
return "Customer Service " + Username;
}
}


















Sample App.Config File


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
Sample App.Config





type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection,
Microsoft.Practices.Unity.Configuration" />










Passing Parameter from C# to IronPython

Code in Python

/////////////////////////////////////////////////

def calc(a, b):
return a+b

print calc(x,y)

/////////////////////////////////////////////////

C# code to pass parameter into the IronPython code

ScriptScope ScriptingScope = null;
ScriptEngine ScriptingHostingEngine = null;
ScriptingHostingEngine = IronPython.Hosting.Python.CreateRuntime().GetEngine("python");
ScriptSource ScriptRequest = ScriptingHostingEngine.CreateScriptSourceFromFile("c:\\del\\expression\\ScriptingTest\\ConsoleApplication1\\Program.py");
ScriptingScope = ScriptingHostingEngine.Runtime.CreateScope();
ScriptingHostingEngine.SetVariable(ScriptingScope, "x", 100);
ScriptingHostingEngine.SetVariable(ScriptingScope, "y", 200);
ScriptRequest.Execute(ScriptingScope);

Cool way to extract PropertyInfo

var VarPropertyEnum = from ReflectionEntity in Source.GetType().GetProperties()
 select new { ReflectionEntity.Name, PropertyValue = ReflectionEntity.GetValue(Source, null).ToString(), PropertyDataType = ReflectionEntity.PropertyType };
However this only works if you have a simple data type.  :(

Cool way to add existing .Net DLL into Silverlight Project

I found this information from this link 
http://www.netfxharmonics.com/2008/12/Reusing-NET-Assemblies-in-Silverlight
To summarize :-
1.ildasm MyClass.dll /out:MyClass.il
Disassemble your code and change the mscorlib version to 2:0:5:0; 
.assembly extern mscorlib  {  .publickeytoken = (7C EC 85 D7 BE A7 79 8E ) // .z\V.4..  .ver 2:0:5:0 }
}
You also need to change the public token key 7C EC 85 D7 BE A7 79 8E
        Then you may need to remove public key from your generated IL file 
 .publickey = (00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00   // .$..............                 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00   // .$..RSA1........                 B5 FC 90 E7 02 7F 67 87 1E 77 3A 8F DE 89 38 C8   // ......g..w:...8.                 1D D4 02 BA 65 B9 20 1D 60 59 3E 96 C4 92 65 1E   // ....e. .`Y>...e.                 88 9C C1 3F 14 15 EB B5 3F AC 11 31 AE 0B D3 33   // ...?....?..1...3                 C5 EE 60 21 67 2D 97 18 EA 31 A8 AE BD 0D A0 07   //…

RodentStore (Phillipe Cudre Mauroux, Eugene Wu and Samuel Madden)

Increase application database domain requires substantial amount of re-engineering effort such as caching or transaction. RodentStore is an adaptive storage engine that uses declarative storage algebra to specify logical schema in a disk. Central to this idea are

1) ability to support table using different physical representation
2) use storage algebra to specify data layout.

Database Administrator --------> Algebra sepcification -----> Algebra Interpreter -----> Storage Backend.

Interesting part of this artcile is RodentStore is not limited to SQL database but ORM like Django / Ruby on Rails.

Physical Layout

Challenges faced

a) Translating Algebra expression with array completion

b) Storage rendering algorithm is 'declarative'. --- leaving many item open for example how data are stored. Deciding what to do when a mix of data placement algorithm for example old and new is used.

Adaptive storage engine is going to be an interesting project especially in porting database engi…

F# / C# - from Chris Smith's Blog on F# tutorial .....

F# Code

#light

let square x = x * x

let numbers = [1 .. 10]

let squares = List.map square numbers

printfn "N^2 = %A"squares

open System

Console.ReadKey(true)


C# Code


using System;using System.Linq;class Program{ static void Main() { Func square = x => x * x; int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; var squares = numbers.Select(square); Console.WriteLine("N^2 = {0}", squares.Aggregate("", (s, i) => s + " " + i)); Console.ReadKey(true); }}

$post / $each with JQuery

Let's say you want to do a JQuery $post and then use $each to traverse through the result. this exampel show how it can be accomplished.



Example JSON data set generated using Php or other scripting languages :-

{"items":[{"memberID":"1","memberName":"Julia Boris","profileInfo":"jaya jaya"},{"memberID":"1","memberName":"Julia Boris","profileInfo":"michael "},{"memberID":"1","memberName":"Julia Boris","profileInfo":"89898989"}]}


From the browser you can use the following codes to do an AJAX Post. Notice the I purposely pass dummy data to the other end. Somehow it returned text instead of JSON if i do not pass dummy data.

You can do some debugging by displaying return "data". If you can see the content of your data as shown example above, then you might not be returning JSON data type - mea…

Speculation - Distributed Transaction for improving performance, reliability and fault tolerance in Distributed Environment

Coming up ....

Extracting and Query a Comprehensive Web Database - M. Cafarella, UWS

Tremendous amount of information lost takes place in existing web database that tries to fit crawled information into a specific domain / predefined domain. This is because information is 'forced' into a pre-defined domain.

This paper improves extraction model for web databases.

Architecture

Web crawl ---> Multimodel Extraction --> Entity Database --> Multimodel Transaction ---> User Query


This paper proposed the use of dynamic domain generation approach.

Challenges faced by this approach are

a) Web Extraction - Generating the E-R model is going to a challenge as different domain maybe generated for the same topic. For example George W Bush or President George Bush. How do you know that these are the same domain? Data reconciliation is a huge issue.

(Dong, A Halevy and Madhavan - Reference Reconciliation in Complex Information Space)
(Singla and Domingos - Entity Resolution with Markov logic)

b) Entity - Relation - A component that contains entity extracted from the web. Tw…

Building MySQL

MySQL Building from Source

Pre-requisite:

1. Install VS C++ Express Edition

2. Microsoft Platform SDK **** very important ****

Build Process

1. Add Path to cMake installation Path

2. Configure your VS2005 Express to Microsoft Platform SDK by going to

Tools->Options->Projects and Solutions->VC++ Directories->Library files

Library files :-

Add D:\Program Files\Microsoft SDKs\Windows\v6.1\Lib

Include

D:\Program Files\Microsoft SDKs\Windows\v6.1\Include


3. Go to your source path and issue the following command \win\configure.js

WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE


4. Execute win\build-vs8.bat (if you're using Vs2005) and this will generate a VS solution file called MySQL.sln

5. Open up the solution file and build it. Goto --> Properties --> Set your configuration; Then right click on MySQL (specific component) and select Build.

Building Mozilla on Windows Vista and VS2008.

1. Install your Visual Studio - VS2008 (older versions are supported as well)

2. Install Microsoft Platform SDK depending on what Windows you're on
3. Install MozillaBuildTool from (http://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/MozillaBuildSetup-1.3.exe)
4. Setup your Mozilla configuration by creating a file called .mozconfig in your installed source root folder
This is configuration for building firefox
ac_add_options --enable-application=browser mk_add_options MOZ_CO_PROJECT=browser

5. Choose your Visual Studio version by executing this is c:\mozilla_build (default directory for installing MozillaBuildTool above)
start-msvc6.batstart-msvc71.bat (VS 2003)
start-msvc8.bat (VS 2005)
start-msvc9.bat (VS 2008)6.Run make -f client.mk build

7. Once your firefox gets build it should be in the firefox-3.0.5-source\mozilla\dist\bin\firefox.exe. Now you may try to run your build version of firefox by double clicking on it.


Unfortunately the above instruction does not work for fi…

Creating ASPCOM to consume WCF Web Service

I'm trying to send messages. The process goes something like this :-

ASP ---(server.createobject)--> COM Object ----(invoke method)----> WCF Web Service

All running on IIS.
So i can send messages from ASP COM to WCF Web Service. Typical processes to do this is :
a) Make your DLL ComVisible b) Sign it c) regasm (ok to skipped coz VS might register for you automatically) d) gacutil e) To place your App.config file during deployment, go and update Web Service Configuration file ----> w3wp.exe.config/aspnet_wp.exe.config.
I did this before. Just couldn't figure out why it slipped my mind.

Flex Web Service Simple / Complex Data Type

Let's say you want to invoke a WCF/ASMX web service using Flex and you need to pass in simple and also complex data type.

This is my web service (I'm using ASMX) . SayHi requires Username parameter of type string. While Welcome method uses a complex data type as its parameter.


[WebMethod]
public void SayHi (string Username )
{

}

[WebMethod]
public void Welcome(Person p)
{

}


public class Person
{
public string Name { get; set; }

public string Ability { get; set; }

}

To show how it is called in Flex just use the following MXML code



With MXML :








function InvokeService():void
{
svcTest.SayHi("Jeremy");
}


function InvokeComplexType():void
{
var p = new Person();
p.Name = "Jeremy";
p.Ability = "Coder";
svcTest.Welcome(p);
}



Using Actionscripts

The code here is almost the same with MXML markup.

function InvokeService():void
{
var ws:WebService = new WebService();
ws.wsdl ="http://localhost:2400/TestTes…

Reinstating Grub after XP installs

Boot up Linux with your bootable Cd or u can simply type

a) linux rescue - this will allows you to boot up your linux

b) grub

c) find /grub/grub.conf

it will display something like

(hd1,1)

d) root (hd1, 1)

e) setup (hd0)


Reboot your system and you can see grub is loaded.

Papers 24/1/2009

Pretty interesting paper

Cloud Computing and Grid Computing 360-Degree Comparedhttp://xxx.lanl.gov/abs/0901.0131

Using Custom DLL with IronPython / Scripts

Using Custom DLL with IronPython

This example here assumed that you have class written in VB/C# with the following namespace Liverpool.Soccer.

It has a static class called Torrest.Hello();

First set the lookup path for Pyton

1.import sys

2.sys.path.append("c:\\love\\Liverpool.soccer\\Liverpool.Soccer\\bin\\Debug")

3.import clr

4.clr.AddReferenceToFile("Liverpool.Soccer.dll");

5.import Liverpool.Soccer

Finally invoke your method by calling :-

6.Liverpool.Soccer.Torrest.Hello();

That's it.


Alternatively .... you can save this into a file call clib.py.

import sys
sys.path.append("c:\\love\\Liverpool.soccer\\Liverpool.Soccer\\bin\\Debug")
import clr
clr.AddReferenceToFile("Liverpool.Soccer.dll");
import Liverpool.Soccer
Liverpool.Soccer.Torrest.Hello();

Then execute it using ipy clib.py

VS 2008 Create Project Tool version unrecognized

If you have error creating project and receive Unable read project file [full filename]: The tools version "3.5" is unrecognised, then the following should help to solve it.

Open up your Window registry :-

And make the following changes....

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\3.5]
"DefaultToolsVersion"="2.0"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\2.0]
"MSBuildToolsPath"="C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5]
"MSBuildToolsPath"="C:\\WINDOWS\\Microsoft.NET\\Framework\\v3.5\\"