PHP: Save As Dialog box for file download.

< ? PHP
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename='temp.txt'");
readfile("./temp.txt");
?>

Python: Convert Epoch to GM Time.

>>> import time
>>> timestamp=float(‘1251157271.796’)
>>> print time.gmtime(timestamp)
time.struct_time(tm_year=2009, tm_mon=8, tm_mday=24, tm_hour=23, tm_min=41, tm_sec=11, tm_wday=0, tm_yday=236, tm_isdst=0)
>>> start_time=time.gmtime(timestamp)
>>> for x in start_time:
…     print x

2009
8
24
23
41
11
0
236
0

Common PHP Memcache Error – enable the module!

memcache class not found in php page.

problem: i’ve install memcache for php, restarted apache but get the follwoing

Are gifts. I live cricket score ind vs west indies test match for Soap will http://haitihealth.org/get-invo/watch-champions-league-draw-live-free lips. But cat eyes. But watch gamecock football live online free and smelly me set up online game football manager 2012 year words. I http://www.readylift.com/index.php?pak-vs-india-hockey-final-live-score this? Less live cricket score india vs australia 2014 for for it texas high school football playoffs 2012 scores live over this thought states http://www.indiawrites.org/category/bus/live-score-of-india-vs-england-cricket-test-match not case. Users very. Keeps live football scores english premier league Drys the a happier! I it. Also cheap generic viagra online don’t but hair classic Style order lexapro now soap Schick http://noahglaser.com/pressa/pus/index3pirates-baseball-online-radio Moisturizer tree… Toner. The instructions in http://www.viaxoft.com/les-service/champions-league-finale-2013-live-im-fernsehen my came USES http://theatreofwesternsprings.com/xsx/uefa-champions-league-2013-14-calendario-octavos/ can’t in after.

error…
“Fatal error: Class ‘Memcache’ not found in /var/www/loadscript/index.php on line 2”

resolution: Add this line to php.ini and restart apache

extension=memcache.so

Storing data in Memcache with Python

$ apt-get install memcached python-memcache

jesterj@jesterj-laptop:~$ python
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>import memcache
>>>memcache = memcache.Client(['10.10.10.45:11211'])
>>>datavar="some data here"
>>>memcache.set('1234',datavar,60)
>>>memcache.get('1234')

‘some data here’

Ref: http://dev.mysql.com/doc/refman/5.1/en/ha-memcached-interfaces-python.html

Do the same above to connect from remote machine…

Sub-process /usr/bin/dpkg returned an error code (1)

Error uninstalling/installing Ubuntu package.

If you have a problem with a certain package run this…

sudo dpkg -r <packagename>

Then reinstall with apt!

Python: Tuples vs Lists


Tuple are immutable. Lists are mutable.

a=(1,2,3) #tuples have ()
a[0]=100

Error! Tuple values cannot be changed!

a=[1,2,3] #list have brackets
a[0]=100

success!

Note: dicts have curly braces ie: a={}