Monday, January 31, 2011

Windows con mistary

Have you even try this:

In Windows, should you run such a thing, create a new folder. Try and give it the name 'con'.

Can't be done, can it?


Why we can't create a folder named 'con' in windows?

May be below is one reason, i'm also not sure about it-

It's not that weird. 'con' is a reserved word from the old DOS days, simply meaning 'console'. If you wanted to create a new text file in DOS you could type 'copy con newfile.txt' meaning copy from the console to newfile.txt. This would let you type some lines and when you ended the file with ^Z (DOSish for 'end of file') you would have a file called newfile.txt containing whatever you wrote in the console. This is indeed still possible in the Windows XP console, and can you see what mess it would cause if you let files or folders have the name 'con'? What would 'copy con newfile.txt' then mean?

Giving this list of other DOS devices that can't be used as folder names:
CON, PRN, AUX, CLOCK$, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.

Sunday, January 23, 2011

Customized uploadify in Zend

Customized upload button in uploadify


In uploadify web site they give a good example that how can you hide the default button and apply your customized css . I'm going to show you how can you place anchor tag instead of button, Its not a new thing but might be helpful for someone. I face this problem when i have to give link which have similar functionality like uploadify button.


What i did is just by CSS below is the code and explanation, please let me know if you find any other issue related to this one and off course please appreciate if find useful :)


In page.phtml






$('#upload_file').uploadify({

//

..........

......

'auto' : true,

'hideButton' : true // We need it for custom browse button

});




in uploadify .css


#upload_fileUploader {

background: none;

z-index: 2;

position: absolute;

margin-left: 5px;

width: 40px;

}


#upload_file {

display: inline;

}


#upload_file a {

position: absolute;

padding-left: 5px;

}



Its done. :)


few things that i have to mention, overlap a upload button with href mainly depends on few CSS steps:

(a) First and most important is z-index

(b) position

(c) display


Hope it helps for you.



How to Enable USB drive

How to enable/disable USB drive?




On the desktop, right click on MY COMPUTER, and then select MANAGE option. a new window will appear, in that select SYSTEM TOOLS, in that click on DEVICE MANAGER, on the right side of the window pane, a list will appear,

that will show u the components attached to your system, in that select the USB port, right click and disable the port.


If a USB storage device is not already installed on the computer

If a USB storage device is not already installed on the computer, assign the user or the group and the local SYSTEM account Deny permissions to the following files:

• %SystemRoot%\Inf\Usbstor.pnf

• %SystemRoot%\Inf\Usbstor.inf

When you do this, users cannot install a USB storage device on the computer. To assign a user or group Deny permissions to the Usbstor.pnf and Usbstor.inf files, follow these steps:

1. Start Windows Explorer, and then locate the %SystemRoot%\Inf folder.

2. Right-click the Usbstor.pnf file, and then click Properties.

3. Click the Security tab.

4. In the Group or user names list, add the user or group that you want to set Deny permissions for.

5. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control.


Note Also add the System account to the Deny list.

6. In the Group or user names list, select the SYSTEM account.

7. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control, and then click OK.

8. Right-click the Usbstor.inf file, and then click Properties.

9. Click the Security tab.

10. In the Group or user names list, add the user or group that you want to set Deny permissions for.

11. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control.

12. In the Group or user names list, select the SYSTEM account.

13. In the Permissions for UserName or GroupName list, click to select the Deny check box next to Full Control, and then click OK.



If a USB storage device is already installed on the computer

There is a simple registry change that will keep the USB storage drivers from starting when the system boots. Keeps people from walking up to a PC and copying data off with a USB key, but allows you to keep your scanner, keyboard, and mouse working.

As always – back your system up before messing around in the registry.

set the Start value in the following registry key to 4:


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor


When you do so, the USB storage device does not work when the user connects the device to the computer.


To set the Start value, follow these


steps:1. Click Start, and then click Run.

2. In the Open box, type regedit, and then click OK.

3. Locate, and then click the following registry key:


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor


4. In the right pane, double-click Start.

5. In the Value data box, type 4, click Hexadecimal (if it is not already

selected), and then click OK.

6. Quit Registry Editor.

Switch this value to 4, and USB storage devices are disabled.

Switch this value to 3, and USB storage devices are enabled.

"Warning : Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall your operating system. Microsoft cannot guarantee that these problems can be solved. Modify the registry at your own risk. If a USB storage device is already installed on the computer"






Something for System Admins

Step1

.from bios set up

go to advanced setting in the bios then disable usb


Step 2

This method can be used only on Windows XP Professional Edition.


1.Open the Group Policy Editor (Start > Run, type in “gpedit.msc” and press [Enter]).

2.Go to User Configuration > Administrative Templates> Windows Components > WindowsExplorer.

3.Here, you’ll find “Hide these specified drives in My Computer” and “Prevent access to drives from My Computer”.

4.The difference between the two settings is that “Prevent access” will allow the user to see the drive icon, but will give an error message when he tries to access it.

5.“Hide” will remove the icon so the user won’t see it, but the drive can still be accessed by using Start > Run and keying in the drive letter.

6.Under this setting, after you click the radio button next to “Enable”, you’ll see several options. Choose the one you want to

apply, for example, “Restrict A and B drives only”. You’ll notice that the options here are restricted; you cannot, for example,

choose to restrict drives A, B and D.


So a more reasonable option for sysadmins is to disable write access to USB port so that data files cannot be written to the mass storage device. The USB thumb drive will be read-only.


Open the Windows Registry and open the following key

HKEY_LOCAL_MACHINE\System\CurrentControlSet\ Control\StorageDevicePolicies


Now add a new DWORD called WriteProtect and put the value as 0 to disable write privileges to the USB port. To reverse the step, either delete the WriteProtect REG_DWORD or toggle the value to 1 which will enable the port.


Remember that the above trick works only with Windows XP SP2.

there are two steps. No one asked the importance or utility of step 1.


Step 2 is enough to enable (or disable) USB. So why do domain admins also do?


They disable the access to the drivers. Usually all USB drives are PnP (plug and play). When a USB stick is inserted into the USB port, Windows checks for the associated and the correct driver file for the device. It will go to USBSTOR.inf and USBSTOR.pnf to discover the device driver.


Now if the access to the two files is disabled for the logged in user, then the driver for the USB device cannot be loaded, let alone enabled or disabled. That is why it is important to grant the access to those files.


Scenarios

a) You had two USB drives - one made by Transcend and other by Kingston.

b) Your PC is domain controlled in your office

c) The domain admin continuously run remote scripts on your machine thereby disabling .inf/.pnf access and disable USB in registry.

d) You have admin rights on PC


Scene 1: You insert the Transcend drive the VERY FIRST time

a) You do not follow step 1 and step 2. Result: FAILURE. Your drive will NOT be usable.

b) You do not follow one or both of the steps. Result: FAILURE. Your drive will NOT be usable.

c) You follow step 1 and step 2. Result: SUCCESS. Your drive will be usable.


Scene 2: You insert the Transcend drive next time

a) You do not follow step 1 and step 2. Result: FAILURE. Your drive will NOT be usable.

b) You follow step 1 but not step 2. Result: FAILURE. Your drive will not be usable.

c) You do not follow step 1 but follow step 2. Result: SUCCESS. Your drive will be usable. This is because the actual driver file (.sys) is already loaded in the \windows\system32 folder.

d) You follow step 1 and step 2. Result: SUCCESS. Your drive will be usable.


Scene 3: You insert the Kingston drive the first time

a) You do not follow step 1 and step 2. Result: FAILURE. Your drive will NOT be usable.

b) You follow step 1 but not step 2. Result: FAILURE. Your drive will not be usable. But the driver file will be loaded in the \windows\system32 folder.

c) You do not follow step 1 but follow step 2. Result: MIXED. If the actual driver file (.sys) is already loaded in the \windows\system32 folder then your drive will work, else not.

d) You follow step 1 and step 2. Result: SUCCESS. Your drive will be usable.


java.lang.OutOfMemoryError | PermGen space

Configuring PermGen


Periodically when developing and redeploying web apps, an error will occur and the JBoss AS will crash, burn, and will require a restart. Most of the time, the error is an out of memory error and will appear in the console as follows:


10:10:22,640 ERROR [MainDeployer] Could not create deployment: file:(yourFile)

java.lang.OutOfMemoryError: PermGen space


To fix this you will need to modify the run file, again. There are two options: increase the size of the PermGen or allow garbage collection on PermGen . Each method has its pro/cons. Increasing the size of the PermGen will only delay the errors longer, because the memory will be used up eventually.


If all you are looking to do is increase the time between restarts, this is a viable solution. If low memory is an issue or if the error must be prevented altogether, then garbage collection should be permitted on PermGen. With this solution, you may run the risk of garbage collecting classes that will be used again (this has not been tested). Both may be used which may lessen the risk that classes will be collected before their time. Realize that this does not eliminate the risk. Note that both methods will require JBoss AS to be restarted.


Increase Memory Size of PermGen: Navigate to JBOSS_HOME/bin/. Open the run.conf (run.bat for windows) file for editing. Add the following after the remote debugging lines:




In run.conf:


# Memory configuration to delay PermGen: OutOfMemoryError(s)

JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=512m"


In run.bat:


rem Memory configuration to delay PermGen: OutOfMemoryError(s)

set JAVA_OPTS=-XX:MaxPermSize=512m %JAVA_OPTS%


Save the file. PermGen will be configured with a larger memory space.


*Note: A size other than 512 may be used.



Garbage Collection on PermGen Navigate to JBOSS_HOME/bin/. Open the run.conf (run.bat for windows) file for editing. Add the following after the remote debugging lines:




In run.conf:


# Garbage Collection configuration to fix PermGen: OutOfMemoryError(s)


JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled"




In run.bat:


rem Garbage Collection configuration to fix PermGen: OutOfMemoryError(s)


set JAVA_OPTS= -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled %JAVA_OPTS%



Save the file. PermGen will be configured to be garbage collected.



more than one instance of JBossWeb | Add more then one JBoss instance to windows service

How to install more then one instance of JBossWeb


(1) For use more then one instance of JBoss you have to create node directory in your JBOSS_HOME/server directory so it will looks like


-server

-----Default

-----Node1

-----Node2

-----Node3

-----Node4



(2)Copy the apps war on their relative directory's default folder, so now we have directory structure looks like


-Server


-----Default

----------Deploy

---------------foo.war


-----Node1

----------Deploy

---------------bar.war


(Also don't forget to copy their dependent properties and configuration files)



(3) You have to uncomment following lines in Node1/conf/jboss-service.xml


<mbean code="org.jboss.services.binding.ServiceBindingManager"

name="jboss.system:service=ServiceBindingManager">

<attribute name="ServerName">ports-01</attribute>

<attribute name="StoreURL">${jboss.home.url}/docs/examples/binding- manager/sample-bindings.xml</attribute>

<attribute name="StoreFactoryClassName">

org.jboss.services.binding.XMLServicesStoreFactory

</attribute>

</mbean>



Replace ports-01 by your server name, here we are using Node1


So in our example these lines will be changed to:


<mbean code="org.jboss.services.binding.ServiceBindingManager"

name="jboss.system:service=ServiceBindingManager">

<attribute name="ServerName">Node1</attribute>

<attribute name="StoreURL">${jboss.home.url}/docs/examples/binding- manager/sample-bindings.xml</attribute>

<attribute name="StoreFactoryClassName">

org.jboss.services.binding.XMLServicesStoreFactory

</attribute>

</mbean>



(4) Now you can start both apps separately by command prompts, type following commands


run.bat :- for default instance and

run.bat -c Node1:- for Node1





(5) But still you will get JVM_BIND address exception, for handle this exception you have to change in following files:-


(a) Node1/conf/jboss-service.xml


<mbean code="org.jboss.web.WebService"

name="jboss:service=WebService">

<attribute name="Port">8083</attribute>


.......


Change port 8083 as any ports that is not in use, simply put +100 in every port

For example change 8083 as 8183


<mbean code="org.jboss.web.WebService"

name="jboss:service=WebService">

<attribute name="Port">8183</attribute>


……..


Same we will change port 1099 as 1199, port 1098 as 1198, port 4444 as 4544, and port 4445 as 4545


<attribute name="Port">1199</attribute>

<!-- The bootstrap JNP server bind address. This also sets the default

RMI service bind address. Empty == all addresses

-->



<attribute name="BindAddress">${jboss.bind.address}</attribute>

<!-- The port of the RMI naming service, 0 == anonymous -->

<attribute name="RmiPort">1198</attribute>



<!-- RMI/JRMP invoker -->

<mbean code="org.jboss.invocation.jrmp.server.JRMPInvoker"

name="jboss:service=invoker,type=jrmp">

<attribute name="RMIObjectPort">4544</attribute>



.....

<attribute name="ServerBindAddress">${jboss.bind.address}</attribute>

<attribute name="ServerBindPort">4545</attribute>



(b) Node1/deploy/jbossweb.sar/server.xml


Change port 8080 as port you wants we are using 8180 in our example Also change 8009 as 8109,


<!-- A HTTP/1.1 Connector on port 8180 -->

<Connector protocol="HTTP/1.1" port="8180" address="${jboss.bind.address}"

redirectPort="8443" xpoweredBy="true"/>



<!-- A AJP 1.3 Connector on port 8109 -->

<Connector protocol="AJP/1.3" port="8109" address="${jboss.bind.address}"

redirectPort="443" />



It works here hope same for you.



(6) Add more then one JBoss instance to windows service


We have to create separate service.bat and .log files for Node1 in JBOSS_HOME/bin folder

In our example we created as service-Node1.bat


Just copy service.bat and rename it as service-Node1.bat


We have to do few changes in service-Node1.bat


See below the changes:



(a)Change service as service-Node1 in following lines, as we did


echo Usage: service-Node1 install^|uninstall^|start^|stop^|restart^|signal

echo Usage: service-Node1 signal <0...9>




(b) Change JBWS1SVC as JBWS1SVCFOO at below places


:cmdInstall

jbosssvc.exe -iwdc JBWS1SVCFOO "%DIRNAME%”........


:cmdUninstall

jbosssvc.exe -u JBWS1SVCFOO


:cmdSignal

jbosssvc.exe -k%2 JBWS1SVCFOO




(c) Now we change start, stop and shutdown parameter in following manners:


:cmdStart

call run.bat -c Node1 >run_Node.log

goto cmdEnd


:cmdStop

call shutdown -S -s localhost:1198>shutdown_Node1.log

goto cmdEnd


:cmdRestart

call shutdown -S -s localhost:1198>>shutdown_Node1.log

call run.bat -c Node1>>run_Node1.log

goto cmdEnd



Look carefully we rename run.log and and shutdown.log as run_Node1.log and shutdown_Node1.log


Also in shutdown parameter we gave jnp port address 1198 that we used in Node1/conf/jboss-service.xml


<attribute name="BindAddress">${jboss.bind.address}</attribute>

<!-- The port of the RMI naming service, 0 == anonymous -->

<attribute name="RmiPort">1198</attribute>




Now you are ready to install JBoss as Windows service


Run on your command prompt following commands for install JBoss to Windows services:-


service install JBWS1SVC :- this command will install default JBossWeb service, and


service-Node1 install JBWS1SVCFOO :- it will install your Node1 service.


Hope it will helpful for you