Construct a Matrix user.
@constructor
@param {string} userId The user_id of the user.
@param {Object=} data Serialized data values
@param {boolean} escape [true] Escape the user's localpart.
351721
function MatrixUser(userId, data, escape=true) {
    if (!userId) {
        throw new Error("Missing user_id");
    }
    if (data && Object.prototype.toString.call(data) !== "[object Object]") {
        throw new Error("data arg must be an Object");
    }
    this.userId = userId;
    const split = this.userId.split(":");
    this.localpart = split[0].substring(1);
    this.host = split[1];
    if (escape) {
        this.escapeUserId();
    }
    this._data = data || {};
}
801348
function buildUserHtml(userLogin, userId, isNew) {
  var userHtml = "<a href='#' id='" + userId;
  if(isNew){
    userHtml += "_new'";
  }else{
    userHtml += "'";
  }
  userHtml += " class='col-md-12 col-sm-12 col-xs-12 users_form' onclick='";
  userHtml += "clickToAdd";
  userHtml += "(\"";
  userHtml += userId;
  if(isNew){
    userHtml += "_new";
  }
  userHtml += "\")'>";
  userHtml += userLogin;
  userHtml +="</a>";

  return userHtml;
}
595034
function(matrix) {
            	var M = matrix.elements || matrix;
            	if (typeof(M[0][0]) == 'undefined') { M = Matrix$b.create(M).elements; }
            	// this.columns should equal matrix.rows
            	return (this.elements[0].length == M.length);
                }
340008
function User(data){
    var self = this;
    Object.keys(data).map(function(k){
      self[k] = data[k];
    });
  }
520914
public static String createLookupKey(String realm, String userid) {
        String key = null;
        if (realm != null && userid != null) {
            key = realm + KEY_SEPARATOR + userid;
        }
        return key;
    }
691070
function usernameIsUnique ( id ) {
        var deferred = q.defer();

        db.users.query( [ { key: 'identities.basic.username', cmp: '=', value: user.identities.basic.username } ] ,
            { limit: 1, skip: 0 } ).then(
                function ( payload ) {
                    if ( payload.total === 0 ) {
                        deferred.resolve();
                    }
                    else if( !_.isUndefined( id ) && payload.results[0]._id.toString() === id.toString() ) {
                        deferred.resolve();
                    }
                    else {
                        deferred.reject( new Error(messages.duplicate_username) );
                    }
                },
                function ( err ) {
                    deferred.reject( err );
                }
            );

        return deferred.promise;
    }
412239
function _Matrix(numRows, numColumns, data) {
  if(!Number.isInteger(numRows))
    throw new TypeError("/numRows/ must be an integer.");
  if(!Number.isInteger(numColumns))
      throw new TypeError("/numColumns/ must be an integer.");

  var _values;
  var _numValues = numRows * numColumns;
  if (!data || data === undefined)
    _values = [];
  else if (!util.isNumberArray(data))
    throw new TypeError('Invalid values for vector.');
  else
    _values = data;

  // Make sure the matrix has numRows * numColumns values
  if (_values.length < _numValues) {
    var zeros = Array(_numValues - _values.length).fill(0);
    _values = _values.concat(zeros);
  } else if (_values.length > _numValues) {
    _values = _values.slice(0, _numValues);
  }

  var size = {"rows": numRows, "columns": numColumns};
  readonly(this, "size", size);
  readonly(this, "values", _values);
  readonly(this, "rows", _getRows(this));
  readonly(this, "columns", _getColumns(this));
}
1180705
static void createUserIfMissing(DbConn cnx, String login, String password, String description, String... roles)
    {
        try
        {
            int userId = cnx.runSelectSingle("user_select_id_by_key", Integer.class, login);
            cnx.runUpdate("user_update_enable_by_id", userId);
            RUser.set_roles(cnx, userId, roles);
        }
        catch (NoResultException e)
        {
            String saltS = null;
            String hash = null;
            if (null != password && !"".equals(password))
            {
                ByteSource salt = new SecureRandomNumberGenerator().nextBytes();
                hash = new Sha512Hash(password, salt, 100000).toHex();
                saltS = salt.toHex();
            }

            RUser.create(cnx, login, hash, saltS, roles);
        }
    }
63095
function insertUser (client, { id, name, organizationId, metadata }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      id = id || uuidV4()

      const sqlQuery = SQL`
        INSERT INTO users (
          id, name, org_id, metadata
        ) VALUES (
          ${id}, ${name}, ${organizationId}, ${metadata}
        )
        RETURNING id
      `

      client.query(sqlQuery, (err, result) => {
        if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
        if (err) return cb(Boom.badImplementation(err))

        cb(null, result)
      })

      return promise
    }
40171
function extractUserId(userIdObject: any): any {
  let newUserId = '';
  if (_.isObject(userIdObject)) {
    Object.keys(userIdObject).forEach(field => {
      newUserId = userIdObject[field];
    });
  } else {
    newUserId = userIdObject;
  }
  return newUserId;
}
1159522
function appendUser(socket, params) {
        try {
            var extra = params.extra;

            var params = socket.handshake.query;

            if (params.extra) {
                try {
                    if (typeof params.extra === 'string') {
                        params.extra = JSON.parse(params.extra);
                    }
                    extra = params.extra;
                } catch (e) {
                    extra = params.extra;
                }
            }

            listOfUsers[socket.userid] = {
                socket: socket,
                connectedWith: {},
                extra: extra || {},
                admininfo: {},
                socketMessageEvent: params.socketMessageEvent || '',
                socketCustomEvent: params.socketCustomEvent || ''
            };
        } catch (e) {
            pushLogs(config, 'appendUser', e);
        }

        sendToAdmin();
    }
219497
def data_filler_user_agent(self, number_of_rows, pipe):
        '''
        '''

        try:
            for i in range(number_of_rows):
                pipe.hmset('user_agent:%s' % i, {
                    'id': rnd_id_generator(self),
                    'ip': self.faker.ipv4(),
                    'countrycode': self.faker.country_code(),
                    'useragent': self.faker.user_agent()
                })
            pipe.execute()
            logger.warning('user_agent Commits are successful after write job!', extra=d)

        except Exception as e:
            logger.error(e, extra=d)
591388
static function construct($name, $id, $aliases = [])
  {
    $user = new NyaaUser();
    $user->name = $name;
    $user->id = $id;
    $user->aliases = $aliases;

    return $user;
  }
401067
public StructuredDataId makeId(final String defaultId, final int anEnterpriseNumber) {
        String id;
        String[] req;
        String[] opt;
        if (anEnterpriseNumber <= 0) {
            return this;
        }
        if (this.name != null) {
            id = this.name;
            req = this.required;
            opt = this.optional;
        } else {
            id = defaultId;
            req = null;
            opt = null;
        }

        return new StructuredDataId(id, anEnterpriseNumber, req, opt);
    }
448649
function createUser(form) {
      // refuse to work with invalid data
      if (vm.user._id || (form && !form.$valid)) {
        return;
      }

      Auth.createUser(vm.user)
        .then(createUserSuccess)
        .catch(createUserCatch);

      function createUserSuccess(newUser) {
        Toast.show({
          type: 'success',
          text: 'User ' + newUser.name + ' has been created',
          link: {state: 'admin.user.list.detail', params: {id: newUser._id}}
        });
        vm.close();
      }

      function createUserCatch(err) {
        if (form && err) {
          form.setResponseErrors(err);
        }

        Toast.show({
          type: 'warn',
          text: 'Error while creating a new user'
        });
      }
    }
1267637
def create_from_userdata(userdata):
        """"""
        memhi = userdata.get('d3')
        memlo = userdata.get('d4')
        memory = memhi << 8 | memlo
        control_flags = userdata.get('d6')
        group = userdata.get('d7')
        addrhi = userdata.get('d8')
        addrmed = userdata.get('d9')
        addrlo = userdata.get('d10')
        addr = Address(bytearray([addrhi, addrmed, addrlo]))
        data1 = userdata.get('d11')
        data2 = userdata.get('d12')
        data3 = userdata.get('d13')
        return ALDBRecord(memory, control_flags, group, addr,
                          data1, data2, data3)
296583
function updateUserDataField(userId, data, overwrite, callback) {
        return _updateUserObjectField(userId, ['data'], data, overwrite)
            .then(function (userData) {
                return userData.data;
            })
            .nodeify(callback);
    }