After countless frustration with Plesk about how to get my domain to work.
I decided to give 'free' a try
And Co.cc is wonderful option . it just works.
This is how i did it
Go to
http://www.co.cc
Search for your domain. Register the CNAME record as :
http://www.co.cc/google_apps/google_apps.php
check it with Google apps.
You're done.
With Plesk. I also found a very helpful tutorial but it doesn't work for me yet
http://branchwire.com/support/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=1#
Friday, December 18, 2009
Tuesday, December 15, 2009
Simple Useful CSS tutorial
After wasting time with other website i found it
http://www.webcredible.co.uk/user-friendly-resources/css/css-forms.shtml
http://www.webcredible.co.uk/user-friendly-resources/css/css-forms.shtml
Monday, December 14, 2009
Dealing with float comparing in Python
Let's start.
a = 0.7
b = 0.3
a - b = 0.4
if a - b == 0.4:
print ' a - b == 0.4'
else:
print 'a - b != 0.4'
Result a - b != 0.4
OH WHAT'S...
Solution:
if str(a -b) == str(0.4):
print 'a - b == 0.4'
Read Python Doc for more information
a = 0.7
b = 0.3
a - b = 0.4
if a - b == 0.4:
print ' a - b == 0.4'
else:
print 'a - b != 0.4'
Result a - b != 0.4
OH WHAT'S...
Solution:
if str(a -b) == str(0.4):
print 'a - b == 0.4'
Read Python Doc for more information
Monday, December 7, 2009
Query with variable and AND
It is
query =db.GqlQuery("SELECT * FROM table WHERE 1st_attribute =:variable AND 2nd_attribute ='value' ", variable = data)
query =db.GqlQuery("SELECT * FROM table WHERE 1st_attribute =:variable AND 2nd_attribute ='value' ", variable = data)
Tuesday, December 1, 2009
invalid literal for int with base 10
/?p=33
I get quite some traffic for the term “invalid literal for int with base 10″. I guess a lot people fumbling around with Python or Django are getting this error message once in a while. This happens when you try to cast a string into an integer and this string does not really contain a “digit”:
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> string = “TestString”
>>>number = int(string)
Traceback (most recent call last):
File “”, line 1, in
ValueError: invalid literal for int() with base 10: ‘TestString’
>>>string = “1″
>>>number = int(string)
>>>number
1
If you work with the Django framework and get this error while trying to request a web page I would check the parameters. Since every parameter that is getting passed in a request is a string you probably cast them into integers somewhere in your source code. It can be a category id or similar. Now when that category id for whatever reason is empty or does not contain a string that can be cast into an integer, you will get the “invalid literal for int with base 10″ error message.
To avoid this error you should check if the string contains a digit:
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> string = “1″
>>> if string.isdigit():
… number = int(string)
… else:
… print “The variable String contains no digit”
…
>>> number
1
str.isdigit()
Return true if all characters in the string are digits and there is at least one character, false otherwise.
For 8-bit strings, this method is locale-dependent.
More on String operations can be found in the Python documentation.
I get quite some traffic for the term “invalid literal for int with base 10″. I guess a lot people fumbling around with Python or Django are getting this error message once in a while. This happens when you try to cast a string into an integer and this string does not really contain a “digit”:
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> string = “TestString”
>>>number = int(string)
Traceback (most recent call last):
File “
ValueError: invalid literal for int() with base 10: ‘TestString’
>>>string = “1″
>>>number = int(string)
>>>number
1
If you work with the Django framework and get this error while trying to request a web page I would check the parameters. Since every parameter that is getting passed in a request is a string you probably cast them into integers somewhere in your source code. It can be a category id or similar. Now when that category id for whatever reason is empty or does not contain a string that can be cast into an integer, you will get the “invalid literal for int with base 10″ error message.
To avoid this error you should check if the string contains a digit:
Python 2.6 (r26:66721, Oct 2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> string = “1″
>>> if string.isdigit():
… number = int(string)
… else:
… print “The variable String contains no digit”
…
>>> number
1
str.isdigit()
Return true if all characters in the string are digits and there is at least one character, false otherwise.
For 8-bit strings, this method is locale-dependent.
More on String operations can be found in the Python documentation.
Wednesday, November 25, 2009
Count Instance method of Query Class
from google.appengine.ext import db
from google.appengine.api import users
class FirstModel(db.Model):
prop = db.IntegerProperty()
class SecondModel(db.Model):
prop2 = db.IntegerProperty()
reference = db.ReferenceProperty(FirstModel, collection_name = "relation")
//Input data to datastore
firstmodel = FirstModel(prop = 06)
firstmodel.put()
secondmodel = SecondModel(prop2 = 1, reference = firstmodel)
secondmodel.put()
secondmodel = SecondModel(prop2 = 2, reference = firstmodel)
secondmodel.put()
//Count
query = firstmodel.relation
query_count = query.count()
print query_count
OR
query = FirstModel.all()
query_count = query.count()
print query_count
Result:
2
Google app engine simple query
from google.appengine.ext import db
from google.appengine.api import users
class FirstModel(db.Model):
prop = db.IntegerProperty()
class SecondModel(db.Model):
prop2 = db.IntegerProperty()
reference = db.ReferenceProperty(FirstModel, collection_name = "relation")
// Put data to datastore
firstmodel = FirstModel(prop = 06)
firstmodel.put()
secondmodel = SecondModel(prop2 = 1, reference = firstmodel)
secondmodel.put()
secondmodel = SecondModel(prop2 = 2, reference = firstmodel)
secondmodel.put()
Get all entity by using collection_name
query = firstmodel.relation
query = query.fetch(30)
print query
The Result
2 entity are displayed.
[<__main__.SecondModel object at 0x020736B0>, <__main__.SecondModel object at 0x02073790>]
from google.appengine.api import users
class FirstModel(db.Model):
prop = db.IntegerProperty()
class SecondModel(db.Model):
prop2 = db.IntegerProperty()
reference = db.ReferenceProperty(FirstModel, collection_name = "relation")
// Put data to datastore
firstmodel = FirstModel(prop = 06)
firstmodel.put()
secondmodel = SecondModel(prop2 = 1, reference = firstmodel)
secondmodel.put()
secondmodel = SecondModel(prop2 = 2, reference = firstmodel)
secondmodel.put()
Get all entity by using collection_name
query = firstmodel.relation
query = query.fetch(30)
print query
The Result
2 entity are displayed.
[<__main__.SecondModel object at 0x020736B0>, <__main__.SecondModel object at 0x02073790>]
Wednesday, November 11, 2009
Monday, October 26, 2009
Prevent to create an Instance of a Class
I think it's cool
class ClassName:
def __init__( self ):
if self.__class__ == ClassName:
raise NotImplementedError, "Cannot create object of this class"
class ClassName:
def __init__( self ):
if self.__class__ == ClassName:
raise NotImplementedError, "Cannot create object of this class"
Friday, October 9, 2009
Tkinter_Checkbutton
from Tkinter import *
master = Tk()
var = IntVar()
def value() :
print var.get()
c = Checkbutton(master, text="Expand", variable=var, command = value)
c.pack()
mainloop()
result
***************
0
1
0
1
master = Tk()
var = IntVar()
def value() :
print var.get()
c = Checkbutton(master, text="Expand", variable=var, command = value)
c.pack()
mainloop()
result
***************
0
1
0
1
Thursday, October 8, 2009
Wednesday, October 7, 2009
SQlite foreign key
FOREIGN KEY constraints is not Supported
http://www.sqlite.org/omitted.html
The 'walk around' method : Use trigger
http://www.sqlite.org/cvstrac/fileview?f=sqlite/tool/genfkey.README
http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers
http://www.sqlite.org/omitted.html
The 'walk around' method : Use trigger
http://www.sqlite.org/cvstrac/fileview?f=sqlite/tool/genfkey.README
http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers
Tuesday, October 6, 2009
Tuesday, September 22, 2009
How to set more than one primary key in Sqlite
Sqlite could have more than one PRIMARY KEY . Do it as the following :
CREATE TABLE ex1(
a TEXT,
b VARCHAR(10),
c FLOAT,
PRIMARY KEY(b,a)
);
CREATE TABLE ex1(
a TEXT,
b VARCHAR(10),
c FLOAT,
PRIMARY KEY(b,a)
);