I really enjoyed this. It gives a great "poor man's" introduction to how encryption like AES works, how it is fast, yet how it is backed up by some really mind-blowing math.
http://www.moserware.com/2009/09/stick-figure-guide-to-advanced.html
A blog for me to record random things I do. I really don't expect anyone other than myself to ever look at it, but I'm happy if they do. Don't be surprised if posts are half complete, poorly edited, or don't make any sense. I'm sure they made perfect sense to me at the time. ;-)
Thursday, September 24, 2009
Tuesday, September 22, 2009
HOWTO Include Subversion version identifiers in your Java source code with Eclipse
It's often useful to include version markers in your source code files, especially when it's possible they will be distributed outside the bounds of a version control system. In my case, I'm using Subversion and Eclipse to write code.
Subversion provides keyword substitution for special keywords that are managed by Subversion during checkin an checkout. (See: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html). These include Date, HeadURL, Revision, Author, and Id (a combination of the others). You can embed these in your text files and SVN will automatically replace them with appropriate values each time. To enable this, you need to do the following:
svn propset svn:keywords "Id HeadURL Revision Author Date" foo.java
Then, you embed a keyword like "$Id" in your file and next time SVN updates your file, it will replace the $Id string with something like
Subversion provides keyword substitution for special keywords that are managed by Subversion during checkin an checkout. (See: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html). These include Date, HeadURL, Revision, Author, and Id (a combination of the others). You can embed these in your text files and SVN will automatically replace them with appropriate values each time. To enable this, you need to do the following:
svn propset svn:keywords "Id HeadURL Revision Author Date" foo.java
Then, you embed a keyword like "$Id" in your file and next time SVN updates your file, it will replace the $Id string with something like
$Id: foo.java 148 2006-07-28 21:30:43Z sally $.
To make this easier, you might want to change the [auto-props] section of your config file to automatically set this property any time you create a new java file:
*.java: svn:keywords="Id HeadURL Revision Author Date";svn:eol-style:native
Typically, this is embedded in a comment block. To make this easy, you can include it in your Eclipse file templates so things get pre-populated when you generate new files.
For general purpose insertion in all your Java source files, use Window > Preferences > Java > Code Style > Templates, then edit the "Files" entry and add the following to the template:
/*
*
* $$Id$$
*/
That will automatically insert the "$Id$" tag into any new source file you create.
Another reference:
http://wiki.collectionspace.org/display/collectionspace/Java+Source+Files+-+Beginning+Comments+Block+Template
For more advanced usage, you can embed a string in a variable that gets compiled into the object code and can be used to identify versions of binaries.
For Java, insert a piece of code that looks like this:
// version identifier automatically filled by svn:keywords "Id"
public static final String __class_id = "$Id$";
This will expand when the files are checked in to be representative of the version of code that was committed.
This can automatically be inserted in new classes with code templates, again. Window > Preferences > Java > Code Style > Templates > Code > Class body. (Make sure you use $$ for the dollar signs when you create the template.)
Pitfall: Make sure you have cleanly committed/updated files when you do this. Don't make the mistake of building your modified code that is checked out, then distributing it. Once you commit this code, the version number will bump up and potentially be different.
Labels:
eclipse,
java,
subversion,
svn:keywords,
template
HOWTO specify default JVM arguments when using Java JAR manifest
A couple of times I've wanted to be able to specify a set of "default" JVM and program properties using the manifest file of a JAR file so that I could invoke it easily with "java -jar MyProgram." In my case, I wanted to set the JVM system property "https.proxyHost" so that all my web traffic would go through a local proxy.
Unfortunately, there doesn't appear to be a way to specify program arguments in a Java JAR manifest file.
To get around it, the solution is to use properties. I found a useful post here (http://www.velocityreviews.com/forums/t129370-vm-arguments-in-manifest.html) that suggests doing something like this:
static {
System.setProperty("https.proxyHost", proxyHost)
}
This solution actually worked quite well. I ended up writing a "JVMProxyHelper.setProxy(host,port)" routine that I simply invoked from the main() of the program I was running. If I get really fancy, I'll go back and make it read the property out of a file and register it that way, but this works for my quick need.
Unfortunately, there doesn't appear to be a way to specify program arguments in a Java JAR manifest file.
To get around it, the solution is to use properties. I found a useful post here (http://www.velocityreviews.com/forums/t129370-vm-arguments-in-manifest.html) that suggests doing something like this:
static {
System.setProperty("https.proxyHost", proxyHost)
}
This solution actually worked quite well. I ended up writing a "JVMProxyHelper.setProxy(host,port)" routine that I simply invoked from the main() of the program I was running. If I get really fancy, I'll go back and make it read the property out of a file and register it that way, but this works for my quick need.
HOWTO Create Ant build.xml file from Eclipse Java project
I searched around and couldn't find an easy answer for this, but accidentally found it in Eclipse while doing something else. Basically, I created a simple Java program in Eclipse. I wanted to be able to build the program from the command line with ant, but didn't want to hand create the build.xml file when I knew that Eclipse should be able to generate a basic one for me. I kept looking in the "Project" menu and "New" menu for a way to do it.
Answer: It's in the "Export" menu. If you do Export > General > Ant build file, everything works fine.
Beware: it automatically over-writes any build.xml file that may exist with no warning. Don't make modifications unless you figure out a way to preserve them when things change.
Similar task: if you want to produce a runnable JAR file from your project, you can use Export > Java > Runnable Jar to do so. This can also create a custom Ant build file that automatically packs all the Jar stuff you need. NOTE that one of the things this does is re-pack any dependent Jar files you have into one big jar so you can run it with "java -jar."
If you have additional rules in the file that you would like to include in the generated build.xml, you can make Eclipse automatically import these files.
In the same directory, create "build-custom.xml" with the following lines:
Then export the build.xml file from Eclipse. It will now include a line
as part of the build.xml file. You could now execute "ant all" to invoke your "all" rule from the main command line.
NOTE: I think your filename must start with the word "build....xml" in order for Eclipse to find it.
Answer: It's in the "Export" menu. If you do Export > General > Ant build file, everything works fine.
Beware: it automatically over-writes any build.xml file that may exist with no warning. Don't make modifications unless you figure out a way to preserve them when things change.
Similar task: if you want to produce a runnable JAR file from your project, you can use Export > Java > Runnable Jar to do so. This can also create a custom Ant build file that automatically packs all the Jar stuff you need. NOTE that one of the things this does is re-pack any dependent Jar files you have into one big jar so you can run it with "java -jar."
If you have additional rules in the file that you would like to include in the generated build.xml, you can make Eclipse automatically import these files.
In the same directory, create "build-custom.xml" with the following lines:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse.ant.import?>
<project default="all" name="Create runnable JARs for everything">
<target name="all" depends="build">
... more stuff ...
</target>
</project>
Then export the build.xml file from Eclipse. It will now include a line
<import file="build-custom.xml">near the beginning. All rules you define in your custom XML file will appear
as part of the build.xml file. You could now execute "ant all" to invoke your "all" rule from the main command line.
NOTE: I think your filename must start with the word "build....xml" in order for Eclipse to find it.
Monday, September 21, 2009
Using Alfresco 3.2 "Share" capabilities
I recently install Alfresco 3.2 Community on a VMware image on my machine to play with it. For information on how I did that, see my other post.
I had some questions about how, exactly, I might use the 'share' capabilities. These basically emulate a lot of the capabilities that Microsoft Sharepoint provides. I believe, in fact, that Alfresco actually presents a Sharepoint protocol interface that can be used by other sharepoint clients.
Questions:
Questions:
I had some questions about how, exactly, I might use the 'share' capabilities. These basically emulate a lot of the capabilities that Microsoft Sharepoint provides. I believe, in fact, that Alfresco actually presents a Sharepoint protocol interface that can be used by other sharepoint clients.
Questions:
Questions:
- Q: How do I get to WebDAV path of files in Document library?
- A: http://192.168.177.131:8080/alfresco/webdav/Sites/firstsite which is the same technique used for all other Alfresco WebDAV access.
- Is there a way to directly edit document library files
- Is there a way to share files between “Share” and “Alfresco” hierarchy?
- o A: “Alfresco” main site sees the content of the “sites” hierarchy as files data, but I don't think the "Share" sites have a good view of the containing Alfresco instance
- o Operations on the items seems to be limited. I don't seem to be able to create "rules" on documents within a "site" document library, but I'm not sure I ever was.
- o Can Embed a “widget” or treat as a “site” ?
- o Tried with a “web view” applet, but that requires you to login and doesn’t really connect to much.
- - How would we create a main company site, then show highlights of other sites for projects
- - How do we create template share sites to create new projects?
- - Is there a quick way to “monitor” for changes in a site? (e.g. email)
- Q: Is there a way to create an “intro page” for a site?
- o A: yes. “Customize Dashboard” to move around widgets.
Labels:
alfresco,
alfresco share,
sharepoint,
virtual machine,
VM
Setting up Alfresco 3.2 Community in a Linux VM
I've used Alfresco a bunch in the past at work to maintain documents. We're thinking of upgrading from the (very) old 2.2 release to the (much) newer 3.2 release. This is what I did to get started.
I set this up in a VMware image of a Ubuntu Workstation 9.04 (512 MB RAM, 25GB disk). For information on this, see my other blog post.
To get started with Alfresco, I did the following:
- Download Sun jdk 1.6 se, install, move to /usr/local/java
- Sudo apt-get install mysql-server
** Ask for a new root PW. Set one.
- Download alfresco 3.2 community from http://www.alfresco.org
- Sudo ./Alfresco-....-install
o Chose /opt/alfresco as installation location
o Asks for root pw of mysql;
o Creates ‘alfresco’ database in mysql
o Ask for where Open Office is installed. I fed it /usr/lib/openoffice after locating it on my disk.
o Start Alfresco
- . cd /opt/alfresco
- . ./alf_start.sh
- (wait)
- http://localhost:8080/alfresco
This produces and “up and running” version of alfresco. (NOTE: The NAT interface between my host OS and guest Linux OS is 192.168.177.x. Host is .1 and guest is .177, hence the interfaces below.)
- http://192.168.177.131:8080/alfresco allows access from my external machine
- Shows "guest" account view by default
- Login: admin (default PW)
- Created user for rmills
- Tested login and upload of a document.
Alternate Interface: Alfresco Share
I set this up in a VMware image of a Ubuntu Workstation 9.04 (512 MB RAM, 25GB disk). For information on this, see my other blog post.
To get started with Alfresco, I did the following:
- Download Sun jdk 1.6 se, install, move to /usr/local/java
- Sudo apt-get install mysql-server
** Ask for a new root PW. Set one.
- Download alfresco 3.2 community from http://www.alfresco.org
- Sudo ./Alfresco-....-install
o Chose /opt/alfresco as installation location
o Asks for root pw of mysql;
o Creates ‘alfresco’ database in mysql
o Ask for where Open Office is installed. I fed it /usr/lib/openoffice after locating it on my disk.
o Start Alfresco
- . cd /opt/alfresco
- . ./alf_start.sh
- (wait)
- http://localhost:8080/alfresco
This produces and “up and running” version of alfresco. (NOTE: The NAT interface between my host OS and guest Linux OS is 192.168.177.x. Host is .1 and guest is .177, hence the interfaces below.)
- http://192.168.177.131:8080/alfresco allows access from my external machine
- Shows "guest" account view by default
- Login: admin (default PW)
- Created user for rmills
- Tested login and upload of a document.
Alternate Interface: Alfresco Share
- http://192.168.177.131:8080/share
- Login: rmills or admin
- Create a site (Collaboration Site)
- Name: FirstSite
- URL: firstsite
- Public
Friday, September 18, 2009
Setting up an easy VMware Linux machine
I spent a few minutes playing around with VMware to get a linux virtual machine set up on my PC. It was actually fairly easy:
Now I have a VM running linux on my machine that I can play with. It seems to be auto configured with NAT networking, so I can use SMB to access shared drives on my host PC to transfer files back and forth. It can also reach the internet with a web browser, etc.
- Download and install latest VMware Player from www.vmware.com (reboot)
- Download a Ubuntu 9.04 Desktop virtual machine from the "Appliance > Operating Systems" section of the VM Ware site
- Unpack the VM image
- Double click on the virtual machine and VMware player starts up.
Now I have a VM running linux on my machine that I can play with. It seems to be auto configured with NAT networking, so I can use SMB to access shared drives on my host PC to transfer files back and forth. It can also reach the internet with a web browser, etc.
Subscribe to:
Posts (Atom)