WinNotify
Posted by rto 2 months and 2 week(s) ago, so far 0 people have commented
Today i found the time to create a small utility i have been needing for some time.
A little background:
I use emacs's rcirc client to talk on irc and on Debian i use the libnotify library's notify-send command to notify me when someone talks to me, as described here.
So now i have created a windows utility to do this: WinNotify which is just a simple command line utility to make windows popup one of those balloon notification dealies.
I am sure it can be applied to other things - please do!
0 Comments
bzrweb-and-other-bazaar-stuff
Posted by rto 4 months and 0 week(s) ago, so far 0 people have commented
Latest commits
35 By Rasmus Toftdahl Olesen posted 3 weeks and 3 day(s) ago
Merge with live site.
34 By Rasmus Toftdahl Olesen posted 3 weeks and 5 day(s) ago
More small fixes.
33 By Rasmus Toftdahl Olesen posted 3 weeks and 5 day(s) ago
Merge with live site.
32 By Rasmus Toftdahl Olesen posted 4 weeks and 1 day(s) ago
First iteration of a Vaca publishing infrastructure.
31 By Rasmus Toftdahl Olesen posted 3 months and 0 week(s) ago
Start using Yahoo's YUI reset, fonts and grids.
30 By Rasmus Toftdahl Olesen posted 3 months and 0 week(s) ago
Add image to RSS feeds.
29 By Rasmus Toftdahl Olesen posted 4 months and 0 week(s) ago
Merge with live.
28 By Rasmus Toftdahl Olesen posted 4 months and 0 week(s) ago
Automatically re-format BAZAAR-using pages after one hour to make sure that the
revision list is up-to-date.
The database has to be manually "refactored" with something like the following:
alter table halfdans_net_pagerevision ADD lastFormatted TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW();
27 By Rasmus Toftdahl Olesen posted 4 months and 0 week(s) ago
Merge with live branch.
26 By Rasmus Toftdahl Olesen posted 4 months and 0 week(s) ago
Add support for listing the latest bazaar branches on wiki pages.
25 By Rasmus Toftdahl Olesen posted 4 months and 0 week(s) ago
Merge with live.
http://halfdans.net/bzr/halfdans.net/trunk
I have played a bit with bzrweb to get it working with mod_python, this was fruitful and you can now browse some code at http://halfdans.net/bzrweb/
Playing with that also got me into working with bzrlib, the python library behind the Bazaar revision control system. To try that out i got bazaar into my "wiki/blog" system and i can now put some commit logging on the pages.
So you should see a list of the latest commits for halfdans.net on the right.
0 Comments
Comments-and-RSS-are-back-in-the-game
Posted by rto 4 months and 0 week(s) ago, so far 0 people have commented
After much toil and trouble with Django bugs #8630 and #9303 i finally have a comment system with email verification up and running.
It got kinda late before i got the whole thing working so i do not know how robust the code is. As always you are welcome to report any problems and security holes to me (my email is at the Colophon page).
I also got rss working, almost a painless introduction, the Django guys really knows what they are doing - although as you can see from the above bugs, perfect magic can be hard to create.
0 Comments
vertigo-0.6.4.3-is-out
Posted by rto 4 months and 2 week(s) ago, so far 1 people have commented
I have released a new version of Vertigo with the changes required to make proxy http work, and hence, make halfdans.net run with Django.
I have also finished migrating the old Trac site to halfdans.net, it is not as fancy and bug tracking is going to be a bitch - but since i'm running on Django i can add some functionality to cope with it when the need arise.
The DebianRepository and BazaarRepository has also migrated to halfdans.net, so update your /etc/apt/sources.list and friends to follow along.
Thanks to the davfs2 guys i now have my repositories mounted locally on my laptop and i can use all my normal tools to access the files as if they were local on my machine.
When will microsoft add a new webdav client to windows? (Nautilus could also use a more robust one but it serves it purpose most of the time).
1 Comments
halfdans-net-is-now-running-on-django
Posted by rto 4 months and 3 week(s) ago, so far 0 people have commented
I have found a few hours lately to convert halfdans.net to a Django application - and it is now done - more or less at least, the comment posting system still needs to be modfied a bit.
I am using the comment system that comes with Django by default (thanks to the included batteries) and there is not built-in support for "email confirmation" which is something i really need to do avoid having to monitor new comments for spam all the time.
Ok, first order of business, i am abandoning further work on my EvolutionSpamBayesPlugin i have been running with the bogofilter plugin and it seems to work quite well. Just remember to train one message as ham to make it "go".
0 Comments
Delving-into-user-mode-linux
Posted by rto 7 months and 0 week(s) ago, so far 0 people have commented
This weekend i suddenly found the determinism to start tackling something i have been wanting to do for a while: transition halfdans.net to Django.
This has several implications, first of, i want it to run as a separate user to ensure security. Hey, one persons paranoia is another persons security consience. I could run it on the http://dev.infonet.dk server, but that one is going away some time in the future since we are eliminating that server in favor of just having a simple router do the job. The http://laesehesten-randers.dk server will also be upgraded some time in the future, it runs very hot - usually crashes during backup - not a great place to crash!
So, the option i have is, e.g., to run another apache instance on an alternate port, this is certainly one way to go ... buuuut, i really think a thing like this is better done using a virtual server. And it gives me a nice chance to take a look at one of the many virtualization options availble for debian, to make a long story short i settled on user-mode-linux since that just seemed like a nice way to go - and didn't require any host kernel meddling - and truth betold i didn't take the time to research other options at all.
I will write up on my user-mode-linux experience later.
One thing that needed doing before halfdans.net can start to migrate to Django is to get Vertigo to support proxying request to another server, this is pretty simple using Apache but i, of course, wanted to automate the process such that it is easy to do again and again.
Vertigo used to use Apache 1.3, but that version does not have mod_proxy support on etch, so i needed to migrate Vertigo to Apache 2.0 (2.2 actually), so now we have release 0.6.4.1 which requires Apache 2.0 and supports proxy subdomains.
I also found another rather embarrassing bug in Vertigo which should definaetely make you upgrade if you are using Vertigo (i am pretty sure i am the only user at the moment).
Since the server halfdans.net is hosted on has a tendency to run hot and crash, the virtual server is not running at the moment, but when it is it will be available at http://test.halfdans.net/
That is all for now, hope you all remembered George the past saturday, i guess all things really must pass.
0 Comments
Summer-sharing-in-C
Posted by rto 11 months and 3 week(s) ago, so far 0 people have commented
Don't you just hate when you have to remember how to use std::string to do any intricate string manipulation in C++, or trying to remember the correct stringstream class names to convert your measly collection of objects to their bloody string representation.
Wouldn't it be nice if there was an almost pythonic way to do it?
Well - ok! Besides using python then? Ok, maybe there is not such a thing (yet!), but until then you can hopefully make a fragment of that dream come true with "yet another string class" from my hand. Built over the years and with documentation and lots of test cases.
Bugs and improvements are very welcome, it's BSD'ed so nothing should keep you from using it in all your projects in the future - i will certainly be using it everywhere now.
Oh, and it's called hstring and there is more stuff on that page (e.g. documentation).
Finally i have some nice summer reading for you while i spend the next week in spain, INTERCAL, the inside story - hilarious!
P.S. The post of hstring (which has been long due) might be inspired by a friend of mine calling me a C# fanboy, you know who you are ;-)
0 Comments
Explicitimplicit-interface-implementation-in-C
Posted by rto 4 months and 4 week(s) ago, so far 2 people have commented
In the C++ world we are only used to one way of implementing an interface in a class, but in C# you have two options: either an implicit implementation, like the one in C++, or an explicit interface implementation.
Consider the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13 | public interface ITest
{
void DoStuff();
}
public class Test : ITest
{
/// Explicitly implement an interface
void ITest.DoStuff()
{
System.Diagnostics.Debug.WriteLine( "Test is doing stuff" );
}
}
|
In the code above we define an interface with a method called DoMethod which is implemented by the class Test. The cool thing is that we now have associated a method implementation explicitly with a method on an interface, first and foremost this means that we do not have to mark the visibility of the method (public, protected, etc.). Additionally it also means that if the method declaration in the interface is modified in some way, e.g. if a parameter is added or removed, we will get a compile error saying the our implementation of DoStuff does not match the one in the interface, with implicit interface implementation we are only told that Test does not implement the new DoStuff method.
Where it gets really cool is when you consider what happens if a method is removed from the interface, this shows up as a compilation error when we use explicit interface implementations, where as with implicit interface implementations the method can linger around in a class for a long time, before it is noticed as implementing a method of a previous interface revision.
1
2
3
4
5
6
7
8
9
10
11
12 | public interface ITest
{
}
public class Test : ITest
{
/// Compilation error, no method DoStuff on ITest interface
void ITest.DoStuff()
{
System.Diagnostics.Debug.WriteLine( "Test is doing stuff" );
}
}
|
So far this is a really cool thing, I like things that are checked at compile-time, and I especially like any technology that can help implement interfaces and keep interface implementations in sync with interface definitions.
But, and this is a big but, when you start using a class which implements an interface explicitly you are left with one big thorn in your eye, you would think that writing something like the following should be possible:
1
2
3
4
5
6
7
8 | class Program
{
static void Main( string[] args )
{
Test test = new Test();
test.DoStuff();
}
}
|
But what are we faced with? Compile errors! The compiler claims that Test does not contain a definition of a DoStuff method. This is really contrary to the common belief that when you implement an interface in a class, you can call those methods on instances of that particular class directly. In this case you first need to cast test to ITest to be able to call the method.
Even more horribly, this means that how you implement an interface in a class, implicitly or explicitly, changes how that class can be used - this is the one that really baffles me - it seems like complete abandonment of good clean object oriented design.
Now, I think I understand why this was done, the whole reason for allowing for explicit interface implementation is probably to make it possible to distinguish implementations of similarly named methods in separate interfaces, e.g. ITest.DoMethod() and ISecondTest.DoMethod(). But I find it strange that mr. Hejlsberg have overlooked the advantages of explicit interface implementations.
2 Comments
One-of-the-nicer-spots
Posted by rto 4 months and 4 week(s) ago, so far 0 people have commented
For a long time i have been wanting to do some posts on things i like or dislike about C# and the whole .net thingy, and since i'm using it everyday at work there is a remote possibility that i will hit on something interesting.
The first thing i will cover is the yield keyword.aspx). For python developers this is all old hat, but for C# developers it is a great improvement to the language.
Basically it rids you of implementing all sorts of "crazy" iterators to supply a generic interface to collections of internal data that you wish to expose.
Normally you try to write generic code, and make your objects as loosely coupled as makes sense, this introduces a problem when you are working with internal collections of objects.
For instance, consider a Department containing a collection of Student(s) - in the first implementation this could be implemented as a simple vector of Student(s) (a List in .net), and you might expose the internal data structure by providing a Students property like the following:
1
2
3
4
5
6
7 | IList<Student> Students
{
get
{
return m_students;
}
}
|
Ok, so far so good, the users of the Department class can now see which students belong to a particular Department, but the users of the class can still modify the collection, they believe they can index the list by integer index, and so on, and so on, the IList<> interface is very broad. You could expose it as an ICollection<> but that would still expose the collection. What you really should do, is have the Students property return an IEnumerable<Student> instance.
This will make the internal way that a Department class represents students completely independent of the way users of the class access them. Luckily List<Student> already exposes the IEnumerable<> interface - so, easy!
1
2
3
4
5
6
7 | IEnumerable<Student> Students
{
get
{
return m_students;
}
}
|
What happens now is that someone comes along and says - hey! Finding out whether or not a student is in a particular Department just by traversing a list is too slow! So you decide to go with something like a Dictionary mapping from student id (SSN or something similar) to the Student object. But you still want users to be able to, simply, traverse the list of students. With a Dictionary that is not so easy, even though a Dictionary exposes the IEnumerable<> it does so for a special Dictionary.KeyValuePair type - which is no good for our purpose. This is where yield will help us for the first time - check out how i implement an IEnumerable<Student> class in 5 lines:
1
2
3
4
5
6
7
8
9
10 | IEnumerable<Student> Students
{
get
{
foreach ( KeyValuePair<int, Student> pair in m_students )
{
yield return pair.Value;
}
}
}
|
Isn't that just almost pythonic'ly beautiful? Isn't that just the simplest way possible to implement that particular task?
--
An even nicer example.
Where it will really save your ass is if you need to traverse a tree structure sequentially, then you just yield your way on to beatiful code - no more note keeping while trying to traverse the tree correctly. Just implement something simple like the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | class TreeNode
{
List<TreeNode> m_children;
...
IEnumerable<TreeNode> AllChildren
{
get
{
foreach ( TreeNode child in m_children )
{
yield return child;
foreach ( TreeNode subChild in child.AllChildren )
{
yield return subChild;
}
}
}
}
}
|
This is pretty much as simple as you are going to get, of course it would be nice with support for a call to yield to automatically yield every member of another IEnumerable<> object, such that the innermost foreach could be replaced with a simple yield child.AllChildren;. That would be really awesome. Does anybody know where to report enhancements (and bugs for that matter) to mirosoft?
You still have the same cross-thread issues as with List<> and Dictionary<>'s implementations of IEnumerator<> but hey, you can't have it all!
Cheers!
-- A microsoft fanboy!
P.S. I haven't even scrached the surface of what the yield keyword can do for you - there is no requirement that you can only expose data throught yield, how about an implementation of python's xrange(from,to,increment) in C#:
1
2
3
4 | IEnumerable<int> Range(int _from, int _to, int _increment)
{
for ( int i = _from; i < _to, i += _increment ) return yield i;
}
|
Strangely pleasing! (bonus points for writing a generic version)
Or perhaps a way to filter the output:
1
2
3
4
5
6
7
8
9
10 | IEnumerable<Student> Seniors
{
get
{
foreach ( Student student in m_students )
{
if ( student.TimeOnCampus > 3 ) yield return student;
}
}
}
|
Which of course is horribly specific, why not generic' it up a bit:
1
2
3
4
5
6
7 | IEnumerable<Student> FilterStudents ( Predicate<Student> _filter )
{
foreach ( Student student in m_students )
{
if ( _filter(student) ) yield return student;
}
}
|
Not hard to see why lambda expressions is part of the new C#, and LINQ also seems closely related to this.
It's not python, but it's is pretty close for a statically linked language without template (as in C++) support.
Hey, i actually said something positive about something microsoft did! I
must be getting old, maybe i should pick up smoking again.
0 Comments
A-little-bit-of-python
Posted by rto a year and 4 month(s) ago, so far 0 people have commented
I finally found a bit of time to hack a bit on the evolution spambayes plugin, and there is now a version 0.1.6 ready, which works with Evolution 2.12.
Hopefully this will hopefully make Tom Arnold and Jim Rorie happy, or at least give them a reason to try yet again to see if they can get it to work.
There is a new package in my DebianRepository for those fortunate enough to be running Debian (should also work on Ubuntu).
I am not reporting anything on company wise so far, other than: We're working on it!
0 Comments