-
Restrict a Linux User’s Access: Only Allowing SCP/SFTP, no SSH
The standard techniques for restricting a Linux user account, does not allow for file transfers to/from the user’s home directory. In my experience it is useful to have certain account types which are only allowed to upload/download files from their home directory; but not login and run shell commands. This is easy to do with…
-
Efficiently Loading Paginated Results From MySQL with Just One Query Per Page
There are many situations in which pagination of query results is very useful, especially for performance optimization. In most of these kinds of situations, the paginating of results requires you to determine the total number of results, so the application knows the number of pages available. The most common way to do this, is to…
-
Looking Towards Calmer Seas Ahead
For the first time in a long time, as far as software work is concerned at least, I’ve felt more and more like the Maytag Repairman. After many weeks up to my ears in customer issues; these hectic times may be drawing to a close, with more peaceful waters ahead. I remember when one of…
-
Writing Complex Web Apps With Google Web Toolkit (GWT)
The Google Web Toolkit (GWT) is a relatively new set of open source tools, developed by Google; which aims to allow developers to write much of the client-side code as Java. This Java code is then compiled into the appropriate JavaScript code, to run on the user’s web browser. Basically, the Google team has come…
-
Sending Mail in Shell Scripts via an External Server with Nail
If you’ve ever tried sending email via the command line, using the mail utility, you may find that the method can be unreliable in some cases. The email messages are often intercepted by spam bots, filtered by security programs, etc. A more elegant and stable alternative, is to use your existing email server to send…
-
Streaming Data as Downloadable Files in Struts Servlet
One way to stream data to the client, is to use the PrintWriter, a library which allows you to directly manipulate the output stream which is sent to the client. One of the benefits of streaming the output to the client with PrintWriter, is the ability to send data as it is generated; instead of…
-
Bash Shell Script to Convert All MySQL Tables to use the Innodb Engine
The following, when run in the Bash shell, will convert the engine for all of your MySQL tables to InnoDB. mysql -B -N -e “SHOW TABLES” -u –password= | while read table; \ do \ echo “+ Converting Table $table”; \ mysql -B -N -e “alter table $table engine=innodb” -u –password= ; \ done; Often,…
-
Copying Yesterday’s Exceptions with Stack Traces from Logs, Then Emailing To Administrators
When you have a java application server which generates a great deal of logs, it can be tricky to find the most important information, especially if you have detailed logging. Fortunately grep is capable of doing this very well. The following command will gather all WARN, ERROR, FATAL, and Exception stack traces. This command can…
-
Monitoring Process Counts and Alerting Via Email
Below is a simple script called monitor_jboss, which checks to see if jboss is running and whether or not too many instances are currently running. I found a need to write this script because we have some cron scripts which automatically restart JBoss each day and the JBoss shutdown script itself sometimes fails to properly…
-
Locating Duplicate Entries In A MySQL Table
If you don’t have unique indexes on your table, it is likely that you will occasionally have entries that are duplicated. This can often happen because of a software bug or possibly a user error. Some applications even choose not to have unique indexes for performance reasons; though this happens at the cost of data…