Loving The Ting Tings – Great DJ. They are playing in March at Terminal 5, should be an awesome show.
Monthly Archive for February, 2009
Check out this Contact – The Irving Sessions by David Alan Wright. You can listen to more of his music over at his blog.
Need to run both php4 and php5 on your Mac? I did – so I used Mamp. It’s awesome! There is even a great little tutorial on installing Wordpress on Mamp here. There is a very simple toggle for running php4 or running php5 built into Mamp. I am also using the native php5 build that ships with Mac OSX 10.5.
I wanted to add a recent tracks on Last.fm widget to my blog. The caveat is that I use wp-cache, meaning, a standard RSS feed widget would be often out of date. I opted for a JSONP widget, the implementation is fairly straight forward. After signing up for a Last.fm API account, I hooked into the recent tracks API, which is capable of providing a JSONP response.
I ended up using jQuery, since it comes with Wordpress. Though a library isn’t entirely necessary for such a simple widget, it’s already on the page, so why not use it. Also, it gave me a good reason to play around and test out that library. For the most part, jQuery is like all the other mainstream libraries in terms of syntax. The no-conflict mode is very nice for pages where name space collision might be an issue, but it did have a few odd behaviors that I’m not sure I understand. One that really confused me was jQuery’s getElementById() equivalent.
var elem = jQuery('#my_id')
For some reason, this returns an array. To actually access the element above, you need to say elem[0]. By definition getElementById() returns only one element. There is probably a good reason for this (at least I hope so), but I’m not sure why yet.
Take a look at my implementation in you’re interested. Help yourself to the code, but please get your own api key. It’s not much more than a simple for-loop that creates a handful of elements. I could probably make it more plug-and-play, but it suits my needs for now.
Update: I have turned this code into a full fledged Wordpress Plugin / Widget. You can download the plugin here. Perfect for both widget-enabled themes and non-widget-enabled. Themes. Get it now.
Blitzen Trapper was featured on Spinner CD Listening Party a few months ago, they’re great. Check out Black River Killer.
A co-worker asked me how I would take an array of a certain size and break it into a multidimensional array with the second dimension not exceeding a certain length. He showed me an example that appeared to step through every element in the array. This felt like a huge waste to me. Why not leverage slice! So I did, check it out
Array.prototype.chunk = function( chunkSize ) { var base = [], i; for(i=0; i<this.length; i+=chunkSize ) { base.push( this.slice( i, i+chunkSize ) ); } return base; }
For those of you who aren’t comfortable modifying the native JavaScript array by using the prototype property, you can use following method.
var array_chunk = function( startArr, chunkSize ) { var base = [], i; for(i=0; i<startArr.length; i+=chunkSize ) { base.push( startArr.slice( i, i+chunkSize ) ); } return base; }
Usage would look something like this
var myarray = []; for( var i=0; i<68; i++ ) { // make an array so we have something to chunk up later myarray.push( "somevalue_" + i ); } var new_array = myarray.chunk( 20 ); for(var i=0; i<new_array.length; i++) { console.log( new_array[i] ); }
This code will provide a new array with length of 4. The first 3 elements will have arrays with 20 items, the last will have an array with 8 items. If your array size is less than the length of the chunk size, it will handle that too. The original array isn’t modified.
Finally, I got a little crazy and thought it would be cool to have it return an object which provides the length of the original array as well as the chunks.
Array.prototype.chunker = function( chunkSize ) { var base = [], i; for(i=0; i<this.length; i+=chunkSize ) { base.push( this.slice( i, i+chunkSize ) ); } return { length : this.length, chunks : base }; }
My sister, Cindy Brummer, just showed me the fruits of her first paid freelance gig Paloma’s Nest. It’s sweet, and very smooth. She is using jQuery to provide the animations. Just another example that you don’t need Flash to build quality websites. Great job Cindy!
I have really been enjoying hayloft by mother mother recently. The band will be in NYC on Feb. 18, I already have my tickets!
Installing Movable Type on Mac 10.5 is fairly easy, though I did go down several paths that proved incorrect. The problem I was having centered around having downloaded the wrong version of MySQL. I had installed MySQL for PowerPC by mistake. Amazingly, this version worked fine for my local Wordpress installation, but wouldn’t work with Perl DBD::mysql. I determined I needed to install the x86 version, not the PowerPC version and not the x86_64 version. Get the MySQL DMG here.
MySQL provides point-and-click package installers. Install MySQL, the Startup Items and the PrefPanel. You don’t have to install all of these, but if you want a simple GUI for starting and stopping MySQL the PrefPanel is a must.
Here is a super quick guide to the install. Some of it was drawn from the references listed at the end.
First things first, you need to grab the latest copy of Movable Type, you can find that here.
Open up Terminal, $ is my prompt.
$ mkdir tmp $ cd tmp $ wget http://www.movabletype.org/downloads/stable/MTOS-4.23-en.zip $ unzip MTOS-4.23-en.zip $ cp -r MTOS-4.23-en /Library/WebServer/CGI-Executables/mt $ cd /Library/WebServer/CGI-Executables/mt $ chmod 775 *.cgi $ mkdir ./db $ chmod 777 ./db $ cp mt-config.cgi-original mt-config.cgi $ cp -r /Library/WebServer/CGI-Executables/mt/mt-static /Library/WebServer/Documents/mt-static # make the directory writable by the web server. This is pretty brute force $ chmod 777 /Library/WebServer/Documents/mt-static
In this installation, I am using MySQL. You will need to create a new database for Movable Type and a user that has full access to that database. I used phpmyadmin to do this.
Now it’s time to edit the config file. Use your favorite text editor, for me, that’s coda. You need to change several values to work with your configuration. Put your mt-static files in the root directory of your local Apache installation, or wherever, just make sure that where you put mt-static and the value of StaticWebPath match.
# The CGIPath is the URL to your Movable Type directory #CGIPath http://www.example.com/cgi-bin/mt/ CGIPath /cgi-bin/mt/ # The StaticWebPath is the URL to your mt-static directory # Note: Check the installation documentation to find out # whether this is required for your environment. If it is not, # simply remove it or comment out the line by prepending a "#". #StaticWebPath http://www.example.com/mt-static StaticWebPath /mt-static
In the database settings, update the values under MySQL to the database you created above. Comment out the other databases or you will get an error. Be sure and save the file.
Now it’s time to get MySQL working with Perl. To do this, you have to grab the Perl Database Interface from this directory. At the time of writing this guide, 4.010 was the latest.
$ cd Library/Perl $ wget http://www.cpan.org/modules/by-category/07_Database_Interfaces/DBD/DBD-mysql-4.010.tar.gz $ tar -zxvf DBD-mysql-4.010.tar.gz $ cd tar -zxvf DBD-mysql-4.010 $ sudo perl Makefile.PL $ sudo make $ sudo make install
You should be all set now, to make sure your environment is configured correctly, go here http://localhost/cgi-bin/mt/mt-check.cgi. Make sure the data storage modules are set up correctly.
You should be all set to run the mt.cgi script, here. This worked okay for me. I spent about an hour thinking I needed to install mod_perl, not sure why I thought that, but you definitely don’t need it.
Check out these references if you have any issues. Let me know in the comments below if you need any help. Like I said before, I went down about 10 ten dead ends and spent 5 hours trying to get this installed, which in the end all turned out to be my mistake for installing the wrong version of MySQL.
Update: When I published this piece, I made the mistake of thinking mt-static is the directory where the blog files will live. This is incorrect, mt-static is the files that power movable type backend and must remain a separate directory.
Update 2: The Blog Herald just linked to this post, unfortunately, trackbacks seem be broken with Disqus, which sucks.
References