Aug 29 2010

Draw Line/Shape in FarPoint FpSpread

xiao

If you worked with FarPoint Spread, you know that it uses conventions and APIs entirely different from what’s used in normal Winforms. When it comes to drawing inside a FarPoint spread, CreateGraphics will definitely not work. If only FarPoint made their documentations Google-friendly, you will find that there are in fact APIs specifically made for drawing. Continue reading


Aug 19 2010

My Take on the MB2-633 CRM 4.0 Installation and Deployment Exam

xiao

Here’s my experience on Microsoft’s MB2-633 exam which I just passed, on the second try.

First of all, as far as I can tell, the Prometric exam has 50 questions and there are only 50 questions in their question pool. The questions I got on my second try are the exact same as on my first exam. Continue reading


Aug 16 2010

CRM 4.0 Read-Only / Disable / Hide Fields Based on Security Role

xiao

Suppose you want to make some fields editable for only some users in CRM forms, there is a great and simple MSDN blog that outlines how to do it.

Here’s a copy of  their code. Just change _roles and _fields to the fields’ names that you want to disable for _roles. Flip it around and enable it only for those users by changing line x to false.

Put it in your form’s onLoad event at Customization->your entity->Forms and Views->Form->Form Properties->Event, OnLoad->Edit Continue reading


Jul 22 2010

CRM Workflows Don’t Work, E-mails Don’t Send…

xiao

Symptom: You choose to run a workflow but nothing seems to happen and the new workflow doesn’t appear in the workflow tab.

Theory: If my CRM exam studyage served me right, the Microsoft Dynamics CRM is composed of 3 parts. The application layer producing the business logic, the data layer interfacing with SQL and the async service layer doing stuff like workflows on the background (a bit like SQL agent). If the first 2 break, you won’t get your CRM site at all. When the async service layer breaks, it’s a bit more subtle like in this case. Continue reading


Jul 21 2010

Stop Transferring All Internet Traffic Through Windows VPN

xiao

By default, when you connect to VPN in Windows, it will put all your Internet traffic through the VPN. This can be annoying if you just want to VPN in to get access to some files on the network. This can be especially annoying if your VPN server is slow and now all your Internet access speed is slow. Continue reading


Jul 20 2010

Free OBD2 Software for Mac

xiao

If you just picked up a generic OBD-II – USB interface on eBay and have a Mac, it is true that it is generally more convenient to access these hardware on Windows. Even embedded device developers tend to use Windows to develop against these generic FT232R chip based USB-UART devices simply because of more available supports. But worry not, it can be done on Mac (really on Linux with a more open-platform framework than Windows), it’s just a bit more complicated since it tends to come in be open-source source code rather than prepackaged self-sufficient binaries. Continue reading


Jul 20 2010

How to Unpause Applications in Mac OS X

xiao

I asked this question on Superuser.com after experiencing this problem. Now it’s accessible to everyone.

When something goes wrong and you run out of memory on Mac OS X, the system puts your existing applications to pause to prevent the system from becoming unstable. After taking care of the problem and freeing more memory, you might notice that the applications you had are still frozen. To unpause them, find their PID using ps and use the kill command to revive it (irony)

kill -CONT 111

Of course, 111 here is replaced with the PID you found with ps


Jul 19 2010

How to List Checked-Out Files in Team Foundation

xiao

In Visual SourceSafe, you were able to look at all the files that were checked-out by members of your team. It is not a default function available for TFS users to find all the checked-out files but it’s an easy task to do.

Continue reading


Jun 22 2010

Quake Style Drop Down Terminal for Windows

xiao

I was used to the convenience of drop-down terminals like Visor in Mac or Yakuake in Linux and needed something similar in Windows.

It turns out, it is possible to achieve almost the same effects in Windows with the use of 2 tools.

  • AutoHotkey -  lets you run scripts triggered by hotkeys anywhere in Windows
  • Console – is a terminal app that lets you run a custom shell with no title bar, no borders, transparency etc.

Continue reading


Jun 10 2010

The location of the file or directory ‘C:\Something’ is not trusted

xiao

The error “The location of the file or directory ‘C:\Something’ is not trusted” can sometimes be issued when linking or deploying assemblies in Windows. The issue is that Vista and Windows 7 have a way of automatically marking files received from another computer as unsafe to execute against.

The easiest way to solve is to remove the restriction against the particular file

Right-click the file and open properties and click unblock.


May 8 2010

Python Convert ISO8601/UTC to Local Time

xiao

Ok, I looked this up twice now… once too many

Suppose you have a datetime of the form “2010-05-08T23:41:54.000Z” and you want a local datetime object

import pytz, dateutil.parser
utctime = dateutil.parser.parse("2010-05-08T23:41:54.000Z")
localtime = utctime.astimezone(pytz.timezone("Canada/Eastern"))

Boom


Apr 28 2010

Deploy PyQt Applications on Mac OS X with PyInstaller!

xiao

The interweb seem to incline on py2app when it come to deploying applications on mac. I’ve tried to make a single deployable .app file for my application for a long time trying to follow these instructions from ars technica. I’m not a hacker and just want to produce a deployable usable application for others to use. And it seems py2app from MacPorts wasn’t able to surmount the Snow Leopard’s 64-bit compatibility issue.

And then, I was slacking off while studying for my final and out of nowhere I found PyInstaller‘s explicit support for PyQt and its recent support for the mac. And after trying, almost everything works out without much of a kink. Credit goes to ChrisWayg who produced an amazingly complete and up-to-date set of instructions to follow. I’m merely telling how my application did using his instructions (April 2010) and hopefully doing my part to draw more attention to the excellent PyInstaller. Continue reading


Apr 7 2010

Python’s Function Static Variable

xiao

So you want a variable that stays between different calls of a function. Not the sexiest thing ever but always handy in small programs.

There’s tons of ways of doing this. You can embark on a quest to find the meaning of Pythonic or take this method that’s relatively simple:

def a():
    if not hasattr(a, "b"): a.b = 0
    a.b += 1
    print a.b

Calling a(), you’ll get 1, 2, 3, …

Note attribute ‘b’ of ‘a’ does not exist until you declare it for a first time. My main preference here is that ‘static’ variables used this way does not spill onto the rest of your code. Also, it’s clean, no classes, no data structures.


Apr 5 2010

Suppress Scapy IPv6 Warning

xiao

When you run Scapy without a default IPv6 routing gateway, Scapy will display this annoying warning:

WARNING: No route found for IPv6 destination :: (no default route?)

You definitely don’t want to see it every time you run the script you built with Scapy. To get rid of it, simply add

import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)

before importing Scapy to suppress all messages below error messages


Apr 4 2010

Determining Run-Time/DesignMode in .NET

xiao

Suppose you fill your table with data from a database, you wouldn’t want it to do so while in Visual Studio’s Designer. Control.DesignMode ought to be the perfect property to check for in your form initialisations but unfortunately, it’s so buggy that it hardly does what you need. It doesn’t work in the constructors and have problems with user controls.

Then people tend to use

If (Process.GetCurrentProcess().ProcessName == "devenv")

which works fine if you call it once but inside a key user control’s initialiser, it may be called hundreds of time and cause a massive memory leak. Currently, the ProcessName string never gets freed and fills up memory very fast. Instead, save the process name in your own global variable when the program starts and check against

If (MyProcessName == "devenv")

instead.