Reviewed: ExtJS 3.0 Cookbook

There is a quantity of snow falling outside as I write this and that means it’s a good day to read programming books. I’ve recently been enjoying the ExtJS 3.0 Cookbook by Jorge Ramon that is published by the Packt group. I’ve been using ExtJS for the last year and have experienced the transition from version 2.0 to 3.0 and have been rather pleased with the results it has delivered for numerous web projects I’ve coded. After trying many other JS kits and frameworks including Jquery, Mootools, and several others I have generally settled on ExtJS to solve the layout and user interface parts of my applications because of its ease of use and flexible nature for expansion. The framework is an extension of the Yahoo javascript framework, otherwise known as YUI, but with many quality extensions. This book comes as a welcome guide to the general tasks that the framework will solve as well as some of the more unique and in-depth items that it can provide. Quite simply it’s a book with over a hundred examples of all the best features of the ExtJS framework. The examples are well explained with detailed write-ups that are fun to read. The examples also have immediately usable code for dropping into place or modifying for your own needs. If you’re interested in learning more about this amazing framework or are already acquainted and need a quick guide to expand your abilities, then this will be a good reference to own. Before I get going you can see the book here.

The book starts out with an overview of the way that ExtJS handles DOM and data types, which is all very basic stuff but required understanding as well. It’s a good start to understanding the base elements if you are a bit rusty. It’s also a good chapter to see how ExtJS handles them since it might not be what you are used to if coming from another framework. After enough pages to answer most typical questions of that topic the book dives into the UI building aspects of the framework. This is where things get really good as I’ve always enjoyed how the framework builds UI for the web. You get examples for containers and positioning, accordion functionality, card and tab based windowing, column and table layouts, and the windowing functions for full browser UI building. I’ve used many of these features all in one layout and the results are a effective and efficient manner of data distribution and information organization for content driven sites. The book even covers dynamic building of UI elements, which comes in handy for a user interface that grows and changes with the needs of the user.

After you build your UI you need methods to get content into the application and ways that the user can interact with the app. The book addresses these needs as well. Plenty of examples abound for all of the required manners that users will be using forms, date fields, combo boxes, remote data loading via JSON and XML, as well as covering grid panels and data tables. Of course it must be mentioned that there are numerous examples that discuss the AJAX features of ExtJS since this is one of it’s major strengths and successes. If there’s a way to use remote data calls via XML or JSON, it is covered in this book. We also get a nice run down of trees and tab data which is inevitably useful for many purposes. If you are interested in progress bars and customized progress circles the book covers those with over 20 pages of examples. Just before the topics are finished off Jorge covers the functions for building rich charts and graphs. Details involve static data display, remote data display, as well as auto-refresh of data for realtime charting. Patterns, class extensions, plugins, and ‘keeping state’ are the last topics of the book. They offer quality methods for customizing ExtJS with your own JS code and keeping the user’s data consistent between sessions.

Overall this is one of the best books I’ve read about ExtJS. It’s as if the author took all of the items that I had to research over the last year of using the framework and put the solutions all into a nicely readable form with quality code examples that are explained in a useful manner. If you are looking for a book that touches upon the most common and some of the more esoteric options of the ExtJS framework but don’t feel like scouring the online forums and hundreds of pages of documentation then this is the book for you. If you haven’t already built your own code for the features that the chapters discuss then the examples given will save you time and get your projects up and running fast and efficiently.

DDR-Drive gets 300,000 IOPS

Sure it’s expensive and hard to justify for most budgets but this is the future of drive technology happening now. http://www.ddrdrive.com

Simple SQL: growth-over-time query

I’ve been messing around with the Kontrollbase schema for the last couple of days, writing various queries for the daily reporting scripts that will eventually be an automated pdf report. I’ll give you examples of two of the queries, the first being overall environment stats, and the second being single-host growth over time.

Overall environment stats
select ((((MAX(os_mem_used)) / 1024 ) / 1024) / 1024) max_os_mem_used, ((((MIN(os_mem_used)) / 1024 ) / 1024) / 1024) min_os_mem_used, ((((AVG(os_mem_used)) / 1024 ) / 1024) / 1024) avg_os_mem_used, ((((STDDEV_POP(os_mem_used)) / 1024 ) / 1024) / 1024) stdev_os_mem_used, ((((MAX(length_data + length_index)) / 1024 ) / 1024) / 1024) max_size, ((((MIN(length_data + length_index)) / 1024 ) / 1024) / 1024) min_size, ((((AVG(length_data + length_index)) / 1024 ) / 1024) / 1024) avg_size, ((((STDDEV_POP(length_data + length_index)) / 1024 ) / 1024) / 1024) stdev_size, MAX(num_connections) max_connections, MIN(num_connections) min_connections, AVG(num_connections) avg_connections, STDDEV_POP(num_connections) stdev_connections, MAX(queries_per_second) max_qps, MIN(queries_per_second) min_qps, AVG(queries_per_second) avg_qps, STDDEV_POP(queries_per_second) stdev_qps from server_statistics;
*************************** 1. row ***************************
max_os_mem_used: 50.743488311768
min_os_mem_used: 0.023044586182
avg_os_mem_used: 1.5759627057922952
stdev_os_mem_used: 2.4064208226596184
max_size: 283.815660957247
min_size: 0.000492287800
avg_size: 10.8213909777686940
stdev_size: 39.9443980717105447
max_connections: 435
min_connections: 0
avg_connections: 16.9734
stdev_connections: 37.3269
stdev_os_mem_used: 2.4064208226596184
max_qps: 9243.6533203125
min_qps: 0.00011409764556447
avg_qps: 216.421064774444
stdev_qps: 1071.72792986232
1 row in set (0.00 sec)

single-host growth over time
mysql> select (select (((length_data + length_index) / 1024) / 1024) as curr_size from server_statistics where server_list_id='44' and CURDATE() <= Creation_time order by Creation_time asc limit 1) as 0_day_size_mb, (select (((length_data + length_index) / 1024) / 1024) as curr_size from server_statistics where server_list_id='44' and DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= Creation_time order by Creation_time asc limit 1) as 30_day_size_mb, ( (select (((length_data + length_index) / 1024) / 1024) as curr_size from server_statistics where server_list_id='44' and CURDATE() <= Creation_time order by Creation_time asc limit 1) - (select (((length_data + length_index) / 1024) / 1024) as curr_size from server_statistics where server_list_id='44' and DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= Creation_time order by Creation_time asc limit 1)) as difference, ( select (select ((select (((length_data + length_index) / 1024) / 1024) as curr_size from server_statistics where server_list_id='44' and CURDATE() <= Creation_time order by Creation_time asc limit 1) - (select (((length_data + length_index) / 1024) / 1024) as curr_size from server_statistics where server_list_id='44' and DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= Creation_time order by Creation_time asc limit 1)) as difference) / (select(select (((length_data + length_index) / 1024) / 1024) as curr_size from server_statistics where server_list_id='44' and CURDATE() <= Creation_time order by Creation_time asc limit 1) as 0_day_size_mb ) * 100) as percent_growth;
+---------------+----------------+--------------+----------------+
| 0_day_size_mb | 30_day_size_mb | difference | percent_growth |
+---------------+----------------+--------------+----------------+
| 9100.43986130 | 8199.39263916 | 901.04722214 | 9.901139240197 |
+---------------+----------------+--------------+----------------+
1 row in set (0.01 sec)

Interesting links that predict the future of data storage

Ok, they aren’t like the 2012 nonsense or anything but they are interesting articles that will be important topics in the near future for expanding our knowledge and usefulness in the job market. Being a DBA does not limit you to relational database systems. I expect to see more requests for non-relational or No-SQL type of data stores as they can have many advantages over an RDBMS. Stability, scalability, simplification of administration, higher performance on lesser hardware for larger datasets, and many other items make no-sql engines very interesting. Here are some useful links:

http://en.wikipedia.org/wiki/NoSQL

http://www.linux-mag.com/cache/7579/1.html

http://www.computerworld.com/s/article/9135086/No_to_SQL_Anti_database_movement_gains_steam_

http://www.viget.com/extend/nosql-misconceptions/

How can I pass up talking about the various Cloud offerings again. Here are some interesting news stories and a shameless link to the cloud service that my employer runs.

http://aws.typepad.com/aws/2009/10/two-new-ec2-instance-types-additional-memory.html

http://www.opsourcecloud.net/

http://virtualization.sys-con.com/node/770174

This is not related to no-sql or the cloud but I’m going to post it anyway: http://www.continuent.com/community/all-projects

Notes for installing MySQL 5.4.2 on OSX 10.5.8 PPC

Some notes from my recent installation of MySQL 5.4.2-beta on a PPC G5 box running OSX 10.5.8. Hopefully these notes will save someone a bit of time when they begin the “I want to make my mac a development box” process. I’m not going to cover installing/configuring Apache and PHP since the web is full of those articles already.  So, first things first,  I downloaded the pkg file  – not the tarball – from the MySQL downloads site and installed the following files in the following order:

  1. mysql-5.4.2-beta-osx10.5-powerpc-64bit.pkg
  2. MySQLStartupItem.pkg
  3. MySQL.prefPane

CNF File Settings

Here are some interesting settings that you may want to be aware of with 5.4 and OSX

  • Do not set innodb_flush_method=fdatasync – it’s not a valid option, and the default after install is actually blank.
  • Do not set “nice = value” in the [mysqld_safe] section as this is not recognized and give the error ‘nice: illegal option — -
  • Set the variable lower_case_table_names=2 because the HFS+ file system is case insensitive – isn’t that special.
  • The variable ‘log_slow_queries’ will work but you should use ‘slow_query_log’ or ‘slow_query_log_file’ instead since it’s getting removed in *gasp* MySQL 7.0 so we do have a bit of time before that becomes something to be concerned about but you will see it in the error log if you don’t correct it now.

Preference Pane service controller

In order to get the Preference Pane controller to work (if you are getting the following error in /var/log/system.log – “Could not setup Mach task special port 9: (os/kern) no access”) you need to correct the permissions for the installation directory as such
(root@g5)-(/usr/local)-
shell> chown -R _mysql:wheel /usr/local/mysql*

This will still generate the ‘(os/kern) no access‘ message in the system.log but the server will be started/stopped by the pane controller and that’s what we really care about. There may be some more notes along the way as I’m going to be testing 5.4 quite a bit for various application related matters.

An easy method for hiding wordpress pages

I needed to hide a page from the page list – the header panel that shows all of the main site pages. Problem was that I needed it accessible to users via links but not listed in the main header. This page from a google search helped me out:

The last way is to hardcode your menu function. WordPress created the menu with this function: wp_list_pages();
You can either remove that function and add your own links, or add the "exclude" argument to wp_list_pages() like so:
wp_list_pages(exclude=17,38);

So my header.php code ended up looking like so:

$pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0&exclude=377');
$pages = preg_replace('%]+)>%U','', $pages);
$pages = str_replace('
','', $pages);
echo $pages;
?>

Bash Basics: Fun with the pipe

Of course there are better ways to manage security on webservers, but I was playing around with the apache error log file today and wanted to get all of the subnets for the script kiddies that are hammering on this dev box. A quick one liner and we’re done!

ROOT-(0)> grep "error" error_log |awk -F[ {'print $4'}| sort | sed -e 's/]//g' | grep -v "/var/www/html/" | grep -v "/usr/local/src/code" | awk {'print $2'} | grep -v "75.142.246.205" |uniq | awk -F. {'print $1"."$2"."$3"/24"'} |uniq
114.80.93/24
119.63.193/24
124.115.0/24
205.234.253/24
208.115.111/24
208.80.195/24
221.194.132/24
58.61.164/24
65.55.106/24
65.55.207/24
66.249.71/24
67.202.34/24
72.14.199/24
74.125.44/24
76.73.37/24
88.131.106/24
92.52.69/24

How to make an editable data grid using ExtJS

I’m not going to go into a great amount of detail here, but I will post the three files required for the process. If you know PHP (this uses the CodeIgniter framework) and JS (this uses the ExtJS framework) then it will make sense. Hopefully this saves people some time and will serve as a basis for a good project.

Model: http://themattreid.pastebin.com/fd163b0
View: http://themattreid.pastebin.com/f2a14ba54
Controller: http://themattreid.pastebin.com/f40599353

Kontrollbase gets a new default theme

I couldn’t take staring at the default theme anymore so I enabled the Slate CSS. Unless I get sick of this one, it will be the default from here on out. Maybe I’ll make a theme chooser at some point as well. Here’s a screenshot of the Slate theme enabled.  If you’re inclined to enable this on your older version it’s very simple. There are two files to touch: system/application/views/header.php and header_host.php

Add the following to line 41 on header.php and line 44 on header_host.php
<link rel="stylesheet" type="text/css" href="$nroot/includes/extjs/resources/css/xtheme-slate.css" />

If your line numbers are different, basically you just want that css file include to be directly below the “ext-all.css” css include file. If you break it then you probably did something wrong. I recommend making a backup of the files before editing just to be sure. Of course you’ll want to make sure that the “includes/extjs/resources/css/xtheme-slate.css” file exists before trying to include it.

Slate theme

Kontrollbase screenshots are posted

It’s taken a while – for no good reason – but the Kontrollbase screenshots are online for viewing pleasure. There are a couple of the overall environment as well as several of the host-specific pages. Check them out here: http://kontrollsoft.com/screenshots