Creates an instance of `Strategy` checking api keys.
542300
function Strategy (options, verify) {
  if (typeof options === 'function') {
    verify = options
    options = {}
  } else {
    if (options && options.log) {
      log = options.log
    }
  }
  if (!verify) {
    throw new Error('apikey authentication strategy requires a verify function')
  }

  passport.Strategy.call(this)

  this._apiKeyHeader = options.apiKeyHeader || 'api_key'
  this.name = 'apikey'
  this._verify = verify
  this._passReqToCallback = true
}
1025276
@Override
	public <T extends Endpoint> Strategy<T> create() {
		return new RoundRobinStrategy<T>(broker, preferLocal);
	}
820083
def use_strategy(new_strategy):
    
    def wrapped_class(klass):
        klass._meta.strategy = new_strategy
        return klass
    return wrapped_class
203001
def strategyLastK(kls, n, k=10):
		""""""
		return set(map(str, filter(lambda x:x>=0, range(n, n-k, -1))))
880379
def _fetch_strategy(name, scope)
      @strategies[scope][name] ||= if klass = Warden::Strategies[name]
        klass.new(@env, scope)
      elsif @config.silence_missing_strategies?
        nil
      else
        raise "Invalid strategy #{name}"
      end
    end
539815
function (data, strategy, term) {
      return $.map(data, function (value) {
        return { value: value, strategy: strategy, term: term };
      });
    }
29732
protected function buildStrategies()
    {
        foreach ($this->strategies as $parameterName => &$strategy) {

            // only build strategies we will actually use

            if ($this->isParameterIgnored($parameterName)) continue;

            // get the value for the filter parameter
            // and if it is empty, we're not filtering by it and should skip it
            $parameterValue = $this->parameterValue($parameterName);

            if ($this->isParameterValueUnset($parameterName, $parameterValue)) continue;

            // check if the strategy is a string that should be instantiated as a class
            if (is_string($strategy) && $strategy !== static::SETTING) {

                try {

                    $reflection = new ReflectionClass($strategy);

                    if ( ! $reflection->IsInstantiable()) {
                        throw new ParameterStrategyInvalidException("Uninstantiable string provided as strategy for '{$strategy}'");
                    }

                    $strategy = new $strategy();

                } catch (\Exception $e) {

                    throw new ParameterStrategyInvalidException(
                        "Exception thrown while trying to reflect or instantiate string provided as strategy for '{$strategy}'",
                        0, $e
                    );
                }

                // check if it is of the correct type
                if ( ! is_a($strategy, ParameterFilterInterface::class)) {

                    throw new ParameterStrategyInvalidException(
                        "Instantiated string provided is not a ParameterFilter: '" . get_class($strategy) . "'"
                    );
                }
            }
        }

        unset($strategy);

        return $this->strategies;
    }
1153750
def strategyKLogN(kls, n, k=4):
		""""""
		assert(k>1)
		s = set([n])
		i = 0
		
		while k**i <= n:
			s.update(range(n, n-k*k**i, -k**i))
			i += 1
			n -= n % k**i
		
		return set(map(str, filter(lambda x:x>=0, s)))
1252361
def apply_strategy(rule, table, column, primary_key)
      if rule.is_a?(Hash)
        if rule.key?("value")
          escape(rule["value"])
        elsif rule.key?("statement")
          rule["statement"]
        else
          raise PgSync::Error, "Unknown rule #{rule.inspect} for column #{column}"
        end
      else
        case rule
        when "untouched"
          quote_ident(column)
        when "unique_email"
          "'email' || #{quoted_primary_key(table, primary_key, rule)}::text || '@example.org'"
        when "unique_phone"
          "(#{quoted_primary_key(table, primary_key, rule)}::bigint + 1000000000)::text"
        when "unique_secret"
          "'secret' || #{quoted_primary_key(table, primary_key, rule)}::text"
        when "random_int", "random_number"
          "(RANDOM() * 100)::int"
        when "random_date"
          "date '1970-01-01' + (RANDOM() * 10000)::int"
        when "random_time"
          "NOW() - (RANDOM() * 100000000)::int * INTERVAL '1 second'"
        when "random_ip"
          "(1 + RANDOM() * 254)::int::text || '.0.0.1'"
        when "random_letter"
          "chr(65 + (RANDOM() * 26)::int)"
        when "random_string"
          "RIGHT(MD5(RANDOM()::text), 10)"
        when "null", nil
          "NULL"
        else
          raise PgSync::Error, "Unknown rule #{rule} for column #{column}"
        end
      end
    end
778404
function (strategy, selector, mult, context) {
    let ext = mult ? 's' : '';
    let command = '';
    context = !context ? context : `, '${context}'` ;
    switch (strategy) {
      case 'name':
        command = `au.getElement${ext}ByName('${selector}'${context})`;
        break;
      case 'accessibility id':
        command = `au.getElement${ext}ByAccessibilityId('${selector}'${context})`;
        break;
      case 'id':
        command = `au.getElement${ext}ById('${selector}')`;
        break;
      case '-ios uiautomation':
        command = `au.getElement${ext}ByUIAutomation('${selector}'${context})`;
        break;
      default:
        command = `au.getElement${ext}ByType('${selector}'${context})`;
    }

    return command;
  }
495102
def build(self, identity, modules, strategy=constants.DEFAULT_CONFIG):
        '''
        
        '''
        # TODO Catch a problem here
        self.engine = TradingEngine(identity, modules, strategy)
        self.initial_cash = strategy['manager'].get('cash', None)
372232
function() {
    if (this._baseOptions) {
      return this._baseOptions;
    }

    var strategies = this.strategies();
    var strategyOptions = Object.keys(strategies).reduce(function(result, strategyName) {
      var options = strategies[strategyName].availableOptions;

      if (Array.isArray(options)) {
        // Add strategy qualifier to option descriptions
        options.forEach(function(option) {
          option.description = "when strategy is '" + strategyName + "', " + option.description;
        });

        result = result.concat(options);
      }

      return result;
    }, []);

    return this._baseOptions = availableOptions.concat(strategyOptions);
  }
19666
def run(self):
        
        logger.info(
            "The {} strategy will be applied on each duplicate set.".format(
                self.conf.strategy))

        self.stats['set_total'] = len(self.mails)

        for hash_key, mail_path_set in self.mails.items():
            # Print visual clue to separate duplicate sets.
            logger.info('---')

            duplicates = DuplicateSet(hash_key, mail_path_set, self.conf)

            # Perfom the deduplication.
            duplicates.dedupe()

            # Merge stats resulting of actions on duplicate sets.
            self.stats += duplicates.stats
1197849
public function buildStrategy($strategy, $concrete = null)
    {
        // If we passed a concrete implementation
        // look for it specifically
        $handle = Str::snake($strategy, '-');
        if ($concrete) {
            $handle .= '.'.Str::snake($concrete, '-');
        }

        // If no found instance, create a new one
        $handle = 'rocketeer.strategies.'.$handle;
        if (!$this->container->has($handle)) {
            $option = Str::snake($strategy, '-');
            $concrete = $concrete ?: $this->config->getContextually('strategies.'.$option);
            $strategy = $this->buildStrategyFromName($strategy, $concrete);
            if (!$strategy) {
                return;
            }

            $this->container->add($handle, $strategy);
        }

        // Get and register modules
        /** @var AbstractStrategy $strategy */
        $strategy = $this->container->get($handle);
        $strategy = $this->modulable->registerBashModulesOn($strategy);

        return $strategy;
    }
190965
public void setProxyIdpAuthenticationContextLookupStrategy(
      final Function<AuthenticationContext, ProxyIdpAuthenticationContext> strategy) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    this.proxyIdpAuthenticationContextLookupStrategy = Constraint.isNotNull(strategy,
      "ProxyIdPAuthenticationContext lookup strategy cannot be null");
  }
753737
@Override
	public <T extends Endpoint> Strategy<T> create() {
		if (transporter == null) {
			return new RoundRobinStrategy<T>(broker, preferLocal);
		}
		return new NetworkLatencyStrategy<T>(broker, preferLocal, maxTries, this);
	}
176580
public void setAssertionLookupStrategy(final Function<ProfileRequestContext, Assertion> strategy) {
    ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
    this.assertionLookupStrategy = Constraint.isNotNull(strategy, "Assertion lookup strategy cannot be null");
  }