An easier search with vim

Use incremental (search as you type) and case insensitive search in vim.

Edit ~.vimrc to add:

:set incsearch
:set ignorecase
:set smartcase
:set nu

ignorecase allow a case-insensitive search.  When smartcase is also used, it makes the search case-sensitive if the searched term contains an uppercase.

Thanks to Linux Magazine for the original article:

http://www.linux-magazine.com/w3/issue/85/Vim_Tricks.pdf

Allow not compatible extension in firefox 3.6

When upgrading firefox, I cannot use extension which have not been flagged as compatible with the new version yet (open book for example).

Just add an entry in the about:config page to let firefox run it (at your own risks )
Add a boolean entry:

extensions.checkCompatibility.3.6

and set it to

false

The syntax evlolved since firefox 3.6 (the version number was not mentionned explicitly before).
Refer to http://le-moulin-de-verre.com/fieldnotes/?p=111 for firefox prior to 3.6.

Mozilla reference: http://kb.mozillazine.org/Extensions.checkCompatibility

Monitoring EJB’s inside Glassfish V2

Interresting ressources regarding EJB monitoring in Glassfish 2.1.1:

http://docs.sun.com/app/docs/doc/820-4335/ablur?a=view

http://dlc.sun.com/pdf/820-4343/820-4343.pdf

KSH vi mode (auto complete)

Daily, I log into unix servers where the only installed shell is KSH.
I really miss the the auto-completion provided by the ‘tab’ key of BASH shells.

Something similar can be activated on KSH, by setting it to to the so called ‘VI’ mode.

set -o vi

in your .profile or .login scripts.
You can now enjoy the vi editor commands (and more) right from the command prompt.

To envoke the editor, simply hit the ESC key. Just like going from input mode to command mode inside of vi. Some of the more useful key strokes:

ESC+\ = autocomplete, will complete upto the non-unique character.
ESC+* = space delimited list of all files that match the pattern you started with.
ESC+/str = search the commandline history for str.
ESC+n = search for the next occurance of str.
ESC+k = go back one in the commandline history.
ESC+j = go forward one in the commandline history.
ESC+$ = go to the end of the current line
ESC+0 = go to the beginning of the current line
ESC+i = return to insert mode
ESC+A = append to the end of the current line
ESC+I = insert from the beginning of the current line
ESC+fx = move cursor to the right until the next occurance of x
ESC+Fx = move cursor to the left until the next occurance of x
ESC+x = delete character under cursor and place it in the buffer
ESC+p = place the contents of the buffer after the cursor
(combining the last two keystrokes)
ESC+xp = transpose two characters (I use this alot)

Allow connection sshd from other hosts

I set up an SSH server using Cygwin on windows. I was able to test it localy (ssh myAccount@localhost) but I encountered an error when trying from a distant machine.

ssh_exchange_identification: Connection closed by remote host

We have to allow connection from a distant machine inside /etc/hosts.allow on the server.
The syntax of this file is

<services separated by coma>:<hosts or IP separated by coma>[:command]

where command is the command to execute on a connection attempt

So I remove the PARANOID deny from the allow file (!?) and explicitly logged connection attempts from ssh.

# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
ALL : localhost 127.0.0.1/32 [::1]/128 : allow
ALL : PARANOID : deny
sshd: ALL
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
ALL : localhost 127.0.0.1/32 [::1]/128 : allow
# sshd: ALL
# same directive while keeping track of attemps
shd: ALL: spawn (echo "Attempt from %h %a to %d at `date` by %u" | tee -a /var/log/sshd.log)

Import oracle dump to a different tablepace

I encountered an issue while importing a oracle dump, and a nice workaround.

The situation:

We have two oracle users, each one with a specific tablespace (ORI_TSDATA for user ORI on ORI_SID, TARGET_TSDATA for user TARGET on TARGET_SID).
I want to export a dump of tables and data from user1 and import it inside user2 tablespace.

The export is made with the exp command (details here).

exp USERID=ORI/ORI_PASSWORD@ORI_SID File=ori.dmp LOG=export.log

The import is performed with

imp USERID=TARGET/TARGET_PASSWORD@TARGET_SID File=ori.dmp LOG=import.log FROMUSER=ORI TOUSER=TARGET

The issue:

Although we us the FROMUSER and TOUSER parameters in the import, the import utility is unable to migrate some tables to a different tablespace.

The migration works for tables using standard columns types, but not with the ones that contain LOB data (Binary objects).
In fact, the import utility tries to recreate the tables that contain BLOB in ORI_TSDATA (the exported tablespace) that does not exist in the target system.

IMP-00017: following statement failed with ORACLE error 959:
"CREATE TABLE "BINARY_CONTENTS" ("ID" NUMBER(19, 0) NOT NULL ENABLE, "CONTEN"
"T" BLOB NOT NULL ENABLE, "MIME_TYPE" VARCHAR2(255 CHAR) NOT NULL ENABLE, "F"
"ILE_NAME" VARCHAR2(255 CHAR) NOT NULL ENABLE, "FILE_SIZE" NUMBER(10, 0) NOT"
" NULL ENABLE)  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(INITIA"
"L 131072 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "ORI"
"_TSDATA" LOGGING NOCOMPRESS LOB ("CONTENT") STORE AS  (TABLESPACE "ORI_"
"TSDATA" ENABLE STORAGE IN ROW CHUNK 16384 PCTVERSION 10 NOCACHE LOGGING  ST"
"ORAGE(INITIAL 81920 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT))"
IMP-00003: ORACLE error 959 encountered
ORA-00959: tablespace 'ORI_TSDATA' does not exist

In fact, if you visualize the dump file, you will notice that LOB create statements explicitly mention the target Tablespace (ie the one you exported from) while other create statement do not mention them.

The official fix:

We should create a tablespace similar to the exported one (ORI_TSDATA) in the target server and migrate the tables to the target tablespace (TARGET_TSDATA) after the import. This cannot always be done, for example if ORI_TSDATA is already used for another purpose on the target server.

The workaround:

We can force the import to TARGET_TSDATA:

  • create the table structure in TARGET_TSDATA prior to importing the dump
  • use the ignore=yes parameter at import time

The import utility will ignore the warnings, and use the existing tables in TARGET_TSDATA to populate the data.

Use the ddl_create_tables.sql script if you have one or retrieve thetable creation orders from the dump otherwise.

imp TARGET_PASSWORD@TARGET_SID File=ori.dmp LOG=import.log FROMUSER=ORI TOUSER=TARGET IGNORE=y

Another workaround

We could edit the dump file with an editor like VI and replace the target tablespace names inside.

Improve Internet Explorer with Google chrome frame

Google just released a preview of Chrome Frame, a plug-in for Internet Explorer. It improves IE ‘s javascript capabilities and make it compatible with the new HTML 5.

This sounds very promising for corporate environments where IE 6 is required.

Read the announcement on the developer blog and download the plug-in on the Google Chrome Frame page.

Our rapid benchmark shows 60 x acceleration !

I made a quick javascript benchmark using the online sunspider tests  (http://www2.webkit.org/perf/sunspider-0.9/sunspider.html).

The results are impressive with more than 60 times acceleration (The global transaction passes from 35 seconds to 0.5 second) !

Have a look on the the  full results using a standard IE6 vs the same IE with the plugin.

The test configuration:

  • Microsoft Windows XP Professional Version 2002 Service Pack 3
  • IE version 6.0.2900.5512.xpsp_sp3_gdr.090206-1234

The only actual drawback is that windows 2000 is not yet supported.

Thanks to Cyril for helping me running the benchmark.

Edit: Chrome Frame plugin is usually lauched by using a specific meta tag in the HTML header. In case you need to force the use of chrome frame without changing the original site, you may trigger it by adding cf: at the begining of the url: (like cf:http://le-moulin-de-verre.com/fieldnotes/).

See the documentation for details


Adapt wordpress for mobile devices

WordPress mobile edition is a nice extension that adapts the blog interface to the constraints of mobile devices.

It detects when the blog is accessed from a mobile terminal and  adapts the display to this specific terminal. Made of two parts, a plugin and a specific theme, it’s pretty straightforward to install.
http://wordpress.org/extend/plugins/wordpress-mobile-edition/

Write and read to a samba shared directory using java (JCIFS)

Challenge of the day: publish a file to a microsoft shared directory and then re-read it.

Windows OSes rely on the SAMBA protocol to share files and directories. Thanks to the JCIFS project( http://jcifs.samba.org/), an open source library, we can access theses kind of shares via java.

Under linux, we could have performed it a the shell level using the SMBclient command line utility.

The example is pretty self explanatory, just remember to add jcifs-1.2.25.jar to your classpath and to adapt the authentication parameters to your real login in the url.

import jcifs.smb.*;
public class SMBClient {
  public static void main(String[] args) {
    try{
      // jcifs.Config.setProperty( "jcifs.netbios.wins", "192.168.1.220" );
      //smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]][?[param=value[param2=value2[...]]]
      String url="smb://domain;user_name:user_password@server_name/directory/test_file.txt";
      String content="hello !";
      SmbFileOutputStream out = new SmbFileOutputStream(url);
      out.write(content.getBytes());
 
      System.out.println("File written, now trying to re-read it:");
      SmbFileInputStream in = new SmbFileInputStream(url);
      byte[] b = new byte[10000];
      int n;
      while(( n = in.read( b )) > 0 ) {
        System.out.write( b, 0, n );
      }
    }catch(Exception e){
  System.out.println(e);
  }
 }
}

Thanks to Cyril for the challenge 🙂 and to the forums of developpez.net (in french) for an example.

Allow not compatible extensions in Firefox

The last version of firefox is out, but an extension that I use daily (QuickProxy) has not been updated yet. In fact, it should work but it is considered ‘not compatible’ by firefox and thus, is automatically de-activated.

The workaround (at your own risks !) is to bypass the security that enforces the compatibilty of extensions.

  • Open firefox and enter  “about:config” in the URL bar.
  • Right click in the page, then “new->boolean”
  • enter “extensions.checkUpdateSecurity” as the preference name in the dialog
  • set it’s value to false.
  • Create a similar entry called “extensions.checkCompatibility” set to false too.

Be careful when testing unsupported extensions, you may want to activate them one by one ! However do not hesitate to try, I have been able to succesfully use QuickProxy this way for more than a month….

For the record, the list of all the about:config options of firefox.

[EDIT:] The extensions.checkUpdateSecurityallow the download of extension without SSL, and is not related to firefox version check. It should remain to true http://kb.mozillazine.org/Extensions.checkUpdateSecurity.