diff --git a/content/posts/2006-10-13-migrate-sqlite3-to-mysql-easily.md b/content/posts/2006-10-13-migrate-sqlite3-to-mysql-easily.md index 5d9f5c0..5b6e52f 100644 --- a/content/posts/2006-10-13-migrate-sqlite3-to-mysql-easily.md +++ b/content/posts/2006-10-13-migrate-sqlite3-to-mysql-easily.md @@ -9,15 +9,16 @@ I've been using a simple Rails application locally with a SQlite 3 database for Here are some easy steps on how to migrate your data to MySQL. First of all you need to dump your SQLite3 database. This includes transaction statements and create commands. That's fine. Since we also migrate the schema information, our RoR app will not know any difference after we change config/database.yml. The biggest probem I encoutered was that the SQLite3 dump places table names in double quotes, which MySQL won't accept. -~ First, make sure you create your MySQL database and create a user to access that database. Then run the following command. (It's a long one, so where you see a \, just continue on the same line.) - sqlite3 db/production.sqlite3 .dump | \ - grep -v "BEGIN TRANSACTION;" | \ - grep -v "COMMIT;" | \ - perl -pe 's/INSERT INTO \"(.*)\" VALUES/INSERT INTO `\1` VALUES/' | \ - mysql -u YOURUSERNAME -p YOURPROJECT_production[/source] +``` shell +sqlite3 db/production.sqlite3 .dump | \ +grep -v "BEGIN TRANSACTION;" | \ +grep -v "COMMIT;" | \ +perl -pe 's/INSERT INTO \"(.*)\" VALUES/INSERT INTO `\1` VALUES/' | \ +mysql -u YOURUSERNAME -p YOURPROJECT_production[/source] +``` This will take the SQLite 3 dump, remote the transaction commands. Next I use perl to replace all INSERT commands containing double quotes with something MySQL will understand. diff --git a/content/posts/2006-10-13-tagging-in-ajax_scaffold.md b/content/posts/2006-10-13-tagging-in-ajax_scaffold.md index 0d897a3..4cba283 100644 --- a/content/posts/2006-10-13-tagging-in-ajax_scaffold.md +++ b/content/posts/2006-10-13-tagging-in-ajax_scaffold.md @@ -4,31 +4,35 @@ title = "Tagging in ajax_scaffold" tags = ["General", "Everything", "Web Development", "RubyOnRails", "Features"] slug = "tagging-in-ajax_scaffold" +++ + I've been using the Ajax Scaffold for quite some time now. It's a great piece of software by Mr. Richard White for Ruby on Rails. It seems that the plugin version of AS is getting quite a bit more attention than the generator. I started out with the generator but quickly reverted to the plugin since it's way more flexible and easier to use. Since I wanted to create a quick app to inventory my CD/DVD collection (which is now in a very sexy alu DJ case) I used Ajax Scaffold to get me started. In the spirit of Web 2.0 I wanted to add tags to every CD so it would be easier to find certain kinds of disks later on. So, I added acts_as_taggable. Acts_as_taggable basically allows you to tag any model in your app. So, I made my Disk model taggable. Great. Now I could do this: - d = Disk.new(:number => 1, :name => "Mac OS X 10.4.6 Install DVD 1") - d.tag_with("macoxs apple macbook install") - d.save +``` ruby +d = Disk.new(:number => 1, :name => "Mac OS X 10.4.6 Install DVD 1") +d.tag_with("macoxs apple macbook install") +d.save +``` The real problem was, how to get this functionality easily integerated in Ajax Scaffold? -~ First of all I had to show a column in AS that included the tags attached to a given disk. I specify all rows manually in the Manager controller. Manager is scaffolded using AS. Here's what my Manager controller looks like: - class ManagerController < ApplicationController - ajax_scaffold :disk +``` ruby +class ManagerController < ApplicationController + ajax_scaffold :disk - @@scaffold_columns = [ - AjaxScaffold::ScaffoldColumn.new(Disk, { :name => "number" }), - AjaxScaffold::ScaffoldColumn.new(Disk, { :name => "name" }), - AjaxScaffold::ScaffoldColumn.new(Disk, { :name => "tags", - :eval => "row.tag_list", :sort => "tag_list"}), - ] - end + @@scaffold_columns = [ + AjaxScaffold::ScaffoldColumn.new(Disk, { :name => "number" }), + AjaxScaffold::ScaffoldColumn.new(Disk, { :name => "name" }), + AjaxScaffold::ScaffoldColumn.new(Disk, { :name => "tags", + :eval => "row.tag_list", :sort => "tag_list"}), + ] +end +``` This will show three columns, including a column named 'tags'. Every model that acts_as_taggable has some extra methods. tag_list is a single string containing all tags seperated by spaces. So, the tags column shows the tag_list for that row. With :sort I specify that AS can just sort keywords alphabetically. @@ -38,22 +42,26 @@ Great! I now can see tags on disks! But, we also need to add those tags and that Adding tags is not done by assignment but by calling a method with your tags, as shown before: tag_with (string). I could create a custom create and update method for the Disks, but there's a prettier solution available. -tag_list returns a string with the current tags. How about using that same name to assign tags? It's rather easy. Here's my Disk model: +`tag_list` returns a string with the current tags. How about using that same name to assign tags? It's rather easy. Here's my `Disk` model: - class Disk < ActiveRecord::Base - acts_as_taggable +``` ruby +class Disk < ActiveRecord::Base + acts_as_taggable - validates_presence_of :name, :number + validates_presence_of :name, :number - def tag_list=(new_tags) - tag_with new_tags - end + def tag_list=(new_tags) + tag_with new_tags end +end +``` Now we can assign tags to tag_list as well as read the tags out. Now the only step is to add a special textfield to the form partial for AS. - - <%= text_field 'disk', 'tag_list' %> +``` erb + +<%= text_field 'disk', 'tag_list' %> +``` Now when a new disk is created or when one is updated, the tag_list will automagically be updated in a correct fashion. diff --git a/content/posts/2006-10-31-wordpressmu-dont-allow-new-blogs.md b/content/posts/2006-10-31-wordpressmu-dont-allow-new-blogs.md index 66c4641..1584c37 100644 --- a/content/posts/2006-10-31-wordpressmu-dont-allow-new-blogs.md +++ b/content/posts/2006-10-31-wordpressmu-dont-allow-new-blogs.md @@ -4,20 +4,23 @@ title = "WordpressMu: Don’t allow new blogs" tags = ["General", "Everything", "Features", "WordPressMu"] slug = "wordpressmu-dont-allow-new-blogs" +++ + If you're using WordpressMu, the blog hosting tool used on Wordpress.com, you may want to disable the creation of blogs by your visitors. Whatever your reasons for this are, I wanted to prevent this, because I (and my team of editors) want to maintain several blogs on different topics. Users are free to register and post comments, but creating new blogs is reserved for the administrator. So, how do you implement this in WordpressMu? There is no checkbox (yet) that disables this feature. So, I had to hack the WordpressMu code a bit. -~ + First, open up wp-signup.php. If you access a blog that does not exist, you'll be redirected to the signup page and be presented a signup form for that particular blog. Open up wp-singup.php en just above the get_header(); call, place the following code: - if (!is_user_logged_in() || $user_identity != 'admin') { - header("Location: http://example.com/gofishatthispage/"); - exit(); - } +``` php +if (!is_user_logged_in() || $user_identity != 'admin') { + header("Location: http://example.com/gofishatthispage/"); + exit(); +} +``` What this does is make sure that only a logged in user named 'admin' is allowed to proceed to the blog creation form. Others will be redirected to a location of your choice. A good idea is to send people to a page that explains why they can't' create a blog or what they have to do to get an administrator to create one for them. diff --git a/content/posts/2006-11-13-cups-426-upgrade-required.md b/content/posts/2006-11-13-cups-426-upgrade-required.md index 2361aac..9ccb961 100644 --- a/content/posts/2006-11-13-cups-426-upgrade-required.md +++ b/content/posts/2006-11-13-cups-426-upgrade-required.md @@ -7,19 +7,20 @@ slug = "cups-426-upgrade-required" As I was installing my printer on my Ubuntu 6.06 Dapper LTS server with CUPS I noticed the following error: -**426 Upgrade Required** +> 426 Upgrade Required After some research I came to the conclusion that CUPS, by default, tries to use SSL whenever possible. So, with this 426 error, you are redirected to the SSL domain. Chances are, you haven't configured SSL properly, if at all. In my case, I didn't want to configure SSL. To get rid of this problem, the key lies in editing your configuration files ( /etc/cups/cupsd.conf ) and adding the following line: -
DefaultEncryption Never
+``` text +DefaultEncryption Never +``` There are several options, Never, IfRequired and Required. By setting this to Never, SSL will never be enforced. Just restart your CUPS server with - $ /etc/init.d/cupsys restart +``` shell +/etc/init.d/cupsys restart +``` and you're good to go. - - - diff --git a/content/posts/2006-11-15-ubuntu-610-live-dvd-on-the-apple-macbook.md b/content/posts/2006-11-15-ubuntu-610-live-dvd-on-the-apple-macbook.md index ccc27b8..5cf0feb 100644 --- a/content/posts/2006-11-15-ubuntu-610-live-dvd-on-the-apple-macbook.md +++ b/content/posts/2006-11-15-ubuntu-610-live-dvd-on-the-apple-macbook.md @@ -30,7 +30,9 @@ In order to solve this problem I had to take a few, rather easy, steps. To get started, let us assign a password to the default ubuntu user. - sudo passwd ubuntu +``` shell +sudo passwd ubuntu +``` Now enter something that you'll remember easily, twice. @@ -38,26 +40,30 @@ In order to get Ubuntu to recognize the native screen resolution automatically, So, we now need to change /etc/apt/sources.list and add the universe repository. This is rather easy, because these repositories already exist, but are commented out. Just open up /etc/apt/sources.list and uncomment the two universe lines. Make sure your sources.list looks like this: - deb http://archive.ubuntu.com/ubuntu edgy main restricted - deb-src http://archive.ubuntu.com/ubuntu edgy main restricted +``` text +deb http://archive.ubuntu.com/ubuntu edgy main restricted +deb-src http://archive.ubuntu.com/ubuntu edgy main restricted - ## Uncomment the following two lines to add software from the 'universe' - ## repository. - ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu - ## team, and may not be under a free licence. Please satisfy yourself as to - ## your rights to use the software. Also, please note that software in - ## universe WILL NOT receive any review or updates from the Ubuntu security - ## team. - deb http://archive.ubuntu.com/ubuntu edgy universe - deb-src http://archive.ubuntu.com/ubuntu edgy universe +## Uncomment the following two lines to add software from the 'universe' +## repository. +## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu +## team, and may not be under a free licence. Please satisfy yourself as to +## your rights to use the software. Also, please note that software in +## universe WILL NOT receive any review or updates from the Ubuntu security +## team. +deb http://archive.ubuntu.com/ubuntu edgy universe +deb-src http://archive.ubuntu.com/ubuntu edgy universe - deb http://security.ubuntu.com/ubuntu edgy-security main restricted - deb-src http://security.ubuntu.com/ubuntu edgy-security main restricted +deb http://security.ubuntu.com/ubuntu edgy-security main restricted +deb-src http://security.ubuntu.com/ubuntu edgy-security main restricted +``` Now, we can update our system and install the 915resolution package. - apt-get update - apt-get install 915resolution +``` shell +apt-get update +apt-get install 915resolution +``` You'll notice that 915resolution spits out a lot of information on your chipset and native resolution. You should check here that the 1280x800 resolution has been detected. diff --git a/content/posts/2006-11-21-svn-how-to-release-software-properly.md b/content/posts/2006-11-21-svn-how-to-release-software-properly.md index 57f9356..f529101 100644 --- a/content/posts/2006-11-21-svn-how-to-release-software-properly.md +++ b/content/posts/2006-11-21-svn-how-to-release-software-properly.md @@ -9,13 +9,15 @@ Many projects use SubVersion nowadays to store their project code. I do this als The question, however, is how to release your current code properly to the public. You probably don't want your users to check out your current development code. Either you want them to check out a certain version (release) or you want to present them with a download archive containing the code. I'm going to show you how to release a simple PHP application from SubVersion as an archive file to my users. -~ + The base layout of my svn repository is like this. I have directory named 'trunk' that always contains the most recent version of the software. This is the development branch, so to say. I also have a 'branches' and a 'tags' directory. If you don't have these, you'll need to create them now: - $ svn mkdir -m "Creating branches directory" svn://yourrepository/branches - Commited revision 123. - $ svn mkdir -m "Creating tags directory" svn://yourrepository/tags - Commited revision 124. +``` shell +$ svn mkdir -m "Creating branches directory" svn://yourrepository/branches +Commited revision 123. +$ svn mkdir -m "Creating tags directory" svn://yourrepository/tags +Commited revision 124. +``` In this case my current development code, in the trunk of the svn repository is at revision 10. All files in the trunk are marked to be develoment quality. This means that I don't display version numbers, but simply show 'HEAD' to indicate you're working with a development quality product. Before I release this code to the public, I want to tweak a few things. Since this is not general development, I create a Release Branch. This release branch is basically a copy of the current code in the trunk. Changes to that branch are stored seperately from the development code, so I can easily tweak it to release quality. @@ -23,8 +25,10 @@ Creating the release branch is really easy. Let's say I want to release version Well, create the Release Branch which is named, by convention, RB-1.1.0. - $ svn copy -m "Creating release branch 1.1.0" https://svn.sourceforge.net/svnroot/cse-tool/trunk https://svn.sourceforge.net/svnroot/cse-tool/branches/RB-1.1.0 - Committed revision 11. +``` shell +$ svn copy -m "Creating release branch 1.1.0" https://svn.sourceforge.net/svnroot/cse-tool/trunk https://svn.sourceforge.net/svnroot/cse-tool/branches/RB-1.1.0 +Committed revision 11. +``` You can see at http://cse-tool.svn.sourceforge.net/viewvc/cse-tool/branches/ that the new release branch (RB-1.1.0) was created as a directory containing a copy of the current develoment code. @@ -32,11 +36,15 @@ I can now do two things. Either I checkout a seperate working copy of the releas Just check out your code as you'd normally do, but make sure you specify the release branch. I've also specified to store this code in a directory named cse-tool-1.1.0 so I don't confuse it with the trunk code, which is stored in a directory named 'cse-tool'. - $ svn co https://svn.sourceforge.net/svnroot/cse-tool/branches/RB-1.0.0 cse-tool-1.1.0 +``` shell +$ svn co https://svn.sourceforge.net/svnroot/cse-tool/branches/RB-1.0.0 cse-tool-1.1.0 +``` I could also swich my current working copy to the release branch. This may be useful if your project is very huge and you don't want to download the whole thing again. Switching between a release branch and the trunk is usually more efficient because you only need to download the differences between the two. - $ svn switch https://svn.sourceforge.net/svnroot/cse-tool/branches/RB-1.0.0 +``` shell +$ svn switch https://svn.sourceforge.net/svnroot/cse-tool/branches/RB-1.0.0 +``` Okay, now I can work on the release branch. Branding it with the right version number among other things. In your case it might be a good place to two SQL files to install or update a database you are using. You might want to update the changelog and other documentation. @@ -44,19 +52,22 @@ When you commit changes, they will be applied to the release branch only, Download them here :)) - - diff --git a/content/posts/2006-11-22-plugins-used-on-ariejannet.md b/content/posts/2006-11-22-plugins-used-on-ariejannet.md index 7710bbb..f1ebe16 100644 --- a/content/posts/2006-11-22-plugins-used-on-ariejannet.md +++ b/content/posts/2006-11-22-plugins-used-on-ariejannet.md @@ -10,7 +10,7 @@ After I released iAriejan comes bundeled with WP Wetfloor and AJAX Comments. -~ +