Aug
29
2010
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
no comments | tags: API, Development, dll, draw, FarPoint, FpSpread, GDI, spread, VB.Net | posted in Tips
Aug
19
2010
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
no comments | tags: answers, certification, CRM, Dynamics, exam, free, MB2-633, Microsoft, Outlook, practice, Prometric, questions, uCertify | posted in Tips
Aug
16
2010
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
no comments | tags: CRM, customization, Dynamics, JavaScript, Microsoft, security | posted in Tips
Jul
22
2010
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
no comments | tags: CRM, Dynamics, IIS, Microsoft, server, SQL, Windows, workflow | posted in Tips
Jul
21
2010
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
no comments | tags: Gateway, ip, Microsoft, networking, TCP, VPN, Windows | posted in Tips
Jul
20
2010
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
no comments | tags: embedded, linux, Mac, MacPorts, OBD, Python, serial, UART, USB, wxPython, X11 | posted in Tips
Jul
20
2010
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
no comments | tags: bash, freeze, kill, Mac, Mac OS X, process, ps, terminal, unfreeze, zsh | posted in Tips
Jul
19
2010
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
no comments | tags: 2008, 2010, check-out, Microsoft, Source Control, Team Explorer, Team Foundation, Team Foundation Server, TF, TFS, users, Visual SourceSafe, Visual Studio | posted in Tips
Jun
22
2010
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
no comments | tags: console, PowerShell, quake, terminal, visor, Windows, Yakuake | posted in Tips
Jun
10
2010
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.
no comments | tags: metadata, security, Vista, Windows | posted in Tips
May
8
2010
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
no comments | tags: astimezone, date, datetime, dateutil, ISO, ISO8601, local, Python, pytz, time, timezone, UTC | posted in Tips
Apr
28
2010
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
no comments | tags: Apple, application, Deployment, Mac, PIL, py2app, PyInstaller, PyQt, Python, Qt, Snow Leopard | posted in Tips
Apr
7
2010
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.
no comments | tags: attribute, function, Python, static, variable | posted in Tips
Apr
5
2010
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
no comments | tags: ip, networking, packet, Python, Scapy, sniffer, TCP | posted in Tips
Apr
4
2010
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.
no comments | tags: .NET, C, design mode, Designer, memory leak, run-time, vb, visual basic | posted in Tips