Martin Fowler coins the phrase
http://martinfowler.com/bliki/FluentInterface.html
Wikipedia
http://en.wikipedia.org/wiki/Fluent_interface
Tuesday, December 28, 2010
Monday, December 27, 2010
Enable/Disable Windows Proxy
http://ozansafi.wordpress.com/2009/07/05/enabledisable-change-ie-proxy-by-scriptprogrammatically/
To disable proxy:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000000
To enable proxy:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
To change proxy:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MigrateProxy"=dword:00000001
"ProxyEnable"=dword:00000001
"ProxyHttp1.1"=dword:00000000
"ProxyServer"="http://ProxyServername:80"
"ProxyOverride"=""
Copy these to a .reg file and double click on them to do the trick. The good part of doing it this way is that it works on every IE version(well, I haven’t tried any IE lower than IE6 and it is able to change it without even opening up anything.
To disable proxy:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000000
To enable proxy:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyEnable"=dword:00000001
To change proxy:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MigrateProxy"=dword:00000001
"ProxyEnable"=dword:00000001
"ProxyHttp1.1"=dword:00000000
"ProxyServer"="http://ProxyServername:80"
"ProxyOverride"="
Copy these to a .reg file and double click on them to do the trick. The good part of doing it this way is that it works on every IE version(well, I haven’t tried any IE lower than IE6 and it is able to change it without even opening up anything.
Friday, December 24, 2010
VS2010 Client Profile - Namespace Reference Invalid After Build
So this is the scenario, in a project, add a reference to an assembly, then declare a variable of a type from the newly referenced assembly. Then type in the declaration, and you get the usual blue squiggly line. If you right-click then you get the option to add a 'using' reference to my assembly, and then bobs-your-uncle, all is good...
Until, you try to build the project, then for some ungodly reason VS no longer regards the namepace inclusion as valid, and spits out a
Error 377
The type or namespace name 'xx' could not be found (are you missing a using directive or an assembly reference?)
error, referring to exactly the same assembly ref that it just suggested be included.
This is, apparently, a dotNET 4 Client Profile Issue.
http://www.go4answers.com/Example/lost-references-while-building-project-143531.aspx
http://msdn.microsoft.com/en-us/library/cc668079.aspx
Until, you try to build the project, then for some ungodly reason VS no longer regards the namepace inclusion as valid, and spits out a
Error 377
The type or namespace name 'xx' could not be found (are you missing a using directive or an assembly reference?)
error, referring to exactly the same assembly ref that it just suggested be included.
This is, apparently, a dotNET 4 Client Profile Issue.
http://www.go4answers.com/Example/lost-references-while-building-project-143531.aspx
http://msdn.microsoft.com/en-us/library/cc668079.aspx
Friday, December 17, 2010
MS Castle Windsor [IOC Container] Cheat-Sheet
Martin Fowler
IOC Containers and the Dependency Injection pattern
Wiki: Castle Windsor
Fluent API
Fluent Registration API
INSTANCE REGISTRATION
- Can you register an existing instance of a type?
- Castle Windsor – Registering Existing Object Instances
- Can you register an existing instance of a type in the container?
REGISTRATION & RESOLUTION OF NAMED INSTANCE
IWindsorContainer.Register(Component.For<ClassType>().Named("instanceKey").Instance(instanceOfClassType));
ClassType retrievedInstance = IWindsorContainer.Resolve("instanceKey");
StackOverflow Thread
REGISTER & RESOLVE BASED ON INTERFACE
Note on Registering/Resolving Generic Lists by Instance
I have been unable to register & resolve generic lists, e.g. List, by instance.
However, if you wrap the generic list in a custom class, e.g.
public class IntList : List
{
}
then you can register & resolve by instance with no problems.
IOC Containers and the Dependency Injection pattern
Wiki: Castle Windsor
Fluent API
Fluent Registration API
INSTANCE REGISTRATION
- Can you register an existing instance of a type?
- Castle Windsor – Registering Existing Object Instances
- Can you register an existing instance of a type in the container?
REGISTRATION & RESOLUTION OF NAMED INSTANCE
IWindsorContainer.Register(Component.For<ClassType>().Named("instanceKey").Instance(instanceOfClassType));
ClassType retrievedInstance = IWindsorContainer.Resolve
StackOverflow Thread
REGISTER & RESOLVE BASED ON INTERFACE
Register Types Implementing Specified Interface:
container.Register(
AllTypes.
FromThisAssembly(). // register all types from parent assembly
BasedOn). // that inherit/implement interface IDialogService
WithService.FromInterface(). // allow resolution based on interface
Configure(c => c.LifeStyle.Is(LifestyleType.Transient)) // construct new
);
Resolve Instance of Class by Interface
IDialogService dialogService = container.Resolve();
Note on Registering/Resolving Generic Lists by Instance
I have been unable to register & resolve generic lists, e.g. List
However, if you wrap the generic list in a custom class, e.g.
public class IntList : List
{
}
then you can register & resolve by instance with no problems.
Tuesday, December 14, 2010
Monday, December 13, 2010
Re-Usable Controls in WPF
MSDN Article - Developing Reusable Controls with the Model-View-ViewModel Pattern
http://blogs.msdn.com/b/nathannesbit/archive/2009/03/13/developing-reusable-controls-with-the-model-view-viewmodel-pattern.aspx
WPF: Binding to Properties in your UserControl or Window
http://decav.com/blogs/andre/archive/2007/05/27/wpf-binding-to-properties-in-your-usercontrol-or-window.aspx
http://blogs.msdn.com/b/nathannesbit/archive/2009/03/13/developing-reusable-controls-with-the-model-view-viewmodel-pattern.aspx
WPF: Binding to Properties in your UserControl or Window
http://decav.com/blogs/andre/archive/2007/05/27/wpf-binding-to-properties-in-your-usercontrol-or-window.aspx
Sunday, December 12, 2010
unable to copy file to the process cannot access because in use another process visual studio
ISSUE
vs2010 build error: unable to copy file to the process cannot access because in use another process visual studio
FIX
add following lines of code to the pre-build event command line of your project.
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
vs2010 build error: unable to copy file to the process cannot access because in use another process visual studio
FIX
add following lines of code to the pre-build event command line of your project.
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"
Wednesday, December 8, 2010
Product Management
1. automated build server
2. deployment history - date, version number (+svn), feature list
3. bug/issue tracking
2. deployment history - date, version number (+svn), feature list
3. bug/issue tracking
Friday, December 3, 2010
Handling Excel Formula Errors
the ISERROR() worksheet function can be used to test whether a cell or formula yields an error, and then by combination with an IF() function allows a branched response.
Sunday, November 14, 2010
text mother mandelbrot
zoom out ('Ctrl' + '-') on your browser to view the entire mandelbrot
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------0---------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------00--------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------00--------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------00--------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------0---------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------000000-------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------000000-------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------000000000------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------0000000000-----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------000000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------0000000000-----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------0000000000-----------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------000000000-----------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------00000000------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------0000000------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------00000-------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------0--0---------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------0---0-0-0000000000000---0-----------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------00--0000000000000000000-0-----------------------------------------------------
-------------------------------------------------------------------------------------------------------------0------------00-0000000000000000000000--00-------------------------------------------------
----------------------------------------------------------------------------------------------------------------0---------00000000000000000000000000-00-------------------------------------------------
----------------------------------------------------------------------------------------------------------------0-00-------00000000000000000000000000-0-------------------------------------------------
-----------------------------------------------------------------------------------------------------------------000-----000000000000000000000000000000-------------------------------------------------
-----------------------------------------------------------------------------------------------------------------0000---00000000000000000000000000000000------------------------------------------------
----------------------------------------------------------------------------------------------------------------00000--00000000000000000000000000000000000----00000-------------------------------------
----------------------------------------------------------------------------------------------------------------00000-000000000000000000000000000000000000----00000-------------------------------------
----------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000--00000--------------------------------------
-----------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000--00000--------------------------------------
-----------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000-00000--------------------------------------
-------------------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000---------------------------------------
----------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000---------------------------------------
----------------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000-----------------------------------------
---------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000-----------------------------------------
---------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000----------------------------------------
---------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000----------------------------------------
----------------------------------------------------------------------------------------------------------000-000000000000000000000000000000000000000000000000000---------------------------------------
-----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000---------------------------------------
-----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000---------------------------------------
-----------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000-------------------------------------
------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000--------------------------------------
-----------------------------------------------------------------------0-----------------------------------00000000000000000000000000000000000000000000000000000000-------------------------------------
----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000-------------------------------------
-----------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000--0----------------------------------
----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000-00----------------------------------
--------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000000000---------------------------------
--------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000000000----------------------------------
---------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000000000000000----------------------------------
---------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000000------------------------------------
-------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000000000000000------------------------------------
-----------------------------------------------------------------------------0-------00-----------------0000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------00------00-----------------0000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------000-----0-0--0------------00000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------000--000000000-----------000000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------000000000000000-----------000000000000000000000000000000000000000000000000000000000000000----------------------------------
-----------------------------------------------------------------------------00000000000000000--------0000000000000000000000000000000000000000000000000000000000000000----------------------------------
------------------------------------------------------------------------------0000000000000000--------00000000000000000000000000000000000000000000000000000000000000000---------------------------------
------------------------------------------------------------------------------000000000000000000------000000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------0000000000000000000------000000000000000000000000000000000000000000000000000000000000000-----------------------------------
----------------------------------------------------------------------------000000000000000000000-----000000000000000000000000000000000000000000000000000000000000000-----------------------------------
----------------------------------------------------------------------------000000000000000000000-----000000000000000000000000000000000000000000000000000000000000000-----------------------------------
-------------------------------------------------------------------------000000000000000000000000-----000000000000000000000000000000000000000000000000000000000000000-----------------------------------
--------------------------------------------------------------------------000000000000000000000000---0000000000000000000000000000000000000000000000000000000000000000-----------------------------------
--------------------------------------------------------------------------000000000000000000000000---00000000000000000000000000000000000000000000000000000000000000000----------------------------------
--------------------------------------------------------------------------000000000000000000000000---000000000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------0000000000000000000000000--000000000000000000000000000000000000000000000000000000000000000------------------------------------
-------------------------------------------------------------------------00000000000000000000000000--000000000000000000000000000000000000000000000000000000000000000------------------------------------
-------------------------------------------------------------------------00000000000000000000000000--00000000000000000000000000000000000000000000000000000000000000-------------------------------------
-------------------------------------------------------------------------000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000000-------------------------------------
-------------------------------------------------------------------------000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000000-------------------------------------
------------------------------------------------------------------------0000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000000-------------------------------------
------------------------------------------------------------------0-00--0000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------0000--0000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------00000-0000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------00000-0000000000000000000000000000-000000000000000000000000000000000000000000000000000000000000---------------------------------------
-----------------------------------------------------------------00000000000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000----------------------------------------
------------------------------------------0---------------------000000000000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000-----------------------------------------
-----------------------------000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000------------------------------------------
------------------------------------------0---------------------000000000000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000-----------------------------------------
-----------------------------------------------------------------00000000000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000----------------------------------------
------------------------------------------------------------------00000-0000000000000000000000000000-000000000000000000000000000000000000000000000000000000000000---------------------------------------
------------------------------------------------------------------00000-0000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------0000--0000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------0-00--0000000000000000000000000000-0000000000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------------0000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000000-------------------------------------
-------------------------------------------------------------------------000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000000-------------------------------------
-------------------------------------------------------------------------000000000000000000000000000-00000000000000000000000000000000000000000000000000000000000000-------------------------------------
-------------------------------------------------------------------------00000000000000000000000000--00000000000000000000000000000000000000000000000000000000000000-------------------------------------
-------------------------------------------------------------------------00000000000000000000000000--000000000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------0000000000000000000000000--000000000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------000000000000000000000000---000000000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------000000000000000000000000---00000000000000000000000000000000000000000000000000000000000000000----------------------------------
--------------------------------------------------------------------------000000000000000000000000---0000000000000000000000000000000000000000000000000000000000000000-----------------------------------
-------------------------------------------------------------------------000000000000000000000000-----000000000000000000000000000000000000000000000000000000000000000-----------------------------------
----------------------------------------------------------------------------000000000000000000000-----000000000000000000000000000000000000000000000000000000000000000-----------------------------------
----------------------------------------------------------------------------000000000000000000000-----000000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------0000000000000000000------000000000000000000000000000000000000000000000000000000000000000-----------------------------------
------------------------------------------------------------------------------000000000000000000------000000000000000000000000000000000000000000000000000000000000000-----------------------------------
------------------------------------------------------------------------------0000000000000000--------00000000000000000000000000000000000000000000000000000000000000000---------------------------------
-----------------------------------------------------------------------------00000000000000000--------0000000000000000000000000000000000000000000000000000000000000000----------------------------------
-----------------------------------------------------------------------------000000000000000-----------000000000000000000000000000000000000000000000000000000000000000----------------------------------
-----------------------------------------------------------------------------000--000000000-----------000000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------000-----0-0--0------------00000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------00------00-----------------0000000000000000000000000000000000000000000000000000000000000-----------------------------------
-----------------------------------------------------------------------------0-------00-----------------0000000000000000000000000000000000000000000000000000000000000-----------------------------------
-------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000000------------------------------------
--------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000000------------------------------------
---------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000000------------------------------------
---------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000000000000000----------------------------------
--------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000000000----------------------------------
--------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000000000---------------------------------
----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000-00----------------------------------
-----------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000--0----------------------------------
----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000000-------------------------------------
-----------------------------------------------------------------------0-----------------------------------00000000000000000000000000000000000000000000000000000000-------------------------------------
------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000--------------------------------------
------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000--------------------------------------
-----------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000000000000-------------------------------------
-----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000---------------------------------------
-----------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000000000---------------------------------------
----------------------------------------------------------------------------------------------------------000-000000000000000000000000000000000000000000000000000---------------------------------------
---------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000----------------------------------------
---------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000----------------------------------------
---------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000-----------------------------------------
----------------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000-----------------------------------------
----------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000000000---------------------------------------
------------------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000---------------------------------------
------------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000000000--------------------------------------
-------------------------------------------------------------------------------------------------------------------00000000000000000000000000000000000000000000000--------------------------------------
-----------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000-00000--------------------------------------
-----------------------------------------------------------------------------------------------------------------000000000000000000000000000000000000000000--00000--------------------------------------
----------------------------------------------------------------------------------------------------------------0000000000000000000000000000000000000000000--00000--------------------------------------
----------------------------------------------------------------------------------------------------------------00000-000000000000000000000000000000000000----00000-------------------------------------
----------------------------------------------------------------------------------------------------------------00000--00000000000000000000000000000000000----00000-------------------------------------
-----------------------------------------------------------------------------------------------------------------0000---00000000000000000000000000000000------------------------------------------------
-----------------------------------------------------------------------------------------------------------------000-----000000000000000000000000000000-------------------------------------------------
----------------------------------------------------------------------------------------------------------------0-00-------00000000000000000000000000-0-------------------------------------------------
----------------------------------------------------------------------------------------------------------------0---------00000000000000000000000000-00-------------------------------------------------
-------------------------------------------------------------------------------------------------------------0------------00-0000000000000000000000--00-------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------00--0000000000000000000-0-----------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------0---0-0-0000000000000---0-----------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------0--0---------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------00000-------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------0000000------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------00000000------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------000000000-----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------0000000000-----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------0000000000-----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------000000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------0000000000-----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------00000000000----------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------000000000------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------000000-------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------000000-------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------0---------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------00--------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------00--------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------00--------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------0---------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Text MandelBrot
------------------------------
------------------------------
--------------------00--------
--------------------00--------
-----------------0-0000-------
-----------------00000000-----
-----------------00000000-----
----------------000000000-----
------------000-000000000-----
-----------0000-000000000-----
-----0000000000000000000------
-----------0000-000000000-----
------------000-000000000-----
----------------000000000-----
-----------------00000000-----
-----------------00000000-----
-----------------0-0000-------
--------------------00--------
--------------------00--------
------------------------------
Thursday, November 11, 2010
pyGTK - Events & Basic 3d
Below is the code for a little exercise in basic pyGTK event-handling and basic 3-d, overhauling some code I wrote yonks ago in Borland Turbo Pascal.
dependencies: pyGTK
dependencies: pyGTK
--- --- rot.py --- --- --- --- --- --- --- --- --- ---
import math
class Point2D(object):
def __init__(self, x=None,y=None):
self.x = x
self.y = y
class Point3D(object):
def __init__(self, x=None,y=None,z=None):
self.x = x
self.y = y
self.z = z
class Rot(object):
rad_const = math.pi / 180.0
def rad(self, theta):
return theta * Rot.rad_const
def __init__(self):
self.sin_table = []
self.cos_table = []
for d in range(360):
self.sin_table.append(math.sin(self.rad(d)))
self.cos_table.append(math.cos(self.rad(d)))
for i in [1]: # points
self.points = []
for i in range(24):
self.points.append(Point3D())
self.points[0].x = 10.0
self.points[0].z = 4.0
self.points[1].x = 4.0
self.points[1].z = 10.0
self.points[2].x = -4.0
self.points[2].z = 10.0
self.points[3].x = -10.0
self.points[3].z = 4.0
self.points[4].x = -10.0
self.points[4].z = -4.0
self.points[5].x = -4.0
self.points[5].z = -10.0
self.points[6].x = 4.0
self.points[6].z = -10.0
self.points[7].x = 10.0
self.points[7].z = -4.0
for i in range(8):
self.points[i].y = 30.0
for i in range(8, 16):
self.points[i].x = self.points[i - 8].x
self.points[i].z = self.points[i - 8].z
self.points[i].y = -30.0
self.points[16].x = 20.0
self.points[16].z = 20.0
self.points[17].x = -20.0
self.points[17].z = 20.0
self.points[18].x = -20.0
self.points[18].z = -20.0
self.points[19].x = 20.0
self.points[19].z = -20.0
for i in range(16, 20):
self.points[i].y = 30.0
for i in range(20, 24):
self.points[i].x = self.points[i - 4].x
self.points[i].z = self.points[i - 4].z
self.points[i].y = -30.0
self.x_off = 320.0
self.y_off = 240.0
self.z_off = 50.0
self.z_deg = 0
self.x_deg = 0
self.y_deg = 0
def flatten(self, cube):
'''
320 : 200 => 1 : 5 / 8 | a.r of 4 : 3, height = 4 / 3 of width, therefore
x : y => 1 : 5 / 6
'''
n = len(self.points)
x_scale = 100.0
y_scale = 100.0 # 83.0
flat = []
for i in range(n):
x = cube[i].x
y = cube[i].y
z = self.z_off - cube[i].z
nx = int(self.x_off + (x / z * x_scale))
ny = int(self.y_off + (y / z * y_scale))
flat.append(Point2D(nx, ny))
return flat
def rotate(self, points, z, x, y):
'''
to rotate a point (oX, oY) through Alpha radians, counter-clockwise, about
the z axis:
nX = [Cos(Alpha) * oX] - [Sin(Alpha) * oY]
nY = [Sin(Alpha) * oX] + [Cos(Alpha) * oY]
'''
rotated = []
for i in range(len(points)):
oX = points[i].x
oY = points[i].y
oZ = points[i].z
# about z axis
nX = (self.cos_table[z] * oX) - (self.sin_table[z] * oY)
nY = (self.sin_table[z] * oX) + (self.cos_table[z] * oY)
oX = nX
oY = nY
# about x axis
nZ = (self.cos_table[x] * oZ) - (self.sin_table[x] * oY)
nY = (self.sin_table[x] * oZ) + (self.cos_table[x] * oY)
oZ = nZ
# about y axis
nX = (self.cos_table[y] * oX) - (self.sin_table[y] * oZ)
nZ = (self.sin_table[y] * oX) + (self.cos_table[y] * oZ)
rotated.append(Point3D(x=nX, y=nY, z=nZ))
return rotated
def draw_to_pixmap(self, points, pixmap, gc, style):
'''
'''
# pixmap.draw_line(self.gc, x, y, self.w/2, self.h/2)
# octal inlay flush with end plate
for i in range(7):
pixmap.draw_line(gc, points[i].x, points[i].y, points[i + 1].x, points[i + 1].y)
pixmap.draw_line(gc, points[7].x, points[7].y, points[0].x, points[0].y)
# connections between octal inlays'pipe'
for i in range(8):
pixmap.draw_line(gc, points[i].x, points[i].y, points[i + 8].x, points[i + 8].y)
# octal inlay flush with end plate
for i in range(8, 15):
pixmap.draw_line(gc, points[i].x, points[i].y, points[i + 1].x, points[i + 1].y)
pixmap.draw_line(gc, points[15].x, points[15].y, points[8].x, points[8].y)
# end plate of column
for i in range(16, 19):
pixmap.draw_line(gc, points[i].x, points[i].y, points[i + 1].x, points[i + 1].y)
pixmap.draw_line(gc, points[19].x, points[19].y, points[16].x, points[16].y)
# end plate of column
for i in range(20, 23):
pixmap.draw_line(gc, points[i].x, points[i].y, points[i + 1].x,points[i + 1].y)
pixmap.draw_line(gc, points[23].x, points[23].y, points[20].x, points[20].y)
def iterate(self, pixmap, gc, style):
'''
'''
rotated = self.rotate(self.points, self.z_deg, self.x_deg, self.y_deg)
flattened = self.flatten(rotated)
self.draw_to_pixmap(flattened, pixmap, gc, style)
def move(self, x, y, z):
self.z_deg = self.z_deg + int(z)
self.x_deg = self.x_deg + int(y)
self.y_deg = self.y_deg - int(x)
self.shake()
def shake(self):
if (self.z_deg >= 360):
self.z_deg = self.z_deg - 360
if (self.z_deg < 0):
self.z_deg = self.z_deg + 360
if (self.x_deg >= 360):
self.x_deg = self.x_deg - 360
if (self.x_deg < 0):
self.x_deg = self.x_deg + 360
if (self.y_deg >= 360):
self.y_deg = self.y_deg - 360
if (self.y_deg < 0):
self.y_deg = self.y_deg + 360
--- --- run.py --- --- --- --- --- --- ---
import gtk
import gobject
import random
# ---
from rot import Rot
class Gfx(object):
'''
'''
def __init__(self):
'''
'''
self.b1_down = False
self.b2_down = False
self.b3_down = False
self.b1_x = None
self.b1_y = None
self.rot = Rot()
self.started = False
self.i = 0
self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.win.set_title('Fractured Nature')
self.gw = 640
self.gh = 480 #int(float(self.gw) / 1.618)
self.win.resize(self.gw, self.gh)
self.win.set_position(gtk.WIN_POS_CENTER)
self.win.connect('destroy', gtk.main_quit)
#self.win.realize()
self.da = gtk.DrawingArea()
self.win.add(self.da)
self.da.set_size_request(self.gw, self.gh)
self.win.set_resizable(False)
self.da.connect("expose-event", self.area_expose_cb)
self.da.connect("button_press_event", self.button_press_event)
self.da.connect("button_release_event", self.button_released_event)
self.da.connect("motion_notify_event", self.motion_notify_event)
#self.da.connect("scroll_event", self.scroll_event)
self.da.set_events(
gtk.gdk.EXPOSURE_MASK |
gtk.gdk.BUTTON_PRESS_MASK |
gtk.gdk.BUTTON_RELEASE_MASK |
gtk.gdk.POINTER_MOTION_MASK #|
# gtk.gdk.SCROLL_MASK
)
self.da.show()
self.win.show_all()
def area_expose_cb(self, area, event):
'''
'''
self.area = area
self.style = self.da.get_style()
self.gc = self.style.fg_gc[gtk.STATE_NORMAL]
self.w, self.h = area.window.get_size()
#for i in dir(area.window): print(i)
self.started = True
return True
def button_press_event(self, widget, event):
if (event.button == 1):
self.b1_x = event.x
self.b1_y = event.y
self.b1_down = True
elif (event.button == 3):
self.b3_z = event.x
self.b3_down = True
elif (event.button == 2):
self.b2_down = True
elif (event.button == 4):
print(4)
elif (event.button == 5):
print(5)
return True
def motion_notify_event(self, widget, event):
if (self.b1_down == True):
x = event.x
y = event.y
d_x = x - self.b1_x
d_y = y - self.b1_y
d_z = 0
self.b1_x = x
self.b1_y = y
self.rot.move(d_x, d_y, d_z)
elif (self.b3_down == True):
z = event.x
d_z = z - self.b3_z
d_y = 0
d_x = 0
self.b3_z = z
self.rot.move(d_x, d_y, d_z)
return True
def button_released_event(self, widget, event):
if (event.button == 1):
self.b1_down = False
elif (event.button == 2):
self.b2_down = False
elif (event.button == 3):
self.b3_down = False
return True
def nop(self):
'''
'''
if (self.started != True):
return True
pixmap = gtk.gdk.Pixmap(self.da.window, self.gw, self.gh, depth=-1)
pixmap.draw_rectangle(self.style.white_gc, True, 0, 0, self.gw, self.gh)
self.rot.iterate(pixmap, self.gc, self.style)
self.area.window.draw_drawable(self.gc, pixmap, 0, 0, 0, 0, -1, -1)
self.area.show()
return True # repeat
g = Gfx()
delay = 50
g.timer = gobject.timeout_add(delay, g.nop)
gtk.main()
Sunday, October 31, 2010
WPF Attached Behaviours - Calling a Method on the View
http://shujaatsiddiqi.blogspot.com/2010/08/attached-behaviors.html
Friday, October 29, 2010
Wednesday, October 27, 2010
Classes from XML, XSD with xsd.exe
MS supplies a command-line tool that generates C# classes from XSD/XML/Xetc.
ML Schema Definition Tool (Xsd.exe)
http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.80).aspx
ML Schema Definition Tool (Xsd.exe)
http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.80).aspx
Easy Proxy Switching with Chrome
I find myself in a situation where I have to switch my proxy on and off very frequently (_many_ times a day), and it's a bit of a hassle to go through the whole multi-click rigmarole, but, thanks to a handy Chrome extension called, somewhat unimaginatively, but wholly functionally - 'SwitchProxy' @ http://www.chromeextensions.org/utilities/switch-proxy/.
I'll try and report back if this has resulted in the total compromising of my security. In the mean time, let's hope not.
I'll try and report back if this has resulted in the total compromising of my security. In the mean time, let's hope not.
Monday, October 25, 2010
E72 Mail for Exchange
Connecting Nokia's with Mail for Exchange
http://copeohs.net/blogs/creativepossibilities/archive/2010/03/09/Connecting-Nokia_2700_s-with-Mail-for-Exchange.aspx
http://copeohs.net/blogs/creativepossibilities/archive/2010/03/09/Connecting-Nokia_2700_s-with-Mail-for-Exchange.aspx
Sunday, October 24, 2010
geany
Finally, in search of a light-weight text editor for ubuntu - one that has code folding and a decent selection of editing facilities (i.e. a tier above gedit and scite), I come to GEANY.
idiotuser@computer:~$ sudo apt-get install geany
Configure with a dark colour scheme from http://download.geany.org/contrib/oblivion2.tar.gz, and you're good to go.
---
Quick Punt:
I've been using Geany for a couple of months now, and I can whole-heartedly recommend it. It could do with a couple more short-cut keys (but maybe they're actually in there somewhere and I've just missed them), but other than that, its a winnner. I've been using it on my Lenovo X100e netbook running Ubuntu 10-1- Meerkat, and it runs snappily, so I can do python dev complete with both basic predictive text and symbol explorers, v.nice. For those of you who are not quite VI/EMACS streetfighters, but want a fast but solid python IDE, rub this lamp.
idiotuser@computer:~$ sudo apt-get install geany
Configure with a dark colour scheme from http://download.geany.org/contrib/oblivion2.tar.gz, and you're good to go.
---
Quick Punt:
I've been using Geany for a couple of months now, and I can whole-heartedly recommend it. It could do with a couple more short-cut keys (but maybe they're actually in there somewhere and I've just missed them), but other than that, its a winnner. I've been using it on my Lenovo X100e netbook running Ubuntu 10-1- Meerkat, and it runs snappily, so I can do python dev complete with both basic predictive text and symbol explorers, v.nice. For those of you who are not quite VI/EMACS streetfighters, but want a fast but solid python IDE, rub this lamp.
EMACS
COLOUR SCHEME
stack overflow - http://stackoverflow.com/questions/1132919/how-do-i-set-up-emacs-colors-correctly
emacs fu - http://emacs-fu.blogspot.com/2009/03/color-theming.html
stack overflow - http://stackoverflow.com/questions/1132919/how-do-i-set-up-emacs-colors-correctly
emacs fu - http://emacs-fu.blogspot.com/2009/03/color-theming.html
PyXTree - pyGTK TreeView ElementTree XML Viewer
PyXTree is a minimal python xml viewer.
Written in python (download), pyxtree uses the treeview and scrolledwindow controls from the pyGTK download) UI, together with the ElementTree xml library that is included in the python standard library.
Written in python (download), pyxtree uses the treeview and scrolledwindow controls from the pyGTK download) UI, together with the ElementTree xml library that is included in the python standard library.
# --- --- --- --- --- --- --- --- --- --- --- ---
from optparse import OptionParser
# pyGTK --- --- --- --- --- --- --- --- ---
import pygtk
pygtk.require('2.0')
import gtk
# ElementTree - --- --- --- --- --- --- ---
import xml.etree.ElementTree as ET
# --- --- --- --- --- --- --- --- --- --- --- ---
import sys
xml_2_ns = {
'http://www.s3.org/XML/1998/namespace' : 'xml',
}
ns_2_xml = {
'xml' : 'http://www.s3.org/XML/1998/namespace',
}
def extend_tree(treestore, element, parent_node, ns_list):
'''
'''
#import pdb; pdb.set_trace()
node_label = '%s' % strip_ns_from_str(element.tag, ns_list)
if element.text != None:
element_text = element.text.strip()
if (len(element_text) > 0):
element_text = strip_ns_from_str(element_text, ns_list)
#discard = treestore.append(node, [element_text])
node_label = 'e %s : %s' % (node_label, element_text)
node = treestore.append(parent_node, [node_label])
# add attribute name/val pairs to node
for name, value in element.items():
name = strip_ns_from_str(name, ns_list)
value = strip_ns_from_str(value, ns_list)
label = 'a %s = %s' % (name, value)
treestore.append(node, [label])
# recurse over children
for child_element in element.getchildren():
child_node = extend_tree(treestore, child_element, node, ns_list)
return node
def etree_to_gtk_treestore(tree):
'''
construct gtk.TreeStore(str) from ElementTree
'''
treestore = gtk.TreeStore(str)
ns_list = ns_list_from_tree(tree)
element = tree.getroot()
node_label = '%s' % strip_ns_from_str(element.tag, ns_list)
if element.text != None:
element_text = element.text.strip()
if (len(element_text) > 0):
element_text = strip_ns_from_str(element_text, ns_list)
node_label = 'e %s : %s' % (node_label, element_text)
node = treestore.append(None, [node_label])
for child_e in element.getchildren():
extend_tree(treestore, child_e, node, ns_list)
# add attribute name/val pairs to node
for name, value in element.items():
name = strip_ns_from_str(name, ns_list)
value = strip_ns_from_str(value, ns_list)
label = '%s = %s' % (name, value)
treestore.append(None, [label])
# if ns is global
for ns in ns_list:
label = 'xmlns : %s' % ns
treestore.append(None, [label])
return treestore
def ns_from_string(s):
left = s.find('{')
right = s.find('}')
ns = s[left+1:right]
return ns
def process_potential_ns_string(s, ns_list):
if s == None:
return
if (s.find('{') != -1) and (s.find('}') != -1):
ns = ns_from_string(s)
if (ns not in ns_list):
ns_list.append(ns)
def ns_list_from_element(el, ns_list):
# tag
process_potential_ns_string(el.tag, ns_list)
# text
process_potential_ns_string(el.text, ns_list)
# attributes
for name, value in el.items():
process_potential_ns_string(name, ns_list)
process_potential_ns_string(value, ns_list)
for child_el in el.getchildren():
ns_list_from_element(child_el, ns_list)
return ns_list
def ns_list_from_tree(etree):
'''
'''
ns_list = []
root_e = etree.getroot()
# tag
process_potential_ns_string(root_e.tag, ns_list)
# text
process_potential_ns_string(root_e.text, ns_list)
# attributes
for name, value in root_e.items():
process_potential_ns_string(name, ns_list)
process_potential_ns_string(value, ns_list)
# child elements
for child_el in root_e.getchildren():
ns_list_from_element(child_el, ns_list)
return ns_list
def strip_ns_from_str(s, ns_list):
stripped = str(s)
for ns in ns_list:
token = '{%s}' % ns
loc = stripped.find(token)
if (loc != -1):
stripped = stripped[:loc] + stripped[loc + len(token):len(stripped)]
return stripped
class XMLTreeView:
'''
'''
def delete_event(widget, event, data=None):
'''
not an instance method, cuz gtk will not call as such
'''
gtk.main_quit()
return False
def __init__(self, path, title='pyxtree - python XML tree viewer', xsize=900, ysize = 500):
'''
'''
etree = ET.parse(path)
self.treestore = etree_to_gtk_treestore(etree)
self.window = gtk.Dialog()
self.window.connect("destroy", self.delete_event)
self.window.set_border_width(0)
self.swin_tree = gtk.ScrolledWindow()
self.swin_tree.set_border_width(10)
self.swin_tree.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
self.window.vbox.pack_start(self.swin_tree, True, True, 0)
self.swin_text = gtk.ScrolledWindow()
self.swin_text.set_border_width(10)
self.swin_text.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
self.window.vbox.pack_start(self.swin_text, True, True, 0)
self.window.set_title(title)
self.window.set_size_request(xsize, ysize)
self.window.connect("delete_event", self.delete_event)
# create the TreeView using treestore
self.treeview = gtk.TreeView(self.treestore)
self.tvcolumn = gtk.TreeViewColumn(path)
self.treeview.append_column(self.tvcolumn)
self.cell = gtk.CellRendererText()
# add the cell to the tvcolumn and allow it to expand
self.tvcolumn.pack_start(self.cell, True)
# set the cell "text" attribute to column 0 - retrieve text
# from that column in treestore
self.tvcolumn.add_attribute(self.cell, 'text', 0)
# make it searchable
self.treeview.set_search_column(0)
# Allow sorting on the column
#self.tvcolumn.set_sort_column_id(0)
# Allow drag and drop reordering of rows
#self.treeview.set_reorderable(True)
self.swin_tree.add_with_viewport(self.treeview)
self.swin_tree.show()
xfile = open(path, 'r')
xtext = xfile.read()
xfile.close()
label = gtk.Label(xtext)
# ns_list = ns_list_from_tree(etree)
# ns_str = ''
# for ns in ns_list:
# ns_str = ns_str + str(ns) + '\n'
# label = gtk.Label(ns_str)
label.set_alignment(xalign=0, yalign=0.5)
self.swin_text.add_with_viewport(label)
self.swin_text.show()
self.window.show_all()
def main(path = None):
'''
'''
if (path == None):
filechooser = gtk.FileChooserDialog(
title=None,
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
filter_stdxmlfiles = gtk.FileFilter()
filter_stdxmlfiles.set_name("Std XML Files")
filter_stdxmlfiles.add_pattern("*.xml")
filter_stdxmlfiles.add_pattern("*.wsdl")
filechooser.add_filter(filter_stdxmlfiles)
filter_allfiles = gtk.FileFilter()
filter_allfiles.set_name("All files")
filter_allfiles.add_pattern("*")
filechooser.add_filter(filter_allfiles)
response = filechooser.run()
if response == gtk.RESPONSE_OK:
path = filechooser.get_filename()
elif response == gtk.RESPONSE_CANCEL:
pass
#log failure
filechooser.destroy()
if (path != None):
tree_view = XMLTreeView(path)
gtk.main()
return
def src_file_from_cmd_args(args):
'''
'''
akapy = [
'pyxtree',
'pyxtree.py',
'python',
'python.exe',
'python2.5',
'python25.exe',
]
cleaned = []
for arg in args:
washed = arg.strip().lower()
if (washed not in akapy) and (washed.find('python') == -1):
cleaned.append(washed)
if len(cleaned) == 0:
cleaned = [None]
return cleaned
def configure_logging(LOG_FILENAME='pyxtree.log'):
import logging
logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO)
log = logging.getLogger()
return log
def setup_command_line_options():
'''
using optparse
define command line arguments
return target filename, None if none specified
'''
parser = OptionParser()
parser.add_option('-f', dest='filename', help='target xml file to view')
(options, args) = parser.parse_args()
return(options.filename)
if __name__ == "__main__":
print('\nPyXTree - david.barkhuizen@gmail.com')
print('help: pyxtree -h\n')
xmlfilepath = setup_command_line_options()
log = configure_logging()
log.info('target file specified at command line = %s' % xmlfilepath)
main(path=xmlfilepath)
Thursday, October 21, 2010
Useful DataBase MetaData Scripts
1. given a column name, return a list of tables with similar columns names
2. given a table name, return a list of tables with similar name
declare @targetColumnName varchar(500)
set @targetColumnName = '%YourTargetColumnNameHere%'
select so.[name] as TableName, sc.[name] as ColumnName
from sysobjects so
inner join syscolumns sc on (so.[id] = sc.[id])
where (so.[type] = 'U') and (sc.[name] like @targetColumnName)
2. given a table name, return a list of tables with similar name
declare @targetTableName varchar(500)
set @targetTableName = '%Entity%'
select so.[name] as TableName
from sysobjects so
where (so.[type] = 'U') and (so.[name] like @targetTableName)
Sunday, September 12, 2010
MySQLdb - 1153, 'Got a packet bigger than 'max_allowed_packet' bytes'
the technology
- mySQL Server 5.?
- python 2.6
- MySQLdb 2.3.1?
- Windows 7
the scenario
1. import MySQLdb
2. create a connection to the db:
> connxn = MySQLdb.connect(params_dict)
3. loop, re-using the connection, each time inserting say 250 records in one query
> cursor = connxn.cursor()
> cursor.execute(multi_record_insert_statement)
> cursor.close()
> connxn.commit()
problem is, i was getting the following errors:
- 1153, 'Got a packet bigger than 'max_allowed_packet' bytes'
then, when i tried to create a new connection, i was getting
- 2006, 'MySQL server has gone away'
- mySQL Server 5.?
- python 2.6
- MySQLdb 2.3.1?
- Windows 7
the scenario
1. import MySQLdb
2. create a connection to the db:
> connxn = MySQLdb.connect(params_dict)
3. loop, re-using the connection, each time inserting say 250 records in one query
> cursor = connxn.cursor()
> cursor.execute(multi_record_insert_statement)
> cursor.close()
> connxn.commit()
problem is, i was getting the following errors:
- 1153, 'Got a packet bigger than 'max_allowed_packet' bytes'
then, when i tried to create a new connection, i was getting
- 2006, 'MySQL server has gone away'
Saturday, September 11, 2010
ubuntu splash screen
How to change the gnome splashimage.
1. Put the splash image you want in "png" format and store it in /usr/share/pixmaps/splash. (You can use Nautilus or the "cp" or the "mv" command from the terminal window if you want. Just remember to use "sudo" before your command. )
2. Press ALT-F2 then at the prompt type "gconf-editor" (without the quotes).
3. Click on "apps" then "gnome-session" then "options".
4. To the right of the Name "splash_image" double click on the Value "splash/ubuntu-splash.png".
5. Change "splash/ubuntu-splash.png" to reflect your new splash image: "splash/newsplash.png".
6. Click on "File" then "Quit".
7. Logout then login in again to see your new splashimage.
1. Put the splash image you want in "png" format and store it in /usr/share/pixmaps/splash. (You can use Nautilus or the "cp" or the "mv" command from the terminal window if you want. Just remember to use "sudo" before your command. )
2. Press ALT-F2 then at the prompt type "gconf-editor" (without the quotes).
3. Click on "apps" then "gnome-session" then "options".
4. To the right of the Name "splash_image" double click on the Value "splash/ubuntu-splash.png".
5. Change "splash/ubuntu-splash.png" to reflect your new splash image: "splash/newsplash.png".
6. Click on "File" then "Quit".
7. Logout then login in again to see your new splashimage.
ssh to ubuntu machine
http://mybroadband.co.za/vb/showthread.php/52204-How-to-do-VPN-with-iBurst-with-Linux
https://wiki.ubuntu.com/AdvancedOpenSSH
Did you install the SSH server on your Ubuntu box? Check with this:
Code:
which sshd
and if you installed check with this if it's running:
Code:
ps -ef | grep sshd
If both are true then check if you have it listening:
Code:
netstat -aln | grep ":22"
Kind regards,
Eric
Make sure SSH is running on Ubuntu:
Code:
ps -ae | grep sshd
It should return something like:
Code:
720 ? 00:00:00 sshd
https://wiki.ubuntu.com/AdvancedOpenSSH
Did you install the SSH server on your Ubuntu box? Check with this:
Code:
which sshd
and if you installed check with this if it's running:
Code:
ps -ef | grep sshd
If both are true then check if you have it listening:
Code:
netstat -aln | grep ":22"
Kind regards,
Eric
Make sure SSH is running on Ubuntu:
Code:
ps -ae | grep sshd
It should return something like:
Code:
720 ? 00:00:00 sshd
Friday, September 10, 2010
Thursday, September 9, 2010
Python is Not Java - PJ Eby
When arriving at python from a statically typed OO language such as c# or java, many people are initially tempted to emulate the formalism required by a statically typed language. Like S&M being permissible in certain liberal jurisdictions, the free-form multi-paradigm environment that is python allows you to follow your slavish inclinations if you so desire, but it would be entirely your own choice - as python generally always offers alternatives, and often a more compact or concise one than that which first comes to the the python-naive mind.
Phillip J. "PJ" Eby
Python is Not Java
Phillip J. "PJ" Eby
Python is Not Java
The Joel Test
http://www.joelonsoftware.com/articles/fog0000000043.html
http://en.wikipedia.org/wiki/The_Joel_Test
http://stackoverflow.com/questions/402050/administering-the-joel-test
The Joel Test
Do you use source control?
Can you make a build in one step?
Do you make daily builds?
Do you have a bug database?
Do you fix bugs before writing new code?
Do you have an up-to-date schedule?
Do you have a spec?
Do programmers have quiet working conditions?
Do you use the best tools money can buy?
Do you have testers?
Do new candidates write code during their interview?
Do you do hallway usability testing?
http://en.wikipedia.org/wiki/The_Joel_Test
http://stackoverflow.com/questions/402050/administering-the-joel-test
The Joel Test
Do you use source control?
Can you make a build in one step?
Do you make daily builds?
Do you have a bug database?
Do you fix bugs before writing new code?
Do you have an up-to-date schedule?
Do you have a spec?
Do programmers have quiet working conditions?
Do you use the best tools money can buy?
Do you have testers?
Do new candidates write code during their interview?
Do you do hallway usability testing?
Friday, September 3, 2010
Use dotNET 2.0 Assembly in dotNET 4.0
ERROR
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
FIX
ensure that app.config contains the following
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
FIX
ensure that app.config contains the following
Thursday, September 2, 2010
Exception Handling in Python
quoted directly from Doug Hellman
This construction prevents the original exception from being overwritten by the latter, and preserves the full stack in the traceback.
#!/usr/bin/env python
import sys
import traceback
def throws():
raise RuntimeError('error from throws')
def nested():
try:
throws()
except Exception, original_error:
try:
raise
finally:
try:
cleanup()
except:
pass # ignore errors in cleanup
def cleanup():
raise RuntimeError('error from cleanup')
def main():
try:
nested()
return 0
except Exception, err:
traceback.print_exc()
return 1
if __name__ == '__main__':
sys.exit(main())
This construction prevents the original exception from being overwritten by the latter, and preserves the full stack in the traceback.
Wednesday, September 1, 2010
WPF Navigation OverView
file:///C:/Users/david/Desktop/coding_ref/dotNET/WPF/WPF%20Navigation%20-%20Paul%20Stovell.htm
Thursday, August 26, 2010
WPF - Error 1 - Program does not contain a static 'Main' method suitable for an entry point
Error 1 Program does not contain a static 'Main' method suitable for an entry point.
The scenario in which this arose for me was after importing a WPF project built in VS2008 into VS2010.
Solution
Set the 'build action' property on App.xaml to 'Application Definition'.
The scenario in which this arose for me was after importing a WPF project built in VS2008 into VS2010.
Solution
Set the 'build action' property on App.xaml to 'Application Definition'.
Tuesday, August 24, 2010
To Execute a VSTO from a NetWork Drive
To Add a DLL to the GAC under Windows7
http://www.codeproject.com/KB/winsdk/AddToGAC.aspx
location of gacutil.exe under Windows7
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
location of caspol.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319
http://www.codeproject.com/KB/winsdk/AddToGAC.aspx
location of gacutil.exe under Windows7
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
location of caspol.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319
Sunday, August 22, 2010
Tuesday, August 17, 2010
Windows7 Power Scheme from the Command Line - PowerCFG
open an admin command prompt by right-clicking on the command prompt, which can be found @ (Start > All Programs > Accessories), and selecting 'run as administrator'.
to list existing power schemes and associated GUIDs
powercfg -l
select guid (right-click > mark), copy (enter)
to set the active config
powercfg -s guid
to list existing power schemes and associated GUIDs
powercfg -l
select guid (right-click > mark), copy (enter)
to set the active config
powercfg -s guid
Sunday, August 15, 2010
sqLite
Dr Dobbs
http://www.drdobbs.com/184401773;jsessionid=0COIHAUN55BUJQE1GHOSKH4ATMY32JVN
limitations of sqlite
- http://www.sqlite.org/omitted.html
- http://www.sqlite.org/limits.html
- http://www.sqlite.org/limits.html
http://www.drdobbs.com/184401773;jsessionid=0COIHAUN55BUJQE1GHOSKH4ATMY32JVN
limitations of sqlite
- http://www.sqlite.org/omitted.html
- http://www.sqlite.org/limits.html
- http://www.sqlite.org/limits.html
Friday, August 6, 2010
Data Access - Context based vs Generic
http://ayende.com/Blog/archive/2010/08/06/data-access-is-contextual-a-generic-approach-will-fail.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+AyendeRahien+(Ayende+%40+Rahien)
Agile Dev & Pair Programming
Martin Fowler from Thoughtworks speaks at Univ du SI
http://universite-du-si.com/fr/conferences/6/sessions/909
http://agilemanifesto.org/
http://martinfowler.com/articles/newMethodology.html
http://www.scrum.org/
Ken Schwaber
http://www.youtube.com/watch?v=IyNPeTn8fpo
Agile Modeling
http://www.agilemodeling.com/essays/introductionToAM.htm
http://universite-du-si.com/fr/conferences/6/sessions/909
http://agilemanifesto.org/
http://martinfowler.com/articles/newMethodology.html
http://www.scrum.org/
Ken Schwaber
http://www.youtube.com/watch?v=IyNPeTn8fpo
Agile Modeling
http://www.agilemodeling.com/essays/introductionToAM.htm
Tuesday, August 3, 2010
Debugging Managed Code Called from an UnManaged External EXE
MSDN Bug Report with Problem Description:
Cannot debug .NET 2.0/3.0/3.5 code using F5 in mixed mode from native c++ projects or c# project with 'start external program' set to native .exe.
For pure native c++ projects, when mixed mode debugging is selected in the properties of the startup project and the user presses 'F5', VS 2010 starts debugging for native and .NET 4.0 code - this assumption is not justified, since the user may want to debug native and .NET 2.0 code.
MSDN Fix:
There are two scenarios however that people have been encountering since Visual Studio 2010 released where Visual Studio cannot correctly determine which engine to attach with, and therefore uses the default of 4.0 leaving 2.0/3.0/3.5 applications “un-debuggable”; (1) developing a class library plug-in for a third party application (Excel, Work, AutoCAD, etc), and (2) interop debugging when launching a native .exe project. In both cases the symptoms will be the same, you will be unable to hit breakpoints in your managed code (they will be hollow with a message that “No symbols have been loaded for this document”) as well as being unable to step into the managed code.
As I explained above, the cause of this is the managed application is 3.5 or previous, and the debugger is attached with the 4.0 engine. The best workaround is to add a tag to your application’s *.exe.config file. For example, if I am debugging the application foo.exe I would edit (or create if necessary) the foo.exe.config file in the same directory as foo.exe. I would then add the tag with the correct version of the .NET runtime in the section as shown in the example below. This will let Visual Studio know which version of the .NET runtime you will be running (so if you are developing a class library plug-in for Excel, you would add the tag to the excel.exe.config file).
<!-- sample foo.exe.config -->
<?xml version ="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.[version on your machine]" />
</startup>
</configuration>
To determine the correct [version on your machine] look in the “C:\Windows\Microsoft.NET\Framework” directory for the most recent “v2.0.xxxxx” folder.
Cannot debug .NET 2.0/3.0/3.5 code using F5 in mixed mode from native c++ projects or c# project with 'start external program' set to native .exe.
For pure native c++ projects, when mixed mode debugging is selected in the properties of the startup project and the user presses 'F5', VS 2010 starts debugging for native and .NET 4.0 code - this assumption is not justified, since the user may want to debug native and .NET 2.0 code.
MSDN Fix:
There are two scenarios however that people have been encountering since Visual Studio 2010 released where Visual Studio cannot correctly determine which engine to attach with, and therefore uses the default of 4.0 leaving 2.0/3.0/3.5 applications “un-debuggable”; (1) developing a class library plug-in for a third party application (Excel, Work, AutoCAD, etc), and (2) interop debugging when launching a native .exe project. In both cases the symptoms will be the same, you will be unable to hit breakpoints in your managed code (they will be hollow with a message that “No symbols have been loaded for this document”) as well as being unable to step into the managed code.
As I explained above, the cause of this is the managed application is 3.5 or previous, and the debugger is attached with the 4.0 engine. The best workaround is to add a
<!-- sample foo.exe.config -->
<?xml version ="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.[version on your machine]" />
</startup>
</configuration>
To determine the correct [version on your machine] look in the “C:\Windows\Microsoft.NET\Framework” directory for the most recent “v2.0.xxxxx” folder.
Saturday, July 31, 2010
change apache/apache2 port
'ports.conf', if you're using ubuntu, is located @ '/etc/apache' (apache), '/etc/apache2' (apache2)
$ sudo gedit etc/apache2/ports.conf
$ sudo gedit etc/apache2/ports.conf
Friday, July 30, 2010
netwrokking
http://blog.ksplice.com/2010/07/learning-by-doing-writing-your-own-traceroute-in-8-easy-steps/
Sunday, July 25, 2010
to mount a disk in linux
all devices are listed as files in /dev
e.g. $ ls -l /dev
for a list of all devices in /dev
to filter it down to devices containing the string 'sda'
$ ls -l /dev | grep -i sda
which for example returns
ptysd
sda
sda1
sda2
sda5
sdb
... and more
then
$ sudo fdisk -l /dev/sda
fdisk in this case yields partition information for the device
fdisk --help for usage
also
$ cat /var/log/messages
e.g. $ ls -l /dev
for a list of all devices in /dev
to filter it down to devices containing the string 'sda'
$ ls -l /dev | grep -i sda
which for example returns
ptysd
sda
sda1
sda2
sda5
sdb
... and more
then
$ sudo fdisk -l /dev/sda
fdisk in this case yields partition information for the device
fdisk --help for usage
also
$ cat /var/log/messages
mod_wsgi
mod_wsgi is now the effective supercedent of mod_python
http://code.google.com/p/modwsgi/
ubuntu package = libapache2-mod-wsgi
ERROR
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
FIX - courtesy of Mohamed Aslam
http://mohamedaslam.com/how-to-fix-apache-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127011-for-servername-error-on-ubuntu/
http://code.google.com/p/modwsgi/
ubuntu package = libapache2-mod-wsgi
ERROR
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
FIX - courtesy of Mohamed Aslam
http://mohamedaslam.com/how-to-fix-apache-could-not-reliably-determine-the-servers-fully-qualified-domain-name-using-127011-for-servername-error-on-ubuntu/
What is mod_python ?
mod_python
1. o'Reilly article by Gregory Trubetskoy
2. WikiPedia
but, most importantly, it appears that
MOD_PYTHON IS DEAD !
LONG LIVE MOD_WSGI !
WSGI Project Page @ Google Code
modpython-project-is-now-officially-dead
modpython-project-soon-to-be-officially-dead
from django
Blog Piece
StackOverflow Thread
1. o'Reilly article by Gregory Trubetskoy
2. WikiPedia
but, most importantly, it appears that
MOD_PYTHON IS DEAD !
LONG LIVE MOD_WSGI !
WSGI Project Page @ Google Code
modpython-project-is-now-officially-dead
modpython-project-soon-to-be-officially-dead
from django
Blog Piece
StackOverflow Thread
to run a pythonscript from ubuntu command line
to run a pythonscript from ubuntu command line
to execute script 'hw.py'
from the command line
in the director of 'hw.py' [i.e. if you entered 'ls' you would see hw.py in the listing)
first, make script executable by granting rights
$ sudo chmod +x hw.py
add the following line to the beginning of the script
#!/usr/bin/python
this instructs the shell to hand the script over to the the python runtime binary,
which is located /usr/bin/python
to execute script 'hw.py'
from the command line
in the director of 'hw.py' [i.e. if you entered 'ls' you would see hw.py in the listing)
first, make script executable by granting rights
$ sudo chmod +x hw.py
add the following line to the beginning of the script
#!/usr/bin/python
this instructs the shell to hand the script over to the the python runtime binary,
which is located /usr/bin/python
Wednesday, July 21, 2010
Tuesday, July 20, 2010
DocPy - Python Source Doc Gen
# docpy.py - david.barkhuizn@gmail.com
# 1. module methods - signature, followed by docstring
# 2. module fields ?
# 3. module classes
# class name, parent class, __init__ method parameters & docstring
# instance fields (get from self.? refs in __init__ method)
# ---------------------------------------------------------------
# ISSUES
# need to strip out classes before extracting method info
# can't handle multi-line method signatures
# ---------------------------------------------------------------
import sys
# ---------------------------------------------------------------
single_marker = '\'\'\''
double_marker = '\"\"\"'
# ---------------------------------------------------------------
class MethodInfo:
def __init__(self, method_name, params, docstrings):
'''
method_name - string
params - list of param name strings
'''
self.method_name = method_name
self.params = params
self.docstrings = docstrings
# ---------------------------------------------------------------
def load_text_file(file_path):
'''
return list of lines in text file @ 'file_path'
'''
try:
text_file = open(file_path, 'r')
text_block = text_file.read()
lines = text_block.split('\n')
text_file.close()
return lines
except Exception, err:
print('error during reading of text file %s' % file_path)
print(err)
return []
def src_file_path_from_cmdargs():
valid_args = []
for arg in sys.argv:
if arg.lower() not in ['docpy.py', 'python']:
valid_args.append(arg.lower())
return 'docpy.py'
if len(valid_args) != 1:
return ''
else:
return valid_args[0]
def get_sig_line_idxs(lines):
'''
lines = list of lines in python source file (in sequence)
'''
token = 'def '
indices = []
for i in range(len(lines)):
if lines[i].strip()[:4] == token:
indices.append(i)
return indices
def parse_method_sig(sig):
# e.g.' def parse_methodsig(sig):#comment '
sig = sig.strip()
# e.g.'def parse_methodsig(sig):#comment'
sig = sig[4:len(sig)]
# e.g.'parse_methodsig(sig):#comment'
i = sig.find('#')
if i != -1:
sig = sig[:i-1]
# e.g.'parse_methodsig(sig):
left = sig.find('(')
right = sig.rfind(')')
meth_name = sig[:left]
params = []
if right - left != 1:
params = sig[left+1:right]
params = params.replace(',', ' ')
got_double = True
while got_double == True:
got_double = (params.find(' ') != -1)
if got_double:
params = params.replace(' ', ' ')
params = params.split(' ')
return MethodInfo(meth_name, params, [])
def extract_single_line_docstring(docstring):
'''example of single line method docstring'''
lsingle = docstring.find(single_marker)
ldouble = docstring.find(double_marker)
marker = ''
left = -1
if lsingle != -1:
marker = single_marker
left = lsingle
elif ldouble != -1:
marker = double_marker
left = ldouble
else:
return ''
right = docstring.rfind(marker)
if (right != -1) and (right != left):
return docstring[left+3:right]
else:
return ''
def strip_leading_triplequotes(line):
left = line.find(single_marker)
if left == -1:
left = line.find(double_marker)
if left == -1:
return ''
return line[left + 3:]
def strip_trailing_triplequotes(line):
right = line.rfind(double_marker)
if right == -1:
right = line.rfind(double_marker)
if right == -1:
return ''
return line[:right]
def extract_docstrings(lines, meth_sig_idx, next_meth_sig_idx):
# determine line indices of starting and ending triple quotes
start = -1
end = -1
for i in range(meth_sig_idx + 1, next_meth_sig_idx):
line = lines[i]
sidx = line.find(single_marker)
if sidx == -1:
sidx = line.find(double_marker)
if sidx != -1:
if start == -1:
start = i
else:
end = i
break
if start == -1:
return []
elif end == -1:
single_line = extract_single_line_docstring(lines[start])
if single_line != '':
return [ single_line ]
else:
return []
else:
docstrings = []
for i in range(start, end + 1):
no_whitespace = lines[i].strip()
if i == start:
stripped = strip_leading_triplequotes(no_whitespace)
if stripped != '':
docstrings.append(stripped)
elif i == end:
stripped = strip_trailing_triplequotes(no_whitespace)
if stripped != '':
docstrings.append(stripped)
else:
docstrings.append(no_whitespace)
return docstrings
def get_method_info(lines, meth_sig_idx, next_meth_sig_idx):
method_info = parse_method_sig(lines[meth_sig_idx])
method_info.docstrings = extract_docstrings(lines, meth_sig_idx, next_meth_sig_idx)
return method_info
def mock_method(one, two, three, four):
print('vokol')
def display_module_method_info(meth_info):
print(meth_info.method_name)
for p in meth_info.params:
print(' ' + p)
for docstring in meth_info.docstrings:
print(docstring)
def main():
text_file_path = src_file_path_from_cmdargs()
lines = load_text_file(text_file_path)
sig_line_idxs = get_sig_line_idxs(lines)
module_methods_info = []
for i in range(len(sig_line_idxs)):
idx = sig_line_idxs[i]
if i < len(sig_line_idxs) - 1:
next_idx = sig_line_idxs[i + 1]
else:
next_idx = len(sig_line_idxs)
module_methods_info.append( get_method_info(lines, idx, next_idx) )
for meth_info in module_methods_info:
display_module_method_info(meth_info)
if __name__ == '__main__':
main()
Monday, July 19, 2010
Untangling Object Dependencies in MS-SQL-08
useful TechRepublic Blog
1. get a list of all system objects from sys.objects
name,object_id,parent_object_id,type
2. determine individual dependencies from sys.sql_dependencies
object_id, referenced_major_id
3. use a topological sort to untangle the list of dependencies to a simple dependency tree.
1. get a list of all system objects from sys.objects
name,object_id,parent_object_id,type
2. determine individual dependencies from sys.sql_dependencies
object_id, referenced_major_id
3. use a topological sort to untangle the list of dependencies to a simple dependency tree.
Sunday, July 18, 2010
setting up iburst driver for ubuntu 8-10 intrepid ibex
http://blog.hostinghabitat.com/2009/02/iburst-usb-modem-installation-tutorial.html
Saturday, July 17, 2010
yapyfin.py Python Yahoo Finance Client
Yahoo Finance exposes a large amount of historical US equity data via their html api. The python code below downloads the open-high-low-close-adjclose-volume data for British Petroleum (BP) = stock ticker symbol BP, between 1900/01/01 and 2010/07/18, to text file BP.csv
import httplib
httplib.HTTPConnection.debuglevel = 1
import urllib
def enc_quote(ticker, fromY, fromM, fromD, toY, toM, toD):
quote = dict()
quote['s'] = ticker
quote['a'] = fromM
quote['b'] = fromD
quote['c'] = fromY
quote['d'] = toD
quote['e'] = toM
quote['f'] = toY
quote['g'] = "d"
return urllib.urlencode(quote)
url_stem = 'http://ichart.yahoo.com/table.csv?'
quote_tokens = enc_quote('BP', '1900', '01', '01', '2010', '07', '18')
url = url_stem + "&ignore=.csv" + quote_tokens
f = urllib.urlopen(url)
body = f.read()
f.close()
try:
f = open('BP.csv', 'w')
f.write(body)
f.close()
except Exception, err:
print('ERROR: %s\n' % str(err))
Labels:
python,
python yahoo finance client,
service,
yahoo_finance
Thursday, July 15, 2010
PyMSSql - import _mssql - ImportError: DLL load failed: The specific module could not be found
under windows xp pro,
When attempting to import pymssql.py,
I experienced the following error:
"
import _mssql
ImportError: DLL load failed: The specific module could not be found
"
So this is all a bit cryptic, but after googling, which suggested using a windows diagnostic tool [ProcessMonitor] to locate the failing process, it turns out that what is missing is an (accessible) copy of 'mscvr71.dll', which can be downloaded off the net, and should be copied to 'c:\windows\system32\', or 'c:\windows\system\' if running 64bit windows.
you then need to run 'regsvr32 msvcr71.dll' from the command line, in the directory that you copied the dll to.
cant find entrypoint
if you get a 'cant find entrypoint' type error message, its actually still all ok, pymssql should run just fine by that point.
When attempting to import pymssql.py,
I experienced the following error:
"
import _mssql
ImportError: DLL load failed: The specific module could not be found
"
So this is all a bit cryptic, but after googling, which suggested using a windows diagnostic tool [ProcessMonitor] to locate the failing process, it turns out that what is missing is an (accessible) copy of 'mscvr71.dll', which can be downloaded off the net, and should be copied to 'c:\windows\system32\', or 'c:\windows\system\' if running 64bit windows.
you then need to run 'regsvr32 msvcr71.dll' from the command line, in the directory that you copied the dll to.
cant find entrypoint
if you get a 'cant find entrypoint' type error message, its actually still all ok, pymssql should run just fine by that point.
Tuesday, July 13, 2010
Sunday, July 11, 2010
Python Client Consumes WCF Web Service
End-Point = ABC
- Address
- Binding
- Contract
WSDL Components
definition
types
message
portType = interface implementation
operation
input
output
binding = abstract interface
operation
documentation
input
output
service
wsdl:port (name, binding)
x:address (location)
Example Publicly Accessible / iNet WSDL
GlobalWeather.com
- http://www.webservicex.com/globalweather.asmx?wsdl
wsf.cdyne.com
- http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL
thomas-bayer.com
- http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
External Links
- Make a SOAP client with Python
- StackOverFlow - How can I consume a WSDL (SOAP) web service in Python?
- SourceForge - Python Web Services Project
Subscribe to:
Posts (Atom)