2010-08-20
Simplicity vs. Choice
Labels:
Thoughts on...
I found this video today it is really worth watching if you do anything with software.
2010-07-14
Why CamelCase is good
Just though I would share today I was woking on someone sp and found the name was:
Readable? I think not.
But with a small change, you can actuall read it:
SPF_GETHARMONISEDSERIESDETAILTARIFFBYHARMONISEDSERIESDETAILIDReadable? I think not.
But with a small change, you can actuall read it:
spf_GetHarmonisedSeriesDetailTariffByHarmonisedSeriesDetailID.
2010-07-13
NotImplementedError: Unable to find the Python PIL library
Labels:
App Engine,
How to,
Python
I have been playing with Google App engine on both mac and windows and in both cases when using
For Mac OSX:
images.resize I get the following error:NotImplementedError: Unable to find the Python PIL library. Please view the SDK documentation for details about installing PIL on your system.After using my friend Google I found the solution.
For Mac OSX:
-
Open to Terminal by navigating to your Applications folder, open Utilities, and double click on Terminal. You will be greeted with a message similar to this:
Last login: Tue Mar 6 17:21:36 on console Welcome to Darwin! imac:~ Matt$
-
Type in "
sudo easy_install --find-links http://www.pythonware.com/products/pil/ Imaging" into the Terminal and press enter. - Enter in your password when prompted and then you are done.
- Download "Python Imaging Library 1.1.7 for Python 2.6" from their website and install.
- Reboot and then you are done.
2010-07-02
2010-05-16
Good Bye JSP
Labels:
App Engine,
gae,
google,
How to
I have tried using JSP on several occasions and every time I realise that I hate it, but when I started playing with Google App Engine(GAE) and the GWT I came to a conclustion that I am not a fan of that either.
I first started with GAE and Python and found that django was quite nice in the way it let you seperate the code and presentation easily, were someone with not python knowladge could easily edit the template.
So I turned to google and types in "JSP alternative", the first one I found was Freemaker so I downloaded the latest version and set out to complete this tutorial. There was one small problem the tutorial was a little out of date and try as I might I could not the the
To go from JSP to Freemarker I had to make a few changes. First I added freemarker.jar to
Next I created a template file called index.html and added to the war folder here is the template.
After that I added a function to the serverlet to set the template values and display the template
Last of all I replaced
The source is available from github.
I first started with GAE and Python and found that django was quite nice in the way it let you seperate the code and presentation easily, were someone with not python knowladge could easily edit the template.
So I turned to google and types in "JSP alternative", the first one I found was Freemaker so I downloaded the latest version and set out to complete this tutorial. There was one small problem the tutorial was a little out of date and try as I might I could not the the
<list>. It turns out the the tutorial is a little old is not for the newest version(2.3.16 at the time of posting) of Freemarker and there have been a few changes with one major change, that being tags such as <list> and <if> now have a # before them so they look like <#list> and <#if> I made the change and the example worked!
To go from JSP to Freemarker I had to make a few changes. First I added freemarker.jar to
/war/WEB-INF/lib/.
Next I created a template file called index.html and added to the war folder here is the template.
<html> <body> <ul> <#list files as file> <li> <a href="/filestorage?name=${file.name}">${file.name}</a> (${file.mime}) </li> </#list> </ul> <hr /> <form enctype="multipart/form-data" action="/filestorage" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> Choose a file to upload: <input name="uploadedfile" type="file"/> <br/> <input type="submit" value="Upload File"/> </form> </body> </html>
After that I added a function to the serverlet to set the template values and display the template
/* * Displays the template */ private void DisplayTemplate(HttpServletResponse resp) { //Now loads the data and adds it to a SimpleHash SimpleHash modelRoot = new SimpleHash(); modelRoot.put("files", FileDAL.getFilesHash()); try { resp.setContentType("text/html"); Configuration cfg = new Configuration(); Template tpl = cfg.getTemplate("index.html"); tpl.process(modelRoot, resp.getWriter()); } catch (Exception e) { System.out.println(e.getLocalizedMessage()); } }
Last of all I replaced
resp.sendRedirect("/index.jsp"); with DisplayTemplate(resp); and thats it.
The source is available from github.
2010-05-11
File storage in the cloud
Labels:
App Engine,
gae,
java,
Web
I have been playing with google app engine for a while now mainly with Granite Data Services and Flex, recently I decided to see if I could store files in the datastore as blobs.
I stared by searching on the web on how to save a file as a blob to the datastore after a bit of playing I managed to get it all working using JSP pages and the apache commons fileupload, using this little bit of code:
I have decided that I really hate JSP Pages so I am going to look into a different template engine stay tuned...
I stared by searching on the web on how to save a file as a blob to the datastore after a bit of playing I managed to get it all working using JSP pages and the apache commons fileupload, using this little bit of code:
The full source is available on github.ServletFileUpload upload = new ServletFileUpload(); FileItemIterator iter; iter = upload.getItemIterator(req); FileItemStream fileItem;
while(iter.hasNext() == true) { fileItem = iter.next(); InputStream fileStream = fileItem.openStream(); Blob imageBlob = new Blob(IOUtils.toByteArray(fileStream)); if (fileItem.getContentType() != null) FileDAL.createFile(fileItem.getName(), fileItem.getContentType(), imageBlob); }
I have decided that I really hate JSP Pages so I am going to look into a different template engine stay tuned...
2010-03-22
Cannot Open Database Project
Labels:
.net,
SQL Server
Today I opened visual studio and got an error message.
".dbproj files cannot be opened because its project type(.dbproj) is not supported by this version of the application"
I reinstalled the service pack and then reinstalled visual studio and it I still couldn't open my database project and all the packs and it was still not working.
So I turned to google and found out that all I had to do was reset the dev environment by running the following command.
devenv /resetskippkgs
If only i have of known this before I spent half the day reinstalling everything.
Subscribe to:
Comments (Atom)