This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from pybing.query import WebQuery | |
>>> query = WebQuery('<your AppId here>', query='python bing') | |
>>> results = query.execute() | |
>>> for result in results[:10]: | |
>>> print repr(result.title) | |
>>> | |
u'Python Wrapper on Bing API \u2014 The Uswaretech Blog - Django Web ... ' | |
u'PyUnit - the standard unit testing framework for Python' | |
u'How to transmit arguments from c++ to python ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.GqlQuery("SELECT * FROM MyModel WHERE prop >= :1 AND prop < :2", "abc", u"abc" + u"\xEF\xBF\xBD") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseModel(db.Expando): | |
@classmethod | |
def filter_prefix(cls, property_name, prefix): | |
query = cls.all() | |
query.filter("%s >= " % property_name, u"%s" % prefix) | |
query.filter("%s < " % property_name, u"%s\xEF\xBF\xBD" % prefix) | |
return query |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Might return TJ if he's in our database. | |
Person.filter_prefix("name", "Thomas Jefferso").get() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from gaetestbed import MailTestCase | |
class MyTestCase(unittest.TestCase, MailTestCase): | |
def test_email_sent(self): | |
# Do something that sends an e-mail | |
send_email_to('[email protected]') | |
# Check that the e-mail was sent to somebody | |
self.assertEmailSent(to='[email protected]') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import with_statement | |
import unittest | |
from gaetestbed import DataStoreTestCase | |
from myproject.models import MyModel | |
class MyTestCase(unittest.TestCase, DataStoreTestCase): | |
def test_num_queries(self): | |
# Check that no more than 1 query is run in this block of code | |
with self.max_queries(10): | |
# Whatever you do in here can't take more than 10 queries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from gaetestbed import TaskQueueTestCase | |
class MyTestCase(unittest.TestCase, TaskQueueTestCase): | |
def test_taskqueue(self): | |
# Check that nothing is in the queue | |
self.assertTasksInQueue(0) | |
# Add something to a Queue | |
add_to_taskqueue(url='/worker/dummy/') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install pacpl faac | |
$ pacpl --to m4a yourfile | |
$ mv yourfile.m4a yourfile.m4r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jj@im-jj:~$ cd workspace/dashboard/src/ | |
jj@im-jj:~/workspace/dashboard/src$ source environment/bin/activate | |
(environment)jj@im-jj:~/workspace/dashboard/src$ deactivate | |
jj@im-jj:~/workspace/dashboard/src$ cd ../../reportingdb/src/ | |
jj@im-jj:~/workspace/reportingdb/src$ source environment/bin/activate | |
(environment)jj@im-jj:~/workspace/reportingdb/src$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git stuff: | |
function get_repository { | |
pwd | grep $HOME'/workspace/.*/src.*' | awk -F/ '{print "("$5")"}' | |
} | |
function get_branch { | |
git branch 2> /dev/null | grep \* | awk '{print "("$2")"}' | |
} | |
# Update PS1 | |
PS1="\[\033[01;34m\]\$(get_repository)\[\033[31m\]\$(get_branch)\[\033[37m\]\[\033[00m\]\[\033[38m\]\u@\h:\w$ " |
OlderNewer