text:
      module syncio
      use :: iso_c_binding
      interface
        subroutine syncio_setup_read(nfiles, handle)
     &   bind(C, NAME='syncio_setup_read')
        use :: iso_c_binding
          integer(c_int), value :: nfiles
          type(c_ptr) :: handle
        end subroutine
        subroutine syncio_setup_write(nfiles, nfields, nppf, handle)
     &   bind(C, NAME='syncio_setup_write')
        use :: iso_c_binding
          integer(c_int), value :: nfiles
          integer(c_int), value :: nfields
          integer(c_int), value :: nppf
          type(c_ptr) :: handle
        end subroutine
      end interface
      end module


text:
package com.amazonaws.services.personalize.model.transform;

import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.services.personalize.model.*;

import com.amazonaws.protocol.*;
import com.amazonaws.annotation.SdkInternalApi;

/**
 * SolutionSummaryMarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class SolutionSummaryMarshaller {

    private static final MarshallingInfo<String> NAME_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("name").build();
    private static final MarshallingInfo<String> SOLUTIONARN_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("solutionArn").build();
    private static final MarshallingInfo<String> STATUS_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("status").build();
    private static final MarshallingInfo<java.util.Date> CREATIONDATETIME_BINDING = MarshallingInfo.builder(MarshallingType.DATE)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("creationDateTime").timestampFormat("unixTimestamp").build();
    private static final MarshallingInfo<java.util.Date> LASTUPDATEDDATETIME_BINDING = MarshallingInfo.builder(MarshallingType.DATE)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("lastUpdatedDateTime").timestampFormat("unixTimestamp").build();

    private static final SolutionSummaryMarshaller instance = new SolutionSummaryMarshaller();

    public static SolutionSummaryMarshaller getInstance() {
        return instance;
    }

    /**
     * Marshall the given parameter object.
     */
    public void marshall(SolutionSummary solutionSummary, ProtocolMarshaller protocolMarshaller) {

        if (solutionSummary == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        try {
            protocolMarshaller.marshall(solutionSummary.getName(), NAME_BINDING);
            protocolMarshaller.marshall(solutionSummary.getSolutionArn(), SOLUTIONARN_BINDING);
            protocolMarshaller.marshall(solutionSummary.getStatus(), STATUS_BINDING);
            protocolMarshaller.marshall(solutionSummary.getCreationDateTime(), CREATIONDATETIME_BINDING);
            protocolMarshaller.marshall(solutionSummary.getLastUpdatedDateTime(), LASTUPDATEDDATETIME_BINDING);
        } catch (Exception e) {
            throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
        }
    }

}

redpajama_set_name: RedPajamaGithub


text:
author: "Robert Pearce"
authorTwitter: "@RobertWPearce"
date: "2018-11-08"
desc: "Things to do and see in New Zealand"
image: "/images/lake-wanaka.jpg"
keywords: "new zealand, otago, things to do, places to see"
photoCredit: "emilycouldmakethat"
photoWebsite: "https://www.instagram.com/emilycouldmakethat"
title: "New Zealand Information Index"
updated: "2020-01-04T00:00:00Z"
---

Things to do and see in New Zealand.

## South Island
* [Otago](/new-zealand/otago/index.html)
  * [Wanaka, Albert Town, Hawea, Glendhu Bay, Cardrona, Cromwell](/new-zealand/otago/wanaka-area.html)
  * [Queenstown, Arrow Town, Glenorchy](/new-zealand/otago/queenstown-area.html)
  * [Dunedin, Oamaru, The Catlins](/new-zealand/otago/dunedin-area.html)
* [South Island Central to West Coast](/new-zealand/south-island-central-to-west-coast.html)

## North Island
* [Auckland](/new-zealand/auckland/index.html)
* [Hawkes Bay](/new-zealand/hawkes-bay.html)
* [Bay Of Plenty](/new-zealand/bay-of-plenty.html)
* [Taupō](/new-zealand/taupo.html)


text:
Class to record and reset relative time. 用于记录精准相对时间的部件

## constructor (clocksource:Function = Date.now)
Construct an instance of `TimeKeeper` using `clocksource` to provide absolute
time (defaults to the current UNIX timestamp in ms).

创建 `TimeKeeper`实例,其中`clocksource` 由于提供绝对时间。默认采用 UNIX 时间戳
(毫秒精度)。

## Properties 属性
###

## Methods 方法


text:
package com.thoughtworks.go.server.service.materials;

import com.thoughtworks.go.config.UpdateConfigCommand;
import com.thoughtworks.go.config.update.CreatePackageRepositoryCommand;
import com.thoughtworks.go.domain.NullPlugin;
import com.thoughtworks.go.domain.Plugin;
import com.thoughtworks.go.domain.config.*;
import com.thoughtworks.go.domain.packagerepository.PackageRepositories;
import com.thoughtworks.go.domain.packagerepository.PackageRepository;
import com.thoughtworks.go.i18n.LocalizedMessage;
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest;
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse;
import com.thoughtworks.go.plugin.infra.PluginManager;
import com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptor;
import com.thoughtworks.go.presentation.TriStateSelection;
import com.thoughtworks.go.server.dao.PluginSqlMapDao;
import com.thoughtworks.go.server.domain.Username;
import com.thoughtworks.go.server.service.EntityHashingService;
import com.thoughtworks.go.server.service.GoConfigService;
import com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult;
import com.thoughtworks.go.serverhealth.HealthStateType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Arrays;

import static java.util.Arrays.asList;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
        "classpath:WEB-INF/applicationContext-global.xml",
        "classpath:WEB-INF/applicationContext-dataLocalAccess.xml",
        "classpath:WEB-INF/applicationContext-acegi-security.xml"
})

public class PackageRepositoryServiceIntegrationTest {
    @Autowired
    private GoConfigService goConfigService;
    @Autowired
    private PackageRepositoryService service;
    @Autowired
    private PluginSqlMapDao pluginSqlMapDao;
    @Autowired
    private EntityHashingService entityHashingService;

    @Mock
    private PluginManager pluginManager;

    private Username username;

    @Before
    public void setUp() throws Exception {
        initMocks(this);
        service.setPluginManager(pluginManager);
        username = new Username("CurrentUser");
        UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(username.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
        goConfigService.updateConfig(command);
    }

    @After
    public void tearDown() throws Exception {
        pluginSqlMapDao.deleteAllPlugins();
        goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories());
    }

    @Test
    public void shouldDeleteTheSpecifiedPackageRepository() throws Exception {
        HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
        String repoId = "npm";
        PackageRepository npmRepo = new PackageRepository();
        npmRepo.setId(repoId);
        goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories(npmRepo));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));

        service.deleteRepository(username, npmRepo, result);

        HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
        expectedResult.setMessage(LocalizedMessage.string("RESOURCE_DELETE_SUCCESSFUL", "package repository", npmRepo.getId()));

        assertThat(result, is(expectedResult));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(0));
        assertNull(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId));
    }

    @Test
    public void shouldReturnTheExactLocalizeMessageIfItFailsToDeletePackageRepository() throws Exception {
        HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
        String repoId = "npm";
        PackageRepository npmRepo = new PackageRepository();
        npmRepo.setId(repoId);
        goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories(npmRepo));
        HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
        expectedResult.unauthorized(LocalizedMessage.string("UNAUTHORIZED_TO_EDIT"), HealthStateType.unauthorised());

        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));

        service.deleteRepository(new Username("UnauthorizedUser"), npmRepo, result);

        assertThat(result, is(expectedResult));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));
    }

    @Test
    public void shouldReturnTheExactLocalizeMessageIfItFailsToCreatePackageRepository() throws Exception {
        HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
        String repoId = "npm";
        PackageRepository npmRepo = new PackageRepository();
        npmRepo.setId(repoId);
        goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories(npmRepo));
        HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
        expectedResult.unauthorized(LocalizedMessage.string("UNAUTHORIZED_TO_EDIT"), HealthStateType.unauthorised());

        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));

        service.createPackageRepository(npmRepo, new Username("UnauthorizedUser"), result);

        assertThat(result, is(expectedResult));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(repoId), is(npmRepo));
    }

    @Test
    public void shouldReturnTheExactLocalizeMessageIfItFailsToUpdatePackageRepository() throws Exception {
        HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
        expectedResult.unauthorized(LocalizedMessage.string("UNAUTHORIZED_TO_EDIT"), HealthStateType.unauthorised());

        HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
        String oldRepoId = "npmOrg";
        String newRepoId = "npm.org";
        PackageRepository oldPackageRepo = new PackageRepository();
        PackageRepository newPackageRepo = new PackageRepository();

        PluginConfiguration pluginConfiguration = new PluginConfiguration();
        pluginConfiguration.setId("npm");
        oldPackageRepo.setPluginConfiguration(pluginConfiguration);
        oldPackageRepo.setId(oldRepoId);
        oldPackageRepo.setName(oldRepoId);
        newPackageRepo.setPluginConfiguration(pluginConfiguration);
        newPackageRepo.setId(newRepoId);
        newPackageRepo.setName(newRepoId);
        Configuration configuration = new Configuration();
        configuration.add(new ConfigurationProperty(new ConfigurationKey("foo"), new ConfigurationValue("bar")));
        oldPackageRepo.setConfiguration(configuration);
        newPackageRepo.setConfiguration(configuration);
        when(pluginManager.getPluginDescriptorFor("npm")).thenReturn(new GoPluginDescriptor("npm", "1", null, null, null, false));
        goConfigService.getConfigForEditing().setPackageRepositories(new PackageRepositories(oldPackageRepo));

        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(oldRepoId), is(oldPackageRepo));
        assertNull(goConfigService.getConfigForEditing().getPackageRepositories().find(newRepoId));
        service.updatePackageRepository(newPackageRepo, new Username("UnauthorizedUser"), "md5", result, oldRepoId);
        assertThat(result, is(expectedResult));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().size(), is(1));
        assertThat(goConfigService.getConfigForEditing().getPackageRepositories().find(oldRepoId), is(oldPackageRepo));
        assertNull(goConfigService.getConfigForEditing().getPackageRepositories().find(newRepoId));
    }
}


text:
import ProtectedRoute from '../protected';

export default ProtectedRoute.extend({
  model: function () {
    return this.store.findAll('following');
  }
});


text:
<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'yii\\swiftmailer\\' => array($vendorDir . '/yiisoft/yii2-swiftmailer'),
    'yii\\jui\\' => array($vendorDir . '/yiisoft/yii2-jui'),
    'yii\\gii\\' => array($vendorDir . '/yiisoft/yii2-gii'),
    'yii\\faker\\' => array($vendorDir . '/yiisoft/yii2-faker'),
    'yii\\debug\\' => array($vendorDir . '/yiisoft/yii2-debug'),
    'yii\\composer\\' => array($vendorDir . '/yiisoft/yii2-composer'),
    'yii\\codeception\\' => array($vendorDir . '/yiisoft/yii2-codeception'),
    'yii\\bootstrap\\' => array($vendorDir . '/yiisoft/yii2-bootstrap'),
    'yii\\authclient\\' => array($vendorDir . '/yiisoft/yii2-authclient'),
    'yii\\' => array($vendorDir . '/yiisoft/yii2'),
    'xj\\qrcode\\' => array($vendorDir . '/xj/yii2-qrcode-widget'),
    'xj\\oauth\\' => array($vendorDir . '/xj/yii2-oauth'),
    'trntv\\glide\\' => array($vendorDir . '/trntv/yii2-glide/src'),
    'trntv\\filekit\\' => array($vendorDir . '/trntv/yii2-file-kit/src'),
    'mdm\\admin\\' => array($vendorDir . '/mdmsoft/yii2-admin'),
    'hightman\\xunsearch\\' => array($vendorDir . '/hightman/xunsearch/wrapper/yii2-ext'),
    'dosamigos\\typeahead\\' => array($vendorDir . '/2amigos/yii2-type-ahead-widget/src'),
    'dosamigos\\gallery\\' => array($vendorDir . '/2amigos/yii2-gallery-widget/src'),
    'dosamigos\\fileupload\\' => array($vendorDir . '/2amigos/yii2-file-upload-widget/src'),
    'creocoder\\nestedsets\\' => array($vendorDir . '/creocoder/yii2-nested-sets/src'),
    'cebe\\markdown\\' => array($vendorDir . '/cebe/markdown'),
    'TrueBV\\' => array($vendorDir . '/true/punycode/src'),
    'Symfony\\Polyfill\\Php55\\' => array($vendorDir . '/symfony/polyfill-php55'),
    'Symfony\\Polyfill\\Php54\\' => array($vendorDir . '/symfony/polyfill-php54'),
    'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
    'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'),
    'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
    'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
    'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
    'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
    'League\\Url\\' => array($vendorDir . '/league/url/src'),
    'League\\Glide\\' => array($vendorDir . '/league/glide/src'),
    'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'),
    'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'),
    'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
    'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'),
);


text:
require 'spec_helper'

describe MarcToArgot::Macros::Shared::StatementOfResponsibility do
  include Util
  let(:statement_of_responsibility) { run_traject_json('duke', 'statement_of_responsibility', 'mrc') }
  let(:statement_of_responsibility_vern1) { run_traject_json('unc', 'statement_of_responsibility_vern1', 'mrc') }

  it '(MTA) sets statement_of_responsibility' do
    result = statement_of_responsibility['statement_of_responsibility']
    expect(result).to eq(
                        [{"value"=>"pod redakt︠s︡īeĭ Grafini Uvarovoĭ."},
                         {"value"=>"под редакціей Графини Уваровой.", "lang"=>"rus"}]
                      )
  end

  it '(MTA) sets vernacular statement_of_responsibility from 245' do
    result = statement_of_responsibility_vern1['statement_of_responsibility']
    expect(result).to eq(
                        [{"value"=>"杨丹.", "lang"=>"cjk"}]
                      )
  end

end


text:
from toee import *
import char_class_utils
import char_editor
###################################################

def GetConditionName():
	return "Assassin"

# def GetSpellCasterConditionName():
# 	return "Assassin Spellcasting"

def GetCategory():
	return "Core 3.5 Ed Prestige Classes"

def GetClassDefinitionFlags():
	return CDF_CoreClass

def GetClassHelpTopic():
	return "TAG_ASSASSINS"

classEnum = stat_level_assassin

###################################################

class_feats = {

1: (feat_armor_proficiency_light, feat_simple_weapon_proficiency_rogue, feat_sneak_attack, "Death Attack"),
2: (feat_uncanny_dodge, "Save Bonus against Poison"),
5: (feat_improved_uncanny_dodge,),
8: ("Hide in Plain Sight",),
}

class_skills = (skill_alchemy, skill_balance, skill_bluff, skill_climb, skill_craft, skill_decipher_script, skill_diplomacy, skill_disable_device, skill_disguise, skill_escape_artist, skill_forgery, skill_gather_information, skill_hide, skill_intimidate, skill_jump, skill_listen, skill_move_silently, skill_open_lock, skill_search, skill_sense_motive, skill_pick_pocket, skill_spot, skill_swim, skill_tumble, skill_use_magic_device, skill_use_rope)

# note:
# added grease to level 1 spells in place of the spells that are not implemented in ToEE
# added Blindness/Deafness and Ghoul Touch to level 2
# added slow and vampiric touch to level 3
spell_list = {
	1: (spell_critical_strike, spell_disguise_self, spell_detect_poison, spell_distract_assailant, spell_feather_fall, spell_ghost_sound, spell_grease, spell_insightfull_feint, spell_jump, spell_lightfoot, spell_obscuring_mist, spell_shock_and_awe, spell_sleep, spell_snipers_shot, spell_sticky_fingers, spell_true_strike),
	2: (spell_alter_self, spell_blindness_deafness, spell_cats_grace, spell_fell_the_greatest_foe, spell_fire_shuriken, spell_foxs_cunning, spell_ghoul_touch, spell_illusory_script, spell_invisibility, spell_invisibility_swift, spell_pass_without_trace, spell_phantom_foe, spell_spider_climb, spell_veil_of_shadow, spell_undetectable_alignment),
	3: (spell_deep_slumber, spell_deeper_darkness, spell_false_life, spell_find_the_gap, spell_magic_circle_against_good, spell_slow, spell_vampiric_touch, spell_misdirection, spell_nondetection, spell_wraithstrike),
	4: (spell_clairaudience_clairvoyance, spell_dimension_door, spell_freedom_of_movement, spell_glibness, spell_heart_ripper, spell_improved_invisibility, spell_locate_creature, spell_modify_memory, spell_poison)
}

spells_per_day = {
1:  (-1,0),
2:  (-1,1),
3:  (-1,2, 0),
4:  (-1,3, 1),
5:  (-1,3, 2, 0),
6:  (-1,3, 3, 1),
7:  (-1,3, 3, 2, 0),
8:  (-1,3, 3, 3, 1),
9:  (-1,3, 3, 3, 2),
10: (-1,3, 3, 3, 3)
}

spells_known = {
1:  (0,2),
2:  (0,3),
3:  (0,3, 2),
4:  (0,4, 3),
5:  (0,4, 3, 2),
6:  (0,4, 4, 3),
7:  (0,4, 4, 3, 2),
8:  (0,4, 4, 4, 3),
9:  (0,4, 4, 4, 3),
10: (0,4, 4, 4, 4)
}

def IsEnabled():
	return 1

def GetHitDieType():
	return 6

def GetSkillPtsPerLevel():
	return 4

def GetBabProgression():
	return base_attack_bonus_type_semi_martial

def IsFortSaveFavored():
	return 0

def IsRefSaveFavored():
	return 1

def IsWillSaveFavored():
	return 0

# Spell casting
def GetSpellListType():
	return spell_list_type_special

def GetSpellSourceType():
	return spell_source_type_arcane

def GetSpellReadyingType():
	return spell_readying_innate

def HasArmoredArcaneCasterFeature():
	return 1

def GetSpellList():
	return spell_list

def GetSpellsPerDay():
	return spells_per_day

caster_levels = range(1, 11)
def GetCasterLevels():
	return caster_levels

def GetSpellDeterminingStat():
	return stat_intelligence

def IsClassSkill(skillEnum):
	return char_class_utils.IsClassSkill(class_skills, skillEnum)

def IsClassFeat(featEnum):
	return char_class_utils.IsClassFeat(class_feats, featEnum)

def GetClassFeats():
	return class_feats

def IsAlignmentCompatible( alignment):
	if not (alignment & ALIGNMENT_EVIL):
		return 0
	return 1

def ObjMeetsPrereqs( obj ):
	#return 0 # WIP
	# skill ranks (only Disable Device since Escape Artist, Decipher Script and Knowledge Arcana aren't implemented in ToEE)
	if obj.skill_ranks_get(skill_hide) < 8:
		return 0
	if obj.skill_ranks_get(skill_move_silently) < 8:
		return 0
	#if not obj.d20_query('Killed to join Assassins'):
	#	return 0
	return 1

# Levelup callbacks
def IsSelectingSpellsOnLevelup(obj):
	return 1

def InitSpellSelection(obj, classLvlNew = -1, classLvlIncrement = 1):
	classLvl = obj.stat_level_get(classEnum)
	classLvlNew = classLvl + 1
	maxSpellLvl = char_editor.get_max_spell_level(obj, classEnum,
	                                              classLvlNew)  # this regards spell list extension by stuff like Mystic Theurge (no need to use spellListLvl as below)

	# Available Spells
	spAvail = char_editor.get_learnable_spells(obj, classEnum, maxSpellLvl)
	# add spell level labels
	for p in range(0, maxSpellLvl + 1):
		spAvail.append(char_editor.KnownSpellInfo(spell_label_level_0 + p, 0, classEnum))
	spAvail.sort()
	char_editor.append_available_spells(spAvail)

	# Spell Slots

	spellListLvl = obj.stat_level_get(stat_spell_list_level,
	                                  classEnum) + 1  # the effective level for getting the number of spells known
	spEnums = char_editor.get_known_class_spells(obj, classEnum)  # get all spells known for this class

	for spellLvl in range(1, maxSpellLvl + 1):
		spEnums.append(char_editor.KnownSpellInfo(spell_label_level_0 + spellLvl, 0, classEnum))  # add label
		# add spell slots
		newSpellsKnownCount = char_class_utils.GetSpellsKnownAddedCount(spells_known, spellListLvl, spellLvl)
		for q in range(0, newSpellsKnownCount):
			spEnums.append(char_editor.KnownSpellInfo(spell_new_slot_lvl_0 + spellLvl, 3, classEnum))

	isReplacing = 0
	if spellListLvl >= 6 and ((spellListLvl - 6) % 2) == 0:  # spell replacement
		isReplacing = 1
	if char_editor.get_class_code() != classEnum:  # grant this benefit only for strict levelup (also to prevent some headache...)
		isReplacing = 0

	if isReplacing == 0:
		spEnums.sort()
		char_editor.append_spell_enums(spEnums)
		return 0

	# mark as replaceable
	for p in range(0, len(spEnums)):
		spEnum = spEnums[p].spell_enum
		if spell_vacant <= spEnum <= spell_label_level_9:
			continue
		if spell_new_slot_lvl_0 <= spEnum <= spell_new_slot_lvl_9:
			continue
		if char_editor.get_spell_level(spEnum, classEnum) <= maxSpellLvl - 2:
			spEnums[p].spell_status = 1

	spEnums.sort()
	char_editor.append_spell_enums(spEnums)
	return 0

def LevelupCheckSpells(obj):
	spell_enums = char_editor.get_spell_enums()
	for spInfo in spell_enums:
		if spInfo.spell_enum == spell_vacant:
			return 0
	return 1

def LevelupSpellsFinalize(obj, classLvlNew = -1 ):
	spEnums = char_editor.get_spell_enums()
	char_editor.spell_known_add(spEnums)  # internally takes care of duplicates and the labels/vacant slots
	return


text:
require 'spec_helper'
require 'zencoder'
require 'json'

describe ActiveEncode::EngineAdapters::ZencoderAdapter do
  before(:all) do
    ActiveEncode::Base.engine_adapter = :zencoder
  end
  after(:all) do
    ActiveEncode::Base.engine_adapter = :test
  end

  let(:create_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_create.json'))) }

  before do
    allow(Zencoder::Job).to receive(:create).and_return(create_response)
  end

  let(:file) { "file://#{File.absolute_path('spec/fixtures/Bars_512kb.mp4')}" }

  describe "#create" do
    subject { ActiveEncode::Base.create(file) }
    before do
      allow(Zencoder::Job).to receive(:details).and_return(details_response)
      allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
    end

    let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_create.json'))) }
    let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_create.json'))) }
    let(:create_output) { [{ id: "511404522", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150610/c09b61e4d130ddf923f0653418a80b9c/399ae101c3f99b4f318635e78a4e587a.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=GY/9LMkQAiDOrMQwS5BkmOE200s%3D&Expires=1434033527", label: nil }] }

    it { is_expected.to be_a ActiveEncode::Base }
    it { expect(subject.id).not_to be_empty }
    it { is_expected.to be_running }
    # it { expect(subject.output).to eq create_output }
    it { expect(subject.current_operations).to be_empty }
    it { expect(subject.percent_complete).to eq 0 }
    it { expect(subject.errors).to be_empty }
    it { expect(subject.created_at).to eq '2015-06-10T14:38:47Z' }
    it { expect(subject.updated_at).to eq '2015-06-10T14:38:47Z' }

    context 'input' do
      subject { ActiveEncode::Base.create(file).input }

      it { is_expected.to be_a ActiveEncode::Input }
      it { expect(subject.id).to eq "166179248" }
      it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
      it { expect(subject.width).to be_blank }
      it { expect(subject.height).to be_blank }
      it { expect(subject.frame_rate).to be_blank }
      it { expect(subject.duration).to be_blank }
      it { expect(subject.file_size).to be_blank }
      it { expect(subject.checksum).to be_blank }
      it { expect(subject.audio_codec).to be_blank }
      it { expect(subject.video_codec).to be_blank }
      it { expect(subject.audio_bitrate).to be_blank }
      it { expect(subject.video_bitrate).to be_blank }
      it { expect(subject.state).to eq :running }
      it { expect(subject.created_at).to eq "2015-06-10T14:38:47Z" }
      it { expect(subject.updated_at).to eq "2015-06-10T14:38:00Z" }
    end

    context 'output' do
      subject { output.first }
      let(:output) { ActiveEncode::Base.find('166019107').reload.output }

      it 'is an array' do
        expect(output).to be_a Array
      end
      it { is_expected.to be_a ActiveEncode::Output }
      it { expect(subject.id).to eq "511404522" }
      it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150610/c09b61e4d130ddf923f0653418a80b9c/399ae101c3f99b4f318635e78a4e587a.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=GY/9LMkQAiDOrMQwS5BkmOE200s%3D&Expires=1434033527" }
      it { expect(subject.label).to be_blank }
      it { expect(subject.width).to be_blank }
      it { expect(subject.height).to be_blank }
      it { expect(subject.frame_rate).to be_blank }
      it { expect(subject.duration).to be_blank }
      it { expect(subject.file_size).to be_blank }
      it { expect(subject.checksum).to be_blank }
      it { expect(subject.audio_codec).to be_blank }
      it { expect(subject.video_codec).to be_blank }
      it { expect(subject.audio_bitrate).to be_blank }
      it { expect(subject.video_bitrate).to be_blank }
      it { expect(subject.state).to eq :running }
      it { expect(subject.created_at).to eq "2015-06-10T14:38:47Z" }
      it { expect(subject.updated_at).to eq "2015-06-10T14:38:47Z" }
    end
  end

  describe "#find" do
    before do
      allow(Zencoder::Job).to receive(:details).and_return(details_response)
      allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
    end

    context "a running encode" do
      subject { ActiveEncode::Base.find('166019107') }
      let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_running.json'))) }
      let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_running.json'))) }
      # let(:running_output) { [{ id: "510582971", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106", label: nil }] }
      # let(:running_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }

      it { is_expected.to be_a ActiveEncode::Base }
      it { expect(subject.id).to eq '166019107' }
      it { is_expected.to be_running }
      # it { expect(subject.output).to eq running_output }
      it { expect(subject.current_operations).to be_empty }
      it { expect(subject.percent_complete).to eq 30.0 }
      it { expect(subject.errors).to be_empty }
      it { expect(subject.created_at).to eq '2015-06-09T16:18:26Z' }
      it { expect(subject.updated_at).to eq '2015-06-09T16:18:28Z' }

      # it { expect(subject.tech_metadata).to eq running_tech_metadata }
      context 'input' do
        subject { ActiveEncode::Base.find('166019107').input }

        it { is_expected.to be_a ActiveEncode::Input }
        it { expect(subject.id).to eq "165990056" }
        it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
        it { expect(subject.width).to eq 320 }
        it { expect(subject.height).to eq 240 }
        it { expect(subject.frame_rate).to eq 29.97 }
        it { expect(subject.duration).to eq 57_992 }
        it { expect(subject.file_size).to be_blank }
        it { expect(subject.checksum).to be_blank }
        it { expect(subject.audio_codec).to eq "aac" }
        it { expect(subject.video_codec).to eq "h264" }
        it { expect(subject.audio_bitrate).to eq 52 }
        it { expect(subject.video_bitrate).to eq 535 }
        it { expect(subject.state).to eq :completed }
        it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
        it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
      end

      context 'output' do
        subject { output.first }
        let(:output) { ActiveEncode::Base.find('166019107').output }

        it 'is an array' do
          expect(output).to be_a Array
        end
        it { is_expected.to be_a ActiveEncode::Output }
        it { expect(subject.id).to eq "510582971" }
        it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
        it { expect(subject.label).to be_blank }
        it { expect(subject.width).to be_blank }
        it { expect(subject.height).to be_blank }
        it { expect(subject.frame_rate).to be_blank }
        it { expect(subject.duration).to be_blank }
        it { expect(subject.file_size).to be_blank }
        it { expect(subject.checksum).to be_blank }
        it { expect(subject.audio_codec).to be_blank }
        it { expect(subject.video_codec).to be_blank }
        it { expect(subject.audio_bitrate).to be_blank }
        it { expect(subject.video_bitrate).to be_blank }
        it { expect(subject.state).to eq :running }
        it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
        it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
      end
    end

    context "a cancelled encode" do
      subject { ActiveEncode::Base.find('165866551') }
      let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_cancelled.json'))) }
      let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_cancelled.json'))) }

      it { is_expected.to be_a ActiveEncode::Base }
      it { expect(subject.id).to eq '165866551' }
      it { is_expected.to be_cancelled }
      it { expect(subject.current_operations).to be_empty }
      it { expect(subject.percent_complete).to eq 0 }
      it { expect(subject.errors).to be_empty }
      it { expect(subject.created_at).to eq '2015-06-08T20:43:23Z' }
      it { expect(subject.updated_at).to eq '2015-06-08T20:43:26Z' }

      context 'input' do
        subject { ActiveEncode::Base.find('165866551').input }

        it { is_expected.to be_a ActiveEncode::Input }
        it { expect(subject.id).to eq "165837500" }
        it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
        it { expect(subject.width).to be_blank }
        it { expect(subject.height).to be_blank }
        it { expect(subject.frame_rate).to be_blank }
        it { expect(subject.duration).to be_blank }
        it { expect(subject.file_size).to be_blank }
        it { expect(subject.checksum).to be_blank }
        it { expect(subject.audio_codec).to be_blank }
        it { expect(subject.video_codec).to be_blank }
        it { expect(subject.audio_bitrate).to be_blank }
        it { expect(subject.video_bitrate).to be_blank }
        it { expect(subject.state).to eq :cancelled }
        it { expect(subject.created_at).to eq "2015-06-08T20:43:23Z" }
        it { expect(subject.updated_at).to eq "2015-06-08T20:43:26Z" }
      end
    end

    context "a completed encode" do
      subject { ActiveEncode::Base.find('165839139') }
      let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_completed.json'))) }
      let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_completed.json'))) }
      let(:completed_output) { { id: "509856876", audio_bitrate: "53", audio_codec: "aac", audio_channels: "2", duration: "5000", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "549", video_codec: "h264", width: "320", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150608/ebbe865f8ef1b960d7c2bb0663b88a12/0f1948dcb2fd701fba30ff21908fe460.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=1LgIyl/el9E7zeyPxzd/%2BNwez6Y%3D&Expires=1433873646", label: nil } }
      # let(:completed_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }

      it { is_expected.to be_a ActiveEncode::Base }
      it { expect(subject.id).to eq '165839139' }
      it { is_expected.to be_completed }
      # it { expect(subject.output).to include completed_output }
      it { expect(subject.current_operations).to be_empty }
      it { expect(subject.percent_complete).to eq 100 }
      it { expect(subject.errors).to be_empty }
      it { expect(subject.created_at).to eq '2015-06-08T18:13:53Z' }
      it { expect(subject.updated_at).to eq '2015-06-08T18:14:06Z' }

      context 'input' do
        subject { ActiveEncode::Base.find('165839139').input }

        it { is_expected.to be_a ActiveEncode::Input }
        it { expect(subject.id).to eq "165810088" }
        it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
        it { expect(subject.width).to eq 320 }
        it { expect(subject.height).to eq 240 }
        it { expect(subject.frame_rate).to eq 29.97 }
        it { expect(subject.duration).to eq 57_992 }
        it { expect(subject.file_size).to be_blank }
        it { expect(subject.checksum).to be_blank }
        it { expect(subject.audio_codec).to eq "aac" }
        it { expect(subject.video_codec).to eq "h264" }
        it { expect(subject.audio_bitrate).to eq 52 }
        it { expect(subject.video_bitrate).to eq 535 }
        it { expect(subject.state).to eq :completed }
        it { expect(subject.created_at).to eq "2015-06-08T18:13:53Z" }
        it { expect(subject.updated_at).to eq "2015-06-08T18:14:06Z" }
      end

      context 'output' do
        subject { output.first }
        let(:output) { ActiveEncode::Base.find('166019107').reload.output }

        it 'is an array' do
          expect(output).to be_a Array
        end
        it { is_expected.to be_a ActiveEncode::Output }
        it { expect(subject.id).to eq "509856876" }
        it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150608/ebbe865f8ef1b960d7c2bb0663b88a12/0f1948dcb2fd701fba30ff21908fe460.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=1LgIyl/el9E7zeyPxzd/%2BNwez6Y%3D&Expires=1433873646" }
        it { expect(subject.label).to be_blank }
        it { expect(subject.width).to eq 320 }
        it { expect(subject.height).to eq 240 }
        it { expect(subject.frame_rate).to eq 29.97 }
        it { expect(subject.duration).to eq 5000 }
        it { expect(subject.file_size).to be_blank }
        it { expect(subject.checksum).to be_blank }
        it { expect(subject.audio_codec).to eq "aac" }
        it { expect(subject.video_codec).to eq "h264" }
        it { expect(subject.audio_bitrate).to eq 53 }
        it { expect(subject.video_bitrate).to eq 549 }
        it { expect(subject.state).to eq :completed }
        it { expect(subject.created_at).to eq "2015-06-08T18:13:53Z" }
        it { expect(subject.updated_at).to eq "2015-06-08T18:14:06Z" }
      end
    end

    context "a failed encode" do
      subject { ActiveEncode::Base.find('166079902') }
      let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_failed.json'))) }
      let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_failed.json'))) }
      let(:failed_tech_metadata) { { mime_type: "video/mp4", checksum: "7ae24368ccb7a6c6422a14ff73f33c9a", duration: "6314", audio_codec: "AAC", audio_channels: "2", audio_bitrate: "171030.0", video_codec: "AVC", video_bitrate: "74477.0", video_framerate: "23.719", width: "200", height: "110" } }
      let(:failed_errors) { "The file is an XML file, and doesn't contain audio or video tracks." }

      it { is_expected.to be_a ActiveEncode::Base }
      it { expect(subject.id).to eq '166079902' }
      it { is_expected.to be_failed }
      it { expect(subject.current_operations).to be_empty }
      it { expect(subject.percent_complete).to eq 0 }
      it { expect(subject.errors).to be_empty }
      it { expect(subject.created_at).to eq '2015-06-09T20:52:57Z' }
      it { expect(subject.updated_at).to eq '2015-06-09T20:53:00Z' }

      context 'input' do
        subject { ActiveEncode::Base.find('165866551').input }

        it { is_expected.to be_a ActiveEncode::Input }
        it { expect(subject.id).to eq "166050851" }
        it { expect(subject.url).to eq "s3://zencoder-customer-ingest/uploads/2015-06-09/240330/187007/682c2d90-0eea-11e5-84c9-f158f44c3d50.xml" }
        it { expect(subject.errors).to include failed_errors }
        it { expect(subject.width).to be_blank }
        it { expect(subject.height).to be_blank }
        it { expect(subject.frame_rate).to be_blank }
        it { expect(subject.duration).to be_blank }
        it { expect(subject.file_size).to be_blank }
        it { expect(subject.checksum).to be_blank }
        it { expect(subject.audio_codec).to be_blank }
        it { expect(subject.video_codec).to be_blank }
        it { expect(subject.audio_bitrate).to be_blank }
        it { expect(subject.video_bitrate).to be_blank }
        it { expect(subject.state).to eq :failed }
        it { expect(subject.created_at).to eq "2015-06-09T20:52:57Z" }
        it { expect(subject.updated_at).to eq "2015-06-09T20:53:00Z" }
      end
    end
  end

  describe "#cancel!" do
    subject { encode.cancel! }
    before do
      allow(Zencoder::Job).to receive(:cancel).and_return(cancel_response)
      allow(Zencoder::Job).to receive(:details).and_return(details_response)
      allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
    end

    let(:cancel_response) { Zencoder::Response.new(code: 200) } # TODO: check that this is the correct response code for a successful cancel
    let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_cancelled.json'))) }
    let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_cancelled.json'))) }

    let(:encode) { ActiveEncode::Base.create(file) }
    it { is_expected.to be_a ActiveEncode::Base }
    it { expect(subject.id).to eq '165866551' }
    it { is_expected.to be_cancelled }
  end

  describe "reload" do
    subject { ActiveEncode::Base.find('166019107').reload }
    before do
      allow(Zencoder::Job).to receive(:details).and_return(details_response)
      allow(Zencoder::Job).to receive(:progress).and_return(progress_response)
    end

    let(:details_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_details_running.json'))) }
    let(:progress_response) { Zencoder::Response.new(body: JSON.parse(File.read('spec/fixtures/zencoder/job_progress_running.json'))) }
    # let(:reload_output) { [{ id: "510582971", url: "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106", label: nil }] }
    # let(:reload_tech_metadata) { { audio_bitrate: "52", audio_codec: "aac", audio_channels: "2", duration: "57992", mime_type: "mpeg4", video_framerate: "29.97", height: "240", video_bitrate: "535", video_codec: "h264", width: "320" } }

    it { is_expected.to be_a ActiveEncode::Base }
    it { expect(subject.id).to eq '166019107' }
    it { is_expected.to be_running }
    # it { expect(subject.output).to eq reload_output }
    it { expect(subject.current_operations).to be_empty }
    it { expect(subject.percent_complete).to eq 30.0 }
    it { expect(subject.errors).to be_empty }
    it { expect(subject.created_at).to eq '2015-06-09T16:18:26Z' }
    it { expect(subject.updated_at).to eq '2015-06-09T16:18:28Z' }

    context 'input' do
      subject { ActiveEncode::Base.find('166019107').reload.input }

      it { is_expected.to be_a ActiveEncode::Input }
      it { expect(subject.id).to eq "165990056" }
      it { expect(subject.url).to eq "https://archive.org/download/LuckyStr1948_2/LuckyStr1948_2_512kb.mp4" }
      it { expect(subject.width).to eq 320 }
      it { expect(subject.height).to eq 240 }
      it { expect(subject.frame_rate).to eq 29.97 }
      it { expect(subject.duration).to eq 57_992 }
      it { expect(subject.file_size).to be_blank }
      it { expect(subject.checksum).to be_blank }
      it { expect(subject.audio_codec).to eq "aac" }
      it { expect(subject.video_codec).to eq "h264" }
      it { expect(subject.audio_bitrate).to eq 52 }
      it { expect(subject.video_bitrate).to eq 535 }
      it { expect(subject.state).to eq :completed }
      it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
      it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
    end

    context 'output' do
      subject { output.first }
      let(:output) { ActiveEncode::Base.find('166019107').reload.output }

      it 'is an array' do
        expect(output).to be_a Array
      end
      it { is_expected.to be_a ActiveEncode::Output }
      it { expect(subject.id).to eq "510582971" }
      it { expect(subject.url).to eq "https://zencoder-temp-storage-us-east-1.s3.amazonaws.com/o/20150609/48a6907086c012f68b9ca43461280515/1726d7ec3e24f2171bd07b2abb807b6c.mp4?AWSAccessKeyId=AKIAI456JQ76GBU7FECA&Signature=vSvlxU94wlQLEbpG3Zs8ibp4MoY%3D&Expires=1433953106" }
      it { expect(subject.label).to be_blank }
      it { expect(subject.width).to be_blank }
      it { expect(subject.height).to be_blank }
      it { expect(subject.frame_rate).to be_blank }
      it { expect(subject.duration).to be_blank }
      it { expect(subject.file_size).to be_blank }
      it { expect(subject.checksum).to be_blank }
      it { expect(subject.audio_codec).to be_blank }
      it { expect(subject.video_codec).to be_blank }
      it { expect(subject.audio_bitrate).to be_blank }
      it { expect(subject.video_bitrate).to be_blank }
      it { expect(subject.state).to eq :running }
      it { expect(subject.created_at).to eq "2015-06-09T16:18:26Z" }
      it { expect(subject.updated_at).to eq "2015-06-09T16:18:32Z" }
    end
  end
end


text:
// ----------------------------------------------------------------------------
// Copyright © Aleksey Nemiro, 2015-2017. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------
using Nemiro.OAuth.Clients;

namespace Nemiro.OAuth.LoginForms
{

  ///
  /// Represents login form for Foursquare.
  ///
  public class FoursquareLogin : Login
  {

    ///
    /// Gets logout url.
    ///
    public string LogoutUrl
    {
      get
      {
        return "https://foursquare.com/logout";
      }
    }

    ///
    /// Initializes a new instance of the login form with a specified parameters.
    ///
    /// <param name="clientId">The Client ID obtained from the <see href="https://foursquare.com/oauth">Foursquare Apps</see>.</param>
    /// <param name="clientSecret">The Client Secret obtained from the <see href="https://foursquare.com/oauth">Foursquare Apps</see>.</param>
    /// <param name="autoLogout">Disables saving and restoring authorization cookies in WebBrowser. Default: false.</param>
    /// <param name="returnUrl">The address to return. You can use <see href="https://oauthproxy.nemiro.net"/>, but for reliability use your own server that you control.</param>
    /// <param name="loadUserInfo">Indicates the need to make a request for recive the user profile or not. Default: false.</param>
    /// <param name="responseType">Allows to set the type of response that is expected from the server. Default: <see cref="ResponseType.Token"/>.</param>
    public FoursquareLogin(string clientId, string clientSecret, string returnUrl, bool autoLogout = false, bool loadUserInfo = false, string responseType = "token") : this(clientId, clientSecret, returnUrl, null, autoLogout, loadUserInfo, responseType) { }

    ///
    /// Initializes a new instance of the login form with a specified parameters.
    ///
    /// <param name="clientId">The Client ID obtained from the <see href="https://foursquare.com/oauth">Foursquare Apps</see>.</param>
    /// <param name="clientSecret">The Client Secret obtained from the <see href="https://foursquare.com/oauth">Foursquare Apps</see>.</param>
    /// <param name="autoLogout">Disables saving and restoring authorization cookies in WebBrowser. Default: false.</param>
    /// <param name="scope">The scope of the access request.</param>
    /// <param name="returnUrl">The address to return. You can use <see href="https://oauthproxy.nemiro.net"/>, but for reliability use your own server that you control.</param>
    /// <param name="loadUserInfo">Indicates the need to make a request for recive the user profile or not. Default: false.</param>
    /// <param name="responseType">Allows to set the type of response that is expected from the server. Default: <see cref="ResponseType.Token"/>.</param>
    public FoursquareLogin(string clientId, string clientSecret, string returnUrl, string scope, bool autoLogout = false, bool loadUserInfo = false, string responseType = "token") : this(new FoursquareClient(clientId, clientSecret) { ReturnUrl = returnUrl, Scope = scope, Parameters = { { "display", "touch" } } }, autoLogout, loadUserInfo, responseType) { }

    ///
    /// Initializes a new instance of the login form with a specified OAuth client.
    ///
    /// <param name="client">Instance of the OAuth client.</param>
    /// <param name="autoLogout">Disables saving and restoring authorization cookies in WebBrowser. Default: false.</param>
    /// <param name="loadUserInfo">Indicates the need to make a request for recive the user profile or not. Default: false.</param>
    /// <param name="responseType">Allows to set the type of response that is expected from the server. Default: <see cref="ResponseType.Token"/>.</param>
    public FoursquareLogin(FoursquareClient client, bool autoLogout = false, bool loadUserInfo = false, string responseType = "token") : base(client, autoLogout, loadUserInfo, responseType)
    {
      this.Height = 595;
      this.Icon = Properties.Resources.foursquare;
    }

  }

}


text:
{-# LANGUAGE DeriveGeneric #-}

-- only export the public interface
module Users (Users.all, matching, User(..)) where

import           Data.Aeson
import           GHC.Generics

data User = User {userId :: Int, userName :: String} deriving (Show, Generic, Eq)

bob :: User
bob = User {userId = 1, userName = "bob"}

jenny :: User
jenny = User {userId = 2, userName = "jenny"}

all :: [User]
all = [bob, jenny]

matching :: Int -> [User] -> [User]
matching id = filter (matchesId id)

matchesId :: Int -> User -> Bool
matchesId id user = userId user == id

-- implement the typeclasses for JSON using Generics
instance ToJSON User
instance FromJSON User


text:
#pragma once
#include <aws/chime/Chime_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/chime/model/OriginationRoute.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Json
{
  class JsonValue;
  class JsonView;
} // namespace Json
} // namespace Utils
namespace Chime
{
namespace Model
{

  /**
   *
Origination settings enable your SIP hosts to receive inbound calls using
   * your Amazon Chime Voice Connector.

The parameters listed below are
   * not required, but you must use at least one.

See Also:

   * AWS
   * API Reference

   */
  class AWS_CHIME_API Origination
  {
  public:
    Origination();
    Origination(Aws::Utils::Json::JsonView jsonValue);
    Origination& operator=(Aws::Utils::Json::JsonView jsonValue);
    Aws::Utils::Json::JsonValue Jsonize() const;

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline const Aws::Vector<OriginationRoute>& GetRoutes() const{ return m_routes; }

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline bool RoutesHasBeenSet() const { return m_routesHasBeenSet; }

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline void SetRoutes(const Aws::Vector<OriginationRoute>& value) { m_routesHasBeenSet = true; m_routes = value; }

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline void SetRoutes(Aws::Vector<OriginationRoute>&& value) { m_routesHasBeenSet = true; m_routes = std::move(value); }

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline Origination& WithRoutes(const Aws::Vector<OriginationRoute>& value) { SetRoutes(value); return *this;}

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline Origination& WithRoutes(Aws::Vector<OriginationRoute>&& value) { SetRoutes(std::move(value)); return *this;}

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline Origination& AddRoutes(const OriginationRoute& value) { m_routesHasBeenSet = true; m_routes.push_back(value); return *this; }

    /**
     *
The call distribution properties defined for your SIP hosts. Valid range:
     * Minimum value of 1. Maximum value of 20. This parameter is not required, but you
     * must specify this parameter or Disabled.

     */
    inline Origination& AddRoutes(OriginationRoute&& value) { m_routesHasBeenSet = true; m_routes.push_back(std::move(value)); return *this; }

    /**
     *
When origination settings are disabled, inbound calls are not enabled for
     * your Amazon Chime Voice Connector. This parameter is not required, but you must
     * specify this parameter or Routes.

     */
    inline bool GetDisabled() const{ return m_disabled; }

    /**
     *
When origination settings are disabled, inbound calls are not enabled for
     * your Amazon Chime Voice Connector. This parameter is not required, but you must
     * specify this parameter or Routes.

     */
    inline bool DisabledHasBeenSet() const { return m_disabledHasBeenSet; }

    /**
     *
When origination settings are disabled, inbound calls are not enabled for
     * your Amazon Chime Voice Connector. This parameter is not required, but you must
     * specify this parameter or Routes.

     */
    inline void SetDisabled(bool value) { m_disabledHasBeenSet = true; m_disabled = value; }

    /**
     *
When origination settings are disabled, inbound calls are not enabled for
     * your Amazon Chime Voice Connector. This parameter is not required, but you must
     * specify this parameter or Routes.

     */
    inline Origination& WithDisabled(bool value) { SetDisabled(value); return *this;}

  private:

    Aws::Vector<OriginationRoute> m_routes;
    bool m_routesHasBeenSet = false;

    bool m_disabled;
    bool m_disabledHasBeenSet = false;
  };

} // namespace Model
} // namespace Chime
} // namespace Aws


text:
using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Exporters;
using BenchmarkDotNet.Jobs;

namespace MicroBenchmarks.LowLevel;

[Config(typeof(Config))]
public class ArrayAccessOrUnsafe
{
    private class Config : ManualConfig
    {
        public Config()
        {
            AddExporter(MarkdownExporter.GitHub);
            AddDiagnoser(new DisassemblyDiagnoser(new DisassemblyDiagnoserConfig(printSource: true, exportDiff: true)));
            AddJob(Job.Default.WithInvocationCount(512000));
        }
    }

    private Consumer consumer = new Consumer();

    [GlobalSetup]
    public void Setup()
    {
        someInterfaces = new ISomeInterface[] {new A(), new B(),new A(), new B(), new A(), new B() };
    }

    private ISomeInterface[] someInterfaces;

    [Benchmark(Baseline = true)]
    public void ArrayAccess()
    {
        consumer.Consume(((A)someInterfaces[0]).DoA());
        consumer.Consume(((B)someInterfaces[1]).DoB());
        consumer.Consume(((A)someInterfaces[2]).DoA());
        consumer.Consume(((B)someInterfaces[3]).DoB());
        consumer.Consume(((A)someInterfaces[4]).DoA());
        consumer.Consume(((B)someInterfaces[5]).DoB());
    }

    [Benchmark()]
    public unsafe void UnsafeArrayAccess()
    {
        consumer.Consume(Unsafe.Read<A>(Unsafe.AsPointer(ref someInterfaces[0])).DoA());
        consumer.Consume(Unsafe.Read<B>(Unsafe.AsPointer(ref someInterfaces[1])).DoB());
        consumer.Consume(Unsafe.Read<A>(Unsafe.AsPointer(ref someInterfaces[2])).DoA());
        consumer.Consume(Unsafe.Read<B>(Unsafe.AsPointer(ref someInterfaces[3])).DoB());
        consumer.Consume(Unsafe.Read<A>(Unsafe.AsPointer(ref someInterfaces[4])).DoA());
        consumer.Consume(Unsafe.Read<B>(Unsafe.AsPointer(ref someInterfaces[5])).DoB());
    }
    [Benchmark()]
    public void UnsafeAs()
    {
        consumer.Consume(Unsafe.As<A>(someInterfaces[0]).DoA());
        consumer.Consume(Unsafe.As<B>(someInterfaces[1]).DoB());
        consumer.Consume(Unsafe.As<A>(someInterfaces[2]).DoA());
        consumer.Consume(Unsafe.As<B>(someInterfaces[3]).DoB());
        consumer.Consume(Unsafe.As<A>(someInterfaces[4]).DoA());
        consumer.Consume(Unsafe.As<B>(someInterfaces[5]).DoB());
    }

    [Benchmark()]
    public void UnsafeAsFrom()
    {
        consumer.Consume(Unsafe.As<ISomeInterface, A>(ref someInterfaces[0]).DoA());
        consumer.Consume(Unsafe.As<ISomeInterface,B>(ref someInterfaces[1]).DoB());
        consumer.Consume(Unsafe.As<ISomeInterface,A>(ref someInterfaces[2]).DoA());
        consumer.Consume(Unsafe.As<ISomeInterface,B>(ref someInterfaces[3]).DoB());
        consumer.Consume(Unsafe.As<ISomeInterface,A>(ref someInterfaces[4]).DoA());
        consumer.Consume(Unsafe.As<ISomeInterface,B>(ref someInterfaces[5]).DoB());
    }

    public interface ISomeInterface
    {

    }

    public class A : ISomeInterface
    {
        public int DoA()
        {
            return 42;
        }
    }

    public class B : ISomeInterface
    {
        public int DoB()
        {
            return 42;
        }
    }
}


text:
@echo off

xcopy /s /i /y target\site\* ..\settlersonlinesimulator.pages

echo **************************************************
echo REMEMBER TO DELETE ALL THE CONTENT FROM THE SITE REPO FIRST
echo          SO THAT ONLY LATEST CONTENT REMAINS
echo **************************************************


text:
using HttpLibrary.Interop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.Security.ExchangeActiveSyncProvisioning;
using Windows.System.Profile;

namespace HttpLibrary.Platform.UWP
{
    class DeviceInfoUWP : IDeviceInfo
    {
        private string appName;
        public string Application
        {
            get
            {
                var version = string.Format("{0}.{1}.{2}.{3}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor, Package.Current.Id.Version.Build, Package.Current.Id.Version.Revision);
                return string.IsNullOrEmpty(appName) ? (string.Format("{0}/{1}", Package.Current.DisplayName, version)) : appName;
            }

            set
            {
                appName = value;
            }
        }

        public string Device
        {
            get
            {
                EasClientDeviceInformation eas = new EasClientDeviceInformation();
                var deviceManufacturer = eas.SystemManufacturer;
                var deviceModel = eas.SystemProductName;

                return string.Format("{0} {1}", deviceManufacturer, deviceModel);
            }
        }

        public string System
        {
            get
            {
                AnalyticsVersionInfo ai = AnalyticsInfo.VersionInfo;
                var systemFamily = ai.DeviceFamily;

                // get the system version number
                //string sv = AnalyticsInfo.VersionInfo.DeviceFamilyVersion;

                // get the package architecure
                Package package = Package.Current;
                var systemArchitecture = package.Id.Architecture.ToString();

                return string.Format("{0}; {1}", systemFamily, systemArchitecture);
            }
        }
    }
}


text:
"""Add a new SSH key."""
# :license: MIT, see LICENSE for more details.
from os import path

import SoftLayer
from SoftLayer.CLI import environment

import click

@click.command()
@click.argument('label')
@click.option('--in-file', '-f',
              type=click.Path(exists=True),
              help="The id_rsa.pub file to import for this key")
@click.option('--key', '-k', help="The actual SSH key")
@click.option('--note', help="Extra note that will be associated with key")
@environment.pass_env
def cli(env, label, in_file, key, note):
    """Add a new SSH key."""

    if key:
        key_text = key
    else:
        key_file = open(path.expanduser(in_file), 'rU')
        key_text = key_file.read().strip()
        key_file.close()

    mgr = SoftLayer.SshKeyManager(env.client)
    result = mgr.add_key(key_text, label, note)

    return "SSH key added: %s" % result.get('fingerprint')


text:
package org.apache.yoko.orb.OCI;

//
// IDL:orb.yoko.apache.org/OCI/PluginId:1.0
//
final public class PluginIdHelper
{
    public static void
    insert(org.omg.CORBA.Any any, String val)
    {
        org.omg.CORBA.portable.OutputStream out = any.create_output_stream();
        write(out, val);
        any.read_value(out.create_input_stream(), type());
    }

    public static String
    extract(org.omg.CORBA.Any any)
    {
        if(any.type().equivalent(type()))
            return read(any.create_input_stream());
        else

            throw new org.omg.CORBA.BAD_OPERATION(
                org.apache.yoko.orb.OB.MinorCodes
                        .describeBadOperation(org.apache.yoko.orb.OB.MinorCodes.MinorTypeMismatch),
                org.apache.yoko.orb.OB.MinorCodes.MinorTypeMismatch, org.omg.CORBA.CompletionStatus.COMPLETED_NO);
    }

    private static org.omg.CORBA.TypeCode typeCode_;

    public static org.omg.CORBA.TypeCode
    type()
    {
        if(typeCode_ == null)
        {
            org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
            typeCode_ = orb.create_alias_tc(id(), "PluginId", orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string));
        }

        return typeCode_;
    }

    public static String
    id()
    {
        return "IDL:orb.yoko.apache.org/OCI/PluginId:1.0";
    }

    public static String
    read(org.omg.CORBA.portable.InputStream in)
    {
        String _ob_v;
        _ob_v = in.read_string();
        return _ob_v;
    }

    public static void
    write(org.omg.CORBA.portable.OutputStream out, String val)
    {
        out.write_string(val);
    }
}


text:
namespace silifuzz {
namespace {

bool SortMemoryRange(const MemoryRange& a, const MemoryRange& b) {
  return a.start_address < b.start_address;
}

void CheckMemoryRanges(std::vector<MemoryRange>& ranges) {
  ASSERT_GT(ranges.size(), 1);
  std::sort(ranges.begin(), ranges.end(), SortMemoryRange);
  for (size_t i = 0; i < ranges.size() - 1; ++i) {
    EXPECT_LE(ranges[i].start_address + ranges[i].num_bytes,
              ranges[i + 1].start_address);
  }
}

TEST(ProxyConfig, NoOverlap_X86_64) {
  FuzzingConfig_X86_64 config = DEFAULT_X86_64_FUZZING_CONFIG;
  std::vector<MemoryRange> ranges = {config.code_range, config.data1_range,
                                     config.data2_range};
  CheckMemoryRanges(ranges);
}

TEST(ProxyConfig, NoOverlap_AArch64) {
  FuzzingConfig_AArch64 config = DEFAULT_AARCH64_FUZZING_CONFIG;
  std::vector<MemoryRange> ranges = {config.code_range, config.stack_range,
                                     config.data1_range, config.data2_range};
  CheckMemoryRanges(ranges);
}

}  // namespace
}  // namespace silifuzz


text:
/**
 * @author Mat Groves http://matgroves.com/ @Doormat23
 */

/**
 * A Text Object will create a line(s) of text. To split a line you can use '\n'
 * or add a wordWrap property set to true and and wordWrapWidth property with a value
 * in the style object
 *
 * @class Text
 * @extends Sprite
 * @constructor
 * @param text {String} The copy that you would like the text to display
 * @param [style] {Object} The style parameters
 * @param [style.font] {String} default 'bold 20px Arial' The style and size of the font
 * @param [style.fill='black'] {String|Number} A canvas fillstyle that will be used on the text e.g 'red', '#00FF00'
 * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text
 * @param [style.stroke] {String|Number} A canvas fillstyle that will be used on the text stroke e.g 'blue', '#FCFF00'
 * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke)
 * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used
 * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap, it needs wordWrap to be set to true
 */
PIXI.Text = function(text, style)
{
    /**
     * The canvas element that everything is drawn to
     *
     * @property canvas
     * @type HTMLCanvasElement
     */
    this.canvas = document.createElement('canvas');

    /**
     * The canvas 2d context that everything is drawn with
     * @property context
     * @type HTMLCanvasElement 2d Context
     */
    this.context = this.canvas.getContext('2d');

    PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas));

    this.setText(text);
    this.setStyle(style);

    this.updateText();
    this.dirty = false;
};

// constructor
PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
PIXI.Text.prototype.constructor = PIXI.Text;

/**
 * Set the style of the text
 *
 * @method setStyle
 * @param [style] {Object} The style parameters
 * @param [style.font='bold 20pt Arial'] {String} The style and size of the font
 * @param [style.fill='black'] {Object} A canvas fillstyle that will be used on the text eg 'red', '#00FF00'
 * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text
 * @param [style.stroke='black'] {String} A canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'
 * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke)
 * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used
 * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap
 */
PIXI.Text.prototype.setStyle = function(style)
{
    style = style || {};
    style.font = style.font || 'bold 20pt Arial';
    style.fill = style.fill || 'black';
    style.align = style.align || 'left';
    style.stroke = style.stroke || 'black'; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
    style.strokeThickness = style.strokeThickness || 0;
    style.wordWrap = style.wordWrap || false;
    style.wordWrapWidth = style.wordWrapWidth || 100;
    this.style = style;
    this.dirty = true;
};

/**
 * Set the copy for the text object. To split a line you can use '\n'
 *
 * @method setText
 * @param {String} text The copy that you would like the text to display
 */
PIXI.Text.prototype.setText = function(text)
{
    this.text = text.toString() || ' ';
    this.dirty = true;

};

/**
 * Renders text and updates it when needed
 *
 * @method updateText
 * @private
 */
PIXI.Text.prototype.updateText = function()
{
    this.context.font = this.style.font;

    var outputText = this.text;

    // word wrap
    // preserve original text
    if(this.style.wordWrap)outputText = this.wordWrap(this.text);

    //split text into lines
    var lines = outputText.split(/(?:\r\n|\r|\n)/);

    //calculate text width
    var lineWidths = [];
    var maxLineWidth = 0;
    for (var i = 0; i < lines.length; i++)
    {
        var lineWidth = this.context.measureText(lines[i]).width;
        lineWidths[i] = lineWidth;
        maxLineWidth = Math.max(maxLineWidth, lineWidth);
    }
    this.canvas.width = maxLineWidth + this.style.strokeThickness;

    //calculate text height
    var lineHeight = this.determineFontHeight('font: ' + this.style.font  + ';') + this.style.strokeThickness;
    this.canvas.height = lineHeight * lines.length;

    if(navigator.isCocoonJS) this.context.clearRect(0,0,this.canvas.width,this.canvas.height);

    //set canvas text styles
    this.context.fillStyle = this.style.fill;
    this.context.font = this.style.font;

    this.context.strokeStyle = this.style.stroke;
    this.context.lineWidth = this.style.strokeThickness;

    this.context.textBaseline = 'top';

    //draw lines line by line
    for (i = 0; i < lines.length; i++)
    {
        var linePosition = new PIXI.Point(this.style.strokeThickness / 2, this.style.strokeThickness / 2 + i * lineHeight);

        if(this.style.align === 'right')
        {
            linePosition.x += maxLineWidth - lineWidths[i];
        }
        else if(this.style.align === 'center')
        {
            linePosition.x += (maxLineWidth - lineWidths[i]) / 2;
        }

        if(this.style.stroke && this.style.strokeThickness)
        {
            this.context.strokeText(lines[i], linePosition.x, linePosition.y);
        }

        if(this.style.fill)
        {
            this.context.fillText(lines[i], linePosition.x, linePosition.y);
        }
    }

    this.updateTexture();
};

/**
 * Updates texture size based on canvas size
 *
 * @method updateTexture
 * @private
 */
PIXI.Text.prototype.updateTexture = function()
{
    this.texture.baseTexture.width = this.canvas.width;
    this.texture.baseTexture.height = this.canvas.height;
    this.texture.frame.width = this.canvas.width;
    this.texture.frame.height = this.canvas.height;

    this._width = this.canvas.width;
    this._height = this.canvas.height;

    this.requiresUpdate =  true;
};

/**
* Renders the object using the WebGL renderer
*
* @method _renderWebGL
* @param renderSession {RenderSession}
* @private
*/
PIXI.Text.prototype._renderWebGL = function(renderSession)
{
    if(this.requiresUpdate)
    {
        this.requiresUpdate = false;
        PIXI.updateWebGLTexture(this.texture.baseTexture, renderSession.gl);
    }

    PIXI.Sprite.prototype._renderWebGL.call(this, renderSession);
};

/**
 * Updates the transform of this object
 *
 * @method updateTransform
 * @private
 */
PIXI.Text.prototype.updateTransform = function()
{
    if(this.dirty)
    {
        this.updateText();
        this.dirty = false;
    }

    PIXI.Sprite.prototype.updateTransform.call(this);
};

/*
 * http://stackoverflow.com/users/34441/ellisbben
 * great solution to the problem!
 * returns the height of the given font
 *
 * @method determineFontHeight
 * @param fontStyle {Object}
 * @private
 */
PIXI.Text.prototype.determineFontHeight = function(fontStyle)
{
    // build a little reference dictionary so if the font style has been used return a
    // cached version...
    var result = PIXI.Text.heightCache[fontStyle];

    if(!result)
    {
        var body = document.getElementsByTagName('body')[0];
        var dummy = document.createElement('div');
        var dummyText = document.createTextNode('M');
        dummy.appendChild(dummyText);
        dummy.setAttribute('style', fontStyle + ';position:absolute;top:0;left:0');
        body.appendChild(dummy);

        result = dummy.offsetHeight;
        PIXI.Text.heightCache[fontStyle] = result;

        body.removeChild(dummy);
    }

    return result;
};

/**
 * Applies newlines to a string to have it optimally fit into the horizontal
 * bounds set by the Text object's wordWrapWidth property.
 *
 * @method wordWrap
 * @param text {String}
 * @private
 */
PIXI.Text.prototype.wordWrap = function(text)
{
    // Greedy wrapping algorithm that will wrap words as the line grows longer
    // than its horizontal bounds.
    var result = '';
    var lines = text.split('\n');
    for (var i = 0; i < lines.length; i++)
    {
        var spaceLeft = this.style.wordWrapWidth;
        var words = lines[i].split(' ');
        for (var j = 0; j < words.length; j++)
        {
            var wordWidth = this.context.measureText(words[j]).width;
            var wordWidthWithSpace = wordWidth + this.context.measureText(' ').width;
            if(wordWidthWithSpace > spaceLeft)
            {
                // Skip printing the newline if it's the first word of the line that is
                // greater than the word wrap width.
                if(j > 0)
                {
                    result += '\n';
                }
                result += words[j] + ' ';
                spaceLeft = this.style.wordWrapWidth - wordWidth;
            }
            else
            {
                spaceLeft -= wordWidthWithSpace;
                result += words[j] + ' ';
            }
        }

        if (i < lines.length-1)
        {
            result += '\n';
        }
    }
    return result;
};

/**
 * Destroys this text object
 *
 * @method destroy
 * @param destroyTexture {Boolean}
 */
PIXI.Text.prototype.destroy = function(destroyTexture)
{
    if(destroyTexture)
    {
        this.texture.destroy();
    }

};

PIXI.Text.heightCache = {};


text:
<TS language="af_ZA" version="2.1">
<context>
    <name>AddressBookPage</name>
    <message>
        <source>Create a new address</source>
        <translation>Skep 'n nuwe adres</translation>
    </message>
    <message>
        <source>Copy the currently selected address to the system clipboard</source>
        <translation>Maak 'n kopie van die huidige adres na die stelsel klipbord</translation>
    </message>
    <message>
        <source>&Delete</source>
        <translation>&Verwyder</translation>
    </message>
    </context>
<context>
    <name>AddressTableModel</name>
    <message>
        <source>Label</source>
        <translation>Etiket</translation>
    </message>
    <message>
        <source>Address</source>
        <translation>Adres</translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation>(geen etiket)</translation>
    </message>
</context>
<context>
    <name>AskPassphraseDialog</name>
    <message>
        <source>Enter passphrase</source>
        <translation>Tik Wagwoord in</translation>
    </message>
    <message>
        <source>New passphrase</source>
        <translation>Nuwe wagwoord</translation>
    </message>
    <message>
        <source>Repeat new passphrase</source>
        <translation>Herhaal nuwe wagwoord</translation>
    </message>
    <message>
        <source>Encrypt wallet</source>
        <translation>Enkripteer beursie</translation>
    </message>
    <message>
        <source>This operation needs your wallet passphrase to unlock the wallet.</source>
        <translation>Hierdie operasie benodig 'n wagwoord om die beursie oop te sluit.</translation>
    </message>
    <message>
        <source>Unlock wallet</source>
        <translation>Sluit beursie oop</translation>
    </message>
    <message>
        <source>This operation needs your wallet passphrase to decrypt the wallet.</source>
        <translation>Hierdie operasie benodig 'n wagwoord om die beursie oop te sluit.</translation>
    </message>
    <message>
        <source>Decrypt wallet</source>
        <translation>Sluit beursie oop</translation>
    </message>
    <message>
        <source>Change passphrase</source>
        <translation>Verander wagwoord</translation>
    </message>
    <message>
        <source>Enter the old and new passphrase to the wallet.</source>
        <translation>Tik asseblief die ou en nuwe wagwoord vir die beursie in.</translation>
    </message>
    <message>
        <source>Confirm wallet encryption</source>
        <translation>Bevestig beursie enkripsie.</translation>
    </message>
    <message>
        <source>Wallet encrypted</source>
        <translation>Die beursie is nou bewaak</translation>
    </message>
    <message>
        <source>Wallet encryption failed</source>
        <translation>Die beursie kon nie bewaak word nie</translation>
    </message>
    <message>
        <source>Wallet encryption failed due to an internal error. Your wallet was not encrypted.</source>
        <translation>Beursie bewaaking het misluk as gevolg van 'n interne fout. Die beursie is nie bewaak nie!</translation>
    </message>
    <message>
        <source>The supplied passphrases do not match.</source>
        <translation>Die wagwoord stem nie ooreen nie</translation>
    </message>
    <message>
        <source>Wallet unlock failed</source>
        <translation>Beursie oopsluiting het misluk</translation>
    </message>
    <message>
        <source>The passphrase entered for the wallet decryption was incorrect.</source>
        <translation>Die wagwoord wat ingetik was om die beursie oop te sluit, was verkeerd.</translation>
    </message>
    <message>
        <source>Wallet decryption failed</source>
        <translation>Beursie dekripsie het misluk</translation>
    </message>
    </context>
<context>
    <name>BitcoinGUI</name>
    <message>
        <source>Synchronizing with network...</source>
        <translation>Sinchroniseer met die netwerk ...</translation>
    </message>
    <message>
        <source>&Overview</source>
        <translation>&Oorsig</translation>
    </message>
    <message>
        <source>Show general overview of wallet</source>
        <translation>Wys algemene oorsig van die beursie</translation>
    </message>
    <message>
        <source>&Transactions</source>
        <translation>&Transaksies</translation>
    </message>
    <message>
        <source>Browse transaction history</source>
        <translation>Besoek transaksie geskiedenis</translation>
    </message>
    <message>
        <source>E&xit</source>
        <translation>S&luit af</translation>
    </message>
    <message>
        <source>Quit application</source>
        <translation>Sluit af</translation>
    </message>
    <message>
        <source>Show information about Qt</source>
        <translation>Wys inligting oor Qt</translation>
    </message>
    <message>
        <source>&Options...</source>
        <translation>&Opsies</translation>
    </message>
    <message>
        <source>Joulecoin</source>
        <translation>Joulecoin</translation>
    </message>
    <message>
        <source>Wallet</source>
        <translation>Beursie</translation>
    </message>
    <message>
        <source>&File</source>
        <translation>&Lêer</translation>
    </message>
    <message>
        <source>&Settings</source>
        <translation>&Instellings</translation>
    </message>
    <message>
        <source>&Help</source>
        <translation>&Hulp</translation>
    </message>
    <message>
        <source>Tabs toolbar</source>
        <translation>Blad nutsbalk</translation>
    </message>
    <message>
        <source>%1 behind</source>
        <translation>%1 agter</translation>
    </message>
    <message>
        <source>Last received block was generated %1 ago.</source>
        <translation>Ontvangs van laaste blok is %1 terug.</translation>
    </message>
    <message>
        <source>Error</source>
        <translation>Fout</translation>
    </message>
    <message>
        <source>Information</source>
        <translation>Informasie</translation>
    </message>
    </context>
<context>
    <name>ClientModel</name>
    </context>
<context>
    <name>CoinControlDialog</name>
    <message>
        <source>Amount:</source>
        <translation>Bedrag:</translation>
    </message>
    <message>
        <source>Amount</source>
        <translation>Bedrag</translation>
    </message>
    <message>
        <source>Date</source>
        <translation>Datum</translation>
    </message>
    <message>
        <source>Copy address</source>
        <translation>Maak kopie van adres</translation>
    </message>
    <message>
        <source>Copy amount</source>
        <translation>Kopieer bedrag</translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation>(geen etiket)</translation>
    </message>
    </context>
<context>
    <name>EditAddressDialog</name>
    <message>
        <source>New receiving address</source>
        <translation>Nuwe ontvangende adres</translation>
    </message>
    <message>
        <source>New sending address</source>
        <translation>Nuwe stuurende adres</translation>
    </message>
    <message>
        <source>Edit receiving address</source>
        <translation>Wysig ontvangende adres</translation>
    </message>
    <message>
        <source>Edit sending address</source>
        <translation>Wysig stuurende adres</translation>
    </message>
    <message>
        <source>Could not unlock wallet.</source>
        <translation>Kon nie die beursie oopsluit nie.</translation>
    </message>
    </context>
<context>
    <name>FreespaceChecker</name>
    </context>
<context>
    <name>HelpMessageDialog</name>
    <message>
        <source>Usage:</source>
        <translation>Gebruik:</translation>
    </message>
    </context>
<context>
    <name>Intro</name>
    <message>
        <source>Error</source>
        <translation>Fout</translation>
    </message>
    </context>
<context>
    <name>OpenURIDialog</name>
    </context>
<context>
    <name>OptionsDialog</name>
    <message>
        <source>Options</source>
        <translation>Opsies</translation>
    </message>
    </context>
<context>
    <name>OverviewPage</name>
    <message>
        <source>Form</source>
        <translation>Vorm</translation>
    </message>
    </context>
<context>
    <name>PaymentServer</name>
    </context>
<context>
    <name>PeerTableModel</name>
    </context>
<context>
    <name>QObject</name>
    <message>
        <source>Amount</source>
        <translation>Bedrag</translation>
    </message>
    </context>
<context>
    <name>QRImageWidget</name>
    </context>
<context>
    <name>RPCConsole</name>
    <message>
        <source>&Information</source>
        <translation>Informasie</translation>
    </message>
    </context>
<context>
    <name>ReceiveCoinsDialog</name>
    <message>
        <source>Copy amount</source>
        <translation>Kopieer bedrag</translation>
    </message>
</context>
<context>
    <name>ReceiveRequestDialog</name>
    <message>
        <source>Address</source>
        <translation>Adres</translation>
    </message>
    <message>
        <source>Amount</source>
        <translation>Bedrag</translation>
    </message>
    <message>
        <source>Label</source>
        <translation>Etiket</translation>
    </message>
    <message>
        <source>Message</source>
        <translation>Boodskap</translation>
    </message>
    </context>
<context>
    <name>RecentRequestsTableModel</name>
    <message>
        <source>Date</source>
        <translation>Datum</translation>
    </message>
    <message>
        <source>Label</source>
        <translation>Etiket</translation>
    </message>
    <message>
        <source>Message</source>
        <translation>Boodskap</translation>
    </message>
    <message>
        <source>Amount</source>
        <translation>Bedrag</translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation>(geen etiket)</translation>
    </message>
    </context>
<context>
    <name>SendCoinsDialog</name>
    <message>
        <source>Send Coins</source>
        <translation>Stuur Munstukke</translation>
    </message>
    <message>
        <source>Amount:</source>
        <translation>Bedrag:</translation>
    </message>
    <message>
        <source>Send to multiple recipients at once</source>
        <translation>Stuur aan vele ontvangers op eens</translation>
    </message>
    <message>
        <source>Balance:</source>
        <translation>Balans:</translation>
    </message>
    <message>
        <source>S&end</source>
        <translation>S&tuur</translation>
    </message>
    <message>
        <source>Copy amount</source>
        <translation>Kopieer bedrag</translation>
    </message>
    <message>
        <source>(no label)</source>
        <translation>(geen etiket)</translation>
    </message>
    </context>
<context>
    <name>SendCoinsEntry</name>
    <message>
        <source>Message:</source>
        <translation>Boodskap:</translation>
    </message>
    </context>
<context>
    <name>ShutdownWindow</name>
    </context>
<context>
    <name>SignVerifyMessageDialog</name>
    <message>
        <source>&Sign Message</source>
        <translation>&Teken boodskap</translation>
    </message>
    <message>
        <source>Signature</source>
        <translation>Handtekening</translation>
    </message>
    <message>
        <source>Sign &Message</source>
        <translation>Teken &Boodskap</translation>
    </message>
    </context>
<context>
    <name>SplashScreen</name>
    </context>
<context>
    <name>TrafficGraphWidget</name>
    </context>
<context>
    <name>TransactionDesc</name>
    <message>
        <source>Date</source>
        <translation>Datum</translation>
    </message>
    <message>
        <source>From</source>
        <translation>Van</translation>
    </message>
    <message>
        <source>To</source>
        <translation>Na</translation>
    </message>
    <message>
        <source>own address</source>
        <translation>eie adres</translation>
    </message>
    <message>
        <source>label</source>
        <translation>etiket</translation>
    </message>
    <message>
        <source>Credit</source>
        <translation>Krediet</translation>
    </message>
    <message>
        <source>not accepted</source>
        <translation>nie aanvaar nie</translation>
    </message>
    <message>
        <source>Debit</source>
        <translation>Debiet</translation>
    </message>
    <message>
        <source>Transaction fee</source>
        <translation>Transaksie fooi</translation>
    </message>
    <message>
        <source>Net amount</source>
        <translation>Netto bedrag</translation>
    </message>
    <message>
        <source>Message</source>
        <translation>Boodskap</translation>
    </message>
    <message>
        <source>Transaction ID</source>
        <translation>Transaksie ID</translation>
    </message>
    <message>
        <source>Amount</source>
        <translation>Bedrag</translation>
    </message>
    <message>
        <source>true</source>
        <translation>waar</translation>
    </message>
    <message>
        <source>false</source>
        <translation>onwaar</translation>
    </message>
    <message>
        <source>unknown</source>
        <translation>onbekend</translation>
    </message>
</context>
<context>
    <name>TransactionDescDialog</name>
    </context>
<context>
    <name>TransactionTableModel</name>
    <message>
        <source>Date</source>
        <translation>Datum</translation>
    </message>
    <message>
        <source>Type</source>
        <translation>Tipe</translation>
    </message>
    <message>
        <source>Address</source>
        <translation>Adres</translation>
    </message>
    <message>
        <source>Received with</source>
        <translation>Ontvang met</translation>
    </message>
    <message>
        <source>Received from</source>
        <translation>Ontvang van</translation>
    </message>
    <message>
        <source>Sent to</source>
        <translation>Gestuur na</translation>
    </message>
    <message>
        <source>Payment to yourself</source>
        <translation>Betalings Aan/na jouself</translation>
    </message>
    <message>
        <source>Mined</source>
        <translation>Gemyn</translation>
    </message>
    <message>
        <source>(n/a)</source>
        <translation>(n.v.t)</translation>
    </message>
    <message>
        <source>Date and time that the transaction was received.</source>
        <translation>Datum en tyd wat die transaksie ontvang was.</translation>
    </message>
    <message>
        <source>Type of transaction.</source>
        <translation>Tipe transaksie.</translation>
    </message>
    </context>
<context>
    <name>TransactionView</name>
    <message>
        <source>All</source>
        <translation>Alles</translation>
    </message>
    <message>
        <source>Today</source>
        <translation>Vandag</translation>
    </message>
    <message>
        <source>This week</source>
        <translation>Hierdie week</translation>
    </message>
    <message>
        <source>This month</source>
        <translation>Hierdie maand</translation>
    </message>
    <message>
        <source>Last month</source>
        <translation>Verlede maand</translation>
    </message>
    <message>
        <source>This year</source>
        <translation>Hierdie jaar</translation>
    </message>
    <message>
        <source>Range...</source>
        <translation>Reeks...</translation>
    </message>
    <message>
        <source>Received with</source>
        <translation>Ontvang met</translation>
    </message>
    <message>
        <source>Sent to</source>
        <translation>Gestuur na</translation>
    </message>
    <message>
        <source>To yourself</source>
        <translation>Aan/na jouself</translation>
    </message>
    <message>
        <source>Mined</source>
        <translation>Gemyn</translation>
    </message>
    <message>
        <source>Other</source>
        <translation>Ander</translation>
    </message>
    <message>
        <source>Min amount</source>
        <translation>Min bedrag</translation>
    </message>
    <message>
        <source>Copy address</source>
        <translation>Maak kopie van adres</translation>
    </message>
    <message>
        <source>Copy amount</source>
        <translation>Kopieer bedrag</translation>
    </message>
    <message>
        <source>Date</source>
        <translation>Datum</translation>
    </message>
    <message>
        <source>Type</source>
        <translation>Tipe</translation>
    </message>
    <message>
        <source>Label</source>
        <translation>Etiket</translation>
    </message>
    <message>
        <source>Address</source>
        <translation>Adres</translation>
    </message>
    <message>
        <source>ID</source>
        <translation>ID</translation>
    </message>
    <message>
        <source>Range:</source>
        <translation>Reeks:</translation>
    </message>
    <message>
        <source>to</source>
        <translation>aan</translation>
    </message>
</context>
<context>
    <name>UnitDisplayStatusBarControl</name>
    </context>
<context>
    <name>WalletFrame</name>
    </context>
<context>
    <name>WalletModel</name>
    <message>
        <source>Send Coins</source>
        <translation>Stuur Munstukke</translation>
    </message>
</context>
<context>
    <name>WalletView</name>
    </context>
<context>
    <name>bitcoin-core</name>
    <message>
        <source>Options:</source>
        <translation>Opsies:</translation>
    </message>
    <message>
        <source>Use the test network</source>
        <translation>Gebruik die toets netwerk</translation>
    </message>
    <message>
        <source>Error: Disk space is low!</source>
        <translation>Fout: Hardeskyf spasie is baie laag!</translation>
    </message>
    <message>
        <source>Information</source>
        <translation>Informasie</translation>
    </message>
    <message>
        <source>This help message</source>
        <translation>Hierdie help boodskap</translation>
    </message>
    <message>
        <source>Loading addresses...</source>
        <translation>Laai adresse...</translation>
    </message>
    <message>
        <source>Insufficient funds</source>
        <translation>Onvoldoende fondse</translation>
    </message>
    <message>
        <source>Loading block index...</source>
        <translation>Laai blok indeks...</translation>
    </message>
    <message>
        <source>Loading wallet...</source>
        <translation>Laai beursie...</translation>
    </message>
    <message>
        <source>Done loading</source>
        <translation>Klaar gelaai</translation>
    </message>
    <message>
        <source>Error</source>
        <translation>Fout</translation>
    </message>
</context>
</TS>


text:
% Example file listing config files.
% Replace this with your own config files and copy to $REGULUS/Prolog/config_files.pl

% file("Toy1Course", '$REGULUS/Examples/Toy1Course/scripts/toy1_course.cfg').
file("Toy1Course", 'H:/Prive/Regulus/Examples/Toy1Course/scripts/toy1_course.cfg').
file("Toy1", '$REGULUS/Examples/Toy1/scripts/toy1.cfg').
file("Toy1 Fre", '$REGULUS/Examples/Toy1/scripts/french.cfg').
file("Toy1 EngFre", '$REGULUS/Examples/Toy1/scripts/toy1_slt_batch.cfg', "LOAD", "LOAD_TRANSLATE").
file("Toy1 Specialised", '$REGULUS/Examples/Toy1Specialised/scripts/toy1_specialised.cfg').

/*
file("MedSLT EngFre Headache", '$MED_SLT2/EngFre/Prolog/med_new_interlingua.cfg', "EBL_LOAD", "LOAD_TRANSLATE").
file("MedSLT FreEng Headache", '$MED_SLT2/FreEng/Prolog/med.cfg').
file("MedSLT EngJap Headache", '$MED_SLT2/EngJap/Prolog/med_new_interlingua.cfg', "EBL_LOAD", "LOAD_TRANSLATE").
file("MedSLT EngAra Headache", '$MED_SLT2/EngAra/Prolog/med.cfg', "EBL_LOAD", "LOAD_TRANSLATE").
file("MedSLT EngSpa Sore Throat",
     '$MED_SLT2/EngSpa/Prolog/med_sore_throat_merged.cfg',
     "EBL_LOAD", "LOAD_TRANSLATE", "TRANSLATE",
     "BIDIRECTIONAL_ON",
     "A: EBL_LOAD", "A: LOAD_TRANSLATE", "A: TRANSLATE", "A: ANSWER_ELLIPSIS_ON").
file("MedSLT EngSpa Sore Throat Restricted",
     '$MED_SLT2/EngSpa/Prolog/med_sore_throat_restricted_merged.cfg',
     "EBL_LOAD", "LOAD_TRANSLATE", "TRANSLATE",
     "BIDIRECTIONAL_ON",
     "A: EBL_LOAD", "A: LOAD_TRANSLATE", "A: TRANSLATE", "A: ANSWER_ELLIPSIS_ON").
file("MedSLT SpaEng Sore Throat",
     '$MED_SLT2/SpaEng/Prolog/med.cfg').
file("MedSLT Spa Recognition Q",
     '$MED_SLT2/Spa/scripts/merged_spa_recognition.cfg',
     "EBL_ANALYSIS").
file("MedSLT Spa Recognition A",
     '$MED_SLT2/Spa/scripts/merged_spa_recognition_answers.cfg',
     "EBL_ANALYSIS").
file("MedSLT Spa Generation Q",
     '$MED_SLT2/Spa/scripts/merged_spa_generation.cfg',
     "EBL_ANALYSIS").
file("MedSLT Spa Generation A",
     '$MED_SLT2/Spa/scripts/merged_spa_generation_answers.cfg',
     "EBL_ANALYSIS").
*/