Blogs
GNU Smalltalk deployment with images and image resumption
Once up on a time I was sitting in a cold hall at the Barcelona exhibition ground, a power outage has taken down several DVB-H platforms (racks consisting of servers, streamers, RF equipment...) and once power was restored red LEDs were blinking, systems not coming up automatically, hordes of engineers trying to boot the right kernel, trying to remember the multicast routes they had typed in by hand, chaos, hectic. It was interesting to witness that as we could lay back, continue with our work, as our platform was configured to come up automatically and it did.
Simple XML Creator
Hello,
This is an extremely simple XML creator to create simple XML files quickly. The usage is like this:
html := XMLNode new: 'html'. body := html add: (XMLNode new: 'body'). body at: 'bgcolor' put: '#ff0000'. h1 := body add: (XMLNode new: 'h1'). h1 value: 'My Heading'. p := body add: (XMLNode new: 'p'). p value: 'My paragraph'. html fileOut: '/home/myhome/sample.xml'.
Which creates an XML file with the following content:
<html>
<body bgcolor="#ff0000">
<h1>My Heading</h1>
<p>My paragraph</p>
</body>
</html>
You can download the package via:
gst-package --download SimpleXMLCreator -t ~/.st
or from:
Creating custom stock items in GTK+
Let's say you want to put a tool button with a custom image, which is not among the stock items, to the toolbar of your GTK+ application. Here is the code for creating additional stock items from custom images:
"Variously sized versions of an image is held inside an icon set and icon sets are held inside icon factories. You may put one size of an image inside an icon set and GTK+ will scale it appropriately for your usage." "First create an icon factory." myIconFactory := GtkIconFactory new. "Add that factory as a default icon factory so that the icons inside it can be found by the application." myIconFactory addDefault. "The image we want to create the icon from." myImage := GtkImage newFromFile: 'Path/To/My/Image.png'.
OsmoST SIP
Intro
The last couple of days, to some degree weeks I was implementing a SIP stack for GNU Smalltalk to be used in my Smalltalk GSM project. The first time I encountered SIP was around 2001 when we were excited to run a SIP Phone on our Linux powered iPAQs (Linphone on Opie).
For Smalltalk I started with looking at SipStack by Frank Shearar (who was very responsive to questions regarding his code and SIP in general). The main problem was that his stack was incomplete and as usual it is difficult to pick things up without knowing SIP and not knowing where the code was heading.
Floating point to decimal conversion is not so easy
Russ Cox of Plan-9 and Go fame posted a blog entry titled Floating Point to Decimal Conversion is Easy. While he is usually right, I believe this time he isn't.
Floating point to decimal conversion is easy if you are okay with ugly results. A good conversion routine will print the shortest decimal representation of the floating-point number, that is, the shortest decimal number whose closest floating-point representation equals the original number. You do not want 0.30000000001, you want 0.3, because the number right above 0.3 is 0.30000000003 and 0.30000000001 does not provide any extra precision.
