Friday, August 22, 2008

linking pojo projects into a gwt project in eclipse

1. export the pojo project as a jar file. make sure the source code is included
2. import the jar file into the gwt project as an external jar

Friday, June 20, 2008

convention tips

bring the following:
official receipt
registration confirmation
businesscards
swag bag

notes:
always stay till end of day for swag
drop businesscards to different sponsor boxes for more swag
check sponsor corners for raffle items, contests and giveaways for even more swag
practice catching shirts

Tuesday, March 18, 2008

auto start a process in Ubuntu

1. Create a script that calls the program you want to auto start
2. Copy the script to /etc/init.d/
3. Run "sudo update-rc.d <script> default"

Thursday, February 14, 2008

remove dillo "Getting Started" page


1. open a terminal and type "vi .xintrc"
2. look for the line containing ".html"
3. comment everything inside the containig "if-fi" statement and save
4. reboot to check if successful

install DamnSmallLinux on vmware

Taken from DamnSmallLinux forums:


1. Create new Virtual Machine in VMware with the following settings. NOTE: When prompted in VMware i chose custom as I want to mount this as a server in VMWare v1.0.3 and virtual machines created in Workstation6 mode are not comptible, so choose Workstation5 if you plan to use as a server.

- Select Guest OS type as Linux -> Other Linux 2.6.x Kernel
- Give it a name e.g. "DSL"
- Choose the number CPUs
- Choose the memory amount (I have used as low as 64MB but depending on what you want to do you will need more, e.g. OpenOffice requires 384MB)
- Choose Network type (use bridged is possible)
- Select I/O adapter types (just click next)
- Create new virtual disk
- Virtual Disk Type (IMPORTANT - Make sure you choose IDE and NOT SCSI as you will have problems)
- Specify Disk Capacity - WARNING - It is painful to increase the disk size at a later date, so bigger is better in this case
- Specify Disk File name - I usually rename it to something smaller than the default long name e.g. DSL.vmdk

2. Configure you new Virtual machine

- You should now see your new virtual machine in VMWare
- Click Edit virtual machine settings
- Remove any un-necesary items e.g. Floppy drive, Sound (if you have no sound card)
- Click add and select CD-ROM
- Select Use ISO Image
- Browse for the DSL ISO image you have downloaded and select it
- Click OK (make sure you see the check box "Connect at power on") so that the Virtual Machine boots from the ISO image

3. Start your Virtual Machine

- You should now see the Boot screen for DSL
- Hit enter, DSL will boot
- once you see your desktop, click "ATerminal"
- type "sudo -s" enter
- type "cfdisk"
- Select "Y" when asked Do you wish to start with a zero table
- You will now see your cfdisk applicaton. Use the arrow keys and select "NEW"
- Select "Primary" then select the size (by default it will be the entire HDD space you sepcified in VMware - I used the whole amount - some say leave space for a swap drive)
- Select "Bootable" (you see the word "Boot" under the Flags coloumn)
- Select "Write"
- When prompted with a (Y/N) type "YES" and hit enter. Once completed you will see the message "Wrote partition to hard disk"
- Select "QUIT"
- now back at the command prompt type "mkfs /dev/hda1". This will prepare the hard drive file system ready for installation. (this is not necessary, you can skip directly to the next step if you wish)
- now type "dsl-hdinstall"
- you will be prompted for the target drive type "hda1" and press enter
- you will then be prompted for multiuser logins (Y/N) - I choose "N"
- Select "N" for ext3 filesystm (unless you know what its for)
- Select "Y" to continue. You should see "The copying of system files has been complted"
- Select "Y" when asked "Proceed to install a boot loader"
- Type "g" for GRUB (Unless you specifically want LILO) - NOTE: This is case sensitive, it will default to GRUB otherwise
- Type "Y" when prompted for reboot
- You will see DSL shut down and press "Enter" when prompted
- At the VMware screen, Stop the Virtual Machine (hit the red stop button) and click edit and select the CD-ROM device that points to your VMware image .iso file
- Click remove and start the Virtual machine again.
- You should be prompted to enter a password for the "root" user and the "dsl" user.
- If it starts and you see your DSL desktop you have succesfully intalled DSL ! Congrats!




authored by phez

Thursday, January 31, 2008

enable password protected lighttpd folders

1. open /etc/lighttpd/lighttpd.conf
2. add "mod_auth to server.modules"
3. add this block of code right after. replace items in <> with desired value


auth.debug = 2
auth.backend = "plain"
auth.backend.plain.userfile = "/home/<username>/.lighttpdpassword"

auth.require = ( "/<web accessible domain to protect>/" =>
(
"method" => "basic",
"realm" => "Password protected area",
"require" => "user=<username>"
)


4. save configuration
5. create the password file ".lighttpdpassword" and append usernames and passwords

<username>:<password>
...

6. save and allow access to everyone chmod 777 .lighttpdpassword
7. restart lighthttpd with /etc/init.d/lighttpd restart

Wednesday, January 9, 2008

running executable jar files via console

Use when:
1. NoClassDefFoundError and MissingResourceExceptions keep appearing every time an executable jar file is run
2. executable jar files need 3rd party libraries
3. resource folders need to be accessible via classpath


There are two ways to run executable jar files. Which to use depends on how the jar file was constructed.

If the jar file does not need any 3rd party libraries use:

java -jar <jarfile>


If the jar file uses any 3rd party libraries that has not been put inside the archive or needs to have folders accessible via classpath, use:

java -cp .;<libraries>;<classpath>;<jarfile> <main-class>

*Note that a folder containing customized Properties files must appear before the main jar file to override any copies inside the archive itself


Tuesday, January 8, 2008

organize eclipse project folders

organize a project's source folders in such a way that:

  1. all source files are stored in the src folder
  2. all configuration files such as xml, properties, and conf files are stored in the conf folder
  3. all compiled classes are put in the bin folder
  4. exported jar file(s) are stored in the dist folder
  5. project specific configuration files (i.e. .jardesc, manifest.mf) are stored in the etc folder


==========
  1. right click Package Explorer and select New>Create a New Project
  2. select Java Project and click Next
  3. specify the project's name and make sure Create separate source and output folders is selected in the Project Layout panel
  4. click Next
  5. click the Create new source folder link and create the src and conf folders
  6. click Finish
  7. right click the project name and add the bin, dist, etc folders
  8. create a new manifest file in the etc folder and name it manifest.mf
  9. make sure ". conf" is part of the Class-path so that configuration files stored in it can be accessed by your classes

easily share eclipse user libraries (windows)

Use when:
1. working on a project on more that two computers (ie. work and home pc)
2. working on multiple projects that share common libraries
3. projects need to be easily passed around with minimal configuration
4. multiple developers are working on single project



========

  1. store all java libraries on a single folder. make sure each library is in its own folder.
  2. create a network share on this folder, and have it mapped to J: drive. if multiple machines are going to access the same set of libraries, have one of them act as a repository for the libraries and have the others map J: drive to it.
  3. in eclipse, goto Window>Preferences>Java>Build Path>User Libraries and create User Libraries for each entry in J:. no need to run steps 3-6 on all machines.
  4. click Export.
  5. click Select All and specify a filename for the .userlibraries file.
  6. click OK to export and save your settings.
  7. copy and distribute the .userlibraries file to all the other machines.
  8. in their User Libraries window, click Import and look for the copied .userlibraries file.
  9. click OK and save your settings.

Monday, January 7, 2008

simple properties file management

Use when:
1. a majority of classes have to each load its own set of settings.
2. properties file is located in folder outside the default classpath
3. a generic solution is needed for loading configuration files that are independent of the filesystem


==========

  1. create a new Class and have it named "ResourceManager"
  2. turn the class into a singleton by hiding the constructor and give it a method named getInstance() that returns an instance of the class
  3. create a static method that will handle file loading. name this method "getResource()" and have it accept a Class object named "name" as a parameter and have it return a Properties object
  4. pass the "name" object appended with ".properties" to the ClassLoader.getResourceAsStream() method to load a Properties file as an InputStream
  5. create a new Properties object and call its "load()" method using the InputStream from step 4

==========
Sample ResourceManager:

public final class ResourceManager {
private static ResourceManager inst;
private static Logger logger = Logger.getLogger(ResourceManager.class);

private ResourceManager(){

}

public static synchronized ResourceManager getInstance(){
if (inst==null)
inst= new ResourceManager();
return inst;
}
public Object clone() throws CloneNotSupportedException
{
throw new CloneNotSupportedException();
}

public Properties getResource(String name){
Properties r = new Properties();
try{
name=name.replace('.', '/');
r.load( ClassLoader.getSystemResourceAsStream(name+".properties") );
}catch(IOException e){
logger.error(e);
}
return r;
}
public Properties getResource(Class name){
return getResource(name.getName());
}
}



=========
The ResourceManager class does not have to be a singleton, but it gives the added bonus of being memory efficient because creating multiple instances of it is no longer necessary; it having only one usable method. It can also be modified so that file access is threaded, preventing any slowdown on particularly large files. But thats for another trick.

force fsck to run on reboot

Use when:
1. df reports incorrect figures
2. file size becomes 0
3. files go missing



==========
sudo touch /forcefsck