Stephen on Software aka SOS

November 10, 2009

Weblogic and Spring Security problems

Filed under: Programming — Tags: , — sljm @ 2:58 pm

When depolying Spring Security on Weblogic 10.3. I encountered 2 pop up one for Spring and one for Weblogic.

Spring Security was configured with basic authentication. If your used is not in Weblogic’s security realm basically you dont get access. Some people also faced the same problem and here are their solutions.

If you use the form base authentication, you should be fine. It just happens for those who use the default basic/digest forms that your web browser provides.

1. Configure web.xml

<login-config>
<auth-method>CLIENT-CERT</auth-method>
</login-config>

add the above to your web.xml.

2. Edit weblogic config/config.xml
Add the following lines to config.xml in your admin server.

<enforce-valid-basic-auth-credentials>
    false
</enforce-valid-basic-auth-credentials>

October 14, 2009

SICP Chapter 1.1 Exercises

Filed under: SICP — Tags: — sljm @ 11:20 am

Exercise 1.5

When using applicative order (1.1.3), the result is a never ending loop. Because when evaluating (test 0 (p)) the operator and the operands are evaluated that means the sub expression (p) is going to evaluate and since (p) is calling itself again, the result is a never ending loop

When using normal-order, since the operands are evaluate as needed, (p) is not going to be evaluated since the (if) statement will be true and so 0 is returned.

September 26, 2009

Slime and Offline Lisp Hyperspec

Filed under: Uncategorized — Tags: , — sljm @ 11:16 am

Just put the following in your .emacs files

(setq common-lisp-hyperspec-root "file:/usr/local/lisp/CLHS6/HyperSpec/")

There are lots of useful information in SLIME Features that are useful for those who are just starting out with SLIME.

September 8, 2009

Clojure and SLIME

Filed under: Uncategorized — Tags: , — sljm @ 8:45 pm

This is my setup for Clojure and SLIME on Emacs 23.1 and Windows Vista.

First download SLIME, clojure-mode and swank-clojure.

Locate your .emacs file. Look for ur %APPDATA% directory or create it if it is not there.

Unzip all the files to a directory, I used c:\lisp and rename the directories accordingly.

  1. SLIME in c:\lisp\slime
  2. clojure-mode in c:\lisp\clojure-mode
  3. swank-clojure in c:\lisp\swank-clojure
  4. clojure in m:\programming stuff\clojure

Just replace the directories with the ones you used.

The following is my .emacs file

(add-to-list 'load-path "c:/lisp/clojure-mode")
(add-to-list 'load-path "c:/lisp/swank-clojure")
(add-to-list 'load-path "C:/lisp/slime");Your slime directory

(setq swank-clojure-jar-path "m:/programming stuff/clojure/clojure-1.0.0.jar")

(require 'clojure-mode)
(require 'swank-clojure-autoload)
(require 'slime)
(eval-after-load "slime" (slime-setup '(slime-repl)))
(slime-setup)

August 24, 2009

this.wrap is undefined error – Ext JS Checkbox

Filed under: extjs — sljm @ 11:11 am

I am using Ext JS 2.2 and when you are setting Ext JS checkbox.setValue(something) before the checkbox is fully rendered you will get an “this.wrap is undefined” error.

The problem and fix is documented here. For a workaround with out changing any code, just make sure that you set the value of the checkbox in the Ext.onReady() portion and you should be ok.

August 20, 2009

Getting image name from urls, using the Content-Disposition header

Filed under: Programming — Tags: , — sljm @ 1:37 pm

You know when you visit some forums and when you click on a link like this http://thecelebrityspotlight.com/attachment.php?attachmentid=64134&stc=1&thumb=1, they open up an image file and when you right click and save some how the image name appears ? There are no clues in the url that tells you what the image name is suppose to be and somehow magically the browser knows.

Well it appears that the browser is looking for the Content-Disposition header in the Http Response. Jim Ley @ jibbering.com has a page Using the XML HTTP Request Object, that describe how to get the headers using the XmlHttpRequest object.

For Firefox this code snippet should work. Read his blog post for more information.

 var xmlhttp=new XMLHttpRequest();
 xmlhttp.open("HEAD", "/faq/index.html",true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
   alert("Content Disposition: "+
    xmlhttp.getResponseHeader("Content-Disposition"));
  }
 }
 xmlhttp.send(null)

August 19, 2009

Implementing File/Folder select for Firefox add-ons

Filed under: Uncategorized — Tags: — sljm @ 5:39 pm

To implement File/Folder select for firefox extensions you can look at the nsIFilePicker component.

To get the object:

var fp = Components.classes["@mozilla.org/filepicker;1"]
                   .createInstance(Components.interfaces.nsIFilePicker);

The object at this point is not initialized yet, you will need to use the init method to initialized it.

The method looks like this void init(parent,title,mode).

For parent you can use the window object that should be present. title is just the title of the file dialog, mode consist of any of the following valid values.

Constant Value Description
modeOpen 0 Load a file or directory.
modeSave 1 Save a file or directory.
modeGetFolder 2 Select a folder/directory.
modeOpenMultiple 3 Load multiple files.

Next you will need to call the show() method and check its return value to see if what the user pressed.

A sample of how to use;

const nsiFilePicker=Components.interfaces.nsIFilePicker;
fp.init(window,"My File dialog",nsIFilePicker.modeGetFolder);
var result=fp.show();
if(result == nsIFilePicker.returnOK || result == nsIFilePicker.returnReplace){
//do something
}

August 18, 2009

Getting the gBrowser object in Firefox

Filed under: Programming — Tags: — sljm @ 9:33 pm

Okies finally I have succumb and decided to do a Firefox add-on or extension to save open tabs that have documents/images inside, cause I am lazy to go one by one and save them.

So first step, try and get the tab browsers elements in the browser. In Firefox, there is a gBrowser object that if you can get it will help you to get all the browser tabs and their uris.

For the documentation, the only way that you can use gBrowser directly is that if you are under the scope of browser.xul when you are doing overlays. So for other windows like dialogs and sidebars, you will need to use window.opener.getBrowser method to get to the gBrowser object. If you look at the documentation for the window object, there is no mention of the getBrowser method, seems like the docs need some updating.

Look at the Getting access to the browser in the Tabbed Browser section of the MDC, you will find the various different methods for getting a gBrowser object.

August 7, 2009

Refreshing browser window when there is a resize event

Filed under: extjs — Tags: — sljm @ 5:19 pm

When I am using an ExtJS ViewPort, when I resize my window manually by dragging the window handles everything goes out of size so I needed a way to detect the window resize then refreshed the window.

First we need to create a function to refresh the window. That can be done using window.location.reload function. In ExtJS you can look at the Ext.EventManager.onWindowResize to add a listener to the onWindowResize event. Code is below.


function resize(){
window.location.reload
}

Ext.EventManager.onWindowResize(resize);

August 6, 2009

WPF Modal Windows

Filed under: Programming — Tags: — sljm @ 5:40 pm

Found this post that does a good job of showing how to do Modal Windows in WPF. Better than what I can explain anyway!

Links

Modal Dialogs in WPF

Older Posts »

Blog at WordPress.com.