Tuesday, May 31, 2011

IronRuby Tutorial, Ruby For C# programmers,Part 1

IronRuby is one of the DLR extension on Microsoft .net platform that enable you programming against .net using the Dynamic Language. I will put a very short tutorial, here.

  Download the assemblies or just the installer file from http://ironruby.codeplex.com/releases/view/49097#DownloadId=159561
for the installation, it basically puts several .net assemblies to the GAC folder. 

Then you can run the IronRuby console, which is the C# version of Irb

when you run process explorer, you will see the loaded Assemblies,
Ir.exe is a standard .net application,


Now, let’s write a basic HelloWorld Ruby application,
First in Ruby Style,

then In C#, we just call System.Console.WriteLine(“Message”). namespace will be mapped to module in Ruby,

Now, you can call the standard .net library, like Datetime

In Ruby, if you want to query the methods of the Object, you can use .methods, we can do this too.

if we want to change the Console foreground color, which we cant do in ruby easily,just call system.foreground_color
here, we can use ruby style naming like foreground_color, or C# style ForegroundColor, the dynamic method dispatcher will delver the call to the right stub,

To using the Base64 encoding that I used pretty often,

in Ruby, it’s easy to subclass to add more methods, say thing error here, I will add one method called writeerror


Wednesday, May 25, 2011

How to: Fix IE9 rendering issues with Google Gmail

One day, When I open Gmail, everything is messed up, the rendering is totally wrong, the screenshot looks like this

When I click the about, I use the latest IE9 version.


To locate it why, I just click F12 to open the developer tools,
it picked up  the IE9 Compact Browse mode somehow.
Switch it back to regular IE9 Mode will fix the rending issue.

Tuesday, May 24, 2011

ActivityManager: Error: Activity class {com.androidyou.asia/com.androidyou.asia.taballActivity} does not exist.

I got this weird  error when I try to run a basic android application, the error console tells nothing but one activity doesn't exist

when I check the logcat, nothing related there.

after a lot try, seems put a . in front of the lanuch activity will be the trick,


Friday, May 13, 2011

Install ADB Driver for Samsung galaxy tablet 10.1 from google io /Samsung galaxy SGH-T959

If you want to install the ADB Driver for the samsung tablet you get from google IO, you may find it’s hard to get the correct driver from samsung download site.

I found another trick to do the installation, Download and Install the Samsung Kies which will install the driver for the tablet,
Download Link, http://www.samsungapps.com/about/onPc.as?LOCALE=hi_IN


After installation of the kies, you will see adb driver is there in the device manager,

and you can run adb devices, to see your samsung device,

For the galaxy phone , please go to the download site, http://www.samsung.com/us/downloads

Chose the cell-phone and your model, click the software tab, download the zipped usb driver (has the ADB one too)

More Adb Driver installation Blogs,

Tuesday, May 3, 2011

Seconds since the Unix epoch in C#/java, the same output of Time() in PHP

in Php, there is one Time() function, Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
  in C#, there is no built-in function to return seconds since UNix epoch, here is the code snippet to return the same thing

int t = (int)DateTime.Now.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;

In Java, there is one standard function, System.currentTimeMillis(),which measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.


Adobe Content Server, Error getting license License server communication problem: E_LIC_WRONG_OPERATOR_KEY

When I try to finish the fulfillment of one ebook using the digital edition, It returns this error.


However, when I test the http://server:8080/fulfillment/statuscheck, all passed.

wrong operater key always means that the p12 file we setup in the c:\config\fulfillment-conf.txt is incorrect.  it doesn’t match the url that do the fulfillment.

So there could be stupid typo mistake, check the fulfillment-conf make sure the com.adobe.adept.serviceURL is matching the cert url.
if you want to check the cert url, just click and import it to the certification store and open the certificate mmc

also it looks like the statuscheck never check the url match the operator certificate which we think it will do. 

adobe content server, Error getting license Server communication problem: E_ADEPT_REQUEST_EXPIRED

I just wrote a simple C# Bookstore by copying the logic in the sample Php bookstore application, all looks pretty straightforward. when I click download to fulfill the book, the Adobe digital edition returns error.


I recalled in the php program, the client will pass a dateval variable to the fulfillment server, it just pick up the time() function which returns seconds since Unix epoch. so I just create my own edition like

int dataval =   (int)DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;

then when the server get the fulfillment request , it think the time has been passed. Why?

here is the trick, the time function that the php sample program uses   Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
I am in the PST timezone, so there is 8 hours difference,

fixing is easy,change it as,
  (int)DateTime.Now.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;

Locations of visitors to this page