Show a single token, mind you: it can be a SingleSurveyTrack
769484
public function showAction()
    {
        $this->showParameters = $this->showParameters + $this->defaultTokenParameters;
        $this->showSnippets   = $this->getToken()->getShowSnippetNames();

        parent::showAction();
    }
917487
function checkAtkeyword(i) {
  let l;

  // Check that token is `@`:
  if (i >= tokensLength ||
      tokens[i++].type !== TokenType.CommercialAt) return 0;

  return (l = checkIdentOrInterpolation(i)) ? l + 1 : 0;
}
683390
public function toSurveyAction()
    {
        if (! $this->_initToken()) {
            // Default option
            $this->_forward('index');
            return;
        }

        $language = $this->locale->getLanguage();

        try {
            $url  = $this->token->getUrl(
                    $language,
                    $this->currentUser->getUserId() ? $this->currentUser->getUserId() : $this->token->getRespondentId()
                    );

            /************************
             * Optional user logout *
             ************************/
            if ($this->currentUser->isLogoutOnSurvey()) {
                $this->currentUser->unsetAsCurrentUser();
            }

            // Redirect at once
            header('Location: ' . $url);
            exit();

        } catch (\Gems_Tracker_Source_SurveyNotFoundException $e) {
            $this->addMessage(sprintf(
                    $this->_('The survey for token %s is no longer active.'),
                    strtoupper($this->tokenId)
                    ));

            // Default option
            $this->_forward('index');
        }
    }
859995
def _verify_multi(self, token, verifying_keys, num_required=None):
        
        headers, payload, raw_signatures, signing_inputs = _unpack_token_json(token)
        if num_required is None:
            num_required = len(raw_signatures)

        if num_required > len(verifying_keys):
            # not possible
            return False

        if len(headers) != len(raw_signatures):
            # invalid 
            raise DecodeError('Header/signature mismatch')

        verifying_keys = [load_verifying_key(vk, self.crypto_backend) for vk in verifying_keys]

        # sanity check: only support one type of key :(
        for vk in verifying_keys:
            if vk.curve.name != verifying_keys[0].curve.name:
                raise DecodeError("TODO: only support using keys from one curve per JWT")
                
        der_signatures = [raw_to_der_signature(rs, verifying_keys[0].curve) for rs in raw_signatures]

        # verify until threshold is met
        num_verified = 0
        for (signing_input, der_sig) in zip(signing_inputs, der_signatures):
            for vk in verifying_keys:
                verifier = self._get_verifier(vk, der_sig)
                verifier.update(signing_input)
                try:
                    verifier.verify()
                    num_verified += 1
                    verifying_keys.remove(vk)
                    break
                except InvalidSignature:
                    pass

            if num_verified >= num_required:
                break

        return (num_verified >= num_required)
43820
def _emitHMM(self, token_type, past_states, past_emissions):
        
        assert token_type in self.emissions
        return utils.weighted_choice(self.emissions[token_type].items())
835510
function Brain(dataset) {
  // The root of the tree represents the start of the query.
  this.root = new Node(this)

  // List of token matchers: functions from tokens
  // (see src/tokenizers/tokenize.js)
  // to either nothing (if no match) or {tag, length, data}.
  this.tokenMatchers = tokenize.defaultTokenMatchers()

  // Number of examples per label.
  this.numExamples = new Map()
  // Are weights built?
  this.weightsNeedBuilding = true
  this.links = []

  this.learn = this.learn.bind(this)
  if (dataset != null) {
    dataset.forEach(this.learn)
  }
}
549990
def match_token(token, tok_type, tok_str=None):
  """"""
  return token.type == tok_type and (tok_str is None or token.string == tok_str)
637194
function singleOrAll (modelNode, address, minTreeAr) {
  const getMin = indices => {
    if (indices.length === 0) {
      // If all elements in the array are null, return null.
      return null
    } else if (nonNullIndices.signals.length === 1) {
      // If there is a single value, return that tree, with an updated address.
      return {
        minSignals: {
          diff: minTreeAr.map(a => a.minSignals.diff),
          address,
          modelNode,
        },
        minUpdate: {
          diff: minTreeAr.map(a => a.minUpdate.diff),
          address,
          modelNode,
        },
      }
    } else {
      // Otherwise, return full trees from this level.
      return {
        minSignals: {
          diff: minTreeAr.map(a => a.minSignals.diff),
          address,
          modelNode,
        },
        minUpdate: {
          diff: minTreeAr.map(a => a.minUpdate.diff),
          address,
          modelNode,
        },
      }
    }
  }
  // Get the indices where the signal and update trees are not null.
  const nonNullIndices = minTreeAr.reduce((accum, val, i) => {
    return {
      signals: val.minSignals !== null ? [ ...accum.signals, i ]: accum.signals,
      update: val.minUpdate !== null ? [ ...accum.update, i ]: accum.update,
    }
  }, { signals: [], update: [] })
  // For each set of indices, test the diffs with these tests to get a minimum
  // tree.
  const minSignals = getMin(nonNullIndices.signals)
  const minUpdate = getMin(nonNullIndices.update)
  return { minSignals, minUpdate }
}
5347
function (source, nextToken) {
      var tm = this,
          tokenizerRe,
          lastIndex,
          matches,
          textType;

      // Initialize for first run
      // if no template passed assume first pass
      // and use the main template.
      if (typeof source === "undefined") {
        source = tm.template;
      }

      // if no token passed, this is an open tag lookup
      if (typeof nextToken === "undefined") {
        tm._tokens = [];
        nextToken = tm.lex.tagOpen;
      }

      while (source) {
        // Use created token.
        tokenizerRe = nextToken.compiledRe;
        matches = tokenizerRe.exec(source);

        lastIndex = tokenizerRe.lastIndex;
        tokenizerRe.lastIndex = 0;

        // This guy matched. So let's push the tokens.
        if (matches) {

          // Flags to see if code or text
          if (nextToken === tm.lex.tagOpen) {
            // if the match was done using the tagOpen, then everything we matched is normal text.
            textType = "text";
          } else {
            // assume the match was a closing tag, so everything we have is code.
            textType = "code";
          }

          // if the token is a tagOpen, or tagClose, we need to push it with the text value matched.
          if (nextToken.hasText) {
            tm._tokens.push({
              type : textType,
              value : matches[1]
            });
          } else {
            // push the token name into the array to mark the open/close/print status on it.
            tm._tokens.push({
              type : nextToken.name
            });
          }

          // A print indicator just shows open prints, so we buffer the open print.
          if (nextToken === tm.lex.printIndicator) {
            tm._openPrints.push(tm._openBrackets);
          }

          // Closing an open print needs to count for open brackets, so we can separate the code blocks.
          if (nextToken === tm.lex.tagClose && tm._openPrints.length > 0) {
            tm._countBrackets(matches[1]);
          }

          // We matched, so let's keep going.
          // from where we left with our new next token.
          source    = source.substr(lastIndex);
          nextToken = tm._nextToken(nextToken);

        //No match:
        } else {
          // We couldn't match anything else. So: Either it's a syntax error,
          // or it's just text. If we were awaiting another token we fail, otherwise
          // assume it's just text.
          if (nextToken == tm.lex.tagOpen) {
            tm._tokens.push({
              type  : "text",
              value : source
            });

            source = "";

          } else {
            // If it wasn't optional. GO!
            if (nextToken.optional) {
              // So continue from where we left with our new next token.
              source    = source.substr(lastIndex);
              nextToken = tm._nextToken(nextToken);

            // so it was not a printing tag, so something went wrong.
            } else {
              throw "Syntax Error: Expecting " + nextToken.name + " ... Nowhere to be found. So I was like, what?";
            }
          }
        }
      }
    }
1071211
public void visitToken(Token token) {
    for (Trivia trivia : token.getTrivia()) {
      if (!trivia.isComment()) {
        continue;
      }
      Token triviaToken = trivia.getToken();
      String comment = triviaToken.getOriginalValue();
      int line = triviaToken.getLine();
      if (indexOfIgnoreCase(comment) != -1) {
        String[] lines = EOL_PATTERN.split(comment);

        for (int i = 0; i < lines.length; i++) {
          int start = indexOfIgnoreCase(lines[i]);
          if (start != -1 && !isLetterAround(lines[i], start)) {
            check.getContext().createLineViolation(check, message, line + i);
          }
        }
      }
    }
  }
734988
def single(wosclient, wos_query, xml_query=None, count=5, offset=1):
    """"""
    result = wosclient.search(wos_query, count, offset)
    xml = _re.sub(' xmlns="[^"]+"', '', result.records, count=1).encode('utf-8')
    if xml_query:
        xml = _ET.fromstring(xml)
        return [el.text for el in xml.findall(xml_query)]
    else:
        return _minidom.parseString(xml).toprettyxml()
516174
public function inSource(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId = null)
    {
        $tokenInfo = $this->getTokenInfo($token, $surveyId, $sourceSurveyId);
        return (boolean) $tokenInfo;
    }
420768
def btc_is_singlesig(privkey_info, **blockchain_opts):
    
    try:
        jsonschema.validate(privkey_info, PRIVKEY_SINGLESIG_SCHEMA)
        return True
    except ValidationError as e:
        return False
1205431
function processGetMetrics(req,res){

    processAuth(req,res).then(function (authResult){
        if(!authResult){
            return;
        }
        res.status(200).set('Content-Type', 'text/plain');
        res.end(promClient.register.metrics());
    });

    /*
    if(!processAuth(req,res)) {
        return;
    }

    res.status(200).set('Content-Type', 'text/plain');
    res.end(promClient.register.metrics());
    */
}
614849
function _checkUnicodeWildcard(i) {
  const start = i;

  if (i >= tokensLength) return 0;

  while (i < tokensLength) {
    if (tokens[i].type === TokenType.QuestionMark) i += 1;
    else break;
  }

  return i - start;
}
1346470
private void checkForTokens( String content, int startOffset, int endOffset ) {
        while( startOffset <= endOffset ) {
            // skip the delimiters to find the start of a new token
            while( isDelimiter(content.substring(startOffset, startOffset + 1)) ) {
                if (startOffset < endOffset)
                    startOffset++;
                else
                    return;
            }
            // Extract and process the entire token
            if (isQuoteDelimiter(content.substring(startOffset, startOffset + 1)))
                startOffset = getQuoteToken(content, startOffset, endOffset);
            else
                startOffset = getOtherToken(content, startOffset, endOffset);
        }
    }
738569
def tokenProgressFunc(state="update", action=None, text=None, tick=0):
	
	print("tokenProgressFunc %s: %s\n%s (%s)"%(state, str(action), str(text), str(tick)))