<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6409152223816122655</id><updated>2011-12-06T09:18:51.257-08:00</updated><category term='iPhone/iPod Touch'/><category term='bittorrent'/><category term='meta'/><category term='javascript'/><category term='shell'/><category term='php'/><category term='rss'/><category term='C'/><category term='OS X'/><title type='text'>Who's hacks?</title><subtitle type='html'>Hacks and bits of code, with a question mark at the end.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://whoshacks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://whoshacks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>whosawhatsis?</name><uri>http://www.blogger.com/profile/12792264289634575186</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-teXKnfK7g7w/TiyIU4HDF0I/AAAAAAAAAFU/LX4MVtueBfA/s220/vecavatar.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6409152223816122655.post-3991529278662368109</id><published>2009-01-14T08:05:00.000-08:00</published><updated>2009-01-14T08:06:06.769-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='OS X'/><category scheme='http://www.blogger.com/atom/ns#' term='shell'/><title type='text'>Change audio devices via shell script</title><content type='html'>I searched for a long time for a way to activate &lt;a href="http://code.google.com/p/soundflower/"&gt;Soundflower&lt;/a&gt; as part of a script, but I couldn't find any way to do so, short of opening system preferences and using UI scripting to control the settings.&lt;br /&gt;&lt;br /&gt;There had to be a better way.&lt;br /&gt;&lt;br /&gt;I found &lt;a href="http://www.rogueamoeba.com/freebies"&gt;SoundSource&lt;/a&gt;, but I couldn't find any way to activate it from applescript, even with UI scripting. I asked the developers about scriptability, and after a few emails back and forth, they decided to release the source, which I used to build audiodevice.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://whosawhatsis.com/paraphernalia/audiodevice.zip"&gt;Audiodevice&lt;/a&gt;&lt;br /&gt;&lt;a href="http://whosawhatsis.com/paraphernalia/audiodevice-src.zip"&gt;Source&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This the basic functionality of SoundSource with a quick and dirty command line interface slapped on. Type "audiodevice help" for usage information. Since I got my Airport express, I haven't had much use for my Soundflower script, but I still regularly use it in conjunction with &lt;a href="http://proxi.griffintechnology.com/"&gt;Proxi&lt;/a&gt; to activate my bluetooth headset from the keyboard.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6409152223816122655-3991529278662368109?l=whoshacks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whoshacks.blogspot.com/feeds/3991529278662368109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6409152223816122655&amp;postID=3991529278662368109' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/3991529278662368109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/3991529278662368109'/><link rel='alternate' type='text/html' href='http://whoshacks.blogspot.com/2009/01/change-audio-devices-via-shell-script.html' title='Change audio devices via shell script'/><author><name>whosawhatsis?</name><uri>http://www.blogger.com/profile/12792264289634575186</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-teXKnfK7g7w/TiyIU4HDF0I/AAAAAAAAAFU/LX4MVtueBfA/s220/vecavatar.png'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6409152223816122655.post-6705851740200478564</id><published>2008-01-02T09:58:00.000-08:00</published><updated>2008-02-01T10:00:17.947-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='rss'/><title type='text'>Directory listing as podcast</title><content type='html'>Here is a quick and dirty (as always) php script to turn a directory listing into an rss 2.0 feed with enclosures, suitable for use with a podcast client. Just drop a copy of this script into the directory and point your feed reader at it. The script automatically hides itself in the listing.&lt;br /&gt;&lt;br /&gt;PHP:&lt;br /&gt;&lt;code&gt;&amp;lt;?php&lt;br /&gt;$link = 'http://'.$_SERVER['SERVER_NAME'].preg_replace('/\/[^\/]+\.[^\/]+$/', '/', $_SERVER['REQUEST_URI']);&lt;br /&gt;$items = preg_replace('/\s+-&amp;gt;\s.*$/','', explode(&amp;quot;\n&amp;quot;, `ls -FlopTt`));&lt;br /&gt;&lt;br /&gt;$items = preg_grep('/('.preg_replace('/.*\//', '', $_SERVER['PHP_SELF']).')$|^$|^total/', $items, PREG_GREP_INVERT);&lt;br /&gt;&lt;br /&gt;header('Content-type: application/rss+xml; charset=utf-8');&lt;br /&gt;echo '&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;rss version=&amp;quot;2.0&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;channel&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;'.$_SERVER['SERVER_NAME'].preg_replace('/\/[^\/]+\.[^\/]+$/', '/', $_SERVER['REQUEST_URI']).'&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;link&amp;gt;'.$link.'&amp;lt;/link&amp;gt;&lt;br /&gt;&amp;lt;description&amp;gt;Contents of '.$link.'&amp;lt;/description&amp;gt;&lt;br /&gt;&amp;lt;language&amp;gt;en-us&amp;lt;/language&amp;gt;&lt;br /&gt;';&lt;br /&gt;foreach ($items as $value) echo '&amp;lt;item&amp;gt;&lt;br /&gt;&amp;lt;title&amp;gt;'.preg_replace('/^(\S+\s+){10}/', '', $value).'&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;description&amp;gt;'.$value.'&amp;lt;/description&amp;gt;&lt;br /&gt;&amp;lt;enclosure url=&amp;quot;'.$link.rawurlencode(preg_replace('/^(\S+\s+){10}/', '', $value)).'&amp;quot; length=&amp;quot;'.preg_replace('/^(\S+\s+){5}((\S+){1}).*/', '\2', $value).'&amp;quot; type=&amp;quot;'.mime_content_type(preg_replace('/^(\S+\s+){10}/', '', $value)).'&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;guid&amp;gt;'.$link.rawurlencode(preg_replace('/^(\S+\s+){10}/', '', $value)).'&amp;lt;/guid&amp;gt;&lt;br /&gt;&amp;lt;pubDate&amp;gt;'.gmdate('D, d M Y G:i:s', strtotime(preg_replace('/^(\S+\s+){6}((\S+\s+){4}).*/', '\2', $value))).' GMT&amp;lt;/pubDate&amp;gt;&lt;br /&gt;&amp;lt;/item&amp;gt;&lt;br /&gt;';&lt;br /&gt;echo '&amp;lt;/channel&amp;gt;&lt;br /&gt;&amp;lt;/rss&amp;gt;';&lt;br /&gt;?&amp;gt;&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6409152223816122655-6705851740200478564?l=whoshacks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whoshacks.blogspot.com/feeds/6705851740200478564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6409152223816122655&amp;postID=6705851740200478564' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/6705851740200478564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/6705851740200478564'/><link rel='alternate' type='text/html' href='http://whoshacks.blogspot.com/2008/01/directory-listing-as-podcast.html' title='Directory listing as podcast'/><author><name>whosawhatsis?</name><uri>http://www.blogger.com/profile/12792264289634575186</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-teXKnfK7g7w/TiyIU4HDF0I/AAAAAAAAAFU/LX4MVtueBfA/s220/vecavatar.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6409152223816122655.post-8020794933175772453</id><published>2007-12-06T21:40:00.000-08:00</published><updated>2009-01-15T08:36:56.106-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='iPhone/iPod Touch'/><category scheme='http://www.blogger.com/atom/ns#' term='bittorrent'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>Start torrent downloads from an iPhone</title><content type='html'>I have a server that I use for, among other things, downloading files with bittorrent. I usually start these torrents by downloading them on my primary computer and then dropping them onto an alias to my server's torrents folder, which my bittorrent client (&lt;a href="http://transmission.m0k.org/"&gt;Transmission&lt;/a&gt;) monitors so that it can start the torrents automatically. I occasionally wanted to use my iPod Touch to start these torrents, but Mobile Safari refuses to download torrent files.&lt;br /&gt;&lt;br /&gt;My solution was to use javascript to alter the torrent link to send its url to my server for download rather than trying to open it. A php script on the server could then download that url to the torrents folder. With both scripts in place and the permissions of the torrents folder modified to allow apache to write files, all I have to do is run the javascript as a bookmarklet before clicking the torrent link, and click the link to download the torrent file. The modified link will pass this url to the script to download it on the server.&lt;br /&gt;&lt;br /&gt;Bookmarklet: &lt;a href="javascript:function%20torrent()%20%7Bwindow.location.href%20=%20%22http://torrent.server.address/t.php?%22%20+%20this.href;%20return%20false;%7D;%20for%20(link%20=%200;%20link%20%3C%20document.links.length;%20link++)%20document.links%5Blink%5D.onclick%20=%20torrent;"&gt;torrent&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;PHP:&lt;br /&gt;&lt;code&gt;&amp;lt;?php&lt;br /&gt;if (!($_SERVER['PHP_AUTH_USER'] == &amp;quot;username&amp;quot; &amp;amp;&amp;amp; $_SERVER['PHP_AUTH_PW'] == &amp;quot;password&amp;quot;)) {&lt;br /&gt; header('WWW-Authenticate: Basic realm=&amp;quot;torrent&amp;quot;');&lt;br /&gt; header('HTTP/1.0 401 Unauthorized');&lt;br /&gt;} else {&lt;br /&gt; passthru('curl -H &amp;quot;Referer: '.$_SERVER['$HTTP_REFERER'].'&amp;quot; -H &amp;quot;User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.3 (KHTML, like Gecko) Version/3.0.4 Safari/523.10&amp;quot; -o /path/to/monitored/torrents/folder/remote.torrent &amp;quot;'.$_SERVER['QUERY_STRING'].'&amp;quot;');&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;history.back()&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Modifications required:&lt;ul&gt;&lt;li&gt;script url in bookmarklet&lt;/li&gt;&lt;li&gt;username in php script&lt;/li&gt;&lt;li&gt;password in php script&lt;/li&gt;&lt;li&gt;torrents folder path in php script&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6409152223816122655-8020794933175772453?l=whoshacks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whoshacks.blogspot.com/feeds/8020794933175772453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6409152223816122655&amp;postID=8020794933175772453' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/8020794933175772453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/8020794933175772453'/><link rel='alternate' type='text/html' href='http://whoshacks.blogspot.com/2007/12/start-torrent-downloads-from-iphone.html' title='Start torrent downloads from an iPhone'/><author><name>whosawhatsis?</name><uri>http://www.blogger.com/profile/12792264289634575186</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-teXKnfK7g7w/TiyIU4HDF0I/AAAAAAAAAFU/LX4MVtueBfA/s220/vecavatar.png'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6409152223816122655.post-6782182369584695964</id><published>2007-12-06T21:24:00.000-08:00</published><updated>2007-12-06T21:24:15.941-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='meta'/><title type='text'>Who's hacks?</title><content type='html'>I already have &lt;a href="whosawhatsis.blogspot.com"&gt;a blog&lt;/a&gt;, but I wanted a place to share some of my hacks and the little bits of code I'm always writing, which may or may not be useful to anyone else. Because this is so different from the subjects of my existing blog, I decided to start a separate one. I plan to use this space to post new hacks as I create them, as well as to post some of older ones when the mood strikes. I hope this will motivate me to clean up some of my code, but don't be surprised to see a lot of one-liners, few if any comments, and stuff that barely works. Everything it offered as-is, and I don't promise to respond to questions about implementation or modification, although I probably will in most cases.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6409152223816122655-6782182369584695964?l=whoshacks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://whoshacks.blogspot.com/feeds/6782182369584695964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6409152223816122655&amp;postID=6782182369584695964' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/6782182369584695964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6409152223816122655/posts/default/6782182369584695964'/><link rel='alternate' type='text/html' href='http://whoshacks.blogspot.com/2007/12/whos-hacks.html' title='Who&apos;s hacks?'/><author><name>whosawhatsis?</name><uri>http://www.blogger.com/profile/12792264289634575186</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/-teXKnfK7g7w/TiyIU4HDF0I/AAAAAAAAAFU/LX4MVtueBfA/s220/vecavatar.png'/></author><thr:total>0</thr:total></entry></feed>
