A community based around the discussion of web & software development practices, databases, operating systems, tools, tricks and anything else in between that effects developers.
Blog Details
Overall rank: 1101071 Number of inbound blogs: 5 Number of incoming links: 8 Last update: 2008-09-10 12:22:07 GMT Estimated value: $5,421
Analytics
Incoming clicks since last reset: 0 Outgoing clicks since last reset: 0
Latest Posts
Contributing with Git
Google Tech Talks October 27, 2008
Length: 56:53
ABSTRACT
Source code versioning is an invaluable tool for software development:
- users can easily track the newest versions, - maintainers can easily track down which commit introduced a bug (often making it easier to come up with a fix), - new developers get more documentation than just a big chunk of source code, - etc
In my talk I want to stress the importance of source code versioning in a related context: when contributing changes to an Open Source project, which is typically a moving target, it can take a few revisions of the patches until they are accepted. I present several scenarios and workflows, and describe how Git can help with them. Speaker: Johannes Schindelin Johannes studied mathematics with a strong bias to number theory, trying to stay away from applied science as far as possible. Failing, he went on to a software company, where he gave up after finding that code quality played a lower role than pure politics. So he went back to university (Wuerzburg, Germany) to get a PhD in neurogene
Senator Conroy & Mates Trying To Silence Critics
The more that is said about the planned ISP level filtering, the worse it seems to sound. The family first nutjob Senator Steve Fielding has piped up, and said that they would like pornography and fetish material blocked by the planned filter.
This in turn seems to have inspired the South Australian independant Nick Xenophon who said should the plan go ahead he would like to block people from visiting overseas casino sites which are currently illegal to run in Australia.
Seems to back up the argument against internet censorship, just the concept of being in control of an as yet still imginary filter has them wandering about expressing their delusional ideals.
On the positive side though it seems the subject is slowly filtering out to the mainstream media outlets, which is going to make criticism of the plan a lot harder to brush under the carpet.
Have you ever been side tracked whilst logged into a remote server via SSH, only to find when you returned your session had timed out? A one line addition to the ssh_config can prevent this from being an issue.
Simply open a terminal window on your Ubuntu machine and type: sudo pico /etc/ssh/ssh_config
And add the line:
ServerAliveInterval 60
Then save your changes, this change will send a small "keep-alive" packet to the server every 60 seconds, making it think that the connection is actively being used, so your connection will no longer time out due to inactivity.
Installing Awstats On a Ubuntu Server
Awstats i think has lost the lime light in the last few years thanks to Google Analytics, but that dosent mean its useless. Its quick and unlike Google Analytics the latest stats are not a few days old, well they arent if your cron jobs run on regular basis anyhow. This post aims to show you how to get awstats up and running on your Ubuntu based server, with the stats of a virtual host pulled straight from the Apache log files.
First login in to your server via SSH and become root:sudo suUpdate your package list:apt-get updateInstall the awstats program:apt-get install awstatsCreate a new configuration file for the virtual host you would like to gather statistics on:cp /etc/awstats/awstats.conf /etc/awstats/awstats.mydomain.tld.confYou will need to create a separate configuration file for each virtual host you would like to gather statistics about. Of course when the virtual host is setup in Apache it will need its own log files.To see where our visitors hail from we will also need to install a PERL GeoIP library:apt-get install libnet-ip-perl libgeo-ipfree-perlNow its actually time to edit the awstats file for you virtual host so it contains the appropriate settings, lines you may need to look at are: Line 51 - This needs to point to the access log of the virtual hostLine 122 - Make sure the log type reflects the format Apache is writingLine 153 - Change this to the domain name of your siteLine 168 - Aliases etc that can be used to access the virtual hostLine 329 - To protect access to the sites statisticsLine 340 - "" "" "" "" ""Line 350 - "" "" "" "" ""Line 362 - Should Awstats create a directory for storing reports if it dosent already existLine 372 - Should Awstats use a text or XML file to build the stats databaseLine 382- XHTML or HTML statistic reportsLine 413 - Should Awstats empty the access log after a parsing it can save having to worry about rolling it.Line 428 - Tells Awstats if you would like to archive the logs which it has already parsedLine 450 - The default name of the report fileLine 466 - Clients that should be skipped in the reports i.e your own IP addressLine 479 - Skip certain user agents i.e wget etcLine 497 - Dont count certain files on your siteLine 732 - Turn on Awstats debugging for more verbose outputLine 1255 - If you want to enable extra toolips in your reportsLine 1271 - Reverse lookups for IPV6 IP address'sLine 1302 - Use of a free GeoIP service for country to IP lookups
After the configuration is finished for our virtual host you will need to configure Apache so you can access your statistics.Create a new file for Apache with:pico /etc/apache2/conf.d/awstatsIn this file put the content:Alias /awstatsclasses "/usr/share/awstats/lib/"Alias /awstats-icon/ "/usr/share/awstats/icon/"Alias /awstatscss "/usr/share/doc/awstats/examples/css"ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ScriptAlias /awstats/ /usr/lib/cgi-bin/Options ExecCGI -MultiViews +SymLinksIfOwnerMatchNow restart the Apache service so you changes to the configuration take effect:/etc/init.d/apache2 restartNow add a line to your crontab to update your statistics every so often:pico /etc/crontabAnd add the following line to update your stats every 20 minutes:*/20 * * * * root /usr/lib/cgi-bin/awstats.pl -config=mydomain.tld -update >/dev/nullSave the changes and just to be on the safe side try and update the stats drom the command line with:/usr/lib/cgi-bin/awstats.pl -config=mydomain.tld -updateNote: If you get an error that looks likeError: SiteDomain parameter not defined in your config/domain file. You must edit it for using this version of AWStats.Setup ('/etc/awstats/awstats.conf' file, web server or permissions) may be wrong.Check config file, permissions and AWStats documentation (in 'docs' directory).Just delete the /etc/awstats/awstats.conf file and it will read the one you are trying to specify instead.Now to see the statistics for the site you just generated type the hostname of your server into a browser followed by /awstats/awstats.pl?config=mydomain.tld i.ehttp://www.myserver.com/awstats/awstats.pl?config=mycooldomain.comWith any luck you should now have access to a webpage with some pretty detailed statistics on your domain.
Ruxcon Registration Open
Registration is open for Ruxcon 2008, Sydney's premier security conference. Which is being held at UTS in the CDB on the Saturday 29th and Sunday the 30th of November. Admission is $60 which going by the site looks like it will be money well spent they have a great line up of talks and presentations.
Performance Tuning your Drupal Install
Your site has been skinned, modules are installed for all the required functionality but your site is running slow, this post will run you through some things you can look at to speed up your Drupal install.
Devel Module
Download the Devel module for your version of Drupal, uncompress and upload to the modules directory of your site. Enable the Devel module in your sites administration section and on the modules configuration page activate the options "collect query info" and "display query log". You may also want to turn on the "page generation timer" and the "display memory usage" option.
After activating the query log you will see all of the SQL queries that where executed in order to generate the page down the very bottom. Using this list you may like to disable any modules which are ineffiecient, but going through what the queries relate to.
The page generation timer is handy when making changes to benchmark what effect they are having on the speed of your site.
Block Cache Module
Another module you may want to look at to improve your site performance is Block Cache this module as the name suggests caches the blocks on a page, this module has been included in the Drupal Core as of version 6 but is available as a seperate download for 5.x versions of Drupal. In my case installing and enabling this module sliced around 100ms on average off my page generation time.
Boost
This module will cache your pages as static html files enabling huge performance increases for sites with large amounts of anonymous traffic. Each time the Drupal Cron file is executed the cached pages are discarded and recreated when the next visitor requests a page.
MySQL Query Cache Optimisation
MySQL query cache stores the results of a SQL query in memory, aftwerward if the results of a cached query is needed MySQL simply serves the result directly from memory without executing the query again. Fine tuning the query cache will have a massive effect on the speed of your site unfortunately this option is only available to those that have complete control of their server environment i.e not a shared hosting environment.There are two ways you can go about tweaking the MySQL query cache, if you have SSH access to you server you can simply login via a terminal and edit the values for the query_cache_limit & query_cache_size options in the my.cnf e.g pico /etc/mysql/my.cnfBe sure to restart MySQL after making any changes to the configuration file.The second way to tweak these values if you don't have shell access but have local GUI access (Windows etc) on the server you can use the "MySQL Administrator" program to change the values for your query cache. If you don't already have this program you can download it free of charge from the MySQL website.Using the program to connect to the MySQL service, click on the "Startup Variables" option in the left hand column, then select the performance tab at the top of the screen. Then select the Cache Size check box to enable the setting, and enter your new value, then apply the changes and restart the MySQL service.You may have to play around a bit with the query cache values to find something that works for you, as the cache size is going to be limited by how much memory you server has available to store query results.Hopefully after install the modules to cache and playing around with the query cache for MySQL you will see some dramatic improvements in the speed of your Drupal site.... Good Luck !!!
Typing Google Into Google Wont Break The Internet But Senator Conroy Sure Will
Seems the rules of the "Clean Feed" game changed this week when it was revealed although people can opt out of the planned mandatory filtered "child friendly" Internet. Everyone will still be subject subject to a filtered Internet, which is a very scary prospect indeed the details seem scarce and as proved true this week no one seems to be forthcoming with the truth on this filter and its application.
So lets look at what we do know so far about this filter:
The Government like everything else tells us its important to "protect the children" and stop the flow of kiddie porn. Tim Marshall, the media contact for Senator Conroy stated in an interview on the topic that is "reasonably emotive issue, and you know there's a few lobby groups in the sector who are pretty keen to put there extreme view out there without perhaps having too much interest in the facts."
It will cost lots, how much? Who knows everytime someone quotes a price it is different, rest assured though it will be a fair bit over 100 million.
The Trials in Tasmania shown accuracy is a hard nut to crack with all filters tested allowing between 2 - 13% of material through that should have been blocked whilst wrongly stopping access to 1.3 - 7.8% of sites tested.
It will slow down access to the Internet. In their Tasmanian trials only one of the filters had an acceptable level of performance loss (2%) as opposed to between a 21 and 86% slow down from the other filters. Tests showed the most accurate filters to cause the biggest drops in performance.
The filter will most likely be easy to bypass, making it useless for those that are determined to get unfiltered Internet.
The Government already spent 89 million providing free Internet filtering software for anyone worried about what content is available on computers in their household. Why should the rest of the country suffer because parents can not keep an eye on their children whilst using the Internet? Why is the "clean feed" and opt out system and not an opt in system after all children make up only 1/5 of the population.
The Government is remaining very tight lipped about what this other "inappropriate" content is they will be blocking, so we can assume it consists of anything they don't like with minimal processes in place to appeal.
Australia is already laughed at due to the Government's refusal to create a new rating for video games that are deemed to be above the MA15+ rating, do you really trust that they can do a better job with the Internet?
Aust Government To Save Children By Destroying The Internet
How To Fight Internet Cenorship In Australia
IE Browser Testing
Testing your web site layouts in IE is still unfortunately an essential part of development. Depending on your OS it can be an inconvienance, needed to load a virtual machine or similar running Windows to test in IE and even then you are limited with the versions of IE you can test in.
Enter the IE NetRenderer, simply type in the URL of the site to test and it will show you what it looks like in Internet Explorer version 5.5 though to 8 beta 2!
Getting Baked With CakePHP
What Is CakePHP?
CakePHP is a PHP open source rapid development framework that was born in 2005, it is distributed under an MIT licence and has a very active community. So of its other features include:
Compatibility with PHP4 and PHP5
Integrated CRUD for database interaction and simplified queries
Fast and flexible templating (PHP syntax, with helpers)
View Helpers for AJAX, Javascript, HTML Forms and more
Security, Session, and Request Handling Components
Flexible access control lists
Data Sanitation
Flexible View Caching
In this post i will run the reader through the process of setting up CakePHP and then creating a simple notice board application to demonstrate the simplicity of writing an application with cake.
Installing CakePHP
Download the latest copy of CakePHP from www.CakePHP.org uncompress and place in the root directory of your web server. Check that the Apache <directory> option for the root directory contains the AllowOverride option and it is set to "ALL" i.e
<Directory /mypath/tocakephp/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
Depending on how you configured Apache you may run into some trouble with the rewrite functionality, have a look at the web server URL in a browser, if the CakePHP page you see is missing its CSS and images something is amiss. You have two options with how you want to move forward from this point, you can uncomment line 40 of the CakePHP config file (app/config/core.php) which will work around the malfunctioning rewrite mod plugin. Or you can look at this page on the CakePHP site, which has some pointers on fixing the problem properly.
Also you must make sure Apache has write access to the app/tmp directory and its sub folders before. A new MySQL database named notice_board will have to be created using PHPmyadmin or similar to hold the data for our sample application. After this is done the file app/config/database.php.default needs to be renamed to app/config/database.php. Using a text editor the database parameters in the file then need to be changed to match your MySQL setup and the changes saved.
Baking Your First Application
Now the framework is installed we can start work on our first CakePHP application its going to be a simple notice board, it wont have all the bells and whistles but it will show you how quickly, and easily some tasks can be accomplished using cake. First up you will need to make a table in the database you created earlier to hold our notices.
CREATE TABLE `notice_board`.`notices` ( `id` INT( 10 ) NOT NULL AUTO_INCREMENT , `title` VARCHAR( 255 ) NOT NULL , `content` TEXT NOT NULL , `created` VARCHAR( 30 ) NOT NULL , `modified` VARCHAR( 30 ) NOT NULL , PRIMARY KEY ( `id` ) );
** Note: it is CakePHP convention to use plural names when naming database tables. All tables should also have a field named "id" as the primary key.
Creating The Model
In CakePHP each database table should have its own model, this model is basically just a class and is used to access and modify the data stored within the table. To create a model for the notices table create a file named notice.php in the app/models folder. In this file enter:
<?php class Notice extends AppModel { var $name='Notice'; } ?>
You can see from the code above the Entry calls extends the AppModel class, in CakePHP all models extend this class.
**Note: It is also a CakePHP convention that the model class its file name is a singular version of database table name.
Creating The Controller
The controller is a piece of code that decides what has to happen within an MVC application. Every model in an application needs an associated controller. Creating a controller for the notice board application is very similar to creating the model. Just create a new file named notices_controller.php in the app/controllers directory.
In this file enter the following code:
<?php class NoticesController extends AppController { var $name = 'Notices'; function index() { $this->set('notices', $this->Notice->findAll()); } } ?>
The addition of the index function is a method to give our controller some functionality in this case to display all of the notices stored in the database. **Note: It is CakePHP convention that controller names are plurals of the model name.
Â
Creating A View
We have a model, a database and a controller so now we need a view to display our hard work to the end user. Create a new directory called notices in the folder named app/views. Now create a file within the newly created directory called index.thtml containing the following code:
<h2>Notice Board</h2> <p><?PHP echo $HTML->link('Add New Notice', '/notices/add'); ?></p> <div style="height: 10px;"></div> <?PHP if(empty($notices)) : ?> This notice board currently has no notices to display. <?PHP else: foreach ($notices as $notice): echo '<b>Title:</b> ' . $notice['Notice']['title'] . '<br>'; echo $notice['Notice']['content'] . '<br>'; echo '<b>Created: </b><i>' . $notice['Notice']['created'] . '</i><br>'; echo $HTML->link('Delete', "/notices/delete/{$notice['Notice']['id']}", null, 'Are you sure?'Â ); echo '<br><div style="height: 10PX;"></div>'; endforeach; endif; ?>
**Note: The 1.2 version of CakePHP will use the file extension .ctp as opposed to the extension .thtml usedfor "views" in the earlier versions.
Now if you aim your browser at your server's url with the trailing name "notices" i.e http://mysever.com/notices, you should be able to now see that we are making some positive progress with our app.
Creating New Notices
Since we have laid out the ability to view notices its time to add some functionality to the controller so a user can actually post notices to the board. To achieve this you will need to edit the notices_controller.PHP and append an add function, so the files contents look like this:
<?PHP class NoticesController extends AppController { var $name = 'Notices'; function index() { $this->set('notices', $this->Notice->findAll()); }
function add() { if (!empty($this->data)) { if ($this->Notice->save($this->data)) { $this->flash('Your notice has been posted.','/notices'); } } } } ?>
Now create a template named app/views/add.thtml with the code below for the user to enter the details of a new notice.
<h2>Create Notice</h2> <form method="post" action="<?PHP echo $HTML->url('/notices/add')?>"> <div align="center"> <p> Notice Title: <?PHP echo $HTML->input('Notice/title', array('size' => '40'))?> <?PHP echo $HTML->tagErrorMsg('Notice/title', 'A notice title is required.') ?> </p>
Since the application has a form to accept data from a user the entered data will have to be validated, one of CakePHP's strong points is its built in validation functionality removing a lot of pain for developers. To handle the validation of our new notice you need to go back and edit the entries model (app/models/notice.PHP) and append a validate array so the file looks like this:
<?PHP class Notice extends AppModel { var $name='Notice'; var $validate = array( 'title' => VALID_NOT_EMPTY, 'body' => VALID_NOT_EMPTY ); } ?>
Deleting Existing Notices
Now notices can be added to the board, it makes sense to add functionality supporting the deletion of a notice. To achieve this we need to add a new function to our controller so the delete link on the index page works properly. Open the controller file back up and add a delete function so the file contents are the same as below:
<?PHP class NoticesController extends AppController { var $name = 'Notices'; function index() { $this->set('notices', $this->Notice->findAll()); }
function add() { if (!empty($this->data)) { if ($this->Notice->save($this->data)) { $this->flash('Your notice has been posted.','/notices'); } } }
function delete($id) { $this->Notice->del($id); $this->flash('The selected notice has been deleted.', '/notices'); }
} ?>
You should now be the proud owner of your first working CakePHP web application!