Drop all tables in MySQL (part 2)

Submitted by Jochus on Mon, 17/05/2010 - 11:22 | Posted in: Database
Posted in

Funny, last week I made this blogpost. Today, I had to do the same, but for a MySQL 5.x database.

As I didn't wanted to start a MySQL client, I wrote a small bash command to perform the operation for me:

<a href="mailto:jochen@baileys">jochen@baileys</a> $ mysqldump -u ##USERNAME## -p##PASSWORD## --add-drop-table --no-data ##DATABASE## | grep ^DROP | mysql -u ##USERNAME## -p##PASSWORD## ##DATABASE##

What does this command do?

  • dump your database to the STDOUTPUT, with ADD-DROP lines, but don't export data, only DDL
  • grep all lines which start with the "DROP" statement
  • pump these lines to your mysql client (which I start on command line)

Network bridging between a wired and wireless connection in Ubuntu

Submitted by Jochus on Sat, 15/05/2010 - 10:13 | Posted in: Linux
Posted in

A lot of people are contacting me about this thread I've once started in the past. This thread is about bridging a wired and wireless connector in Ubuntu.

There were a lot of replies, and I could try a lot of things ... but unfortunately, I was never able to fix this problem :-( ... The only solution I have, is written here: http://wiki.jochus.be/index.php/Linux/Bridging_alternatief => yes, I should translate this page :p ...
Basicly, what it does: I'm assigning different subnets to the two networks and I use IP forwarding to make them communicate. This isn't a very good solution, as the clients need some extra configuration too ...

But anywayz, if somebody was able to fix it, please let me know. I know there are a lot of people searching for a solution :-) !

Drop all tables in Oracle DB (scheme)

Submitted by Jochus on Mon, 10/05/2010 - 23:47 | Posted in: Database
Posted in


Imagine you have a list of tables in your Oracle DB and you want to drop them all using a client like SQLDeveloper. That's easier said then done, as you have to drop each table individually.

Therefore, I wrote a SQL query that generates a "DROP-sql-script":

SELECT 'DROP TABLE "' || TABLE_NAME || '" CASCADE CONSTRAINTS;' FROM user_tables;

  • user_tables is a system table which contains all the tables of the user
  • the SELECT clause will generate a DROP statement for every table

This will generate something like:

DROP TABLE "FOO" CASCADE CONSTRAINTS;                    
DROP TABLE "BAR" CASCADE CONSTRAINTS;         
DROP TABLE "DUMMY" CASCADE CONSTRAINTS;         
...

Now you can easily run that script :-)

Creating a dropdown box with no default selection label (Seam JSF controls)

Submitted by Jochus on Thu, 06/05/2010 - 23:58 | Posted in: Java
Posted in


Everybody knows the dropdownbox. You can see it in the image at the left of your screen. It's very easy to create it with Seam:

<h:selectOneMenu value="#{criteria.name}" id="name">
    <s:selectItems var="name"
        value="#{nameManager.getNames()}"
        label="#{messages[nameManager.getKey(name)]}"/>
    <s:convertEnum />
</h:selectOneMenu>

The class NameManager has a method getNames() which returns a a list of enums. The s:convertEnum tag will convert the enum to a text based String. The label attributes is used to translate the name in the correct language (with help of the getKey() method of course, which will return a String).

Now, my problem was that there was a default label (the empty String), and I wanted to be one of the select items to be selected by default.
Easy said, easy done. In your backend, make sure #{criteria.name} is initialized to an enum which holds the default value.

So with this change, one of the select items was selected by default. The problem was: the empty label was STILL there!
After doing some research, I noticed I had to specify the hideNoSelectionLabel : true.

So my code would look like:

<h:selectOneMenu value="#{criteria.name}" id="name">
    <s:selectItems var="name"
        value="#{nameManager.getNames()}"
        label="#{messages[nameManager.getKey(name)]}"
        hideNoSelectionLabel="true"/>
    <s:convertEnum />
</h:selectOneMenu>

... but still, the no selection label was visible :-). The final trick I had to do, was to specify the h:selectOneMenu to required

<h:selectOneMenu value="#{criteria.name}" id="name" required="true">
    <s:selectItems var="name"
        value="#{nameManager.getNames()}"
        label="#{messages[nameManager.getKey(name)]}"
        hideNoSelectionLabel="true"/>
     <s:convertEnum />
</h:selectOneMenu>

Problem solved :-) !

Mozilla Firefox and slow HTTP requests in Ubuntu Karmic Koala (9.10) [ part 2 ]

Submitted by Jochus on Fri, 30/04/2010 - 19:35 | Posted in: Linux
Posted in

The problem I described earlier wasn't totally solved after the about:config change (although things went better ...)

Yesterday, I solved the problem but I wanted to be sure the problem didn't come up again :-).

The problem is situated in a broken profiles directory:

<a href="mailto:jochen@baileys">jochen@baileys</a> ~/.mozilla/firefox $ ls -al
total 24
drwx------ 4 jochen jochen 4096 2010-04-29 09:08 .
drwx------ 5 jochen jochen 4096 2010-02-09 15:29 ..
drwx------ 8 jochen jochen 4096 2010-04-29 09:07 56r3yu4x.default
-rw-r--r-- 1 jochen jochen   94 2010-04-29 09:08 profiles.ini

Solution

  • stop Firefox
  • move 56r3yu4x.default and profiles.ini to a backup folder
  • start Firefox
  • ... problem should be fixed now :-)

How to find a keyword in a list of files (recursive) ?

Submitted by Jochus on Thu, 29/04/2010 - 22:03 | Posted in: Lifetime
Posted in

Arghhh ... everytime I need this, I always have to Google it. Dunno why, but I'm not able to remember it :-). I want to have a list of files (just the path/name) which contain that keyword

The correct command is:

$ find . | xargs grep '##KEYWORD_YOU_WANT_TO_LOOKUP##' -sl