<?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>adamblog &#187; bash</title>
	<atom:link href="http://blog.amyl.org.uk/category/bash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.amyl.org.uk</link>
	<description>my half-arsed attempt at blogging</description>
	<lastBuildDate>Tue, 06 Dec 2011 19:09:09 +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>cURL and Google Spreadsheets</title>
		<link>http://blog.amyl.org.uk/2011/12/curl-and-google-spreadsheets/</link>
		<comments>http://blog.amyl.org.uk/2011/12/curl-and-google-spreadsheets/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 19:06:58 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[google-docs]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://blog.amyl.org.uk/?p=98</guid>
		<description><![CDATA[I failed to find a good example of something that worked to pull a spreadsheet from google-docs using cURL. All that I found didn&#8217;t work, in one shape or another.
A bit of playing, and quite a bit of reading got this

#!/bin/bash
PASS=`cat /path/to/0600/google-password-file`
SHEET="https://spreadsheets.google.com/feeds/download/spreadsheets/Exportkey=addyourownsheetIDhere&#038;exportFormat=csv&#038;gid="
AUTH_TOKE=`curl --silent https://www.google.com/accounts/ClientLogin -d \
    Email=foo@example.org -d \
   ]]></description>
			<content:encoded><![CDATA[<p>I failed to find a good example of something that worked to pull a spreadsheet from google-docs using cURL. All that I found didn&#8217;t work, in one shape or another.</p>
<p>A bit of playing, and quite a bit of reading got this</p>
<p><code><br />
#!/bin/bash<br />
PASS=`cat /path/to/0600/google-password-file`<br />
SHEET="https://spreadsheets.google.com/feeds/download/spreadsheets/Exportkey=addyourownsheetIDhere&#038;exportFormat=csv&#038;gid="</p>
<p>AUTH_TOKE=`curl --silent https://www.google.com/accounts/ClientLogin -d \<br />
    Email=foo@example.org -d \<br />
    Passwd=${PASS} -d \<br />
    accountType=HOSTED -d \<br />
    source=cURL-SpreadPull -d \<br />
    service=wise | grep Auth\= | sed 's/Auth/auth/'`</p>
<p>curl --silent --output /path/to/file --header "GData-Version: 3.0" --header "Authorization: GoogleLogin ${AUTH_TOKE}" "${SHEET}${TAB}"<br />
</code></p>
<p>seemed to do the trick</p>
<p><code>Exportkey</code> could be defined in the script, as a variable, thinking about it. You&#8217;ll need to supply that; I typically grab it from the web-based URI, but there is a warning in <a href="http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html#RetrievingCellFeeds">the docs</a> about that:</p>
<p><quote><br />
<em>To determine the URL of a cell-based feed for a given worksheet, get the worksheets metafeed and examine the &lt;link&gt; element in which rel is http://schemas.google.com/spreadsheets/2006#cellsfeed. The href value in that element is the cell feed&#8217;s URI.</em><br />
</quote></p>
<p> YMMV.</p>
<p>I&#8217;ve added in <code>&#038;exportFormat=csv&#038;gid=</code> because I wanted CSV outputs, and gid&#8217;s value is provided via a for &#8230; and case deviation.</p>
<p><code>--header "GData-Version: 3.0"</code> was needed to avoid the  redirection.</p>
<p>Hopefully, this might be of benefit &#8212; as a working (when written) example of using curl and google docs/google spreadsheets.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.amyl.org.uk/2011/12/curl-and-google-spreadsheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transmission and Renaming Torrents</title>
		<link>http://blog.amyl.org.uk/2010/09/transmission-and-renaming-torrents/</link>
		<comments>http://blog.amyl.org.uk/2010/09/transmission-and-renaming-torrents/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 14:20:56 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[mailer]]></category>
		<category><![CDATA[rename]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[symlink]]></category>
		<category><![CDATA[transmission]]></category>
		<category><![CDATA[works for me]]></category>

		<guid isPermaLink="false">http://blog.amyl.org.uk/?p=89</guid>
		<description><![CDATA[I&#8217;ve recently (ish) started using transmission as my torrent client; the change-over comes from my switching-things-off approach; instead of keeping ktorrent running on the laptop (and caneing my bandwidth), I can have something mainly work on the NAS which is always on (bar power-cuts/maint).
One of the things that I noticed was the apparent lack of]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently (ish) started using transmission as my torrent client; the change-over comes from my switching-things-off approach; instead of keeping <a href="http://ktorrent.org">ktorrent</a> running on the laptop (and caneing my bandwidth), I can have something mainly work on the NAS which is always on (bar power-cuts/maint).</p>
<p>One of the things that I noticed was the <a href="https://trac.transmissionbt.com/ticket/1220">apparent lack</a> of <a href="https://trac.transmissionbt.com/ticket/672">renaming</a> within Transmission (and the curious way earlier tickets are marked as duplicitous of later ones).</p>
<p>So, erm, I&#8217;ve <a href="http://github.com/adamamyl/transmission">written something</a> that works for me. And hacked out the mailer-script to something a little cleaner&#8212; at least in my view.</p>
<p>The premise is that you&#8217;re using a POSIXish operating system &#8212; <a href="http://www.readynas.com/">my NAS</a> runs on Debian &#8212; and that all of your exports are within the /nas directory, and your torrents directory is /nas/torrents.</p>
<p>The changes needed are (with transmission not running, apparently) to include <code>/path/to/post-download</code> as the value for<br />
<code>script-torrent-done-filename</code> in <code>settings.json</code></p>
<p>You&#8217;ll need to echo in <code>"/path/to/store/the/completed-file"</code> to a file named as per the torrent (see your <code>incomplete</code> directory for that), but with &#8220;<code>.move</code>&#8221; appended; the rest should all happen automagically.</p>
<p>You might find it useful to chown the directories you&#8217;ll be moving things to that of the user running the transmission processes; I tend to setgid to my GID too.</p>
<p>The other file, mvtor, is one for doing a manual move, specify the torrent as an arguement; e.g., <code>./mvtor "ubuntu-10.04.1-alternate-i386.iso"</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.amyl.org.uk/2010/09/transmission-and-renaming-torrents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox Extensions</title>
		<link>http://blog.amyl.org.uk/2010/01/firefox-extensions/</link>
		<comments>http://blog.amyl.org.uk/2010/01/firefox-extensions/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 00:39:15 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[indolence]]></category>
		<category><![CDATA[machine set-up]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[geek]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[new machine]]></category>
		<category><![CDATA[set-up]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.amyl.org.uk/?p=70</guid>
		<description><![CDATA[Thought this might double up as a note of the firefox extensions I currently have installed &#8212; I&#8217;ve tried getting this to script, but, the source file isn&#8217;t something I&#8217;m over-familiar with, and getting fields to match-up ain&#8217;t happening, due to my crapness.
Anyhow, I would appear to have these firefox extensions installed:

Adblock Plus
AutoPager
BetterFlickr
Better YouTube
Delicious Bookmarks
DownloadHelper
Echofon
Extended]]></description>
			<content:encoded><![CDATA[<p>Thought this might double up as a note of the firefox extensions I currently have installed &#8212; I&#8217;ve tried getting this to script, but, the source file isn&#8217;t something I&#8217;m over-familiar with, and getting fields to match-up ain&#8217;t happening, due to my crapness.</p>
<p>Anyhow, I would appear to have these firefox extensions installed:</p>
<ul>
<li><a href="http://adblockplus.org/">Adblock Plus</a></li>
<li>AutoPager</li>
<li>BetterFlickr</li>
<li><a href="http://ginatrapani.org/workshop/firefox/betteryoutube/">Better YouTube</a></li>
<li><a href="http://delicious.com">Delicious Bookmarks</a></li>
<li>DownloadHelper</li>
<li><a href="http://echofon.com/">Echofon</a></li>
<li>Extended Statusbar</li>
<li><a href="http://www.applian.com/fast-video-download/">Fast Video Downloader (with SearchMenu)</a></li>
<li><a href="http://www.getfirebug.com/">Firebug</a></li>
<li>Firefox (default)</li>
<li>Firefox (en-GB)</li>
<li><a href="http://flagfox.net/">Flagfox</a></li>
<li><a href="http://flashblock.mozdev.org/">Flashblock</a></li>
<li><a href="http://www.longfocus.com/firefox/gmanager/">Gmail Manager</a></li>
<li><a href="http://skrul.com/blog/projects/greasefire">Greasefire</a></li>
<li><a href="http://mozmonkey.com/">Greasemonkey</a></li>
<li>Image Download</li>
<li>Image Zoom</li>
<li>Inline Code Finder for Firebug</li>
<li>is.gd Creator</li>
<li><a href="http://www.oxymoronical.com/web/firefox/jsoptions">JavaScript Options</a></li>
<li>keyconfig</li>
<li><a href="http://www.magic-imv.ro/vd/">Magic&#8217;s Video Downloader</a></li>
<li>oldbar</li>
<li><a href="http://passwordexporter.fligtar.com">Password Exporter</a></li>
<li>Save Image in Folder [sic]</li>
<li><a href="http://code.google.com/p/firefox-showip/">ShowIP</a></li>
<li><a href="http://skipscreen.com/">SkipScreen</a></li>
<li>TinyUrl Creator</li>
<li>Ubuntu Firefox Modificiations</li>
<li>URL Fixer</li>
<li><a href="http://www.vmware.com/">VMware Remote Console Plug-In</a></li>
<li>Xulrunner (en-GB)</li>
<li>YesScript</li>
</ul>
<p>A few of those don&#8217;t have links I can identify from the URI.</p>
<p>Want some code that vaguely does this for you?<br />
<code><br />
#!/bin/sh<br />
#<br />
# ffexts:<br />
#   list firefox extensions: names and URIs for download/homepage<br />
#<br />
# Copyright (c) 2010 Adam McGreggor. Some rights reserved.<br />
# Email: &#60;adam@amyl.org.uk&#62; Web: &#60;http://blog.amyl.org.uk&#62;<br />
#<br />
# $Id: ffexts 119 2010-01-10 00:38:04Z adam $<br />
#</p>
<p>set -e</p>
<p>MOZDIR=~/.mozilla/firefox<br />
PROFDIR=`ls -lha ${MOZDIR} | grep default | awk '{print $NF}'`<br />
FILE=extensions.rdf<br />
INFILE=${MOZDIR}/${PROFDIR}/${FILE}<br />
OF=~/tmp/ffexts<br />
OUTFILE=~/pseudohome/nas-docs/firefox-extensions-$(date '+%Y%m%d')</p>
<p># check for existing outfile, as we'll be<br />
# appending; if so, zap it<br />
if [ -e ${OUTFILE} ]; then<br />
    rm ${OUTFILE}<br />
fi</p>
<p># grab the interesting bits from the RDF file<br />
for K in name homepageURL<br />
do<br />
   # nice fix-up, eh?<br />
    grep "NS1:${K}" ${INFILE}  | sed -e "s/NS1:${K}=//" \<br />
            -e 's/"//g' -e 's/>//' \<br />
            -e 's/^[ \t]*//' | sort | uniq > ${OF}-${K}<br />
    # using wc here is entirely optional <img src='http://blog.amyl.org.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
    wc -l ${OF}-${K}<br />
    # append<br />
    cat ${OF}-${K} >> ${OUTFILE}<br />
done<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.amyl.org.uk/2010/01/firefox-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conditional Prompt colo(u)rs</title>
		<link>http://blog.amyl.org.uk/2009/12/conditional-prompt-colors/</link>
		<comments>http://blog.amyl.org.uk/2009/12/conditional-prompt-colors/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 16:45:04 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[ENV]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[machine set-up]]></category>
		<category><![CDATA[misc]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[conditional]]></category>
		<category><![CDATA[dotfiles]]></category>
		<category><![CDATA[hostname]]></category>
		<category><![CDATA[prompt]]></category>
		<category><![CDATA[PS1]]></category>

		<guid isPermaLink="false">http://tanqueray.amyl.org.uk/~adam/blog/?p=61</guid>
		<description><![CDATA[setting a colored prompt; different color for different machines based on hostname, oh yes.]]></description>
			<content:encoded><![CDATA[<p>I often work on several different machines, for different projects and things. It&#8217;s bloody annoying when I get the wrong machine!</p>
<p>I thought. I know what, I&#8217;ll make all of these machines use a colored prompt, and make that lot of machines use a different one.</p>
<p>(At this point, I should say that my dotfiles, and a variety of other things are kept in a subversion repo. Most of those bits are my-eyes-only (particularly a lot of the very badly/hastily thrown together scripts), but a few bits I&#8217;m gradually releasing.)</p>
<p>After mentioning this on <a href="http://twitter.com/adamamyl/status/6945837040">twitter</a>, a couple of people have been interested in how I did it.</p>
<p>The solution is quite easy, work out the hostname, and from that determine the &#8216;class&#8217; of machine, and then apply some colors. The <a href="http://wiki.archlinux.org/index.php/Color_Bash_Prompt#Wolfman.27s">archwiki</a> was useful in getting out the colors to use; along with underlining, and emboldening (I <strong>never</strong> use underlining, except in manuscript: ghastly thing that obscures text).</p>
<p>Whilst not perfect (the color parts could be set as a variable, and then passed to the PS1 line; I could have used &#8220;else&#8221; clauses&#8230;), it works. For me, so, erm, here&#8217;s <a href="http://code.amyl.org.uk/adam/dotfiles/bashrc">my .bashrc</a> &#8212; you want from the <code># work out machine name/domain:</code> line.</p>
<p>A simple switch wotsits in <code>screen(1)</code>, and</p>
<p><code>$ cd ~/pseudohome &#038;&#038; svn up</code></p>
<p>followed with a </p>
<p><code> $ . .bashrc</code></p>
<p>is how I deploy (some people have an &#8217;svn up&#8217; in their start-up scripts, I don&#8217;t).</p>
<p>Comments here, if you want to.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.amyl.org.uk/2009/12/conditional-prompt-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

