Search This Blog

Thursday, November 18, 2010

Grails: Storing Uploaded Files with Unique Names

This is how I was able to store uploaded files in a project directory rather than a blob in a database, as well as provide unique file names for each file by providing hash names.

Within my save action of the class with a property for the uploaded file

//handle uploaded file
def uploadedFile = request.getFile('file')
if(!uploadedFile.empty){
println "Class: ${uploadedFile.class}"
println "Name: ${uploadedFile.name}"
println "OriginalFileName: ${uploadedFile.originalFilename}"
println "Size: ${uploadedFile.size}"
println "ContentType: ${uploadedFile.contentType}"

//Creates hashed fileName using 128bit identifier
def splitName = uploadedFile.originalFilename.split("\\.") <--Splits the name of the file and the file type def hashedName = java.util.UUID.randomUUID().toString() def newFileName = hashedName + splitName[1].toString() //Sets the directory of the file
def dir = servletContext.getRealPath("/")
def userDir = new File(dir, "/uploaded/files")
userDir.mkdirs()
uploadedFile.transferTo( new File( userDir, newFileName))

25N - Nodal Network Operator-Maintainer - US ARMY

I recently enlisted in the Army National Guard as 25N and spent a considerable amount of time researching exactly what 25N does. Here is the best information that I could find, hopefully it helps others out who are looking at this mos.

Basic Description from Goarmy.com:
With communication being such an integral and critical part of the Army, Nodal Network Systems Operator-Maintainers are responsible for making sure that the lines of communication are always up and running. They install, operate, maintain and repair strategic and tactical nodal systems.

Some of your duties as a Nodal Network Systems Operator-Maintainer may include:

Install, initialize, operate and perform field level maintenance on electronic nodal assemblages, combat net radios, and ancillary communications equipment
Use computers and software tools to perform system/network operations
Interpret system and equipment error codes to correct system faults
Install, operate, maintain, perform maintenance and unit level maintenance on all internal communications systems and COMSEC devices
Execute the installation, operation, PMCS and field level maintenance on numerous network management systems

GoArmy.com/25N

The equipment that 25Ns use:
http://www.globalsecurity.org/space/systems/jnn.htm



Other helpful links:
https://forums.goarmy.com/thread/205817
https://www.cool.army.mil/enlisted/25n.htm
http://community.armystudyguide.com/groupee/forums/a/tpc/f/4291043041/m/1951067061
http://militaryyearbookproject.com/cmf-25-communication-and-information-systems-operation/25n-nodal-network-systems-operator-maintainer

Wednesday, November 17, 2010

Installing Groovy/Grails on MAC OSX Snow Leopard

Installing Groovy/Grails on MAC OSX Snow Leopard

Do this through terminal:
Install Groovy:
$ sudo mv groovy-1.x.x /usr/share
$ cd /usr/share
$ sudo chmod 0755 groovy-1.x.x/bin/*
$ sudo ln -s groovy-1.x.x groovy


Install Grails:
$ sudo mv grails-1.x.x /usr/share
$ cd /usr/share
$ sudo chmod 0755 grails-1.x.x/bin/*
$ sudo ln -s grails-1.x.x grails


Edit or create your ~/.profile file:

To create a .profile use the command pico .profile
export GROOVY_HOME=/usr/share/groovy
export GRAILS_HOME=/usr/share/grails
export PATH=${PATH}:$GROOVY_HOME/bin
export PATH=${PATH}:$GRAILS_HOME/bin

Reload your profile:
$ . ~/.profile
or
$ source ~/.profile.

Installing Tesseract on Mac OSX

Instructions for installation on Mac:

Installation on a mac (Snow leapord 10.6.4) with english language ocr in mind:

1) Download tesseract-3.00.tar.gz and eng.traineddata.gz from the downloads page (http://code.google.com/p/tesseract-ocr/downloads/list)

2) Open a terminal, cd to wherever you downloaded the above files, then do:

tar -xf tesseract-3.00.tar.gz.gz

cd tesseract-3.00

3) Will want to install libraries libtiff (read compressed tiff files) and leptonica. Install Macports if not already installed and execute:

sudo port install tiff

sudo port install leptonica

4) Then run:

./configure

make

sudo make install

or alternatively there is a macport for tesseract:

sudo port install tesseract

5) Then move the english language pack for use with tesseract

cd ..

tar -xf eng.traineddata.gz

sudo mv eng.traineddata /usr/local/share/tessdata

- you now have a working install of tesseract set up to do ocr on english language documents. Run in the directory containing the desired .tif :

tesseract inputimage.tif outputtext -l eng

and you should get a file called outputtext.txt. in the same directory with the results!