Hunch

2

How I wrote DroPub in two days

September 20 by Rasmus Andersson, tagged cocoa, programming and dropub, filed under software

Yesterday I wrote DroPub — a simple but powerful little OS X application which transparently handles file transfers “from the desktop”.

Even though it has a lot of features, have been tested, updates itself and so on, I only spent about two days on the whole project — for me, this is the essence of Cocoa.

DroPub is heavily based on NSOperations and uses a hierarchy model for structuring operations. NSOperation hierarchies are powerful means for writing most types of “service” applications. The code can easily be followed by a Cocoa programmer and the operating system frameworks and libraries can give really good performance.

Continue reading...

4

Gitblog

July 16 by Rasmus, tagged gitblog, programming and software, filed under software

So, my blog is back up again after a month downtime. We tried to upgrade Wordpress on our server and when pressing the upgrade button, Wordpress deleted every file on our server (writable by the web server user). So, all 30+ web sites hosted, all Hunch Stuff from 2003 to 2009 and our Subversion repository is gone forever. Nope, we’re stupid and did not have a backup.

I set out to write a better blog tool than Wordpress and here it is — behold the mighty Gitblog.

More info to come.

Smisk 1.0

May 12, 2008 by Rasmus, tagged programming, python and smisk, filed under software

So, after two years, The Smisk web service framework has finally been released as a stable version.

Smisk is a small but powerful framework, or more like a base, for building and running high-performance web services, based on FastCGI. Before I get any further, here is the classic example:

from smisk import Application
class MyApp(Application):
  def service(self):
    self.response.write("Hello World!")

MyApp().run()

This example is obviously not much to hang up in the christmas tree, as we say in Sweden, but there’s definitely more. The major feature of Smisk is it’s speed and this because of the fact that it’s written in C. Yes, not Python. It’s a machine-native library that manifests itself as a Python extension thus control is done with Python.

Installing Smisk is very easy if you have setuptools:

sudo easy_install smisk

(There are other means of installation available…)

As I mentioned earlier, Smisk is a FastCGI based entity. As the name suggests, this is a fast interface, or a fast proxy interface, for HTTP services. FastCGI was built to do two things in particular: Be as fast as possible and scale as good as possible. Smisk retains both of those criteria.

Continue reading...

1

Extending Xcode

May 4, 2008 by Rasmus, tagged cocoa, objective-c, osx, plugin, programming and xcode, filed under software

xcode-icon-256A lot of software enables the user to extend it in order to enhance productivity and customize her work environment. An excellent example of this kind of software is TextMate. But I’m not going to talk about TextMate today, but instead another very popular development tool for the Mac OS – Apple Xcode.

Xcode have had plug-in support during most of it’s life time so far, but the means for creating new plugins has been (and is still in many ways) something only Apple has. Documentation is extremely sparse and most of that which is available is outdated. If you bring up the “New project…” (CMD+SHIFT+N) you will find “AppleScript Xcode Plug-in” inside the “Standard Apple Plug-ins” category. However great this might sound, it restricts you to only fiddle with AppleScript, which in my point of view is just a pain in the ass. (AppleScript, that is. One might call it a necessary evil)

Writing a “real” plugin (using Cocoa, AppKit aso.) should be as easy as writing a normal Application, since a xcplugin is just a simple bundle like any other OS X bundle. What is different though, is that you probably want to fiddle with Xcode itself. (i.e. change the color of some text based on some rules, which for instance a language extension would do) Doing so requires knowledge (i.e. headers) about how to poke around. Unfortunately Apple does not expose these interfaces. Damien Bobillot maintains a (somewhat outdated) document called Xcode’s Plugin Interface in which he provides a package of private headers one must have, in order to use the DevToolCore framework.

Continue reading...

D and TextMate

April 30, 2008 by Rasmus, tagged d, osx, plugin, programming and textmate, filed under software

Example of the syntax highlighterIn combination with the Tango OS X package release I created a D bundle for TextMate. There is already a D bundle available from Macromates bundle repository, but it is extremely simple. I started out pretty simple too, but based the language parser on the Java parser.

However, I’ve been home reading Learn to Tango with D and after a while it started itching in my coding fingers – I re-wrote much of the TextMate bundle and it now has extensive support for all parts of the D language as well “knowledge” about all (non-private) exceptions, classes, structs and interfaces in the lastest version of Tango (0.99.6). What also might be considered a major improvement is the relatively vast number of helpers (snippets, command, templates). Click here for a list of the helpers. (as at the time of writing this) Integration with DSSS is supported through graphical build, run and clean commands. Inline documentation is handled as Javadoc thus writing comments in D makes use of all helpers exposed by the Javadoc bundle. This should probably be revisited in the future to comply with the exact specs of D’s version of inline documentation.

The D bundle for TextMate is now it’s own project. Download and install it directly:

svn co http://svn.hunch.se/rasmus/textmate/D.tmbundle/
open -a TextMate D.tmbundle

(Checking it out from the repository and importing it with TextMate)

If you like the color scheme in the screenshot above, why not grap a copy of it?!

svn co http://svn.hunch.se/rasmus/textmate/themes/ hunch-themes
open -a TextMate hunch-themes/Hunch-Dark.tmTheme

Tango 0.99.6

April 28, 2008 by Rasmus, tagged d, dsss, gdc, osx, programming, tango and textmate, filed under software

gdc-tango-0996

Tango 0.99.6 has just been released. I’m now part of the team and is maintaining the Mac OS X bundle, which was previously announced here.

General highlights in this release:

  • A thread pool module, thanks to Anders Halager
  • Root finding algorithms by Don Clugston
  • Updated for DMD 1.029
  • Universal binaries for Mac OSX

Updates to the Mac OS X bundle:

  • New version of GDC and Tango
  • Includes DSSS
  • Includes a TextMate bundle
  • Source code integrated into the Tango API documentation

Download

Since dsource.org has had alot of problems lately, I’ve put up a (temporary) mirror:
http://d.hunch.se/tango/0.99.6/

13

Say it in D

April 13, 2008 by Rasmus, tagged code, d, osx, programming and tango, filed under software

gdc-tango-installer-screenshot

I just released a true Mac-style simple installer package which gives you a complete D with Tango-programming environment.

Included is GDC with libgtango together with a complete set of D and Tango documentation as well as about 50 different examples with complete source code. Installs into standard paths and does not interfere with your current environment (using isolating prefix /usr/share/gdc). This package does not require Apple Developer tools, even though it is highly recommended.

D is a general purpose systems and applications programming language. It is a higher level language than C++, but retains the ability to write high performance code and interface directly with the operating system API’s and with hardware. D is well suited to writing medium to large scale million line programs with teams of developers. D is easy to learn, provides many capabilities to aid the programmer, and is well suited to aggressive compiler optimization technology.

/* Shows how to create a basic socket client, and how to converse
   with a remote server. */
import tango.io.Console;
import tango.net.SocketConduit,
       tango.net.InternetAddress;

void main() {
  // make a connection request to the server
  auto request = new SocketConduit;
  request.connect(new InternetAddress("localhost", 8080));
  request.output.write("hello\n");

  // wait for response (there is an optional timeout supported)
  char[64] response;
  auto size = request.input.read(response);

  // close socket
  request.close;

  // display server response
  Cout(response[0..size]).newline;
}