This file contains 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
# Add One Field to all documents | |
db.RssLink.update({}, {$set: {"type": "normal"}}, false#upsert#, true#multi#) | |
#simple Search | |
db.RssLink.find({run_time :{"$gt":180}}) |
This file contains 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
{ | |
"aggregations": { | |
"remax_stats" : { | |
"filter" : { "range" : { "RE" : { "gt" : 100 } } }, | |
aggregations : { | |
"stat_re" : {"stats" : { "field" : "RE" }} | |
} | |
}, | |
"cat_stat": {"terms": {"field": "category"}} | |
}, |
This file contains 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
OIFS=$IFS; | |
IFS=","; | |
# fill in your details here | |
dbname="dbname" | |
user="username" | |
pass="pass" | |
host="127.0.0.1:27017" | |
collections=`mongo "$host/$dbname" -u $user -p $pass --eval "rs.slaveOk();db.getCollectionNames();"`; |
This file contains 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" : 0, "size" : 30, | |
"sort" : [ { "RE" : {"order" : "desc"}},"_score"], | |
"query": { | |
"simple_query_string" : { | |
"query" : "(+iran && +obama) || (+moore && +iran) || (+u.s. && +iran)", | |
This file contains 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
##Add File Logger | |
import logging | |
logger = logging.getLogger('myapp') | |
hdlr = logging.FileHandler('/var/tmp/myapp.log') | |
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') | |
hdlr.setFormatter(formatter) | |
logger.addHandler(hdlr) | |
logger.setLevel(logging.WARNING) | |
We can use this logger object now to write entries to the log file: |
This file contains 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
TIP #1 : Check Membership Efficiently | |
lyrics_list = ['her', 'name', 'is', 'rio'] | |
# Avoid this | |
words = make_wordlist() # Pretend this returns many words that we want to test | |
for word in words: | |
if word in lyrics_list: # Linear time | |
print word, "is in the lyrics" |
This file contains 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 reset --hard <old-commit-id> | |
git push -f |
This file contains 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
1. in Google Developer Console , https://console.developers.google.com/ , create project -> create new Client ID in Credential Link at left sidebar | |
2. |
This file contains 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
1.Setup a dns server in ubuntu : http://www.servermom.org/how-to-install-and-setup-bind9-on-ubuntu-server/136/ |
This file contains 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" : 0, "size" : 20, | |
"sort" : [ { "RE" : {"order" : "desc"}}], | |
"query": { | |
"filtered": { | |
"query" : { | |
"query_string" : { |