Apr 1, 2010

my old phone has a funny way of letting me know I didn't give it enough affection

I use my old phone as a clock alarm. It's an HTC S710 and was my very first WM smartphone. It was a good phone and served me well. As I don't use it for anything else, often it discharges past operating levels. But it has a funny way of reminding me I didn't care, after I charge it and power up, the clock alarm kind of forgets that the OS was dead all this time and kindly ("hey wake up!") starts up all the alarms from the point where it went dead (you know modern devices have a RTC powered by a different battery). Now have fun turning them off. 1-4 or all 16 of them!


What does this teach us? Design your apps in such a way that you don't need to save any state before exiting, put some thoughts into it's architecture, that is were you should spend a lot of your time, don't jump to the code.

And no, this is not a April Fools' joke.

Mar 14, 2010

I met a weird guy on XBL yesterday....

We had our regular 5 vs. 5 team slayer. And one guy from his team quit early. So there were 4 left in his team. The name of the players was x, x(1), x(2) and x(3). Meaning all the players were on the same console using 4 controllers. Halo 3 supports up to 4 and many other games do too. x(1)-x(3) appeared to be inactive, and only x was. This usually happens when a player goes to get a drink and leaves his controller behind while the game is playing. However the weird thing was that once you approached x(1)-x(3), being pretty confident they'll die pretty easily, they started shooting at you. :) Go figure. x actually was playing all 4 of them, and switching the controllers!

Sep 2, 2009

_VtblGap: skipping vtable slots when doing COM

When doing COM interop is very important that the imported interface should match the COM one, you can always skip methods at the end or skip the parameters for the methods you are not interested in, that will work, granted:

The COM interface:

MIDL_INTERFACE("F4B1A599-7266-4319-A8CA-E70ACB11E8CD")
IAudioSessionControl : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE GetState(
/* [annotation][out] */
__out AudioSessionState *pRetVal) = 0;

virtual HRESULT STDMETHODCALLTYPE GetDisplayName(
/* [annotation][string][out] */
__out LPWSTR *pRetVal) = 0;

virtual HRESULT STDMETHODCALLTYPE SetDisplayName(
/* [annotation][string][in] */
__in LPCWSTR Value,
/* [unique][in] */ LPCGUID EventContext) = 0;

virtual HRESULT STDMETHODCALLTYPE GetIconPath(
/* [annotation][string][out] */
__out LPWSTR *pRetVal) = 0;

virtual HRESULT STDMETHODCALLTYPE SetIconPath(
/* [annotation][string][in] */
__in LPCWSTR Value,
/* [unique][in] */ LPCGUID EventContext) = 0;

virtual HRESULT STDMETHODCALLTYPE GetGroupingParam(
/* [annotation][out] */
__out GUID *pRetVal) = 0;

virtual HRESULT STDMETHODCALLTYPE SetGroupingParam(
/* [annotation][in] */
__in LPCGUID Override,
/* [unique][in] */ LPCGUID EventContext) = 0;

virtual HRESULT STDMETHODCALLTYPE RegisterAudioSessionNotification(
/* [annotation][in] */
__in IAudioSessionEvents *NewNotifications) = 0;

virtual HRESULT STDMETHODCALLTYPE UnregisterAudioSessionNotification(
/* [annotation][in] */
__in IAudioSessionEvents *NewNotifications) = 0;

};

Imported as:

[ComImport]
[Guid("F4B1A599-7266-4319-A8CA-E70ACB11E8CD")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IAudioSessionControl
{
int GetState(/*ref AudioSessionState pRetVal*/);
int GetDisplayName(/*[MarshalAs(UnmanagedType.LPWStr)] ref string pRetVal*/);
int SetDisplayName(/*string Value, ref Guid EventContext*/);
int GetIconPath(/*[MarshalAs(UnmanagedType.LPWStr)] ref string pRetVal*/);
int SetIconPath(/*string Value, ref Guid EventContext*/);
int GetGroupingParam(/*ref Guid pRetVal*/);
int SetGroupingParam(/*ref Guid Override, ref Guid EventContext*/);
int RegisterAudioSessionNotification(ref IAudioSessionEvents NewNotifications);
int UnregisterAudioSessionNotification(ref IAudioSessionEvents NewNotifications);
}

Now what can you do if you are only interested in the last 2 methods? Actually not much:

[ComImport]
[Guid("F4B1A599-7266-4319-A8CA-E70ACB11E8CD")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IAudioSessionControl
{
void _VtblGap1_7();
int RegisterAudioSessionNotification(ref IAudioSessionEvents NewNotifications);
int UnregisterAudioSessionNotification(ref IAudioSessionEvents NewNotifications);
}

This hides under a umbrella called NoPIA, part of .NET Framework 4.0

Aug 1, 2009

"to do"

"to do", "to be done" or "for reading"... while following some delicious tags I encountered some of those, that reminds me of myself doing sometimes the same thing. It is a bad way of dealing with things and definitely a bad habit, if you consider it *important* enough you should read it ASAP *even* if you have more urgent matters at hand, queuing stuff is almost equivalent to keeping a weak reference to them in some dark side of your brain, or not... That thing you've just read may prove itself useful at some point and may indirectly improve your productivity, "may". Besides you won't run on "déjà vu"s, weakening the reference even more, if you read it in the first place

Sep 23, 2008

Ichigo and Rukia literally or virtually :)

being a Bleach fan, couldn't control myself from not posting this:

GTalk: ichigo vs. rukia

if you are not a Bleach fan, then you probably won't get it, though

Jun 14, 2008

New blog, my blog?

After a long time I decided to write my own blog engine, it's not like blogger doesn't do it's job well anymore, it does, just that being a developer and using a blogging service doesn't sounds cool. Anyway it appears that I'll have a lot of free time, so it's a good idea to put all that energy into something (although not only this project). Lets see how this will turn out, it's not so big deal, I may even get bored and don't finish it, anyway stay tuned.

EDIT: I felt like I need to post some explanations about this, NOT GOING TO HAPPEN! First of all that kind of stuff sounds boring in my ears now, secondly I got too busy, this thing I'm using now JUST WORKS, wanting to do something new just for the sick of sounding cool is silly, specially when there is nothing to gain from doing it

May 14, 2008

Mono support for Windows Forms 2.0 is (almost) complete!

Mono team announced that the support for Windows Forms 2.0 is "almost" done, and is now API complete. Mono team also released first public Moonlight release supporting Silverlight 1.0. This is great and exciting news, congrats to Mono team!!! they deserve all the cakes in the world :)