Posts

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...
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 1...

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 databa...

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 - ...

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 t...

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.bat start-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 d...

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 { ...

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 Compared http://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\\"

My Notes on Safari Nightly Build

To install safari nightly build 1. Go down to : http://webkit.org/ and 2. Extract the file and run-nightly-webkit.cmd You might need to run FindSafari.exe to seek out where Safari is installed in your machine

Writting a SQL Profiler

In case you're wondering how to write a SQL Profiler to automate some of your task, here are some code that you might want to try out :) Add reference to Microsoft.SqlServer.ConnectionInfo in your project and you are good to go! using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SqlServer.Management.Trace; using Microsoft.SqlServer.Management.Common; using System.IO; using System.Configuration; namespace MSSQLProfiler { public class MSSqlTracer { ConnectionInfoBase conninfo = null; public string TemplateTraceFile { get; set; } public string TraceOutputFile { get; set; } public void StartTrace(string TemplateFileSource, string OutputFileName) { TemplateTraceFile = TemplateFileSource; TraceOutputFile = OutputFileName; Initialization(); /// Perform Database Tracing //// RunTracing(); } private void RunTracing() ...