NEWS
Just a little over a week ago, Chris Lattner announced to the Clang mailing list that Apple was adding something called "blocks" to C. These blocks are basically closures in the same sense that any computer science student would use them in Lisp, except with a few extra twists of memory management thrown in. (Specifically, if you want to mutate variables declared outside the block, you have to use a new storage qualifier, Today, the anticipated "Objective-J" framework used to build the impressive 280 Slides web application was released, along with a Cocoa-inspired (almost Cocoa-cloned) framework known as Cappuccino. In some cases it seems almost too close, with methods like Anyway, so I think blocks are cool, and would like to start using them except I try to maintain backwards compatibility. (Think about alert sheet callbacks, though!) Objective-J is pretty cool but I want to see some performance specs (though I'm sure it's faster than an overly-AJAXed site). What I find interesting, though, is this snippet from the Objective-J Tutorial's Methods section:
At the same time, Objective-C, and indeed pure C as well, gets the use of blocks:
// something like this
[fooObject setCallback:^(NSString *title, NSString *company) {
// do stuff
}];
...and while this is no good for bindings, and maybe even not target-action replacement, it's great for callbacks. Ironic that the two languages seem to pass each other in the mist. Personally, I've been finally won over to Blocks since they don't seem to mess up C at all (unlike some other closure syntaxes I've seen which only work in a high-level environment). Whereas although using JavaScript functions as first class entities isn't always needed, it seems like it wouldn't be hard to implement. Maybe it was just a problem of copying the syntax a little too closely. *grin* Posted by jediknil | Post a response | 04 Sep 2008 12:16:41 If you've been running your own server for a while, eventually you'll start getting privacy jitters and want to use HTTPS, at which point you'll either happily set it up with minimal difficulty (if you're running a single site) or realize frustratedly that you can't use HTTPS with name-based virtual hosts. To quote the Apache site:
If you're not looking for a solution to this problem, you should probably stop reading here. Otherwise, read on—but be warned that I don't have my configuration files handy, so I may get some of the details wrong. Correct me in the comments, please. You must have mod_rewrite to use these instructions. So, Apache won't do it for us. If you want to implement this solution, you have to give up the use of the <VirtualHost> directive, and any per-host configuration settings that aren't allowed in <Directory> or <Location> sections. Before you do that, note that Apache will allow you to set one virtual host as using SSL, just by adding it to that host's config and having the host listen on port 443. This is only for two or more hosts; I think in that case Apache will default to the first one it reads. Step 0: disable virtual hosting on port 80. Use Step 1: Add the following sort of code to your main config file. Again, I don't have mine handy, so I'm giving you the general idea.
# This is the site that will be displayed if mod_rewrite isn't enabled
DocumentRoot /var/www/html/main-site
<IfModule rewrite_module>
RewriteEngine On
# Change this to the path to your sitemap file (see below)
RewriteMap sitemap txt:/etc/apache2/sitemap
# It's this line that may not be correct
# And getting it wrong can result in infinite loops
RewriteRule ^ ${sitemap:%{HTTP_HOST}|%{DOCUMENT_ROOT}}%{REQUEST_URI}
</IfModule>
<VirtualHost *:443>
SSL on
# fill in the rest of your SSL settings here
<IfModule rewrite_module>
RewriteEngine On
# Change this to the path to your sitemap file (see below)
RewriteMap sitemap txt:/etc/apache2/sitemap
# It's this line that may not be correct
# And getting it wrong can result in infinite loops
RewriteRule ^ ${sitemap:%{HTTP_HOST}|%{DOCUMENT_ROOT}}%{REQUEST_URI}
</IfModule>
</VirtualHost>
Step 2: Create your sitemap file. This is a rewriting map that maps site names to filesystem paths. Mine looks a bit like this, though don't rely on it for hacking me... # These entries are technically not necessary since it's my DocumentRoot belkadan.com /var/www/html/belkadan www.belkadan.com /var/www/html/belkadan # Look! Another "host"! mail.belkadan.com /var/www/html/webmail # etc Step 3: Convert your old virtual host specifications over to use <Directory>. I think you can handle this on your own, but remember to run a Step 4: Reload Apache and hope things don't break. Test all your sites with both HTTP and HTTPS. And that's it! Well...nearly. You can stop here if you want, but if you want special handling of certain locations, you have to implement a namespace system for yourself. I decided that paths starting with Step 5: Change both your rewriting sections to look like this. The
<IfModule rewrite_module>
RewriteEngine On
# Change this to the path to your sitemap file (see below)
RewriteMap sitemap txt:/etc/apache2/sitemap
# Careful with these lines
RewriteCond %{REQUEST_URI} !^\/\._
RewriteCond ${sitemap:%{HTTP_HOST}|%{DOCUMENT_ROOT}} ^\/\._
RewriteRule ^ ${sitemap:%{HTTP_HOST}|%{DOCUMENT_ROOT}}%{REQUEST_URI} [PT]
RewriteCond %{REQUEST_URI} !^\/\._
RewriteCond ${sitemap:%{HTTP_HOST}|%{DOCUMENT_ROOT}} !^\/\._
RewriteRule ^ ${sitemap:%{HTTP_HOST}|%{DOCUMENT_ROOT}}%{REQUEST_URI}
</IfModule>
Step 6: If you're using fancy indexing, change all references from Step 7: Add your special-case sites to the sitemap file. Let's pretend we're adding WebDAV capabilities, and for some reason you want it on another host. # all the stuff from before... webdav.belkadan.com /._webdav Step 8: Change your special-case virtual hosts to use <Location>. This is useful for something like "Dav on" or "Require valid-user", which you don't want to do for normal access to your main site! Unfortunately, <Location> allows even fewer directives than <Directory>, but you can get around this by setting an environment variable and using an <IfDefine> later. Step 9: Add an Alias directive for your special-case virtual host. Alias /._webdav /var/www/html/belkadan Step 10: Secure your special-case virtual hosts. Right now anyone could access the hypothetical DAV by going to <Location /._webdav> # All of your config settings here, then... Satisfy all SetEnvIf Host ^webdav\.belkadan\.com allow_alias_access Allow from env=allow_alias_access </Location> Step 11: I'll dub this technique "virtual virtual hosting" and leave you with the fallout of the pun. Oh, and I think there's probably a better way to handle the special cases rather than using a made-up path (a separate host-based SetEnvIf would probably do it), but this is what worked for me. Posted by jediknil | Post a response | 28 Aug 2008 22:54:04 Quickie for today that some people might find handy. (I need to start posting much more. And reorganize a bit.) Just yesterday I found myself wondering what to do when Dockyard would crash. The new Dockyard uses the wonderfully transparent distributed objects of Cocoa, which become staggeringly destructive when the remote process crashes. If you only used the data in a few places, or transferred everything by-copy, then you can probably recover. But in the bindings-intensive AppKit world of Dockyard Manager, you're going to crash before you can say (I'd like to know why I can't just use NSAlert, but I have no idea where to go from the bit of poking I did. Pausing during the alert reveals an apparently normal run loop, but the alert simply won't close.) So, I have decided instead to bail out as planned, but to show an alert after the application quits. (Huh‽) Rather than use AppleScript's "display alert", which doesn't look as nice, requires twice as much space as my final solution, and (the clincher) doesn't work on Panther outside of AppleScript Studio, I wrote a small application intended to be called with a property list file describing the parameters of the alert. The application wouldn't be so remarkable, except that it works and it's nibless. Even if you don't care about the app itself (to be fair it's really odd to want to display an alert without having an application context already, and a better sudden death app might be needed in the end), you might still be a bit interested in how to write a nibless application. Summary: nibless faceless application that displays alerts based on a property list file description. If you're interested at all, you can download the source to what I've named Alert Notifier. Posted by jediknil | Post a response | 08 Mar 2008 23:23:48 | ||
| Powered by | BlogAgain | Apache | MySQL | PHP | |