Today while coding my first Facebook application running on Google App Engine I was getting odd errors related to time from the datastore.
The problem was that Google App Engine’s time is always running from Coordinated Universal Time (UTC), even when you use something like:
import datetime datetime.datetime.now()
How you should and I have compensate for this is taking the difference of the time you want to UTC time in order to shift the time to the time zone of interest:
1 2 3 4 5
import datetime time = datetime.datetime.utcnow() - datetime.timedelta(hours = 5) # for East Coast United States time = datetime.datetime.utcnow() - datetime.timedelta(hours = 6) # for Central United States time = datetime.datetime.utcnow() - datetime.timedelta(hours = 7) # for Rocky Mountains United States time = datetime.datetime.utcnow() - datetime.timedelta(hours = 8) # for West Coast United States
This will give you the correct time in your time zone
I got stuck this morning with an invalid sender error from my deployed Google app engine application (you can see the errrors in the log in the dashboard if it just says “Server Error” in the title tag) and I had to search around for a while for an answer.
I eventually figured it out and I’ll post my solution here just to make it easier for others:
- Make sure the email in your main settings.py is valid and yours/part of your groups.
- Also make sure that that email is included in the developers in the dashboard of the application. (https://appengine.google.com/)
- If its not:
- Log into the dashboard with the original user
- Go into the developers section and invite them to also be an administrator to the application
This simple walk through doesn’t only pertain to those that use Google app engine, it applies to all users of Google app engine.
Hopefully it will save someone some time.
Today I was searching around the web trying to figure out how to set the line thickness in HTML5 Canvas.
I stumbled across this great cheatsheet:
It had the information I needed, after setting the context you do something like this to make the lines thicker:
Then go ahead and do your stroke:
The line should now be more thick.
It seems pretty easy to notice how worried Microsoft is about Google. Just watch your favorite prime time television station for a bit and you’re sure to see ads for Bing, Microsoft’s new search engine trying to compete with Google. Well thats Microsoft trying to drink Google’s milkshake … What is Google doing to drink Microsoft’s?
Google Apps Are Rendering Microsoft’s Exchange Server Email Obsolete, Even For Businesses
Google Apps are superseding Outlook and Exchange server for businesses with their web based email, instant messaging and calendar. They’re all easy to use, shareable and available from anywhere. Did I mention they’re significantly less expensive?
Docs Still Doesn’t Have All The Features As Office, But Its Getting There
Google Docs could use a little work in terms of competing with office. Nevertheless, they are easy to use, fast and get the job done. They are just a mild foreshadowing of the office applications on the web we have yet to see. This includes Microsoft’s own Office Live which may save them in this space.
They Have Created Their Own Browser (Chrome) And Are Starting To Get Significant Market Share
HTML5′s Canvas Will Allow Any 2D Interfaces/Fonts To Be On The Web Without Flash, Silverlight Or Any Other Proprietary Plugin
Developers no longer need some fancy authoring software, or user’s with proprietary plugins in order to create great two dimensional interfaces, animations and applications. Get ready for the torrent of canvas powered apps.
Google Has Integrated 3D In The Browser
For those that say that you can’t have a truly web based os until you get 3d graphics in the browser, wait no more. There are now many options to get 3d in the browser and more coming. Google’s O3D is simply one of many fast 3d graphics plugins now available.
They Provide Most Of The Revenue For Firefox
In 2006 Google provided 85% of Mozilla’s revenue through an agreement where Google is the default search provider setting on Firefox. Its been a few years but the contract was extended in 2008 to be valid until 2011. This means that Google has very strong influence over even more of the browser market and can try to convince Mozilla to integrate the technologies it wants to see in the browser.
Google Is Coming Out With Their Own Operating System.
This is the obvious “massive straw” (… or should I say Wendy’s straw?) for sucking down the market share of Microsoft’s core products. As everything moves on to the web we’ll no longer need that clunky, slow, proprietary behemoth that is Windows. Instead we can hop on our computer as fast as we turn on the tv, navigate to our favorite web applications and get the operating system out of the way. As is pretty evident, there is pretty much nothing a windows application can do that its cloud counterpart can’t. The tools for those cloud applications are disproportionately made by Google.
Google’s Not Doing The Work, You Are
They Have Cojones
Finally sick of dealing with the Chinese government’s bull, Google finally took a stand and said it will provide non-censored access to its search engine or leave the country. They did this in response to an attack on their servers where several Chinese dissidents GMail accounts were compromised. I wonder, who would be hacking Google’s servers looking for information on Chinese dissidents? Seems to me we all know what really happened with this one. Thank You, Google, for taking a stand.
Run Microsoft, Run! Google has set up the dominoes … its only a matter of time.
A lot of times developers use REST services or other data feeds that move data using XML. I tried doing this today and noticed the lack of a simple, extremely easy to follow tutorial on how to parse XML using python.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#import library to do http requests: import urllib2 #import easy to use xml parser called minidom: from xml.dom.minidom import parseString #all these imports are standard on most modern python implementations #download the file: file = urllib2.urlopen('http://www.somedomain.com/somexmlfile.xml') #convert to string: data = file.read() #close file because we dont need it anymore: file.close() #parse the xml you downloaded dom = parseString(data) #retrieve the first xml tag (<tag>data</tag>) that the parser finds with name tagName: xmlTag = dom.getElementsByTagName('tagName').toxml() #strip off the tag (<tag>data</tag> ---> data): xmlData=xmlTag.replace('<tagName>','').replace('</tagName>','') #print out the xml tag and data in this format: <tag>data</tag> print xmlTag #just print the data print xmlData
There you have it, that is all you need to do to get a value out of a simple web based xml file using python.
If you want to do it from a file you can do it in a similar fashion:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#import easy to use xml parser called minidom: from xml.dom.minidom import parseString #all these imports are standard on most modern python implementations #open the xml file for reading: file = open('somexmlfile.xml','r') #convert to string: data = file.read() #close file because we dont need it anymore: file.close() #parse the xml you got from the file dom = parseString(data) #retrieve the first xml tag (<tag>data</tag>) that the parser finds with name tagName: xmlTag = dom.getElementsByTagName('tagName').toxml() #strip off the tag (<tag>data</tag> ---> data): xmlData=xmlTag.replace('<tagName>','').replace('</tagName>','') #print out the xml tag and data in this format: <tag>data</tag> print xmlTag #just print the data print xmlData
And thats all you need to know to do the same with a file on your local machine.
If you have any questions post some comments on this post, thanks.