tag:blogger.com,1999:blog-70572484311954157342024-03-19T04:24:07.761+00:00Measurable WinsMy "idea bucket" as a resource for developers.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.comBlogger65125tag:blogger.com,1999:blog-7057248431195415734.post-62619803989226846942015-07-31T02:55:00.000+01:002015-07-31T02:55:59.027+01:00Google Wallet Offers Expiry DatesI've been working with Google Wallet API for the last week and it's been interesting, but also a little frustrating.<br />
<br />
If you're reading this then you've probably come to the realisation that setting up Google Wallet Offers is not a simple task, especially when compared to setting up Apple's Passbook Coupons.<br />
<br />
I'm on the last leg of this project now and one of the final tasks is to roll expiry dates into the Google Offers I've created.<br />
<br />
There's a handy snippet of code found at <a href="https://developers.google.com/wallet/objects/offers/tutorial">https://developers.google.com/wallet/objects/offers/tutorial</a> which suggests it should be no big deal...
<br />
<br />
<pre class="prettyprint" style="background: rgb(247, 247, 247); box-sizing: inherit; color: #455a64; font-family: 'Roboto Mono', monospace; font-size: 14px; font-stretch: normal; line-height: 20px; margin: -7px; overflow-x: auto; padding: 7px;"><span class="pln" style="box-sizing: inherit;">$validTimeInterval </span><span class="pun" style="box-sizing: inherit;">=</span><span class="pln" style="box-sizing: inherit;"> </span><span class="kwd" style="box-sizing: inherit; color: #0097a7;">new</span><span class="pln" style="box-sizing: inherit;"> </span><span class="typ" style="box-sizing: inherit; color: #9c27b0;">Google_TimeInterval</span><span class="pun" style="box-sizing: inherit;">();</span><span class="pln" style="box-sizing: inherit;">
$startDateTime </span><span class="pun" style="box-sizing: inherit;">=</span><span class="pln" style="box-sizing: inherit;"> </span><span class="kwd" style="box-sizing: inherit; color: #0097a7;">new</span><span class="pln" style="box-sizing: inherit;"> </span><span class="typ" style="box-sizing: inherit; color: #9c27b0;">Google_DateTime</span><span class="pun" style="box-sizing: inherit;">();</span><span class="pln" style="box-sizing: inherit;">
$startDateTime</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setDate</span><span class="pun" style="box-sizing: inherit;">(</span><span class="str" style="box-sizing: inherit; color: #689f38;">'2013-06-12T23:20:50.52Z'</span><span class="pun" style="box-sizing: inherit;">);</span><span class="pln" style="box-sizing: inherit;">
$validTimeInterval</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setStart</span><span class="pun" style="box-sizing: inherit;">(</span><span class="pln" style="box-sizing: inherit;">$startDateTime</span><span class="pun" style="box-sizing: inherit;">);</span><span class="pln" style="box-sizing: inherit;">
$endDateTime </span><span class="pun" style="box-sizing: inherit;">=</span><span class="pln" style="box-sizing: inherit;"> </span><span class="kwd" style="box-sizing: inherit; color: #0097a7;">new</span><span class="pln" style="box-sizing: inherit;"> </span><span class="typ" style="box-sizing: inherit; color: #9c27b0;">Google_DateTime</span><span class="pun" style="box-sizing: inherit;">();</span><span class="pln" style="box-sizing: inherit;">
$endDateTime</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setDate</span><span class="pun" style="box-sizing: inherit;">(</span><span class="str" style="box-sizing: inherit; color: #689f38;">'2013-12-12T23:20:50.52Z'</span><span class="pun" style="box-sizing: inherit;">);</span><span class="pln" style="box-sizing: inherit;">
$validTimeInterval</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setEnd</span><span class="pun" style="box-sizing: inherit;">(</span><span class="pln" style="box-sizing: inherit;">$endDateTime</span><span class="pun" style="box-sizing: inherit;">);</span></pre>
<br />
and then during the Offer creation:<br />
<br />
<pre class="prettyprint" style="background: rgb(247, 247, 247); box-sizing: inherit; color: #455a64; font-family: 'Roboto Mono', monospace; font-size: 14px; font-stretch: normal; line-height: 20px; margin: -7px; overflow-x: auto; padding: 7px;"><span class="pln" style="box-sizing: inherit;">$offerObject</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setValidTimeInterval</span><span class="pun" style="box-sizing: inherit;">(</span><span class="pln" style="box-sizing: inherit;">$validTimeInterval</span><span class="pun" style="box-sizing: inherit;">);</span></pre>
<br />
<br />
Unfortunately there's a little wrinkle there - the Google_TimeInterval and Google_DateTime classes were not included in any of the API libraries I couldn't find, and I couldn't find anything useful about where to get them.<br />
<br />
<br />
<b><u>Solution:</u></b><br />
<br />
What you should be looking for is Google_Service_Walletobjects_TimeInterval and Google_Service_Walletobjects_DateTime so your code will be like this:<br />
<br />
<pre class="prettyprint" style="background: rgb(247, 247, 247); box-sizing: inherit; color: #455a64; font-family: 'Roboto Mono', monospace; font-size: 14px; font-stretch: normal; line-height: 20px; margin: -7px; overflow-x: auto; padding: 7px;"><span class="pln" style="box-sizing: inherit;">$validTimeInterval </span><span class="pun" style="box-sizing: inherit;">=</span><span class="pln" style="box-sizing: inherit;"> </span><span class="kwd" style="box-sizing: inherit; color: #0097a7;">new</span><span class="pln" style="box-sizing: inherit;"> </span><span class="typ" style="box-sizing: inherit; color: #9c27b0;">Google_Service_Walletobjects_TimeInterval</span><span class="pun" style="box-sizing: inherit;">();</span><span class="pln" style="box-sizing: inherit;">
$startDateTime </span><span class="pun" style="box-sizing: inherit;">=</span><span class="pln" style="box-sizing: inherit;"> </span><span class="kwd" style="box-sizing: inherit; color: #0097a7;">new</span><span class="pln" style="box-sizing: inherit;"> </span><span class="typ" style="box-sizing: inherit; color: #9c27b0;">Google_Service_Walletobjects_DateTime</span><span class="pun" style="box-sizing: inherit;">();</span><span class="pln" style="box-sizing: inherit;">
$startDateTime</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setDate</span><span class="pun" style="box-sizing: inherit;">(</span><span class="str" style="box-sizing: inherit; color: #689f38;">'2013-06-12T23:20:50.52Z'</span><span class="pun" style="box-sizing: inherit;">);</span><span class="pln" style="box-sizing: inherit;">
$validTimeInterval</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setStart</span><span class="pun" style="box-sizing: inherit;">(</span><span class="pln" style="box-sizing: inherit;">$startDateTime</span><span class="pun" style="box-sizing: inherit;">);</span><span class="pln" style="box-sizing: inherit;">
$endDateTime </span><span class="pun" style="box-sizing: inherit;">=</span><span class="pln" style="box-sizing: inherit;"> </span><span class="kwd" style="box-sizing: inherit; color: #0097a7;">new</span><span class="pln" style="box-sizing: inherit;"> </span><span class="typ" style="box-sizing: inherit; color: #9c27b0;">Google_Service_Walletobjects_DateTime</span><span class="pun" style="box-sizing: inherit;">();</span><span class="pln" style="box-sizing: inherit;">
$endDateTime</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setDate</span><span class="pun" style="box-sizing: inherit;">(</span><span class="str" style="box-sizing: inherit; color: #689f38;">'2013-12-12T23:20:50.52Z'</span><span class="pun" style="box-sizing: inherit;">);</span><span class="pln" style="box-sizing: inherit;">
$validTimeInterval</span><span class="pun" style="box-sizing: inherit;">-></span><span class="pln" style="box-sizing: inherit;">setEnd</span><span class="pun" style="box-sizing: inherit;">(</span><span class="pln" style="box-sizing: inherit;">$endDateTime</span><span class="pun" style="box-sizing: inherit;">);</span></pre>
GregJxnhttp://www.blogger.com/profile/13753550284186386005noreply@blogger.com160tag:blogger.com,1999:blog-7057248431195415734.post-35577298260862470042014-02-04T04:51:00.002+00:002014-02-04T04:56:49.356+00:00Safari: Setting third party iframe cookiesSafari is known to be strict about permissions in iframes, especially when the domain of the iframe page is different from the domain of the parent page. Some would even say paranoically strict.<br />
<br />
Safari will block you from setting cookies for the third-party domain (the different domain in the iframe), unless you already have cookies set for that domain.<br />
<br />
Here's a snippet of javascript I pulled together last week that as a way to get around the iframe cookie security. It works great if your page is nice and light and loads fast, otherwise it can feel pretty clunky with the triple loading...<br />
<br />
<pre>window.onload=function(){
if(navigator.userAgent.indexOf('Safari')!=-1&&navigator.userAgent.indexOf('Chrome')==-1){
var cookies=document.cookie;</pre>
<pre> if(top.location!=document.location){
if(!cookies){
href=document.location.href;
href=(href.indexOf('?')==-1)?href+'?':href+'&';
top.location.href =href+'reref='+encodeURIComponent(document.referrer);
}
} else {</pre>
<pre> ts=new Date().getTime();document.cookie='ts='+ts;
rerefidx=document.location.href.indexOf('reref=');
if(rerefidx!=-1){
href=decodeURIComponent(document.location.href.substr(rerefidx+6));
window.location.replace(href);
}
}
}
}</pre>
<br />
Here's what it basically does:<br />
<ul>
<li>The javascript is placed in the page loaded inside the iframe. </li>
<li>If the JS is run inside the iframe and the browser is Safari and there are no cookies set, then we frame-burst the page to take over the window and append the original parent page URL as a parameter. </li>
<li>If the JS is run not inside a frame and the browser is Safari, then we set a timestamp cookie (now that we are out of the iframe) and if a reref param exists we redirect back to the original page.</li>
<li>If the JS is run inside the iframe and the browser is Safari and there ARE cookies set, then we do nothing.</li>
</ul>
<br />
And one more time in pseudo-code
<br />
<br />
<pre>if(browser is Safari){
if(we are in an iframe){
if(no cookies){
set window_url = iframe_url + reref=iframe_parent_url;
}
} else {
set a timestamp cookie;
if(reref exists in url){
redirect to original url so we have iframe again
}
}
}
</pre>
GregJxnhttp://www.blogger.com/profile/13753550284186386005noreply@blogger.com393tag:blogger.com,1999:blog-7057248431195415734.post-23073552944485016362014-01-21T01:52:00.001+00:002014-01-21T01:52:36.247+00:00WordPress: Remove/hide Google+ field from Contact Info on user admin pageThis WordPress tweak is pretty unlikely to come up for most developers, but I was asked to remove the Google+ field from the Contact Info section of the User admin page. Here's a quick snippet to paste into functions.php to do so:<br />
<br />
<span style="font-family: monospace;">function custom_admin_js() {</span><br />
<span style="font-family: monospace;"> // hide WP's Googleplus input on user profile</span><br />
<span style="font-family: monospace;"> if( strpos($_SERVER["REQUEST_URI"], '/user-edit.php')) {</span><br />
<span style="font-family: monospace;"> echo '<script type="text/javascript"> jQuery(\'#your-profile input[name="googleplus"]\').parent().parent().hide(); </script>';</span><br />
<span style="font-family: monospace;"> }</span><br />
<span style="font-family: monospace;">}</span><br />
<span style="font-family: monospace;">add_action('admin_footer', 'custom_admin_js');</span>GregJxnhttp://www.blogger.com/profile/13753550284186386005noreply@blogger.com27tag:blogger.com,1999:blog-7057248431195415734.post-46918568694190008782013-07-22T06:46:00.001+01:002013-07-22T06:46:31.247+01:00Checking A File's Upload Size In The BrowserThis really just a quick note so I don't lose the code snippet I just used...
<br />
<br />
I'm working on a form which allows users to upload a file, but we want to stop them uploading giant things. Ultimately the server's maximum upload filesize will stop anything too huge getting through, but it's nice to remind people of the limit before they bother uploading.
<br />
<br />
This is a great little snippet to do that in current versions of Chrome, Firefox and Safari.
<br />
<pre></pre>
<pre>$('#contact_file').bind('change', function() {
filebytes = this.files[0].size;
if(filebytes>1024*1024*5) {
alert("The file you selected is TOO LARGE and will be rejected by the server. Please select a smaller file.");
}
});
</pre>
<br />
If you can't work out what is happening there, then "contact_file" is the id from your file input and 1024*1024*5 is the limit you want to impose, in this case 5MB. Don't forget to check that the server side limit is in line with this.
<br />
<br />
It won't work in IE* or some older browser versions, but it's a nice extra courtesy for users where it can be executed. You could also hook it up to the submit button if you want to do a check at that stage.
<br />
<br />
*Apparently there's an ActiveX thing you can do for IE users, but I am not so inclined.GregJxnhttp://www.blogger.com/profile/13753550284186386005noreply@blogger.com6tag:blogger.com,1999:blog-7057248431195415734.post-35778799362399158142013-07-07T02:20:00.000+01:002013-07-07T02:20:09.789+01:00How To: International Exchange Rates in iOS Stocks AppI like to keep an eye on the exchange rate for the US Dollar against the British Pound Sterling GBP and the Euro, and have been using the Stocks app built into iOS. I don't have any stocks, so I only use the application for tracking exchange rates and it performs well for my needs.<br />
<br />
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-9-_7m83M1vM/UdjB1zbV9CI/AAAAAAAAAFs/zOrgXArSbIw/s1600/photo.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="http://1.bp.blogspot.com/-9-_7m83M1vM/UdjB1zbV9CI/AAAAAAAAAFs/zOrgXArSbIw/s400/photo.PNG" width="400" /></a></div>
<br />
<br />
Over the last few weeks I have shared this functionality with a few friends who also want to keep track of exchange rates and realized that setting these up in the Stocks app is not at all obvious, some would say impossible unless you know the process. Thankfully, once you know the process, it's a piece of cake.</div>
<div>
<br /></div>
<div>
Here are the steps</div>
<div>
<br /></div>
<div>
<ol>
<li>Open the Stocks app</li>
<li>Tap the ( i ) icon in the bottom right hand corner</li>
<li>Tap the + icon in the top left corner</li>
<li>Enter the currency rate described as AAABBB=X in the search box (e.g: GBPUSD=X )</li>
<li>Tap the item in the list</li>
<li>Click the "Done" button in the top right corner</li>
</ol>
</div>
<div>
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-PI4CagQHh54/UdjB2KDGZPI/AAAAAAAAAFw/L9c10ZR_fL0/s1600/photo+(1).PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://4.bp.blogspot.com/-PI4CagQHh54/UdjB2KDGZPI/AAAAAAAAAFw/L9c10ZR_fL0/s400/photo+(1).PNG" width="266" /></a></div>
<br />
<br /></div>
GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com22tag:blogger.com,1999:blog-7057248431195415734.post-52825868384103467082013-07-07T02:12:00.000+01:002013-07-07T02:12:09.352+01:00How To: Import an Excel CSV file with Sequel ProI've been working with a database migration project lately that is bringing together data from three different sources. One of those sources is a big Excel spreadsheet. The data in the spreadsheet has been problematic due as each row included cells with pipe delimited items, typos and other strangenesses that have slowed the pat to a relational database. On top of "ropey data", I also had some problems with importing the data into mySQL.<br />
<br />
Usually I would just Save As a CSV (comma separated values) file, and then import the CSV file using OSX application <a href="http://www.sequelpro.com/">Sequel Pro</a>. This time I was getting fields by split due to some of the fields containing quotes and commas in their text content. I tried to looking for options to use different delimiters, but this is not available Excel (certainly not the version I use), I tried opening the spreadsheet in Google Docs and saving as CSV from there, but this returned the same result. It seemed that Sequel Pro's import engine was not able to interpret the "" encoding of " content and the age-old options of backslashing \" or custom delimiters are no longer available. Upgrading to the latest version of Sequel Pro didn't help either.<br />
<br />
I did a bit of searching and eventually found a <a href="https://code.google.com/p/sequel-pro/issues/detail?id=1252">source</a> that outlined the solution to the problem. Realistically, it's a simple thing I should've thought of myself, but if I missed it and others have too, I thought it was worth documenting here so that others could save time looking for a solution.<br />
<br />
<blockquote class="tr_bq">
<blockquote class="tr_bq">
<span style="font-family: Georgia, Times New Roman, serif;">The problem here is that the CSV you have uses Excel-style quote escaping, where escaped double quotes are represented by "" instead of using backslash escaping - \" . </span></blockquote>
</blockquote>
<blockquote class="tr_bq">
<blockquote class="tr_bq">
<span style="font-family: Georgia, Times New Roman, serif;">When you select the CSV file in the import dialog, you can see there's a "Fields escaped by" setting underneath the file selection dialog. If you change this to a double quote, instead of a backslash, you'll find your file is imported correctly (and your choice will be remembered in future).</span></blockquote>
</blockquote>
<br />
Here's an image of what you need to alter for Excel files to be processed properly:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-vWB0AmoYBv0/Udi-VSVatVI/AAAAAAAAAFc/xGIuYQzO4ag/s1600/CSV_EXCEL_FIX.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="131" src="http://3.bp.blogspot.com/-vWB0AmoYBv0/Udi-VSVatVI/AAAAAAAAAFc/xGIuYQzO4ag/s400/CSV_EXCEL_FIX.png" width="400" /></a></div>
<br />
Don't forget that you've made this change when it comes to importing other CSV files. The last part of the quote above states "and your choice will be remembered in future", so you *may* need to change it back to backslash \ for other files.GregJxnhttp://www.blogger.com/profile/13753550284186386005noreply@blogger.com8tag:blogger.com,1999:blog-7057248431195415734.post-7520047273958954532012-09-05T01:20:00.000+01:002014-03-14T09:12:57.075+00:00GarageBand '11 : Upgrade your instruments for freeI've been writing and playing music for a number of years and lately have been using <a href="http://www.apple.com/ilife/garageband/" target="_blank">Apple's GarageBand</a> to capture my writing ideas. It's certainly not a fully fledged <a href="http://en.wikipedia.org/wiki/Digital_audio_workstation" target="_blank">DAW</a>, but I've found it to be more than adequate for getting an idea fleshed out to a demo quality recording.<br />
<br />
Here are some example tracks to show what I've been producing with GarageBand lately:<br />
<br />
<iframe style="border: 0; width: 100%; height: 120px;" src="https://bandcamp.com/EmbeddedPlayer/track=3134634350/size=large/bgcol=333333/linkcol=e99708/tracklist=false/artwork=small/transparent=true/" seamless><a href="http://music.gregjxn.com/track/ocean-spray">Ocean Spray by Greg Jackson</a></iframe>
<br />
<br />
<iframe seamless="" src="http://bandcamp.com/EmbeddedPlayer/track=4039026862/size=medium/bgcol=333333/linkcol=e99708/transparent=true/" style="border: 0; height: 120px; width: 100%;"><a href="http://music.gregjxn.com/track/the-fairytale">The Fairytale by Greg Jackson</a></iframe>
<br />
<br />
<iframe seamless="" src="http://bandcamp.com/EmbeddedPlayer/track=1301154312/size=medium/bgcol=333333/linkcol=e99708/transparent=true/" style="border: 0; height: 120px; width: 100%;"><a href="http://music.gregjxn.com/track/enchilada-flaps">Enchilada Flaps by Greg Jackson</a></iframe>
<br />
<br />
<iframe seamless="" src="http://bandcamp.com/EmbeddedPlayer/track=1037591981/size=medium/bgcol=333333/linkcol=e99708/transparent=true/" style="border: 0; height: 120px; width: 100%;"><a href="http://music.gregjxn.com/track/recurring-dream">Recurring Dream by Greg Jackson</a></iframe>
<br />
<br />
<iframe seamless="" src="http://bandcamp.com/EmbeddedPlayer/track=374501183/size=medium/bgcol=333333/linkcol=e99708/transparent=true/" style="border: 0; height: 120px; width: 100%;"><a href="http://music.gregjxn.com/track/that-twang-thang">That Twang Thang by Greg Jackson</a></iframe>
<br />
<iframe seamless="" src="http://bandcamp.com/EmbeddedPlayer/album=4022693223/size=medium/bgcol=333333/linkcol=e99708/transparent=true/" style="border: 0; height: 120px; width: 100%;"><a href="http://music.gregjxn.com/album/songs-from-2008">Songs From 2008 by Greg Jackson</a></iframe>
<br />
The more I have used GarageBand, the more I have found its limitations (although these are not unreasonable limits for the application that it is). The main one for me is that the software instruments are a minimal set, some of which are what I would consider novelty sounds (basically unusable) and others are flawed with pitch issues (e.g. Fretless Electric Bass). Coupling this with not being able to MIDI OUT to an external device (of which I have a few), the software instrument set can become a bit frustrating.<br />
<br />
I really don't like the default Electric Piano instrument (sounds too crunchy like a clav to me), I want a sound like a classic Rhodes or a Yamaha DX7, so I decided to find out how to get one without throwing any money at it.<br />
<br />
<br />
<b><span style="font-size: large;">Audio Unit Instruments / Modules</span></b><br />
<br />
The first solutions I found were from <b>4Front Technologies</b>. I downloaded and installed their <a href="http://yohng.com/software/epiano.html" target="_blank">E-Piano</a> (based on Yamaha DX7 e-piano), <a href="http://yohng.com/software/rpiano.html" target="_blank">R-Piano</a> (based on Rhodes Stage Piano) and the <a href="http://yohng.com/software/bass.html" target="_blank">4Front Bass</a> since I was noticing some pitchiness on Fingerstyle Electric Bass (specifically playing A1). I'd recommend grabbing them all and the <a href="http://yohng.com/software/piano.html" target="_blank">Upright Piano</a> so you can install them all in one hit,<br />
<br />
Here's the process to install and use these instruments:<br />
<ul>
<li>Download the instruments you want from 4Front</li>
<li>Unzip the file and copy the .component file to Library/Audio/Plug-Ins/Components</li>
<li>Quit GarageBand if it is running</li>
<li>Open GarageBand and open a project </li>
<li>Create a new Software Instrument track and open the Track Info pane ( ⌘+I )</li>
<li>Click the Edit tab and then the Sound Generator list, your new instrument(s) should appear in the <i>Audio Unit Modules</i> section</li>
<li>Select the instrument you wish to use</li>
<li>Adjust any instrument settings or Effects</li>
</ul>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-Uv0RrrCyaio/UEZx144RkQI/AAAAAAAAAHI/vgFuN2Cit3Q/s1600/GB_AUselect.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-Uv0RrrCyaio/UEZx144RkQI/AAAAAAAAAHI/vgFuN2Cit3Q/s400/GB_AUselect.png" height="400" width="392" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><span style="font-size: small; text-align: left;">Select your new instrument in the "</span><span style="font-size: small; text-align: left;">Audio Unit Modules"</span><span style="font-size: small; text-align: left;"> section</span></td></tr>
</tbody></table>
<div>
<br /></div>
<div>
If you want the instrument to show up on the Browse tab in the correct list, then follow these steps:<br />
<ul>
<li>Select the instrument group on the Browse tab that you want the instrument to be saved into, and the select icon that you want to be used.</li>
<li>Click the Edit tab and select the instrument as the Sound Generator</li>
<li>Adjust any instrument settings or Effects</li>
<li>Click on "<i>Save Instrument...</i>" and enter the name for this instrument</li>
</ul>
</div>
<br />
Obviously the choice of free instruments available is not as broad as those available for purchase, but there are some good ones <a href="https://www.google.com/search?q=free+au+instrument+plugins" target="_blank">out there</a>. There is a good freeware AU list at <a href="http://www.dontcrack.com/freeware/software.php/id/7030/audio/Virtual-Instruments/plugins/AU/platform/mac/" target="_blank">Don't Crack.com</a> and an extensive list at <a href="http://www.kvraudio.com/plugin-ranks.php?show=50&os=1&m=1" target="_blank">KVR Audio</a>, although many are only VST plugins, not AU. Just remember that you get what you pay for, so don't be upset if some don't work well.<br />
<br />
<b>UPDATE:</b> You can also find a good selection of plugins which are available in AU format in "<a href="http://beta.musicradar.com/tuition/tech/the-27-best-free-vst-plug-ins-in-the-world-today-277953/1" target="_blank">The 27 best free VST plug-ins in the world today</a>" (2012) on <a href="http://beta.musicradar.com/" target="_blank">MusicRadar.com</a><br />
<br />
<br />
<b><span style="font-size: large;">Soundfonts (.sf2)</span></b><br />
<br />
Another option for expanding your instrument arsenal is <a href="http://en.wikipedia.org/wiki/Soundfont" target="_blank">Soundfonts</a>. These files have been around since the 1990s, so there is a large variety in both instruments and quality. There are probably a lot more<br />
<br />
There are a few quirks about using these for instrument sounds. GarageBand will use .sf2 files, but not the archive formats .sfark or .sfpack. Both these formats appear to be abandoned now and unpacking the soundfonts on OSX is next to impossible.<br />
<br />
Although some soundfonts are available as "collections", these are a little less easy to use in GarageBand. Unless you can send a MIDI Program Change to the track, you'll be stuck using the first sound/voice in that collection. I tend to use single instrument soundfonts so that I can save them as an instrument once installed.<br />
<br />
Some sources I have used for .sf2 soundfont files are <a href="http://www.hammersound.net/" target="_blank">HammerSound</a>, <a href="http://www.fox-gieg.com/rkhive/" target="_blank">ЯK Hive</a>, <a href="http://www.ntonyx.com/sf_f.htm" target="_blank">NTONYX</a> and <a href="http://johannes.roussel.free.fr/music/soundfonts.htm" target="_blank">www.johannes.fr</a>. Probably the largest soundfont archive is <a href="http://www.sf2midi.com/soundfonts/">sf2midi.com</a>, although it has some drawbacks: you need to register to download, the free downloads are slow (and require too many clicks in my opinion), and the zip files cannot be opened by OSX's Archive Utility (10.6) - luckily they can be unzipped by the free app <a href="http://wakaba.c3.cx/s/apps/unarchiver" target="_blank">The Unarchiver</a>. Nearly all of the .sf2 files I have tried to date have worked well, but some just don't work.<br />
<br />
<br />
Here's the process to install and use a soundfont in GarageBand:<br />
<ul>
<li>Find and download the desired soundfont .sf2 file</li>
<li>Copy the file to Library/Audio/Sounds/Banks</li>
<li>Quit GarageBand if it is running</li>
<li>Open GarageBand and open a project </li>
<li>Create a new Software Instrument track and open the Track Info pane ( ⌘+I )</li>
<li>Click the Edit tab and then the Sound Generator list and select <i>DLSMusicDevice</i> from the <i>Audio Unit Modules</i> section</li>
<li>Double-Click the large button to the left of the DLSMusicDevice to edit the settings</li>
<li>Select your soundfont in the Apple Sound Bank Synthesizer list (QuickTime Music Synthesizer is the default value)</li>
</ul>
<div>
You can save the soundfont instrument so it is listed on the Browse tab by using the same steps outlined above for AU Instruments.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-9iuzpUQXvTI/UEaViatUKTI/AAAAAAAAAHY/aPQgpXNoCyo/s1600/GB_DLS.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-9iuzpUQXvTI/UEaViatUKTI/AAAAAAAAAHY/aPQgpXNoCyo/s400/GB_DLS.png" height="376" width="400" /></a></div>
<br />
<br /></div>
<div>
Pro Tip: If you want to organise your soundfont files into instrument types, or to keep a set of files together, etc. then you can create folders within Library/Audio/Sounds/Banks folder and this will be reflected in the Sound Bank list.<br />
<br />
<b>UPDATE 28-OCT-2012</b>: I just found this post that links to downloads for "<a href="http://www.newgrounds.com/bbs/topic/1200140" target="_blank">3.5 Gigabytes Of HQ Orchestral SF2</a>" at newgrounds.com. I haven't tried them all yet, but those that I have tried are sounding pretty good. I also discovered <a href="http://www.freesf2.com/" target="_blank">freesf2.com</a> which also has some great free SF2 files (although you'll need sfArk).</div>
<div>
<br />
<b>UPDATE 25-FEB-2014:</b> Blogger's stats tell me that this post is getting quite a bit of traffic and that a chunk of that is coming from <a href="http://thegaragebandguide.com/resources" target="_blank">thegaragebandguide.com</a> :)</div>GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com13tag:blogger.com,1999:blog-7057248431195415734.post-26783578933618366612012-08-14T12:57:00.001+01:002012-08-14T12:59:03.278+01:00How To: Connect Your PS3 To Mac Internet Sharing WiFiRecently I moved to a new house and had to make changes to the way I set up my network to <a href="http://measurablewins.blogspot.co.uk/2012/08/dealing-with-wifi-dead-zones.html">extend WiFi coverage</a>. Part of the solution I employed was to enable Internet Sharing of the ethernet connection on my Mac Mini so other devices could use it as a WiFi connection point.<br />
<br />
My Mac Mini is still running OS X 10.6.8 so I had to solve the problems of <a href="http://measurablewins.blogspot.co.uk/2012/08/internet-sharing-wifi-with-wep.html">connecting non-Apple devices to a Mac using WEP</a>. Even when I had other devices connecting, I couldn't get my Playstation 3 to connect. Thankfully the PS3 connection test gives some specific indicators of what is failing, so I could see that the problem was related to getting an IP Address assigned.<br />
<br />
When you enable Internet Sharing on your Mac a file is created at <b>/etc/bootpd.plist</b> which should contain something like this:<br />
<pre><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Subnets</key>
<array>
<dict>
<key>_creator</key>
<string>com.apple.nat</string>
<key>allocate</key>
<true/>
<key>dhcp_domain_name_server</key>
<string>192.168.2.1</string>
<key>dhcp_router</key>
<string>192.168.2.1</string>
<key>lease_max</key>
<integer>86400</integer>
<key>lease_min</key>
<integer>86400</integer>
<key>name</key>
<string>192.168.2</string>
<key>net_address</key>
<string>192.168.2.0</string>
<key>net_mask</key>
<string>255.255.255.0</string>
<key>net_range</key>
<array>
<string>192.168.2.2</string>
<string>192.168.2.254</string>
</array>
</dict>
</array>
<key>bootp_enabled</key>
<false/>
<key>detect_other_dhcp_server</key>
<integer>1</integer>
<key>dhcp_enabled</key>
<array>
<string>en0</string>
</array>
<key>reply_threshold_seconds</key>
<integer>4</integer>
</dict>
</plist>
</pre>
<br />
To get your Playstation3 to connect (or other device that is timing out while waiting for an IP Address), you need to change the integer value for the key <b>reply_threshold_seconds</b> from 4 to 0 (zero). <i>Note: You will need an Administrator password to complete this process.</i><br />
<br />
Here are the steps you'll need to follow to get this to work:<br />
<br />
<ul>
<li>Turn on Internet Sharing so that the file mentioned above is created.</li>
<li>Open the Terminal application (usually found in Applications > Utilities)</li>
<li>Type this command and then press return to copy the file into the tmp directory:<br /><code>cp /etc/bootpd.plist /tmp/bootpd.plist</code></li>
<li>Turn off Internet Sharing. This will delete /etc/bootpd.plist</li>
<li>To open the copied file in TextEdit, type this command in the Terminal window and press return:<br /><code>open -e /tmp/bootpd.plist</code></li>
<li>Find this section near the end of the file<br /><code><key>reply_threshold_seconds</key><br /><integer>4</integer></code></li>
<li>Change 4 to 0 (zero).</li>
<li>Save and Close the file and Quit TextEdit.</li>
<li>To copy the file back to the original location, type this command in the Terminal window and press return:<br /><code>sudo cp /tmp/bootpd.plist /etc</code></li>
<li>You will be prompted to enter a Password. Enter your Administrator password and press return.</li>
<li>Turn on Internet Sharing.</li>
<li>Try and connect with your PS3 (or other device).</li>
</ul>
<div>
<br /></div>
<div>
You can also find details on how to fix this issue at <a href="https://discussions.apple.com/thread/2244318?start=0&tstart=0" target="_blank">Apple Support Communities</a> and <a href="http://community.eu.playstation.com/t5/PlayStation-3-Technical/Internet-Sharing-Mac-OSX-amp-PS3/td-p/10935510" target="_blank">PlayStation®3 Technical Solutions</a>.</div>
<div>
<br /></div>
<div>
</div>GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com121tag:blogger.com,1999:blog-7057248431195415734.post-21611783336731222032012-08-12T16:27:00.001+01:002012-08-14T13:18:21.480+01:00Internet Sharing WiFi with WEP encryption from OSX to non-Apple devicesI almost entitled this post as "How To Use Your Mac As A WiFi Hot-Spot", but hopefully the title I used will help more people find the article and get the simple answer on how to connect to Airport via Internet Sharing when using WEP as security.<br />
<br />
There are a lot of simple articles about how to use your Mac as a WiFi Hot-Spot by sharing your Ethernet connection. If you don't know how to do that yet, then I recommend reading "<a href="http://www.macinstruct.com/node/118" target="_blank"><b>How to Use Your Mac as a Wireless Router</b></a>" which covers the general setup process nicely, although it does not address the problems you can face when using WEP and trying to connect from non-Apple devices (e.g Android phone/tablet, Windows PC, PS3, Wii, etc.)<br />
<br />
The Mac Mini that I was using to share WiFi was running OS X 10.6.8, so the setup screens are slightly different from those in the article above. Here's a screenshot if you want to compare:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-phMvv8P_Jho/UCey_SF79sI/AAAAAAAAAGc/wS7xQWkQlXM/s1600/WEP_setup_OSX10.6.8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img alt="" border="0" src="http://2.bp.blogspot.com/-phMvv8P_Jho/UCey_SF79sI/AAAAAAAAAGc/wS7xQWkQlXM/s1600/WEP_setup_OSX10.6.8.png" title="OSX 10.6.8 Internet Sharing WEP setup" /></a></div>
<br />
<br />
Mac OS X 10.6.8 only supports WEP security on Internet Sharing so you either have to use WEP or no security. Nobody wants uninvited users on their network, so using WEP is recommended. Unfortunately using WEP is what usually causes non-Apple devices to fail to connect to the network.<br />
<br />
There is a "trick" to get it to work that I will clearly outline for you here, so you don't have to cobble together the solution from a half-dozen sources that all point in the direction but never actually have all the required steps (as I had to do).<br />
<br />
This is the process that worked for me:<br />
<br />
<ul>
<li>Set a Network Name that does not include spaces or special characters, you may need to reduce the name length (my actual Network Name is 9 characters long)</li>
<li>Leave the Channel as automatic unless you need to use something specific</li>
<li>Check the box for "Enable encryption (using WEP)"</li>
<li>Set the WEP Key Length to "40-bit (more compatible)"</li>
</ul>
<div>
<br /></div>
<div>
Now comes the arcane step that will allow your non-Apple devices to connect</div>
<div>
<ul>
<li>You must use a Password containing five <a href="http://en.wikipedia.org/wiki/Hexadecimal" target="_blank">HEXADECIMAL</a> values prefixed with a dollar sign ($). The $ prefix tells your Mac you are entering a hexadecimal value. You do not need to use the $ prefix when connecting to the your Mac</li>
<li>Hexadecimal values contain of a pair of characters which are limited to 0-9 and A-F, so you need to enter a password which starts with $ and then has ten characters which must be numbers or the letters A, B, C, D, E or F. (examples $A1B2C3D4E5, $1234567890, $2FACEDBABE )</li>
<li>As soon as you enter the $ in the Password field, the WEP Key Length and the OK button will be disabled. When you have entered the same value in Confirm Password (including the $ prefix) then the OK button will be enabled for you to click.</li>
<li>If you want to use 128-bit encryption, you must enter 13 hexadecimal values, which equates to 26 characters plus the $ prefix. As soon as you type a password longer than described for 40-bit, then the disabled WEP Key Length field will change to 128-bit. (Note: I have not tested that 128-bit actually works)</li>
<li>Click OK and then check the Internet Sharing box, and then click Start.</li>
</ul>
</div>
<br />
You should now be able to connect your non-Apple device (and your Apple devices) to your HotSpot using the new password. Remember, you do not need to use the $ prefix when connecting to your Mac.<br />
<br />
If you are still unable to connect to your Mac, it may be because your device is failing to receive an IP Address. This is a common problem with Playstation3 consoles, and there is a fix for that which I will detail in my next post <a href="http://measurablewins.blogspot.co.uk/2012/08/how-to-connect-your-ps3-to-mac-internet.html">How To: Connect Your PS3 To Mac Internet Sharing WiFi</a>.<br />
<br />
<br />
Note: This is a follow-up post to <a href="http://measurablewins.blogspot.co.uk/2012/08/dealing-with-wifi-dead-zones.html">Dealing With WiFi Dead Zones</a>.<br />
<br />
<br />GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com5tag:blogger.com,1999:blog-7057248431195415734.post-58742451670772483452012-08-10T19:51:00.000+01:002012-08-14T12:59:52.517+01:00Dealing With WiFi Dead ZonesThis month we moved to a new home. Some things about the new place are better, other things are worse, and some things are just different. One of the "different" things is the property layout, it's much longer and narrower. This does cause a problem because the router is located at one end of the property, conveniently near my desk, but too far away from the living room for any usable WiFi.<br />
<br />
I didn't want to install long ethernet cables here, so my first response was to look into signal boosting. I even tried the <a href="http://www.freeantennas.com/projects/template2/">Windsurfer foil parabola reflector</a> which didn't really work for me. Another inexpensive option I considered was to relocate the router to a more central position by using a <a href="http://www.amazon.co.uk/gp/product/B0031WW1B0/" target="_blank">long modem cable</a>. This approach didn't really work due to our property layout and the position of power outlets.<br />
<br />
In the end I stumbled across a completely different approach which was <a href="http://www.ebuyer.com/263575-tp-link-200mbps-powerline-adapter-twin-pack-tl-pa211kit" target="_blank">fairly inexpensive</a> and has provided WiFi signal across the whole house, although with two hotspots.<br />
<br />
<blockquote class="tr_bq">
"TP-LINK's TL-PA211 powerline adapter takes advantage of your home's existing electrical wires to transfer data while simultaneously transferring traditional power. That means, with no additional wiring required, users can simply plug the TL-PA211 into existing power sockets and instantly establish a networking infrastructure."
</blockquote>
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="allowfullscreen" frameborder="0" height="270" src="http://www.youtube.com/embed/0ptFVDxzd2g" width="480"></iframe></div>
<br />
I'd never used <a href="http://www.ebuyer.com/263575-tp-link-200mbps-powerline-adapter-twin-pack-tl-pa211kit" target="_blank">powerline adaptors</a> for extending my network before, but I took a punt on these which has worked out to be a good solution for my set up. I plugged one powerline adaptor in next to the router and connected the ethernet cable, and then plugged the other adaptor at the other end of the house and connected it to my Mac Mini which is currently connected to the TV.<br />
<br />
I then enabled Internet Sharing on the Mac Mini running 10.6.8, so that it acts as a WiFi hotspot. This worked great for connecting with an iPad and iPod Touch, but needed some special tweaks to connect non-Apple devices including an Android phone, Dell laptop, Wii and Playstation3. I'll detail the tricks for connecting those devices in my next posts.<br />
<br />GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0tag:blogger.com,1999:blog-7057248431195415734.post-29187920523312341242012-06-25T17:41:00.001+01:002012-08-14T13:02:06.110+01:00Playing/Converting AVHDC .MTS files on OSXLately I've been using <a href="http://en.wikipedia.org/wiki/AVCHD">AVHDC</a> (Advanced Video Coding High Definition) .MTS video files on OSX a bit. This video format is not greatly supported on OSX at this point in time. This HD format was developed by SONY and Panasonic and is considered to by a high quality format. My video files are coming from a Panasonic Lumix DMC-TZ10.<br />
<br />
<b>Playback</b><br />
OSX does not currently natively support playback of these files. I recommend installing <a href="http://www.videolan.org/vlc/index.html">VLC</a> <a href="http://www.videolan.org/vlc/index.html">http://www.videolan.org/vlc/index.html</a> which is both free and has a large enthusiastic usage community.<br />
<br />
<b>Conversion </b><br />
If you want to use these files in iMovie then you have to import them directly from the camera. This can be both slow and reduce the video quality.
If you are not wanting to use iMovie and just want to convert to MPEG-2, DivX, H.264, etc. then you will probably have noticed most search results end up pointing to an expensive piece of conversion software with a heavily crippled trial version.<br />
<br />
VLC (see above) does include conversion/export functionality, but its results are a bit unpredictable and is best suited to stream capture.<br />
<br />
The best option I have discovered which is fast, reliable and free is <a href="http://handbrake.fr/">Handbrake</a> <a href="http://handbrake.fr/">http://handbrake.fr/</a> This application is commonly used by some to rip DVD content to a playable file, but it has a great video transcoder at it's core and really does a great job converting .MTS files on OSX for free :)<br />
<br />GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com2tag:blogger.com,1999:blog-7057248431195415734.post-14730441058525577052012-05-23T15:19:00.001+01:002012-05-23T15:19:35.296+01:00Introducing TheToolbox.ccI was recently introduced to <a href="http://thetoolbox.cc/">TheToolbox.cc</a> which is a handy site for web developers. <a href="http://thetoolbox.cc/">TheToolbox</a> is a collection of best-of-breed tools and helpers for a wide range of jobs: Animation, Bookmarklets, Colors, CSS, Editors, Grids, Icons, Images, Javascript, Lorem Ipsum, Markup, Patterns, Photoshop, Reference, Regular Expressions, Responsive Design, Sprites, Starter Kits, Time & Date, Typography, Unicode, and Web Performance. Definitely worth checking out and bookmarking if you have to deal with those sort of things on a semi-regular basis.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://thetoolbox.cc/"><img border="0" height="640" src="http://4.bp.blogspot.com/-l7HtD5soWHY/T7zwp2AG4HI/AAAAAAAAAGM/7CA6tpYw92w/s640/toolbox.png" width="603" /></a></div>
<br />GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0tag:blogger.com,1999:blog-7057248431195415734.post-12043492627268180742011-09-08T12:30:00.000+01:002011-09-08T12:30:28.419+01:00Syntax Highlighter Chrome Extension: SightLast week a colleague introduced me to a handy Chrome Extension called <a href="https://chrome.google.com/webstore/detail/epmaefhielclhlnmjofcdapbeepkmggh">Sight</a> that allows syntax highlighting in your browser and "makes reading code on the browser a joy".<br />
<br />
After using it for few days I have to admit that it does make javascript a lot easier on the eye. It has optional line numbers and supports syntax for about 35 different languages.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://chrome.google.com/webstore/detail/epmaefhielclhlnmjofcdapbeepkmggh">
<img border="0" src="http://1.bp.blogspot.com/enUIn3JF52_EXL8SAaQRLiidWkoyV7k75BdaoRIK2SYCXHYrlvID3K0HBoAFGwgBHeU1yMRNXg=s400-h275-e365" /></a>
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Sadly it doesn't support view-source highlighting, but apparently it's next on the to-do list and is still worth installing in it's current state.<br />
<br />
If you're using Chrome you can get the extension from here <a href="https://chrome.google.com/webstore/detail/epmaefhielclhlnmjofcdapbeepkmggh">https://chrome.google.com/webstore/detail/epmaefhielclhlnmjofcdapbeepkmggh</a>GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com1tag:blogger.com,1999:blog-7057248431195415734.post-47644050083089524362011-06-03T11:12:00.012+01:002011-06-03T12:34:12.692+01:00WordPress Form Helper FunctionsSetting the state of checkboxes, radio buttons and selected items in dropdown lists in html forms can become tiresome, so I was pleased to recently discover WordPress has some built-in helper functions. I've found these to be pretty handy in building admin forms for Wordpress plugins and hopefully they can save you some time too.<br /><br /><code>checked( $checked, $current = true, $echo = true )</code><br /><br />This function compares two given values (for example, a saved option vs. one chosen in a form) and, if the values are the same, adds the checked attribute to the current radio button or checkbox. This is essentially the same as comparing values with if(), but results in more concise code. The third parameter determines if the result is echoed or just returned which is handy if you are concatenating to a string, etc.<br /><br />This function has been defined since WordPress v1.0 and is documented <a href="http://codex.wordpress.org/Function_Reference/checked">here</a>.<br /><br /><br /><code>selected( $selected, $current = true, $echo = true )</code><br /><br />This function is for use in dropdown form fields. Compares two given values (for example, a saved option vs. one chosen in a form) and, if the values are the same, adds the selected attribute to the current option tag. Again, the third parameter determines if the result is echoed or just returned which is handy if you are concatenating to a string, etc.<br /><br />This function has been defined since WordPress v1.0 and is documented <a href="http://codex.wordpress.org/Function_Reference/selected">here</a>.<br /><br /><br /><code>disabled( $disabled, $current = true, $echo = true )</code><br /><br />This function compares two given values (for example, a saved option vs. one chosen in a form) and, if the values are the same, adds the disabled attribute to a form input field. Again, the third parameter determines if the result is echoed or just returned which is handy if you are concatenating to a string, etc.<br /><br />This function was not defined until WordPress v3.0 and is documented <a href="http://codex.wordpress.org/Function_Reference/disabled">here</a>.<br /><br />These functions are all located in <code>wp-includes/general-template.php</code>.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com2tag:blogger.com,1999:blog-7057248431195415734.post-35000496017897275212011-04-26T14:07:00.013+01:002012-08-14T13:00:17.109+01:00Using Recycle Files (REX) With Logic ExpressThis week I made the leap from using Cubase 5 on Win32 to Logic Express on OS X. I don't get as much recording done lately as I would like, so thought I would try Logic Express first before committing to the more expensive Logic Pro.<br /><br />One of the problems I found was that Logic Express was not recognising my REX files and prompting me to install a REX Shared Library from Propellerheads.se. Searching the Propellerheads site didn't seem to turn up the results until I eventually I spotted this link hidden away in the last column of the footer of the <a href="http://www.propellerheads.se/download/">Downloads</a> page.<br /><br /><a href="http://www.propellerheads.se/download/index.cfm?fuseaction=get_article&article=rexsharedlibrary">http://www.propellerheads.se/download/index.cfm?fuseaction=get_article&article=rexsharedlibrary</a><br /><br />There are a few versions there so I downloaded this one as it matched my setup<br /><br /><span style="font-weight:bold;">REX Shared Library 1.7 - Universal Binary</span><br />For owners of Logic 9.1.2 and later<br /><a href="http://www.propellerheads.se/download/files/Install_Rex_1_7_library.pkg">http://www.propellerheads.se/download/files/Install_Rex_1_7_library.pkg</a><br /><br />The install all appeared to work properly but Logic Express was still reporting the same error.<br />I tried restarting Logic Express, but the error persisted.<br />I tried restarting my machine, but the error persisted.<br />I tried reinstalling and carefully read every screen - nothing was wrong there.<br /><br />I started searching various forums and found there were confusing opinions about the probable cause, most of them quite out of date and that there were multiple possible install paths.<br /><br />After much reading I found that the files had been installed to <span style="font-style:italic;">/Library/Application Support/Propellerhead Software/REX</span> but the red icon on the folder in Finder told me that I did not have permission to access that folder. It seems that the installer has an issue setting permissions.<br /><br />I opened a Terminal window, navigated to that folder and entered this command: <span style="font-style:italic;">sudo chmod REX 777</span> to set the permissions wide open.<br /><br />After that Logic Express was able to process REX files properly.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com1tag:blogger.com,1999:blog-7057248431195415734.post-58845548720738182932011-03-31T14:21:00.000+01:002011-04-01T14:40:35.633+01:00WordPress Post ID from PermalinkLately I've been migrating a few websites from Movable Type to WordPress. One of the SEO issues involved with that is supporting the old site's URLs so that existing page rankings don't drop off en masse.<br /><br />A common Movable Type URL format appends the entry id to the URL which makes it easy to redirect to the correct content IF you have preserved the entry id from MT as the new post id in WP, other times it can be a lot more convoluted. <br /><br />One of the functions I sometimes need to employ is pretty uncommon, (which is not surprising due it's rare use), so I thought I'd create a quick post here so I can can easily find it next time I need it.<br /><br />The function is <span style="font-weight:bold;"><a href="http://codex.wordpress.org/Function_Reference/url_to_postid">url_to_postid()</a></span><br /><br />This function returns the id for a post or page from a given URL. I like to this of this function as the reverse of the commonly used <a href="http://codex.wordpress.org/Function_Reference/get_permalink">get_permalink()</a>.<br /><br />It's pretty hard to turn up any useful search results for this function so hopefully this page will help somebody when they need it.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0tag:blogger.com,1999:blog-7057248431195415734.post-68043997969480698172010-09-24T13:15:00.013+01:002010-09-24T15:08:34.066+01:00Pro Tip: Check It YourselfYesterday I was pushing a module of new code to the blog site of a moderately famous celebrity that is still creaking along on Movable Type (the site, not the celeb). I've not really had to work with Movable Type much before so it was a little bit interesting and I learnt a few bits and pieces. <br /><br />The code module was working exactly as expected on the development site so I was a bit surprised when it failed on the production site, truncating the rendering of some posts.<br /><br />Debugging code on a production server is a tricky business (especially when you can't find the error logs), but I tracked it down to this:<br /><br /><code>PHP Fatal error: Call to undefined function: file_put_contents() ...</code><br /><br />The function <span style="font-weight:bold;">file_put_contents()</span> was introduced with PHP version 5, so this error indicated the production server was running some version of PHP4. This kind of disparity between production and development environments is certainly not the optimal configuration, but it's not entirely uncommon when working with legacy systems. The problem for me yesterday was that it took me a lot longer to identify and fix the problem because I was <span style="font-style:italic;">sure</span> that the production site was on PHP5...<br /><br />I'd asked the rest of the development team if the sites I was working on with this module were on PHP5, they were pretty sure they were, but recommended I checked with the ops team. A member of the ops team told me they were all on PHP5 too. I don't know if the error was due to a chat-window miscommunication, lack of familiarity with the site, or just a genuine mistake - it's not really a big deal. In reality, it probably would have been quicker to just check the <span style="font-weight:bold;">phpversion()</span> myself when I first thought to ask about it - I would have discovered it was on PHP4 and altered the module's code <span style="font-style:italic;">before</span> I tried to push it to the production environment.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0tag:blogger.com,1999:blog-7057248431195415734.post-81305263746986054092010-09-01T15:32:00.008+01:002010-09-01T16:16:19.561+01:00IE8 Ajax Caching/Session IssueToday I spent a bit of time trying to track down an ajax problem the was only occuring in IE8.<br /><br />The ajax funcionality was calling a static URL which returned a JSON result containing the html to display login buttons depending on the user's state. The call was made via jQuery.getJSON(), which is wrapper function for .ajax() and .parseJSON()<br /><br />The problem was that IE8 was exhibiting fairly unpredictable behaviour, sometimes it seemed that call was not firing, other times it appeared to return the opposite result I was expecting.<br /><br />Initially it looked like IE8 was not passing the user's session. A quick Google search returned a number of threads where developers had assumed this to be the case, but there were very few constructive suggestions in addressing the issue. Eventually I spotted <a href="http://codeigniter.com/forums/viewthread/124446/#616356">something</a> where the true issue had been identified as IE8 caching the ajax response.<br /><br />I added a cache-busting parameter to my ajax URL using the following javascript and <span style="font-style:italic;">voila</span>, everything starting working as expected.<br /><br /><code>"...&cachebuster="+Math.random()</code><br /><br />Hopefully this short post will save you some IE8 related head-scratching.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com2tag:blogger.com,1999:blog-7057248431195415734.post-23834160280291592152010-08-18T13:14:00.017+01:002010-08-30T20:30:52.993+01:00Wordpress colorpicker.jsThe Wordpress <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress">wp_enqueue_script</a> reference page lists Colorpicker as one of the default scripts imstalled, but doesn't offer any clues on how to implement it. The link on that page (currently) points to <a href="http://mattkruse.com/">http://mattkruse.com/</a> which has no details on how to use it either.<br /><br />The best online reference I've found so far is Matt Kruse's <a href="http://mattkruse.com/javascript/colorpicker/">JavaScript Toolbox - Color Picker Swatch Popup</a> which suggests you look at <a href="http://www.javascripttoolbox.com/">http://www.javascripttoolbox.com/</a> which doesn't have any documentation about colorpicker.js. Here's a link to the cached version of the documentation page just in case the source page is taken down: <a href="http://webcache.googleusercontent.com/search?q=cache:nlxkcPxsepEJ:mattkruse.com/javascript/colorpicker/">http://webcache.googleusercontent.com/search?q=cache:nlxkcPxsepEJ:mattkruse.com/javascript/colorpicker/</a><br /><br />The javascript file /wp-includes/js/colorpicker.js is minified and browsing it doesn't easily reveal anything. There's a lot more information in /wp-includes/js/colorpicker.dev.js but it's not as straightforward as it could be.<br /><br /><span style="font-weight:bold;">What you need to do:</span><br /><br />Include the colorpicker javascript file:<br /><code>wp_enqueue_script( 'colorpicker');</code><br /><br />Create a colorpicker object and hidden div, preferably put this near the end of your page:<br /><code><SCRIPT LANGUAGE="JavaScript"><br />var cp = new ColorPicker(); cp.writeDiv();<br /></SCRIPT></code><br /><br />Set up the input field and picker anchor tag:<br /><code>Color: <INPUT TYPE="text" id="color2" name="color2" SIZE="20" VALUE=""> <A HREF="#" onClick="jQuery('#color2').each(function(index){cp.select(this,'pick2');return false;});return false;" NAME="pick2" ID="pick2">Pick color</A></code><br /><br />Alternatively, you could also try this approach where you ditch the anchor tag and use some jQuery to handle the rest:<br /><code><br /><INPUT TYPE="text" id="color2" name="color2" SIZE="20" VALUE="" class="jColorpicker" ><br /><br /><SCRIPT LANGUAGE="JavaScript"><br />jQuery(".jColorpicker").bind("click", function(){cp.select(this,jQuery(this).attr(\'name\')); });<br /></SCRIPT><br /></code><br /><br /><span style="font-weight:bold;">Conclusion</span><br />This snippet of code is showing it's age and there are better options out there if you need a color picker. The more I try to use it the more I become frustrated with it. <br /><br />jQuery UI doesn't have a native one (yet) but I am guessing that will come in time. For now, probably the best candidate is the jQuery plugin <a href="http://www.digitalmagicpro.com/jPicker/">jPicker</a> from Digital Magic Productions.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0tag:blogger.com,1999:blog-7057248431195415734.post-19468959221308155132010-07-14T20:52:00.012+01:002010-07-14T21:29:23.994+01:00Firefox 3.6.6 redirect issueToday I spent a chunk of time investigating an issue related to redirecting browser requests for media files to the CDN (content delivery network) for that domain. The redirect was being thrown into a redirection loop. The curious thing about the issue is that it only affected users using Firefox 3.6.6 on Microsoft Windows.<br /><br />I tested the MP3 player in Opera, Chrome and even Internet Explorer and everything performed as expected, but when I used Firefox 3.6.6 it failed every time for any file. Then I checked it in Firefox 2.0 and Firefox 3.5.10 - both did not reproduce the issue. I checked it in Firefox 3.6.6 on an Apple Mac and the issue could not be reproduced. Neither could it be reproduced in Firefox 3.6.7(beta) on Windows.<br /><br /><span style="font-weight:bold;">Multiple Firefox Installations</span><br />I decided to grab Firefox 3.6.4 (the previous release - there was no 3.6.5) and install that to see if just this version was experiencing the issue. To do this I decided to set up another Firefox install - If you've not done this before, there's a great guide here: <a href="http://idizyn.com/development/installing-multiple-versions-of-firefox/">http://idizyn.com/development/installing-multiple-versions-of-firefox/</a> The post is pretty old, but what worked for Firefox 1.5 and 2.0 still works now.<br /><br />Installing Firefox 3.6.4 confirmed my suspicion that this problem only occurred so predictably in Firefox 3.6.6.<br /><br /><span style="font-weight:bold;">What Caused This??</span><br />I recorded the headers for different browser versions using <a href="http://livehttpheaders.mozdev.org/">Live HTTP Headers</a>. This highlighted that Firefox 3.6.6 was being thrown into redirection loop, but didn't explain why. I added timestamps to the redirection point and saw that the redirection was not reflecting any change in that, so some level of caching was involved - but this cached result did not occur for any other browser version (even on the same machine).<br /><br />I disabled my Add-ons, flushed my cache, and restarted the browser multiple times to no avail - I could not isolate either a cause or a solution. At this point I can only suggest there is a problem with this release of Firefox causing the problem.<br /><br />Firefox 3.6.7 is currently slated for release on 20 July 2010 (in 6 days). Hopefully this will address this issue and many users will quickly upgrade without us having to suggest it as a solution to this issue.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0tag:blogger.com,1999:blog-7057248431195415734.post-66823537838657532342010-06-18T17:38:00.014+01:002010-06-18T18:04:05.423+01:00WordPress Broken Theme : Template is missingI came across an interesting bug on a Wordpress development project I was working on this week. The issue was that the Wordpress Theme was reported as a Broken Theme because the "Template is missing" on the Appearances->Themes admin page.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_3mv2BsZUuXk/TBuh8LZkfcI/AAAAAAAAAEY/VYVQh_ZAkc0/s1600/BrokenTheme.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 276px;" src="http://2.bp.blogspot.com/_3mv2BsZUuXk/TBuh8LZkfcI/AAAAAAAAAEY/VYVQh_ZAkc0/s400/BrokenTheme.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5484155026477972930" /></a><br /><br />In most cases the site was performing as expected using the allegedly broken theme, however the custom template selection was no longer available on the Pages admin page. (This is where I first spotted there was a problem and then discovered the Appearances->Themes admin page.)<br /><br />After poking about for a bit, I traced the problem to a rather innocuous looking line the designer had added to the theme's style.css file.<br /><br /><code>/* UNIQUE CATEGORY TEMPLATE: VIDEO*/</code><br /><br />It's just the "TEMPLATE:" portion that caused the style.css parser to fail. This line works just fine:<br /><br /><code>/* UNIQUE CATEGORY TEMPLATE : VIDEO*/</code><br /><br />I doubt this error comes up often, but it took a few minutes to track down the problem so I thought I'd post something here to hopefully save somebody time in the future.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com22tag:blogger.com,1999:blog-7057248431195415734.post-20456130351580744862010-04-22T23:00:00.016+01:002010-04-22T23:36:41.432+01:00Google Buzz Button IE8 ErrorRecently Google introduced their <a href="http://www.google.com/buzz/stuff">Buzz buttons</a> to "<span style="font-style:italic;">Help people post your content on Google Buzz</span>". Share buttons are not a new idea, but Google Buzz is new and kinda shiny. Here's a quick intro if you're not up to speed yet:<br /><br /><object width="480" height="340"><param name="movie" value="http://www.youtube.com/v/yi50KlsCBio&hl=en_GB&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/yi50KlsCBio&hl=en_GB&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="340"></embed></object><br /><br />And here's a Buzz button: <a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="small-count" data-locale="en_GB" data-url="http://measurablewins.blogspot.com/2010/04/google-buzz-button-ie8-error.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script><br /><br />A few days ago I implemented the Buzz share buttons on a website at the clients request and it all seemed to be working great, until this morning I found that some pages were failing to load in Internet Explorer 8.<br /><br />I pointed IE8 at the development site and confirmed there was a serious problem. The error I recieved was thus:<br /><br /><code>Webpage error details <br />User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30) <br />Timestamp: Thu, 22 Apr 2010 13:33:25 UTC <br />Message: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) Line: 0 Char: 0 Code: 0</code><br /><br />I disabled the Buzz button to confirm it was part of the problem (which it was), and then checked my implementation against the documntation and other sites. Everything seemed to be OK. After a long period of debugging, and following up false leads it turned out to be that Internet Explorer was executing the Google Buzz button's javascript code too early - even when it was in the page footer.<br /><br />The Solution:<br />Once again jQuery came to the rescue - I replaced this line:<br /><code><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></code><br /><br />with this line:<br /><code><script type="text/javascript">jQuery(document).ready(function(){jQuery.getScript('http://www.google.com/buzz/api/button.js');});</script></code>GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com3tag:blogger.com,1999:blog-7057248431195415734.post-82253695203028866992010-04-05T13:24:00.014+01:002010-04-05T13:49:21.642+01:00Managing WordPress FiltersWordPress filters offer a great way to control many aspects of the way the WordPress engine processes or publishes information, without hacking any of the core code.<br /><br />In recent projects I've found filters to be the easiest way to manage many of the functionality requests the client has made. Some examples of the are: RSS formatting, custom Avatars, auto rendering images/links in comments, controlling the Category used in permalinks, reformatting legacy data in posts, and even <a href="http://measurablewins.blogspot.com/2010/03/suppressing-link-url-in-wp-media.html">tweaking the behaviour of Admin pages</a>.<br /><br />All these changes can add up to quite a chunk of code and functions.php was getting quite large and difficult to maintain with all the other general functions in there. I decided to move all the filter functions and add_filter statements into a separate file called functions_filters.php and include it from functions.php. This made it much easier to add/maintain filters and localised the changes to that dedicated file. <br /><br />It's an incredibly simple idea, but I highly recommend taking this approach if you are implementing filters to any degree.<br /><br />If you've not used filters but want to learn more, you can find a good introduction here: <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference">http://codex.wordpress.org/Plugin_API/Filter_Reference</a>GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0tag:blogger.com,1999:blog-7057248431195415734.post-31646598361113558862010-03-16T14:21:00.014+00:002016-01-29T02:27:21.381+00:00Suppressing Link URL In WP Media LibraryUPDATE: You can now set the default action by adding the following code to your functions.php file.<br />
<code><br />
update_option('image_default_link_type','none');
<br />
</code>
<br />
<br />
<hr />
<br />
<br />
It's been a while since I've posted anything here (I've been pretty busy lately), so when I threw together a quick fix for a WordPress installation today, I thought I should put a quick note about it here.<br />
<br />
<span style="font-weight: bold;">The Problem:</span><br />
When inserting or attaching an image to a post with WP's Media Library the Link URL is always pre-populated with the URL to the file. To remove this URL so that the image is not linking to the original file, users must go through the arduous process of remembering to click the "None" button before inserting the image.<br />
<br />
<a href="http://4.bp.blogspot.com/_3mv2BsZUuXk/S5-WKvtE3EI/AAAAAAAAAEQ/MdQHKuBBulY/s1600-h/Suppress_URL.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5449239185489976386" src="http://4.bp.blogspot.com/_3mv2BsZUuXk/S5-WKvtE3EI/AAAAAAAAAEQ/MdQHKuBBulY/s400/Suppress_URL.png" style="cursor: hand; cursor: pointer; display: block; height: 384px; margin: 0px auto 10px; text-align: center; width: 400px;" /></a><br />
<br />
OK, that was a little sarcastic, but that's pretty much what the feature request was saying. They wanted the field's behaviour to change so that the default was blank.<br />
<br />
<span style="font-weight: bold;">The Solution:</span><br />
To create the desired behaviour, I created the following function and hooked it to the <span style="font-style: italic;">attachment_fields_to_edit filter</span> to clear out the URL before it is displayed. <br />
<br />
<code><br />// hide the URL by default for people too lazy to click "None"<br />add_filter('attachment_fields_to_edit', 'suppress_linkURL');<br />function suppress_linkURL($fields) {<br /> $img_url = $fields['image_url']['value'];<br /> if(!empty($img_url)){<br /> $html = $fields['url']['html'];<br /> if(!empty($html)) {<br /> $fields['url']['html'] = str_replace("value='$img_url'","value=''",$html);<br /> }<br /> } <br /> return $fields;<br />} </code><br />
<br />
I doubt there is going to be a lot of demand for this particular snippet of code, but hopefully somebody will find it helpful.GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com1tag:blogger.com,1999:blog-7057248431195415734.post-65877100439432155872010-01-29T19:38:00.012+00:002010-01-29T20:28:30.120+00:00jQuery image roll-oversOn the site I am currently working on I needed to implement hover/roll-over states for a number of image tags. Other elements in the site use the CSS based <span style="font-style:italic;">x</span>:hover{background:<span style="font-style:italic;">y</span>} approach, but that was not an appropriate solution for these instances - background images were not going to used, so I came up with a nice jQuery based solution that keeps my page-source pretty uncluttered too.<br /><br />I added a class value of "hover" to the image tags I wanted to exhibit this behaviour. The replacement images all had the suffix _hover added (e.g. theimage_hover.png )<br /><br /><code><img src="/images/theimage.png" class="hover"></code><br /><br />Then in my main javascript file I added this little snippet:<br /><code><br />function imghover_on(img){if(img.src.indexOf('_hover.')==-1){img.src=img.src.substr(0,img.src.length-4)+'_hover'+img.src.substr(img.src.length-4)}}<br /><br />function imghover_off(img){img.src = img.src.replace('_hover.','.');}<br /><br />jQuery(document).ready(function(){<br /> jQuery("img.hover").mouseenter(function(e){ imghover_on(this);});<br /> jQuery("img.hover").mouseleave(function(e){ imghover_off(this);});<br />});<br /></code><br /><br />This code declares two functions which add or remove the "_hover" suffix to the image tag's source, while not needing to know if the image is .png .gif or .jpg. <br /><br />The jQuery statement waits for the page to load and then finds all img tags in the document with the hover class set and binds the function calls to the mouseenter and mouseleave. This saves me from having to add these events to every single image tag manually like this:<br /><br /><code><img src="/images/theimage.png" onmouseover="imghover_on(this);" onmouseout="imghover_off(this)"></code><br /><br />Notes:<ul><br /><li>I used mouseenter/mouseleave as they fire a lot less than mouseover/mouseout (see: <a href="http://docs.jquery.com/Events/mouseenter">http://docs.jquery.com/Events/mouseenter</a> )<br /><li>It's not infallable, a .jpeg file extension would fail, but it's working nicely for first cut.</ul>GregJxnhttp://www.blogger.com/profile/09828030539845311474noreply@blogger.com0