2010-05-11

File storage in the cloud

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:
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); }
The full source is available on github.

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

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.

2009-11-14

MonoTouch - Image View in Interface Builder

I have been playing with MonoTouch recently in an attempt to make a iPhone app. I was playing quite happily there just one problem. I couldn't work out how to set the image for the "Image View" in Interface Builder I searched the internet for a few hours and still couldn't find a thing. So it was time to start randomly clicking and compiling until it worked. Here is what I did....

  1. Create a new iPhone Solution in MonoDevelop.
  2. Drag the image you want to use in to the Solution Explorer.
  3. Click Copy on the dialog box.
  4. Right click the image in the solution and select "Properties", the Properties panel should show up.
  5. Change the "Build Action" to "Content".
  6. Double Click MainWindow.xib in the "Solution Explorer" and Interface builder should open up.
  7. Click "Tools" > "Library", the library window will pop open.
  8. Drag and "Image View" (under "Library" > "Cocoa Touch" > "Data Views") to the "Window".
  9. Click on the Image View, then click "Tools" > "Attribute Inspector".
  10. Type the name of the image in the "Image" field. The image view will be replaced with a question mark icon
  11. Close interface builder.
  12. In MonoDevelop Click "Run" > "Run".
  13. Wait for the iPhone Simulartor to start and enjoy the results.

2009-11-08

Free Mac Apps Go get yours now!

MacHeist are at it again and are giving away free apps one of which I used to to grab the image for this post.

If you want the pack just jump on over to MacHeist sign up and then get to downloading. You have to be quick tho because the deal ends in four days from today(Sunday 8 November 2009).

2009-10-22

Single Quotes in TSQL

Recently I had a to format some data, originally the formatting was done using the MVC.NET page but there was one for small problem it took over five minutes to return 2,000 records which is just a little bit to long for my liking.

We only had a day to fix this problem so it was time for a dirty yet brilliant hack. I created a table variable and for the formatted data added the data to it and returned the date all in one stored procedure, there was one problem tho I needed to generate T-SQL and run it using EXECUTE (I know its not the best way to do things). I was working away at this and then a problem popped up there is no way to escape single quotes that I could work out in T-SQL.

But with a little trickery.....

DECLARE @singleQuote CHAR(1);
SET @singleQuote = CHAR(39);

Problem Solved!

2009-09-24

Flex - Button label truncation problem

I recently had trouble with Flex truncating the label on some but...




It was a particularly aggravating affair, playing with the padding and the width which had no apparent effect. After hours of searching the net and finding nary a shred I discovered that there was a simple fix.




Simply changing the label placement property of the button to 'bottom' had the desired effect rendering the label correctly.




Ahhhhh, much better.

2009-09-01

Making the Eclipse XML editor Useful

I use Eclipse for editing pretty much everything I on my Mac with its great free plugins who wouldn't want to use it there is only one small problem. That problem is the built in XML editor for Eclipse sucks, it tree based meaning you can't get the the underlying code without using the default Text Editor.

I decided that there must be a free plugin you can use so I Googled "free eclipse xml editor" and found several articles about an editor called XmlBuddy but there was a problem, the domain www.xmlbuddy.com has been sold so you are not going to be able to download it from there crap! So yet again I turn to my friend google and at last I have found the answer.

I downloaded the plugin from cnet unzipped into my Eclipse plugins directory, now I finally have a decent XML editor.