<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>studioblīp &#187; Technology</title>
	<atom:link href="http://www.studiobleep.com/blog/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.studiobleep.com/blog</link>
	<description>digital artifacts.</description>
	<lastBuildDate>Fri, 14 May 2010 18:22:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Favorite new tool: named_scope</title>
		<link>http://www.studiobleep.com/blog/2008/11/09/favorite-new-tool-named_scope/</link>
		<comments>http://www.studiobleep.com/blog/2008/11/09/favorite-new-tool-named_scope/#comments</comments>
		<pubDate>Sun, 09 Nov 2008 18:07:38 +0000</pubDate>
		<dc:creator>jmileham</dc:creator>
				<category><![CDATA[Technology]]></category>
<category></category><category></category><category></category>
		<guid isPermaLink="false">http://www.studiobleep.com/blog/2008/11/09/favorite-new-tool-named_scope/</guid>
		<description><![CDATA[Update: I&#8217;ve been using named_scope for a bit longer now and totally don&#8217;t agree with my former self about naming conventions when creating named_scopes.  I now do what comes natural.  Love, me.
I&#8217;ve been using the new-ish Rails feature named_scope for a couple days now, and I love it.  The expressiveness was something I really missed [...]]]></description>
			<content:encoded><![CDATA[<p><em>Update: I&#8217;ve been using named_scope for a bit longer now and totally don&#8217;t agree with my former self about naming conventions when creating named_scopes.  I now do what comes natural.  Love, me.</em></p>
<p>I&#8217;ve been using the new-ish Rails feature named_scope for a couple days now, and I love it.  The expressiveness was something I really missed jumping from OpenACS, a &#8220;framework&#8221; where you&#8217;re encouraged to write powerful queries in raw SQL.  So you get the best of both worlds: modular business logic and (relatively) powerful queries.  I wish Rails had more features to enable INNER JOINs using finders in a way that still allows the pre-fetching of associated objects, but that&#8217;s another matter entirely.  Some observations, though:</p>
<p><span id="more-11"></span></p>
<p><strong>Naming named_scopes</strong></p>
<p>I&#8217;ve now come to the conclusion that all objects in the titles of named_scopes should be singular (unless there&#8217;s a complex case I haven&#8217;t encountered yet where it makes sense).  So CourseMembership#in_sections_of_term should be CourseMembership#in_section_of_term, etc, even if the named_scope might return multiple rows &#8212; in fact, most do.  My reasoning is that you&#8217;ll typically be operating on something singular (a model class), and you&#8217;re really describing a criterion, not the result set.  Also named_scopes should never be nouns or they may collide with attribute or association names.  They should be adjectives or predicates (in the grammar sense), like:</p>
<p>Car#red (obviously a Car doesn&#8217;t belong_to or has_one Red: it probably has an attribute named &#8220;color&#8221;)<br />
Course#live (Live is an adjective. Course doesn&#8217;t have a Live: it has a belongs_to association to CourseItem which in turn has a live_revision_id attribute)<br />
User#is_student (This is tricky: i was tempted to call it User#student, but the User might well have a Student &#8211; though I don&#8217;t know how that might be defined)</p>
<p>Moral of the story is that named_scopes need to be named carefully so they don&#8217;t confuse the programmer into thinking that they&#8217;re calling an association or attribute instead.  named_scopes return proxies to arrays of the class in question where obviously associations and attributes return proxies to arrays or objects of different classes.</p>
<p><strong>named_scopes on associated objects</strong></p>
<p>The one thing that is preventing named_scopes from being as DRY as possible is that you can define all these fancy named_scopes on your models, but then there is no way to talk to the named_scope of an associated object in order to scope your own object.</p>
<p>For instance: at Berklee&#8217;s online extension school we&#8217;ve got Sections (of courses).  Each one has a starts_on date, ends_on date, closes_on date (after which you can&#8217;t post anymore), and archived_until date (after which you can&#8217;t see the course).  So I&#8217;ve got a bunch of named scopes on the Section class, including current (between start and end), open (between start and close), archived (between close and archived_until).  They work great.  But there&#8217;s a possiblity that these implementations might actually need to become more complicated, so it&#8217;s critical that this code be DRY.</p>
<p>So the kicker is that I need to be able to find enrollments based on those criteria.  There&#8217;s even a comment in the HasFinder blog post (HasFinder is the progenitor of named_scope) <a title="Request for integration of named_scope into associations" href="http://pivots.pivotallabs.com/users/nick/blog/articles/284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries#559">requesting something along these lines</a>.  But I consider that to be a bit of a special case of the general problem.  I see there being two ways to grapple with it.  Either find() needs a way of letting you specify named_scopes to fire on :included associations (which is very powerful but gets away from the uber-fancy named_scope compositions that are currently allowed), or perhaps there is an even more sugary solution: What if there were an alternate form of named_scope that let you steal and alias named_scopes from associated classes?  For example, in the Enrollment class we could have:</p>
<p>named_scope :in_current_section, :inherit_from =&gt; :section, :scope_name =&gt; :current</p>
<p>Then I could find all the enrollments in Music Theory 101 by calling:</p>
<p>Enrollment.in_current_section.in_section_of_course(Course.live.find_by_title(&#8220;Music Theory 101&#8243;).course_item)</p>
<p>Sugary and DRY like Cap&#8217;n Crunch.</p>
<p>My gut is that you&#8217;d want both the finder enhancement and the aliasing options because there may be some objects that you need to scope a ton of ways based on inherited named_scopes, and you wouldn&#8217;t want to have to name all of them if they&#8217;re used relatively few times each.  Also, the semantics of the finder vs. aliasing approach would be different.  The aliased scope would additionally require that the association_table.primary_key be NOT NULL so that the scoping will actually have an effect on the result set of the primary object (or maybe this would be an additional boolean parameter to the named_scope call), whereas from the finder you might geniuinely want to return an unscoped set of objects, but have a pre-scoped set of children available to play with without hitting the database again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.studiobleep.com/blog/2008/11/09/favorite-new-tool-named_scope/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is there hope of automated Oracle Calendar iCalendar export?</title>
		<link>http://www.studiobleep.com/blog/2007/09/22/is-there-hope-of-automated-oracle-calendar-icalendar-export/</link>
		<comments>http://www.studiobleep.com/blog/2007/09/22/is-there-hope-of-automated-oracle-calendar-icalendar-export/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 19:57:50 +0000</pubDate>
		<dc:creator>jmileham</dc:creator>
				<category><![CDATA[Technology]]></category>
<category>c</category><category>google calendar</category><category>ical</category><category>icalendar</category><category>iphone</category><category>libsyncml</category><category>oracle</category><category>syncml</category>
		<guid isPermaLink="false">http://www.studiobleep.com/blog/2007/09/22/is-there-hope-of-automated-oracle-calendar-icalendar-export/</guid>
		<description><![CDATA[At work, we use Oracle&#8217;s calendaring software.  Oracle is nice because it can be synced via SyncML.  This worked great with my Treo thanks to Synthesis&#8217; PalmOS client software.  But sadly, my iPhone is hopelessly tethered to Apple iCal.  Ironically an iPhone on PC would have no problems since you can [...]]]></description>
			<content:encoded><![CDATA[<p>At work, we use Oracle&#8217;s calendaring software.  Oracle is nice because it can be synced via SyncML.  This worked great with my Treo thanks to <a href="http://www.google.com/url?sa=t&amp;ct=res&amp;cd=3&amp;url=http%3A%2F%2Fwww.synthesis.ch%2F&amp;ei=4Wf1Rri-AaLSet-L7fQO&amp;usg=AFQjCNFibZoQ18Zio43mZimEgJ2Bb00o9w&amp;sig2=bvxos7dMPduYXJq3EttwaA">Synthesis&#8217;</a> PalmOS client software.  But sadly, my iPhone is hopelessly tethered to Apple iCal.  Ironically an iPhone on PC would have no problems since you can sync an <a href="http://www.apple.com/iphone/easysetup/getready.html">iPhone with Outlook</a>, and sync <a href="http://www.funambol.com/opensource/downloads.html">Outlook with Oracle Calendar</a> via SyncML.  But being attached to iCal is a decided problem.  It&#8217;s just not used by enough corporate types that it gets that kind of attention.  The only sync tool I found,  <a href="http://www.spanningsync.com/">Spanning Sync</a>, hooked iCal up to Google Calendar which is a big win for me, since I do my personal calendar stuff in Google Calendar.  So we&#8217;re 50% of the way to having my calendaring life mobile.</p>
<p><span id="more-9"></span>But the only solution I currently have to get my Oracle calendar data onto my iPhone is to manually export it in <a href="http://en.wikipedia.org/wiki/ICalendar">iCalendar</a> format &#8211; a format that existed before iCal but has since been conflated with the Apple product, even in Google&#8217;s own usage: <em>&#8220;If you know the address to a calendar (in iCal format), you can type in the address here.</em><em>&#8220;</em></p>
<p>Exporting iCalendar files into iCal to get a one-time dump of upcoming meetings works fine, but it&#8217;s not exactly clean and easy (especially in contrast to Spanning Sync).  My obsession with elegant solutions (or some might say fundamental laziness) prevents me from accepting this in the long term.</p>
<p>So, what to do?  Well, as I mentioned, Oracle Calendar offers SyncML synchronization.  So if I could theoretically get a SyncML frontend for iCal, I&#8217;d be golden, but that appears not to exist.  Just to taunt me, recent iterations of iSync apparently support SyncML in order to talk with various SmartPhones that have standardized on the protocol.  But that&#8217;s SyncML over USB or SyncML over Bluetooth, and instead of implementing a SyncML client, iSync is implementing the server end of the transaction.</p>
<p>But, seriously, I don&#8217;t have much need for bidirectional sync with my Oracle calendar.  I rarely have to stuff a meeting into my calendar when I&#8217;m not sitting at my laptop &#8212; I&#8217;m at my desk all day long.  I would just like to be able to glance at what&#8217;s coming up when I&#8217;m on the go.  So what about a SyncML client that dumps its results to iCalendar format?  Better yet, in web app form (perhaps with caching so that it doesn&#8217;t completely kill the Oracle server every time you hit it), so that the iCalendar feed can have a URL?  Then I could get my Oracle data via Google or iCal (both support remote iCalendar feeds).</p>
<p>So it looks like there are a few libs out there that might help.  I downloaded <a href="http://libsyncml.opensync.org/">libsyncml</a> (which is not to be confused with this <a href="http://libsyncml.sourceforge.net/">defunct libsyncml project</a>), and compiled it.  To my immediate and utter joy, I discovered the lib came with a few utility/demo applications.  One was called syncml-http-client.  It is completely undocumented save for the &#8211;help output, which it seems to share with syncml-http-server and syncml-obex-client.  Some of the features seem like they&#8217;d be more relevant to a server than a client.  And as far as I can tell, syncml-http-client completely ignores the rather important issue of authenticating itself.  The library seems to be tailored more for acting as a single-user server or client than as a client of a major multiuser application.  Ethereal dumps of the SyncML conversations seem to indicate that syncml-http-client and Oracle are indeed speaking the same language, but syncml-http-client is completely confused when asked by Oracle to authenticate itself.</p>
<p>So I&#8217;m going to dust off my previously meager and now practically nonexistent C chops and see what can be done about it.  Luckily SyncML is an open protocol, so the only limitation is my own ineptitude.</p>
<p>Would that all Oracle calendar instances did out-of-the-box what <a href="http://wiki.case.edu/Oracle_Calendar">Case Western&#8217;s does</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.studiobleep.com/blog/2007/09/22/is-there-hope-of-automated-oracle-calendar-icalendar-export/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Geeking out with iPhone</title>
		<link>http://www.studiobleep.com/blog/2007/09/21/geeking-out-with-iphone/</link>
		<comments>http://www.studiobleep.com/blog/2007/09/21/geeking-out-with-iphone/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 02:23:14 +0000</pubDate>
		<dc:creator>jmileham</dc:creator>
				<category><![CDATA[Technology]]></category>
<category>arm</category><category>darwin</category><category>firefox</category><category>hack</category><category>iphone</category><category>laptop</category><category>phone as modem</category><category>safari</category><category>socks</category><category>unix</category>
		<guid isPermaLink="false">http://www.studiobleep.com/blog/?p=7</guid>
		<description><![CDATA[I&#8217;m not gonna lie.  I began fantasizing about the iPhone back in January when it was announced at MacWorld.  But I really had no practical need for the thing, given that I already had a Treo 650 that could do all the usual SmartPhone bits, and that my existing iPod nano had hung [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not gonna lie.  I began fantasizing about the iPhone back in January when it was announced at MacWorld.  But I really had no practical need for the thing, given that I already had a Treo 650 that could do all the usual SmartPhone bits, and that my existing iPod nano had hung out in my car pretty much since I got it and served exclusively as a CD-changer replacement (with an increasingly stale copy of my iTunes library).</p>
<p>So I held out when the big launch came.  I probably read more of the iPhone hype on Wired.com than the people who actually bought them.  Being a UNIX geek, the greed welled up within me when I learned that people had been successful at installing an SSH server and standard set of command line utilities on the phone.  And this wasn&#8217;t like reflashing your iPod to run Linux, thereby throwing out all of the excellent software that it came with, making the device less useful.  Nope, the iPhone ran a full multitasking protected-memory Darwin kernel.  Jobs hadn&#8217;t been overstating the fact that the phone ran OS X (which I half snorted at when I heard it last year).</p>
<p>Then came the price drop.  I still held firm for another two weeks, but ultimately my resolve crumbled.  I had to have it.<span id="more-7"></span></p>
<p>So I&#8217;m not going to give you a review, or a how-to.  There are many sites that have done a much better job on those subjects.  But I will say, having tried out some of the command line tools, they&#8217;re not quite as rock solid as you might dream.  I suppose that shouldn&#8217;t come as a surprise since they&#8217;re entirely unauthorized ports written for a hardware/software platform that, while made up of some standard bits (an ARM processor and Darwin kernel) is wholly undocumented.</p>
<p>The one nagging problem with the iPhone (besides its inability to synchronize directly with my Oracle calendar at work) is that it doesn&#8217;t have a phone-as-modem mode.  For all its networking prowess with built-in Wifi and (pokey but reasonably reliable) 2.5G EDGE network connection, it wouldn&#8217;t share its good fortune with my lowly laptop.  Luckily, clever iPhoners had discovered long before I picked mine up how to compile srelay, an open source SOCKS proxy, for the device.  Naturally it was the first thing I installed after getting the usual command line tools.  I mean, what is a UNIX system without grep and vim?</p>
<p>I really didn&#8217;t know anything about SOCKS.  Proxies in general have always seemed like a really awkward idea to me.  If you&#8217;ve got the ability to do NAT and stateful packet inspection in a firewall, why break the abstraction on the client side?  In fact, I&#8217;m not really sure what about the routing details inside of the iPhone&#8217;s network stack prevent somebody from installing a proper DHCP server and NATing router on it.  But nonetheless, in this case I&#8217;ll take whatever I can get, &#8217;cause I haven&#8217;t got a clue how to set up gcc to cross compile for Darwin on ARM, let alone write network subsystem code for it.  So it turns out SOCKS can proxy <a href="http://www.macosxhints.com/article.php?story=20060831091645414">just about any service</a> if you give it enough loving.  It seems it would be a lot more convenient if the SOCKS client were implemented at the OS level then.  In OS X, it sort of is.  There is an OS global SOCKS configuration, but it seems that it&#8217;s only an FYI for applications that can choose to implement SOCKS client features on their own.  Basically, that means that Safari is about the only thing that pays attention to the setting.  Of course I use Firefox, so I&#8217;m pretty much hosed.  If I want to switch back and forth it&#8217;s not as simple as changing Networking locations, but rather changing my Firefox config and whatever else.</p>
<p>Also, ssh (or any other command line tool for that matter) isn&#8217;t down with SOCKS.  But this is where <a href="http://tsocks.sourceforge.net/">tsocks</a> comes in, or so I thought.  But, it turns out that wrapping ssh in tsocks is a sure fire way to lock up my iPhone.  I&#8217;m not sure if it&#8217;s a memory issue, or what.  But it sure ain&#8217;t happy.</p>
<p>Of course it&#8217;s not strictly necessary since I can just ssh to the iPhone and then out from there to wherever I&#8217;ve got to go.  Dropbear, the iPhone&#8217;s SSH server claims to even support X11 forwarding, though I&#8217;ve yet to get that to work.  So, overall, the phone-as-modem support works in a pinch.  And as an added benefit, if you just have to use the web, the phone&#8217;s built-in browser is really an amazing thing.  It almost doesn&#8217;t suck to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.studiobleep.com/blog/2007/09/21/geeking-out-with-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
