MySQL – A simple script to truncate all MySQL tables in a Database

girl using imac

Want a quick and dirty way to Truncate all the tables in a MySQL DB?  You can use the following one line script.

mysqldump -ppassword YourDBName –no-data dumpfile | mysql dumpfile

What this does is uses mysqldump to output all the tables in the database “YourDBName” into a dump file.  This dump file contains drop statements, and create table statements for each table in the database.  What this effectively does is drops every table, and recreates it WITHOUT any data inside.  Be very careful, since this is a very powerful script, it has the ability to completely wipe out your database with no hope of recovery unless you have a current backup.

For additional ways to execute specific commands against all tables in a DB, look into using mk-find in Maatkit, it is an excellent tool for advanced MySQL scripting.


MySQL – Select rows from a table when a field starts with a number

girl drawing database

A common request is how to select records from a table when a specific field starts with a number. This request often is used when searching free-form text fields where the fields were used to provide an answer field to a question.

The simplest way to attack this is by using a regular expression. For example:

SELECT * FROM BadlyDesignedTable WHERE AnswerColumn regexp ‘^[0-9]+’;

or
SELECT * FROM BadlyDesignedTable WHERE AnswerColumn RLIKE ‘^[0-9]+’;

Regex and RLIKE are compatible keywords that both represent regular expression matching.

The regex is described as follows :

^    – Start anchor, used to ensure the pattern matches start of the string.
[    – Start of character class.
0-9  – Any digit
]    – End of character class


Topgun Days by Dave “Bio” Baranek – The Truth Behind Topgun and Top Gun


I recently had the chance to read the book Topgun Days by Dave “Bio” Baranek.  As many readers of this blog know, Topgun is the United States Navy Strike Fighter Tactics Instructor program, created during the height of the Vietnam War.  The Navy had been concerned about the high number of US aircraft losses, and believed that the Ault Report (written by USN Captain Frank Ault) revealed an inadequacy in air combat maneuvering skills among Naval aviators (and Air Force too!).  From this report, Topgun was born, and it was later introduced to the general public through the movie Top Gun starring Tom Cruise.

Dave “Bio” Baranek does an excellent job providing a behind the scenes peek into the real Topgun experience.  While providing an overview of his days as a Grumman F-14 Tomcat Radar Intercept Officer (RIO), Bio highlights his initial training in the Topgun program, and then onto his role as an official Topgun instructor.  The story starts with Bio’s becoming a brand new Naval Flight Officer ensign fresh out of flight training, and a quick squadron tour and two deployments.  Bio suddenly finds himself shipped back state side so that he can enter the Topgun program, what many feel is the ultimate opportunity for a Navy Fighter Pilot/RIO.  What follows is an excellently told story of the real way that Topgun operated, the personalities of those involved, and the hard work required to succeed.

Shortly after graduating Topgun, Bio finds out that he was one those who’s name ended up on the “Wish List”, the list of student who performed so well that they were to be invited back as an instructors.  And as an instructor, Bio was fortunate to be at Topgun while the filming of Top Gun with Tom Cruise was also occurring. Bio provides great insight into all that went into making the movie from their perspective.  The impressive work that the Navy and Paramount did in filming the breath-taking scenes in the movie is described in detail.  And the author also shares a number of personal stories that provide an entertaining view into what it must have been like to live the Top Gun experience while also trying to share it with the rest of the work.

This book was written for a wide-ranging audience, military aviation history buffs will get something out of it, as will those who don’t know a F-14 from a F-15. Dave Baranek’s writing is straight-forward, told from the perspective of one who actually lived the experience, and entertaining enough to force you to keep turning the pages to see what happens next.  I recently had the opportunity to exchange some e-mails with the author, and he comes across as a nice guy with a typical high-energy military manner, excited about what he has done, and a true aviation fan.  I look forward to his future works…

If you click the link above, you can buy the book at Amazon, the perfect gift for a friend, family, or just for yourself!

 

 

 

 

 

 


Infiniti G35x – The ABS, VDC, AWS, and SLIP Lights all on

The other morning I get into my Infiniti G35x and as I head out the driveway, I notice that my ABS, VDC, AWD, and SLIP lights are all illuminated. This is not a good situation, as luck would have it, the areas first snow storm was expected later that day. The car drove normally during my 35 mile commute, however I was able to determine that yes, the car was only in RWD mode, and the traction control was not operating. After searching on the web, I found a couple suggestions, including low brake fluid. As I drove over to the local auto parts store at lunch, I was pretty sure that was not going to be the issue. As I pulled into the parking lot, I suddenly remembered that I had run over some twigs in the road the night before. Thinking maybe something got stuck in the wheel, I turned the front wheel all the way to lock.

Imagine my surprise to see the left wheel wheel filled with a black plastic fencing material that had wrapped thousands of times around the front drive shaft. Clearly this was the issue, either it was causing the wheel sensor to not work, or it had ripped out the wiring to the wheel sensor. After jacking up the front end and removing the left wheel, I spent the next 30 minutes cutting and unwrapping a very large amount of plastic fencing from around the drive shaft. I noticed that the front wheel sensor is a press-fit into the wheel hub where it extends out close to the ring around the wheel hub that is used to measure wheel speed. The sensor had been pushed out, which increased the distance from the hub ring enough so that it would not function.

The Infiniti’s ECU uses the wheel speed sensor to determine if a wheel is locked up or spinning at a different rate from the other wheels. This is what allows it to control the ABS (anti-lock brakes) and VDC (Vehicle Dynamic Control – Traction Control). The ECU is also smart enough to disengage the all-wheel drive if these systems are not functioning properly.

Once I pushed back the sensor, the ECU again realized that it was receiving signals from the wheel sensor, and all the warning lights went out. So, if you have all of these warning lights illuminate at one time, and you know your brake fluid is topped off, check your wheel sensors. They may have been dislodged, the wiring damaged, or they may simply have failed. A quick inspection could save you thousands of dollars in repair bills.  In the following diagram, item 8 is the wheel speed sensor.


Exiting a MySQL Stored Procedure in the middle of the code

girl pointing at computer
While exiting a MySQL function is fairly straight-forward, simply use the RETURN keyword, exiting a Stored Procedure is not quite as obvious.  There is no EXIT keyword, however you can use the LEAVE keyword and specify a label that is associated with the BEGIN of the Stored Procedure.  In this way, you are defining the Stored Procedure with a Label, which the LEAVE statement can then act upon.

As an example, look at the following Stored Procedure :

CREATE PROCEDURE TestProc(Value INT)

ThisSP:BEGIN

IF  Value is null or Value=0 then
Select ‘Invalid Value’;
LEAVE ThisSP;
END IF;

Select * from Table twhere t.Value=Value;

END;


Google Chrome’s new False Start “Feature”

Girl in white tank top working on laptop computer

In the past few weeks, millions of Google Chrome users have started to experience issues accessing isolated web sites. These users are typically accessing sites using HTTPS, and have often successfully accessed these sites in the past, but no longer can. Accessing these sites using Internet Explorer or FireFox are successful. When attempting to access the site, Chrome will just spin forever attempting to load the page, or will display an Error 101 (net::ERR_CONNECTION_RESET): Unknown error.

So, what is happening?

Google Chrome now has a “feature” called False Start that is designed to speed up secure communications over SSL and TLS. False Start eliminates one of the round-trip messages needed to set up a secure channel between a Web browser and Web server. While this is a nice little improvement to speed up sites that use HTTPS, many web sites do not yet support the ability to handle False Start, and this is why the pages will not load. Chrome has a built-in set of sites that it knows does not support False Start, and Chrome disables False Start when communicating with them. However, it is clear that Google appears to underestimate the number of sites this issue is affecting. In particular, we are getting reports from lots of people who use private internal web applications that can no longer work with Chrome. Even when a web server (Apache, IIS, Tomcat) is updated, it seems as if many load balancers are still running very old versions of software. If they have not been updated recently, and SSL/TLS negotiation is handled at the load balancer level, you will have issues. A10 Networks only recently updated their code, and it is unclear what version of F5 BigIP supports False Start.

What can you do?

if you control the servers, make sure your server and load balancer version are up to date. Complain to vendors who are not yet supporting False Start. If you are using Chrome to access a web site that you do not control, you can use Chrome command line options to allow Chrome to access offending websites.

First Option is –use-system-ssl. This forces Chrome to use your systems SSL library (Windows-SCHANNEL) rather than Chrome’s built-in NSS.

You must specify –use-system-ssl in the command line, without extra spaces inside. Your shortcut should look like : “C:\…blahblah…\chrome.exe” –use-system-ssl

Second Option is –disable-ssl-false-start. This forces Chrome to not use False Start, but still use internal NSS stack.

You must specify –disable-ssl-false-start in the command line, without extra spaces inside. Your shortcut should look like : “C:\…blahblah…\chrome.exe” –disable-ssl-false-start

Leave me a message if you use Chrome and have been bitten by this “feature”