Monday, February 16, 2009

php SimpleDB files

It took me a while longer to find anything good and the only thing I found was this http://objectcentral.com/paws/ I did find some problems with this script and so I made a few changes myself. I have put everything you need into a zip file. The paws stuff depends on the Amazon folder and they both need to be in the same directory. I didn't want to bother to figure out the include stuff so I just put another copy of both folders in my list directory. Just add the amazon keys to the config file in paws directory and the line include 'paws/pawsSDB.php' into your php files. Then you can make use of all methods on the pawsSDB object.

The changes I made were two small things: 1) on the query method I added a parameter to tell it how many objects you wanted returned at a time. Currently, it defaults to 11 (because of the project) but you can pass in any number you want. 2) The getNextItemName method used to keep calling the last query until all the items that the query returned were sent back to you no matter what you set as the max number of items. I made it so that if you tell it to only return 11 from the query, you only get 11.

Anyway, go forth and do good stuff.

Thursday, February 12, 2009

SimpleDB and sorting comments


I was chatting with Dave Wilcox as I was working on my lab tonight and he is a life saver. (A wild cherry one, I would guess.) Anyway, as I was working on my query for comments he gave me the greatest tip ever!

If you want to sort by something in your SimpleDB query, it has to be referenced in the query.

For example, if I wanted to sort by coolness in my made up SimpleDB domain, you might think the query "['submitdate' > 'some param'] sort 'coolness' desc". This query seems to make sense to me and probably everyone who has ever used SQL. Yet, you won't get nothin' back from SimpleDB. You need to make sure you include whatever you want to sort by in your query: ['submitdate' > 'some param'] intersection ['coolness' = 'something that is always true' sort 'coolness' desc". Now SimpleDB will give you back all the results your heart or query desires. I thought it was very odd so I just wanted to warn everyone else! Good luck.

Picture from : http://ecx.images-amazon.com/images/I/519DTFXWQ6L._SL500_AA280_PIbundle-12,TopRight,0,0_AA280_SH20_.jpg

Wednesday, February 11, 2009

PHP s3 Objects

I have looked through a few php5 objects that will do all the s3 stuff for me and the best one I have found so far is http://code.google.com/p/php-aws/source/browse/trunk/class.s3.php# I have yet to actually use it so we will see how that goes. It seems like it works pretty well. Don't forget to install php5-curl (that is what it is on ubuntu anyway) because it uses that.

Thursday, February 5, 2009

use PHP without mod_rewrite

In a previous post I talked about how apache just magically found my php files even when I didn't enter /submit.php but only /submit. Apparently, by default in Ubuntu 8.10 with apt-get apache2/php5 install this behavoir is enabled automatically. However, on the Fedora image it appears that this is not enabled. From a comment posted by Artan in the origional post you need to do a little httpd.conf editing. His comment follows:

"I was trying to get my Apache to do the same thing, but it wasn't working. I finally found a way to do that and it's as simple as putting one option in the options directive in your httpd.conf file. This is called MultiViews.
If you look in the .conf file, among others, there will be a section called Directory "/var/www/html" or whatever the path to your directory is.
The Options directive will most likely be there and will have some options set. All I did was add MultiViews to the list of Option directive and it all magically worked.

This is what my Options directive looks like now:
Options Indexes FollowSymLinks Includes ExecCGI MultiViews
(that is all supposed to be in one line)"

Hope that helps!

Wednesday, February 4, 2009

Fedora Shutdown Script

Someone was asking me for this in class today : http://www.linuxforums.org/forum/redhat-fedora-linux-help/64580-where-shutdown-script.html If it works or not I know not since I am not using fedora. Good luck!

Show me my public ip address!

Well, alas, another small kink in the making of a distributed web app: finding my new EC2's public ip address. I would have thought there was a really easy way to do this from the command line on linux machines and maybe there is and I am completely ignorant. But, be that as it may, I figured the easiest way to solve my problem was to solve it myself. Introducing.....show me my public ip address Hit up this script with whatever kind of http producing program you got and all it will return is some headers followed by your public ip address. I am going to use it.

Tuesday, February 3, 2009

{"success":false, "error":"invalid arguments"}

Well, that was a junky three hours of my life. I am using php to implement my stuff and I actually went ahead and implemented RFC1867. The sad part is...no matter what I did, the app server rejected me like a stinky bum from the street.

Sadly, I had to admit that the black-box app server knew better than I or in other words, I couldn't figure out what I was doing wrong with my implementation of the RFC. I ended up just making a system call to curl. How sad is that...a computer beat me.

I think I am going to go read the real RFC and see exactly what I was doing wrong.

sendToHost - the php way

Just a heads up for any php guys. I have been using a function I found randomly through google to get all the replies from the app server. If you don't like raw http you probably shouldn't use it but I found it on this site.

I customized it myself so it worked better for me. One other thing that you might try is curl for php. I am pretty sure there is a library that allows you to create a curl object in php and use that to hit other sites. Anyway, good luck.