<?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>p3d.co.uk</title>
	<atom:link href="http://p3d.co.uk/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://p3d.co.uk/blog</link>
	<description></description>
	<lastBuildDate>Tue, 23 Mar 2010 17:28:03 +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>remove files older than x days</title>
		<link>http://p3d.co.uk/blog/?p=105</link>
		<comments>http://p3d.co.uk/blog/?p=105#comments</comments>
		<pubDate>Tue, 23 Mar 2010 17:28:03 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[memotoself]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=105</guid>
		<description><![CDATA[find .* -mtime +14 -exec rm {} \;
]]></description>
			<content:encoded><![CDATA[<p><code>find .* -mtime +14 -exec rm {} \;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=105</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>json and rails</title>
		<link>http://p3d.co.uk/blog/?p=93</link>
		<comments>http://p3d.co.uk/blog/?p=93#comments</comments>
		<pubDate>Sat, 20 Feb 2010 14:24:13 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=93</guid>
		<description><![CDATA[The following is one way to handle json responses from a rails application.
So, I have a ajax request in a script in my page. In this example I am using the jquery poll plugin to poll the status of a file import.

$("#").poll({
    url: "/mis_imports/import_state/&#60;%=import.id%&#62;",
    interval: 3000,
    [...]]]></description>
			<content:encoded><![CDATA[<p>The following is <strong>one</strong> way to handle json responses from a rails application.<br />
So, I have a ajax request in a script in my page. In this example I am using the jquery poll plugin to poll the status of a file import.</p>
<pre name="code" class="javascript">
$("#<%=import.id%>").poll({
    url: "/mis_imports/import_state/&lt;%=import.id%&gt;",
    interval: 3000,
    type: "GET",
    success: function(data){
                   var return_data = eval('(' + data + ')');
                   $("#<%=import.id%>").attr("class","mis_import_state_"+return_data.state);
		   $("#<%=import.id%>_message").html(""+return_data.status+"");
		   $("#<%=import.id%>_timestamp").html(""+return_data.timestamp+"");
		   if (return_data.state == 1){
		     $(this).stop();
		   }
    }
});
</pre>
<p>And on the server, my rails action method looks like this:</p>
<pre name="code" class="ruby">
def import_state
    import = MisImport.find(params[:id])
    render :text => {:state => import.state,:status => import.message,:timestamp => Time.now.strftime("%d:%b:%Y %H:%M:%S")}.to_json
  end
</pre>
<p>The key part to this working is line 6 of the javascript listing, where one &#8216;evals&#8217; the data returned from the server.<br />
This effectively rehydrates the data structure into a usable javascript object, and that&#8217;s the bit I keep forgetting!</p>
<p>There are probably smarter ways of doing this; I know there is a <a href="http://api.jquery.com/jQuery.getJSON/">jQuery.getJSON()</a> function, but in this case I couldn&#8217;t work out how to use that with jquery poll. Again, probably very simple&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=93</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony class::preInsert() should be compatible with that of Doctrine_Record::preInsert()</title>
		<link>http://p3d.co.uk/blog/?p=88</link>
		<comments>http://p3d.co.uk/blog/?p=88#comments</comments>
		<pubDate>Tue, 19 Jan 2010 11:21:18 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[memotoself]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=88</guid>
		<description><![CDATA[I wanted to use the preInsert() method to do some calculations on a model class before it was saved. But I encountered the error:
Strict Standards: Declaration of Blah::preInsert() should be compatible with that of Doctrine_Record::preInsert() in /PATH/lib/model/doctrine/Klass.class.php on line 14
The code I had in my class file looked something like this:

public function preInsert(Doctrine_Event $event)
{
$this-&#62;calculate_status();
}

This seemed [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to use the preInsert() method to do some calculations on a model class before it was saved. But I encountered the error:<br />
<strong>Strict Standards: Declaration of Blah::preInsert() should be compatible with that of Doctrine_Record::preInsert() in /PATH/lib/model/doctrine/Klass.class.php on line 14</strong></p>
<p>The code I had in my class file looked something like this:</p>
<pre name="code" class="php">
public function preInsert(Doctrine_Event $event)
{
$this-&gt;calculate_status();
}
</pre>
<p>This seemed correct, but I was getting this strict error.<br />
Anyway, short story shorter, I removed the Doctrine_Event (type hint?) from my method signature and the warning went away.<br />
New code looks like this:</p>
<pre name="code" class="php">
public function preInsert($event)
{
$this-&gt;calculate_status();
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=88</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony throws message &#8220;couldn&#8217;t get last insert identifier&#8221;</title>
		<link>http://p3d.co.uk/blog/?p=84</link>
		<comments>http://p3d.co.uk/blog/?p=84#comments</comments>
		<pubDate>Sat, 09 Jan 2010 19:49:04 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[memotoself]]></category>
		<category><![CDATA[symfony]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tippage]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=84</guid>
		<description><![CDATA[I&#8217;ve started using the Symfony PHP framework for my php projects, and while the learning curve has been steeper than I would have liked, I&#8217;m getting there.
Anyway, one of the problems I&#8217;ve had a few times over the current project is the error
&#8220;couldn&#8217;t get last insert identifier&#8221;
So far, the problem has been down to the [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started using the <a href="http://www.symfony-project.org/">Symfony PHP framework</a> for my php projects, and while the learning curve has been steeper than I would have liked, I&#8217;m getting there.</p>
<p>Anyway, one of the problems I&#8217;ve had a few times over the current project is the error<br />
<strong>&#8220;couldn&#8217;t get last insert identifier&#8221;</strong></p>
<p>So far, the problem has been down to the object I have been trying to create didn&#8217;t have it&#8217;s id field set to autoincrement. Or perhaps more accurately, <strong>setting that model&#8217;s id field to autoincrement has sorted the problem</strong> so far.<br />
Hopefully once I get the hang of the schema file and the (what appears to be) the slightly different syntax for migrations, all my models should have autoincrement id fields and this shouldn&#8217;t be a problem anymore.</p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=84</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>trouble installing ruby image_science</title>
		<link>http://p3d.co.uk/blog/?p=73</link>
		<comments>http://p3d.co.uk/blog/?p=73#comments</comments>
		<pubDate>Mon, 07 Dec 2009 19:50:45 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[image science]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=73</guid>
		<description><![CDATA[I am using the Image Science library to do some simple thumbnailing of uploaded images in a project.
This library is very simple to use, and by all accounts is nice and lightweight and so seemed right.
However, I hit a few problems getting it installed.
One of the requirements on the site is for Ruby Inline. Now, [...]]]></description>
			<content:encoded><![CDATA[<p>I am using the <a href="http://seattlerb.rubyforge.org/ImageScience.html">Image Science</a> library to do some simple thumbnailing of uploaded images in a project.</p>
<p>This library is very simple to use, and by all accounts is nice and lightweight and so seemed right.</p>
<p>However, I hit a few problems getting it installed.</p>
<p>One of the requirements on the site is for <a href="http://rubyforge.org/frs/?group_id=440&amp;release_id=37754">Ruby Inline</a>. Now, in my haste the first time through I thought I could just <strong>gem install inline</strong> .</p>
<p>Hah, not so! <strong>The inline gem is not the RubyInline gem</strong> as linked to from the Image Science site.</p>
<p>So, one has to install the RubyInline gem to get it to work.</p>
<p>Of course this is clearly signposted on the Image Science  page, but I thought I&#8217;d note it here.</p>
<p>Assumption being the mother of all wasted evenings etc etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=73</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>rebuild cpanel apache config for custom includes</title>
		<link>http://p3d.co.uk/blog/?p=70</link>
		<comments>http://p3d.co.uk/blog/?p=70#comments</comments>
		<pubDate>Tue, 01 Dec 2009 12:03:38 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[cpanel]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=70</guid>
		<description><![CDATA[I needed to create a ServerAlias for one of my subdomains recently and cPanel was stubbornly refusing to do it via the web interface, something to do with dns servers.
Anyway, I just added a simple ServerAlias subdomain.domain.com entry in a file in
/usr/local/apache/conf/userdata/std/2/domain.com/sub.domain.com/subdomain.conf
Then I ran this command:
/scripts/ensure_vhost_includes --all-users
which gets cPanel to rebuild it&#8217;s various config files.
Everything [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to create a ServerAlias for one of my subdomains recently and cPanel was stubbornly refusing to do it via the web interface, something to do with dns servers.</p>
<p>Anyway, I just added a simple <strong>ServerAlias subdomain.domain.com </strong>entry in a file in</p>
<pre>/usr/local/apache/conf/userdata/std/2/domain.com/sub.domain.com/subdomain.conf</pre>
<p>Then I ran this command:</p>
<pre>/scripts/ensure_vhost_includes --all-users</pre>
<p>which gets cPanel to rebuild it&#8217;s various config files.</p>
<p>Everything works fine now</p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=70</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>sort a ruby hash</title>
		<link>http://p3d.co.uk/blog/?p=67</link>
		<comments>http://p3d.co.uk/blog/?p=67#comments</comments>
		<pubDate>Mon, 30 Nov 2009 20:01:31 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=67</guid>
		<description><![CDATA[A neat way to sort a hash
my_hash.keys.sort_by {&#124;s&#124; s.to_s}.map {&#124;key&#124; [key, my_hash[key]] }
found here
]]></description>
			<content:encoded><![CDATA[<p>A neat way to sort a hash</p>
<pre name="code" class="ruby">my_hash.keys.sort_by {|s| s.to_s}.map {|key| [key, my_hash[key]] }</pre>
<p><a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/197213">found here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=67</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>escaping text input for urls in javascript</title>
		<link>http://p3d.co.uk/blog/?p=65</link>
		<comments>http://p3d.co.uk/blog/?p=65#comments</comments>
		<pubDate>Thu, 29 Oct 2009 10:54:11 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript escaping]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=65</guid>
		<description><![CDATA[If you need to make sure that some text entered into a text field can be sent as part of a uri, say in an ajax call as a parameter, then the built in javascript function encodeURIComponent() seems to work well.
Reference here.
]]></description>
			<content:encoded><![CDATA[<p>If you need to make sure that some text entered into a text field can be sent as part of a uri, say in an ajax call as a parameter, then the built in javascript function <strong>encodeURIComponent()</strong> seems to work well.</p>
<p><a href="http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp">Reference here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=65</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with json from rails</title>
		<link>http://p3d.co.uk/blog/?p=59</link>
		<comments>http://p3d.co.uk/blog/?p=59#comments</comments>
		<pubDate>Wed, 28 Oct 2009 17:18:17 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[rails javascript json]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=59</guid>
		<description><![CDATA[If we have an array called users which contains a number of User objects sent from our rails app, then looping through this array gives us access to each user object.
for (var i = 0;i&#60;users.length;i++) {
   var user = users[i];
   alert(user.user.name);  //This gives us the name property of the object.
 }
Note that each object in [...]]]></description>
			<content:encoded><![CDATA[<p>If we have an array called users which contains a number of User objects sent from our rails app, then looping through this array gives us access to each user object.</p>
<pre name="code" class="javascript">for (var i = 0;i&lt;users.length;i++) {
   var user = users[i];
   alert(user.user.name);  //This gives us the name property of the object.
 }</pre>
<p>Note that each object in the array is preceeded by the name of the class, hence the double user. syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=59</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jquery Boxy close popup</title>
		<link>http://p3d.co.uk/blog/?p=56</link>
		<comments>http://p3d.co.uk/blog/?p=56#comments</comments>
		<pubDate>Tue, 27 Oct 2009 15:26:58 +0000</pubDate>
		<dc:creator>paul</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://p3d.co.uk/blog/?p=56</guid>
		<description><![CDATA[I use the rather excellent Boxy plugin to do some modal style popups.
If you want to close the popup programatically from within the popup, say from a cancel button, you can do it like so&#8230;
&#60;input type=button value="Cancel" onClick="cancel_button(this);"&#62;

function cancel_button(popup){
 if(confirm("All changes will be lost")){
  Boxy.get(popup).hide();
 }
}
]]></description>
			<content:encoded><![CDATA[<p>I use the rather excellent <a href="http://onehackoranother.com/projects/jquery/boxy/">Boxy plugin</a> to do some modal style popups.</p>
<p>If you want to close the popup programatically from within the popup, say from a cancel button, you can do it like so&#8230;</p>
<pre name="code" class="html">&lt;input type=button value="Cancel" onClick="cancel_button(this);"&gt;</pre>
<pre name="code" class="javascript">
function cancel_button(popup){
 if(confirm("All changes will be lost")){
  Boxy.get(popup).hide();
 }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://p3d.co.uk/blog/?feed=rss2&amp;p=56</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
