create a unique id and returns it if the callback with same extra arguments was already scheduled, then returns same id
340521
function create(callback) {
  /* jslint validthis: true */
  for (var
    queue = this,
    args = [],
    info = {
      id: {},
      fn: callback,
      ar: args
    },
    i = 1; i < arguments.length; i++
  ) args[i - 1] = arguments[i];
  return infoId(queue, info) || (queue.push(info), info.id);
}
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;
    }
1085921
function findOrCreate(params, cb) {
	/* istanbul ignore next */
	if (typeof cb !== 'function') {
		throw new Error('Callback must be a function');
	}

	db.findOne(params, (err, doc) => {
		/* istanbul ignore next: hard-to-invoke error */
		if (err) {
			cb(err);
			return;
		}

		if (doc) {
			cb(null, doc.token);
		} else {
			params.token = uuid();
			db.insert(params, (err, newDoc) => {
				/* istanbul ignore next: hard-to-invoke error */
				if (err) {
					cb(err);
					return;
				}

				cb(null, newDoc.token);
			});
		}
	});
}
72347
def checkAndCreate(self, key, payload):
        
        if key not in self:
            self[key] = payload
        return self[key]['id']
382849
def validate_unique(self, *args, **kwargs):
        """"""
        super(EighthSignup, self).validate_unique(*args, **kwargs)

        if self.has_conflict():
            raise ValidationError({NON_FIELD_ERRORS: ("EighthSignup already exists for the User and the EighthScheduledActivity's block",)})
157966
function createId (coll) {
  var _ = this
  var idProperty = _.__id()
  if (_.isEmpty(coll)) {
    return 1
  } else {
    var id = _.maxBy(coll, function (doc) {
      return doc[idProperty]
    })[idProperty]

    if (_.isFinite(id)) {
      // Increment integer id
      return ++id
    } else {
      // Generate string id
      return uuid()
    }
  }
}
1355445
def duplicate(self):
        '''
        
        '''
        return self.__class__(amount=self.amount, date=self.date,
                              method=self.method, ref=self.ref)
706238
def gen_unique_id():
    
    # Workaround for http://bugs.python.org/issue4607
    if ctypes and _uuid_generate_random:
        buffer = ctypes.create_string_buffer(16)
        _uuid_generate_random(buffer)
        return str(UUID(bytes=buffer.raw))
    return str(uuid4())
923221
public static function callbackUniqueId(callable $callback = null)
    {
        if (is_string($callback)) {
            return $callback;
        }
        if (is_object($callback)) {
            $callback = [$callback, ''];
        } else {
            $callback = (array) $callback;
        }
        if (is_object($callback[0])) {
            return spl_object_hash($callback[0]).$callback[1];
        } else {
            if (is_string($callback[0])) {
                return $callback[0].'::'.$callback[1];
            }
        }
    }
952407
function(id, period, callback) {
    var self = this;

    if (this.$resource.cron) {
      if (!this.crons[id]) {
        self._logger.call(self, 'POD:Registering Cron:' + self.getName() + ':' + id);
        self.crons[id] = new self.$resource.cron.CronJob(
          period,
          callback,
          null,
          true,
          self.options.timezone
        );
      }
    }
  }
25501
def ensure_unique(qs, field_name, value, exclude_id=None):
    
    orig = value
    if not value:
        value = "None"
    for x in itertools.count(1):
        if not qs.exclude(id=exclude_id).filter(**{field_name: value}).exists():
            break
        if orig:
            value = '%s-%d' % (orig, x)
        else:
            value = '%d' % x

    return value
980032
function(e, unique_id){
			
			var timer_str = (this._custom_timer) ? this._custom_timer : this.time;
			this['_int_id_' + unique_id] = setTimeout(function(){ 
				Gritter._fade(e, unique_id);
			}, timer_str);
		
		}
216088
def _generate_ack_id(self, sid, namespace, callback):
        """"""
        namespace = namespace or '/'
        if sid not in self.callbacks:
            self.callbacks[sid] = {}
        if namespace not in self.callbacks[sid]:
            self.callbacks[sid][namespace] = {0: itertools.count(1)}
        id = six.next(self.callbacks[sid][namespace][0])
        self.callbacks[sid][namespace][id] = callback
        return id
475092
def check_uniqueness(self, *args):
        
        self.get_unique_index().check_uniqueness(*self.prepare_args(args, transform=False))
637223
def id_(reset=False):
    '''
    
    '''
    if reset:
        id_pattern = re.compile(r'Monit id (?P<id>[^ ]+)')
        cmd = 'echo y|monit -r'
        out = __salt__['cmd.run_all'](cmd, python_shell=True)
        ret = id_pattern.search(out['stdout']).group('id')
        return ret if ret else False
    else:
        cmd = 'monit -i'
        out = __salt__['cmd.run'](cmd)
        ret = out.split(':')[-1].strip()
    return ret
376075
def unique_id
      # check all_data instead of data, as we have to not reuse deleted key
      ids = Set.new(all_data.map { |e| e[:key] })
      id = 1
      loop do
        return id.to_s unless ids.include?(id.to_s)

        id += 1
      end
    end
1013582
def uniqueID(size=6, chars=string.ascii_uppercase + string.digits):
    """"""
    return ''.join(random.choice(chars) for x in xrange(size))