db.users.update({}, {$rename: {'username': 'email', 'password': 'hashedPassword'}, false, true});
Before : [{username: "[email protected]", password: "pwd"}]
after : [{email: "[email protected]", hashedPassword: "pwd"}]
| sudo npm cache clean -f | |
| sudo npm install -g n | |
| sudo n stable | |
| sudo n 0.12.7 |
db.users.update({}, {$rename: {'username': 'email', 'password': 'hashedPassword'}, false, true});
Before : [{username: "[email protected]", password: "pwd"}]
after : [{email: "[email protected]", hashedPassword: "pwd"}]
| //Enable Express csrf protection | |
| app.use(express.csrf()); | |
| app.use(function(req, res, next) { | |
| res.locals.csrftoken = req.csrfToken(); | |
| next(); | |
| }); |
| app.factory('authInterceptor', function ($cookies) { | |
| return { | |
| // Add authorization token to headers | |
| request: function (config) { | |
| config.headers = config.headers || {}; | |
| config.headers.post['x-csrf-token'] =$cookies['XSRF-TOKEN']; | |
| return config; | |
| } | |
| }; | |
| }); |
| var database = require('../../../models'); | |
| var async = require('async'); | |
| var VisitorApi = (function() { | |
| /** | |
| * Public Functions | |
| */ | |
| var _countVisitorsByOperator = function(operator,value,callback) { | |
| var query = {}; | |
| query[operator] = value; |
| docker ps -a | awk '{print $1}' | xargs --no-run-if-empty docker rm |
| var countUser = function (callback) { | |
| database.getCollection('User').find(function (err, nbUsers) { | |
| if (err) return callback(err); | |
| return callback(null, nbUsers.length); | |
| }); | |
| }; | |
| var countRestaurantByCity = function(city, callback) { | |
| database.getCollection('Restaurant').count({'adresse.ville': city}, function (err, nbR) { | |
| if (err) return callback(err); | |
| return callback(null, nbR); |
| #!/usr/bin/env python | |
| """ | |
| Your task is as follows: | |
| - read the provided Excel file | |
| - find and return the min, max and average values for the COAST region | |
| - find and return the time value for the min and max entries | |
| - the time values should be returned as Python tuples | |
| Please see the test function for the expected return format | |
| """ |
| def parse_file(datafile): | |
| name = "" | |
| data = [] | |
| with open(datafile,'rb') as f: | |
| r = csv.reader(f) | |
| name = r.next()[1] | |
| header = r.next() | |
| data = [row for row in r] | |
| return (name, data) |