Sunday, November 13, 2011
Illusion
This is another example of an amazing illusion!!! The last sentence is so true.
If your eyes follow the movement of the rotating pink dot, the dots will remain only one color, pink.
However if you stare at the black '+ ' in the center, the moving dot turns to green.
Now, concentrate on the black ' + ' in the center of the picture. After a short period, all the pink dots will slowly disappear, and you will see only a single green dot rotating.
It's amazing how our brain works. There really is no green dot, and the pink ones really don't disappear. This should be proof enough, we don't always see what we think we see.
Friday, November 04, 2011
Eclipse & Tomcat - Create a Webapp - Hello World Tutorial
Directory Structure under: C:\xampp\tomcat\bin\webapps\mytomcat-eclipse-helloworld-scratch List of Directories: \WEB-INF \WEB-INF\lib \WEB-INF\src \WEB-INF\src\java \WEB-INF\src\myeclipse \WEB-INF\classes \pages List of files: |
Eclipse IDE for Java Developers
XAMPP comes really handy with
Apache 2.2.21
MySQL 5.5.16
PHP 5.3.8
phpMyAdmin 3.4.5
FileZilla FTP Server 0.9.39
Tomcat 7.0.21 (with mod_proxy_ajp as connector)
At the time of this article tomcatPluginV33.zip
Extract the archive tomcatPluginV33.zip under C:\eclipse\plugins this should create a sub folder com.sysdeo.eclipse.tomcat_3.3.0
To give you the big picture, in the steps below, you will use Eclipse to
create the following directory structure and files.
This examples Tomcat "webapps" directory is located at:
C:\xampp\tomcat\bin\webapps
The Sysdeo Tomcat Plugin is our best friend. After you have installed it, you will notice these buttons and menues in your IDE.
The left button starts Tomcat, the middle button stops it, the right button restarts Tomcat. Right now, they won't work if you press them. To enable them, you first need to configure a few things. Go to the menu "Window-> Preferences" there, you will see this dialogue box.
Configure Tomcat Plugin
Windows-->Preferences-->Tomcat
Now you need to go to the menu item "Tomcat" and select your Tomcat version. At the time of writing that would be the 7.x version. Now we adjust the field "Tomcat Home" to point to the install directory that we selected before at install time. The Sysdeo plugin now knows where to look for the server.xml file and automatically assumes the standard path to look for the file. Eclipse is now able to manage this configuration file, i.e. add a new <context> for a new application
Browse for tomcat home and select tomcat version
Click on JVM settings and add JVM Parameters
-Xmx2000M
-Xms1000M
Now we are ready to test start our Tomcat server. Click on the start button in the Tomcat menu and watch the console output. If Tomcat boots up without any stacktraces open your browser, and try to open the following address http://localhost:8080/ . If you see an image
that is similar, to the one below everything is working okay
- 10 File, New, Project, Java Project, Next
- 11 Project Name: mytomcat-eclipse-helloworld-scratch
- 12 UnCheck - Use default location.
- 13 Click "Browse" and navigate to the Tomcat webapps"
directory (ex: C:\xampp\tomcat\bin\webapps\webapps). - 14 This is a little tricky so follow closely. We want to create a
new directory.
- Note: The "webapps" directory should be selected.
- Click "Make New Folder"
- In the browse window list, you should be able replace the words "New
Folder" with: mytomcat-eclipse-helloworld-scratch
Note: If you can't, in the browse window scroll to the "New
Folder" and right click, choose "Rename" and change the folder name to
mytomcat-eclipse-helloworld-scratch - Click "OK".
- Check the value of "Location:" to make sure you have selected the
correct folder.
Location should now show: C:\Tomcat\Tomcat6.0\webapps\mytomcat-eclipse-helloworld-scratch - Click "Next" to go to the "Java Settings" screen.
- 15 Source Folder
- Click "Create new source folder".
Folder name: WEB-INF/src
Click "Finish" - Right click on "src" and choose "Remove from Build Path".
Later you will delete the folder.
(Note: We just created the src file in a directory that web users
can't directly get to: WEB-INF/src)
- Click "Create new source folder".
- 16 Output Folder
- Change the "Default output folder" to: mytomcat-eclipse-helloworld-scratch/WEB-INF/classes
(Note: Currently the default will be:
mytomcat-eclipse-helloworld-scratch/bin)
- Change the "Default output folder" to: mytomcat-eclipse-helloworld-scratch/WEB-INF/classes
- 17 Click "Finish"
- 18 In the "Package Explorer" right click on "src" and choose delete.
- Right click on the project.
- Click "Build Path", "Configure Build Path", then
click the tab "Libraries" - Check to see if "JRE System Library"
is listed. If not complete the next steps in this bullet.
Click "Add Library", "JRE System Library",
"Next", "Finish".
Note: Under the tab "Order and Export" this lib file should be directly
under the WEB-INF/src directory.
You can't compile .java files without this library!!! - Click "Add External JARs"
- Browse to the Tomcat common library directory.
Ex: C:\xampp\tomcat\lib - Select all of the JAR files (Ctrl-A), then click "Open".
- Click "OK" to leave the "Java Build Path" screen.
- Right click on "WEB-INF", "New", "Folder".
- Folder name: lib
- Click "Finish"
- Library files - for this project we will be using 2 .jar files:
standard.jar & jstl.jar.
These 2 jar files need to reside in: webapps\mytomcat-eclipse-helloworld\WEB-INF\lib
mytomcat-eclipse-helloworld-scratch-lib.zip - download and extract this
zip file into the new "lib" directory you just created.
Note: If you downloaded the files in this tutorial you will have this
file in the directory:
Pathname: tomcat\tutorial_tomcat_eclipse\webapps\mytomcat-eclipse-helloworld-scratch-lib.zip
(Note: These lib files came from the Apache JSTL project called
"standard".)- If you don't place the files properly in the lib directory you will get
compile errors etc...
- Right click on "WEB-INF/src" (not
"WEB-INF"), "New", "Package".
Folder name: myeclipse - Click "Finish"
- Right click on "mytomcat-eclipse-helloworld-scratch",
"New", "Folder". Folder name: pages - Click "Finish"
- Right click on "WEB-INF" (not "WEB-INF/src"), "New", "File".
File name: web.xml - web.xml -
copy this content into the file. Right click on the filename, open
with, Text Editor. If you open with the XML editor you can't copy and
paste. After you copy-n-paste, then open with "XML Editor". - Notice the 2 tags: <servlet> & <servlet-mapping>. This is planning
for the .java servlet file we will create.
24 Create the "index.jsp" file
- Right click on "mytomcat-eclipse-helloworld-scratch", "New", "File".
File name: index.jsp - index.jsp -
copy this content into the file. (Warning:
If the server & browser doesn't show this file as a Text file then do a
view source so you can copy-n-paste.) - Note:
- This JSP has just HTML tags.
- Right click on "myeclipse"
under the directory "WEB-INF/src", "New", "Class".
Name: MyHelloWorldBean
Click "Finish"
MyHelloWorldBean.java -
copy this content into the file. (Warning:
If the server & browser doesn't show this file as a Text file then do a view
source so you can copy-n-paste.)
- Right click on "myeclipse"
under the directory "WEB-INF/src", "New", "Class".
Name: MyHelloWorldServlet
Click "Finish"
MyHelloWorldServlet.java -
copy this content into the file. (Warning:
If the server & browser doesn't show this file as a Text file then do a view
source so you can copy-n-paste.)
- Right click on "pages", "New", "File".
File Name: myhelloworld_jstl.jsp
Click "Finish"
myhelloworld_jstl.jsp -
copy this content into the file. (Warning:
If the server & browser doesn't show this file as a Text file then do a view
source so you can copy-n-paste.)
- Right click on "pages", "New", "File".
File Name: myhelloworld_bean.jsp
Click "Finish"
myhelloworld_bean.jsp -
copy this content into the file. (Warning:
If the server & browser doesn't show this file as a Text file then do a view
source so you can copy-n-paste.)
- 31 Start Tomcat and/or Reload this WebApp
- 32 Go to:
http://localhost:8080/mytomcat-eclipse-helloworld-scratch/pages/myhelloworld_jstl.jsp - 33 Go to: http://localhost:8080/mytomcat-eclipse-helloworld-scratch/pages/myhelloworld_bean.jsp
- 34 Go to: http://localhost:8080/mytomcat-eclipse-helloworld-scratch/MyHelloWorldServlet
- Using Eclipse, modify the following files then Reload the web app
or Stop/Start Tomcat. - filename: index.jsp
For the title & h1 tags change the following:
from:
mytomcat-eclipse-helloworld
to:
mytomcat-eclipse-helloworld-scratch - filename: WEB-INF\src\myeclipse\MyHelloWorldBean.java
from:
setStrMyMessage("Hello World");
to:
setStrMyMessage("Hello World - Hi"); - filename: WEB-INF/src/myeclipse/MyHelloWorldServlet.java
from:
<p>Hello World</p>
to:
<p>Hello World - Hi</p> - filename: pages/myhelloworld_jstl.jsp
from:
<c:out
value="Hello
World"/>
to:
<c:out
value="Hello World
- Hi"/> - Reload Web App or Stop/Start Tomcat Service
(because you changed a .java file!) - see steps
above! - Test your Web App again
Hello World (JSTL Example)
JSTL Example (c:out): Hello World
Hello World (JSP & Java Bean Example)
Bean Example MyHelloWorld.getStrMyMessage(): Hello World
Hello World (Servlet Example)
Hello World
35 Optional - Change Text - Hello World
Thursday, November 03, 2011
Matlab relative path issue in prj and MWArray.dll nightmare on Windows 7 64 bit
The main problem is that the .prj file which deploytool creates contains absolute paths which will not work on other computers!. This is really bad to see that this is still the case in MatLab R2011a.... Really! So I decided to use Visual Studio 2005 vcproj file to maintain my deployment project because Visual Studio 2005 project support relative path pretty damn well! Thank you Microsoft Visual Studio Team!. I decided to create a WIN32 utility using MFC to convert the relative path to absolute path using the vcproj file and generate a Matlab PRJ file. In my case I am targetting C# .Net Assembly. Here is the source code!
#define _CRT_SECURE_NO_DEPRECATE
#include "stdafx.h"
#include "vcproj2matlabprj.h"
#include
#include
#include
#include
#include
#include "xmlParser.h"
#include "win32utility.h"
CString RelativePathToAbsolutePath(LPCTSTR contentRelativePath,LPCTSTR rootPath, BOOL &bRelativePathToParentFolders);
void PrintFileName(XMLNode xNode,LPCTSTR pszRootFolder);
FILE *_pOutMakeFile = NULL;
#if !defined (WIN32)
#define _strdup strdup
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
CString strRootFolder;
CString strVCProjShortFilename;
CString csPath;
CString csFilenameNoExt;
CString csExtension;
CString strVCProj;
CString strMathlabProj;
CString strMathLabRootPath;
CString strClassName;
CString strNamespace;
if ( argc < 4 )
{
printf("Usage: %s
return 1;
}
XMLNode xMainNode=XMLNode::openFileHelper(argv[1],"VisualStudioProject");
strRootFolder = CString(argv[1]);
strMathlabProj = CString(argv[2]);
GetPathFromFileName(strRootFolder);
strVCProj = CString(argv[1]);
strVCProjShortFilename = CString(argv[1]);
strMathLabRootPath = CString(argv[3]);
GetFileNameComponents(strMathlabProj, // in
csPath, csFilenameNoExt, csExtension); // out
if ( xMainNode.isEmpty() )
{
printf("Not valid input file [%s]\n", argv[1]);
return 2;
}
XMLNode xNode;
xNode = xMainNode.getChildNode("Configurations");
// Try to open output file
_pOutMakeFile = fopen(argv[2],"w");
if ( _pOutMakeFile == NULL )
{
printf("Can not open output file [%s]\n", argv[2]);
return 3;
}
// Generate Header
fprintf(_pOutMakeFile,"\n");
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
strNamespace = csFilenameNoExt;
strNamespace.MakeUpper();
fprintf(_pOutMakeFile,"
strClassName = csFilenameNoExt;
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
// Print list of files
xNode = xMainNode.getChildNode("Files");
PrintFileName(xNode,strRootFolder);
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
//fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
fprintf(_pOutMakeFile,"
}
return nRetCode;
}
void PrintFileName(XMLNode xParentNode, LPCTSTR pszRootFolder)
{
CString strRootFolder = pszRootFolder;
int n=xParentNode.nChildNode();
for( int i = 0; i < n; i ++ )
{
XMLNode xNode = xParentNode.getChildNode(i);
if ( !strcmp(xNode.getName(), "File" ) )
{
const char *pcFileName = xNode.getAttribute("RelativePath");
char *pcNewStr = _strdup(pcFileName );
// Find the file extension
char *ext = strrchr(pcNewStr, '.');
if ( NULL != ext && !strcmp(ext, ".m"))
{
CString strFullFilename;
BOOL bRelativePathToParentFolders;
CString strRelativePath = pcNewStr;
if (IsCurrentDirPath(&strRelativePath))
{
CString strSubPath;
// remove .\ and append path
int pos = strRelativePath.Find("\\");
int len = strRelativePath.GetLength();
if ( pos > 0 ) {
strSubPath = strRelativePath.Right(len-pos-1);
}
// append
strFullFilename = strRootFolder + strSubPath;
}
else
{
strFullFilename = RelativePathToAbsolutePath(strRelativePath,strRootFolder, bRelativePathToParentFolders);
}
fprintf(_pOutMakeFile,"
}
free( pcNewStr );
}
else
{
PrintFileName(xNode,strRootFolder);
}
}
}
CString RelativePathToAbsolutePath(LPCTSTR contentRelativePath,LPCTSTR rootPath, BOOL &bRelativePathToParentFolders)
{
CString strContentPath;
CString strFullPath;
CString tempPath = _T("");
strContentPath.Format(_T("%s"),contentRelativePath);
tempPath.Format(_T("%s"),contentRelativePath);
// First let's convert to the right kind of path seps:
strContentPath.Replace('/', PATH_SEPARATOR);
CString fullPath = rootPath;
int sepIndex = fullPath.ReverseFind(PATH_SEPARATOR);
// put those together, and we've got our full path
if (sepIndex >= 0)
{
BOOL gotPath = FALSE;
CString strAbsoluteFullPath;
bool bRelativeUp = false;
CString beginStr = strContentPath.Left(3);
bRelativeUp = ( beginStr.CompareNoCase(REL_PATH_STR_WIN) == 0 || beginStr.CompareNoCase(REL_PATH_STR_MAC) == 0 || beginStr.CompareNoCase(REL_PATH_STR_UNIX) == 0 );
bRelativePathToParentFolders = bRelativeUp;
strFullPath = fullPath.Left(sepIndex + 1);
if (!strContentPath.IsEmpty() && strFullPath != contentRelativePath && bRelativeUp) {
CString extension;
int period = strContentPath.ReverseFind('.');
if ( period >= 0 )
extension = strContentPath.Right(strContentPath.GetLength()-period-1);
if ( (extension.GetLength() == 3) || (extension.GetLength() == 1)) {
//strContentPath.Replace(_T("..\\"), _T(".\\"));
CreateFullPath(&strAbsoluteFullPath, strFullPath, strContentPath);
strFullPath = strAbsoluteFullPath;
strFullPath.Replace('/', PATH_SEPARATOR);
gotPath = FileExist(strFullPath);
if (gotPath)
return strFullPath;
else
return CString(_T(""));
}
else
return CString(_T(""));
}
else
{
int sepIndex = strContentPath.ReverseFind(PATH_SEPARATOR);
if (sepIndex >= 0) {
// We have a full path already
gotPath = FileExist(strContentPath);
if (gotPath)
return strContentPath;
}
// We have a relative path (subfolder)
CString extension = _T("");
int period = strContentPath.ReverseFind('.');
if ( period >= 0 )
extension = strContentPath.Right(strContentPath.GetLength()-period-1);
if (extension.GetLength() == 3) {
// single file name no sub folder
strFullPath = strFullPath + strContentPath;
gotPath = FileExist(strFullPath);
if (gotPath)
return strFullPath;
else
return CString(_T(""));
}
}
}
else
{
strFullPath = fullPath;
}
strFullPath += tempPath;
return strFullPath;
}
This will solve the following issue :)
http://stackoverflow.com/questions/1790417/matlab-deployment-add-files-to-source-control
Now let's look at a sample Matlab script which can be converted to an assembly.
Follow the following link
http://www.mathworks.com/matlabcentral/fileexchange/12987-integrating-matlab-with-c
There is a big problem when targeting .NET 4.0 for a client referencing a generated assembly targeting .NET 4.0 as far as I am concerned which should be fixed ASAP by Mathworks. This problem still remains with Matlab R2011a.
A C# client targeting .NET 4.0 will not run on Windows 7 64 bit. When the C# client will try to instantiate the class wrapper for the generated Matlab assembly using new, an exception will be thrown. Only 32 bit OS such as the old Windows XP will support both the .NET Framework 2.0 and 4.0. But not Windows 7 64 bit running as 32 bit. There is a dependency with .NET 2.0 for MWArray.dll at least I can't find the v4 version anywhere under C:\MATLAB\R2011a. Because .NET Framework 2.0 won't install on Windows 7 64 bit, I highly request the Mathworks folks to release MWArray.dll for .NET 4.0 and create a dependency with the 4.0 version when building the assembly. I always check target 4.0 but the dependency is still the 2.0. Maybe this is a fallback and I am missing the 4.0 version or maybe it is not supported.
Deployment Runtime
http://www.mathworks.com/help/toolbox/compiler/f12-999353.html
Thanks!
Google engineer Steve Yegge let the frustration fly in a post regarding the Mountain View's plucky social network
Tuesday, November 01, 2011
Really adobe
Sept 13, 2011 10.1.1 Q Latest release. This a regular quarterly update with security enhancements, improvements to stability, and bug fixes.
Jun 14, 2011 10.1 Q This is a major update that provides security fixes, feature updates, and major enhancements such as Protected View for Acrobat.
Apr 21, 2011 10.0.3 OOC This patch fixes a vulnerability and provides an updated Flash player.
Mar 21, 2011 10.0.2 OOC This patch fixes a vulnerability and provides an updated Flash player.
Feb 8 2011 10.0.1 Q Numerous security fixes as well as improvements to Protected Mode, QTP support, Flash, and support for SCCM via newly released SCUP catalogs.
Convert Mathlab to C# assembly
Step 2 Install Visual Studio 2010
Step 3 native compiler
make sure you runmex -setup to select your target C++ compiler
Step 4 To create an Assembly launch Mathlab 2011
Select New Deployment Project then select the target Type
Step 5 Finally build .NET Assembly
The sub folder will contain the Assembly DLL and Native DLL
Small, simple, cross-platform, free and fast C++ XML Parser
Business Intelligence
TIMi added value
This project started from his frustration that he could not find any simple, portable XML Parser to use inside all my projects (for example, inside the award-winning TIMi software suite created by the Business-Insight company). Let's look at the well-known Xerces C++ library: The complete Xerces project is 53 MB! (11 MB compressed in a zipfile). In 2003, He was developping many small tools. He was using XML as standard for all my input/ouput configuration and data files. The source code of his small tools was usually around 600KB. In these conditions, don't you think at 53MB to be able to read an XML file is a little bit "too much"? So he created his own XML parser. His XML parser "library" is composed of only 2 files: a .cpp file and a .h file. The total size is 104 KB
Here is how it works: The XML parser loads a full XML file in memory, it parses the file and it generates a tree structure representing the XML file. Of course, you can also parse XML data that you have already stored yourself into a memory buffer. Thereafter, you can easily "explore" the tree to get your data. You can also modify the tree using "add" and "delete" functions
and regenerate a formatted XML string from a subtree. Memory management is totally transparent through the use of smart pointers (in other words, you will never have to do any new, delete, malloc or free)("Smart pointers" are a primitive version of the garbage collector in Java).
To the best of his knowledge, there exists no other "non-validating C++ XML parser" that is as simple and as powerfull.
Well Tiny XML is pretty powerful too!
Here are the characteristics of the XMLparser library:
Non-validating XML parser written in standard C++ (DTD's or XSD's informations are ignored).
Cross-plateform: the library is currently used every day on Solaris, Linux (32bit and 64bit) and Windows to manipulate "small" PMML documents (10 MB).
The library has been tested and is working flawlessly using the following compilers: gcc (under linux, Mac OS X Tiger and under many unix flavours), Visual Studio 6.0, Visual Studio .NET (under Windows 9x,NT,2000,XP,Vista,CE,mobile), Intel C/C++ compiler, SUN CC compiler, C++ Borland Compiler. The library is also used under Apple OS, iPhone/iPad OS, Amiga OS, QNX and under the Netburner plateform. To the best of my knowledge, i think that all plateforms are now supported.
The parser builds a tree structure that you can "explore" easily (DOM-type parser).
The parser can be used to generate XML strings from subtrees (it's called rendering). You can also save subtrees directly to files (automatic "Byte Order Mark"-BOM support).
Modification or "from scratch creation" of large XML tree structures in memory using funtions like addChild, addAttribute, updateAttribute, deleteAttribute,...
It's SIMPLE: no need to learn how to use dozens of classes: there is only one simple class: the 'XMLNode' class (that represents one node of the XML tree).
Very efficient (Efficiency is required to be able to handle BIG files):
The string parser is very efficient: It does only one pass over the XML string to create the tree. It does the minimal amount of memory allocations. For example: it does NOT use slow STL::String class but plain, simple and fast C malloc 's. It also allocates large chunk of memory instead of many small chunks. Inside Visual C++, the "debug versions" of the memory allocation functions are very slow: Do not forget to compile in "release mode" to get maximum speed.
The "tree exploration" is very efficient because all operations on the 'XMLNode' class are handled through references: there are no memory copy, no memory allocation, never.
The XML string rendering is very efficient: It does one pass to compute the total memory size of the XML string and a second pass to actually create the string. There is thus only one memory allocation and no extra memory copy. Other libraries are slower because they are using the string concatenation operator that requires many memory (re-)allocations and memory copy.
In-memory parsing
Supports XML namespaces
Very small and totally stand-alone (not built on top of something else). Uses only standard
Easy to integrate into you own projects: it's only 2 files! The .h file does not contain any implementation code. Compilation is thus very fast.
Robust.
Optionnally, if you define the C++ prepocessor directives STRICT_PARSING and/or APPROXIMATE_PARSING, the library can be "forgiving" in case of errors inside the XML.
He has tried to respect the XML-specs given at: http://www.w3.org/TR/REC-xml/
Fully integrated error handling :
The string parser gives you the precise position and type of the error inside the XML string (if an error is detected).
The library allows you to "explore" a part of the tree that is missing. However data extracted from "missing subtrees" will be NULL. This way, it's really easy to code "error handling" procedures.
Thread-safe (however the global parameters "guessUnicodeChar" and"strictUTF8Parsing" must be unique because they are shared by all threads).
Full Native Supports for a wide range of character sets & encodings: ANSI (legacy) / UTF-8 / Shift-JIS / GB2312 / Big5 / GBK.
Under Windows, Linux, Linux 64 bits & Solaris, they have additionnaly: Unicode 16bit / Unicode 32bit widechar characters support that includes:
For the unicode version of the library: Automatic conversion to Unicode before parsing (if the input XML file is standard ansi 8bit characters).
For the ascii version of the library: Automatic conversion to legacy or UTF-8 before parsing (if the input XML file is unicode 16 or 32bit wide characters).
The XMLParser library is able to handle successfuly chinese, japanese, cyrilic and other extended characters thanks to an extended UTF-8 encoding support, Shift-JIS (japanese) and to GB2312/Big5/GBK encoding support (chinese) (see this UTF-8-demo that shows the characters available). If you are still experiencing character encoding problems, he suggest you to convert your XML files to UTF-8 using a tool like iconv (precompiled win32 binary).
Transparent memory management through the use of smart pointers.
Support for a wide range of clearTags that are containing unformatted text:
{![CDATA[ ... ]]}, {!-- ... --}, {PRE} ... {/PRE}, {!DOCTYPE ... }
Unformatted texts are not parsed by the library and can contain items that are usually 'forbidden' in XML (for example: html code)
Support for inclusion of pure binary data (images, sounds,...) into the XML document using the four provided ultrafast Base64 conversion functions.
The library is under the Aladdin Free Public License(AFPL).
A small tutorial
Let's assume that you want to parse the XML file "PMMLModel.xml" that contains:
( all < replace by { and all > replace by } )
{?xml version="1.0" encoding="ISO-8859-1"?>
{PMML version="3.0" xmlns="http://www.dmg.org/PMML-3-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema_instance"}
{Header copyright="Frank Vanden Berghen"}
Hello World!
{Application name="<Condor>" version="1.99beta" /}
{/Header}
{Extension name="keys"}
{Key name="urn"}{/Key}
{/Extension}
{DataDictionary}
{DataField name="persfam" optype="continuous" dataType="double"}
{Value value="9.900000e+001" property="missing" /}
{/DataField}
{DataField name="prov" optype="continuous" dataType="double" /}
{DataField name="urb" optype="continuous" dataType="double" /}
{DataField name="ses" optype="continuous" dataType="double" /}
{/DataDictionary}
{RegressionModel functionName="regression" modelType="linearRegression"} {RegressionTable intercept="0.00796037"}
{NumericPredictor name="persfam" coefficient="-0.00275951" /}
{NumericPredictor name="prov" coefficient="0.000319433" /}
{NumericPredictor name="ses" coefficient="-0.000454307" /}
{NONNumericPredictor name="testXmlExample" />
{/RegressionTable}
{/RegressionModel}
{/PMML}
Let's analyse line by line the following small example program:
#include
#include
#include "xmlParser.h"
int main(int argc, char **argv)
{
// this open and parse the XML file:
XMLNode xMainNode=XMLNode::openFileHelper("PMMLModel.xml","PMML");
// this prints "
XMLNode xNode=xMainNode.getChildNode("Header");
printf("Application Name is: '%s'\n", xNode.getChildNode("Application").getAttribute("name"));
// this prints "Hello world!":
printf("Text inside Header tag is :'%s'\n", xNode.getText());
// this gets the number of "NumericPredictor" tags: xNode=xMainNode.getChildNode("RegressionModel").getChildNode("RegressionTable");
int n=xNode.nChildNode("NumericPredictor");
// this prints the "coefficient" value for all the "NumericPredictor" tags:
for (int i=0; i
// this prints a formatted ouput based on the content of the first "Extension" tag of the XML file:
char *t=xMainNode.getChildNode("Extension").createXMLString(true); printf("%s\n",t);
free(t);
return 0;
}