adric: (Mac OS X)
2007-11-24 02:52 am
Entry tags:

Scripting, iSight, madness, ruby

So, I banged around in irb and Google working on this whole automate my Mac's built-in camera thing. I'm not averse to buying one of the neat-o cam applications I found, like EvoCam, which could almost certainly do whatever still or video capture I want, but I want to know what I can do for free and/or with the shipping software image. And although this is a Mac specific project for the most part, the less shareware involved the more likely I am to learn something portable to another platform. From a MacDevCenter thread I was reminded of QuickTime Broadcaster, and fetched new binaries of it from Apple. Checking the FAQ for it about Applescript and then Googling led me straight into the PDF of the Leopard Server manual which says this:

For detailed information on the AppleScript features QuickTime Broadcaster supports, drag the QuickTime Broadcaster icon to the Script Editor icon in /Applications/ AppleScript/.

This seemed a rather odd thing to suggest, but I gave it a go, and it actually worked! Apparently for applications with Applescript (OSA) hooks, this odd gesture opens their dictionaries (API) in Script Editor. I could already get this in html with a tool that the rubyosa gem installs called rbdoc-osa, but I was still amused. It helped confirm my earlier finding that Photo Booth is completely without scripting hooks (fail!). I was able to create a simple little script that starts recording video with the existing setting, and another to stop it. I also ended up futzing more with my rbosa scripts and got them all working and updated.

adric: (Hacker)
2007-10-05 04:58 pm

Success?! (Yes, more Windows Scripting crap)

windows console spam )

Or, with the DotNet assemblies (libraries) loaded in ...
PS C:\scripts> $sm = ( New-Object Microsoft.Web.Administration.ServerManager )
PS C:\scripts> $sm.Sites | Select Id, Name

 Id Name
 -- ----
  1 Default Web Site
  2 longhorn

ala: http://blogs.iis.net/tobintitus/archive/2006/11/30/powershell-and-microsoft-web-administration.aspx
adric: (Hacker)
2007-10-04 09:49 pm
Entry tags:

WMI, IIS, CIM and other cursewords

Finally, after hours of reading through mind-numbingly overcomplicated documentation about the incredible plural architectures for Windows system management (not that I wanted to know any of that, mind you) and their various benighted APIs and tools ...

I present, the answer, or at least the kernel of one:
arcane invocations within )
ref: http://msdn2.microsoft.com/en-us/library/ms524913.aspx
adric: (Hacker)
2007-10-03 09:32 pm
Entry tags:

RegEx Drain Brammage

Whats this do? ^([^.?]+)$ Or rather, how does it do it, and why wouldn't something simpler work, like ^(.+)$ ?

in:
RewriteEngine on
# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]
# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
from: http://us2.php.net/manual/en/security.hiding.php#72630

my guessing, so far )
adric: (Mac OS X)
2006-11-22 05:16 pm
Entry tags:

Ruby and Mac scripting (rubyosa)

Check out this: "RubyOSA: The End of AppleScript?" http://www.clarkware.com/cgi/blosxom/2006/10/24#RubyOSA
which links to: "Rake Shame" http://codefluency.com/2006/10/23/rake-shame
and from which I scrawled song.rb:
require '~/Work/rubyosa/osa.bundle'
require '~/Work/rubyosa/rbosa.rb'

itunes = OSA.app('itunes')
track = itunes.current_track

p track.artist + " - " + track.name
With which and a dash of alias song="ruby ~/Work/song.rb" I now have a song command for posting to LJ:
song | pbcopy ... complete with Unicode escapes that no one likes, apparently...
and this with some inevitability leads to:
tunes = OSA.app('itunes')
ducktroller = OSA.app('adium').adium_controller
ducktroller.my_status_message= tunes.current_track.artist + " - " + tunes.current_track.name
.. which I'll shortly thrown in cron..