Skip to content

Instantly share code, notes, and snippets.

View zhenghao1's full-sized avatar

Mark Huang zhenghao1

View GitHub Profile
@zhenghao1
zhenghao1 / mixin.py
Created April 4, 2013 06:44
Accessing self in class attribute
class A(object):
# Dictionary
extra_content = None
def get_context_data(self, **kwargs):
kwargs.update(extra_content)
return kwargs
class B(A):
@zhenghao1
zhenghao1 / .vimrc
Created August 29, 2012 08:48 — forked from c9s/.vimrc
" Git rebase helper for:
" git rebase --interactive
"
" L - view commit log
" p - pick
" e - edit
" s - squash
" r - reword
" D - delete
"
@zhenghao1
zhenghao1 / product.json
Created August 20, 2012 07:54
New Product mapper for ElasticSearch
{
"product": {
"_type": {"store": "yes"},
"_source": {"compress": true},
"index_analyzer": "standard",
"search_analyzer": "standard",
"dynamic_date_formats": ["date_time_no_millis", "date_optional_time"],
"properties": {
"_id": {"type": "string", "index": "not_analyzed"},
"key": {"type": "string"},
@zhenghao1
zhenghao1 / product.py
Created August 11, 2012 17:39
Product listing using elastic search with python's pyes
fields = [
"_id", "key", "content.name", "content.brand", "content.season",
"content.description", "content.status", "content.category"
]
typeFilter = TermFilter("type", "product")
deleteFilter = TermFilter("deleted", False)
f = ANDFilter([typeFilter, deleteFilter])
query = FilteredQuery(MatchAllQuery(), f)
search = Search(query, start=paging['skip'], size=paging['take'],
fields=fields)
def main():
"""
THis is an exmaple
"""
print 'Hello %s' % "123"