text:
package org.apereo.cas.config;

import net.shibboleth.utilities.java.support.xml.BasicParserPool;
import org.apereo.cas.authentication.principal.ServiceFactory;
import org.apereo.cas.authentication.principal.WebApplicationService;
import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.services.ServicesManager;
import org.apereo.cas.support.saml.OpenSamlConfigBean;
import org.apereo.cas.support.saml.services.SamlIdPEntityIdValidationServiceSelectionStrategy;
import org.apereo.cas.support.saml.services.SamlIdPSingleLogoutServiceLogoutUrlBuilder;
import org.apereo.cas.support.saml.services.idp.metadata.cache.ChainingMetadataResolverCacheLoader;
import org.apereo.cas.support.saml.services.idp.metadata.cache.DefaultSamlRegisteredServiceCachingMetadataResolver;
import org.apereo.cas.support.saml.services.idp.metadata.cache.SamlRegisteredServiceCachingMetadataResolver;
import org.apereo.cas.support.saml.web.idp.metadata.SamlIdpMetadataAndCertificatesGenerationService;
import org.apereo.cas.support.saml.web.idp.metadata.ShibbolethIdpMetadataAndCertificatesGenerationService;
import org.apereo.cas.support.saml.web.idp.profile.AbstractSamlProfileHandlerController;
import org.apereo.cas.support.saml.web.idp.profile.IdPInitiatedProfileHandlerController;
import org.apereo.cas.support.saml.web.idp.profile.SLOPostProfileHandlerController;
import org.apereo.cas.support.saml.web.idp.profile.SSOPostProfileCallbackHandlerController;
import org.apereo.cas.support.saml.web.idp.profile.SSOPostProfileHandlerController;
import org.apereo.cas.support.saml.web.idp.profile.builders.AuthnContextClassRefBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.DefaultAuthnContextClassRefBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.SamlProfileSamlAssertionBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.SamlProfileSamlAttributeStatementBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.SamlProfileSamlAuthNStatementBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.SamlProfileSamlConditionsBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.SamlProfileSamlNameIdBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.SamlProfileSamlResponseBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.SamlProfileSamlSubjectBuilder;
import org.apereo.cas.support.saml.web.idp.profile.builders.enc.SamlObjectEncrypter;
import org.apereo.cas.support.saml.web.idp.profile.builders.enc.SamlObjectSigner;
import org.apereo.cas.util.http.HttpClient;
import org.apereo.cas.validation.ValidationServiceSelectionStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.ui.velocity.VelocityEngineFactory;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

/**
 * The {@link SamlIdPConfiguration}.
 *
 * @author Misagh Moayyed
 * @since 5.0.0
 */
@Configuration("samlIdPConfiguration")
@EnableConfigurationProperties(CasConfigurationProperties.class)
public class SamlIdPConfiguration {

    @Autowired
    private CasConfigurationProperties casProperties;

    @Autowired
    @Qualifier("servicesManager")
    private ServicesManager servicesManager;

    @Autowired
    @Qualifier("noRedirectHttpClient")
    private HttpClient httpClient;

    @Autowired
    @Qualifier("shibboleth.OpenSAMLConfig")
    private OpenSamlConfigBean openSamlConfigBean;

    @javax.annotation.Resource(name = "validationServiceSelectionStrategies")
    private List<ValidationServiceSelectionStrategy> validationServiceSelectionStrategies;

    @Autowired
    @Qualifier("shibboleth.VelocityEngine")
    private VelocityEngineFactory velocityEngineFactory;

    @Autowired
    @Qualifier("shibboleth.ParserPool")
    private BasicParserPool parserPool;

    @javax.annotation.Resource(name = "webApplicationServiceFactory")
    private ServiceFactory<WebApplicationService> webApplicationServiceFactory;

    @Autowired(required = false)
    @Qualifier("authenticationContextClassMappings")
    private Map authenticationContextClassMappings;

    @Autowired(required = false)
    @Qualifier("overrideDataEncryptionAlgorithms")
    private List overrideDataEncryptionAlgorithms;

    @Autowired(required = false)
    @Qualifier("overrideKeyEncryptionAlgorithms")
    private List overrideKeyEncryptionAlgorithms;

    @Autowired(required = false)
    @Qualifier("overrideBlackListedEncryptionAlgorithms")
    private List overrideBlackListedEncryptionAlgorithms;

    @Autowired(required = false)
    @Qualifier("overrideWhiteListedEncryptionAlgorithms")
    private List overrideWhiteListedAlgorithms;

    @Autowired(required = false)
    @Qualifier("overrideSignatureReferenceDigestMethods")
    private List overrideSignatureReferenceDigestMethods;

    @Autowired(required = false)
    @Qualifier("overrideSignatureAlgorithms")
    private List overrideSignatureAlgorithms;

    @Autowired(required = false)
    @Qualifier("overrideBlackListedSignatureAlgorithms")
    private List overrideBlackListedSignatureSigningAlgorithms;

    @Autowired(required = false)
    @Qualifier("overrideWhiteListedSignatureSigningAlgorithms")
    private List overrideWhiteListedSignatureSigningAlgorithms;

    @PostConstruct
    public void init() {
        this.validationServiceSelectionStrategies.add(0, samlIdPEntityIdValidationServiceSelectionStrategy());
    }

    @Bean
    public Resource templateSpMetadata() {
        return new ClassPathResource("template-sp-metadata.xml");
    }

    /**
     * Saml id p single logout service logout url builder saml id p single logout service logout url builder.
     *
     * @return the saml idp single logout service logout url builder
     */
    @Bean(name = {"defaultSingleLogoutServiceLogoutUrlBuilder",
            "samlIdPSingleLogoutServiceLogoutUrlBuilder"})
    public SamlIdPSingleLogoutServiceLogoutUrlBuilder samlIdPSingleLogoutServiceLogoutUrlBuilder() {
        final SamlIdPSingleLogoutServiceLogoutUrlBuilder b = new SamlIdPSingleLogoutServiceLogoutUrlBuilder();
        b.setSamlRegisteredServiceCachingMetadataResolver(defaultSamlRegisteredServiceCachingMetadataResolver());
        b.setServicesManager(servicesManager);
        return b;
    }

    @Bean
    public ValidationServiceSelectionStrategy samlIdPEntityIdValidationServiceSelectionStrategy() {
        final SamlIdPEntityIdValidationServiceSelectionStrategy s =
                new SamlIdPEntityIdValidationServiceSelectionStrategy();
        s.setWebApplicationServiceFactory(webApplicationServiceFactory);
        return s;
    }

    @Bean
    @RefreshScope
    public ChainingMetadataResolverCacheLoader chainingMetadataResolverCacheLoader() {
        final ChainingMetadataResolverCacheLoader c = new ChainingMetadataResolverCacheLoader();

        c.setFailFastInitialization(casProperties.getAuthn().getSamlIdp().getMetadata().isFailFast());
        c.setMetadataCacheExpirationMinutes(casProperties.getAuthn().getSamlIdp().getMetadata().getCacheExpirationMinutes());
        c.setRequireValidMetadata(casProperties.getAuthn().getSamlIdp().getMetadata().isRequireValidMetadata());
        c.setConfigBean(this.openSamlConfigBean);
        c.setHttpClient(this.httpClient);
        return c;
    }

    @Bean
    @RefreshScope
    public SamlRegisteredServiceCachingMetadataResolver defaultSamlRegisteredServiceCachingMetadataResolver() {
        final DefaultSamlRegisteredServiceCachingMetadataResolver r =
                new DefaultSamlRegisteredServiceCachingMetadataResolver();
        r.setChainingMetadataResolverCacheLoader(chainingMetadataResolverCacheLoader());
        r.setMetadataCacheExpirationMinutes(casProperties.getAuthn().getSamlIdp().getMetadata().getCacheExpirationMinutes());
        r.setChainingMetadataResolverCacheLoader(chainingMetadataResolverCacheLoader());
        return r;
    }

    @Bean
    @RefreshScope
    public SamlProfileSamlResponseBuilder samlProfileSamlResponseBuilder() {
        final SamlProfileSamlResponseBuilder b = new SamlProfileSamlResponseBuilder();
        b.setConfigBean(openSamlConfigBean);
        b.setSamlObjectEncrypter(samlObjectEncrypter());
        b.setSamlProfileSamlAssertionBuilder(samlProfileSamlAssertionBuilder());
        b.setVelocityEngineFactory(velocityEngineFactory);
        b.setSamlObjectSigner(samlObjectSigner());
        return b;
    }

    @Bean
    @RefreshScope
    public SamlProfileSamlSubjectBuilder samlProfileSamlSubjectBuilder() {
        final SamlProfileSamlSubjectBuilder b = new SamlProfileSamlSubjectBuilder();
        b.setConfigBean(openSamlConfigBean);
        b.setSkewAllowance(casProperties.getAuthn().getSamlIdp().getResponse().getSkewAllowance());
        b.setSsoPostProfileSamlNameIdBuilder(samlProfileSamlNameIdBuilder());
        return b;
    }

    @Bean
    @RefreshScope
    public SamlObjectEncrypter samlObjectEncrypter() {
        final SamlObjectEncrypter e = new SamlObjectEncrypter();
        e.setOverrideBlackListedEncryptionAlgorithms(overrideBlackListedEncryptionAlgorithms);
        e.setOverrideDataEncryptionAlgorithms(overrideDataEncryptionAlgorithms);
        e.setOverrideKeyEncryptionAlgorithms(overrideKeyEncryptionAlgorithms);
        e.setOverrideWhiteListedAlgorithms(overrideWhiteListedAlgorithms);
        return e;
    }

    @Bean
    @RefreshScope
    public SamlObjectSigner samlObjectSigner() {
        final SamlObjectSigner s = new SamlObjectSigner();
        s.setOverrideBlackListedSignatureAlgorithms(overrideBlackListedSignatureSigningAlgorithms);
        s.setOverrideSignatureAlgorithms(overrideSignatureAlgorithms);
        s.setOverrideSignatureReferenceDigestMethods(overrideSignatureReferenceDigestMethods);
        s.setOverrideWhiteListedAlgorithms(overrideWhiteListedSignatureSigningAlgorithms);
        return s;
    }

    @Bean
    public SamlIdpMetadataAndCertificatesGenerationService shibbolethIdpMetadataAndCertificatesGenerationService() {
        final ShibbolethIdpMetadataAndCertificatesGenerationService s =
                new ShibbolethIdpMetadataAndCertificatesGenerationService();

        s.setEntityId(casProperties.getAuthn().getSamlIdp().getEntityId());
        s.setHostName(casProperties.getAuthn().getSamlIdp().getHostName());
        s.setMetadataLocation(casProperties.getAuthn().getSamlIdp().getMetadata().getLocation());
        s.setScope(casProperties.getAuthn().getSamlIdp().getScope());

        return s;
    }

    @Bean
    @RefreshScope
    public SamlProfileSamlNameIdBuilder samlProfileSamlNameIdBuilder() {
        final SamlProfileSamlNameIdBuilder b = new SamlProfileSamlNameIdBuilder();
        b.setConfigBean(openSamlConfigBean);
        return b;
    }

    @Bean
    @RefreshScope
    public SamlProfileSamlConditionsBuilder samlProfileSamlConditionsBuilder() {
        final SamlProfileSamlConditionsBuilder b = new SamlProfileSamlConditionsBuilder();
        b.setConfigBean(openSamlConfigBean);
        return b;
    }

    @Bean
    @RefreshScope
    public AuthnContextClassRefBuilder defaultAuthnContextClassRefBuilder() {
        return new DefaultAuthnContextClassRefBuilder();
    }

    @Bean
    @RefreshScope
    public SamlProfileSamlAssertionBuilder samlProfileSamlAssertionBuilder() {
        final SamlProfileSamlAssertionBuilder b = new SamlProfileSamlAssertionBuilder();

        b.setConfigBean(openSamlConfigBean);
        b.setSamlObjectSigner(samlObjectSigner());
        b.setSamlProfileSamlAttributeStatementBuilder(samlProfileSamlAttributeStatementBuilder());
        b.setSamlProfileSamlAuthNStatementBuilder(samlProfileSamlAuthNStatementBuilder());
        b.setSamlProfileSamlConditionsBuilder(samlProfileSamlConditionsBuilder());
        b.setSamlProfileSamlSubjectBuilder(samlProfileSamlSubjectBuilder());
        return b;
    }

    @Bean
    @RefreshScope
    public SamlProfileSamlAuthNStatementBuilder samlProfileSamlAuthNStatementBuilder() {
        final SamlProfileSamlAuthNStatementBuilder b = new SamlProfileSamlAuthNStatementBuilder();
        b.setConfigBean(openSamlConfigBean);
        b.setAuthnContextClassRefBuilder(defaultAuthnContextClassRefBuilder());
        return b;
    }

    @Bean
    @RefreshScope
    public SamlProfileSamlAttributeStatementBuilder samlProfileSamlAttributeStatementBuilder() {
        final SamlProfileSamlAttributeStatementBuilder b = new SamlProfileSamlAttributeStatementBuilder();
        b.setConfigBean(openSamlConfigBean);
        return b;
    }

    @Bean
    @RefreshScope
    public SSOPostProfileHandlerController ssoPostProfileHandlerController() {
        final SSOPostProfileHandlerController c = new SSOPostProfileHandlerController();
        initControllerBean(c);
        return c;
    }

    private void initControllerBean(final AbstractSamlProfileHandlerController c) {
        c.setConfigBean(openSamlConfigBean);
        c.setParserPool(parserPool);
        c.setResponseBuilder(samlProfileSamlResponseBuilder());
        c.setSamlObjectSigner(samlObjectSigner());
        c.setSamlRegisteredServiceCachingMetadataResolver(defaultSamlRegisteredServiceCachingMetadataResolver());
        c.setServicesManager(servicesManager);
        c.setWebApplicationServiceFactory(webApplicationServiceFactory);

        c.setLogoutUrl(casProperties.getServer().getLogoutUrl());
        c.setForceSignedLogoutRequests(casProperties.getAuthn().getSamlIdp().getLogout().isForceSignedLogoutRequests());
        c.setSingleLogoutCallbacksDisabled(casProperties.getAuthn().getSamlIdp().getLogout().isSingleLogoutCallbacksDisabled());

        c.setLoginUrl(casProperties.getServer().getLoginUrl());
        c.setServerName(casProperties.getServer().getName());
        c.setServerPrefix(casProperties.getServer().getPrefix());
        c.setAuthenticationContextRequestParameter(casProperties.getAuthn().getMfa().getRequestParameter());

        c.setAuthenticationContextClassMappings(this.authenticationContextClassMappings);
    }

    @Bean
    @RefreshScope
    public SLOPostProfileHandlerController sloPostProfileHandlerController() {
        final SLOPostProfileHandlerController c = new SLOPostProfileHandlerController();
        initControllerBean(c);
        return c;
    }

    @Bean
    @RefreshScope
    public IdPInitiatedProfileHandlerController idPInitiatedSamlProfileHandlerController() {
        final IdPInitiatedProfileHandlerController c = new IdPInitiatedProfileHandlerController();
        initControllerBean(c);
        return c;
    }

    @Bean
    @RefreshScope
    public SSOPostProfileCallbackHandlerController ssoPostProfileCallbackHandlerController() {
        final SSOPostProfileCallbackHandlerController c = new SSOPostProfileCallbackHandlerController();
        initControllerBean(c);
        return c;
    }
}


text:
package com.blundell.quicksand.viscosity;

import java.util.Random;

import org.junit.Test;

import static org.fest.assertions.api.Assertions.assertThat;

public class NoChangeViscosityTest {

    private static final long ANY_LONG = new Random().nextLong();

    @Test
    public void testNoMatterTheViewCountDurationIsNeverChanged() throws Exception {
        ViscosityInterpolator viscosity = new NoChangeViscosityInterpolator();

        for (int i = 0; i < 5000; i++) {
            long duration = viscosity.calculateDuration(ANY_LONG, i);

            assertThat(duration).isEqualTo(ANY_LONG);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
/*
!!!!!!!!!本插件依赖parseBoxes插件

判断两个盒的交叠情况,只要有一像素重叠就算
obj,可以是选择器,DOM,或JQ对象,必选
atmosphere,默认为false,只计算border-box部分,如果为true则计算margin-box部分,有磁性吸引的效果
返回对象{
	mode: 'contain(包含)|intersect(交叠)',
	left, right, top, bottom 交叠区的四个位置
}
不交叠的话返回false
*/
(function(){
	$.fn.boxIntersect=function(obj,atmosphere){
		atmosphere=!!atmosphere;
		var obj1=this,
			obj2=$(obj),
			size1=parseInt(obj1.outerWidth(atmosphere)) * parseInt(obj1.outerHeight(atmosphere)),
			size2=parseInt(obj2.outerWidth(atmosphere)) * parseInt(obj2.outerHeight(atmosphere)),
			small= size2>=size1 ? obj1 : obj2,
			big= size1>size2 ? obj1 : obj2,
			box= atmosphere ? "marginBox" : "borderBox",
			boxSmall= small[box](),
			boxBig= big[box](),
			leftBig= boxBig.left,
			rightBig= boxBig.right,
			leftSmall= boxSmall.left,
			rightSmall= boxSmall.right,
			leftIn= leftSmall >= leftBig && leftSmall <= rightBig,
			rightIn= rightSmall >= leftBig && rightSmall <= rightBig;
		if(!leftIn && !rightIn) return false;
		var topBig= boxBig.top,
			bottomBig= boxBig.bottom,
			topSmall= boxSmall.top,
			bottomSmall= boxSmall.bottom,
			topIn= topSmall >= topBig && topSmall <= bottomBig,
			bottomIn=  bottomSmall >= topBig && bottomSmall <= bottomBig;
		if(!topIn && !bottomIn) return false;
		return {
			mode: topIn && bottomIn && leftIn && rightIn ? "contain" : "intersect",
			left: leftIn ? leftSmall : leftBig,
			right: rightIn ? rightSmall : rightBig,
			top: topIn ? topSmall : topBig,
			bottom: bottomIn ? bottomSmall : topSmall
		};
	}
})();


text:
<!DOCTYPE html>

<title>InPhO Topic Explorer</title>

<link rel="stylesheet" type="text/css" href="lib/bootstrap-2.3.2/css/bootstrap.min.css" />

InPhO Topic Explorer

This visualization shows the similarity of {{context_type}}s in the
  {{#corpus_link}}{{corpus_name}}{{/corpus_link}}
  {{^corpus_link}}{{corpus_name}}{{/corpus_link}}.

This visualization shows the similarity of {{context_type}}s in the
  {{#corpus_link}}{{corpus_name}}{{/corpus_link}}
  {{^corpus_link}}{{corpus_name}}{{/corpus_link}} to .

  <form method="GET" class="form-inline" id="searchForm">
  <button class="btn" type="button" id="helpBtn"></button>

    <input type="hidden" name="doc" id="hidden_id">
    <input type="text" id="doc" class="typeahead input-xlarge" placeholder="Document or Search Terms" autocomplete="off">
    <button disabled class="btn" type="button" id="autocompleteDoc"></button>

    <button class="btn" type="button" id="randomDoc"></button>

    <button type="submit" id="submit" class="btn">Visualize</button>

    {{#topic_range}}

{{k}} Topics

    {{/topic_range}}

    <button class="btn" type="button" id="citeBtn">Cite</button>

    Tweet

  </form>

Cite the topic explorer as:

Jaimie Murdock and Colin Allen. (2015) Visualization Techniques for Topic Model Checking in Proceedings of the 29th AAAI Conference on Artificial Intelligence (AAAI-15). Austin, Texas, USA, January 25-29, 2015. http://inphodata.cogs.indiana.edu/

    BibTeX
    PDF

Use the search box below to select an entry or click the  button to populate the box with a random {{context_type}}.

The color bands within each article's row show the topic distribution within that article, and the relative sizes of each band indicates the weight of that topic in the article. The total width of each row indicates similarity to the focal topic or document, measured by the quantity sim(doc) = 1 – JSD(doc, ), where JSD is the Jensen-Shannon distance between the word probability distributions of each item. Each topic's label is arbitrarily assigned, while the color corresponds to the topic's oscillation across documents. Both label and color are consistent across articles in the browser.

Display options include topic normalization, alphabetical sort and topic sort. By normalizing topics, the combined width of each bar expands so that topic weights per document can be compared. By clicking a topic, the documents will reorder acoording to that topic's weight and topic bars will reorder according to the topic weights in the highest weighted document. When a topic is selected, clicking "Top Documents for [Topic]" will take you to a new page showing the most similar documents to that topic's word distribution. The original sort order can be restored with the "Reset Topic Sort" button.

This data was generated using the InPhO VSM module's LDA implementation.  See Wikipedia: Latent Dirichlet Allocation for more on the LDA topic modeling approach or "Probabilistic Topic Models" (Blei, 2012) for a recent review.

Source code and issue tracking for this page available at GitHub. Contact Jaimie Murdock (jammurdo) with further comments.

Loading documents...

  Display Options
  <input class="sort" type="checkbox"> Alphabetical sort
  <input class="scale" type="checkbox"> Normalize topic bars
  <button class="btn reset" onclick="resetTopicSort()" disabled>Reset Topic Sort</button>

  <button class="btn topdoc" style="display:none">Top Documents for [Topic]</button>


text:
/***************
 * PROGRAM:       Modeler
 * NAME:          slider_class.cpp
 * DESCRIPTION:   class for slider subclass
 * AUTHORS:       Andreas Heumann
 * HISTORY:
 *    DATE     NAME  COMMENT
 *    20.11.96 ah    initial release
 *
 * Tags                                type     default
 * --------------------------------------------------------------------------
 * MUIA_StringSlider_Min         IS-   ULONG    1     lower border
 * MUIA_StringSlider_Max         IS-   ULONG    100   upper border
 * MUIA_StringSlider_LowerBound  I--   BOOL     FALSE limit to lower border
 * MUIA_StringSlider_UpperBound  I--   BOOL     FALSE limit to upper border
 * MUIA_StringSlider_Value       ISG   float    1     value
 * MUIA_StringSlider_FLoat       I--   BOOL     TRUE  string accepts floats
 ***************/

#include <math.h>
#include <stdlib.h>
#include <pragma/utility_lib.h>

#ifndef TYPEDEFS_H
#include "typedefs.h"
#endif

#ifndef MUIDEFS_H
#include "MUIdefs.h"
#endif

#ifndef SLIDER_CLASS_H
#include "slider_class.h"
#endif

#ifndef MUIUTILITY_CLASS_H
#include "MUIutility.h"
#endif

/*************
 * DESCRIPTION:   do initialations for string slider subclass
 * INPUT:         system
 * OUTPUT:        created object or 0 if failed
 *************/
static ULONG New(struct IClass *cl,Object *obj,struct opSet *msg)
{
	struct StringSlider_Data *data,databuf;
	char buffer[32];
	float value;

	obj = (Object *)WARPOS_PPC_FUNC(DoSuperNew)(cl,obj,
		MUIA_Group_Columns, 2,
		Child, databuf.sl_slider = SliderObject,
			MUIA_CycleChain, TRUE,
		End,
		Child, databuf.fs_string = StringObject,
			StringFrame,
			MUIA_String_MaxLen, 30,
			MUIA_String_Accept, "0123456789eE.+-",
			MUIA_String_AdvanceOnCR, TRUE,
			MUIA_CycleChain, TRUE,
			MUIA_HorizWeight, 33,
		End,
	TAG_MORE,msg->ops_AttrList);
	if(obj)
	{
		data = (struct StringSlider_Data*)INST_DATA(cl,obj);
		*data = databuf;
		value = (float)WARPOS_PPC_FUNC(GetTagData)(MUIA_StringSlider_Value,1,msg->ops_AttrList);
		data->lower = WARPOS_PPC_FUNC(GetTagData)(MUIA_StringSlider_Min,1,msg->ops_AttrList);
		data->upper = WARPOS_PPC_FUNC(GetTagData)(MUIA_StringSlider_Max,100,msg->ops_AttrList);
		data->lowerbound = (BOOL)WARPOS_PPC_FUNC(GetTagData)(MUIA_StringSlider_LowerBound,FALSE,msg->ops_AttrList);
		data->upperbound = (BOOL)WARPOS_PPC_FUNC(GetTagData)(MUIA_StringSlider_UpperBound,FALSE,msg->ops_AttrList);
		if((BOOL)WARPOS_PPC_FUNC(GetTagData)(MUIA_StringSlider_Float, TRUE, msg->ops_AttrList))
			SetAttrs(obj, MUIA_String_Accept, "0123456789eE.+-", TAG_DONE);
		else
			SetAttrs(obj, MUIA_String_Accept, "0123456789+-", TAG_DONE);

		Float2String(value,buffer);
		SetAttrs(data->fs_string, MUIA_String_Contents, buffer, TAG_DONE);
		SetAttrs(data->sl_slider, MUIA_Slider_Level, (int)ceil(value), TAG_DONE);
		SetAttrs(data->sl_slider, MUIA_Slider_Min, data->lower, TAG_DONE);
		SetAttrs(data->sl_slider, MUIA_Slider_Max, data->upper, TAG_DONE);

		DOMETHOD(data->sl_slider, MUIM_Notify, MUIA_Slider_Level, MUIV_EveryTime,
			data->fs_string, 4, MUIM_SetAsString, MUIA_String_Contents, "%ld", MUIV_TriggerValue);

		DOMETHOD(data->fs_string, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,
			obj, 1, MUIM_StringSlider_StringAck);

		return((ULONG)obj);
	}
	return(0);
}

/*************
 * DESCRIPTION:   OM_SET method
 * INPUT:         system
 * OUTPUT:
 *************/
static ULONG Set(struct IClass *cl,Object *obj,struct opSet *msg)
{
	struct StringSlider_Data *data = (struct StringSlider_Data *)INST_DATA(cl,obj);
	struct TagItem *tags,*tag;
	float value;
	char buffer[32];

	tags=msg->ops_AttrList;
	do
	{
		tag = WARPOS_PPC_FUNC(NextTagItem)(&tags);
		if(tag)
		{
			switch (tag->ti_Tag)
			{
				case MUIA_StringSlider_Value:
					value = *(float*)tag->ti_Data;
					Float2String(value, buffer);
					SetAttrs(data->fs_string, MUIA_String_Contents, buffer, TAG_DONE);
					SetAttrs(data->sl_slider, MUIA_NoNotify, TRUE, MUIA_Slider_Level, (int)ceil(value), TAG_DONE);
					break;
				case MUIA_StringSlider_Min:
					data->lower = tag->ti_Data;
					SetAttrs(data->sl_slider, MUIA_Slider_Min, data->lower, TAG_DONE);
					break;
				case MUIA_StringSlider_Max:
					data->upper = tag->ti_Data;
					SetAttrs(data->sl_slider, MUIA_Slider_Max, data->lower, TAG_DONE);
					break;
			}
		}
	}
	while(tag);

	return(WARPOS_PPC_FUNC(DoSuperMethodA)(cl,obj,(Msg)msg));
}

/*************
 * DESCRIPTION:   OM_GET method
 * INPUT:         system
 * OUTPUT:
 *************/
static ULONG Get(struct IClass *cl,Object *obj,struct opGet *msg)
{
	struct StringSlider_Data *data = (struct StringSlider_Data *)INST_DATA(cl,obj);
	char *s;

	switch (msg->opg_AttrID)
	{
		case MUIA_StringSlider_Value:
			GetAttr(MUIA_String_Contents,data->fs_string,(ULONG*)&s);
			*(float*)(msg->opg_Storage) = atof(s);
			return TRUE;
	}

	return(WARPOS_PPC_FUNC(DoSuperMethodA)(cl,obj,(Msg)msg));
}

/*************
 * DESCRIPTION:   this method is called whenever the user presses return in
 *    the float string object
 * INPUT:         system
 * OUTPUT:
 *************/
static ULONG StringAck(struct IClass *cl,Object *obj,struct opGet *msg)
{
	struct StringSlider_Data *data = (struct StringSlider_Data *)INST_DATA(cl,obj);
	char *s;
	float value;
	char buffer[32];

	GetAttr(MUIA_String_Contents,data->fs_string,(ULONG*)&s);

	value = atof(s);
	if(data->lowerbound && (value < data->lower))
	{
		value = data->lower;
		Float2String(value, buffer);
		SetAttrs(data->fs_string, MUIA_String_Contents, buffer, TAG_DONE);
	}
	if(data->upperbound && (value > data->upper))
	{
		value = data->upper;
		Float2String(value, buffer);
		SetAttrs(data->fs_string, MUIA_String_Contents, buffer, TAG_DONE);
	}

	SetAttrs(data->sl_slider, MUIA_NoNotify, TRUE, MUIA_Slider_Level, (int)ceil(value), TAG_DONE);

	return 0;
}

/*************
 * DESCRIPTION:
 * INPUT:         system
 * OUTPUT:
 *************/
SAVEDS ASM ULONG StringSlider_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
{
	switch(msg->MethodID)
	{
		case OM_NEW:
			return(New(cl,obj,(struct opSet*)msg));
		case OM_SET:
			return(Set(cl,obj,(struct opSet*)msg));
		case OM_GET:
			return(Get(cl,obj,(struct opGet*)msg));
		case MUIM_StringSlider_StringAck:
			return(StringAck(cl,obj,(struct opGet*)msg));
	}
	return(WARPOS_PPC_FUNC(DoSuperMethodA)(cl,obj,msg));
}


text:
/**
 * Bootstrap Table Urdu translation
 * Author: Malik <me@malikrizwan.com>
 */
(function ($) {
    'use strict';

    $.fn.bootstrapTable.locales['ur-PK'] = {
        formatLoadingMessage: function () {
            return 'براۓ مہربانی انتظار کیجئے';
        },
        formatRecordsPerPage: function (pageNumber) {
            return pageNumber + ' ریکارڈز فی صفہ ';
        },
        formatShowingRows: function (pageFrom, pageTo, totalRows) {
            return 'دیکھیں ' + pageFrom + ' سے ' + pageTo + ' کے ' +  totalRows + 'ریکارڈز';
        },
        formatSearch: function () {
            return 'تلاش';
        },
        formatNoMatches: function () {
            return 'کوئی ریکارڈ نہیں ملا';
        },
        formatRefresh: function () {
            return 'تازہ کریں';
        },
        formatToggle: function () {
            return 'تبدیل کریں';
        },
        formatColumns: function () {
            return 'کالم';
        }
    };

    $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['ur-PK']);

})(jQuery);


text:
// datasignal.h

#ifndef DATASIGNAL_H
#define DATASIGNAL_H

#include <iostream>
#include <stdlib.h>
#include <math.h>

#include "SndInFile.h"
#include "SndOutFile.h"
#include "newcomtd_99.h"
//#include "dictionary.h"

#define NMAX_CANAIS_ANALOG 300
#define NMAX_CANAIS_DIGITAL 300

/* Definitions for random functions */
#define Sem_Inicial -1234567
#define IA	    16807
#define IM 	    2147483647
#define AM 	    (1.0/IM)
#define IQ 	    127773
#define IR 	    2836
#define NTAB 	    32
#define NDIV 	    (1+(IM-1)/NTAB)
#define EPS 	    1.2e-7
#define RNMX 	    (1.0-EPS)

using namespace std;

/**
 * \brief Data signal class
 */

class CDataSignal {
protected:
	char*				m_fileName;
	int                 m_numSignal;
	int					m_signalSize;
	double**			m_signal;
	int					m_blockSize;
	int					m_blockHop;
    int                 m_numBlock;
	double*				m_norm;
	int					m_type;
	double				m_Fs;

public:

    // Constructors
    CDataSignal();

    // Destructor
    virtual ~CDataSignal();

    void        setFileName(const char* file);
    void        setNumSignal(const int);
    void        setSignalSize(const int);
    void        setBlockSize(int);
    void        setBlockHop(int);
    void        setNumBlock(int);
    void        setNorm();
    void        setNorm(int signum, double norm);
    void        setType(int);
    void        setSamplingRate(double);

    char*       getFileName();
    int         getNumSignal();
    int	        getSignalSize();
    double**    getSignal();
    int         getBlockSize();
    int         getBlockHop();
    int         getNumBlock();
    double      getNorm(int );
    int         getType();

    // Interface
    virtual void    setSignal()=0;
    virtual void    setSignal(double** signal)=0;
    virtual void    saveSignal()=0;
};

/**
 * \brief Comtrade signal class
 */

class CComtradeSignal : public CDataSignal {

	CConfigComtrade*	m_config;
	int					m_numDigitalSignal;
	char**				m_digitalSignal;

public:

	// Constructors
	CComtradeSignal();

	// Destructor
	~CComtradeSignal();

	// Interface

    virtual void    setSignal();
    virtual void    setSignal(double** signal){};
    virtual void    saveSignal(){};

	// Intrinsic methods
	int					setConfig();
	int					setComtradeSignal();
	void				cutComtrade(char* file,
									int initSample,
									int endSample);

	CConfigComtrade*	getConfig() const;
	long				getNumberOfSamples() const;
	int					getNumberOfAnalogChannels() const;
	int					getNumberOfDigitalChannels() const;
	char**				getDigitalSignal() const;
	double				getSamplingRate(int index) const;
	double				getFundamentalFrequency() const;
};

/**
 * \brief Audio signal class
 */

class CAudioSignal : public CDataSignal {

public:

	// Constructors
	CAudioSignal(){m_type=2;};

	// Destructor
	virtual ~CAudioSignal(){};

	// Interface
	virtual void    setSignal();
    virtual void    setSignal(double** signal);
    virtual void    saveSignal();

	// Intrinsic
	double				getSamplingRate() const;
};

/**
 * \brief Gaussian noise signal class
 */

class CNoiseSignal : public CDataSignal {
public:
	// Constructors
	CNoiseSignal(){m_type=3;};
	// Destructor
	virtual ~CNoiseSignal(){};

	// Interface
	virtual void    setSignal();
    virtual void    setSignal(double** signal){};
    virtual void    saveSignal(){};

	// Intrinsic
	double				getSamplingRate() const;

	double gausdev(long int *sem);
	double ran1(long int *sem);
};

#endif


text:
#import "GifVideo.h"
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

#import "PlayerView.h"

extern GLint sMaxTextureSize;

@implementation GifVideo

int goodSize(int val)
{
    if (val < 128)
        val = 128;
    else if (val < 256)
        val = 256;
    else if (val < 512)
        val = 512;
    else if (val < 1024)
        val = 1024;
    else if (val < 2048)
        val = 2048;
   else if (val < 4096)
        val = 4906;

    return  val;
}

- (int)videoType
{
   return VIDEO_GIF;
}

- (id)initWithSource:(VideoSource*)source inContext:(EAGLContext*)ctx
{
    if (self = [super initWithSource:source inContext:ctx]) {
        // hmm....
        disposal = 0;
        trans = false;
        thumbDelegate = nil;
        /*
         16 colours of format:
         #define GL_PALETTE4_RGB8_OES              0x8B90 (16*3) + ((width*height)/2)  // best
         #define GL_PALETTE4_RGBA8_OES             0x8B91 (16*4) + ((width*height)/2)
         #define GL_PALETTE4_R5_G6_B5_OES          0x8B92 (16*2) + ((width*height)/2)  // second best
         #define GL_PALETTE4_RGBA4_OES             0x8B93 (16*2) + ((width*height)/2)
         #define GL_PALETTE4_RGB5_A1_OES           0x8B94 (16*2) + ((width*height)/2)

         256 colours of format:
         #define GL_PALETTE8_RGB8_OES              0x8B95 (256*3) + (width*height) // best
         #define GL_PALETTE8_RGBA8_OES             0x8B96 (256*4) + (width*height)
         #define GL_PALETTE8_R5_G6_B5_OES          0x8B97 (256*2) + (width*height) // second best
         #define GL_PALETTE8_RGBA4_OES             0x8B98 (256*2) + (width*height)
         #define GL_PALETTE8_RGB5_A1_OES           0x8B99 (256*2) + (width*height)
         */

        bpp = 8;
        bestQuality = true;

        framebuffer = 0;
        texture = 0;

        painter = NULL;

        [self resetState:YES];

        if (upload_size == 0 || gifinfo == 0x0)
        {
            [self release];
            return nil;
        }
    }

    return self;
}

- (void)dealloc {
    // free gif...
    if (gifinfo)
        DGifCloseFile(gifinfo);

    [super dealloc];
}

void map_palette(unsigned char *curPal, int bestFormat, int transIdx, ColorMapObject *global, ColorMapObject *lmap)
{
    unsigned char *cp = curPal;
    GifColorType *color;
    int count = 0;

    if (!lmap) {
        count = global->ColorCount;
        color = global->Colors;
    } else {
        count = lmap->ColorCount;
        color = lmap->Colors;
        cp = curPal;
    }

    if (count < 0)
        return;

    if (bestFormat) {
       int idx = 0;
       while (count-- != 0) {
           *cp++ = color->Red;
           *cp++ = color->Green;
           *cp++ = color->Blue;
           if (idx == transIdx)
              *cp++ = 0;
           else
              *cp++ = 255;
          color++;
          idx++;
       }
    } else {
       // TODO
    }
}

void setPointDrawRect(GLfloat *texCoords, GIFRect src_rect)
{
   float left = src_rect.x;
   float top = src_rect.y;
   float right = left + src_rect.width;
   float bottom = top + src_rect.height;

   texCoords[0] = left;
   texCoords[1] = bottom;
   texCoords[2] = right;
   texCoords[3] = bottom;
   texCoords[4] = left;
   texCoords[5] = top;
   texCoords[6] = right;
   texCoords[7] = top;
}

void setTexDrawRect(GLfloat *texCoords, int tex_width, int tex_height, GIFRect src_rect)
{
   float left = (float)src_rect.x / tex_width;
   float top = (float)src_rect.y / tex_height;
   float right = (float)(src_rect.x + src_rect.width) / tex_width;
   float bottom = (float)(src_rect.y + src_rect.height) / tex_height;

   // Scale by the texture size
   //left = tex_width / left;
   //top = tex_height / top;
   //right = tex_width / right;
   //bottom = tex_height / bottom;

   texCoords[0] = left;
   texCoords[1] = bottom;
   texCoords[2] = right;
   texCoords[3] = bottom;
   texCoords[4] = left;
   texCoords[5] = top;
   texCoords[6] = right;
   texCoords[7] = top;
}

// Copies raw bytes
void copyImageBits8(unsigned char *dest, unsigned char *src, int width, int height, int stride)
{//if (stride != 512) return;
   unsigned char *ptr = dest;
   //memcpy(dest, src, stride);
   for (int y=0; y<height; y++) {
      ptr = dest + (y*stride);
      for (int x=0; x<width; x++) {
         *ptr++ = *src++;
      }
   }
}

// Copies 256 color palette + data
void copyImageBitsPal8(unsigned char *dest, unsigned char *src, int width, int height, int stride)
{//if (stride != 512) return;
   unsigned char *ptr;
   memcpy(dest, src, 256*4);
   src += 256*4;
   //memcpy(dest + 256*3, src, stride);

   for (int y=0; y<height; y++) {
      ptr = dest + (256*4) + (y*stride);
      for (int x=0; x<width; x++) {
         *ptr++ = *src++;
      }
   }
}

VideoWorkerFrame_t *errFrame= NULL;

int sFrameCount = 0;

void debugPrintRenderBuffer();

- (bool)drawFrame:(VideoWorkerFrame_t*)frame andDisposal:(bool)updateDisposal
{
   //if (frame)
   //   printf("drawFrame: drawing frame %i\n", frame->frameID);

   // Don't draw if we haven't recieved frames yet
   if (frame == NULL && last_frame.data == NULL)
      return false;

   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

   glEnableClientState(GL_VERTEX_ARRAY);
   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   glVertexPointer(2, GL_FLOAT, 0, sVidSquareVertices);
   glTexCoordPointer(2, GL_FLOAT, 0, sVidSquareTexcoords);

   // Draw disposal frame
   if (updateDisposal) {
      // Now drawing to texture
      TargetRenderInfoSet(disposalRenderInfo);
      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glLoadIdentity();

      /*glPushMatrix();
      glTranslatef(last_frame.rect.x, last_frame.rect.y, last_frame.rect.width);
      glPopMatrix();*/

      if (frame && frame->reset) {
         glClearColor(1,0,0,0);
         glClear(GL_COLOR_BUFFER_BIT);
      }
      else {
         [self setPaintHead:painter];

         // draw new previous frame
         switch (last_frame.disposal_type) {
            case DISPOSE_RESET:
               // Clear all pixels
               glEnable(GL_SCISSOR_TEST);
               glScissor(last_frame.rect.x, last_frame.rect.y, last_frame.rect.width, last_frame.rect.height);
               glClearColor(0,0,0,0);
               glClear(GL_COLOR_BUFFER_BIT);
               glDisable(GL_SCISSOR_TEST);
               break;
            case DISPOSE_CLEARBG:
               // Clear BG color
               glEnable(GL_SCISSOR_TEST);
               glScissor(last_frame.rect.x, last_frame.rect.y, last_frame.rect.width, last_frame.rect.height);
               glClearColor(last_frame.clear_r / 255.0f, last_frame.clear_g  / 255.0f, last_frame.clear_b  / 255.0f, last_frame.clear_a  / 255.0f);
               glClear(GL_COLOR_BUFFER_BIT);
               glDisable(GL_SCISSOR_TEST);
               break;
            case DISPOSE_PREVIOUSBG:
               // Do nothing
               break;
            case DISPOSE_NONE:
            default:
               // Copy current frame to previous
               //setPointDrawRect(sVidSquareVertices, last_frame.rect);
               //setTexDrawRect(sVidSquareTexcoords, painter->width, painter->height, tex_rect);

               glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
               /*glEnable(GL_SCISSOR_TEST);
                glScissor(last_frame.rect.x, last_frame.rect.y, last_frame.rect.width, last_frame.rect.height);
                glClearColor(0,1,0,1);
                glClear(GL_COLOR_BUFFER_BIT);
                glDisable(GL_SCISSOR_TEST);*/
               break;
         }
      }

      // Reset state
      glMatrixMode(GL_MODELVIEW);
      glPopMatrix();
      glFinish();
   }

   // Set player view rendering
   TargetRenderInfoSet(viewRenderInfo);

   // Update paint head
   if (frame)
   {
      if (!VideoTexture_lock(painter)) {
         return false;
      }
      memset(painter->data, '\0', upload_size);
      copyImageBitsPal8(painter->data, frame->data, frame->rect.width, frame->rect.height, painter->width);
      VideoTexture_unlock(painter);
   }

   // First, render last frame (ALL of it)
   if ((frame && !frame->reset) || !(!frame && last_frame.reset)) {
      GIFRect rect;
      rect.x = 0;
      rect.y = 0;
      rect.width = gifinfo->SWidth;
      rect.height = gifinfo->SHeight;
      [self drawPreviousFrame:rect];
   }

   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

   //debugPrintRenderBuffer();

   if (frame) last_frame = *frame;
   GIFRect tex_rect = last_frame.rect;
   tex_rect.x = tex_rect.y = 0;

   // draw new frame
   [self setPaintHead:painter];
   setPointDrawRect(sVidSquareVertices, last_frame.rect);
   setTexDrawRect(sVidSquareTexcoords, painter->width, painter->height, tex_rect);
   glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

   // if (sFrameCount++ >= 2) {
   //    return true;
   // }
   //return false;

   return true;
}

- (bool)nextFrame:(VideoWorkerFrame_t*)frame
{
    unsigned char *data = frame->data;
    // Are we reading headers?
    if (!VideoSource_bytesready(src))
        return false;

    //L0Log(@"frame == %d, sync == %f, fps == %f", frame, sync_time, fps_time);

    // First stage: read all of the blocks
    if (!readingFrame)
    {
        GifRecordType recordType;
        bool inError = false;

        // Currently reading headers?
        if (!VideoSource_bytesready(src))
            return false;

        VideoSource_startBytes(src); // start pos (if not set)

        do {
            int oldpos = src->pos;
            if (DGifGetRecordType(gifinfo, &recordType) == GIF_ERROR) {
                inError = true;
                break;
            }

            // Check record types
            if (recordType == IMAGE_DESC_RECORD_TYPE) {
                if (DGifGetImageDesc(gifinfo) == GIF_ERROR) {
                    inError = true;
                    break;
                }
                //L0Log(@"IMAGE DESC @ %i...", oldpos);
                readingFrame = YES;
                src->last_pos = oldpos;
                break;
            }
            else if (recordType == EXTENSION_RECORD_TYPE)
            {
                GifByteType *ext;
                int extCode;

                // Skip any extension blocks in file
                if (DGifGetExtension(gifinfo, &extCode, &ext) != GIF_ERROR) {
                    if (extCode == 0xF9) {
                        GifByteType *ptr = ext+1;
                        if (*ptr & 0x1) {
                            transindex = *(ptr+3);
                            trans = true;
                        } else {
                            trans = false;
                            transindex = -1;
                        }
                        int frametime = *(ptr+1) | (*(ptr+2) << 8);
                        disposal= ((*ptr)>>2) & 0x7;
                        if (disposal == 0) disposal = 1; // Fix for broken gifs

                        // 0 == no action  (reset)
                        {
                            // 1 == no dispose (start with previous state)
                            // 2 == restore to background (prev == background)
                        }
                        // 3 == restore to previous (next prev == current)

                        if(frametime<10) frametime=10;
                        if(disposal==4) disposal=3;

                        switch (disposal) {
                           case 0:
                              frame->disposal_type = DISPOSE_RESET;
                              break;
                           case 1:
                              frame->disposal_type = DISPOSE_NONE;
                              break;
                           case 2:
                              frame->disposal_type = DISPOSE_CLEARBG;
                              break;
                           case 3:
                              frame->disposal_type = DISPOSE_PREVIOUSBG;
                              break;
                           default:
                              frame->disposal_type = DISPOSE_NONE;
                              break;
                        }

                        frame->dt = (1.0/100.0)*frametime;
                        frame->blend_type = BLEND_SOURCE;

                        //if(disposal==2&&transindex==gifinfo->SBackGroundColor)
                        //    trans=true;
                    }
                    while (ext != NULL)  // read the rest of the extension blocks
                    {
                        if (DGifGetExtensionNext(gifinfo, &ext) == GIF_ERROR) {
                            inError = true;
                            break;
                        }
                    }
                } else {
                    inError = true;
                    break;
                }
            }
        } while (recordType != TERMINATE_RECORD_TYPE);

        if (inError) {
            if (!VideoSource_waitforbytes(src)) // no more data?
            {
                VideoSource_endBytes(src);

                // loop or stop completely
                if (!loop) {
                    [self stop];
                    return false;
                } else {
                    // Start again!
                   [self resetState:NO];
                    return false;
                }
            }
            else
            {
                // Waiting for data, flush the damn state
               [self flushState];
            }
        }
    }

    // Second stage: read frame
    if (readingFrame) {
        // starting at IMAGE_DESC_RECORD_TYPE
        int gwidth  = gifinfo->Image.Width;
        int gheight = gifinfo->Image.Height;

        int palSize = bestQuality ? 4 : 2;

        unsigned char curPal[256*4];

        // Map image palette colors info color map
        map_palette(curPal, bestQuality, transindex, gifinfo->SColorMap, gifinfo->Image.ColorMap);

        frame->rect.x = gifinfo->Image.Left;
        frame->rect.y = gifinfo->Image.Top;
        frame->rect.width = gwidth;
        frame->rect.height = gheight;

        unsigned char *cp = curPal + (gifinfo->SBackGroundColor*palSize);
        if (trans && transindex == gifinfo->SBackGroundColor) {
           frame->clear_a = 0;
        } else {
           frame->clear_a = 255;
        }

        frame->clear_r = cp[0];
        frame->clear_g = cp[1];
        frame->clear_b = cp[2];
        frame->reset = current_frame == 0;
        frame->frameID = current_frame++;
        //printf("GifInfo: added frame %i\n", frame->frameID);

        // Now we decode the frame

        unsigned char *gif_data = ( unsigned char * ) malloc( gwidth * gheight );

        if (DGifGetLine(gifinfo, gif_data, gwidth * gheight) != GIF_ERROR) {
            readingFrame = NO;
            unsigned char *buff = (unsigned char*)data + (256*palSize);
            memcpy(data, curPal, 256*palSize);
            memset(buff, '\0', width*height);

            //memset(buff, gifinfo->SBackGroundColor, width*height);

            // src is data
            unsigned char *gifsrc = (unsigned char *)gif_data;
            int bottom = gheight;
            int next = 0;//(width-gwidth);

            if (gifinfo->Image.Interlace)
            {
                int sourceRow = 0;

                for (int i=0; i<4; i++) {
                    int startRow;
                    int interval;
                    switch (i) {
                        case 0:
                            startRow = 0;
                            interval = 8;
                            break;
                        case 1:
                            startRow = 4;
                            interval = 8;
                            break;
                        case 2:
                            startRow = 2;
                            interval = 4;
                            break;
                        case 3:
                            startRow = 1;
                            interval = 2;
                            break;
                    }

                    // Spit out into buff using indexes
                    for (int destRow = startRow; destRow < bottom; destRow += interval)
                    {
                        unsigned char *dptr = buff + (destRow * (gwidth+next));
                        unsigned char *sptr = gifsrc + (sourceRow * gwidth);                        for (int j=0; j<gwidth; j++) {
                             *dptr++ = *sptr++;
                        }

                        sourceRow++;
                    }
                }
            }
            else while (bottom--) // non-interlaced
            {
                int right = gwidth;
                while (right-- != 0) {
                    *buff++ = *gifsrc++;
                }
                buff += next;
            }

            VideoSource_endBytes(src);

            free(gif_data);
            return true;
        } else {
            free(gif_data);

            // Need more bytes, try and wait...
            if (!src->writeable)
            {
                VideoSource_endBytes(src);

                // Error, loop frame in case of EOF
                if (!loop) {
                    [self stop];
                    return false;
                } else {
                   [self resetState:NO];
                    return false;
                }
            }
            else
            {
                [self flushState];

                // Keep reading the image description (last saved place) until we get more data
                //L0Log(@"NOT ENOUGH DATA TO DECODE...");
                VideoSource_rewind(src);
                readingFrame = false;
                return false;
            }
        }
    }

    return false;
}

static int gifReadDataFn(GifFileType *gifinfo, GifByteType *data, int length)
{
    VideoSource *src = (VideoSource*)gifinfo->UserData;
    return VideoSource_read(src, (unsigned char*)data, length);
}

- (void)resetState:(bool)gl
{
    sFrameCount = 0;
    current_frame = 0;
    errFrame = NULL;
    last_frame.data = NULL;
    waitDT = 0;

    VideoSource_seek(src, 0);
    if (gifinfo)
        DGifCloseFile(gifinfo);
    gifinfo = DGifOpen( src, gifReadDataFn);
    if (gifinfo)
        gifinfo->generateSavedImages = false;

    readingFrame = false;

    // determine master width, height

    width  = gifinfo ? goodSize(gifinfo->SWidth) : 0;
    height = gifinfo ? goodSize(gifinfo->SHeight) : 0;

    if (gifinfo == NULL || width > sMaxTextureSize || height > sMaxTextureSize)
    {
        upload_size = 0;
        if (gifinfo)
            DGifCloseFile(gifinfo);
        gifinfo = nil;
        return;
    }

 // texture format
    fmt = bestQuality ? GL_PALETTE8_RGBA8_OES : GL_PALETTE8_RGBA4_OES;

    upload_size = VideoTexture_sizeOfTexture(fmt, width, height, 0);

   if (gl) {

    if (painter)
      VideoTexture_release(painter);

    painter = VideoTexture_init(width, height, fmt);
   }
}

- (void)flushState
{
    int oldPos = src->pos;
    VideoSource_seek(src, 0);
    if (gifinfo)
        DGifCloseFile(gifinfo);
    gifinfo = DGifOpen(src, gifReadDataFn);
    VideoSource_seek(src, oldPos);
}

- (void)frameClipScale:(float*)scale
{
    if (gifinfo) {
        scale[0] = (float)gifinfo->SWidth / (float)width;
        scale[1] = (float)gifinfo->SHeight / (float)height;
    } else {
        scale[0] = 1.0;
        scale[1] = 1.0;
    }
}

- (CGSize)frameSize
{
    if (gifinfo)
        return CGSizeMake(gifinfo->SWidth, gifinfo->SHeight);
    else
        return CGSizeMake(width, height);
}

@end


text:
from __future__ import unicode_literals

from django.db import models, migrations

class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Pin',
            fields=[
                ('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
                ('title', models.CharField(max_length=200)),
            ],
        ),
    ]


text:
package io.hekate.lock.internal;

import io.hekate.cluster.ClusterNode;
import io.hekate.lock.LockOwnerInfo;
import io.hekate.util.format.ToString;

public class DefaultLockOwnerInfo implements LockOwnerInfo {
    private final long threadId;

    private final ClusterNode node;

    public DefaultLockOwnerInfo(long threadId, ClusterNode node) {
        this.threadId = threadId;
        this.node = node;
    }

    @Override
    public long threadId() {
        return threadId;
    }

    @Override
    public ClusterNode node() {
        return node;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (!(o instanceof DefaultLockOwnerInfo)) {
            return false;
        }

        DefaultLockOwnerInfo that = (DefaultLockOwnerInfo)o;

        if (threadId != that.threadId) {
            return false;
        }

        return node.equals(that.node);
    }

    @Override
    public int hashCode() {
        int result = (int)(threadId ^ threadId >>> 32);

        result = 31 * result + node.hashCode();

        return result;
    }

    @Override
    public String toString() {
        return ToString.format(LockOwnerInfo.class, this);
    }
}


text:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <exception>
#include <stdexcept>

#include <boost/shared_ptr.hpp>

#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <memory.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <netinet/in.h>

#include "shared.h"
#include "onl_database.h"

#include "onlcrd_reservation.h"
#include "onlcrd_session.h"
#include "onlcrd_component.h"
#include "onlcrd_session_manager.h"
#include "onlcrd_globals.h"
#include "onlcrd_requests.h"
#include "onlcrd_responses.h"
#include "onlcrd_session_sharing.h"

using namespace onlcrd;
switch_vlan test_vlan = 0; //used when testing and don't want to connect to NMD

session_manager::session_manager() throw()
{
  pthread_mutex_init(&vlan_lock, NULL);

  pthread_mutex_init(&port_lock, NULL);

  pthread_mutex_init(&comp_lock, NULL);

  pthread_mutex_init(&session_lock, NULL);
  next_session_id = 1;

  pthread_mutex_init(&reservation_lock, NULL);
  next_reservation_id = 1;

  pthread_mutex_init(&db_lock, NULL);
  database = new onl::onldb();

  //JP added 11/13/12 to force users to wait until we know about all testbed nodes
  initializing = true;
}

session_manager::~session_manager()
{
  pthread_mutex_destroy(&vlan_lock);

  pthread_mutex_destroy(&db_lock);

  pthread_mutex_destroy(&comp_lock);

  pthread_mutex_destroy(&session_lock);

  while(!active_reservations.empty())
  {
    delete active_reservations.front();
    active_reservations.pop_front();
  }
  pthread_mutex_destroy(&reservation_lock);
}

void
session_manager::initialize()
{
  if (testing) return;
  int ret;
  if(!testing)
  {
    std::string cmd = "/usr/testbed/scripts/send_crd_email.pl";
    ret = system(cmd.c_str());
    if(ret < 0 || WEXITSTATUS(ret) != 1) write_log("session_manager::initialize(): Warning: starting email was not sent");
    database->clear_all_experiments();
  }

  if(!testing)
  {
    onld::initialize* init = new onld::initialize();

    onl::switch_info_list switch_list;
    database->get_switch_list(switch_list);
    while(!switch_list.empty())
    {
      onl::switch_info sw = switch_list.front();
      switch_list.pop_front();

      onld::switch_info nextsw(sw.get_switch(), sw.get_num_ports());
      nextsw.set_management_port(sw.get_mgmt_port());
      init->add_switch(nextsw);
    }

    init->set_connection(the_gige_conn);
    if(!init->send_and_wait())
    {
      write_log("session_manager::initialize(): NMD initialization failed! exiting.");
      exit(1);
    }
    switch_response *swresp = (switch_response*)init->get_response();
    if(swresp->getStatus() != NCCP_Status_Fine)
    {
      write_log("session_manager::initialize(): warning!! NMD initialization returned failure!");
    }
    delete swresp;
    delete init;
  }

  onl::node_info_list node_list;
  database->get_base_node_list(node_list);

  autoLockDebug clock(comp_lock, "session_manager::initialize(): comp_lock");

  std::list<crd_component_ptr> new_nodes;
  while(!node_list.empty())
  {
    onl::node_info node = node_list.front();
    node_list.pop_front();

    if(node.state() == "free")
    {
      std::string cp = "";
      unsigned short cp_port = 0;
      if(node.has_cp())
      {
        cp = node.cp();
        cp_port = node.cp_port();
      }

      crd_component_ptr new_comp(new crd_component(node.node(), cp, cp_port, node.do_keeboot(), node.is_dependent()));
      new_comp->setCluster(node.cluster());
      new_nodes.push_back(new_comp);

    }
  }
  //set dependent info
  std::list<crd_component_ptr>::iterator cit;
  std::list<crd_component_ptr>::reverse_iterator cit2;
  for(cit = new_nodes.begin(); cit != new_nodes.end(); ++cit)
    {
      if (!(*cit)->getCluster().empty())
	{
	  write_log("session_manager::initialize set dependent comp:" + (*cit)->getName() + " cluster:" + (*cit)->getCluster());
	  for(cit2 = new_nodes.rbegin(); cit2 != new_nodes.rend(); ++cit2)
	    {
	      if ((*cit)==(*cit2)) break;
	      if ((*cit2)->getCluster() == (*cit)->getCluster())
		{
		  (*cit)->setDependentComp((*cit2)->getName());
		  (*cit2)->setDependentComp((*cit)->getName());
		  break;
		}
	    }
	}
    }
  for(cit = new_nodes.begin(); cit != new_nodes.end(); ++cit)
  {
    if(!(*cit)->ignore())
    {
      refreshing_components.push_back((*cit));
      (*cit)->refresh();
    }
  }
  new_nodes.clear();
  clock.unlock();
}

bool
session_manager::authenticate(std::string username, std::string password)
{
  write_log("session_manager::authenticate(): user " + username + " with password hash " + password);
  autoLockDebug dlock(db_lock, "session_manager::authenticate(): db_lock");

  onl::onldb_resp res = database->authenticate_user(username,password);
  if(res.result() < 1)
  {
    write_log("session_manager::authenticate(): failed error:" + res.msg());
    return false;
  }
  return true;
}

bool
session_manager::has_session(std::string username)
{
  write_log("session_manager::has_session(): user " + username);
  autoLockDebug slock(session_lock, "session_manager::has_session(): session_lock");

  std::list<session_ptr>::iterator it;
  for(it = active_sessions.begin(); it != active_sessions.end(); ++it)
  {
    if(((*it)->getUser() == username) && (!((*it)->is_cleared()))) { return true; }
  }
  return false;
}

int
session_manager::reservation_time_left(std::string username)
{
  autoLockDebug dlock(db_lock, "session_manager::reservation_time_left(): db_lock");

  onl::onldb_resp res = database->has_reservation(username);
  if(res.result() < 1)
  {
    return 0;
  }
  return res.result();
}

bool
session_manager::is_admin(std::string username)
{
  autoLockDebug dlock(db_lock, "session_manager::is_admin(): db_lock");

  onl::onldb_resp res = database->is_admin(username);
  if(res.result() < 1)
  {
    return false;
  }
  return true;
}

bool
session_manager::extend_reservation(std::string username, uint32_t minutes)
{
  write_log("session_manager::extend_reservation(): user " + username + " for " + int2str(minutes));
  autoLockDebug dlock(db_lock, "session_manager::extend_reservation(): db_lock");

  onl::onldb_resp res = database->extend_current_reservation(username, minutes);
  if(res.result() < 1)
  {
    write_log("session_manager::extend_reservation(): failed: " + res.msg());
    return false;
  }
  return true;
}

bool
session_manager::cancel_reservation(std::string username)
{
  write_log("session_manager::cancel_reservation(): user " + username);
  autoLockDebug dlock(db_lock, "session_manager::cancel_reservation(): db_lock");

  onl::onldb_resp res = database->cancel_current_reservation(username);
  if(res.result() < 1)
  {
    return false;
  }
  return true;
}

int
session_manager::get_capacity(std::string type, int port)
{
  //write_log("session_manager::get_capacity(): type=" + type + " port=" + int2str(port));
  autoLockDebug dlock(db_lock, "session_manager::get_capacity(): db_lock");

  onl::onldb_resp res = database->get_capacity(type, port);

  return res.result();
}

bool
session_manager::has_virtual_port(std::string type)
{
  //write_log("session_manager::get_capacity(): type=" + type + " port=" + int2str(port));
  autoLockDebug dlock(db_lock, "session_manager::is_vport(): db_lock");

  onl::onldb_resp res = database->has_virtual_port(type);

  if (res.result())
    return true;
  else
    return false;
}

void
session_manager::get_switch_ports(unsigned int cid, switch_port& p1, switch_port& p2)
{
  //write_log("session_manager::get_switch_ports(): cid=" + int2str(cid));
  autoLockDebug dlock(db_lock, "session_manager::get_switch_ports(): db_lock");

  onl::switch_port_info spi1, spi2;

  database->get_switch_ports(cid, spi1, spi2);

  p1 = switch_port(spi1.get_switch(),spi1.get_port(),spi1.is_interswitch_port(),spi1.get_pass_tag());
  p2 = switch_port(spi2.get_switch(),spi2.get_port(),spi2.is_interswitch_port(),spi2.get_pass_tag());
}

void
session_manager::fix_component(onl::topology* top, uint32_t id, std::string cp)
{
  write_log("session_manager::fix_component(): id=" + int2str(id) + " cp=" + cp);
  autoLockDebug dlock(db_lock, "session_manager::fix_component(): db_lock");

  database->fix_component(top, id, cp);
}

bool
session_manager::make_reservation(reservation* res, std::string username, std::string early_start, std::string late_start, uint32_t duration, onl::topology* top)
{
  write_log("session_manager::make_reservation(): user " + username);
  autoLockDebug dlock(db_lock, "session_manager::make_reservation(): db_lock");

  onl::onldb_resp resp = database->make_reservation(username, early_start, late_start, duration, top);
  res->setErrorMsg(resp.msg());
  if(resp.result() < 1)
  {
    return false;
  }
  return true;
}

bool
session_manager::assign_resources(session_ptr sess, std::string username, onl::topology* top)
{
  write_log("session_manager::assign_resources(): user " + username);
  //write_usage_log("USAGE_LOG: COMMIT user " + username);
  autoLockDebug dlock(db_lock, "session_manager::assign_resources(): db_lock");

  onl::onldb_resp res = database->assign_resources(username, top);
  if(res.result() < 1)
  {
    sess->setErrorMsg(res.msg());
    return false;
  }
  return true;
}

void
session_manager::return_resources(std::string username, onl::topology* top)
{
  write_log("session_manager::return_resources(): user " + username);
  //write_usage_log("USAGE_LOG: CLOSE user " + username);
  autoLockDebug dlock(db_lock, "session_manager::return_resources(): db_lock");

  database->return_resources(username, top);
}

void
session_manager::check_for_expired_sessions()
{
  std::list<std::string> users;

  autoLockDebug dlock(db_lock, "session_manager::check_for_expired_sessions(): db_lock");
  onl::onldb_resp res = database->get_expired_sessions(users);
  dlock.unlock();

  if(res.result() < 1)
  {
    write_log("session_manager::check_for_expired_sessions(): warning: db call failed: " + res.msg());
    return;
  }

  while(!users.empty())
  {
    std::string user = users.front();
    users.pop_front();

    session_ptr sess = get_session(user);
    if (sess)
      {
	sess->expired();
	sess->clear();
      }
  }
}

void
session_manager::received_up_msg(std::string hostname)
{
  //TODO make sure all of the relevant components are updated particularly for vms
  write_log("session_manager::received_up_msg(): host " + hostname);

  autoLockDebug clock(comp_lock, "session_manager::received_up_msg(): comp_lock");

  crd_component_ptr comp;
  std::list<crd_component_ptr>::iterator i;
  for(i=refreshing_components.begin(); i!=refreshing_components.end(); ++i)
  {
    if((*i)->getCP() == hostname)
    {
      comp = *i;
      break;
    }
  }

  if(!comp)
  {
    for(i=active_components.begin(); i!=active_components.end(); ++i)
    {
      if((*i)->getCP() == hostname)
      {
        comp = *i;
        break;
      }
    }
  }
  clock.unlock();

  // if comp was in the list, then let the refresher finish
  if(comp)
  {
    comp->got_up_msg();
    return;
  }

  // if comp wasn't in the list, then it must have been in an unknown state
  // but is now back up
  autoLockDebug dlock(db_lock, "session_manager::received_up_msg(): db_lock");
  onl::onldb_resp r = database->get_node_from_cp(hostname);
  if(r.result() <= 0)
  {
    write_log("session_manager::received_up_msg(): get node failed: " + r.msg());
    return;
  }

  // if we got the node, r.msg() has the node name
  std::string node = r.msg();

  // get the base node info
  onl::node_info info;
  r = database->get_node_info(node, false, info);
  if(r.result() < 0)
  {
    write_log("session_manager::received_up_msg(): get node info failed: " + r.msg());
    return;
  }

  // since the node is back up now, free it
  r = database->set_state(node, "free");
  if(r.result() <= 0)
  {
    write_log("session_manager::received_up_msg(): set state to free failed: " + r.msg());
    return;
  }
  dlock.unlock();

  // if the node uses keeboot, then we need to complete the keeboot. the
  // simplest way to ensure a clean state is to refresh the node completely
  if(info.do_keeboot())
  {
    std::string cp = "";
    unsigned short cp_port = 0;
    if(info.has_cp())
    {
      cp = info.cp();
      cp_port = info.cp_port();
    }

    crd_component_ptr new_comp(new crd_component(node, cp, cp_port, info.do_keeboot(), info.is_dependent()));
    if(!new_comp->ignore())
    {
      refreshing_components.push_back(new_comp);
      new_comp->refresh();
    }
  }
}

void
session_manager::set_keeboot_param(std::string name, std::string param)
{
  autoLockDebug clock(comp_lock, "session_manager::set_keeboot_param(): comp_lock");
  keeboot_params[name] = param;
}

bool
session_manager::check_keeboot_param(std::string name)
{
  autoLockDebug clock(comp_lock, "session_manager::check_keeboot_param(): comp_lock");
  std::map<std::string, std::string>::iterator it;
  it = keeboot_params.find(name);
  if(it == keeboot_params.end())
  {
    return false;
  }
  return true;
}

std::string
session_manager::get_keeboot_param(std::string name)
{
  std::map<std::string, std::string>::iterator it;
  it = keeboot_params.find(name);
  if(it == keeboot_params.end())
  {
    // if the user hasn't set an fs to boot, check for a file in the
    // install directory with this nodes name.
    struct stat fb;
    std::string install_file = "/export/keeboot_kernels/install/" + name + ".fsa";
    if(lstat(install_file.c_str(), &fb) == 0)
    {
      if((fb.st_mode & S_IFMT) == S_IFLNK)
      {
        std::string install_fs = "install/" + name;
        return install_fs;
      }
    }
    return "";
    //std::string default_fs = type + "/default";
    //return default_fs;
  }
  std::string fs = it->second;
  keeboot_params.erase(it);
  return fs;
}

bool
session_manager::start_session_vlans(std::string sid)
{
  if (!testing)
    {
      onld::start_session* startsession = new onld::start_session(sid);
      startsession->set_connection(the_gige_conn);
      if (!startsession->send_and_wait())
	{
	  delete startsession;
	  return false;
	}

      switch_response *swresp = (switch_response*)startsession->get_response();
      if(swresp->getStatus() != NCCP_Status_Fine)
	{
	  delete swresp;
	  delete startsession;
	  return false;
	}

      delete swresp;
      delete startsession;
    }
  return true;
}

bool
session_manager::clear_session_vlans(std::string sid)
{
  if (!testing)
    {
      onld::end_session* endsession = new onld::end_session(sid);
      endsession->set_connection(the_gige_conn);
      if (!endsession->send_and_wait())
	{
	  delete endsession;
	  return false;
	}

      switch_response *swresp = (switch_response*)endsession->get_response();
      if(swresp->getStatus() != NCCP_Status_Fine)
	{
	  delete swresp;
	  delete endsession;
	  return false;
	}

      delete swresp;
      delete endsession;
    }
  return true;
}

vlan_ptr
session_manager::add_vlan(std::string sid)
{
  switch_vlan vlan = 0;
  vlan_ptr null_ptr(new crd_vlan());
  null_ptr->vlanid = 0;;
  null_ptr->is_deleted = true;
  if (!testing)
    {
      onld::add_vlan* addvlan = new onld::add_vlan(sid);
      addvlan->set_connection(the_gige_conn);

      if(!addvlan->send_and_wait())
	{
	  delete addvlan;
	  return null_ptr;
	}

      add_vlan_response *addresp = (add_vlan_response*)addvlan->get_response();
      if(addresp->getStatus() != NCCP_Status_Fine)
	{
	  delete addresp;
	  delete addvlan;
	  return null_ptr;
	}

      vlan = addresp->getVlan();
      write_log("session_manager::add_vlan() vlan " + int2str(vlan));

      delete addresp;
      delete addvlan;
    }
  else
    {
      vlan = ++test_vlan;
    }
  autoLockDebug vlock(vlan_lock, "session_manager::add_vlan(): vlan_lock");
  num_ports_on_vlan[vlan] = 0;
  vlock.unlock();
  vlan_ptr new_vlan(new crd_vlan());
  new_vlan->vlanid = vlan;
  new_vlan->is_deleted = false;

  return new_vlan;
}

bool
session_manager::add_port_to_vlan(vlan_ptr vlan, switch_port port, std::string sid)
{
  if (!testing)
    {
      add_to_vlan* addtovlan = new add_to_vlan(vlan->vlanid, port, sid);
      addtovlan->set_connection(the_gige_conn);

      if(!addtovlan->send_and_wait())
	{
	  delete addtovlan;
	  return false;
	}

      switch_response *swresp = (switch_response*)addtovlan->get_response();
      if(swresp->getStatus() != NCCP_Status_Fine)
	{
	  delete swresp;
	  delete addtovlan;
	  return false;
	}

      delete swresp;
      delete addtovlan;
    }

  autoLockDebug vlock(vlan_lock, "session_manager::add_port_to_vlan(): vlan_lock");
  num_ports_on_vlan[vlan->vlanid] = num_ports_on_vlan[vlan->vlanid] + 1;
  vlock.unlock();

  return true;
}

bool
session_manager::remove_port_from_vlan(vlan_ptr vlan, switch_port port, std::string sid)
{
  bool last_port = false;

  autoLockDebug vlock(vlan_lock, "session_manager::remove_port_from_vlan(): vlan_lock");
  num_ports_on_vlan[vlan->vlanid] = num_ports_on_vlan[vlan->vlanid] - 1;
  if(num_ports_on_vlan[vlan->vlanid] == 0) { last_port = true; }
  vlock.unlock();

  if (!testing)
    {
      delete_from_vlan* delfromvlan = new delete_from_vlan(vlan->vlanid, port, sid);
      delfromvlan->set_connection(the_gige_conn);
      /*
      if(!add_port_to_outstanding_list(port))
	{
	  write_log("session_manager::remove_port_from_vlan(" + int2str(vlan->vlanid) + "): giving up after port was always in outstanding list: " + port.getSwitchId() + " port " + int2str(port.getPortNum()));
	  delete delfromvlan;
	  return false;
	  }*/

      if(!delfromvlan->send_and_wait())
	{
	  //remove_port_from_outstanding_list(port);
	  delete delfromvlan;
	  if(last_port)
	    {
	      if (delete_vlan(vlan, sid))
		write_log("session_manager::remove_port_from_vlan(): delete vlan " + int2str(vlan->vlanid));
	      else
		write_log("session_manager::remove_port_from_vlan(): warning: delete vlan failed for vlan " + int2str(vlan->vlanid));
	    }
	  return false;
	}

      //remove_port_from_outstanding_list(port);

      switch_response *swresp = (switch_response*)delfromvlan->get_response();
      if(swresp->getStatus() != NCCP_Status_Fine)
	{
	  delete swresp;
	  delete delfromvlan;
	  if(last_port)
	    {
	      if (delete_vlan(vlan, sid))
		write_log("session_manager::remove_port_from_vlan(): b delete vlan " + int2str(vlan->vlanid));
	      else
		write_log("session_manager::remove_port_from_vlan(): warning: delete vlan failed for vlan " + int2str(vlan->vlanid));
	    }
	  return false;
	}

      delete swresp;
      delete delfromvlan;
    }
  //else //testing
  //remove_port_from_outstanding_list(port);

  if(last_port)
  {
    if (delete_vlan(vlan, sid))
      write_log("session_manager::remove_port_from_vlan(): c delete vlan " + int2str(vlan->vlanid));
    else
      write_log("session_manager::remove_port_from_vlan(): warning: delete vlan failed for vlan " + int2str(vlan->vlanid));
  }
  return true;
}

bool
session_manager::delete_vlan(vlan_ptr vlan, std::string sid)
{
  autoLockDebug vlock(vlan_lock, "session_manager::delete_vlan(): vlan_lock");
  num_ports_on_vlan.erase(vlan->vlanid);
  if (vlan->is_deleted)
    {
      write_log("session_manager::delete_vlan() vlan " + int2str(vlan->vlanid) + " already deleted");
      return true;
    }
  vlan->is_deleted = true;
  vlock.unlock();

  if (!testing)
    {
      onld::delete_vlan* delvlan = new onld::delete_vlan(vlan->vlanid, sid);
      delvlan->set_connection(the_gige_conn);

      write_log("session_manager::delete_vlan() vlan " + int2str(vlan->vlanid));
      if(!delvlan->send_and_wait())
	{
	  vlock.lock();
	  vlan->is_deleted = false;
	  vlock.unlock();
	  delete delvlan;
	  return false;
	}

      switch_response *delresp = (switch_response*)delvlan->get_response();
      if(delresp->getStatus() != NCCP_Status_Fine)
	{
	  delete delresp;
	  delete delvlan;
	  return false;
	}

      delete delresp;
      delete delvlan;
    }
  return true;
}

bool
session_manager::add_port_to_outstanding_list(switch_port port)
{
  unsigned int num_attempts = 0;
  std::set<switch_port>::iterator pit;
  autoLockDebug plock(port_lock, "session_manager::add_port_to_outstanding_list(): port lock");
  pit = outstanding_ports.find(port);
  while(pit != outstanding_ports.end())
  {
    plock.unlock();

    num_attempts++;
    if(num_attempts == 100)
    {
      return false;
    }

    sleep(3);
    plock.lock();
    pit = outstanding_ports.find(port);
  }
  outstanding_ports.insert(port);
  plock.unlock();
  return true;
}

void
session_manager::remove_port_from_outstanding_list(switch_port port)
{
  autoLockDebug plock(port_lock, "session_manager::remove_port_from_outstanding_list(): port lock");
  outstanding_ports.erase(port);
  plock.unlock();
}

crd_component_ptr
session_manager::get_component(std::string name, unsigned int vmid)
{
  crd_component_ptr comp;

  if(name.substr(0,5) == "vgige")
  {
    crd_component_ptr tmp(new crd_virtual_switch(name));
    return tmp;
  }

  autoLockDebug dlock(db_lock, "session_manager::get_component(): db_lock");
  onl::node_info info;
  onl::onldb_resp r = database->get_node_info(name, false, info);
  if(r.result() < 0)
  {
    write_log("session_manager::get_component(): failed: " + r.msg());
    return comp;
  }
  dlock.unlock();

  std::string cp = "";
  unsigned short cp_port = 0;
  if(info.has_cp())
  {
    cp = info.cp();
    cp_port = info.cp_port();
  }

  if(info.do_keeboot())
  {
    autoLockDebug clock(comp_lock, "session_manager::get_component(): comp_lock");
    keeboot_params.erase(name);
    clock.unlock();
  }

  if (vmid == 0)
    {
      crd_component_ptr new_comp(new crd_component(info.node(), cp, cp_port, info.do_keeboot(), info.is_dependent()));
      new_comp->setCluster(info.cluster());
      return new_comp;
    }
  else
    {
      crd_component_ptr new_comp(new crd_virtual_machine(vmid, info.node(), cp, cp_port, info.do_keeboot(), info.is_dependent()));
      return new_comp;
    }
}

void
session_manager::add_component(crd_component_ptr comp, session_ptr sess)
{
  comp->set_session(sess);
  if(comp->get_type() == "vgige" || comp->get_type() == "vm")
  {
    return;
  }

  autoLockDebug clock(comp_lock, "session_manager::add_component(): comp_lock");
  std::list<crd_component_ptr>::iterator i;
  for(i=active_components.begin(); i!=active_components.end(); ++i)
  {
    //TODO VM there may be more than one active session with a valid active VM using
    //the same node
    //remove if user is same and session is different
    if((*i)->getName() == comp->getName())
    {
      clock.unlock();
      session_ptr old_sess = (*i)->get_session();
      old_sess->expired();
      old_sess->clear();
      clock.lock();
      break;
    }
  }

  active_components.push_back(comp);
}

void
session_manager::remove_component(crd_component_ptr comp)
{
  if(comp->get_type() == "vgige" || comp->get_type() == "vm")
  {
    return;
  }

  autoLockDebug clock(comp_lock, "session_manager::remove_component(): comp_lock");
  std::list<crd_component_ptr>::iterator i;
  for(i=active_components.begin(); i!=active_components.end();)
  {
    if((*i) == comp)
    {
      i = active_components.erase(i);
      refreshing_components.push_back(comp);
    }
    else
    {
      ++i;
    }
  }
}

void
session_manager::clear_component(crd_component* comp)
{
  if(comp->get_type() == "vgige" || comp->get_type() == "vm")
  {
    comp->clear_session();
    return;
  }

  write_log("session_manager::clear_component: comp(" + int2str((unsigned long) comp) + ") " + comp->getName());
  autoLockDebug clock(comp_lock, "session_manager::clear_component(): comp_lock");
  std::list<crd_component_ptr>::iterator i;
  for(i=refreshing_components.begin(); i!=refreshing_components.end(); ++i)
  {
    if((*i).get() == comp)
    {
      comp->clear_session();
      refreshing_components.erase(i);
      if (initializing && refreshing_components.empty())//JP added 11/13/12
	{
	  initializing = false;
	  write_log("session_manager::clear_component: all components processed. initializing phase of crd is over.");
	}
      return;
    }
  }

  // really should never get here..
  write_log("session_manager::clear_component: warning: calling clear on node " + comp->getName() + " which is not in the refreshing list");
  comp->clear_session();
}

session_ptr
session_manager::add_session(std::string username, nccp_connection* conn,begin_session_req* begin_req)
{
  autoLockDebug slock(session_lock, "session_manager::add_session(): session_lock");
  session_ptr sess(new session(next_session_id, username, conn));
  if (begin_req != NULL) sess->set_begin_request(begin_req);
  else write_log("session_manager::add_session user:" + username + " begin_req is NULL");
  next_session_id++;
  active_sessions.push_back(sess);
  return sess;
}

session_ptr
session_manager::get_session(nccp_connection* conn)
{
  autoLockDebug slock(session_lock, "session_manager::get_session(nccp_conn): session_lock");
  std::list<session_ptr>::iterator it;
  for(it = active_sessions.begin(); it != active_sessions.end(); ++it)
  {
    if(((*it)->getConnection() == conn) && !((*it)->is_cleared())) { return *it; }
  }
  return session_ptr();
}

session_ptr
session_manager::get_session(nccp_connection* conn, std::string sid)
{
  autoLockDebug slock(session_lock, "session_manager::get_session(nccp_conn): session_lock");
  std::list<session_ptr>::iterator it;
  for(it = active_sessions.begin(); it != active_sessions.end(); ++it)
  {
    if(((*it)->getConnection() == conn) && ((*it)->getID() == sid) && !((*it)->is_cleared())) { return *it; }
  }
  return session_ptr();
}

session_ptr
session_manager::get_session(std::string username)
{
  autoLockDebug slock(session_lock, "session_manager::get_session(string): session_lock");
  std::list<session_ptr>::iterator it;
  for(it = active_sessions.begin(); it != active_sessions.end(); ++it)
  {
    if(((*it)->getUser() == username) && !((*it)->is_cleared())) { return *it; }
  }
  return session_ptr();
}

void
session_manager::remove_session(session* sess)
{
  autoLockDebug slock(session_lock, "session_manager::remove_session(): session_lock");
  std::list<session_ptr>::iterator it;
  for(it = active_sessions.begin(); it != active_sessions.end(); ++it)
  {
    if((*it)->getID() == sess->getID())
    {
      write_log("session_manager::remove_session: removing session " + (*it)->getID() + " with ref count " + int2str((*it).use_count()));
      active_sessions.erase(it);
      break;
    }
  }
}

reservation*
session_manager::add_reservation(std::string username, nccp_connection* conn, begin_reservation_req* begin_req)
{
  autoLockDebug rlock(reservation_lock, "session_manager::add_reservation(): reservation_lock");
  reservation* res = new reservation(next_reservation_id, username, conn);
  if (begin_req != NULL) res->set_begin_request(begin_req);
  else write_log("session_manager::add_reservation user:" + username + " begin_req is NULL");
  next_reservation_id++;
  active_reservations.push_back(res);
  return res;
}

reservation*
session_manager::get_reservation(nccp_connection* conn)
{
  autoLockDebug rlock(reservation_lock, "session_manager::get_reservation(): reservation_lock");
  std::list<reservation *>::iterator it;
  for(it = active_reservations.begin(); it != active_reservations.end(); ++it)
  {
    if((*it)->getConnection() == conn) { return *it; }
  }
  return NULL;
}

reservation*
session_manager::get_reservation(nccp_connection* conn, std::string rid)
{
  autoLockDebug rlock(reservation_lock, "session_manager::get_reservation(): reservation_lock");
  std::list<reservation *>::iterator it;
  for(it = active_reservations.begin(); it != active_reservations.end(); ++it)
  {
    if((*it)->getConnection() == conn && (*it)->getID() == rid) { return *it; }
  }
  return NULL;
}

void
session_manager::remove_reservation(reservation* res)
{
  res->clear();

  autoLockDebug rlock(reservation_lock, "session_manager::remove_reservation(): reservation_lock");
  std::list<reservation *>::iterator it;
  for(it = active_reservations.begin(); it != active_reservations.end(); ++it)
  {
    if((*it)->getConnection() == res->getConnection())
    {
      active_reservations.erase(it);
      break;
    }
  }
  rlock.unlock();

  delete res;
}

void
session_manager::get_observable_sessions(std::string username, std::list<session_ptr>& list)
{
  autoLockDebug slock(session_lock, "session_manager::get_observable_sessions(): session_lock");
  std::list<session_ptr>::iterator it;
  for(it = active_sessions.begin(); it != active_sessions.end(); ++it)
  {
    if((*it)->observable_by(username)) { list.push_back(*it); }
  }
}


text:
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.1.0.min.js"></script>

{% if site.ios_app_id %}

<script>

$(function() {

    var apiURL = "https://itunes.apple.com/lookup?id={{ site.ios_app_id }}&country={{ site.ios_app_country }}&callback=?";

    $.getJSON(apiURL, function(json) {

        if (json.results && json.results.length) {

            console.info("Image strings loaded from Apple API.");
            var appInfo = json.results[0];

            // Set favicon
            $('link[rel="shortcut icon"]').attr("href", appInfo.artworkUrl512);

            // Set page title using the iOS app ID if it is not set manually in _config.yml
            var $pageTitle = $(".pageTitle");
            if ($.trim($($pageTitle).text()).length == 0) {
                $($pageTitle).html(appInfo.trackName);
            }

            // Set large app icon using the iOS app ID if it is not set manually in _config.yml
            var $appIconLarge = $(".appIconLarge");
            if (!$appIconLarge.attr('src')) {
                $($appIconLarge).attr("src", appInfo.artworkUrl512);
            }

            // Set header app icon using the iOS app ID if it is not set manually in _config.yml
            var $appIconHeader = $(".headerIcon");
            if (!$appIconHeader.attr('src')) {
                $($appIconHeader).attr("src", appInfo.artworkUrl512);
            }

            // Set app name using the iOS app ID if it is not set manually in _config.yml
            var $appName = $(".appName");
            if ($.trim($($appName).text()).length == 0) {
                $($appName).html(appInfo.trackName);
            }

            // Set the name displayed in the header if it is not set manually in _config.yml
            var $headerName = $(".headerName");
            if ($.trim($($headerName).text()).length == 0) {
                $($headerName).html(appInfo.trackName);
            }

            // Set price using the iOS app ID if it is not set manually in _config.yml
            var $appPrice = $(".appPrice");
            if ($.trim($($appPrice).text()).length == 0) {
                $($appPrice).html(appInfo.formattedPrice);
            }

            // Set App Store link using the iOS app ID if it is not set manually in _config.yml
            var $appStoreLink = $(".appStoreLink");
            if ($.trim($appStoreLink.attr('href')).length == 0) {
                $($appStoreLink).attr("href", appInfo.trackViewUrl);
            }

            console.info(appInfo);

        }
    });
});

</script>

{% endif %}


text:
<?php

namespace Psi\Test\Cases\Plugin\Command;

use Psi\Plugin\Command\Registry;
use Psi\Test\Fixtures\Command\ContainerAwareCommand;

/**
 * @covers \Psi\Plugin\Command\Registry
 */
class RegistryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Registry
     */
    private $registry;

    protected function setUp()
    {
        $this->registry = new Registry();
    }

    public function testIterator()
    {
        $command1 = new ContainerAwareCommand();
        $command2 = new ContainerAwareCommand();

        $this->registry->add($command1);
        $this->registry->add($command2);

        static::assertContains($command1, $this->registry);
        static::assertContains($command2, $this->registry);
    }

    public function testCountable()
    {
        static::assertCount(0, $this->registry);

        $this->registry->add(new ContainerAwareCommand());
        $this->registry->add(new ContainerAwareCommand());

        static::assertCount(2, $this->registry);
    }
}


text:
'use strict';

const Expr = require('./expr');
const Word = require('../lexer/word');

class Temp extends Expr {
  constructor(line, type) {
    super(line, Word.temp, type);
    this.number = ++Temp.count;
  }

  toString() {
    return 't' + this.number;
  }
}

Temp.count = 0;

module.exports = Temp;


text:
require 'dfp_api'
require 'dfp_api_statement'

API_VERSION = :v201505

def get_user_team_associations_by_statement()
  # Get DfpApi instance and load configuration from ~/dfp_api.yml.
  dfp = DfpApi::Api.new

  # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
  # the configuration file or provide your own logger:
  # dfp.logger = Logger.new('dfp_xml.log')

  # Get the UserTeamAssociationService.
  uta_service = dfp.service(:UserTeamAssociationService, API_VERSION)

  # Get the UserService.
  user_service = dfp.service(:UserService, API_VERSION)

  # Get the current user.
  user = user_service.get_current_user()

  # Create filter text to select user team associations by the user ID.
  statement = DfpApiStatement::FilterStatement.new(
      'WHERE userId = :user_id ORDER BY id',
      [
          {:key => 'user_id',
           :value => {:value => user[:id], :xsi_type => 'NumberValue'}},
      ]
  )

  begin
    # Get user team associations by statement.
    page = uta_service.get_user_team_associations_by_statement(
        statement.toStatement())

    if page and page[:results]
      page[:results].each_with_index do |association, index|
        puts "%d) Team user association between team ID %d and user ID %d." %
            [index + statement.offset, association[:team_id],
             association[:user_id]]
      end
    end
    statement.offset += DfpApiStatement::SUGGESTED_PAGE_LIMIT
  end while statement.offset < page[:total_result_set_size]

  # Print a footer.
  if page.include?(:total_result_set_size)
    puts "Number of results found: %d" % page[:total_result_set_size]
  end
end

if __FILE__ == $0
  begin
    get_user_team_associations_by_statement()

  # HTTP errors.
  rescue AdsCommon::Errors::HttpError => e
    puts "HTTP Error: %s" % e

  # API errors.
  rescue DfpApi::Errors::ApiException => e
    puts "Message: %s" % e.message
    puts 'Errors:'
    e.errors.each_with_index do |error, index|
      puts "\tError [%d]:" % (index + 1)
      error.each do |field, value|
        puts "\t\t%s: %s" % [field, value]
      end
    end
  end
end


text:
package com.jdroid.android.googleplay.publisher.task;

import com.jdroid.android.googleplay.publisher.App;
import com.jdroid.android.googleplay.publisher.GooglePlayPublisher;

public class PromoteFromAlphaToBetaTask extends BaseTask {

	public PromoteFromAlphaToBetaTask() {
		setDescription("Promote a current alpha to beta");
	}

	@Override
	protected void onExecute(App app) {
		GooglePlayPublisher.promoteFromAlphaToBeta(app);
	}

}


text:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>mask= (Imlib2::Context)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre>/*
 * Set the current X11 Mask.
 *
 * Note: This method is not available unless Imlib2-Ruby was compiled
 * with X11 support.  You can check the constant Imlib2::X11_SUPPORT to
 * see if X11 support is available.
 *
 * Examples:
 *   context.set_mask mask
 *   context.mask = mask
 *
 */
static VALUE ctx_set_mask(VALUE self, VALUE mask_o) {
</pre>
</body>
</html>


text:
package com.phloc.commons.lang;

import static org.junit.Assert.assertNotNull;

import java.text.DecimalFormatSymbols;
import java.util.Locale;

import org.junit.Test;

/**
 * Test class for class {@link DecimalFormatSymbolsFactory}.
 *
 * @author Philip Helger
 */
public final class DecimalFormatSymbolsFactoryTest
{
  @Test
  public void testAll ()
  {
    final DecimalFormatSymbols aDFS = DecimalFormatSymbolsFactory.getInstance (Locale.GERMAN);
    assertNotNull (aDFS);
  }
}


text:
package com.appleframework.web.register;

import java.util.Map;

/**
 * @author tanghc
 */
public class ValidationAnnotationDefinition {
    private Class<?> annotationClass;
    private Map<String, Object> properties;

    public Class<?> getAnnotationClass() {
        return annotationClass;
    }

    public void setAnnotationClass(Class<?> annotationClass) {
        this.annotationClass = annotationClass;
    }

    public Map<String, Object> getProperties() {
        return properties;
    }

    public void setProperties(Map<String, Object> properties) {
        this.properties = properties;
    }
}


text:
<?php declare(strict_types=1);

namespace PAF\Common\Security;

use Nette\Security\IIdentity;
use PAF\Modules\CommonModule\Model\User;

class LiveUserIdentity implements IIdentity
{

    /** @var mixed */
    private $id;

    /** @var string[] */
    private $roles;
    /** @var User */
    private $user;

    public function __construct($id)
    {
        $this->id = $id;
    }

    /** @inheritDoc */
    public function getId()
    {
        return $this->id;
    }

    /** @inheritDoc */
    public function getRoles(): array
    {
        return $this->isInitialized() ? $this->roles : [];
    }

    public function isInitialized(): bool
    {
        return !is_null($this->user);
    }

    public function initialize(User $user, array $roles = [])
    {
        $user->detach();

        $this->user = $user;
        $this->roles = $roles;
    }

    public function getData(string $key = null)
    {
        if (!$key) {
            return $this->user->getRowData();
        }

        return $this->user->$key;
    }

    public function getEntity(): User
    {
        return $this->user;
    }

    public function __sleep()
    {
        return ['id'];
    }
}


text:
import React, { Children, useState, useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

const Collapsible = ({
  children,
  className,
  accordion,
  options,
  defaultActiveKey,
  popout,
  onSelect,
  ...props
}) => {
  const _collapsible = useRef(null);
  const collapsible = accordion ? 'accordion' : 'expandable';
  const [activeKey, setActiveKey] = useState(defaultActiveKey);

  const renderItem = (child, key) => {
    if (!child) return null;

    // Extend with props if child is a react component
    if (typeof child.type === 'function') {
      Object.assign(props, {
        expanded: activeKey === key || child.props.expanded,
        eventKey: key
      });
    }

    return React.cloneElement(child, {
      onSelect: () => handleSelect(key)
    });
  };

  const handleSelect = key => {
    if (onSelect) {
      onSelect(key);
    }

    if (activeKey === key) {
      setActiveKey(null);
    }

    if (accordion) {
      setActiveKey(key);
    }
  };

  useEffect(() => {
    if (typeof M !== 'undefined') {
      const instance = M.Collapsible.init(_collapsible.current, {
        accordion: accordion,
        ...options
      });

      return () => {
        instance && instance.destroy();
      };
    }
  }, [_collapsible, accordion, options, children]);

  return (
    <ul
      ref={_collapsible}
      className={cx(className, {
        collapsible,
        expandable: accordion !== true,
        popout
      })}
      data-collapsible={collapsible}
      {...props}
    >
      {Children.map(children, renderItem)}
    </ul>
  );
};

Collapsible.propTypes = {
  /**
   * There are two ways a collapsible can behave. It can either allow multiple sections to stay open,
   * or it can only allow one section to stay open at a time, which is called an accordion.
   * @default true
   */
  accordion: PropTypes.bool,
  className: PropTypes.string,
  children: PropTypes.node,
  /**
   * Enable popout style
   */
  popout: PropTypes.bool,
  /**
   * The default CollapsibleItem that should be expanded. This value should match the specified
   * item's eventKey value. Ignored if accordion is false.
   */
  defaultActiveKey: PropTypes.any,
  onSelect: PropTypes.func,
  /**
   * Options passed to initializer
   */
  options: PropTypes.any
};

Collapsible.defaultProps = {
  accordion: true
};

export default Collapsible;


text:
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_POLICY_FEERATE_H
#define BITCOIN_POLICY_FEERATE_H

#include <amount.h>
#include <serialize.h>

#include <string>

extern const std::string CURRENCY_UNIT;

/**
 * Fee rate in satoshis per kilobyte: CAmount / kB
 */
class CFeeRate
{
private:
    CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes

public:
    /** Fee rate of 0 satoshis per kB */
    CFeeRate() : nSatoshisPerK(0) { }
    template<typename I>
    CFeeRate(const I _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) {
        // We've previously had bugs creep in from silent double->int conversion...
        static_assert(std::is_integral<I>::value, "CFeeRate should be used without floats");
    }
    /** Constructor for a fee rate in satoshis per kB. The size in bytes must not exceed (2^63 - 1)*/
    CFeeRate(const CAmount& nFeePaid, size_t nBytes);
    /**
     * Return the fee in satoshis for the given size in bytes.
     */
    CAmount GetFee(size_t nBytes) const;
    /**
     * Return the fee in satoshis for a size of 1000 bytes
     */
    CAmount GetFeePerK() const { return GetFee(1000); }
    friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
    friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
    friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
    friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; }
    friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
    friend bool operator!=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK != b.nSatoshisPerK; }
    CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
    std::string ToString() const;

    ADD_SERIALIZE_METHODS;

    template <typename Stream, typename Operation>
    inline void SerializationOp(Stream& s, Operation ser_action) {
        READWRITE(nSatoshisPerK);
    }
};

#endif //  BITCOIN_POLICY_FEERATE_H


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>AIPlayerTest</title>
<meta name="date" content="2017-05-04">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

io.github.teamfractal.entity

Class AIPlayerTest

java.lang.Object

io.github.teamfractal.TesterFile

io.github.teamfractal.entity.AIPlayerTest

public class AIPlayerTest
extends TesterFile

Tests for the AI can be found here and in the Manual Testing part of the Test3 document
 https://github.com/NotKieran/DRTN-Fractal/blob/Assessment3_Docs/Test3.pdf

Field Summary

Fields

Modifier and Type
Field and Description

org.junit.rules.ExpectedException
exception

private RoboticonQuest
game

private Player
player

Constructor Summary

Constructors

Constructor and Description

AIPlayerTest()

Method Summary

All Methods Instance Methods Concrete Methods

Modifier and Type
Method and Description

void
setUp()

void
testAIPlayerBuyResource()

Test to purchase and sell resource from the market.

void
testAIPlayerCanCustomiseOwnedRoboticons()

void
testAIPlayerCanCustomiseRoboticon()

void
testAIPlayerCannotBuyMoreThanAllowed()

void
testAIPlayerCannotSellMoreEnergyThanAllowed()

void
testAIPlayerCannotSellMoreFoodThanAllowed()

void
testAIPlayerCannotSellMoreOreThanAllowed()

void
testAIPlayerSellResource()

void
testPlayerInitialMoney()

This part of the Test Class is a duplicate of PlayerTest but calling an AI player instead, this checks that the AI inherits correctly

Methods inherited from class io.github.teamfractal.TesterFile

cleanUp, init

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

exception

public final org.junit.rules.ExpectedException exception

player

private Player player

game

private RoboticonQuest game

Constructor Detail

AIPlayerTest

public AIPlayerTest()

Method Detail

setUp

public void setUp()

testPlayerInitialMoney

public void testPlayerInitialMoney()

This part of the Test Class is a duplicate of PlayerTest but calling an AI player instead, this checks that the AI inherits correctly

testAIPlayerBuyResource

public void testAIPlayerBuyResource()

Test to purchase and sell resource from the market.

testAIPlayerSellResource

public void testAIPlayerSellResource()
                              throws java.lang.Exception

Throws:

java.lang.Exception

testAIPlayerCannotBuyMoreThanAllowed

public void testAIPlayerCannotBuyMoreThanAllowed()
                                          throws java.lang.Exception

Throws:

java.lang.Exception

testAIPlayerCannotSellMoreEnergyThanAllowed

public void testAIPlayerCannotSellMoreEnergyThanAllowed()

testAIPlayerCannotSellMoreOreThanAllowed

public void testAIPlayerCannotSellMoreOreThanAllowed()

testAIPlayerCannotSellMoreFoodThanAllowed

public void testAIPlayerCannotSellMoreFoodThanAllowed()

testAIPlayerCanCustomiseRoboticon

public void testAIPlayerCanCustomiseRoboticon()

testAIPlayerCanCustomiseOwnedRoboticons

public void testAIPlayerCanCustomiseOwnedRoboticons()

Skip navigation links

Overview

Package

Class

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method