text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2013.11.29 at 12:35:53 PM GMT
//

package org.mule.modules.hybris.model;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for cockpitSavedQueryDTO complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="cockpitSavedQueryDTO">
 *   <complexContent>
 *     <extension base="{}itemDTO">
 *       <sequence>
 *         <element name="cockpitSavedFacetValues" minOccurs="0">
 *           <complexType>
 *             <complexContent>
 *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 <sequence>
 *                   <element name="cockpitSavedFacetValue" type="{}cockpitSavedFacetValueDTO" maxOccurs="unbounded" minOccurs="0"/>
 *                 </sequence>
 *               </restriction>
 *             </complexContent>
 *           </complexType>
 *         </element>
 *         <element name="cockpitSavedParameterValues" minOccurs="0">
 *           <complexType>
 *             <complexContent>
 *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 <sequence>
 *                   <element name="cockpitSavedParameterValue" type="{}cockpitSavedParameterValueDTO" maxOccurs="unbounded" minOccurs="0"/>
 *                 </sequence>
 *               </restriction>
 *             </complexContent>
 *           </complexType>
 *         </element>
 *         <element name="cockpitSavedSortCriteria" minOccurs="0">
 *           <complexType>
 *             <complexContent>
 *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 <sequence>
 *                   <element name="cockpitSavedSortCriterion" type="{}cockpitSavedSortCriterionDTO" maxOccurs="unbounded" minOccurs="0"/>
 *                 </sequence>
 *               </restriction>
 *             </complexContent>
 *           </complexType>
 *         </element>
 *         <element name="defaultViewMode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="description" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="label" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="readSavedQueryPrincipals" minOccurs="0">
 *           <complexType>
 *             <complexContent>
 *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 <sequence>
 *                   <element ref="{}principal" maxOccurs="unbounded" minOccurs="0"/>
 *                 </sequence>
 *               </restriction>
 *             </complexContent>
 *           </complexType>
 *         </element>
 *         <element name="selectedTemplateCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="selectedTypeCode" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element name="simpleText" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         <element ref="{}user" minOccurs="0"/>
 *       </sequence>
 *       <attribute name="code" type="{http://www.w3.org/2001/XMLSchema}string" />
 *     </extension>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "cockpitSavedQueryDTO", propOrder = {
    "cockpitSavedFacetValues",
    "cockpitSavedParameterValues",
    "cockpitSavedSortCriteria",
    "defaultViewMode",
    "description",
    "label",
    "readSavedQueryPrincipals",
    "selectedTemplateCode",
    "selectedTypeCode",
    "simpleText",
    "user"
})
public class CockpitSavedQueryDTO
    extends ItemDTO
{

    protected CockpitSavedQueryDTO.CockpitSavedFacetValues cockpitSavedFacetValues;
    protected CockpitSavedQueryDTO.CockpitSavedParameterValues cockpitSavedParameterValues;
    protected CockpitSavedQueryDTO.CockpitSavedSortCriteria cockpitSavedSortCriteria;
    protected String defaultViewMode;
    protected String description;
    protected String label;
    protected CockpitSavedQueryDTO.ReadSavedQueryPrincipals readSavedQueryPrincipals;
    protected String selectedTemplateCode;
    protected String selectedTypeCode;
    protected String simpleText;
    protected UserDTO user;
    @XmlAttribute(name = "code")
    protected String code;

    /**
     * Gets the value of the cockpitSavedFacetValues property.
     *
     * @return
     *     possible object is
     *     {@link CockpitSavedQueryDTO.CockpitSavedFacetValues }
     *
     */
    public CockpitSavedQueryDTO.CockpitSavedFacetValues getCockpitSavedFacetValues() {
        return cockpitSavedFacetValues;
    }

    /**
     * Sets the value of the cockpitSavedFacetValues property.
     *
     * @param value
     *     allowed object is
     *     {@link CockpitSavedQueryDTO.CockpitSavedFacetValues }
     *
     */
    public void setCockpitSavedFacetValues(CockpitSavedQueryDTO.CockpitSavedFacetValues value) {
        this.cockpitSavedFacetValues = value;
    }

    /**
     * Gets the value of the cockpitSavedParameterValues property.
     *
     * @return
     *     possible object is
     *     {@link CockpitSavedQueryDTO.CockpitSavedParameterValues }
     *
     */
    public CockpitSavedQueryDTO.CockpitSavedParameterValues getCockpitSavedParameterValues() {
        return cockpitSavedParameterValues;
    }

    /**
     * Sets the value of the cockpitSavedParameterValues property.
     *
     * @param value
     *     allowed object is
     *     {@link CockpitSavedQueryDTO.CockpitSavedParameterValues }
     *
     */
    public void setCockpitSavedParameterValues(CockpitSavedQueryDTO.CockpitSavedParameterValues value) {
        this.cockpitSavedParameterValues = value;
    }

    /**
     * Gets the value of the cockpitSavedSortCriteria property.
     *
     * @return
     *     possible object is
     *     {@link CockpitSavedQueryDTO.CockpitSavedSortCriteria }
     *
     */
    public CockpitSavedQueryDTO.CockpitSavedSortCriteria getCockpitSavedSortCriteria() {
        return cockpitSavedSortCriteria;
    }

    /**
     * Sets the value of the cockpitSavedSortCriteria property.
     *
     * @param value
     *     allowed object is
     *     {@link CockpitSavedQueryDTO.CockpitSavedSortCriteria }
     *
     */
    public void setCockpitSavedSortCriteria(CockpitSavedQueryDTO.CockpitSavedSortCriteria value) {
        this.cockpitSavedSortCriteria = value;
    }

    /**
     * Gets the value of the defaultViewMode property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDefaultViewMode() {
        return defaultViewMode;
    }

    /**
     * Sets the value of the defaultViewMode property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setDefaultViewMode(String value) {
        this.defaultViewMode = value;
    }

    /**
     * Gets the value of the description property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDescription() {
        return description;
    }

    /**
     * Sets the value of the description property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setDescription(String value) {
        this.description = value;
    }

    /**
     * Gets the value of the label property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getLabel() {
        return label;
    }

    /**
     * Sets the value of the label property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setLabel(String value) {
        this.label = value;
    }

    /**
     * Gets the value of the readSavedQueryPrincipals property.
     *
     * @return
     *     possible object is
     *     {@link CockpitSavedQueryDTO.ReadSavedQueryPrincipals }
     *
     */
    public CockpitSavedQueryDTO.ReadSavedQueryPrincipals getReadSavedQueryPrincipals() {
        return readSavedQueryPrincipals;
    }

    /**
     * Sets the value of the readSavedQueryPrincipals property.
     *
     * @param value
     *     allowed object is
     *     {@link CockpitSavedQueryDTO.ReadSavedQueryPrincipals }
     *
     */
    public void setReadSavedQueryPrincipals(CockpitSavedQueryDTO.ReadSavedQueryPrincipals value) {
        this.readSavedQueryPrincipals = value;
    }

    /**
     * Gets the value of the selectedTemplateCode property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSelectedTemplateCode() {
        return selectedTemplateCode;
    }

    /**
     * Sets the value of the selectedTemplateCode property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSelectedTemplateCode(String value) {
        this.selectedTemplateCode = value;
    }

    /**
     * Gets the value of the selectedTypeCode property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSelectedTypeCode() {
        return selectedTypeCode;
    }

    /**
     * Sets the value of the selectedTypeCode property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSelectedTypeCode(String value) {
        this.selectedTypeCode = value;
    }

    /**
     * Gets the value of the simpleText property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSimpleText() {
        return simpleText;
    }

    /**
     * Sets the value of the simpleText property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSimpleText(String value) {
        this.simpleText = value;
    }

    /**
     * Gets the value of the user property.
     *
     * @return
     *     possible object is
     *     {@link UserDTO }
     *
     */
    public UserDTO getUser() {
        return user;
    }

    /**
     * Sets the value of the user property.
     *
     * @param value
     *     allowed object is
     *     {@link UserDTO }
     *
     */
    public void setUser(UserDTO value) {
        this.user = value;
    }

    /**
     * Gets the value of the code property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getCode() {
        return code;
    }

    /**
     * Sets the value of the code property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setCode(String value) {
        this.code = value;
    }

    /**
     *
Java class for anonymous complex type.
     *
     *
The following schema fragment specifies the expected content contained within this class.
     *
     *

     * <complexType>
     *   <complexContent>
     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       <sequence>
     *         <element name="cockpitSavedFacetValue" type="{}cockpitSavedFacetValueDTO" maxOccurs="unbounded" minOccurs="0"/>
     *       </sequence>
     *     </restriction>
     *   </complexContent>
     * </complexType>
     *

     *
     *
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "cockpitSavedFacetValue"
    })
    public static class CockpitSavedFacetValues {

        protected List<CockpitSavedFacetValueDTO> cockpitSavedFacetValue;

        /**
         * Gets the value of the cockpitSavedFacetValue property.
         *
         *

         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a set method for the cockpitSavedFacetValue property.
         *
         *

         * For example, to add a new item, do as follows:
         *

         *    getCockpitSavedFacetValue().add(newItem);
         *

         *
         *
         *

         * Objects of the following type(s) are allowed in the list
         * {@link CockpitSavedFacetValueDTO }
         *
         *
         */
        public List<CockpitSavedFacetValueDTO> getCockpitSavedFacetValue() {
            if (cockpitSavedFacetValue == null) {
                cockpitSavedFacetValue = new ArrayList<CockpitSavedFacetValueDTO>();
            }
            return this.cockpitSavedFacetValue;
        }

    }

    /**
     *
Java class for anonymous complex type.
     *
     *
The following schema fragment specifies the expected content contained within this class.
     *
     *

     * <complexType>
     *   <complexContent>
     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       <sequence>
     *         <element name="cockpitSavedParameterValue" type="{}cockpitSavedParameterValueDTO" maxOccurs="unbounded" minOccurs="0"/>
     *       </sequence>
     *     </restriction>
     *   </complexContent>
     * </complexType>
     *

     *
     *
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "cockpitSavedParameterValue"
    })
    public static class CockpitSavedParameterValues {

        protected List<CockpitSavedParameterValueDTO> cockpitSavedParameterValue;

        /**
         * Gets the value of the cockpitSavedParameterValue property.
         *
         *

         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a set method for the cockpitSavedParameterValue property.
         *
         *

         * For example, to add a new item, do as follows:
         *

         *    getCockpitSavedParameterValue().add(newItem);
         *

         *
         *
         *

         * Objects of the following type(s) are allowed in the list
         * {@link CockpitSavedParameterValueDTO }
         *
         *
         */
        public List<CockpitSavedParameterValueDTO> getCockpitSavedParameterValue() {
            if (cockpitSavedParameterValue == null) {
                cockpitSavedParameterValue = new ArrayList<CockpitSavedParameterValueDTO>();
            }
            return this.cockpitSavedParameterValue;
        }

    }

    /**
     *
Java class for anonymous complex type.
     *
     *
The following schema fragment specifies the expected content contained within this class.
     *
     *

     * <complexType>
     *   <complexContent>
     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       <sequence>
     *         <element name="cockpitSavedSortCriterion" type="{}cockpitSavedSortCriterionDTO" maxOccurs="unbounded" minOccurs="0"/>
     *       </sequence>
     *     </restriction>
     *   </complexContent>
     * </complexType>
     *

     *
     *
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "cockpitSavedSortCriterion"
    })
    public static class CockpitSavedSortCriteria {

        protected List<CockpitSavedSortCriterionDTO> cockpitSavedSortCriterion;

        /**
         * Gets the value of the cockpitSavedSortCriterion property.
         *
         *

         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a set method for the cockpitSavedSortCriterion property.
         *
         *

         * For example, to add a new item, do as follows:
         *

         *    getCockpitSavedSortCriterion().add(newItem);
         *

         *
         *
         *

         * Objects of the following type(s) are allowed in the list
         * {@link CockpitSavedSortCriterionDTO }
         *
         *
         */
        public List<CockpitSavedSortCriterionDTO> getCockpitSavedSortCriterion() {
            if (cockpitSavedSortCriterion == null) {
                cockpitSavedSortCriterion = new ArrayList<CockpitSavedSortCriterionDTO>();
            }
            return this.cockpitSavedSortCriterion;
        }

    }

    /**
     *
Java class for anonymous complex type.
     *
     *
The following schema fragment specifies the expected content contained within this class.
     *
     *

     * <complexType>
     *   <complexContent>
     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       <sequence>
     *         <element ref="{}principal" maxOccurs="unbounded" minOccurs="0"/>
     *       </sequence>
     *     </restriction>
     *   </complexContent>
     * </complexType>
     *

     *
     *
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "principal"
    })
    public static class ReadSavedQueryPrincipals {

        protected List<PrincipalDTO> principal;

        /**
         * Gets the value of the principal property.
         *
         *

         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a set method for the principal property.
         *
         *

         * For example, to add a new item, do as follows:
         *

         *    getPrincipal().add(newItem);
         *

         *
         *
         *

         * Objects of the following type(s) are allowed in the list
         * {@link PrincipalDTO }
         *
         *
         */
        public List<PrincipalDTO> getPrincipal() {
            if (principal == null) {
                principal = new ArrayList<PrincipalDTO>();
            }
            return this.principal;
        }

    }

}


text:
// ###replace: package controllers
package javaguide.config;

import com.typesafe.config.Config;
import play.mvc.Controller;

import javax.inject.Inject;

public class MyController extends Controller {

  private final Config config;

  @Inject
  public MyController(Config config) {
    this.config = config;
  }
}

redpajama_set_name: RedPajamaGithub


text:
'use strict';
/* eslint-disable max-len*/
require('./lib/index.js');
const auth = require('../middleware/authMiddleware');
const authController = require('../auth').authConfigCtrl;
const passport = require('passport');
const req = {
  isAuthenticated: () => {
    return true;
  }
};
const res = {};

describe('lib', () => {

  after(() => {
    delete require.cache[require.resolve('../middleware/authMiddleware')];
  });

  describe('middleware', () => {
    describe('authmiddleware', () => {
      describe('should call next if authenticated and no access_token expired', () => {
        let authSpy, next, accessTokenStub;
        beforeEach(() => {
          authSpy = sinon.spy(auth, 'ensureAuthenticated');
          accessTokenStub = sinon.stub(authController, 'checkAccessTokenExpired');
          next = sinon.stub();
        });
        afterEach(() => {
          authSpy.restore();
          accessTokenStub.restore();

        });
        it('should call next on authenticate', (done) => {
          accessTokenStub.returns(false);
          auth.ensureAuthenticated(req, res, next);
          expect(authSpy.calledOnce).to.equal(true);
          expect(next.called).to.equal(true);
          done();
        });
      });
    });

    describe('authmiddleware unauthenticated/accesstokenexpired', () => {
      let authSpy, passportSpy, next, checkAccessTokenExpiredStub;
      let passportAuthStub;
      beforeEach(() => {
        authSpy = sinon.spy(auth, 'ensureAuthenticated');
        passportSpy = sinon.spy(passport, 'authenticate');
        req.originalUrl = 'http://demo';
        req.isAuthenticated = () => {
          return false;
        };
        req.params = {};
        req.query = {};
        req.get = sinon.stub();
        req.logout = sinon.stub();
        req.session = { destroy : sinon.stub() };
        res.setHeader = sinon.stub();
        res.status = sinon.stub();
        res.json = sinon.stub();
        res.redirect = sinon.stub();
        checkAccessTokenExpiredStub = sinon.stub(authController, 'checkAccessTokenExpired');
        passportAuthStub = sinon.stub(auth,'passportAuthenticate');
        next = sinon.stub();
      });

      afterEach(() => {
        authSpy.restore();
        passportSpy.restore();
        checkAccessTokenExpiredStub.restore();
        passportAuthStub.restore();
      });

      it('should call passport authenticated when not authorized', (done) => {
        passportAuthStub.restore();
        auth.passportAuthenticate(req,res,next);
        sinon.assert.calledWith(passportSpy, 'oauth2', {
          successReturnToOrRedirect: req.originalUrl,
          callbackURL: req.originalUrl
        });
        done();
      });

      it('should call req logOut and send 401 unauthorized' ,(done)=> {
        req.session.destroy.callsArg(0);
        req.get.returns('true');
        res.status.returns(res);
        auth.ensureAuthenticated(req,res,next);
        sinon.assert.called(req.logout);
        sinon.assert.calledWith(req.get, 'X-WebApp-Request');
        sinon.assert.calledWith(res.setHeader,'X-Session-Expiry','true');
        sinon.assert.calledWith(res.status,401);
        sinon.assert.calledWith(res.json,{});
        done();
      });

      it('should redirect to /manage/instance/instanceId',(done)=>{
        req.originalUrl = 'https://service-dashboard.com/v1/logout?instance_id=abcd12345';
        req.query.instance_id = 'abcd12345';
        auth.ensureAuthenticated(req,res,next);
        sinon.assert.calledWith(res.redirect, '/manage/instances/abcd12345');
        done();
      });

      it('should redirect to passport autheticate if no instance_id is found', (done)=>{
        req.originalUrl = 'https://service-dashboard.com/v1/logout?force=true';
        req.query.force = true;
        auth.ensureAuthenticated(req,res,next);
        sinon.assert.calledWith(passportAuthStub,req,res,next);
        done();
      });

      it('should redirect to /manage/instance/abcd12345 if part of req param', (done) => {
        req.originalUrl = 'http://service.dashboard.com/manage/instances/xyz1234';
        req.params.instance_id = 'xyz1234';
        auth.ensureAuthenticated(req,res,next);
        sinon.assert.calledWith(res.redirect,'/manage/instances/xyz1234');
        done();
      });

      it('should redirect all random path to passport authenticate', (done) => {
        res.originalUrl = 'http://service.dashboard.com/abc/xyz';
        auth.ensureAuthenticated(req,res,next);
        sinon.assert.calledWith(passportAuthStub,req,res,next);
        done();
      });

      it('should not authenticate /healthcheck call', (done) => {
        req.originalUrl = 'http://service.dashboard.com/healthcheck';
        req.baseUrl = '/healthcheck';
        auth.ensureAuthenticated(req,res,next);
        sinon.assert.neverCalledWith(passportAuthStub,req,res,next);
        done();
      });
    });
  });
});


text:
<?php
define('ROOT',   dirname(dirname(__FILE__)));
define('APP',    ROOT.'/app');
define('MISAGO', ROOT.'/../..');
define('PUBLIC', ROOT.'/public');
define('TMP',    ROOT.'/tmp');
require MISAGO.'/lib/Misago/boot.php';
?>


text:
function USAGE() {
  echo -e "$0 <option>.\nThis script installs several plugins."
  echo "<option> can be:"
  echo -e "\t-i : Interactive mode will ask if you want or not to try to install each plugin"
  echo -e "\t-y : Install all the plugins without asking."
  echo -e "\t-n : Dry run of the script (Doesn't install anything)."
}

if [ "$#" -lt 1 ]; then
  USAGE;
  exit -1;
fi

OPTION=$1
DRY=""
INTERACTIVE=""
if [ "$OPTION" == "-i" ]; then
  INTERACTIVE="1"
elif [ "$OPTION" == "-y" ]; then
  INTERACTIVE="0"
elif [ "$OPTION" == "-n" ]; then
  DRY="echo "
else
  USAGE;
  exit -1;
fi

BASE=$PWD

function process() {
  # target_folder, clone_cmd, update_cmd, fnc
  # - target_folder: what folder to create and where
  # - clone_cmd: what command to run to get the data. It can be 'git clone...' or 'mkdir...'
  # - update_cmd: what command to run to get update the data. It can be 'git pull...'
  # - fnc: lambda function to execute after performing the clone_cmd or update_cmd
  target_folder=$1
  clone_cmd=$2
  update_cmd=$3
  fnc=$4

  if [ "$INTERACTIVE" == "1" ]; then
    read -p "Do you want to run '$1' (y/n)?" ANSWER
    if [ "$ANSWER" != "y" ]; then
      echo "Skipping..."
      return 0
    fi
  fi

  $DRY cd $BASE

  if [ ! -d $BASE/$target_folder ]; then
    echo "Cloning $target_folder"
    $DRY $clone_cmd $BASE/$target_folder
  else
    echo "Updating $target_folder"
    $DRY cd $BASE/$target_folder
    $DRY $update_cmd
  fi
  if [ -n "$fnc" ]; then
    echo "Executing lambda function '$fnc'"
    $DRY $fnc
  fi

  echo ""
}

# git clone https://github.com/vim-scripts/WebAPI.vim.git sources_non_forked/WebAPI
process "sources_non_forked/WebAPI" "git clone https://github.com/vim-scripts/WebAPI.vim.git" "git pull"

# C/C++ with YouCompleteMe
# git clone https://github.com/Valloric/YouCompleteMe.git sources_non_forked/YouCompleteMe
function ycm_install() {
  cd $BASE/sources_non_forked/YouCompleteMe
  git submodule update --init --recursive
  ./install.sh --clang-completer
}
process "sources_non_forked/YouCompleteMe" "git clone https://github.com/Valloric/YouCompleteMe.git" "git pull" "ycm_install"

# Lisp
# git clone https://github.com/kovisoft/slimv.git sources_non_forked/slimv
process "sources_non_forked/slimv" "git clone https://github.com/kovisoft/slimv.git" "git pull"

# Latex
# git clone https://github.com/vim-latex/vim-latex.git sources_non_forked/vim-latex
process "sources_non_forked/vim-latex" "git clone https://github.com/vim-latex/vim-latex.git" "git pull"

# Python
# git clone https://github.com/python-mode/python-mode sources_non_forked/python-mode
process "sources_non_forked/python-mode" "git clone --recursive https://github.com/python-mode/python-mode" "git pull && git submodule update --init --recursive"

# Ultisnips
# git clone https://github.com/sirver/ultisnips sources_non_forked/ultisnips
process "sources_non_forked/ultisnips" "git clone https://github.com/sirver/ultisnips" "git pull"

#taglist
function taglist_install() {
  cd $BASE/sources_non_forked/taglist
  wget http://www.vim.org/scripts/download_script.php?src_id=19574 -O taglist.zip
  unzip taglist.zip -d $PWD
}
process "sources_non_forked/taglist" "mkdir -v " "echo NOOP" "taglist_install"

# Scala
# https://github.com/ensime/ensime-vim
# process "sources_non_forked/ensime-vim" "git clone https://github.com/ensime/ensime-vim"
# https://github.com/derekwyatt/vim-scala
process "sources_non_forked/vim-scala" "git clone https://github.com/derekwyatt/vim-scala" "git pull"

# Ginger grammar check
function ginger_install() {
  cd $BASE/sources_non_forked/ginger-vim/plugin
  wget https://gist.githubusercontent.com/spino327/1896cad258a6dd956edf597c6960d886/raw/ac5ab0c33579b4bbbe42dfd87527a04f0613b9c3/ginger.vim -O ginger.vim
}
process "sources_non_forked/ginger-vim/plugin" "mkdir -vp " "echo NOOP" "ginger_install"


text:
I'm tasting GitHub possibilities
## Copyright Aleksandra_the_QA <br>
That's nice GitHub adventure!


text:
"""
    api
    ~~~

    Implements API Server and Interface

    :author:    Feei <feei@feei.cn>
    :homepage:  https://github.com/wufeifei/cobra
    :license:   MIT, see LICENSE for more details.
    :copyright: Copyright (c) 2017 Feei. All rights reserved
"""
import errno
import json
import multiprocessing
import os
import socket
import subprocess
import threading
import time
import traceback

import requests
from flask import Flask, request, render_template
from flask_restful import Api, Resource
from werkzeug.urls import url_unquote

from . import cli
from .cli import get_sid
from .config import Config, running_path, package_path
from .engine import Running
from .log import logger
from .utils import allowed_file, secure_filename, PY2, split_branch

try:
    # Python 3
    import queue
except ImportError:
    # Python 2
    import Queue as queue

q = queue.Queue()
app = Flask(__name__, static_folder='templates/asset')
running_host = '0.0.0.0'
running_port = 5000

def producer(task):
    q.put(task)

def consumer():
    while True:
        task = q.get()
        p = multiprocessing.Process(target=cli.start, args=task)
        p.start()
        p.join()
        q.task_done()

class AddJob(Resource):
    @staticmethod
    def post():
        data = request.json
        if not data or data == "":
            return {"code": 1003, "msg": "Only support json, please post json data."}

        target = data.get("target")
        formatter = data.get("formatter")
        output = data.get("output")
        rule = data.get("rule")

        is_valid_key = key_verify(data=data)

        if is_valid_key is not True:
            return is_valid_key

        if not target or target == "":
            return {"code": 1002, "msg": "URL cannot be empty."}

        if not formatter or formatter == '':
            formatter = 'json'
        if not output or output == '':
            output = ''
        if not rule or rule == '':
            rule = ''

        # Report All Id
        a_sid = get_sid(target, True)
        running = Running(a_sid)

        # Write a_sid running data
        running.init_list(data=target)

        # Write a_sid running status
        data = {
            'status': 'running',
            'report': ''
        }
        running.status(data)

        if isinstance(target, list):
            for t in target:
                # Scan
                arg = (t, formatter, output, rule, a_sid)
                producer(task=arg)

            result = {
                'msg': 'Add scan job successfully.',
                'sid': a_sid,
                'total_target_num': len(target),
            }
        else:
            arg = (target, formatter, output, rule, a_sid)
            producer(task=arg)
            result = {
                'msg': 'Add scan job successfully.',
                'sid': a_sid,
                'total_target_num': 1,
            }

        return {"code": 1001, "result": result}

class JobStatus(Resource):
    @staticmethod
    def post():
        data = request.json
        if not data or data == "":
            return {"code": 1003, "msg": "Only support json, please post json data."}

        sid = data.get("sid")

        is_valid_key = key_verify(data=data)
        if is_valid_key is not True:
            return is_valid_key

        if not sid or sid == "":
            return {"code": 1002, "msg": "sid is required."}

        sid = str(data.get("sid"))  # 需要拼接入路径,转为字符串
        running = Running(sid)
        if running.is_file() is not True:
            data = {
                'code': 1004,
                'msg': 'scan id does not exist!',
                'sid': sid,
                'status': 'no such scan',
                'report': ''
            }
            return data
        else:
            result = running.status()
            r_data = running.list()
            if result['status'] == 'running':
                ret = True
                result['still_running'] = dict()
                for s_sid, git in r_data['sids'].items():
                    if Running(s_sid).is_file(True) is False:
                        result['still_running'].update({s_sid: git})
                        ret = False
                if ret:
                    result['status'] = 'done'
                    running.status(result)
            data = {
                'msg': 'success',
                'sid': sid,
                'status': result.get('status'),
                'report': request.url_root + result.get('report'),
                'still_running': result.get('still_running'),
                'total_target_num': r_data.get('total_target_num'),
                'not_finished': int(r_data.get('total_target_num')) - len(r_data.get('sids'))
                                + len(result.get('still_running')),
            }
        return {"code": 1001, "result": data}

class FileUpload(Resource):
    @staticmethod
    def post():
        """
        Scan by uploading compressed files
        :return:
        """
        if 'file' not in request.files:
            return {'code': 1002, 'result': "File can't empty!"}
        file_instance = request.files['file']
        if file_instance.filename == '':
            return {'code': 1002, 'result': "File name can't empty!"}
        if file_instance and allowed_file(file_instance.filename):
            filename = secure_filename(file_instance.filename)
            dst_directory = os.path.join(package_path, filename)
            file_instance.save(dst_directory)
            # Start scan
            a_sid = get_sid(dst_directory, True)
            data = {
                'status': 'running',
                'report': ''
            }
            Running(a_sid).status(data)
            try:
                cli.start(dst_directory, None, 'stream', None, a_sid=a_sid)
            except Exception as e:
                traceback.print_exc()
            code, result = 1001, {'sid': a_sid}
            return {'code': code, 'result': result}
        else:
            return {'code': 1002, 'result': "This extension can't support!"}

class ResultData(Resource):
    @staticmethod
    def post():
        """
        pull scan result data.
        :return:
        """
        data = request.json
        if not data or data == "":
            return {"code": 1003, "msg": "Only support json, please post json data."}

        s_sid = data.get('sid')
        if not s_sid or s_sid == "":
            return {"code": 1002, "msg": "sid is required."}

        s_sid_file = os.path.join(running_path, '{sid}_data'.format(sid=s_sid))
        if not os.path.exists(s_sid_file):
            return {'code': 1002, 'msg': 'No such target.'}

        with open(s_sid_file, 'r') as f:
            scan_data = json.load(f)
            if scan_data.get('code') == 1001:
                scan_data = scan_data.get('result')
            else:
                return {
                    'code': scan_data.get('code'),
                    'msg': scan_data.get('msg'),
                }

        rule_filter = dict()
        for vul in scan_data.get('vulnerabilities'):
            rule_filter[vul.get('id')] = vul.get('rule_name')

        return {
            'code': 1001,
            'result': {
                'scan_data': scan_data,
                'rule_filter': rule_filter,
            }
        }

class ResultDetail(Resource):
    @staticmethod
    def post():
        """
        get vulnerable file content
        :return:
        """
        data = request.json
        if not data or data == "":
            return {'code': 1003, 'msg': 'Only support json, please post json data.'}

        sid = data.get('sid')
        file_path = url_unquote(data.get('file_path'))

        if not sid or sid == '':
            return {"code": 1002, "msg": "sid is required."}

        if not file_path or file_path == '':
            return {'code': 1002, 'msg': 'file_path is required.'}

        s_sid_file = os.path.join(running_path, '{sid}_data'.format(sid=sid))
        if not os.path.exists(s_sid_file):
            return {'code': 1002, 'msg': 'No such target.'}

        with open(s_sid_file, 'r') as f:
            target_directory = json.load(f).get('result').get('target_directory')

        if not target_directory or target_directory == '':
            return {'code': 1002, 'msg': 'No such directory'}

        if PY2:
            file_path = map(secure_filename, [path.decode('utf-8') for path in file_path.split('/')])
        else:
            file_path = map(secure_filename, [path for path in file_path.split('/')])

        filename = target_directory
        for _dir in file_path:
            filename = os.path.join(filename, _dir)
        if os.path.exists(filename):
            extension = guess_type(filename)
            if is_text(filename):
                with open(filename, 'r') as f:
                    file_content = f.read()
            else:
                file_content = 'This is a binary file.'
        else:
            return {'code': 1002, 'msg': 'No such file.'}

        return {'code': 1001, 'result': {'file_content': file_content, 'extension': extension}}

class Search(Resource):
    @staticmethod
    def post():
        """
        Search specific rule.
        :return:
        """
        data = request.json
        if not data or data == "":
            return {'code': 1003, 'msg': 'Only support json, please post json data.'}

        sid = data.get('sid')
        if not sid or sid == '':
            return {'code': 1002, 'msg': 'sid is required.'}

        rule_id = data.get('rule_id')
        if not rule_id or rule_id == '':
            return {'code': 1002, 'msg': 'rule_id is required.'}

        scan_list_file = os.path.join(running_path, '{sid}_list'.format(sid=sid))
        if not os.path.exists(scan_list_file):
            return {'code': 1002, 'msg': 'No such sid.'}

        with open(scan_list_file, 'r') as f:
            scan_list = json.load(f)

        if not isinstance(rule_id, list):
            rule_id = [rule_id]

        search_data = list()
        for s_sid in scan_list.get('sids').keys():
            target, branch = split_branch(scan_list.get('sids').get(s_sid))
            search_result = search_rule(s_sid, rule_id)
            cvi_count = list(search_result.values())
            if int(cvi_count[0]) > 0:
                search_data.append({
                    'target_info': {
                        'sid': s_sid,
                        'target': target,
                        'branch': branch,
                    },
                    'search_result': search_result,
                })

        return {
            'code': 1001,
            'result': search_data,
        }

@app.route('/', methods=['GET', 'POST'])
def summary():
    a_sid = request.args.get(key='sid')
    key = Config(level1="cobra", level2="secret_key").value
    if a_sid is None:
        return render_template(template_name_or_list='index.html',
                               key=key)

    status_url = 'http://{host}:{port}/api/status'.format(host=running_host, port=running_port)
    post_data = {
        'key': key,
        'sid': a_sid,
    }
    headers = {
        "Content-Type": "application/json",
    }
    r = requests.post(url=status_url, headers=headers, data=json.dumps(post_data))
    try:
        scan_status = json.loads(r.text)
    except ValueError as e:
        return render_template(template_name_or_list='error.html',
                               msg='Check scan status failed: {0}'.format(e))

    if scan_status.get('code') != 1001:
        return render_template(template_name_or_list='error.html',
                               msg=scan_status.get('msg'))
    else:
        if scan_status.get('result').get('status') == 'running':
            still_running = scan_status.get('result').get('still_running')
            for s_sid, target_str in still_running.items():
                target, branch = split_branch(target_str)
                still_running[s_sid] = {'target': target,
                                        'branch': branch}
        else:
            still_running = dict()

        scan_status_file = os.path.join(running_path, '{sid}_status'.format(sid=a_sid))

        scan_list = Running(a_sid).list()

        start_time = os.path.getctime(filename=scan_status_file)
        start_time = time.localtime(start_time)
        start_time = time.strftime('%Y-%m-%d %H:%M:%S', start_time)

        total_targets_number = scan_status.get('result').get('total_target_num')
        not_finished_number = scan_status.get('result').get('not_finished')

        total_vul_number, critical_vul_number, high_vul_number, medium_vul_number, low_vul_number = 0, 0, 0, 0, 0
        rule_num = dict()
        rules = dict()
        targets = list()

        for s_sid, target_str in scan_list.get('sids').items():
            if s_sid not in still_running:
                target_info = dict()

                # 分割项目地址与分支,默认 master
                target, branch = split_branch(target_str)

                target_info.update({
                    'sid': s_sid,
                    'target': target,
                    'branch': branch,
                })
                s_sid_file = os.path.join(running_path, '{sid}_data'.format(sid=s_sid))
                with open(s_sid_file, 'r') as f:
                    s_sid_data = json.load(f)
                    if s_sid_data.get('code') != 1001:
                        continue
                    else:
                        s_sid_data = s_sid_data.get('result')
                total_vul_number += len(s_sid_data.get('vulnerabilities'))

                target_info.update({'total_vul_number': len(s_sid_data.get('vulnerabilities'))})
                target_info.update(s_sid_data)

                targets.append(target_info)

                for vul in s_sid_data.get('vulnerabilities'):
                    if 9 <= int(vul.get('level')) <= 10:
                        critical_vul_number += 1
                    elif 6 <= int(vul.get('level')) <= 8:
                        high_vul_number += 1
                    elif 3 <= int(vul.get('level')) <= 5:
                        medium_vul_number += 1
                    elif 1 <= int(vul.get('level')) <= 2:
                        low_vul_number += 1

                    try:
                        rule_num[vul.get('rule_name')] += 1
                    except KeyError:
                        rule_num[vul.get('rule_name')] = 1

                    rules[vul.get('id')] = vul.get('rule_name')

        return render_template(template_name_or_list='summary.html',
                               total_targets_number=total_targets_number,
                               not_finished_number=not_finished_number,
                               start_time=start_time,
                               targets=targets,
                               a_sid=a_sid,
                               total_vul_number=total_vul_number,
                               critical_vul_number=critical_vul_number,
                               high_vul_number=high_vul_number,
                               medium_vul_number=medium_vul_number,
                               low_vul_number=low_vul_number,
                               rule_num=rule_num,
                               rules=rules,
                               running=still_running,)

def key_verify(data):
    key = Config(level1="cobra", level2="secret_key").value
    _key = data.get("key")

    if _key == key:
        return True
    elif not _key or _key == "":
        return {"code": 1002, "msg": "Key cannot be empty."}
    elif not _key == key:
        return {"code": 4002, "msg": "Key verify failed."}
    else:
        return {"code": 4002, "msg": "Unknown key verify error."}

def is_text(fn):
    msg = subprocess.Popen(['file', fn], stdout=subprocess.PIPE).communicate()[0]
    return 'text' in msg.decode('utf-8')

def guess_type(fn):
    import mimetypes
    extension = mimetypes.guess_type(fn)[0]
    if extension:
        """text/x-python or text/x-java-source"""
        # extension = extension.split('/')[1]
        extension = extension.replace('-source', '')
    else:
        extension = fn.split('/')[-1].split('.')[-1]

    custom_ext = {
        'html': 'htmlmixed',
        'md': 'markdown',
    }
    if custom_ext.get(extension) is not None:
        extension = custom_ext.get(extension)

    return extension.lower()

def search_rule(sid, rule_id):
    """
    Search specific rule name in scan data.
    :param sid: scan data id
    :param rule_id: a list of rule name
    :return: {rule_name1: num1, rule_name2: num2}
    """
    scan_data_file = os.path.join(running_path, '{sid}_data'.format(sid=sid))
    search_result = dict.fromkeys(rule_id, 0)
    if not os.path.exists(scan_data_file):
        return search_result

    with open(scan_data_file, 'r') as f:
        scan_data = json.load(f)

    if scan_data.get('code') == 1001 and len(scan_data.get('result').get('vulnerabilities')) > 0:
        for vul in scan_data.get('result').get('vulnerabilities'):
            if vul.get('id') in rule_id:
                    search_result[vul.get('id')] += 1
        return search_result
    else:
        return search_result

def start(host, port, debug):
    logger.info('Start {host}:{port}'.format(host=host, port=port))
    api = Api(app)

    api.add_resource(AddJob, '/api/add')
    api.add_resource(JobStatus, '/api/status')
    api.add_resource(FileUpload, '/api/upload')
    api.add_resource(ResultData, '/api/list')
    api.add_resource(ResultDetail, '/api/detail')
    api.add_resource(Search, '/api/search')

    # consumer
    threads = []
    for i in range(5):
        threads.append(threading.Thread(target=consumer, args=()))

    for i in threads:
        i.setDaemon(daemonic=True)
        i.start()

    try:
        global running_port, running_host
        running_host = host if host != '0.0.0.0' else '127.0.0.1'
        running_port = port
        app.run(debug=debug, host=host, port=int(port), threaded=True, processes=1)
    except socket.error as v:
        if v.errno == errno.EACCES:
            logger.critical('[{err}] must root permission for start API Server!'.format(err=v.strerror))
            exit()
        else:
            logger.critical('{msg}'.format(msg=v.strerror))

    logger.info('API Server start success')


text:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "DTD/xhtml1-strict.dtd">

    <title>pynprcalc.funciones.math : API documentation</title>

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="apidocs.css" />

            pynprcalc API Documentation

      <button onclick="togglePrivate()" class="btn btn-link">Toggle Private API</button>

pynprcalc.funciones.math package documentation

          Part of pynprcalc.funciones

Funciones matemáticas.

    Module
    basico

Funciones matemáticas básicas.

    Module
    const

Constantes matemáticas.

    Module
    exp

Funciones exponenciales.

    Module
    misc

Funciones misceláneas.

    Module
    trig

Funciones trigonométricas.

      <address>
        API Documentation for pynprcalc, generated by pydoctor at 2017-06-18 11:43:43.
      </address>


text:
package exsplay.examples.user.pure

import exsplay.api.routing.Route
import exsplay.api.action.Action
import spray.http.HttpMethods._
import exsplay.api.routing.Route

/**
 * User: wert
 * Date: 21.07.13
 * Time: 2:05
 */
object Router {

  val routes: PartialFunction[Route, Action] = {
    case Route(GET,     "v1" :: "users" :: id :: Nil)   => PureUserController.get(id)
    case Route(PUT,     "v1" :: "users" :: id :: Nil)   => PureUserController.update(id)
    case Route(POST,    "v1" :: "users" :: Nil)         => PureUserController.create
    case Route(GET,     "v1" :: "users" :: Nil)         => PureUserController.find

  }

}


text:
layout: page
title: Lawrence Media Trade Fair
date: 2016-05-24
author: Dylan Caldwell
tags: weekly links, java
status: published
summary: Mauris sed ipsum quis eros tincidunt tincidunt. Quisque.
banner: images/banner/leisure-04.jpg
booking:
  startDate: 05/03/2017
  endDate: 05/06/2017
  ctyhocn: GEGVYHX
  groupCode: LMTF
published: true
---
Donec scelerisque gravida rutrum. Nulla facilisi. Vestibulum vitae dui mattis, congue mi a, euismod nisl. Ut ut fermentum nunc. Proin eget libero sit amet augue finibus ornare. Nunc at fringilla ex. Cras mauris sem, vestibulum eu dapibus quis, pharetra sed purus. Nam volutpat sem in varius placerat. Nunc diam diam, malesuada ut dignissim dictum, hendrerit vitae tortor. Aliquam mattis nisl porta nulla maximus, scelerisque vulputate sapien venenatis. Phasellus porta turpis ac felis bibendum interdum.

1 Pellentesque sed neque at augue posuere auctor
1 Proin a quam sollicitudin, congue mi id, sagittis est
1 Aenean a quam ac sapien porta eleifend
1 Duis tincidunt dui eget euismod auctor
1 Suspendisse mattis lorem sed porttitor dictum.

Nam rhoncus eros ac bibendum iaculis. Ut sed magna velit. Nunc erat nisl, suscipit euismod nulla eu, ultrices tincidunt orci. Integer euismod non ligula semper ornare. Donec euismod ultrices massa sit amet suscipit. Cras suscipit ac sem eu vestibulum. Nullam viverra sem arcu, eleifend porttitor purus tempus ut.


text:
/** @file This file contains functions that draw the popup bubble during labeling or editing an object. */

// *******************************************
// Public methods:
// *******************************************

/** This function creates the popup bubble.
 * @param {float} left - xlocation of the bubble
 * @param {float} top - ylocation of the bubble
 * @param {string} innerhtml - extra html content for the bubble
 * @param {string} dom_attach - id of the html element where it should be attached
 * @returns {string} bubble_name - dom element name for the popup bubble
*/
var part_bubble;
function CreatePopupBubble(left,top,innerHTML,dom_attach) {
  var html_str;
  var bubble_name = 'myPopup';

  // Adjust location to account for the displacement of the arrow:
  left -= 22;
  if (left < 5) left = 5;

  // Select the vertical position of the bubble decoration arrow
  if (top > 214) {
    html_str  = '
';
  }
  else {
    html_str  = '
';
  }

  // Insert bubble inner contents:
  html_str += innerHTML;

  // Close div tag:
  html_str += '
';

  // Insert bubble into the DOM tree:
  $('#'+dom_attach).append(html_str);
  if (part_bubble) $('#myPopup').css('background-color', 'rgb(255,230,230)')

  // Place bubble in the right location taking into account the rendered size and the location of the arrow
  if(top > 214) {
    h = $('#'+bubble_name).height();
    document.getElementById(bubble_name).style.top = (top-h-80) + 'px';
  }
  else {
    document.getElementById(bubble_name).style.top = (top) + 'px';
  }
  setTimeout("$('#objEnter').focus();",1);
  if (autocomplete_mode){
    addAutoComplete();
  }
  return bubble_name;
}
function addAutoComplete(){
	var tags = [];
	$.getScript("./annotationTools/js/wordnet_data.js", function(){
    var NoResultsLabel = 'No results found';
		tags = data_wordnet;
		$( "#objEnter" ).autocomplete({

			  source: function( request, response ) {
          if (request.term.length > 0){
            var matcher2 = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term )+'$', "i" );
    			  var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
            res = $.grep( tags, function( item ){
              aux = matcher.test( item );
              return aux
            });
            res2 = $.grep( tags, function( item ){
              aux = matcher2.test( item );
              return aux
            });
            if (res2.length == 0){
              $("#objEnter").css('color', 'red');
            }
            else {
              $("#objEnter").css('color', 'black');
            }
            if (res.length == 0){
              res = [NoResultsLabel];
            }
    			  response(res);
          }
          else {
            $("#objEnter").css('color', 'black');
            response(false);
          }
        },
        // response: function(event, ui){
        //   console.log(this.term);
        //   if (ui.content.length > 0 && ui.content[0].label == NoResultsLabel) {
        //     //$("#empty-message").text("No results found");
        //     $("#objEnter").css('color', 'red');
        //   }
        //   else {
        //     $("#objEnter").css('color', 'black');
        //   }
        // },
        select: function (event, ui) {
            $("#objEnter").css('color', 'black');
            if (ui.item.label === NoResultsLabel || event.which == 13) {
                event.preventDefault();
            }
        },
        focus: function (event, ui) {
            if (ui.item.label === NoResultsLabel) {
                event.preventDefault();
            }
        },

        minLength: 0
		}).data("ui-autocomplete")._renderItem =  function( ul, item ) {
            // Replace the matched text with a custom span. This
            // span uses the class found in the "highlightClass" option.
             var newText = String(item.value).replace(
                new RegExp("^" + $.ui.autocomplete.escapeRegex( this.term ), "i"),
                "$&");
            return $("

")
                .data("ui-item.autocomplete", item)
                .append("" + newText + "")
                .appendTo(ul);

          };
    $(".ui-autocomplete").css('font-size', '11px')
    $(".ui-autocomplete").css('font-family', 'BlinkMacSystemFont')
	});

}

/** This function creates the close button at the top-right corner of the popup bubble
 * @param {string} dom_bubble - dom_bubble name
 * @param {function} close_button - function to run when the close button is pressed
*/
function CreatePopupBubbleCloseButton(dom_bubble,close_function) {
  if(arguments.length==1) {
    close_function = function() {return;};
  }
  var html_str = '';
  $('#'+dom_bubble).append(html_str);
  $('#'+dom_bubble+'_closebutton').mousedown(function () {
      $('#'+dom_bubble).remove();
      close_function();
      return;
    });
}

// *******************************************
// All functions below here need to be moved to their appropriate module:
// *******************************************

// THINGS THAT WILL BE GOOD TO SIMPLIFY:
//  1- why are there two functions -almost-identical- to close the bubble?
//  2- why is different the way the data is submitted in edit and query? I think with LM_xml data handling this will be simplified.
//  3- I want functions
//        LM_xml.store(obj_index, fieldname, value)
//        LM_xml.getvalue(obj_index, fieldname)
//        LM_xml.sendtoserver
//

// Query popup bubble:
function mkPopup(left,top,scribble_popup) {
  wait_for_input = 1;
  var innerHTML = GetPopupFormDraw(scribble_popup);
  CreatePopupBubble(left,top,innerHTML,'main_section');

  // Focus the cursor inside the box
  setTimeout("$('#objEnter').focus();",1);
}

function mkEditPopup(left,top,anno) {
  edit_popup_open = 1;
  var innerHTML = GetPopupFormEdit(anno);
  var dom_bubble = CreatePopupBubble(left,top,innerHTML,'main_section');
  CreatePopupBubbleCloseButton(dom_bubble,StopEditEvent);

  // Focus the cursor inside the box
  $('#objEnter').select();
  $('#objEnter').focus();
}

function CloseQueryPopup() {
  wait_for_input = 0;
  $('#myPopup').remove();
}

function CloseEditPopup() {
  edit_popup_open = 0;
  $('#myPopup').remove();
}

// ****************************
// Forms:
// ****************************

function GetPopupFormDraw(scribble_form) {
  wait_for_input = 1;
  part_bubble = false;
  html_str = "Enter object name
";
  if (add_parts_to != null){
    html_str = "Enter part name
";
    part_bubble = true;
  }
  html_str += HTMLobjectBox("");

  if(use_attributes) {
    html_str += HTMLoccludedBox("");
    html_str += "Enter attributes
";
    html_str += HTMLattributesBox("");
  }
  if(use_parts) {
    html_str += HTMLpartsBox("");
  }
  html_str += "
";

  // Done button:
  html_str += '<input type="button" value="Done" title="Press this button after you have provided all the information you want about the object." onclick="main_handler.SubmitQuery();" tabindex="0" />';

  // Delete button:
  html_str += '<input type="button" style="float:right" value="Delete" title="Press this button if you wish to delete the polygon." onclick="main_handler.WhatIsThisObjectDeleteButton();" tabindex="0" />';
  html_str += '
'
  // Undo close button/Keep editting
  if (!scribble_form) if (!bounding_box) html_str += '<input type="button" value="Undo close" title="Press this button if you accidentally closed the polygon. You can continue adding control points." onclick="UndoCloseButton();" tabindex="0" />';
  else if (scribble_form) html_str += '<input type="button" value="Edit Scribble" title="Press this button if to keep adding scribbles." onclick="KeepEditingScribbles();" tabindex="0" />';
  // Add parts/Stop adding parts
  if (add_parts_to == null) html_str += '<input type="button" value="Add parts" title="Press this button if you want to start adding parts" onclick="main_handler.StartAddParts();" tabindex="0" />';
  else html_str += '<input type="button" value="Stop parts" title="Press this button if you want to stop adding parts" onclick="main_handler.StopAddParts();" tabindex="0" />';

  return html_str;
}

function GetPopupFormEdit(anno) {
  // get object name and attributes from 'anno'
  edit_popup_open =  1;
  part_bubble = false;
  var obj_name = LMgetObjectField(LM_xml,anno.anno_id,'name');
  if(obj_name=="") obj_name = "?";
  var attributes = LMgetObjectField(LM_xml,anno.anno_id,'attributes');
  var occluded = LMgetObjectField(LM_xml,anno.anno_id,'occluded');
  var parts = LMgetObjectField(LM_xml, anno.anno_id, 'parts');

  html_str = "Enter object name
";
  html_str += HTMLobjectBox(obj_name);

  if(use_attributes) {
    html_str += HTMLoccludedBox(occluded);
    html_str += "Enter attributes
";
    html_str += HTMLattributesBox(attributes);
  }

  if(use_parts) {
    html_str += HTMLpartsBox(parts);
  }

  html_str += "
";

  // Done button:
  if (video_mode) html_str += '<input type="button" value="Done" title="Press this button when you are done editing." onclick="main_media.SubmitEditObject();" tabindex="0" />';

  else html_str += '<input type="button" value="Done" title="Press this button when you are done editing." onclick="main_handler.SubmitEditLabel();" tabindex="0" />';

  /*************************************************************/
  /*************************************************************/
  // Scribble: if anno.GetType() != 0 then scribble mode:

  // Delete button:
  html_str += '<input type="button" style="float:right" value="Delete" title="Press this button if you wish to delete the polygon." onclick="main_handler.EditBubbleDeleteButton();" tabindex="0" />
';
  // Adjust polygon button:
  if (anno.GetType() == 0) {
    html_str += '<input type="button" value="Adjust polygon" title="Press this button if you wish to update the polygon\'s control points." onclick="javascript:AdjustPolygonButton();" />';
  }
  else {
    html_str += '<input type="button" value="Edit Scribbles" title="Press this button if you wish to update the segmentation." onclick="javascript:EditBubbleEditScribble();" />';
  }
  /*************************************************************/
  /*************************************************************/

  // Add parts/Stop adding parts
  if (add_parts_to == null) html_str += '<input type="button" value="Add parts" title="Press this button if you want to start adding parts" onclick="main_handler.StartAddParts();" tabindex="0" />';

  return html_str;
}

// ****************************
// Simple building blocks:
// ****************************

// Shows the box to enter the object name
function HTMLobjectBox(obj_name) {
  var html_str="";

  html_str += '<input name="objEnter" id="objEnter" type="text" style="width:220px;" tabindex="0" value="'+obj_name+'" title="Enter the object\'s name here. Avoid application specific names, codes, long descriptions. Use a name you think other people would agree in using. "';

  html_str += ' onkeyup="var c;if(event.keyCode)c=event.keyCode;if(event.which)c=event.which;if(c==13){';
  //html_str += 'console.log($(".ui-autocomplete.ui-widget:visible").length);';
  // if obj_name is empty it means that the box is being created
  if (obj_name=='') {
    // If press enter, then submit; if press ESC, then delete:
    if (video_mode) html_str += 'main_media.SubmitObject()};if(c==27) main_handler.WhatIsThisObjectDeleteButton();" ';
    else html_str += 'main_handler.SubmitQuery()};if(c==27)main_handler.WhatIsThisObjectDeleteButton();" ';
  }
  else {
    // If press enter, then submit:
    if (video_mode) html_str += 'main_media.SubmitEditObject()};" ';
    else html_str += 'main_handler.SubmitEditLabel()};" ';
  }

  // if there is a list of objects, we need to habilitate the list
  if(object_choices=='...') {
    html_str += '/>'; // close <input
  }
  else {
    html_str += 'list="datalist1" />'; // insert list and close <input
    html_str += '<datalist id="datalist1"><select style="display:none">';
    for(var i = 0; i < object_choices.length; i++) {
      html_str += '<option value="' + object_choices[i] + '">' + object_choices[i] + '</option>';
    }
    html_str += '</select></datalist>';
  }

  html_str += '
';

  return html_str;
}

// ****************************
// ATTRIBUTES:
// ****************************
// ?attributes=object:car;brand:seat/ford;color:...;comments:...

// is the object occluded?
function HTMLoccludedBox(occluded) {
  var html_str="";

  // by default, the value of occluded is "no"
  if (!(occluded=="no" || occluded=="yes")) {
    occluded="no";
  }

  // the value of the selection is inside a hidden field:
  html_str += 'Is occluded? <input type="hidden" name="occluded" id="occluded" value="'+occluded+'"/>';

  // generate radio button
  if (occluded=='yes') {
    html_str += '<input type="radio" name="rboccluded" id="rboccluded" value="yes" checked="yes" onclick="document.getElementById(\'occluded\').value=\'yes\';" />yes';
    html_str += '<input type="radio" name="rboccluded" id="rboccluded" value="no"  onclick="document.getElementById(\'occluded\').value=\'no\';" />no';
  }
  else {
    html_str += '<input type="radio" name="rboccluded" id="rboccluded" value="yes"  onclick="document.getElementById(\'occluded\').value=\'yes\';" />yes';
    html_str += '<input type="radio" name="rboccluded" id="rboccluded" value="no" checked="yes"  onclick="document.getElementById(\'occluded\').value=\'no\';" />no';
  }
  html_str += '
';

  return html_str;
}

// Boxes to enter attributes
function HTMLattributesBox(attList) {
  return '<textarea name="attributes" id="attributes" type="text" style="width:220px; height:3em;" tabindex="0" title="Enter a comma separated list of attributes, adjectives or other object properties">'+attList+'</textarea>';
}

// ****************************
// PARTS:
// ****************************
function HTMLpartsBox(parts) {
  var html_str="";
  if (parts.length>0) {
    if (parts.length==1) {
      html_str = 'Object has 1 part.';
    }
    else {
      html_str = 'Object has '+parts.length+' parts.';
    }
  }
  else {
    html_str = 'Object has no parts.';
  }

  return html_str;
}


text:
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;

namespace OpenSource.Data.HashFunction.FNV
{
    /// <summary>
    /// Defines a configuration for a <see cref="IFNV"/> implementation.
    /// </summary>
    public interface IFNVConfig
    {
        /// <summary>
        /// Length of the produced hash, in bits.
        /// </summary>
        /// <value>
        /// The length of the produced hash, in bits
        /// </value>
        int HashSizeInBits { get; }

        /// <summary>
        /// The prime integer to use when calculating the FNV value.
        /// </summary>
        /// <value>
        /// The prime value.
        /// </value>
        BigInteger Prime { get; }

        /// <summary>
        /// The offset integer to use when calculating the FNV value.
        /// </summary>
        /// <value>
        /// The offset value.
        /// </value>
        BigInteger Offset { get; }

        /// <summary>
        /// Makes a deep clone of current instance.
        /// </summary>
        /// <returns>A deep clone of the current instance.</returns>
        IFNVConfig Clone();
    }
}