/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
 *  File Name:          String/match-003.js
 *  ECMA Section:       15.6.4.9
 *  Description:        Based on ECMA 2 Draft 7 February 1999
 *
 *  Author:             christine@netscape.com
 *  Date:               19 February 1999
 */

/*
 *  String.match( regexp )
 *
 *  If regexp is not an object of type RegExp, it is replaced with result
 *  of the expression new RegExp(regexp). Let string denote the result of
 *  converting the this value to a string.  If regexp.global is false,
 *  return the result obtained by invoking RegExp.prototype.exec (see
 *  section 15.7.5.3) on regexp with string as parameter.
 *
 *  Otherwise, set the regexp.lastIndex property to 0 and invoke
 *  RegExp.prototype.exec repeatedly until there is no match. If there is a
 *  match with an empty string (in other words, if the value of
 *  regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1.
 *  The value returned is an array with the properties 0 through n-1
 *  corresponding to the first element of the result of each matching
 *  invocation of RegExp.prototype.exec.
 *
 *  Note that the match function is intentionally generic; it does not
 *  require that its this value be a string object.  Therefore, it can be
 *  transferred to other kinds of objects for use as a method.
 */

var SECTION = "String/match-003.js";
var VERSION = "ECMA_2";
var TITLE   = "String.prototype.match( regexp )";

startTest();

// the regexp argument is not a RegExp object
// this is not a string object

//  [if regexp.global is true] set the regexp.lastIndex property to 0 and
//  invoke RegExp.prototype.exec repeatedly until there is no match. If
//  there is a match with an empty string (in other words, if the value of
//  regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1.
//  The value returned is an array with the properties 0 through n-1
//  corresponding to the first element of the result of each matching invocation
//  of RegExp.prototype.exec.

// set the value of lastIndex
re = /([\d]{5})([-\ ]?[\d]{4})?$/g;

s = "Boston, MA 02134";

AddGlobalRegExpCases( re,
		      "re = " + re,
		      s,
		      ["02134" ]);

re.lastIndex = 0;

AddGlobalRegExpCases(
  re,
  "re = " + re + "; re.lastIndex = 0 ",
  s,
  ["02134"]);

re.lastIndex = s.length;

AddGlobalRegExpCases(
  re,
  "re = " + re + "; re.lastIndex = " + s.length,
  s,
  ["02134"] );

re.lastIndex = s.lastIndexOf("0");

AddGlobalRegExpCases(
  re,
  "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"),
  s,
  ["02134"]);

re.lastIndex = s.lastIndexOf("0") + 1;

AddGlobalRegExpCases(
  re,
  "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1),
  s,
  ["02134"]);

test();

function AddGlobalRegExpCases(
  regexp, str_regexp, string, matches_array ) {

  // prevent a runtime error

  if ( string.match(regexp) == null || matches_array == null ) {
    AddTestCase(
      string + ".match(" + str_regexp +")",
      matches_array,
      string.match(regexp) );

    return;
  }

  AddTestCase(
    "( " + string  + " ).match(" + str_regexp +").length",
    matches_array.length,
    string.match(regexp).length );

  var limit = matches_array.length > string.match(regexp).length ?
    matches_array.length :
    string.match(regexp).length;

  for ( var matches = 0; matches < limit; matches++ ) {
    AddTestCase(
      "( " + string + " ).match(" + str_regexp +")[" + matches +"]",
      matches_array[matches],
      string.match(regexp)[matches] );
  }
}

{'repo_name': 'jxcore/jxcore', 'stars': '2265', 'repo_language': 'JavaScript', 'file_name': 'testencce.bat', 'mime_type': 'text/x-msdos-batch', 'hash': 8142878246539401048, 'source_dataset': 'data'}


var activeXObfuscator = require('./index');
var assert            = require('assert');

var OBFUSCATED_ACTIVE_X_OBJECT = activeXObfuscator.OBFUSCATED_ACTIVE_X_OBJECT;
var OBFUSCATED_ACTIVE_X        = activeXObfuscator.OBFUSCATED_ACTIVE_X;

var input =
  "foo(new ActiveXObject('Microsoft.XMLHTTP'))";
var expected =
  "foo(new window[" + OBFUSCATED_ACTIVE_X_OBJECT + "]('Microsoft.XMLHTTP'))";
assert.equal(activeXObfuscator(input), expected);

var input =
  "var foo = 'ActiveXObject';";
var expected =
  "var foo = " + OBFUSCATED_ACTIVE_X_OBJECT + ";";
assert.equal(activeXObfuscator(input), expected);

var input =
  'var foo = "ActiveXObject";';
var expected =
  "var foo = " + OBFUSCATED_ACTIVE_X_OBJECT + ";";
assert.equal(activeXObfuscator(input), expected);

var input =
  'var foo = o.ActiveXObject;';
var expected =
  "var foo = o[" + OBFUSCATED_ACTIVE_X_OBJECT + "];";
assert.equal(activeXObfuscator(input), expected);

var input =
  'var foo = "ActiveX";';
var expected =
  "var foo = " + OBFUSCATED_ACTIVE_X + ";";
assert.equal(activeXObfuscator(input), expected);

var input =
  "var foo = 'ActiveX';";
var expected =
  "var foo = " + OBFUSCATED_ACTIVE_X + ";";
assert.equal(activeXObfuscator(input), expected);

var input =
  "var foo; // ActiveX is cool";
var expected =
  "var foo; // Ac...eX is cool";
assert.equal(activeXObfuscator(input), expected);

var input =
  "var foo = 'ActiveX is cool';";
assert.throws(function() {
  activeXObfuscator(input);
}, /Unknown ActiveX occurence/);

{'repo_name': 'linyouhappy/kongkongxiyou', 'stars': '261', 'repo_language': 'C++', 'file_name': 'linyou.xml', 'mime_type': 'text/plain', 'hash': -7515447856547586441, 'source_dataset': 'data'}


<?php
/**
 * Slim - a micro PHP 5 framework
 *
 * @author      Josh Lockhart
 * @link        http://www.slimframework.com
 * @copyright   2011 Josh Lockhart
 *
 * MIT LICENSE
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 * Session Cookie Handler
 *
 * This class is used as an adapter for PHP's $_SESSION handling.
 * Session data will be written to and read from signed, encrypted
 * cookies. If the current PHP installation does not have the `mcrypt`
 * extension, session data will be written to signed but unencrypted
 * cookies; however, the session cookies will still be secure and will
 * become invalid if manually edited after set by PHP.
 *
 * @package Slim
 * @author Josh Lockhart
 * @since Version 1.3
 */
class Slim_Session_Handler_Cookies extends Slim_Session_Handler {

    public function open( $savePath, $sessionName ) {
        return true;
    }

    public function close() {
        return true; //Not used
    }

    public function read( $id ) {
        return $this->app->getEncryptedCookie($id);
    }

    public function write( $id, $sessionData ) {
        $this->app->setEncryptedCookie($id, $sessionData, 0);
    }

    public function destroy( $id ) {
        $this->app->deleteCookie($id);
    }

    public function gc( $maxLifetime ) {
        return true; //Not used
    }

}

{'repo_name': 'ccoenraets/wine-cellar-php', 'stars': '186', 'repo_language': 'PHP', 'file_name': 'main.js', 'mime_type': 'text/html', 'hash': -1412058711396654178, 'source_dataset': 'data'}


^<\?xml version="1.0"\?>
<GCC_XML[^>]*>
  <Class id="_1" name="start" context="_2" location="f1:1" file="f1" line="1" members="_3 _4 _5 _6 _7" size="[0-9]+" align="[0-9]+"/>
  <Converter id="_3" returns="_8" context="_1" access="private" location="f1:3" file="f1" line="3" mangled="[^"]+" attributes="annotate\(an annotation\)"/>
  <Constructor id="_4" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
  <Constructor id="_5" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?>
    <Argument type="_9" location="f1:1" file="f1" line="1"/>
  </Constructor>
  <OperatorMethod id="_6" name="=" returns="_10" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")? mangled="[^"]+">
    <Argument type="_9" location="f1:1" file="f1" line="1"/>
  </OperatorMethod>
  <Destructor id="_7" name="start" context="_1" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throw="")?/>
  <FundamentalType id="_8" name="int" size="[0-9]+" align="[0-9]+"/>
  <ReferenceType id="_9" type="_1c" size="[0-9]+" align="[0-9]+"/>
  <CvQualifiedType id="_1c" type="_1" const="1"/>
  <ReferenceType id="_10" type="_1" size="[0-9]+" align="[0-9]+"/>
  <Namespace id="_2" name="::"/>
  <File id="f1" name=".*/test/input/Converter-annotate.cxx"/>
</GCC_XML>$

{'repo_name': 'CastXML/CastXML', 'stars': '317', 'repo_language': 'C++', 'file_name': 'layout.html', 'mime_type': 'text/html', 'hash': -2636666106748474318, 'source_dataset': 'data'}


getClass()}">

            getLearnMoreRoute())}">
                getImagePath()}">

                {$promotion->getHeadline()}
                {if $promotion->getLearnMoreRoute()}
                    getLearnMoreRoute())}">Learn more...
                {/if}

{$promotion->getTagline()}

            {if $promotion->getDescription()}

{$promotion->getDescription()}

            {/if}

            {if $promotion->hasFeatures()}

                    {foreach $promotion->getFeatures() as $feature}

 {$feature}

                    {/foreach}

            {/if}

            <form method="post" action="{$targetUrl}">
                {foreach $inputParameters as $key => $value}
                    <input type="hidden" name="{$key}" value="{$value}">
                {/foreach}
                <button type="submit" class="btn btn-success">
                    {$promotion->getCta()} {$product->name}
                    {if $product->isFree()}
                        {lang key="orderfree"}
                    {else}
                        from just
                        {if $product->pricing()->first()->isYearly()}
                            {$product->pricing()->first()->yearlyPrice()}
                        {else}
                            {$product->pricing()->first()->monthlyPrice()}
                        {/if}
                    {/if}
                </button>
            </form>

{'repo_name': 'WHMCSCare/WHMCS-ThemeForest', 'stars': '118', 'repo_language': 'JavaScript', 'file_name': 'main.js', 'mime_type': 'text/plain', 'hash': -6045777390498848950, 'source_dataset': 'data'}


/*
 * RPA Virtual I/O device functions
 * Copyright (C) 2004 Linda Xie <lxie@us.ibm.com>
 *
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 * NON INFRINGEMENT.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * Send feedback to <lxie@us.ibm.com>
 *
 */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sysfs.h>
#include <linux/pci.h>
#include <linux/string.h>
#include <linux/slab.h>

#include <asm/rtas.h>
#include "rpaphp.h"

/* free up the memory used by a slot */
static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
{
	struct slot *slot = (struct slot *) hotplug_slot->private;
	dealloc_slot_struct(slot);
}

void dealloc_slot_struct(struct slot *slot)
{
	kfree(slot->hotplug_slot->info);
	kfree(slot->name);
	kfree(slot->hotplug_slot);
	kfree(slot);
}

struct slot *alloc_slot_struct(struct device_node *dn,
		int drc_index, char *drc_name, int power_domain)
{
	struct slot *slot;

	slot = kzalloc(sizeof(struct slot), GFP_KERNEL);
	if (!slot)
		goto error_nomem;
	slot->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
	if (!slot->hotplug_slot)
		goto error_slot;
	slot->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
					   GFP_KERNEL);
	if (!slot->hotplug_slot->info)
		goto error_hpslot;
	slot->name = kstrdup(drc_name, GFP_KERNEL);
	if (!slot->name)
		goto error_info;
	slot->dn = dn;
	slot->index = drc_index;
	slot->power_domain = power_domain;
	slot->hotplug_slot->private = slot;
	slot->hotplug_slot->ops = &rpaphp_hotplug_slot_ops;
	slot->hotplug_slot->release = &rpaphp_release_slot;

	return (slot);

error_info:
	kfree(slot->hotplug_slot->info);
error_hpslot:
	kfree(slot->hotplug_slot);
error_slot:
	kfree(slot);
error_nomem:
	return NULL;
}

static int is_registered(struct slot *slot)
{
	struct slot *tmp_slot;

	list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) {
		if (!strcmp(tmp_slot->name, slot->name))
			return 1;
	}
	return 0;
}

int rpaphp_deregister_slot(struct slot *slot)
{
	int retval = 0;
	struct hotplug_slot *php_slot = slot->hotplug_slot;

	 dbg("%s - Entry: deregistering slot=%s\n",
		__func__, slot->name);

	list_del(&slot->rpaphp_slot_list);

	retval = pci_hp_deregister(php_slot);
	if (retval)
		err("Problem unregistering a slot %s\n", slot->name);

	dbg("%s - Exit: rc[%d]\n", __func__, retval);
	return retval;
}
EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);

int rpaphp_register_slot(struct slot *slot)
{
	struct hotplug_slot *php_slot = slot->hotplug_slot;
	int retval;
	int slotno;

	dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n",
		__func__, slot->dn->full_name, slot->index, slot->name,
		slot->power_domain, slot->type);

	/* should not try to register the same slot twice */
	if (is_registered(slot)) {
		err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name);
		return -EAGAIN;
	}

	if (slot->dn->child)
		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
	else
		slotno = -1;
	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
	if (retval) {
		err("pci_hp_register failed with error %d\n", retval);
		return retval;
	}

	/* add slot to our internal list */
	list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head);
	info("Slot [%s] registered\n", slot->name);
	return 0;
}

{'repo_name': 'libos-nuse/net-next-nuse', 'stars': '238', 'repo_language': 'C', 'file_name': 'nf_tables_netdev.c', 'mime_type': 'text/x-c', 'hash': -6054510897495649372, 'source_dataset': 'data'}


/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved.
 *
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common Development
 * and Distribution License("CDDL") (collectively, the "License").  You
 * may not use this file except in compliance with the License.  You can
 * obtain a copy of the License at
 * https://oss.oracle.com/licenses/CDDL+GPL-1.1
 * or LICENSE.txt.  See the License for the specific
 * language governing permissions and limitations under the License.
 *
 * When distributing the software, include this License Header Notice in each
 * file and include the License file at LICENSE.txt.
 *
 * GPL Classpath Exception:
 * Oracle designates this particular file as subject to the "Classpath"
 * exception as provided by Oracle in the GPL Version 2 section of the License
 * file that accompanied this code.
 *
 * Modifications:
 * If applicable, add the following below the License Header, with the fields
 * enclosed by brackets [] replaced by your own identifying information:
 * "Portions Copyright [year] [name of copyright owner]"
 *
 * Contributor(s):
 * If you wish your version of this file to be governed by only the CDDL or
 * only the GPL Version 2, indicate your decision by adding "[Contributor]
 * elects to include this software in this distribution under the [CDDL or GPL
 * Version 2] license."  If you don't indicate a single choice of license, a
 * recipient has the option to distribute your version of this file under
 * either the CDDL, the GPL Version 2 or to extend the choice of license to
 * its licensees as provided above.  However, if you add GPL Version 2 code
 * and therefore, elected the GPL Version 2 license, then the option applies
 * only if the new code is made subject to such option by the copyright
 * holder.
 */

package com.sun.enterprise.admin.servermgmt.domain;

import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.sun.enterprise.admin.servermgmt.DomainConfig;
import com.sun.enterprise.admin.servermgmt.DomainException;
import com.sun.enterprise.admin.servermgmt.SLogger;
import com.sun.enterprise.admin.servermgmt.domain.SubstitutableTokens;
import com.sun.enterprise.universal.i18n.LocalStringsImpl;
import com.sun.enterprise.util.net.NetUtils;

public class DomainPortValidator {

    /* These properties are public interfaces, handle with care */
    private static final Logger _logger = SLogger.getLogger();
    private static final LocalStringsImpl _strings = new LocalStringsImpl(DomainPortValidator.class);

    public static final int PORT_MAX_VAL = 65535;

    private DomainConfig _domainConfig;
    private Properties _defaultProps;

    DomainPortValidator(DomainConfig domainConfig, Properties defaultProps) {
        _domainConfig = domainConfig;
        _defaultProps = defaultProps;
    }

    /**
     * Validate's the port. If custom port value is not given then it retrieves
     * its default value. If the port is already been occupied then it picks
     * randomly available port value.
     *
     * @throws DomainException If any exception occurs in validation.
     */
    public void validateAndSetPorts() throws DomainException {
        Properties domainProperties = _domainConfig.getDomainProperties();
        try {
            // Validate and gets the port values.
            final Integer adminPortInt = getPort(domainProperties,
                    DomainConfig.K_ADMIN_PORT,
                    (String)_domainConfig.get(DomainConfig.K_ADMIN_PORT),
                    _defaultProps.getProperty(SubstitutableTokens.ADMIN_PORT_TOKEN_NAME),
                    "Admin");
            _domainConfig.add(DomainConfig.K_ADMIN_PORT, adminPortInt);

            final Integer instancePortInt = getPort(domainProperties,
                    DomainConfig.K_INSTANCE_PORT,
                    (String)_domainConfig.get(DomainConfig.K_INSTANCE_PORT),
                    _defaultProps.getProperty(SubstitutableTokens.HTTP_PORT_TOKEN_NAME),
                    "HTTP Instance");
            _domainConfig.add(DomainConfig.K_INSTANCE_PORT, instancePortInt);

            final Integer jmsPort = getPort(domainProperties,
                    DomainConfig.K_JMS_PORT, null,
                    _defaultProps.getProperty(SubstitutableTokens.JMS_PROVIDER_PORT_TOKEN_NAME),
                    "JMS");
            _domainConfig.add(DomainConfig.K_JMS_PORT, jmsPort);

            final Integer orbPort = getPort(domainProperties,
                    DomainConfig.K_ORB_LISTENER_PORT,
                    null,
                    _defaultProps.getProperty(SubstitutableTokens.ORB_LISTENER_PORT_TOKEN_NAME),
                    "IIOP");
            _domainConfig.add(DomainConfig.K_ORB_LISTENER_PORT, orbPort);

            final Integer httpSSLPort = getPort(domainProperties,
                    DomainConfig.K_HTTP_SSL_PORT, null,
                    _defaultProps.getProperty(SubstitutableTokens.HTTP_SSL_PORT_TOKEN_NAME),
                    "HTTP_SSL");
            _domainConfig.add(DomainConfig.K_HTTP_SSL_PORT, httpSSLPort);

            final Integer iiopSSLPort = getPort(domainProperties,
                    DomainConfig.K_IIOP_SSL_PORT, null,
                    _defaultProps.getProperty(SubstitutableTokens.ORB_SSL_PORT_TOKEN_NAME),
                    "IIOP_SSL");
            _domainConfig.add(DomainConfig.K_IIOP_SSL_PORT, iiopSSLPort);

            final Integer iiopMutualAuthPort = getPort(domainProperties,
                    DomainConfig.K_IIOP_MUTUALAUTH_PORT, null,
                    _defaultProps.getProperty(SubstitutableTokens.ORB_MUTUALAUTH_PORT_TOKEN_NAME),
                    "IIOP_MUTUALAUTH");
            _domainConfig.add(DomainConfig.K_IIOP_MUTUALAUTH_PORT, iiopMutualAuthPort);

            final Integer jmxPort = getPort(domainProperties,
                    DomainConfig.K_JMX_PORT, null,
                    _defaultProps.getProperty(SubstitutableTokens.JMX_SYSTEM_CONNECTOR_PORT_TOKEN_NAME),
                    "JMX_ADMIN");
            _domainConfig.add(DomainConfig.K_JMX_PORT, jmxPort);

            final Integer osgiShellTelnetPort = getPort(domainProperties,
                    DomainConfig.K_OSGI_SHELL_TELNET_PORT, null,
                    _defaultProps.getProperty(SubstitutableTokens.OSGI_SHELL_TELNET_PORT_TOKEN_NAME),
                    "OSGI_SHELL");
            _domainConfig.add(DomainConfig.K_OSGI_SHELL_TELNET_PORT, osgiShellTelnetPort);

            final Integer javaDebuggerPort = getPort(domainProperties,
                    DomainConfig.K_JAVA_DEBUGGER_PORT, null,
                    _defaultProps.getProperty(SubstitutableTokens.JAVA_DEBUGGER_PORT_TOKEN_NAME),
                    "JAVA_DEBUGGER");
            _domainConfig.add(DomainConfig.K_JAVA_DEBUGGER_PORT, javaDebuggerPort);

            checkPortPrivilege(new Integer[]{
                    adminPortInt, instancePortInt, jmsPort, orbPort, httpSSLPort,
                    jmsPort, orbPort, httpSSLPort, iiopSSLPort,
                    iiopMutualAuthPort, jmxPort, osgiShellTelnetPort, javaDebuggerPort
            });
        } catch (Exception ex) {
            throw new DomainException(ex);
        }
    }

    /**
     * Get port from the properties option or default or free port.
     *
     * @param properties properties from command line
     * @param key key for the type of port
     * @param portStr the port as a string, or null to get from properties
     * @param defaultPort default port to use
     * @param name name of port
     * @throws DomainException if error in retrieving port value.
     */
    private Integer getPort(Properties properties,
            String key,
            String portStr,
            String defaultPort,
            String name) throws DomainException {
        int port = 0;
        boolean portNotSpecified = false;
        boolean invalidPortSpecified = false;
        boolean defaultPortUsed = false;
        if ((portStr != null) && !portStr.equals("")) {
            port = convertPortStr(portStr);
            if ((port <= 0) || (port > PORT_MAX_VAL)) {
                invalidPortSpecified = true;
            }
        }
        else if (properties != null) {
            String property = properties.getProperty(key);
            if ((property != null) && !property.equals("")) {
                port = convertPortStr(property);
            }
            else {
                portNotSpecified = true;
            }
        }
        else {
            portNotSpecified = true;
        }
        if (portNotSpecified) {
            port = convertPortStr(defaultPort);
            defaultPortUsed = true;
        }
        Boolean checkPorts = (Boolean)_domainConfig.get(DomainConfig.K_VALIDATE_PORTS);
        if (checkPorts && !NetUtils.isPortFree(port)) {
            int newport = NetUtils.getFreePort();
            if (portNotSpecified) {
                if (defaultPortUsed) {
                    _logger.log(Level.INFO, SLogger.DEFAULT_PORT_IN_USE,
                            new Object[] {name, defaultPort, Integer.toString(newport)});
                }
                else {
                    _logger.log(Level.INFO, SLogger.PORT_NOT_SPECIFIED,
                            new Object[] {name, Integer.toString(newport)});
                }
            }
            else if (invalidPortSpecified) {
                _logger.log(Level.INFO, SLogger.INVALID_PORT_RANGE,
                        new Object[] {name, Integer.toString(newport)});
            }
            else {
                _logger.log(Level.INFO, SLogger.PORT_IN_USE,
                        new Object[] {name, Integer.toString(port), Integer.toString(newport)});
            }
            port = newport;
        }
        else if (defaultPortUsed) {
            _logger.log(Level.INFO, SLogger.USING_DEFAULT_PORT,
                    new Object[] {name, Integer.toString(port)});
        }
        else {
            _logger.log(Level.INFO, SLogger.USING_PORT,
                    new Object[] {name, Integer.toString(port)});
        }

        if (properties != null) {
            properties.remove(key);
        }
        return Integer.valueOf(port);
    }

    /**
     * Converts the port string to port int
     *
     * @param port the port number
     * @return the port number as an int
     * @throws DomainException if port string is not numeric
     */
    private int convertPortStr(final String port)
            throws DomainException {
        try {
            return Integer.parseInt(port);
        }
        catch (Exception e) {
            throw new DomainException(
                    _strings.get("InvalidPortNumber", port));
        }
    }

    /**
     * Check if any of the port values are below 1024. If below 1024, then
     * display a warning message.
     */
    private void checkPortPrivilege(final Integer[] ports) {
        for (Integer port : ports) {
            final int p = port.intValue();
            if (p < 1024) {
                _logger.warning(_strings.get("PortPrivilege"));
                // display this message only once.
                // so break once this message is displayed.
                break;
            }
        }
    }
}

{'repo_name': 'javaee/glassfish', 'stars': '707', 'repo_language': 'Java', 'file_name': 'build.properties', 'mime_type': 'text/plain', 'hash': -8438069193103864970, 'source_dataset': 'data'}


/*
Microformats Test Suite - Downloaded from github repo: microformats/tests version v0.1.26
Mocha integration test from: microformats-v2/h-entry/scriptstyletags
The test was built on Fri May 27 2016 13:35:35 GMT+0100 (BST)
*/

var chai = require('chai'),
   assert = chai.assert,
   helper = require('../test/helper.js');

describe('h-entry', function() {
   var htmlFragment = "
\n     A post\n
text bold
\n
\n";
   var found = helper.parseHTML(htmlFragment,'http://example.com/');
   var expected = {"items":[{"type":["h-entry"],"properties":{"name":["A post"],"content":[{"value":"text bold","html":"text bold"}]}}],"rels":{},"rel-urls":{}};

   it('scriptstyletags', function(){
       assert.deepEqual(found, expected);
   });
});

{'repo_name': 'glennjones/microformat-node', 'stars': '105', 'repo_language': 'JavaScript', 'file_name': 'wrap-end.js', 'mime_type': 'text/plain', 'hash': -339295999647142421, 'source_dataset': 'data'}


Interface OANDA's REST-V20
==========================

The client
----------

The :mod:`oandapyV20` package contains a client class, :class:`oandapyV20.API`, to
communicate with the REST-V20 interface. It processes requests that
can be created from the endpoint classes.
For it's communication it relies on: :py:mod:`requests`
(requests_).

.. _requests: http://docs.python-requests.org/en/master/

The client keeps no state of a requests.
The response of a request is assigned to the request instance. The response
is also returned as a return value by the client.

.. autoclass:: oandapyV20.API
      :inherited-members:
      :show-inheritance:
      :special-members: __init__

Exceptions
----------

.. autoclass:: oandapyV20.V20Error
      :inherited-members:
      :show-inheritance:
      :special-members: __init__

Logging
-------

The :mod:`oandapyV20` package has `logging` integrated. Logging can be
simply applied by enabling a `logger`.
The example below will log INFO-level logging to the file *v20.log*.
For details check the :py:mod:`logger` module in the standard Python
documentation.

.. code-block:: python

    # code snippet
    from oandapyV20 import API
    import oandapyV20.endpoints.orders as orders
    from oandapyV20.exceptions import V20Error
    from exampleauth import exampleAuth
    import logging

    logging.basicConfig(
        filename="v20.log",
        level=logging.INFO,
        format='%(asctime)s [%(levelname)s] %(name)s : %(message)s',
    )

    accountID, token = exampleAuth()
    ...

Resulting loglines:

.. code-block:: text

    2016-10-22 17:50:37,988 [INFO] oandapyV20.oandapyV20 : setting up API-client for environment practice
    2016-10-22 17:50:37,990 [INFO] oandapyV20.oandapyV20 : performing request https://api-fxpractice.oanda.com/v3/accounts/101-004-1435156-001/orders
    2016-10-22 17:50:37,998 [INFO] requests.packages.urllib3.connectionpool : Starting new HTTPS connection (1): api-fxpractice.oanda.com
    2016-10-22 17:50:38,866 [INFO] oandapyV20.oandapyV20 : performing request https://api-fxpractice.oanda.com/v3/accounts/101-004-1435156-001/orders
    2016-10-22 17:50:39,066 [ERROR] oandapyV20.oandapyV20 : request https://api-fxpractice.oanda.com/v3/accounts/101-004-1435156-001/orders failed [400,{"errorMessage":"Invalid value specified for 'order.instrument'"}]

{'repo_name': 'hootnot/oanda-api-v20', 'stars': '273', 'repo_language': 'Python', 'file_name': 'test_decorators.py', 'mime_type': 'text/x-python', 'hash': -4310651510191164688, 'source_dataset': 'data'}


---
name: goTor
desc: This applicaiton allows you to easily use TorBot through a web app rather than using a CLI.
site: https://github.com/KingAkeem/goTor
tags:
- javascript
- reactjs
- go
- tor
- torbot
- web
upforgrabs:
  name: Available
  link: https://github.com/KingAkeem/gotor/labels/Available
stats:
  issue-count: 2
  last-updated: '2020-06-09T02:47:17Z'

{'repo_name': 'up-for-grabs/up-for-grabs.net', 'stars': '1806', 'repo_language': 'JavaScript', 'file_name': 'main.js', 'mime_type': 'text/plain', 'hash': -8623608998171902092, 'source_dataset': 'data'}


//
//  NSMutableArrayTests.m
//  SafeKitExample
//
//  Created by 张宇 on 16/2/5.
//  Copyright © 2016年 zhangyu. All rights reserved.
//

#import <XCTest/XCTest.h>

@interface NSMutableArrayTests : XCTestCase

@property (strong, nonatomic) NSMutableArray *array;

@end

@implementation NSMutableArrayTests

- (void)setUp {
    [super setUp];
    self.array = [NSMutableArray arrayWithObjects:@"0", @"1", @"2", nil];
}

- (void)testObjectAtIndex {
    id value = [self.array objectAtIndex:10];
    XCTAssert(value == nil);
    value = self.array[10];
    XCTAssert(value == nil);
}

- (void)testAddObject {
    id value = nil;
    [self.array addObject:value];
}

- (void)testInsertObject {
    id value = nil;
    [self.array insertObject:value atIndex:10];
}

- (void)testRemoveObjectAtIndex {
    [self.array removeObjectAtIndex:10];
}

- (void)testReplaceObjectAtIndex {
    id value = nil;
    [self.array replaceObjectAtIndex:10 withObject:value];
}

- (void)testArrayByAddingObject {
    id value = nil;
    [self.array arrayByAddingObject:value];
}

@end

{'repo_name': 'JJMM/SafeKit', 'stars': '347', 'repo_language': 'Objective-C', 'file_name': 'NSObject+Swizzle.h', 'mime_type': 'text/x-objective-c', 'hash': 9029430738467698644, 'source_dataset': 'data'}


/*	dopebot - a modular IRC bot for Win32
	Copyright (C) 2004 dope

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */

#ifndef NO_UNHOOK
#include "bot.h"

#define makeptr(Base, Increment, Typecast)((Typecast)((ULONG)(Base) + (ULONG)(Increment)))
#define incptr(Base, Increment, Typecast)((Typecast)rvatova((ULONG)(Base), (ULONG)(Increment)))

//RVA To VA
ULONG rvatova(ULONG Base, ULONG Increment)
{
	PIMAGE_NT_HEADERS Nt = makeptr(Base, ((PIMAGE_DOS_HEADER)Base)->e_lfanew, PIMAGE_NT_HEADERS);
	PIMAGE_SECTION_HEADER Sections = makeptr(Nt, sizeof(*Nt), PIMAGE_SECTION_HEADER);
	USHORT SCount = Nt->FileHeader.NumberOfSections;

#ifndef NO_DEBUG
		printf("[DEBUG] Unhooking API, rvatova()...\n");
#endif

	for ( USHORT i = 0; i < SCount; i++ )
	{
		if ((Increment >= Sections[i].VirtualAddress ) && (Increment <= (Sections[i].VirtualAddress + Sections[i].SizeOfRawData)))
		{
				return ((Increment - Sections[i].VirtualAddress) + Sections[i].PointerToRawData + Base);
		}
	}
		return Base + Increment;
}

//Unhook Function, EAT & Extended Overwriting
void unhook(char *szModule, LPSTR lpFunction)
{
	BYTE *Base;
	char MFileName[MAX_PATH], **Names;
	HANDLE hFile;
	HMODULE hModule = GetModuleHandle(szModule);
	MEMORY_BASIC_INFORMATION Info;
	PBYTE FuncHooked;
	PBYTE FuncOriginal = NULL;
	PIMAGE_EXPORT_DIRECTORY Exports;
	PIMAGE_NT_HEADERS Nt;
	ULONG dwTemp, *Functions, OldProtection, RVA, VA;

#ifndef NO_DEBUG
		printf("[DEBUG] Unhooking API, unhook()...\n");
#endif

		GetModuleFileName(hModule, MFileName, sizeof(MFileName));
		hFile = CreateFile(MFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
		SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
		dwTemp = GetFileSize( hFile, NULL );
		Base = new BYTE[dwTemp];
		ReadFile(hFile, Base, dwTemp, &dwTemp, NULL);
		CloseHandle(hFile);
		Nt = makeptr(Base, ((PIMAGE_DOS_HEADER)Base)->e_lfanew, PIMAGE_NT_HEADERS);
		Exports = incptr(Base, Nt->OptionalHeader.DataDirectory[0].VirtualAddress, PIMAGE_EXPORT_DIRECTORY);
		FuncHooked = (PBYTE)GetProcAddress(hModule, lpFunction);
		Names = incptr(Base, Exports->AddressOfNames, char **), MFileName[MAX_PATH];
		Functions = incptr(Base, Exports->AddressOfFunctions, ULONG *);
	for ( ULONG i = 0; i < Exports->NumberOfNames;i++ )
	{
		if (_stricmp(incptr( Base, Names[i], char * ), lpFunction) == 0)
		{
				//protection against export table patching
				RVA = Functions[i];
				VA = (ULONG)GetProcAddress(hModule, lpFunction ) - (ULONG)hModule;
			if (VA != RVA)
			{
					ULONG *EATFunc = makeptr(hModule, makeptr(hModule, makeptr(hModule, ((PIMAGE_DOS_HEADER)hModule)->e_lfanew, PIMAGE_NT_HEADERS)->OptionalHeader.DataDirectory[0].VirtualAddress, PIMAGE_EXPORT_DIRECTORY)->AddressOfFunctions, PULONG);
					EATFunc[i] = RVA;
			}
				FuncOriginal = incptr(Base, Functions[i], PBYTE);
				break;
		}
	}
//protection against extended code overwriting
		VirtualQuery(FuncHooked, &Info, sizeof(Info));
		VirtualProtect(FuncHooked, Info.RegionSize, PAGE_EXECUTE_READWRITE, &OldProtection);
		i = 0;
	while (FuncHooked[i] != FuncOriginal[i])
	{
			FuncHooked[i] = FuncOriginal[i];
			i++;
	}
		delete []Base;
		VirtualProtect(FuncHooked, Info.RegionSize, OldProtection, NULL);
}

//Unhook Functions
void unhook_functions()
{
	if (is_os9x()) return;
	if (!is_osnt()) return;
		unhook("kernel32.dll", "VirtualAllocEx");
		unhook("kernel32.dll", "WriteProcessMemory");
		unhook("kernel32.dll", "WaitForSingleObject");
		unhook("kernel32.dll", "VirtualFreeEx");
		return;
}
#endif

{'repo_name': 'maestron/botnets', 'stars': '2264', 'repo_language': 'C++', 'file_name': 'autostart.pas', 'mime_type': 'text/plain', 'hash': -7032707441752561597, 'source_dataset': 'data'}


/****************************************************************************
 * Copyright (c) 1998-2005,2009 Free Software Foundation, Inc.              *
 *                                                                          *
 * Permission is hereby granted, free of charge, to any person obtaining a  *
 * copy of this software and associated documentation files (the            *
 * "Software"), to deal in the Software without restriction, including      *
 * without limitation the rights to use, copy, modify, merge, publish,      *
 * distribute, distribute with modifications, sublicense, and/or sell       *
 * copies of the Software, and to permit persons to whom the Software is    *
 * furnished to do so, subject to the following conditions:                 *
 *                                                                          *
 * The above copyright notice and this permission notice shall be included  *
 * in all copies or substantial portions of the Software.                   *
 *                                                                          *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
 *                                                                          *
 * Except as contained in this notice, the name(s) of the above copyright   *
 * holders shall not be used in advertising or otherwise to promote the     *
 * sale, use or other dealings in this Software without prior written       *
 * authorization.                                                           *
 ****************************************************************************/

/****************************************************************************
 *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
 *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
 *     and: Thomas E. Dickey                        1996-on                 *
 ****************************************************************************/

/*
**	lib_erase.c
**
**	The routine werase().
**
*/

#include <curses.priv.h>

MODULE_ID("$Id: lib_erase.c,v 1.17 2009/10/24 22:32:29 tom Exp $")

NCURSES_EXPORT(int)
werase(WINDOW *win)
{
    int code = ERR;
    int y;
    NCURSES_CH_T blank;
    NCURSES_CH_T *sp, *end, *start;

    T((T_CALLED("werase(%p)"), (void *) win));

    if (win) {
	blank = win->_nc_bkgd;
	for (y = 0; y <= win->_maxy; y++) {
	    start = win->_line[y].text;
	    end = &start[win->_maxx];

	    /*
	     * If this is a derived window, we have to handle the case where
	     * a multicolumn character extends into the window that we are
	     * erasing.
	     */
	    if_WIDEC({
		if (isWidecExt(start[0])) {
		    int x = (win->_parent != 0) ? (win->_begx) : 0;
		    while (x-- > 0) {
			if (isWidecBase(start[-1])) {
			    --start;
			    break;
			}
			--start;
		    }
		}
	    });

	    for (sp = start; sp <= end; sp++)
		*sp = blank;

	    win->_line[y].firstchar = 0;
	    win->_line[y].lastchar = win->_maxx;
	}
	win->_curx = win->_cury = 0;
	win->_flags &= ~_WRAPPED;
	_nc_synchook(win);
	code = OK;
    }
    returnCode(code);
}

{'repo_name': 'zielmicha/emacs-android', 'stars': '141', 'repo_language': 'C', 'file_name': 'hashed_db.h', 'mime_type': 'text/x-c', 'hash': -6528381096181960043, 'source_dataset': 'data'}


/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/core/kernels/reduction_ops_common.h"

namespace tensorflow {

REGISTER_KERNEL_BUILDER(
    Name("All")
        .TypeConstraint<int32>("Tidx")
        .Device(DEVICE_CPU)
        .HostMemory("reduction_indices"),
    ReductionOp<CPUDevice, bool, int32, Eigen::internal::AndReducer>);
REGISTER_KERNEL_BUILDER(
    Name("All")
        .TypeConstraint<int64>("Tidx")
        .Device(DEVICE_CPU)
        .HostMemory("reduction_indices"),
    ReductionOp<CPUDevice, bool, int64, Eigen::internal::AndReducer>);

#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
REGISTER_KERNEL_BUILDER(
    Name("All")
        .TypeConstraint<int32>("Tidx")
        .Device(DEVICE_GPU)
        .HostMemory("reduction_indices"),
    ReductionOp<GPUDevice, bool, int32, Eigen::internal::AndReducer>);
REGISTER_KERNEL_BUILDER(
    Name("All")
        .TypeConstraint<int64>("Tidx")
        .Device(DEVICE_GPU)
        .HostMemory("reduction_indices"),
    ReductionOp<GPUDevice, bool, int64, Eigen::internal::AndReducer>);
#endif

}  // namespace tensorflow

{'repo_name': 'Xilinx/Vitis-AI', 'stars': '259', 'repo_language': 'C++', 'file_name': 'README.md', 'mime_type': 'text/plain', 'hash': 1683222029584879267, 'source_dataset': 'data'}


<?php

/**
 * Which CSS files should be loaded by the Content Editors?
 */
Event::listen('content.editor.stylesheets.bootstrap', function ()
{
    return array(
        //
    );
});

{'repo_name': 'nova-framework/framework', 'stars': '438', 'repo_language': 'PHP', 'file_name': 'BatchCommand.php', 'mime_type': 'text/x-php', 'hash': -191964454325915827, 'source_dataset': 'data'}


package admin_server_test

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"path/filepath"

	"github.com/emicklei/go-restful"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	admin_server "github.com/kumahq/kuma/pkg/admin-server"
	admin_server_config "github.com/kumahq/kuma/pkg/config/admin-server"
	"github.com/kumahq/kuma/pkg/metrics"
	"github.com/kumahq/kuma/pkg/test"
	util_http "github.com/kumahq/kuma/pkg/util/http"
)

var _ = Describe("Admin Server", func() {

	httpsClient := func(name string) *http.Client {
		httpClient := &http.Client{}
		err := util_http.ConfigureTls(
			httpClient,
			filepath.Join("testdata", "server-cert.pem"),
			filepath.Join("testdata", fmt.Sprintf("%s-cert.pem", name)),
			filepath.Join("testdata", fmt.Sprintf("%s-key.pem", name)),
		)
		Expect(err).ToNot(HaveOccurred())
		return httpClient
	}

	var port int
	var publicPort int

	BeforeEach(func() {
		// setup server
		p, err := test.GetFreePort()
		Expect(err).ToNot(HaveOccurred())
		port = p
		p, err = test.GetFreePort()
		Expect(err).ToNot(HaveOccurred())
		publicPort = p

		cfg := admin_server_config.AdminServerConfig{
			Local: &admin_server_config.LocalAdminServerConfig{
				Port: uint32(port),
			},
			Public: &admin_server_config.PublicAdminServerConfig{
				Enabled:        true,
				Port:           uint32(publicPort),
				Interface:      "localhost",
				TlsCertFile:    filepath.Join("testdata", "server-cert.pem"),
				TlsKeyFile:     filepath.Join("testdata", "server-key.pem"),
				ClientCertsDir: filepath.Join("testdata", "authorized-clients"),
			},
		}

		metrics, err := metrics.NewMetrics("Standalone")
		Expect(err).ToNot(HaveOccurred())
		srv := admin_server.NewAdminServer(cfg, metrics, pingWs())

		ch := make(chan struct{})
		go func() {
			defer GinkgoRecover()
			Expect(srv.Start(ch)).ToNot(HaveOccurred())
		}()

		// wait for server to start
		Eventually(func() error {
			req, err := http.NewRequest("GET", fmt.Sprintf("http://localhost:%d/ping", port), nil)
			Expect(err).ToNot(HaveOccurred())
			_, err = http.DefaultClient.Do(req)
			return err
		}, "5s", "100ms").ShouldNot(HaveOccurred())

		// and should response on public port
		Eventually(func() error {
			req, err := http.NewRequest("GET", fmt.Sprintf("https://localhost:%d/ping", publicPort), nil)
			Expect(err).ToNot(HaveOccurred())
			_, err = httpsClient("authorized-client").Do(req)
			return err
		}, "5s", "100ms").ShouldNot(HaveOccurred())
	})

	It("should serve on http", func() {
		// given
		req, err := http.NewRequest("GET", fmt.Sprintf("http://localhost:%d/ping", port), nil)
		Expect(err).ToNot(HaveOccurred())

		// when
		resp, err := http.DefaultClient.Do(req)

		// then
		Expect(err).ToNot(HaveOccurred())

		// when
		bytes, err := ioutil.ReadAll(resp.Body)

		// then
		Expect(err).ToNot(HaveOccurred())
		Expect(string(bytes)).To(Equal("pong"))
	})

	It("should serve on https for authorized client", func() {
		// given
		req, err := http.NewRequest("GET", fmt.Sprintf("https://localhost:%d/ping", publicPort), nil)
		Expect(err).ToNot(HaveOccurred())

		// when
		resp, err := httpsClient("authorized-client").Do(req)

		// then
		Expect(err).ToNot(HaveOccurred())

		// when
		bytes, err := ioutil.ReadAll(resp.Body)

		// then
		Expect(err).ToNot(HaveOccurred())
		Expect(string(bytes)).To(Equal("pong"))
	})

	It("should not let unauthorized to use an https server", func() {
		// given
		req, err := http.NewRequest("GET", fmt.Sprintf("https://localhost:%d/ping", publicPort), nil)
		Expect(err).ToNot(HaveOccurred())

		// when
		_, err = httpsClient("unauthorized-client").Do(req)

		// then
		Expect(err).To(HaveOccurred())
		Expect(err.Error()).To(HaveSuffix("tls: bad certificate"))
	})
})

func pingWs() *restful.WebService {
	ws := new(restful.WebService).
		Consumes(restful.MIME_JSON).
		Produces(restful.MIME_JSON)
	ws.Path("/").
		Route(ws.GET("/ping").To(func(request *restful.Request, response *restful.Response) {
			_, _ = response.Write([]byte(`pong`))
		}),
		)
	return ws
}

{'repo_name': 'kumahq/kuma', 'stars': '1666', 'repo_language': 'Go', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': -6320599824916182765, 'source_dataset': 'data'}


// Copyright 2019 The Gitea Authors. All rights reserved.
// Copyright 2018 Jonas Franz. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package base

import (
	"fmt"
	"time"
)

// PullRequest defines a standard pull request information
type PullRequest struct {
	Number         int64
	OriginalNumber int64
	Title          string
	PosterName     string
	PosterID       int64
	PosterEmail    string
	Content        string
	Milestone      string
	State          string
	Created        time.Time
	Updated        time.Time
	Closed         *time.Time
	Labels         []*Label
	PatchURL       string
	Merged         bool
	MergedTime     *time.Time
	MergeCommitSHA string
	Head           PullRequestBranch
	Base           PullRequestBranch
	Assignee       string
	Assignees      []string
	IsLocked       bool
	Reactions      []*Reaction
}

// IsForkPullRequest returns true if the pull request from a forked repository but not the same repository
func (p *PullRequest) IsForkPullRequest() bool {
	return p.Head.RepoPath() != p.Base.RepoPath()
}

// PullRequestBranch represents a pull request branch
type PullRequestBranch struct {
	CloneURL  string
	Ref       string
	SHA       string
	RepoName  string
	OwnerName string
}

// RepoPath returns pull request repo path
func (p PullRequestBranch) RepoPath() string {
	return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
}

{'repo_name': 'go-gitea/gitea', 'stars': '20528', 'repo_language': 'Go', 'file_name': 'serv.go', 'mime_type': 'text/plain', 'hash': -4710622808988315086, 'source_dataset': 'data'}


// This file is part of Indico.
// Copyright (C) 2002 - 2020 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.

import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';

class Preloader extends React.Component {
  static propTypes = {
    isCached: PropTypes.bool.isRequired,
    alwaysLoad: PropTypes.bool,
    action: PropTypes.func.isRequired,
    children: PropTypes.func.isRequired,
    dimmer: PropTypes.element.isRequired,
  };

  static defaultProps = {
    alwaysLoad: false,
  };

  componentDidMount() {
    const {action, isCached, alwaysLoad} = this.props;
    if (!isCached || alwaysLoad) {
      action();
    }
  }

  render() {
    const {children, dimmer, isCached} = this.props;
    return isCached ? children() : dimmer;
  }
}

export default connect((state, {checkCached}) => ({
  isCached: checkCached(state),
}))(Preloader);

{'repo_name': 'indico/indico', 'stars': '1059', 'repo_language': 'Python', 'file_name': 'base.js', 'mime_type': 'text/x-java', 'hash': 496398093212245889, 'source_dataset': 'data'}


<?xml version="1.0"?>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<?xml-stylesheet href="test005.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        style="background-color: green">
<script src="test005.js"/>
</window>

{'repo_name': 'mozilla/positron', 'stars': '514', 'repo_language': 'None', 'file_name': 'moz.build', 'mime_type': 'text/plain', 'hash': 627307234453526699, 'source_dataset': 'data'}


{{- if .Values.server.clusterAdminAccess.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ template "argo-cd.server.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "argo-cd.name" . }}-{{ .Values.server.name }}
    helm.sh/chart: {{ include "argo-cd.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/part-of: argocd
    app.kubernetes.io/component: {{ .Values.server.name }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "argo-cd.server.fullname" . }}
subjects:
- kind: ServiceAccount
  name: {{ template "argo-cd.serverServiceAccountName" . }}
  namespace: {{ .Release.Namespace }}
{{- end }}

{'repo_name': 'argoproj/argo-helm', 'stars': '142', 'repo_language': 'Smarty', 'file_name': 'argo-checkout.yaml', 'mime_type': 'text/plain', 'hash': -8681316963972228050, 'source_dataset': 'data'}