2008-05-31

 

tkcvs problem on debian/ubuntu systems

As many have discovered, there is a annoying bug in the Tcl version shipped with Debian/Ubuntu (which may not be the case with the latest Ubuntu - I am still one release behind on my day-to-day laptop). In any case, here is my fix:

In the file /usr/share/tkcvs/cvs.tcl search for the line "set juliandate [clock scan $date -gmt yes]" (around line number 143).

Add a line just before it, so that your code now reads:


} else {
set date [concat [lindex $date 0] [lindex $date 1]]
set juliandate [clock scan $date -gmt yes]

That's it. Restart tkcvs and all should work now.

2008-05-03

 

Dynamic Code Execution in Python

Some might remember my earlier experiments in dynamic code execution in Perl. Here is a simple recipe to demonstrate a similar concept in Python:

1 #!/usr/bin/python
2
3 import new
4
5 def importCode(code, name, add_to_sys_modules=False):
6 # code can be any object containing code: a string, a file object, or
7 # a compiled code object. Returns a new module object initialized
8 # by dynamically importing the given code, and optionally adds it
9 # to sys.modules under the given name.
10 #
11 module = new.module(name)
12 if add_to_sys_modules:
13 import sys
14 sys.modules[name] = module
15 exec code in module.__dict__
16 return module
17
18 code = """
19 def testFunc( ):
20 print "
spam!"
21 class testClass(object):
22 def testMethod(self):
23 print "
eggs!"
24 "
""
25
26 m = importCode( code, "test" )
27 m.testFunc( )
28 o = m.testClass( )
29 o.testMethod( )

Hopefully you will find this useful. In theory you can now execute snippets of code from sources like databases and files. I think this has potential for some distributed processing framework :-)

 

Adding to the search path in Pyhton

Simple, really:
import sys
sys.path.append("/home/you/your_modules")


And that's it.

Labels:


2008-05-01

 

You learn something new every day...

I could never figure how to grow/shrink vertical splits in Vim - sad, but true. It never really bothered me, as I rarely used vertical splits, but now that I know how to resize the windows, I used it more and more.

So, to grow/shrink the vertical split:
<ctrl>+W and '<' or '>'


That's it :-)

O - and I found a simple short way to toggle line numbers:
:se nu!

This page is powered by Blogger. Isn't yours?