Skip to content

Instantly share code, notes, and snippets.

View jgeewax's full-sized avatar
🤯
Learning

JJ Geewax jgeewax

🤯
Learning
View GitHub Profile
>>> 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 '
db.GqlQuery("SELECT * FROM MyModel WHERE prop >= :1 AND prop < :2", "abc", u"abc" + u"\xEF\xBF\xBD")
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
# Might return TJ if he's in our database.
Person.filter_prefix("name", "Thomas Jefferso").get()
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('test@example.org')
# Check that the e-mail was sent to somebody
self.assertEmailSent(to='test@example.org')
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
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/')
$ sudo apt-get install pacpl faac
$ pacpl --to m4a yourfile
$ mv yourfile.m4a yourfile.m4r
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$
# 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$ "