Monthly Archives: June 2016

Renaming a virtualenv folder without breaking it

http://stackoverflow.com/questions/6628476/renaming-a-virtualenv-folder-without-breaking-it If you want to fix this manually, that is the way: modify /tmp/project/env/bin/activate with yout favoriate editor like Vim, usually in Line 42 VIRTUAL_ENV=’/tmp/myproject/env’ => VIRTUAL_ENV=’/tmp/project/env’ 2. modify /tmp/project/env/bin/pip in Line 1 #!/tmp/myproject/env/bin/python => #!/tmp/project/env/bin/python

Posted in Uncategorized | Leave a comment

Load data in a json file into mongo db

“”” Load data in a json file into mongo db “”” import os import json from pymongo import MongoClient CONN_STR = ‘mongodb://{}’ CONN_STR_AUTH = ‘mongodb://{}:{}@{}’ DB_NAME = “” MONGO_SERVER = “127.0.0.1:27017” conn_str = CONN_STR.format(MONGO_SERVER) conn = MongoClient(conn_str) db = conn[DB_NAME] … Continue reading

Posted in Uncategorized | Leave a comment

Set row color in ui-grid conditionally

$scope.regularAssignmentGridOptions = { rowTemplate: ‘ ng-style=” row.entity.target == 4 && {\’font-weight\’:\’bold\’,\’color\’:\’red\’}”> ‘, columnDefs: [ {name: ‘grade’, width: ‘5%’}, {name: ‘type’, width: ‘8%’}, {name: ‘start’, width: ‘6%’, displayName: ‘Start Level/Score ‘}, {name: ‘target’, width: ‘6%’,displayName: ‘Target Level/Score ‘}, ] }

Posted in Uncategorized | Leave a comment

Python obj to JSON in Flask

Posted in Uncategorized | Leave a comment

Python object to/from JSON string

import json user = { “name”: “Test”, “_id”: “1234567890”, “address”: { “street”: “De Anza”, “city”: “San Jose” } } json_from_user = json.JSONEncoder().encode(user) print json_from_user user_from_json = json.JSONDecoder().decode(json_from_user) print user_from_json

Posted in Uncategorized | Leave a comment