<?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>Craig Loftus &#187; Scripts</title>
	<atom:link href="http://craigloftus.net/blog/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://craigloftus.net/blog</link>
	<description></description>
	<lastBuildDate>Tue, 25 Oct 2011 09:55:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Changing the S3 bucket region with Déjà Dup</title>
		<link>http://craigloftus.net/blog/2011/10/13/changing-the-s3-bucket-region-with-deja-dup/</link>
		<comments>http://craigloftus.net/blog/2011/10/13/changing-the-s3-bucket-region-with-deja-dup/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 18:03:59 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[back-up]]></category>
		<category><![CDATA[dconf]]></category>
		<category><![CDATA[deja-dup]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://craigloftus.net/blog/?p=103</guid>
		<description><![CDATA[Déjà Dup is a simplified back-up tool for Gnome that lets you use a variety of storage options for backing up your computer. However, its handling of Amazon S3 is a little simplistic as it does not let you set the region of the bucket that it will automatically create for you or use a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://launchpad.net/deja-dup">Déjà Dup</a> is a simplified back-up tool for Gnome that lets you use a variety of storage options for backing up your computer. However, its handling of <a href="http://aws.amazon.com/s3/">Amazon S3</a> is a little simplistic as it does not let you set the region of the bucket that it will automatically create for you or use a pre-existing bucket. Amazon charges based on where data is sent and got from, so if you do not live in the US Déjà Dup will cost you extra. There is <a href="https://bugs.launchpad.net/deja-dup/+bug/548632">a bug report</a> of course, but that does not seem to be getting attention, so below are instructions for a work around.</p>
<p>I have not tested the instructions exhaustively, but it works for me on Fedora 16 Beta with Déjà Dup version 19.90, having initially let Déjà Dup create a default bucket. They are based on an <a href="https://answers.launchpad.net/deja-dup/+question/81409">answer</a> to a different problem. Essentially the fix is to manually specify the bucket used in the dconf data for Déjà Dup, after which it just magically carries on working.</p>
<ul>
<li>Using an S3 tool&hellip;</li>
<ol>
<li>Create a bucket with the correct region specified</li>
<li>If applicable, copy the contents from the default Déjà Dup bucket into the new one</li>
</ol>
<li>On your computer&hellip;</li>
<ol>
<li>You will need to use the <em>dconf</em> tool, which is probably already installed</li>
<li><code>$ dconf write /org/gnome/deja-dup/s3/bucket \'<var>bucket-name</var>\'</code></li>
<li>Also, you may want to change or reset the folder key, <code>$ dconf reset /org/gnome/deja-dup/s3/folder</code></li>
</ol>
</ul>
<p>Note that the escaped quote marks are required but I have no idea why. If you are not comfortable putting magic incantations into the terminal there is a GUI editor for dconf which you should be able to find in a package with a name like <em>dconf-editor</em>, or <em>dconf-tools</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigloftus.net/blog/2011/10/13/changing-the-s3-bucket-region-with-deja-dup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google Books android script</title>
		<link>http://craigloftus.net/blog/2010/07/29/google-books-android-script/</link>
		<comments>http://craigloftus.net/blog/2010/07/29/google-books-android-script/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 08:49:02 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Distractions]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://craigloftus.net/blog/?p=71</guid>
		<description><![CDATA[The script below lets you scan multiple book barcodes and add the books directly to your Google Library. Since getting a Nexus One I&#8217;ve been wanting to dabble with programming something for it, Java seemed far too hard. However, I quickly came across Scripting Layer for Android (SL4A) which lets you write quick scripts in [...]]]></description>
			<content:encoded><![CDATA[<p>The script below lets you scan multiple book barcodes and add the books directly to your Google Library.</p>
<p>Since getting a Nexus One I&#8217;ve been wanting to dabble with programming something for it, Java seemed far too hard. However, I quickly came across <a href="http://code.google.com/p/android-scripting/">Scripting Layer for Android</a> (SL4A) which lets you write quick scripts in a variety of languages; including my favourite, Python. The next challenge was to actually come up with a simple project to get my hands dirty.</p>
<p>Matt Cutts wrote a <a href="http://www.mattcutts.com/blog/android-barcode-scanner/">simple script</a> that scans a barcode and pulls up its Google Books page, from which you can then click the &#8216;add to my library&#8217; button, but this seemed far too clumsy and slow to me, so I settled on improving it. The script now lets you scan multiple books in series and then add them to your Google library by making use of the <a href="http://code.google.com/apis/books/">Google Books Search API</a>.</p>
<p>See the code (public domain) below:</p>
<blockquote>
<pre>
import android
from gdata.books.service import BookService
import gdata.books

email = 'youremail@gmail.com'
password = 'yourpassword'

droid = android.Android()

def dialog(items):
  title = 'Another?'
  droid.dialogCreateAlert(title)
  droid.dialogSetItems(items)
  droid.dialogSetPositiveButtonText('Add')
  droid.dialogSetNegativeButtonText('Exit')
  droid.dialogSetNeutralButtonText('Upload')
  droid.dialogShow()
  response = droid.dialogGetResponse().result
  return response['which']

def add_from_queue(self):
   for k,b in self.queue.items():
      self.add_item_to_library(b)
   return(True)

def get_by_barcode(self):
   (id, result, error) = droid.scanBarcode()
   if result is not True:
      return(False)
   isbn = int(result['extras']['SCAN_RESULT'])
   q = 'ISBN'+str(isbn)
   b = self.search(q, feed=self.ITEM_FEED).entry[0]
   self.queue[b.dc_title[0].text] = b
   return(True)

gdata.books.service.BookService.get_by_barcode = get_by_barcode
gdata.books.service.BookService.add_from_queue = add_from_queue
gdata.books.service.BookService.queue = {}
gdata.books.service.BookService.ITEM_FEED = gdata.books.service.ITEM_FEED

service = gdata.books.service.BookService()
service.ClientLogin(email, password)

service.get_by_barcode()

i = True
while i:
  response = dialog(service.queue.keys())

  if response == 'positive':
     service.get_by_barcode()

  elif response == 'neutral':
     service.add_from_queue()
     service.queue = {}

  else:
     i = False

droid.exit()
</pre>
</blockquote>
<p><strong>Updated:</strong> Thanks to sjb for <a href="http://groups.google.com/group/android-scripting/browse_thread/thread/6bcda21978b49f2#msg_73ecc35dec8b0d8d">pointing out</a> a bug in the code; now fixed.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigloftus.net/blog/2010/07/29/google-books-android-script/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Not so new look</title>
		<link>http://craigloftus.net/blog/2007/04/21/not-so-new-look/</link>
		<comments>http://craigloftus.net/blog/2007/04/21/not-so-new-look/#comments</comments>
		<pubDate>Sat, 21 Apr 2007 13:16:34 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Information]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://craigloftus.net/blog/2007/04/21/not-so-new-look/</guid>
		<description><![CDATA[I changed the look of the website a little while back, as you may have noticed. It is quite a significant departure from the previous style and layout. The two main changes are the new colour scheme and the inclusion of a number of feeds on the index page. Colour scheme I was inspired to [...]]]></description>
			<content:encoded><![CDATA[<p>I changed the look of the website a little while back, as you may have noticed.  It is quite a significant departure from the previous style and layout.  The two main changes are the new colour scheme and the inclusion of a number of feeds on the index page.</p>
<h4>Colour scheme</h4>
<p>I was inspired to change to a much darker scheme having read an article on <a href="http://ecoiron.blogspot.com/2007/01/emergy-c-low-wattage-palette.html">how the colours effect the energy required to display a website</a>.  Essentially, bright and light colours require more energy from your monitor.</p>
<h4>Feeds</h4>
<p>These feeds represent online content which I have created.  Although in the case of recommended posts and bookmarks this <em>creation</em> might be considered a bit abstract.  This was an idea I had a <a href="http://craigloftus.net/blog/2006/12/25/what-am-i-reading-2/" title="My post called What am I reading">long while ago</a>, and then not so long ago came across a way of quickly and crudely implementing it.</p>
<p>Up until today the feeds have been read, parse and output each time the page was called.  This was causing significant delays in the page loading times.   As of today a static file containing the parsed feeds is generated every 12 hours.  The index page then calls on the static file when a request is made which means that no time is wasted on parsing the feed and preparing the output.</p>
<p>For those interested I&#8217;ve done this quite simply by writing taking a php file that was parsing the feeds and having it write the output to a static file.  I then have a <a href="http://en.wikipedia.org/wiki/Cron">cron</a> job run the php file at 9am and 9pm everyday:</p>
<p><code>0 9,21 * * * /usr/bin/php -q /<var>PATH</var>/generate_static_feeds.php > /dev/null</code></p>
<p>The last bit of that command &#8220;/dev/null&#8221; sends the output into the ether.  Without it the server will e-mail the output of the script&hellip;  which for some purposes can be rather useful.</p>
<p>In time I&#8217;ll be working on a more complex way of displaying the recommended posts, which will allow me to write a little note to go with each explaining why I have recommended them.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigloftus.net/blog/2007/04/21/not-so-new-look/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New toys</title>
		<link>http://craigloftus.net/blog/2006/04/22/new-toys/</link>
		<comments>http://craigloftus.net/blog/2006/04/22/new-toys/#comments</comments>
		<pubDate>Sat, 22 Apr 2006 10:51:14 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://craigloftus.net/blog/2006/04/22/new-toys/</guid>
		<description><![CDATA[Over the Easter holiday I managed to find some time to tinker with a few new features for my website. Statistics Update This is no longer available This grew out of my insatiable curiosity which has meant I have sought to record visitors to my website for some time now. I forced myself around to [...]]]></description>
			<content:encoded><![CDATA[<p>Over the Easter holiday I managed to find some time to tinker with a few new features for my website.</p>
<h4>Statistics</h4>
<p><strong>Update</strong> This is no longer available</p>
<p>This grew out of my insatiable curiosity which has meant I have sought to record visitors to my website for some time now.  I forced myself around to doing so, managing to get it started by combining it with a new fascination for <a href="http://maps.google.com">Google Maps</a>.  There are quite a few features I would like to try to work into it, but I think the basics are there.  You are being watched! (But only if you visit the index page).</p>
<h4><a href="http://craigloftus.net/tools/polyliner/" title="The polyliner homepage">Polyliner</a></h4>
<p>A tool for drawing routes onto Google Maps, and associating information with it.  This is very much in development at the moment, and there are lot of things I&#8217;m not particularly happy with.  This came from a need to display migration routes of my ancestors to be place on the family website my dad <ins>was</ins> <del>is</del> developing.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigloftus.net/blog/2006/04/22/new-toys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

