<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Transcending Frontiers » Understanding Ruby Blocks, Procs and Lambdas</title>
	
	<link>http://thefrontiergroup.com.au/blog</link>
	<description>Your peek inside the collective mind of The Frontier Group</description>
	<pubDate>Wed, 07 Jan 2009 00:33:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/TranscendingFrontiers" type="application/rss+xml" /><item>
		<title>Understanding Ruby Blocks, Procs and Lambdas</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/504778649/</link>
		<comments>http://thefrontiergroup.com.au/blog/2009/01/understanding-ruby-blocks-procs-and-lambdas/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 00:33:16 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
		
		<category><![CDATA[Websites or Tools]]></category>

		<category><![CDATA[Rails]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=267</guid>
		<description><![CDATA[I thought that I understood Ruby a little bit, but after reading Robert Sosinski&#8217;s article on Blocks, Procs and Lamdas in Ruby I felt a little humbled. To take such a small part of a language and express such detail and give some very useful examples really impressed me. The similarities between some of the [...]]]></description>
			<content:encoded><![CDATA[<p>I thought that I understood Ruby a little bit, but after reading Robert Sosinski&#8217;s article on <a href="http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/">Blocks, Procs and Lamdas in Ruby</a> I felt a little humbled. To take such a small part of a language and express such detail and give some very useful examples really impressed me. The similarities between some of the ways I do things using Javascript and his examples really surprised me too.</p>
<p>I&#8217;d recommend giving it a good read to really understand how things work with these constructs and it may even give you a few new ideas on how to approach some problems you&#8217;ve encountered along the way.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2009/01/understanding-ruby-blocks-procs-and-lambdas/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2009/01/understanding-ruby-blocks-procs-and-lambdas/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2009/01/understanding-ruby-blocks-procs-and-lambdas/</feedburner:origLink></item>
		<item>
		<title>And then there was five…</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/504104267/</link>
		<comments>http://thefrontiergroup.com.au/blog/2009/01/and-then-there-was-five/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 07:41:51 +0000</pubDate>
		<dc:creator>mlambie</dc:creator>
		
		<category><![CDATA[Inside TFG]]></category>

		<category><![CDATA[Lifestyle]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=274</guid>
		<description><![CDATA[Yesterday we had the honour of welcoming the company&#8217;s fifth employee to the team, Tony Issakov.
Tony&#8217;s worked on some projects with us in the past (so you might have already seen his handywork) and has been a good friend to each of us for some time now.
He shares our enthusiasm for web development and all [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday we had the honour of welcoming the company&#8217;s fifth employee to the team, Tony Issakov.</p>
<p>Tony&#8217;s worked on some projects with us in the past (so you might have already seen his handywork) and has been a good friend to each of us for some time now.</p>
<p>He shares our enthusiasm for web development and all things geeky. He&#8217;s best known for his amazing digital photography and mad JavaScript skills, and comes to us having spent many years developing Java applications as en employee of the state government. The move from Java to Ruby and PHP, as well as his shiny new MacBook Pro and having Epic Espresso just up the street are all things that he&#8217;s excited about, but I&#8217;ll let him elaborate on that. As they say, &#8220;watch this space.&#8221;</p>
<p>We&#8217;re looking forward to the new opportunities we&#8217;ll be able to undertake with the inclusion of Tony to our team.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2009/01/and-then-there-was-five/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2009/01/and-then-there-was-five/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2009/01/and-then-there-was-five/</feedburner:origLink></item>
		<item>
		<title>vi mode inside your shell</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/504094119/</link>
		<comments>http://thefrontiergroup.com.au/blog/2009/01/vi-mode-inside-your-shell/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 07:28:08 +0000</pubDate>
		<dc:creator>mlambie</dc:creator>
		
		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[bash]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[Mac]]></category>

		<category><![CDATA[terminal]]></category>

		<category><![CDATA[vi]]></category>

		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=269</guid>
		<description><![CDATA[For as long as I can remember I&#8217;ve used vim (or vi) as my editor of choice when on Linux or UNIX systems. I&#8217;ve also used bash as my shell, except in circumstances where it wasn&#8217;t available. We&#8217;ve been using Macs for a long time now, and one of the things that I only recently [...]]]></description>
			<content:encoded><![CDATA[<p>For as long as I can remember I&#8217;ve used <code>vim</code> (or <code>vi</code>) as my editor of choice when on Linux or UNIX systems. I&#8217;ve also used <code>bash</code> as my shell, except in circumstances where it wasn&#8217;t available. We&#8217;ve been using Macs for a long time now, and one of the things that I only recently learnt was that you can use CTRL-a to take you to the beginning of a line in a terminal. This meant I no longer leant on the left arrow key to get me back to the beginning of a long command.</p>
<p>I use <code>screen</code> to maintain remote, active connections to our various servers, and with my setup the CTRL-a trick didn&#8217;t work. I&#8217;ve just found that setting vi mode in bash will allow me to hit ESC then shift-I and take me to the beginning of a line. ESC engages vi mode, and you can navigate around the command as you would inside vi. For example, shift-I or 0 takes you to the start of the line, shift-a or $ to the end and h, l, k and j act as cursor keys.</p>
<p>You can engage vi mode by executing the following code, or adding it to your <code>~/.profile</code> (or any other dot file that is executed upon login).</p>
<pre name="code" class="shell">set -o vi</pre>
<p>I always like finding new shortcuts, even if there&#8217;s some minor annoyance at my former lack of awareness. It&#8217;s like how we discovered syntax highlighting in vim after completing our uni degrees&#8230; very bittersweet.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2009/01/vi-mode-inside-your-shell/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2009/01/vi-mode-inside-your-shell/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2009/01/vi-mode-inside-your-shell/</feedburner:origLink></item>
		<item>
		<title>Scaling memcached at Facebook</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/488367391/</link>
		<comments>http://thefrontiergroup.com.au/blog/2008/12/scaling-memcached-at-facebook/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 06:07:19 +0000</pubDate>
		<dc:creator>mhale</dc:creator>
		
		<category><![CDATA[Inside TFG]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=263</guid>
		<description><![CDATA[Paul Saab has written an interesting article about scaling memcached at Facebook. It looks like they&#8217;re doing some cool things over there.
]]></description>
			<content:encoded><![CDATA[<p>Paul Saab has written an interesting article about <a href="http://www.facebook.com/note.php?note_id=39391378919&amp;id=9445547199&amp;index=0">scaling memcached at Facebook</a>. It looks like they&#8217;re doing some cool things over there.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2008/12/scaling-memcached-at-facebook/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2008/12/scaling-memcached-at-facebook/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2008/12/scaling-memcached-at-facebook/</feedburner:origLink></item>
		<item>
		<title>Generating random data with MySQL</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/488319250/</link>
		<comments>http://thefrontiergroup.com.au/blog/2008/12/generating-random-data-with-mysql/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 04:56:10 +0000</pubDate>
		<dc:creator>mlambie</dc:creator>
		
		<category><![CDATA[Inside TFG]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[random]]></category>

		<category><![CDATA[typecast]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=261</guid>
		<description><![CDATA[I&#8217;m doing some modifications to a Copper installation for a customer that involved the addition of some new fields to their project table, namely CashContribution and InKind. They both track different donation types that can be made against a project.
I needed a quick way to populate some projects with dummy, random data, and here&#8217;s what [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m doing some modifications to a Copper installation for a customer that involved the addition of some new fields to their project table, namely <code>CashContribution</code> and <code>InKind</code>. They both track different donation types that can be made against a project.</p>
<p>I needed a quick way to populate some projects with dummy, random data, and here&#8217;s what I ended up with:</p>
<pre name="code" class="sql">UPDATE Projects
SET CashContribution = (SELECT CONVERT(RAND() * 1000, UNSIGNED))
WHERE ID > 600;</pre>
<p>This meant that I wasn&#8217;t looking at row-after-row of the same dummy data, and that the test system better represents the intended real-world use.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2008/12/generating-random-data-with-mysql/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2008/12/generating-random-data-with-mysql/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2008/12/generating-random-data-with-mysql/</feedburner:origLink></item>
		<item>
		<title>25 Tips for Better jQuery</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/488191281/</link>
		<comments>http://thefrontiergroup.com.au/blog/2008/12/25-tips-for-better-jquery/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 01:39:20 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
		
		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Websites or Tools]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=254</guid>
		<description><![CDATA[Typically these types of &#8220;25 Tips To&#8230;&#8221; or &#8220;10 Things That&#8230;&#8221; style articles have a few good points but are filled with fluff. However the article 25 Tips for Better jQuery is full of great points that cover architecture, coding conventions, compatibility and performance.
If you are looking to get a better handle on jQuery and [...]]]></description>
			<content:encoded><![CDATA[<p>Typically these types of &#8220;25 Tips To&#8230;&#8221; or &#8220;10 Things That&#8230;&#8221; style articles have a few good points but are filled with fluff. However the article <a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx">25 Tips for Better jQuery</a> is full of great points that cover architecture, coding conventions, compatibility and performance.</p>
<p>If you are looking to get a better handle on jQuery and more importantly how to use it well, I haven&#8217;t seen many better places to start.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2008/12/25-tips-for-better-jquery/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2008/12/25-tips-for-better-jquery/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2008/12/25-tips-for-better-jquery/</feedburner:origLink></item>
		<item>
		<title>Handling Permissions for AJAX Requests</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/487518981/</link>
		<comments>http://thefrontiergroup.com.au/blog/2008/12/handling-permissions-for-ajax-requests/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 11:10:12 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=248</guid>
		<description><![CDATA[Again I have a website where a lot of data transfer is done asynchronously and a large amount of the presentation is done using Javascript. Different users have different access to features across the site, and I can&#8217;t just rely on hiding links given the data is a simple HTTP request away. Protecting this data [...]]]></description>
			<content:encoded><![CDATA[<p>Again I have a website where a lot of data transfer is done asynchronously and a large amount of the presentation is done using Javascript. Different users have different access to features across the site, and I can&#8217;t just rely on hiding links given the data is a simple HTTP request away. Protecting this data on the server side has always been easy to me, but I&#8217;ve typically found building the persistent abstractions I like to have far more difficult on the client side. As per usual, it&#8217;s probably just another issue I haven&#8217;t spent enough time to get a grip on. </p>
<p>It&#8217;s possible technologies such as Prism and Gears will help with this in the future. Unfortunately, it is the present.</p>
<p>This time I think I have a solution that I&#8217;m pretty happy with though. On the server side it involves using the existing HTTP response codes to indicate to the requester what happened with their request. On the client side the <code>ajaxComplete()</code> event is used to handle these codes. </p>
<p>jQuery will automatically call the function you specify as your callback in an AJAX request if the request is successful, so I&#8217;m only interested in handling failures. At the moment I&#8217;m assuming that all of my calls use JSON for their data format, but the alternative is a case I can handle later if need be. Only do what is necessary right now is a great credo I think.</p>
<p>So here is my event handler, it&#8217;s very simple but the documentation on the arguments to the event are a little slight. The <code>success()</code> call just makes a call to the function specified in the original call, hence passing in an empty array, simulating no records returned. The code I&#8217;m handling is for 401: Unauthorized, which in this case is the truth. This code will be sent back when I determine that the user is trying to access some data they aren&#8217;t supposed to. <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP codes</a> handle the majority of cases you&#8217;ll run into.</p>
<pre name="code" class="javascript">
(function() {
	if (typeof(jQuery) != 'undefined') {
		jQuery().ajaxComplete(function(ev, req, settings) {
			if (req.status == 401) {
				settings.success([]);
				alert('You have insufficient privileges.');
			}
		});
	}
})();
</pre>
<p>The server side code is simple, it&#8217;s just a matter of sending back the appropriate <a href="http://php.net/header">header</a>:</p>
<pre name="code" class="php">
	header('HTTP/1.0 401 Insufficient Privileges', false, 401);
</pre>
<p>This function is specified in a global include where part of the website uses prototype, I&#8217;ve been slowly integrating jQuery. Therefore the first thing I do is check if jQuery has been defined, if it has then I register my function as the handler for the <code>ajaxComplete</code> event. Since it&#8217;s declared globally this will happen on every AJAX call. If the response code is 401 then first I pass back and empty array to my <code>success</code> handler so that the little loading notifier disappears, and then I notify the user of the error. </p>
<p>It seems to be a trend lately, but again this is just a very simple idea but I hope it saves someone some hassle. I know I&#8217;ve searched high and low on the topic and haven&#8217;t found a nice generic solution.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2008/12/handling-permissions-for-ajax-requests/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2008/12/handling-permissions-for-ajax-requests/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2008/12/handling-permissions-for-ajax-requests/</feedburner:origLink></item>
		<item>
		<title>Bench marking instead of bench warming</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/486544371/</link>
		<comments>http://thefrontiergroup.com.au/blog/2008/12/bench-marking-instead-of-bench-warming/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 11:56:30 +0000</pubDate>
		<dc:creator>mlambie</dc:creator>
		
		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Websites or Tools]]></category>

		<category><![CDATA[apc]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[opcode]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[rasmus]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=232</guid>
		<description><![CDATA[In August of this year we deployed a series of new server and storage devices which we expect will carry us through to 2011. One of the negative side effects of this deployment was that all of the sites and services we hosted on the new hardware performed significantly better than on the old configuration.
I [...]]]></description>
			<content:encoded><![CDATA[<p>In August of this year we deployed a series of new server and storage devices which we expect will carry us through to 2011. One of the negative side effects of this deployment was that all of the sites and services we hosted on the new hardware performed significantly better than on the old configuration.</p>
<p>I hear you ask &#8220;how is that a negative side effect?&#8221; It meant that I put off the investigation into bench marking and tuning our server platforms simply because the move to newer hardware gave us significant gains. I had planned on doing some configuration tuning and system refinement, but the sheer increase in processing power meant that I didn&#8217;t bother with it back then.</p>
<p>Today, however, I decided to investigate what the addition of a PHP opcode cache would provide, and I was very happy with the results.</p>
<p>I came across an issue with running APC, the opcode cache developed by Rasmus and other core PHP developers, alongside the Zend Optimizer. The two are incompatible so you&#8217;ll have to play favourites and pick one or the other.</p>
<p>Installation of APC is easy on Ubuntu. There&#8217;s many guides online, but <a href="http://www.blogovela.com/installing-apc-on-ubuntu-804-hardy-heron-0314.html">I found this one</a> to be the most succinct. You end up installing the following packages (note: I didn&#8217;t have <code>build-essential</code> initially and PECL couldn&#8217;t build the package because I was missing <code>make</code>):</p>
<pre>mlambie@prime:~$  sudo aptitude install php-pear php5-dev apache2-prefork-dev build-essential</pre>
<p>The installation of APC is easy via PECL:</p>
<pre>mlambie@prime:~$  sudo pecl install apc</pre>
<p>Then enable the module by creating an apc.ini file:</p>
<pre>mlambie@prime:~$ cat /etc/php5/apache2/conf.d/apc.ini
extension = apc.so
apc.enabled = 1
apc.shm_size = 48
apc.include_once_override = 1
apc.mmap_file_mask = /tmp/apc.XXXXXX</pre>
<p>I ran some benchmarks using Apache Bench. The results were very encouraging. I saw a reduction in the time per request fall from 91ms to 37ms (250% improvement). The  volume of requests per second increased from 11/sec to 27/sec (245% improvement). Lastly, 98% of all requests are served within 639ms instead of 1165ms (182% improvement).</p>
<p>Each actual apache process saw a significant memory reduction too, from 26MB down to 20MB (almost a 25% footprint saving). When you&#8217;ve got multiple processes running the reclaimed memory adds up quite quickly.</p>
<p>I found the figures staggering, and the improvements are actual, real things that are visible when interacting with the sites and applications hosted on <code>prime</code>. </p>
<p>It&#8217;s fair to say that we more then doubled our performance, from a single server, simply by adding PHP opcode cache. If you&#8217;re not running one on your server, you might want to consider why.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2008/12/bench-marking-instead-of-bench-warming/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2008/12/bench-marking-instead-of-bench-warming/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2008/12/bench-marking-instead-of-bench-warming/</feedburner:origLink></item>
		<item>
		<title>Animating Table Rows with jQuery</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/481678440/</link>
		<comments>http://thefrontiergroup.com.au/blog/2008/12/animating-table-rows-with-jquery/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 13:55:19 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
		
		<category><![CDATA[AuroraCMS]]></category>

		<category><![CDATA[Code]]></category>

		<category><![CDATA[Product Reviews]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[Animation]]></category>

		<category><![CDATA[HTML]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=220</guid>
		<description><![CDATA[Animating table rows in the browser is problematic. You see, they aren&#8217;t block elements and as such don&#8217;t have a height or width property. Instead they take their constraints from the content inside them, and the elements that contain them. For rows this typically means they&#8217;re constrained by the containing table, and filled by the [...]]]></description>
			<content:encoded><![CDATA[<p>Animating table rows in the browser is problematic. You see, they aren&#8217;t block elements and as such don&#8217;t have a height or width property. Instead they take their constraints from the content inside them, and the elements that contain them. For rows this typically means they&#8217;re constrained by the containing table, and filled by the contained columns.</p>
<p>Today I wanted to slide a row up, and then when it had finished sliding I wanted to remove it from the DOM. Essentially giving it a nice effect when something is deleted.</p>
<p>Given that the height of a row is controlled by it&#8217;s content, I figured the easiest way to do this would be to wrap all of the content inside each column with a block element, in this case a <code>div</code>, and then resize those.</p>
<p>jQuery makes this extremely easy :</p>
<pre name="code" class="javascript">var el = $(options.element_prefix + id);
el.children("td").each(function() {
    $(this).wrapInner("< div />").children("div").slideUp(function() {el.remove();})
});</pre>
<p>NOTE : The div tag in the <code>wrapInner()</code> is malformed because it won&#8217;t display properly otherwise. Please remove the space between the opening bracket and &#8216;div&#8217;. </p>
<p>It&#8217;s all pretty easy to understand. Essentially my root element is a row, and so for each <code>td</code> in that row wrap it&#8217;s content in a <code>div</code>. Then for the child <code>divs</code> in each <code>td</code>, run the <code>slideUp()</code> method. The callback in the <code>slideUp()</code> method says after the animation is done, remove the row. Given the speed of computers these days, no one will notice that the last few columns quite likely just vanish instead of complete their animation.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2008/12/animating-table-rows-with-jquery/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2008/12/animating-table-rows-with-jquery/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2008/12/animating-table-rows-with-jquery/</feedburner:origLink></item>
		<item>
		<title>Prompting for a password with Applescript</title>
		<link>http://feeds.feedburner.com/~r/TranscendingFrontiers/~3/479218632/</link>
		<comments>http://thefrontiergroup.com.au/blog/2008/12/prompting-for-a-password-with-applescript/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 05:50:19 +0000</pubDate>
		<dc:creator>mlambie</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Tips and Tricks]]></category>

		<category><![CDATA[applescript]]></category>

		<category><![CDATA[automation]]></category>

		<category><![CDATA[management]]></category>

		<category><![CDATA[password]]></category>

		<category><![CDATA[server]]></category>

		<category><![CDATA[sudo]]></category>

		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://thefrontiergroup.com.au/blog/?p=211</guid>
		<description><![CDATA[Further to my previous foray into the world of Applescript, I&#8217;ve modified my server management script to now prompt me for a sudo password. Previously I would have to tab between each Terminal window and enter my sudo password, but now I enter it once and a dynamic command is generated that looks like this:
echo [...]]]></description>
			<content:encoded><![CDATA[<p>Further to my <a href="http://thefrontiergroup.com.au/blog/2008/11/managing-multiple-ubuntu-servers-painlessly/">previous foray into the world of Applescript</a>, I&#8217;ve modified my server management script to now prompt me for a sudo password. Previously I would have to tab between each Terminal window and enter my sudo password, but now I enter it once and a dynamic command is generated that looks like this:</p>
<p><code>echo &lt;password&gt; | sudo -S clear &#038;&#038; sudo aptitude update &#038;&#038; sudo aptitude dist-upgrade &#038;&#038; sudo aptitude clean'"</code></p>
<p>I don&#8217;t like that my sudo password is displayed on the screen. I could get around this by manually editing <code>/etc/sudoers</code> to allow for password-less aptitude. Alternatively, perhaps I could encrypt my password inside the Applescript and send it, pre-encrypted, to sudo. They&#8217;re options I guess.</p>
<p>You&#8217;ll notice that the first thing I do is clear the screen, but when there&#8217;s a second or so lag it means my password is bare for all to see. I&#8217;ll consider that when I run the script.</p>
<p>Below is an Applescript snippet which shows you how to open a dialog box and take some simple text input:</p>
<pre name="code" class="php">set my_password to display dialog "Please enter your password:" ¬
	with title "Password" ¬
	with icon caution ¬
	default answer "" ¬
	buttons {"Cancel", "OK"} default button 2 ¬
	giving up after 295 ¬
	with hidden answer
if length of (text returned of my_password) is not 0 then
	display dialog "Running the application!" buttons ["OK"] default button 1
else
	display dialog "You didn't enter a sudo password!" buttons ["OK"] default button 1
end if</pre>
<p>Having spent a bit of time with Ruby lately, I don&#8217;t like the syntax of Applescript very much, though it gets the job done.</p>
<script src="http://feeds.feedburner.com/~s/TranscendingFrontiers?i=http://thefrontiergroup.com.au/blog/2008/12/prompting-for-a-password-with-applescript/" type="text/javascript" charset="utf-8"></script>]]></content:encoded>
			<wfw:commentRss>http://thefrontiergroup.com.au/blog/2008/12/prompting-for-a-password-with-applescript/feed/</wfw:commentRss>
		<feedburner:origLink>http://thefrontiergroup.com.au/blog/2008/12/prompting-for-a-password-with-applescript/</feedburner:origLink></item>
	</channel>
</rss>
