Problem If you attempt to store an object more than approximately 1 MB in size using memcache in the Google App Engine, it will give a ValueError, something like this: ValueError: Values may not be more than 1000000 bytes in length; received 1088171 bytes Solution I’ve added a library to my Appswell framework that allows [...]
Posted on 9 October 2010, 1:24 pm, by klenwell, under
Code Case.
The Google Arcade Fire HTML5 demo is cool, but the code is surprisingly simple: from google import WebApp, Predict, Users, Maps, Html5, NsaProxy user = Users.lookup_by_existing_cookies_and_ip() address = Predict.get_address('Enter the address where you grew up:') data_raper = NsaProxy.init(user, address) try: map = Maps.load_data(address) if map.context == 'urban': kid = Html5.load_urban_kid() else: kid = Html5.load_suburban_kid() video [...]
Posted on 11 April 2009, 10:43 am, by klenwell, under
Code Case.
If you’re using Pylons, the Python framework, you’re probably using FormEncode. And if you’re using FormEncode, you’ve probably have noticed, and blithely ignored, the state argument that’s the last argument to a number of the validator class methods.
So what is state and why would you want to use it?
Posted on 14 March 2009, 9:49 am, by klenwell, under
Code Case.
Problem What if I need to compare really big numbers in PHP? Like comparing 2^66 > 3^53? Overview This will work: print (int) (pow(2,66) > pow(3,53)); PHP will convert the integers to scientific notation. But this script illustrates the limitation of normal operational syntax (i.e.: pow(2,66) > pow(3,53) vs. bccomp(bcpow(2,66), bcpow(3,53),1) > 0): $max = [...]
Posted on 31 January 2009, 9:28 am, by klenwell, under
Code Case.
Problem In CakePhp, I want to invalidate a field submitted in a form and set the error message dynamically. If the error message is set by a validation parameter within the model, the new message should override that error message and be displayed by the form in the view. Overview Consider the following three cases [...]