M-A's

technology blog

Friday, 12 June 2009

Archival price

I was considering buying a 50pk 4.5gig DVD spindle. It's ~15.40$ CAD for a good archival quality.
On the other side, a 1.5TB HD is 150$.

15.50$ / (50*4.5gb) = 6.9¢
150$ / 1500gb = 10¢

Taking in account that there's always lost space in DVD due to trying to fit it to its maximum space, the amount of time taken to format the data to fit in a DVD, the manual intervention of swaping the disks and the slow DVD write speed (compared to a SATA2 HD), I think it's not valuable to archive on DVD anymore, assuming you keep 2 copies of your data.

Wednesday, 3 June 2009

Dell mini 10v

Coolness
1) With a 6 cells battery, this thing last a full day!
2) Jaunty supports hibernation, faster boot and *way* faster wifi connection. Hardy was way too slow to connect back to the wifi network.
3) If you take a colored top, you get the webcam for free. Mostly useless on a Atom processor anyway. :)

Issues
1) It took me a day to figure out how to page up/down key; kind of necessary when programming. Hint: FN key.
2) No video acceleration for the 945GME / GMA 950 until Karmic Koala 9.10. This video card is too unstable with UXA to be usable. That's quite disapointing.
3) The touchpad default configuration isn't great, I highly recommend a Logitech Nano VX.
4) With the 6 cells battery, the laptop is not level, making it hard to look at the monitor while the laptop is on a table and you are straight up. This is due to the fact that the monitor doesn't bend backward enough.
5) The dell ubuntu comes with Fluendo codecs and a custom shell launcher. My wife liked the launcher but the one in NBR is fine enough for her. TODO The codecs can be imported back into the new install if you install both OS side by side.

Survival kit
1) Install Ubuntu Jaunty 9.04 netbook remix (NBR). This netbook has a SDHC card reader so you can put it on a memory card from the stock ubuntu install.
2) Fix the palm check otherwise the mouse is constantly moving while typing on the keyboard.
Temporary fix:
DEVICE="SynPS/2 Synaptics TouchPad"
xinput list-props "$DEVICE"
xinput --set-int-prop "$DEVICE" "Synaptics Palm Detection" 8 1
xinput --set-int-prop "$DEVICE" "Synaptics Palm Dimensions" 32 10 10
First modify the file is /usr/share/hal/fdi/policy/20thirdparty/11-x11-synaptics.fdi as explained in:
http://ubuntu-snippets.blogspot.com/2009/03/multi-touch-for-anyall-synaptics.html

You can then install
sudo apt-get install gsynaptics
but it doesn't let you modify every settings..

3) If you kept the stock dell ubuntu 8.04 on a separate partition, fix the grub menu timeout to 1 second
sudo nano /boot/grub/menu.lst
Set the "timeout" line to 1.

4) Install Google Chrome!
http://dev.chromium.org/getting-involved/dev-channel

Update
- Better just turn off the touchpad after all, it's way too bad.
- Go in the bios and fix the Function keys as multimedia keys.
- I installed 2 gigs of RAM in it with the videos on youtube.

Friday, 10 April 2009

Section synchronization

I was looking at a cleaver way to use interprocess communication and we (chromium) use shared memory with CreateFileMapping(). The main issue is synchronization. I was looking at using the section as an inherent synchronization tool but it fails miserably. I finally found the answer: « File mapping objects do not support the SYNCHRONIZE standard access right. »[1]

That would have been useful, even if it would have been limited to 4kb granularity or even just a global section lock. Sad. Going back to mutex. :(

[1]
http://msdn.microsoft.com/en-us/library/aa366559.aspx

EMF buffer idiocracy

On Windows XP, when creating an HDC from an EMF buffer with CreateEnhMetaFile():
  • SetDCBrushColor() and SetDCPenColor() calls are not recorded. Too bad for you.
  • When using GetStockObject(), DC_BRUSH and DC_PEN are useless and will return a white pen and a black pen respectively. Just don't use them.
  • Expect no-op from ExtTextOut(..., ETO_GLYPH_INDEX, ...) if GDI32!GdiInitializeLanguagePack hasn't been called.

Thursday, 17 January 2008

Understanding vsprops files

I've began using .vsprops files (along side .vcproj files) on VS2005 SP1. I discovered that you can do something that looks like that:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" inheritedpropertysheets=".\randomprefix_$(RANDOM_ENVIRONMENT_VARIABLE).vsprops">
< /VisualStudioPropertySheet >
This is cool, you can modify which vsprops file will be inherited by an externally defined environment variable, before starting Visual Studio. Ok fine, then try further:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" inheritedpropertysheets="$(SolutionDir)..\randomdir\random_file.vsprops">
< /VisualStudioPropertySheet >
Cool again! I can use locally defined variable in Visual Studio. Ok, then let's try to do something useful:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" inheritedpropertysheets="randomprefix_$(ConfigurationName).vsprops">
< /VisualStudioPropertySheet >
It fails. :( That would have been useful: include a vsprops file named after the current configuration name (debug or release or whatever). Here a counter example:
< ?xml version="1.0" encoding="Windows-1252"? >
< VisualStudioPropertySheet
projecttype="Visual C++"
version="8.00"
name="whatever" outputdirectory="$(SolutionDir)$(ConfigurationName)" >
< /VisualStudioPropertySheet >
Yes, that actually works. In fact, you can even set « CharacterSet="1" » in the vsprops even if the VS vsprops editor doesn't allow you to set this (the same applies to WholeProgramOptimization). So it seems like $(ConfigurationName) and $(SolutionDir) aren't defined at the same time, which is normal. The way VS looks at the project file looks like this:

  1. Initial parsing
  2. For each Configuration in Configurations
    1. Load the InheritedPropertySheets attribute
      1. Open recursively the property sheets
    2. Load the Name attribute in Configuration in the vcproj
    3. Process property sheets
    4. Process the rest of the attributes
    5. Load the rest
The thing is that you can use $(ConfigurationName) in the OutputDirectory attribute but not in the InheritedPropertySheet. Too bad, what a missed opportunity. I somewhat tried playing with UserMacro but without any success.

Disclaimer: I didn't try with VS2008.
Disclaimer: I know the blogger's editor sucks and that I couldn't write real XML. In fact, they know it too. I just wished they cared. We're just all eager to have it actually fixed.

Sunday, 13 January 2008

The undocumented frustration

I had some frustration when updating WINVER and _WIN32_WINNT from 0x501 to 0600 (okay we're late but better be late than sorry). I came across two things I'd like to document.

---

First I need to reference Nicolas Sylvain post about GENERIC_MAPPING changes to give some background. Then all I have to say is that there are other access masks that changed, but explicitly. The ones we hit were PROCESS_ALL_ACCESS and THREAD_ALL_ACCESS. They have a new bitmask. Here are the definition:
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
#define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
#else
#define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF)
#endif

#if (NTDDI_VERSION >= NTDDI_LONGHORN)
#define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF)
#else
#define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF)
#endif
The nice thing is that the new bitmasks are refused by Windows XP. So you need to use different flags depending on the OS, which you need to define yourself. Not great! The easiest work around is to use MAXIMUM_ALLOWED but this is not always what you want.

---

The second one is nasty. The NONCLIENTMETRICS structure's size silently changed between XP and Vista. Here is the definition:
typedef struct tagNONCLIENTMETRICSW
{
UINT cbSize;
int iBorderWidth;
int iScrollWidth;
int iScrollHeight;
int iCaptionWidth;
int iCaptionHeight;
LOGFONTW lfCaptionFont;
int iSmCaptionWidth;
int iSmCaptionHeight;
LOGFONTW lfSmCaptionFont;
int iMenuWidth;
int iMenuHeight;
LOGFONTW lfMenuFont;
LOGFONTW lfStatusFont;
LOGFONTW lfMessageFont;
#if(WINVER >= 0x0600)
int iPaddedBorderWidth;
#endif /* WINVER >= 0x0600 */
} NONCLIENTMETRICSW, *PNONCLIENTMETRICSW, FAR* LPNONCLIENTMETRICSW;

WTL 8.0 has a workaround for this
but let's face it, it looks more as a hack than anything else. It looks like the guy at Microsoft that changed the structure should have wrote a unit test...
Anything that is written that looks like this is bound to fail:
NONCLIENTMETRICS cm = { sizeof(NONCLIENTMETRICS) };
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &cm, 0);
I don't blame Microsoft for doing small errors like this. Managing an operating system is a tremendous task and we all know errors can slip through. The real problem I see is that even one year after the release, it's still not documented. Let's hope the Vista SP1 SDK will define PROCESS_ALL_ACCESS_XP, THREAD_ALL_ACCESS_XP and NONCLIENTMETRICS_v1.

Friday, 4 January 2008

Risk of using embedded MSHTML

There is always some risks involved in using third parties in UI.



This one is cute: It is the "My Web Sites on MSN" wizard that is hit by the IE ActiveX security bar. But this is really nice inside a dialog box, knowing that it is pure Microsoft code.

It is funny because it gives the feeling that it is less secure while in reality it doesn't change anything since it is simply a side-effect of using MSHTML for rendering.