Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ucaiado
ucaiado / key_binding_user.json
Last active July 7, 2017 16:54
Sublime Configurations
[
{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser", "parser":"markdown"} }
]
@ucaiado
ucaiado / gist:15eba1ff20828036d537
Created April 10, 2015 20:10
To see the version of a specific python module
pip freeze | grep pymongo
@ucaiado
ucaiado / gist:24c2ddd52dc31b013e20
Last active August 29, 2015 14:18
Make your matplotlib plots look great
#source: http://nbviewer.ipython.org/github/mwaskom/seaborn/blob/master/examples/plotting_distributions.ipynb
import seaborn as sns
sns.set_palette("deep", desat=.6)
sns.set_context(rc={"figure.figsize": (8, 4)})
@ucaiado
ucaiado / gist:50a157cc5411866e682c
Created January 26, 2015 19:33
Check numers in Python
def isfloat(x):
try:
a = float(x)
except ValueError:
return False
else:
return True
def isint(x):
try:
@ucaiado
ucaiado / gist:4aa2051206a4178428ec
Created January 15, 2015 17:29
looping through a list
#source: https://www.udacity.com/course/viewer#!/c-cs253/l-48299958/e-48381418/m-48721320
MYLIST=['a','b','c','d']
n =-1
def looping():
global n
n+=1
return MYLIST[n % len(MYLIST)]
@ucaiado
ucaiado / gist:b88c402a122296d2593c
Last active August 29, 2015 14:12
MONGO - COMMAND LINE

#MongoDB

####PYMONGO a=grades.find({'type': 'homework'}).sort('student', pymongo.ASCENDING).sort('score', pymongo.ASCENDING) doc=foo.find(query).hint([('c', pymongo.ASCENDING)]).explain()#arrays of tuples db.cities.save(newdoc) #create or replace the newdoc into db

####PYMONGO AND UDACITY EXAMPLES

@ucaiado
ucaiado / gist:a432b5e9bce3da9aaaee
Last active August 29, 2015 14:12
WEB DEVELOPMENT
@ucaiado
ucaiado / gist:1f145b71171fe81a89b7
Last active August 29, 2015 14:10
Force your script be UTF-8
#Make sure that your script is in UTF-8. It is not the really a solution, but it is a quick fix
#source: http://stackoverflow.com/questions/5040532/python-ascii-codec-cant-decode-byte
import sys
reload(sys)
sys.setdefaultencoding('utf-8')