<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description></description><title>devblog</title><generator>Tumblr (3.0; @bluefuton-devblog)</generator><link>http://devblog.bluefuton.com/</link><item><title>OS X: replace tabs with spaces in all files using expand</title><description>&lt;div&gt;
&lt;p&gt;We use four spaces (a.k.a. soft tabs) to indent our PHP files. If an errant developer has unknowingly used tabs, you can use &lt;a href="http://ss64.com/bash/expand.html" title="expand"&gt;expand&lt;/a&gt; to &lt;span&gt;replace tabs with spaces across an entire project.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://gist.github.com/1468061" title="https://gist.github.com/1468061"&gt;&lt;a href="https://gist.github.com/1468061"&gt;https://gist.github.com/1468061&lt;/a&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;</description><link>http://devblog.bluefuton.com/post/14120220569</link><guid>http://devblog.bluefuton.com/post/14120220569</guid><pubDate>Mon, 12 Dec 2011 16:27:00 +0000</pubDate></item><item><title>PHP: removing zero values from an array</title><description>&lt;p&gt;If you call &lt;a href="http://php.net/manual/en/function.array-filter.php"&gt;array_filter&lt;/a&gt; without a callback function, it’ll remove all array elements that evaluate to false (including zeroes).&lt;/p&gt;
&lt;pre&gt;$numbers = array(0, 1, 2, 0);
echo array_filter($numbers);&lt;/pre&gt;
&lt;p&gt;Produces:&lt;/p&gt;
&lt;pre&gt;array(1,2);&lt;/pre&gt;</description><link>http://devblog.bluefuton.com/post/4577454089</link><guid>http://devblog.bluefuton.com/post/4577454089</guid><pubDate>Wed, 13 Apr 2011 12:01:00 +0100</pubDate><category>php</category><category>array</category></item><item><title>PHP: returning an array of single attributes from an array of objects</title><description>&lt;p&gt;I miss &lt;a href="/post/2976252583/ruby-returning-an-array-of-single-attributes-from-an-arr"&gt;Ruby’s shorthand collect method to return an array of single attributes&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;animals.collect(&amp;:name)&lt;/pre&gt;
&lt;p&gt;…so I’ve created a (less elegant) equivalent for PHP.&lt;/p&gt;
&lt;pre&gt;class ArrayExtensions
{
    /**
     * From an array of objects, create a new array containing only 
     * a single attribute of each object
     * 
     * Similar to array.collect(&amp;:attribute) in Ruby
     */
    public static function collect_by_attribute($attribute, $array_of_objects)
    {
        if (!is_array($array_of_objects))
        {
            return array();
        }

        $output = array();

        foreach ($array_of_objects as $object)
        {
            if (is_object($object) &amp;&amp; isset($object-&gt;$attribute))
            {
                $output[] = $object-&gt;$attribute;
            }
        } 
        
        return $output;
    }
}
&lt;/pre&gt;
&lt;p&gt;Use it like this:&lt;/p&gt;
&lt;pre&gt;$colours = ArrayExtensions::collect_by_attribute('colour', $animals);&lt;/pre&gt;
&lt;p&gt;…and you’ll get a simple array containing just the attribute you’ve specified:&lt;/p&gt;
&lt;pre&gt;array('brown', 'blue', 'green')&lt;/pre&gt;
&lt;h2&gt;Update&lt;/h2&gt;
&lt;p&gt;If you happen to be using &lt;a href="http://www.phpactiverecord.org/"&gt;PHP ActiveRecord&lt;/a&gt;, they have a function called collect that will accomplish the same thing.&lt;/p&gt;
&lt;pre&gt;$colours = ActiveRecord\collect($animals, 'colour');&lt;/pre&gt;</description><link>http://devblog.bluefuton.com/post/4577309878</link><guid>http://devblog.bluefuton.com/post/4577309878</guid><pubDate>Wed, 13 Apr 2011 11:49:00 +0100</pubDate><category>php</category><category>array</category></item><item><title>PHP: check if a PEAR class is installed</title><description>&lt;p&gt;You can’t use file_exists because it doesn’t search the include path.&lt;/p&gt;
&lt;p&gt;fopen has a third argument that will check the include path, though:&lt;/p&gt;
&lt;pre&gt;if (@fopen('Log.php', 'r', true)) 
{   
  echo 'It exists!'; 
}
&lt;/pre&gt;</description><link>http://devblog.bluefuton.com/post/4024806363</link><guid>http://devblog.bluefuton.com/post/4024806363</guid><pubDate>Tue, 22 Mar 2011 15:32:00 +0000</pubDate><category>php</category><category>pear</category></item><item><title>Redirect the output of a command to a file when using sudo</title><description>&lt;p&gt;Rather than &gt; or », use &lt;a href="http://en.wikipedia.org/wiki/Tee_(command)"&gt;tee&lt;/a&gt;.

&lt;/p&gt;&lt;blockquote&gt;Redirecting the output of commands run with sudo requires a different approach. For instance consider &lt;code&gt;sudo ls &gt; /root/somefile&lt;/code&gt; will not work since it is the shell that tries to write to that file. You can use &lt;code&gt;ls | sudo tee -a /root/somefile&lt;/code&gt; to append, or &lt;code&gt;ls | sudo tee /root/somefile&lt;/code&gt; to overwrite contents.&lt;/blockquote&gt;

From &lt;a href="https://help.ubuntu.com/community/RootSudo"&gt;https://help.ubuntu.com/community/RootSudo&lt;/a&gt;</description><link>http://devblog.bluefuton.com/post/2976261545</link><guid>http://devblog.bluefuton.com/post/2976261545</guid><pubDate>Thu, 19 Aug 2010 16:49:11 +0100</pubDate><category>append</category><category>file</category><category>sudo</category><category>write</category></item><item><title>Subversion branching best practice</title><description>&lt;p&gt;&lt;blockquote&gt;Most new code is checked into the trunk.  In general, our developers try to never “break the tree”.  Anyone who checks in code which causes the trunk builds to fail will be the recipient of heaping helpings of trash talk and teasing until he gets it fixed.  The trunk should always build, and as much as possible, the resulting build should always work.

Most new code is checked into the trunk. The trunk is the place where active development of new features is happening.  The trunk could be described as “basically unstable”. In our situation, the stability of the trunk build fluctuates over the months during our development cycle.

During the early and middle parts of a development cycle, the trunk is often not very stable at all.  As we approach alpha, beta and final release, things settle down and the trunk gets more and more stable.

At the moment of release, a branch gets created.  This branch becomes our maintenance tree for that release.  Our current maintenance branch is called “3.0”, since that’s the current major version number of our product.  When we need to do a bug fix or patch release, it is done in the maintenance branch.  Each time we do a release out of the maintenance branch (like 3.0.2), we apply a tag.

After the maintenance branch is created, the trunk once again becomes “basically unstable”.  Developers start adding the risky code changes we didn’t want to include in the release.  New feature work begins.  The cycle starts over and repeats itself.&lt;/blockquote&gt;

From &lt;a href="http://www.ericsink.com/scm/scm_branches.html"&gt;http://www.ericsink.com/scm/scm_branches.html&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976261249</link><guid>http://devblog.bluefuton.com/post/2976261249</guid><pubDate>Mon, 02 Aug 2010 15:39:09 +0100</pubDate><category>Subversion</category></item><item><title>List your Apache virtual hosts</title><description>&lt;p&gt;&lt;pre lang="bash"&gt;apache2ctl -t -D DUMP_VHOSTS&lt;/pre&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976260951</link><guid>http://devblog.bluefuton.com/post/2976260951</guid><pubDate>Fri, 21 May 2010 14:48:15 +0100</pubDate><category>apache</category><category>virtualhost</category></item><item><title>Copy a large directory of files using ls and xargs</title><description>&lt;p&gt;&lt;pre lang="bash"&gt;ls . | xargs -i -t cp ./{} /path/to/new/directory&lt;/pre&gt;

See example 12-6 at &lt;a href="http://www.homepage.montana.edu/~unixuser/051905/abs-guide/moreadv.html"&gt;http://www.homepage.montana.edu/~unixuser/051905/abs-guide/moreadv.html&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976260652</link><guid>http://devblog.bluefuton.com/post/2976260652</guid><pubDate>Thu, 13 May 2010 16:00:14 +0100</pubDate></item><item><title>Rails migrations: creating a MySQL BIGINT</title><description>&lt;p&gt;&lt;pre lang="ruby"&gt;add_column :facebook_user_id, :integer, :limit =&gt; 8 # BIGINT&lt;/pre&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976260338</link><guid>http://devblog.bluefuton.com/post/2976260338</guid><pubDate>Wed, 07 Apr 2010 16:56:35 +0100</pubDate><category>bigint</category><category>migration</category><category>mysql</category><category>rails</category></item><item><title>Basic use of 'screen'</title><description>&lt;p&gt;Using &lt;a href="http://www.kuro5hin.org/story/2004/3/9/16838/14935"&gt;screen&lt;/a&gt; is a great way to leave long-running processes churning away when you’re not logged into the machine.

&lt;h3&gt;Open a new screen&lt;/h3&gt;

&lt;pre lang="bash"&gt;screen&lt;/pre&gt;

&lt;h3&gt;Detach from the screen&lt;/h3&gt;

This does not interrupt whatever is running in the screen.

Press Ctrl-A then D.

&lt;h3&gt;Reattach to a screen you’ve already opened&lt;/h3&gt;

&lt;pre lang="bash"&gt;screen -r&lt;/pre&gt;

If you’ve opened multiple screens, a list will be displayed:

&lt;pre lang="bash"&gt;
There are several suitable screens on:
	1681.ttys004.braeburn	(Detached)
	1686.ttys004.braeburn	(Detached)
&lt;/pre&gt;

Just use the process ID of the screen to resume the right one:

&lt;pre lang="bash"&gt;screen -r 1681&lt;/pre&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976259999</link><guid>http://devblog.bluefuton.com/post/2976259999</guid><pubDate>Thu, 25 Feb 2010 16:25:40 +0000</pubDate><category>linux</category><category>osx</category><category>screen</category></item><item><title>Change your default SSH username</title><description>&lt;p&gt;If you’ve not had your own choice of username on your machine (for example, if your company imposes a username policy), you can set up a different default username for SSH in ~/.ssh/config:

&lt;pre lang="bash"&gt;
Host *
  User chris
&lt;/pre&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976259710</link><guid>http://devblog.bluefuton.com/post/2976259710</guid><pubDate>Fri, 12 Feb 2010 17:09:09 +0000</pubDate><category>ssh</category></item><item><title>Readable, colourful Terminal in Snow Leopard</title><description>&lt;p&gt;&lt;ol&gt;&lt;li&gt;Install SIMBL: &lt;a href="http://www.culater.net/software/SIMBL/SIMBL.php"&gt;http://www.culater.net/software/SIMBL/SIMBL.php&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the Snow-Leopard-friendly version of the TerminalColors plugin for SIMBL: &lt;a href="http://github.com/timmfin/terminalcolours"&gt;http://github.com/timmfin/terminalcolours&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the IR_Black theme and set it as default in Terminal.app preferences: &lt;a href="http://blog.infinitered.com/entries/show/6"&gt;http://blog.infinitered.com/entries/show/6&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Turn on CLI color in your .bash_profile:
&lt;pre&gt;export CLICOLOR=1;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Bonus round: set yourself a colourful bash prompt: &lt;a href="http://devblog.bluefuton.com/2008/05/coloured-bash-prompt-in-os-x/"&gt;http://devblog.bluefuton.com/2008/05/coloured-bash-prompt-in-os-x/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976258781</link><guid>http://devblog.bluefuton.com/post/2976258781</guid><pubDate>Wed, 27 Jan 2010 20:15:00 +0000</pubDate><category>bash</category><category>snowleopard</category><category>terminal</category></item><item><title>Border radius in Chrome, Firefox and Safari</title><description>&lt;p&gt;Chrome 4 currently appears to be the only browser to implement the W3C’s border-radius property:

&lt;a href="http://www.w3.org/TR/2002/WD-css3-border-20021107/#the-border-radius"&gt;http://www.w3.org/TR/2002/WD-css3-border-20021107/#the-border-radius&lt;/a&gt;

&lt;pre lang="css"&gt;
border-top-left-radius: 1em;
border-top-right-radius: 1em;
&lt;/pre&gt;

You can produce the same result using proprietary attributes in Firefox 3.5 and Safari 4:

&lt;pre lang="css"&gt;
/* Firefox */
-moz-border-radius-topleft: 1em;
-moz-border-radius-topright: 1em;

/* Safari */
-webkit-border-top-left-radius: 1em;
-webkit-border-top-right-radius: 1em;
&lt;/pre&gt;

Source: &lt;a href="http://www.css3.info/preview/rounded-border/"&gt;http://www.css3.info/preview/rounded-border/&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976258486</link><guid>http://devblog.bluefuton.com/post/2976258486</guid><pubDate>Mon, 07 Dec 2009 15:47:23 +0000</pubDate><category>border</category><category>CSS</category><category>css3</category><category>radius</category></item><item><title>Using find with -exec to copy large directories</title><description>&lt;p&gt;To copy files from one directory, you might usually do:

&lt;pre lang="bash"&gt;cp dir/* anotherdir/&lt;/pre&gt;

If you try to do this with a particular large number of files, you may encounter the ‘argument list too long’ error. In this case you can use:

&lt;pre lang="bash"&gt;find . -exec cp {} /path/to/anotherdir/ \;&lt;/pre&gt;

More approaches at: &lt;a href="http://www.linuxjournal.com/article/6060"&gt;http://www.linuxjournal.com/article/6060&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976258156</link><guid>http://devblog.bluefuton.com/post/2976258156</guid><pubDate>Tue, 13 Oct 2009 20:38:16 +0100</pubDate><category>linux</category></item><item><title>FOWA 2009: The Future of HTML5</title><description>&lt;p&gt;&lt;blockquote&gt;“The web is too important for society to be in the hands of any one vendor”&lt;/blockquote&gt; - Bruce Lawson, Opera

HTML5 is more a collection of new technologies than a single new standard - we can start using parts of it today.

You can use &lt;a href="http://www.modernizr.com/"&gt;Moderizr&lt;/a&gt; to check what HTML5/CSS3 features are available in your browser. You can see it in action at &lt;a href="http://findmebyip.com/"&gt;FindMeByIP&lt;/a&gt;.

&lt;h2&gt;Canvas/SVG&lt;/h2&gt;

&lt;a href="http://www.azarask.in/blog/post/cross-browser-canvas-support-speed-tests/"&gt;Cross-browser canvas support &amp; speed&lt;/a&gt;

Canvas is possible in IE using a single script tag: check out &lt;a href="http://excanvas.sourceforge.net/"&gt;Excanvas&lt;/a&gt;

Filament have created accessible charts from HTML tables using the canvas element: &lt;a href="http://www.filamentgroup.com/lab/jquery_visualize_plugin_accessible_charts_graphs_from_tables_html5_canvas/"&gt;jQuery Visualise plugin&lt;/a&gt;

&lt;h3&gt;Accessibility: canvas or SVG?&lt;/h3&gt;
&lt;ul&gt;&lt;li&gt;With images off, canvas elements are essentially blank, whereas SVG remains as text&lt;/li&gt;
&lt;li&gt;Use SVG for content and canvas for bling (for now)&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;Forms&lt;/h2&gt;

Browser handles special field display and front-end validation that has traditionally required Javascript (popup calendar, focus on field, email validation, required field validation).

Examples: &lt;a href="http://people.opera.com/brucel/demo/html5-forms-demo.html"&gt;http://people.opera.com/brucel/demo/html5-forms-demo.html&lt;/a&gt;

&lt;h2&gt;Geolocation&lt;/h2&gt;

Currently iPhone Safari and Firefox 3.5 only.

Examples: &lt;a href="http://html5demos.com/geo"&gt;http://html5demos.com/geo&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976257821</link><guid>http://devblog.bluefuton.com/post/2976257821</guid><pubDate>Tue, 13 Oct 2009 17:42:32 +0100</pubDate><category>fowa</category><category>html5</category></item><item><title>Linux: email alert when disk is nearly full </title><description>&lt;p&gt;&lt;pre lang="bash"&gt;
#!/bin/bash
# Send an email when disk space used reaches a certain threshold
FS="/"
SERVER_NAME="linux02"
EMAIL="user@example.com"
THRESHOLD=95
OUTPUT=($(LC_ALL=C df -P ${FS}))
CURRENT=$(echo ${OUTPUT[11]} | sed 's/%//')
[ $CURRENT -gt $THRESHOLD ] &amp;&amp; df -h | mail -s "$SERVER_NAME disk space alert: $CURRENT% full" $EMAIL
&lt;/pre&gt;

I’ve set this up as a cron job run at 3am daily:

&lt;pre lang="bash"&gt;
0 3 * * * ./root/maintenance/check_free_space.sh
&lt;/pre&gt;

Based upon &lt;a href="http://www.cyberciti.biz/faq/mac-osx-unix-get-an-alert-when-my-disk-is-full/"&gt;&lt;a href="http://www.cyberciti.biz/faq/mac-osx-unix-get-an-alert-when-my-disk-is-full/"&gt;http://www.cyberciti.biz/faq/mac-osx-unix-get-an-alert-when-my-disk-is-full/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976257473</link><guid>http://devblog.bluefuton.com/post/2976257473</guid><pubDate>Wed, 30 Sep 2009 22:23:00 +0100</pubDate><category>linux</category></item><item><title>Is IE rendering in quirks mode?</title><description>&lt;p&gt;To find out, load the page in question and then paste this into your address bar:

&lt;pre lang="javascript"&gt;javascript:alert(document.compatMode);&lt;/pre&gt;

‘backCompat’ is quirks mode; ‘css1Compat’ is standards mode.

More info on quirks mode: &lt;a href="http://www.quirksmode.org/css/quirksmode.html"&gt;http://www.quirksmode.org/css/quirksmode.html&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976257131</link><guid>http://devblog.bluefuton.com/post/2976257131</guid><pubDate>Fri, 11 Sep 2009 17:27:30 +0100</pubDate><category>browser</category><category>ie</category><category>javascript</category></item><item><title>Configuring the viewport on iPhone and iPod Touch</title><description>&lt;p&gt;By default, Mobile Safari assumes that the page is 980px wide and sizes the viewport accordingly. If your page is significantly smaller, you can use the &lt;strong&gt;viewport&lt;/strong&gt; meta tag to configure the viewport dimensions. For example:

&lt;pre&gt;
&lt;meta name="viewport" content="width=320"&gt;&lt;/pre&gt;

Detailed documentation is available at &lt;a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html#//apple_ref/doc/uid/TP40006509-SW26"&gt;developer.apple.com&lt;/a&gt;.

In portrait mode, the viewport is 320px wide; in landscape mode, it’s 480px wide.&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976256844</link><guid>http://devblog.bluefuton.com/post/2976256844</guid><pubDate>Tue, 04 Aug 2009 21:26:37 +0100</pubDate><category>iphone</category><category>viewport</category></item><item><title>Apache: rewriting requests for iPhone and iPod Touch</title><description>&lt;p&gt;This snippet will rewrite all requests to the page iphone.html when viewed on iPhone or iPod Touch. Requests for .gif and .css files are not rewritten, so you can include stylesheets and images in your iPhone-specific page.

&lt;pre lang="bash"&gt;
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} .*Mobile.*Safari
RewriteRule !\.(gif|css)$ /iphone.html  [L]&lt;/pre&gt;

Source: &lt;a href="http://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/"&gt;&lt;a href="http://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/"&gt;http://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976256534</link><guid>http://devblog.bluefuton.com/post/2976256534</guid><pubDate>Tue, 04 Aug 2009 21:20:39 +0100</pubDate><category>apache</category><category>iphone</category><category>rewrite</category></item><item><title>Find files created in the last x minutes</title><description>&lt;p&gt;To find files created in the last 30 minutes:

&lt;pre lang="bash"&gt;find -cmin +30&lt;/pre&gt;&lt;/p&gt;</description><link>http://devblog.bluefuton.com/post/2976256248</link><guid>http://devblog.bluefuton.com/post/2976256248</guid><pubDate>Fri, 31 Jul 2009 16:46:35 +0100</pubDate><category>bash</category></item></channel></rss>

