Install Firefox Java Plugin on Linux


This is silly but not super obvious and not easy to find on the interweb thingie searches come up with Oracle’s solution about linking the libjavaplugin_oji lib in the Mozilla plugins dir:

<Java installation directory>/plugin/i386/ns7/

which does not work for me. The way to get this going is to create a link to the libnpjp2 library in the Mozilla plugin directory as follows:

ln -s /<Java installation directory>/jre/lib/i386/ /usr/lib/mozilla/plugins/

Recursive Grep Example

Nothing really needing explaining here, but wanted an example for doing a recursive grep handy as I can never remember it.


grep -RH –include “*.java” TEXT_I_AM_LOOKING_FOR *


use vi editor to insert newline char in replace

Something else I have to do and cannot remember and then have to look up.

In vi to insert a newline character in a search and replace, do the following:


the command above would replace all instances of “look_for” with “replace_with\n” (with \n meaning newline)

to get the “^M”, enter the key combination “ctl-V” then after that (release all keys) press the “enter” key.

Add a Field to Web-to-Lead form

I often have to modify a site that uses for their form handling, and it can be quite a lot to keep in one’s head sometimes. It also is difficult to explain to someone else in a mail or over the phone when you need them to do something for you, so I am going to start posting here each explanation I give out. One day maybe I will have a simple guide to the basics of

Today’s task is to add a couple of fields on a form, as well as adding these to the salesforce database and confirmation emails etc. Here we go.

login to
choose setup (upper right corner)

first step is to add the new fields to the database, adding a check box for Mon and Tues in this case, and I use a special prefix and name scheme for fields I create, so these will look like MyPrefix_AvailableMon and MyPrefix_AvailableTues. Note the actual prefix is different in my case, and should be as the others are, which will be obvious when looking at them

under app setup (on left side) open Leads
choose fields
scroll down to “Lead Custom Fields & Relationships”
choose New
choose type (checkbox in the case of the days of the week to add)
choose next
enter a label and name (MyPrefix_AvailableMon/MyPrefix_AvailableMon and MyPrefix_AvailableTues/MyPrefix_AvailableTues in our ccase)
choose next, then next again, to complete, accepting the defaults
choose save, or if making more “save and new”

Next we will get the HTML for the new controls to add to the TFK site

under App Setup again, on the left, under leads, choose web-to-lead
choose the button in the middle of the screen “create Web-to-lead”

hi-light any fields in the box “Selected Fields” and use the arrow to the left of the box to move them out of selected and back to “available fields”

Next scroll down in the available fields and choose your new fields, hi-light them then use the arrow button to the right to move your new fields to the “selected fields” box

then choose the “generate” button in the middle of the page, below the two boxes you have been working in

Scroll down and copy only the HTML elements for the two new fields you created. In our case these look like this:

MyPrefix_AvailableMon:<input id="00N50000001yAWZ" name="00N50000001yAWZ" type="checkbox" value="1" /><br>

MyPrefix_AvailableTues:<input id="00N50000001yAWa" name="00N50000001yAWa" type="checkbox" value="1" /><br>

and save this text, you will need to add it to the form on the site with the forms later.

next we need to add the new fields to the mails that come to us and the confirmation mails that go to the person that filled in the form

on the bar on the left, under “Personal Setup” choose “My Templates”

choose edit next to the email template that you wish to add the field to. These are related to the page you wanted to add the field to. There are two templates for each page, one for the mail to us, with all the data, and one that is a confirmation to the person filling in the form. In this case it is for a “volunteer signup” to choose now.

Choose “edit”, next to the signup page template

You will see a somewhat cryptic way they add the fields to the form, for instance the other days of the week are show like:

Wed: {!Lead.MyPrefix_AvailableWed__c}

so there is this !lead. before our field name. and the __c afterward. We can just copy this for our purpose of adding just a couple new fields, and these end up like:

Mon: {!Lead.MyPrefix_AvailableMon__c}
Tues: {!Lead.MyPrefix_AvailableTues__c}

choose save

Then choose edit next to the confirmation page for the signup page, and add the same fields to that page as you did above.

That is all for Next edit the HTML form on your site that submits to the web-to-lead page and add the two fields you saved a while back

These as you will recall looked like:

MyPrefix_AvailableMon:<input id="00N50000001yAWZ" name="00N50000001yAWZ" type="checkbox" value="1" /><br>

MyPrefix_AvailableTues:<input id="00N50000001yAWa" name="00N50000001yAWa" type="checkbox" value="1" /><br>

but you might want to change the label, add styles etc. to match the page, so just remember to keep the id and name as you have got from the web-to-lead generation page.

Get PS to display the complete path (on Linux)

Something else I can never remember and waste time looking up is how to display long long long paths when looking at processes with “ps”. Well just a couple of “W” does the trick.

ps -auxww

More on why, later but wanted to put it down while it was fresh

Apple/Mac – Convert Picture Clipping ( pictclipping ) image to PNG, JPEG, etc

UPDATE 2011 March 8: A commenter reports dragging the pictcliped image into PowerPoint allows you save the image from there, possibly in other formats. I cannot test this as I do not have this setup. It appears however that the latest version of iTunes, at least, no longer creates these when copying album art out of the app.

UPDATE 2010 July 4: This process no longer works with 10.6 (.3 for me) as reported by readers. It seems that Apple found this feature and killed it. However there is a simple workaround.  See the section for 10.6.3

For versions of OSX up to 10.6:

So a little annoying feature of some Apple/Mac apps is the creation of a image in the format “pictclipping”. Converting these to something usable is not so intuitive so I am posting it here as to be easily located for myself if for nobody else (though I imagine others are looking for this from time to time).

Anyway, the easiest way to do this seems to be to use the clipboard and the “Preview” application.
To do the conversion in this way, first double click the pictclipping image to open it in the finder. Next from the Finder’s “Edit” menu choose “Copy”. Next, launch the “Preview” application and from the “File” menu choose “New from clipboard”. Then using the “File” “Save as” menu options, save as any image type you like.

Pretty simple, but not something I would have thought of right away.

For versions of OSX after 10.6:

Ok, so it seems Apple did not like the feature of being able to coy a Picture Clipping so easily, using their own software. I have tried to figure out a solution and did some searching but without some purchased software, so far, it seems this is not possible. However, here is something you can do to hold you over till something is discovered.

Right click on the Picture Clipping, in the Finder, choose “Quick Look [NAME OF YOUR PICTURE CLIPPING HERE]”  to view the full sized image in the Finder Quick Look previewer app. Then use the selective screenshot tool to grab just the image. If not familiar with this process: with the Picture Clipping image up, choose the [command] key at the same time as the [shift] key and then press the [4] key. This will bring up a small crossed lines (not sure how to explain it, think crosshairs for targeting something) pointer. Use this to hilight just the portion of the picture clipping in the preview that you wish to copy. When you release the pointer this image will be on the desktop as a PNG file with a name like “Screen shot 2010-07-04 at 5.16.53 AM”. Simply rename this file to something useful like “my-album-art.png” and you are done.

Hope something better appears. I will keep looking for something.


Determine if a String is XML using Java and Regular Expressions

So again I am posting something I have to do every now and then and have to spend time, each time, to check the pattern or usage etc. for.

Once in a while, in an app that does not do much XML, and therefore is not already using an XML parser of some kind, will need to at the least, determine if a String is XML. With a pretty simple Regular Expression, it is possible using plain old Java and without using any specific XML technology.

I know there are other references out there for doing this, but it is here below as a code sample, for my easy reference and maybe it will help someone else out, who knows. Enjoy.

Are we XML (like) data? :

import java.util.regex.Pattern;
import java.util.regex.Matcher;

public class test {

     * return true if the String passed in is something like XML
     * @param inString a string that might be XML
     * @return true of the string is XML, false otherwise
    public static boolean isXMLLike(String inXMLStr) {

        boolean retBool = false;
        Pattern pattern;
        Matcher matcher;

        final String XML_PATTERN_STR = "<(\\S+?)(.*?)>(.*?)</\\1>";

        // IF WE HAVE A STRING
        if (inXMLStr != null && inXMLStr.trim().length() > 0) {

            // IF WE EVEN RESEMBLE XML
            if (inXMLStr.trim().startsWith("<")) {

                pattern = Pattern.compile(XML_PATTERN_STR,
                Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);

                matcher = pattern.matcher(inXMLStr);
                retBool = matcher.matches();
        // ELSE WE ARE FALSE

        return retBool;