code stringlengths 3 1.05M | repo_name stringlengths 4 116 | path stringlengths 4 991 | language stringclasses 9 values | license stringclasses 15 values | size int32 3 1.05M |
|---|---|---|---|---|---|
from planarprocess import *
from gds_helpers import *
from itertools import cycle
xmin, xmax = -5, 5
layers = gds_cross_section('mypmos.gds', [(0,xmin), (0, xmax)], 'gdsmap.map')
['P-Active-Well', 'Active-Cut', 'N-Well', 'Metal-2', 'Metal-1', 'P-Select',
'N-Select', 'Transistor-Poly', 'Via1']
wafer = Wafer(1., 5., 0, xmax - xmin)
# N-Well
nw = layers['N-Well']
wafer.implant(.7, nw, outdiffusion=5., label='N-Well')
# Field and gate oxides
de = layers['P-Active-Well']
# TODO: channel stop under field oxide
fox = wafer.grow(.5, wafer.blank_mask().difference(de),
y_offset=-.2, outdiffusion=.1)
gox = wafer.grow(.05, de, outdiffusion=.05, base=wafer.wells,
label='Gate oxide')
# Gate poly and N+/P+ implants
gp = layers['Transistor-Poly']
poly = wafer.grow(.25, gp, outdiffusion=.25, label='Gate poly')
np = layers['N-Select'].intersection(
layers['P-Active-Well']).difference(gp)
nplus = wafer.implant(.1, np, outdiffusion=.1, target=wafer.wells, source=gox,
label='N+')
pp = layers['P-Select'].intersection(
layers['P-Active-Well']).difference(gp)
pplus = wafer.implant(.1, pp, outdiffusion=.1, target=wafer.wells, source=gox,
label='P+')
# Multi-level dielectric and contacts
mld_thickness = .5
mld = wafer.grow(mld_thickness, wafer.blank_mask(), outdiffusion=.1)
ct = layers['Active-Cut']
contact = wafer.grow(-mld_thickness*1.1, ct, consuming=[mld, gox], base=wafer.air,
outdiffusion=.05, outdiffusion_vertices=3)
# Metals and vias
m1 = layers['Metal-1']
metal1 = wafer.grow(.6, m1, outdiffusion=.1, label='Metal-1')
ild_thickness = 1.2
ild1 = wafer.grow(ild_thickness, wafer.blank_mask(), outdiffusion=.1)
wafer.planarize()
v1 = layers['Via1']
via1 = wafer.grow(-ild_thickness*1.1, v1, consuming=[ild1], base=wafer.air,
outdiffusion=.05, outdiffusion_vertices=3)
m2 = layers['Metal-2']
metal2 = wafer.grow(1., m2, outdiffusion=.1, label='Metal-2')
# Presentation
custom_style = {s: {} for s in wafer.solids}
for solid, color in {
fox: '.4', gox: 'r', poly: 'g', mld: 'k',
ild1: '.3', contact: '.5', via1: '.5',
metal1: '.7', metal2: '.8'}.items():
custom_style[solid].update(dict(facecolor=color, edgecolor='k'))
for solid in wafer.solids:
if solid not in wafer.wells:
custom_style[solid].update(dict(hatch=None, fill=True))
base_hatches = r'\/' # r'/\|-+xoO.*'
hatches = cycle(list(base_hatches) + [h1+h2 for h1 in base_hatches
for h2 in base_hatches])
colors = cycle('krgbcmy')
plot_geometryref(wafer.air, hatch='.', fill=False, linewidth=0, color=(.9,.9,.9),
zorder=-100)
zorder = -99
for solid in wafer.solids:
style = dict(hatch=next(hatches), fill=False,
edgecolor=next(colors), zorder=zorder)
zorder += 1
style.update(custom_style.get(solid, {}))
plot_geometryref(solid, **style)
pyplot.legend()
pyplot.savefig('mypmos-x.png')
pyplot.show()
| ignamv/PlanarProcess | test.py | Python | gpl-3.0 | 2,927 |
app
.service('LanguageService', function LanguageService(ExchangeService) {
this.translate = (label) => ExchangeService.i18n().__(label);
});
| Kagurame/LuaSB | src/app/ui/services/LanguageService.js | JavaScript | gpl-3.0 | 150 |
package tools.renamers;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import tools.EntryPoint;
import tools.Tool;
import tools.utils.EnumerationIterator;
import tools.utils.MappingUtils;
import tools.utils.Utils;
public class AllClassesRenamer implements Tool {
@Override
public void run() {
String args[] = EntryPoint.getArgs();
String inputJarFileName = args[0];
String outputSrgMappingsFileName = args[1];
try (
PrintWriter outputSrgMappingWriter = new PrintWriter(outputSrgMappingsFileName);
JarFile inputJarFile = new JarFile(inputJarFileName)
) {
for (JarEntry jarEntry : new EnumerationIterator<>(inputJarFile.entries())) {
if (jarEntry.isDirectory() || !jarEntry.getName().endsWith(".class")) {
continue;
}
String original = Utils.stripClassEnding(jarEntry.getName());
String[] pathAndName = original.split("[/]");
String path = pathAndName.length > 1 ? String.join("/", Arrays.copyOf(pathAndName, pathAndName.length - 1)) : null;
String remappedname = String.join("$", rename(pathAndName[pathAndName.length - 1].split("[$]")));
String remapped = path == null ? remappedname : path + "/" + remappedname;
outputSrgMappingWriter.println(MappingUtils.createSRG(original, remapped));
}
} catch (Throwable t) {
t.printStackTrace();
}
}
private static String[] rename(String[] elements) {
for (int i = 0; i < elements.length; i++) {
if (i == 0) {
elements[i] = "class_" + elements[i];
} else {
elements[i] = "class_" + elements[i] + "_in_" + elements[i - 1];
}
}
return elements;
}
}
| MCCarbon/DecompileTools | src/tools/renamers/AllClassesRenamer.java | Java | gpl-3.0 | 1,654 |
#include "gradientwidget.h"
#include "ui_gradientwidget.h"
GradientWidget::GradientWidget(QWidget *parent) :
AbstractWidget(parent),
ui(new Ui::GradientWidget)
{
ui->setupUi(this);
connect(ui->nextButton,SIGNAL(clicked(bool)),this,SLOT(nextClick(bool)));
hide();
}
GradientWidget::~GradientWidget()
{
delete ui;
}
void GradientWidget::showEvent(QShowEvent *)
{
ui->graphicsView->setScene(new QGraphicsScene);
}
void GradientWidget::execute()
{
module.mod_main();
m_picture renPic;
renPic.width = module.p_width;
renPic.height = module.p_height;
renPic.data = module.HDR;
ui->graphicsView->scene()->addPixmap(QPixmap::fromImage(picToImg(renPic)));
ui->graphicsView->scene()->update();
}
| LuisHsu/HDRI-Project | gradientwidget.cpp | C++ | gpl-3.0 | 746 |
/*
* Copyright 2016 Takashi Inoue
*
* This file is part of EzPuzzles.
*
* EzPuzzles is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EzPuzzles is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EzPuzzles. If not, see <http://www.gnu.org/licenses/>.
*/
#include "WallPiece.h"
namespace MineSweeper {
bool WallPiece::isOpened() const
{
return true;
}
bool WallPiece::isLocked() const
{
return true;
}
bool WallPiece::isMine() const
{
return false;
}
bool WallPiece::isNearMine() const
{
return false;
}
bool WallPiece::isWall() const
{
return true;
}
int WallPiece::countAroundMines() const
{
return 0;
}
} // MineSweeper
| Takashi-Inoue/EzPuzzles | MineSweeper/WallPiece.cpp | C++ | gpl-3.0 | 1,120 |
<?php
// Text
$_['text_success'] = 'Succes: Ai modificat coșul tău de cumpărături!';
// Error
$_['error_permission'] = 'Atenție: Nu ai permisiunile necesare pentru a accesa API-ul!';
$_['error_stock'] = 'Produsele marcate cu *** nu sunt disponibile în cantitatea dorită sau nu sunt în stoc deloc!';
$_['error_minimum'] = 'Cantitatea minima de %s ce poate fi comandată este %s!';
$_['error_store'] = 'Produsul nu poate fi cumpărat de la magazinul selectat!';
$_['error_required'] = '%s este obligatoriu!'; | Ozi94/opencart | upload/catalog/language/ro-ro/api/cart.php | PHP | gpl-3.0 | 534 |
#include "camera.h"
#include "../window.h"
D3DXMATRIX Camera::GetViewMatrix()
{
if (recalculateViewMatrix)
updateViewMatrix();
return viewMatrix;
}
D3DXMATRIX Camera::GetProjectionMatrix()
{
if (recalculateProjectionMatrix)
updateProjectionMatrix();
return projectionMatrix;
}
D3DXVECTOR3 Camera::ScreenPointToWorldDirection(D3DXVECTOR2& point)
{
if (recalculateProjectionMatrix)
updateProjectionMatrix();
if (recalculateViewMatrix)
updateViewMatrix();
float px = point.x, py = point.y;
D3DXMATRIX proj = GetProjectionMatrix();
px = 2.0f * px / Window::GetWidth() - 1.0f;
py = -2.0f * py / Window::GetHeight() + 1.0f;
px /= proj._11;//proj matrix actually
py /= proj._22;
D3DXMatrixInverse(&proj, null, &GetViewMatrix());
D3DXVECTOR3 dir;
dir.x = (px * proj._11) + (py * proj._21) + proj._31;
dir.y = (px * proj._12) + (py * proj._22) + proj._32;
dir.z = (px * proj._13) + (py * proj._23) + proj._33;
D3DXVec3Normalize(&dir, &dir);
return dir;
} | XZelnar/Simplex | Graphics/camera.cpp | C++ | gpl-3.0 | 1,019 |
from setuptools import setup, find_packages
setup(
name = "CyprjToMakefile",
version = "0.1",
author = "Simon Marchi",
author_email = "simon.marchi@polymtl.ca",
description = "Generate Makefiles from Cypress cyprj files.",
license = "GPLv3",
url = "https://github.com/simark/cyprj-to-makefile",
packages = find_packages(),
install_requires = ['jinja2'],
package_data = {
'cyprj_to_makefile': ['Makefile.tpl'],
},
entry_points = {
'console_scripts': [
'cyprj-to-makefile = cyprj_to_makefile.cyprj_to_makefile:main',
],
},
)
| simark/cyprj-to-makefile | setup.py | Python | gpl-3.0 | 576 |
package ft.sim.monitoring;
import static ft.sim.monitoring.ViolationSeverity.*;
import static ft.sim.monitoring.ViolationType.*;
import ft.sim.world.train.Train;
import ft.sim.world.connectables.Connectable;
import ft.sim.world.connectables.Section;
import ft.sim.world.connectables.Station;
import ft.sim.world.connectables.Switch;
import ft.sim.world.connectables.Track;
/**
* Created by sina on 10/04/2017.
*/
public class ViolationBuilder {
public static void createTrainCrashViolation(Oracle o, Train t1, Train t2, Section section) {
int idTrain1 = o.getWorld().getTrainID(t1);
int idTrain2 = o.getWorld().getTrainID(t2);
int trackID = o.getWorld().getTrackIDforSection(section);
int sectionID = o.getWorld().getTrack(trackID).getSectionPosition(section);
String violationDescription = String
.format("Train %s and Train %s were on the same Section %s on track %s",
idTrain1, idTrain2, sectionID, trackID);
o.addViolation(new Violation(CRASH, CRITICAL, o.getTick(), violationDescription));
}
public static void createFixedBlockViolation(Oracle o, Train t1, Train t2,
Connectable connectable) {
String connectableName = "Unknown";
if (connectable instanceof Track) {
connectableName = "Track-" + o.getWorld().getTrackID((Track) connectable);
} else if (connectable instanceof Switch) {
connectableName = "Switch-" + o.getWorld().getSwitchID((Switch) connectable);
}
String violationDescription = String
.format("Train %s and Train %s were on the same Connectable %s",
o.getWorld().getTrainID(t1), o.getWorld().getTrainID(t2), connectableName);
o.addViolation(new Violation(FIXED_BLOCK, CRITICAL, o.getTick(), violationDescription));
}
public static void createVariableBlockViolation(Oracle o, Train t1, Train t2, double distance) {
String violationDescription = String.format(
"Train %s and Train %s were within less than braking distance from each other (%s)",
o.getWorld().getTrainID(t1), o.getWorld().getTrainID(t2), distance);
o.addViolation(new Violation(VARIABLE_BLOCK, HIGH, o.getTick(), violationDescription));
}
public static void createOverfullStationViolation(Oracle o, Station station) {
int stationID = o.getWorld().getStationID(station);
String violationDescription = String
.format("Station %s is over capacity (%s out of %s)",
stationID, station.usedCapacity(), station.getCapacity());
o.addViolation(new Violation(OVERFULL_STATION, CRITICAL, o.getTick(), violationDescription));
}
}
| sinaa/train-simulator | src/main/java/ft/sim/monitoring/ViolationBuilder.java | Java | gpl-3.0 | 2,596 |
package net.ess3.commands;
import net.ess3.api.IUser;
public class Commandworkbench extends EssentialsCommand
{
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
user.getPlayer().openWorkbench(null, true);
}
}
| Curtis3321/Essentials | Essentials/src/net/ess3/commands/Commandworkbench.java | Java | gpl-3.0 | 280 |
/**
* Created by ken_kilgore1 on 1/11/2015.
*/
jQuery(document).ready(function ($) {
$("#spouse_info").hide();
$("#spouse_spacer").hide();
$("#family_info").hide();
$("#family_spacer").hide();
$("input:radio[name$='memb_type']").click(function () {
if ($("input[name$='memb_type']:checked").val() === 1) {
$("#spouse_info").hide();
$("#spouse_spacer").hide();
$("#family_info").hide();
$("#family_spacer").hide();
} else if ($("input[name$='memb_type']:checked").val() === 2) {
$("#spouse_info").hide();
$("#spouse_spacer").hide();
$("#family_info").show();
$("#family_spacer").show();
} else if ($("input[name$='memb_type']:checked").val() === 3) {
$("#spouse_spacer").show();
$("#spouse_info").show();
$("#family_info").hide();
$("#family_spacer").hide();
} else if ($("input[name$='memb_type']:checked").val() === 4) {
$("#spouse_info").show();
$("#spouse_spacer").show();
$("#family_info").show();
$("#family_spacer").show();
}
});
}); | ctxphc/beach-holiday | includes/js/mp-show-hide-script.js | JavaScript | gpl-3.0 | 1,199 |
// ****************************************************************************
// compiler-llvm.cpp XLR project
// ****************************************************************************
//
// File Description:
//
// The interface between the compiler and LLVM
//
//
//
//
//
//
//
//
// ****************************************************************************
// This document is released under the GNU General Public License, with the
// following clarification and exception.
//
// Linking this library statically or dynamically with other modules is making
// a combined work based on this library. Thus, the terms and conditions of the
// GNU General Public License cover the whole combination.
//
// As a special exception, the copyright holders of this library give you
// permission to link this library with independent modules to produce an
// executable, regardless of the license terms of these independent modules,
// and to copy and distribute the resulting executable under terms of your
// choice, provided that you also meet, for each linked independent module,
// the terms and conditions of the license of that module. An independent
// module is a module which is not derived from or based on this library.
// If you modify this library, you may extend this exception to your version
// of the library, but you are not obliged to do so. If you do not wish to
// do so, delete this exception statement from your version.
//
// See http://www.gnu.org/copyleft/gpl.html and Matthew 25:22 for details
// (C) 1992-2010 Christophe de Dinechin <christophe@taodyne.com>
// (C) 2010 Taodyne SAS
// ****************************************************************************
#include "compiler.h"
#include "compiler-llvm.h"
XL_BEGIN
// ============================================================================
//
// Define all the LLVM wrappers
//
// ============================================================================
#define UNARY(name) \
static llvm_value xl_llvm_##name(llvm_builder bld, llvm_value *args) \
{ \
return bld->Create##name(args[0]); \
}
#define BINARY(name) \
static llvm_value xl_llvm_##name(llvm_builder bld, llvm_value *args) \
{ \
return bld->Create##name(args[0], args[1]); \
}
#include "llvm.tbl"
CompilerLLVMTableEntry CompilerLLVMTable[] =
// ----------------------------------------------------------------------------
// A table initialized with the various LLVM entry points
// ----------------------------------------------------------------------------
{
#define UNARY(name) { #name, xl_llvm_##name, 1 },
#define BINARY(name) { #name, xl_llvm_##name, 2 },
#include "llvm.tbl"
// Terminator
{ NULL, NULL, 0 }
};
XL_END
| trustifier/xlr | xlr/compiler-llvm.cpp | C++ | gpl-3.0 | 3,098 |
/**
* Copyright (C) Intersect 2012.
*
* This module contains Proprietary Information of Intersect,
* and should be treated as Confidential.
*/
package au.org.intersect.exsite9.service;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.stub;
import static org.mockito.Mockito.when;
import java.io.File;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import au.org.intersect.exsite9.dao.DAOTest;
import au.org.intersect.exsite9.dao.factory.MetadataAttributeDAOFactory;
import au.org.intersect.exsite9.dao.factory.MetadataCategoryDAOFactory;
import au.org.intersect.exsite9.dao.factory.SchemaDAOFactory;
import au.org.intersect.exsite9.domain.MetadataCategory;
import au.org.intersect.exsite9.domain.MetadataCategoryType;
import au.org.intersect.exsite9.domain.MetadataCategoryUse;
import au.org.intersect.exsite9.domain.MetadataValue;
import au.org.intersect.exsite9.domain.Schema;
/**
* Tests {@link SchemaService}
*/
public final class SchemaServiceUnitTest extends DAOTest
{
@Test
public void testCreateLocalSchema()
{
final EntityManagerFactory emf = mock(EntityManagerFactory.class);
when(emf.createEntityManager()).thenReturn(createEntityManager());
final File defaultSchemaDir = new File("defaultSchemaDir");
final File defaultSchemaFile = new File("defaultSchemaFile");
final File metadataSchemaSchema = new File("metadataSchemaSchema");
final SchemaDAOFactory schemaDAOFactory = new SchemaDAOFactory();
final MetadataCategoryDAOFactory metadataCategoryDAOFactory = new MetadataCategoryDAOFactory();
final MetadataAttributeDAOFactory metadataAttributeDAOFactory = new MetadataAttributeDAOFactory();
final SchemaService toTest = new SchemaService(defaultSchemaDir, defaultSchemaFile, metadataSchemaSchema, emf, schemaDAOFactory, metadataCategoryDAOFactory, metadataAttributeDAOFactory);
assertEquals(defaultSchemaFile, toTest.getDefaultSchema());
assertEquals(defaultSchemaDir, toTest.getDefaultSchemaDirectory());
final Schema schema = toTest.createLocalSchema("name", "description", "namespace url");
assertNotNull(schema.getId());
assertTrue(schema.getLocal());
assertEquals("name", schema.getName());
assertEquals("description", schema.getDescription());
assertEquals("namespace url", schema.getNamespaceURL());
}
@Test
public void testCreateImportedSchema()
{
final EntityManagerFactory emf = mock(EntityManagerFactory.class);
when(emf.createEntityManager()).thenReturn(createEntityManager());
final File defaultSchemaDir = new File("defaultSchemaDir");
final File defaultSchemaFile = new File("defaultSchemaFile");
final File metadataSchemaSchema = new File("metadataSchemaSchema");
final SchemaDAOFactory schemaDAOFactory = new SchemaDAOFactory();
final MetadataCategoryDAOFactory metadataCategoryDAOFactory = new MetadataCategoryDAOFactory();
final MetadataAttributeDAOFactory metadataAttributeDAOFactory = new MetadataAttributeDAOFactory();
final SchemaService toTest = new SchemaService(defaultSchemaDir, defaultSchemaFile, metadataSchemaSchema, emf, schemaDAOFactory, metadataCategoryDAOFactory, metadataAttributeDAOFactory);
final Schema importedSchema = new Schema("name", "desc", "namespace url", Boolean.FALSE);
final MetadataCategory mdc = new MetadataCategory("category", MetadataCategoryType.FREETEXT, MetadataCategoryUse.optional);
final MetadataValue mdv = new MetadataValue("metadata value");
mdc.getValues().add(mdv);
importedSchema.getMetadataCategories().add(mdc);
toTest.createImportedSchema(importedSchema);
assertNotNull(importedSchema.getId());
}
@Test
public void testUpdateSchema()
{
final EntityManagerFactory emf = mock(EntityManagerFactory.class);
stub(emf.createEntityManager()).toAnswer(new Answer<EntityManager>()
{
@Override
public EntityManager answer(final InvocationOnMock invocation) throws Throwable
{
return createEntityManager();
}
});
final File defaultSchemaDir = new File("defaultSchemaDir");
final File defaultSchemaFile = new File("defaultSchemaFile");
final File metadataSchemaSchema = new File("metadataSchemaSchema");
final SchemaDAOFactory schemaDAOFactory = new SchemaDAOFactory();
final MetadataCategoryDAOFactory metadataCategoryDAOFactory = new MetadataCategoryDAOFactory();
final MetadataAttributeDAOFactory metadataAttributeDAOFactory = new MetadataAttributeDAOFactory();
final SchemaService toTest = new SchemaService(defaultSchemaDir, defaultSchemaFile, metadataSchemaSchema, emf, schemaDAOFactory, metadataCategoryDAOFactory, metadataAttributeDAOFactory);
final Schema schema = toTest.createLocalSchema("name", "description", "namespace url");
assertNotNull(schema.getId());
assertTrue(schema.getLocal());
assertEquals("name", schema.getName());
assertEquals("description", schema.getDescription());
assertEquals("namespace url", schema.getNamespaceURL());
toTest.updateSchema(schema, "new name", "new description", "new namespace url");
final Schema updatedSchema = createEntityManager().find(Schema.class, schema.getId());
assertEquals("new name", updatedSchema.getName());
assertEquals("new description", updatedSchema.getDescription());
assertEquals("new namespace url", updatedSchema.getNamespaceURL());
}
@Test
public void testRemoveSchema()
{
final EntityManagerFactory emf = mock(EntityManagerFactory.class);
stub(emf.createEntityManager()).toAnswer(new Answer<EntityManager>()
{
@Override
public EntityManager answer(final InvocationOnMock invocation) throws Throwable
{
return createEntityManager();
}
});
final File defaultSchemaDir = new File("defaultSchemaDir");
final File defaultSchemaFile = new File("defaultSchemaFile");
final File metadataSchemaSchema = new File("metadataSchemaSchema");
final SchemaDAOFactory schemaDAOFactory = new SchemaDAOFactory();
final MetadataCategoryDAOFactory metadataCategoryDAOFactory = new MetadataCategoryDAOFactory();
final MetadataAttributeDAOFactory metadataAttributeDAOFactory = new MetadataAttributeDAOFactory();
final SchemaService toTest = new SchemaService(defaultSchemaDir, defaultSchemaFile, metadataSchemaSchema, emf, schemaDAOFactory, metadataCategoryDAOFactory, metadataAttributeDAOFactory);
final Schema importedSchema = new Schema("name", "desc", "namespace url", Boolean.FALSE);
final MetadataCategory mdc = new MetadataCategory("category", MetadataCategoryType.FREETEXT, MetadataCategoryUse.optional);
final MetadataValue mdv = new MetadataValue("metadata value");
mdc.getValues().add(mdv);
importedSchema.getMetadataCategories().add(mdc);
toTest.createImportedSchema(importedSchema);
assertNotNull(importedSchema.getId());
toTest.removeSchema(importedSchema);
assertNull(createEntityManager().find(Schema.class, importedSchema.getId()));
}
@Test
public void testAddRemoveMetadataCategory()
{
final EntityManagerFactory emf = mock(EntityManagerFactory.class);
stub(emf.createEntityManager()).toAnswer(new Answer<EntityManager>()
{
@Override
public EntityManager answer(final InvocationOnMock invocation) throws Throwable
{
return createEntityManager();
}
});
final File defaultSchemaDir = new File("defaultSchemaDir");
final File defaultSchemaFile = new File("defaultSchemaFile");
final File metadataSchemaSchema = new File("metadataSchemaSchema");
final SchemaDAOFactory schemaDAOFactory = new SchemaDAOFactory();
final MetadataCategoryDAOFactory metadataCategoryDAOFactory = new MetadataCategoryDAOFactory();
final MetadataAttributeDAOFactory metadataAttributeDAOFactory = new MetadataAttributeDAOFactory();
final SchemaService toTest = new SchemaService(defaultSchemaDir, defaultSchemaFile, metadataSchemaSchema, emf, schemaDAOFactory, metadataCategoryDAOFactory, metadataAttributeDAOFactory);
final Schema schema = toTest.createLocalSchema("name", "description", "namespace url");
assertNotNull(schema.getId());
final MetadataCategory mc = new MetadataCategory("mc", MetadataCategoryType.CONTROLLED_VOCABULARY, MetadataCategoryUse.required);
final MetadataValue mv = new MetadataValue("mv");
mc.getValues().add(mv);
toTest.addMetadataCategoryToSchema(schema, mc);
final Schema outSchema1 = createEntityManager().find(Schema.class, schema.getId());
assertEquals(1, outSchema1.getMetadataCategories().size());
toTest.removeMetadataCategoryFromSchema(schema, mc);
final Schema outSchema2 = createEntityManager().find(Schema.class, schema.getId());
assertEquals(0, outSchema2.getMetadataCategories().size());
}
}
| IntersectAustralia/exsite9 | exsite9/test/au/org/intersect/exsite9/service/SchemaServiceUnitTest.java | Java | gpl-3.0 | 9,680 |
package com.esd.phicomm.bruce.esdapp;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
/**
* Created by Bruce on 2017/1/4.
*/
class Gpio {
private String port;
public boolean output(int value) {
String command = String.format("echo %d > /sys/class/gpio_sw/%s/data\n", value, port);
try {
Runtime.getRuntime().exec(new String[] {"su", "-c", command});
return true;
} catch (IOException e) {
return false;
}
}
private String readinput(){
Process p;
String command = String.format("cat /sys/class/gpio_sw/%s/data\n", port);
try {
p = Runtime.getRuntime().exec("su");
DataOutputStream outputStream = new DataOutputStream(p.getOutputStream());
outputStream.write(command.getBytes());
outputStream.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder text = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
text.append(line);
break;
}
reader.close();
return text.toString();
} catch (IOException e) {
return "";
}
}
public boolean setcfg(int cfg){
String command = String.format("echo %d > /sys/class/gpio_sw/%s/cfg\n", cfg, port);
try {
Runtime.getRuntime().exec(new String[] {"su", "-c", command});
return true;
} catch (IOException e) {
return false;
}
}
private String readcfg(){
Process p;
String command = String.format("cat /sys/class/gpio_sw/%s/cfg\n", port);
try {
p = Runtime.getRuntime().exec(new String[] {"su", "-c", command});
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuilder text = new StringBuilder();
String line;
while((line = reader.readLine()) != null){
text.append(line);
text.append("\n");
}
return text.toString();
} catch (IOException e) {
return "";
}
}
public int input(){
char ch;
String cfg;
cfg = readinput();
if(cfg.isEmpty())
return -1;
else{
ch = cfg.charAt(0);
if(Character.isDigit(ch))
return Character.getNumericValue(ch);
else
return -1;
}
}
public int getcfg(){
char ch;
String cfg;
cfg = readcfg();
if(cfg.isEmpty())
return -1;
else{
ch = cfg.charAt(0);
if(Character.isDigit(ch))
return Character.getNumericValue(ch);
else
return -1;
}
}
//Constructor
Gpio(String port){
this.port = port;
}
}
| bruce-wei/EsdApp | app/src/main/java/com/esd/phicomm/bruce/esdapp/Gpio.java | Java | gpl-3.0 | 3,231 |
/**
* @file GeneticAlgorithm.hpp
* @author Renato Oliveira (renatorro@comp.ufla.br)
* @version 1.0
* @since GeneticNet 1.0
* @date 10/07/2012
*/
#ifndef GRUBI_GENETICNET_GENETICALGORITHM_HPP_INCLUDED
#define GRUBI_GENETICNET_GENETICALGORITHM_HPP_INCLUDED
#include <iostream>
#include <cstdlib>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/string.hpp>
#include "AbstractMetaheuristic.hpp"
#include "ResultManager.hpp"
#include "Solution.hpp"
#include "SensorNetwork.hpp"
#include <GMPI/Logger.hpp>
namespace geneticnet {
namespace GA {
class Setup;
}
/**
* @brief Implements the canonical Genetic Algorithm.
*/
class GeneticAlgorithm : public AbstractMetaheuristic {
public:
GeneticAlgorithm();
GeneticAlgorithm(GA::Setup* gaSetup);
GeneticAlgorithm(boost::archive::xml_iarchive& input);
~GeneticAlgorithm();
virtual void execute(ResultManager * results = NULL);
virtual void save_setup_to_xml(boost::archive::xml_oarchive& output);
virtual void load_setup_from_xml(boost::archive::xml_iarchive& input);
Solution* tournment(Solution** population);
protected:
GA::Setup *setup;
};
/// The Genetic Algorithm specific structures.
namespace GA {
/**
* @brief This is a bean class for the Genetic Algorithm's execution parameters.
*/
class Setup {
friend class geneticnet::AbstractMetaheuristic;
friend class geneticnet::GeneticAlgorithm;
friend class boost::serialization::access;
public:
/// Constructs the setup and define default values for all parameters.
Setup() {
this->populationSize = 8;
this->maximumGenerations = 1000000;
this->maximumExecutionTime = 3600.0;
this->crossoverRate = 0.7;
this->mutationRate = 0.05;
this->elitism = true;
this->tournmentSize = 3;
this->instanceFilename = "";
}
/// Destruct parameters, if necessary.
~Setup() {}
protected:
/// Number of individuals in the population.
int populationSize;
/// Maximum number of population's generations.
int maximumGenerations;
/// Maximum execution time (real time) for the Genetic Algorithm.
double maximumExecutionTime;
/// The rate to apply crossover to generate the new individual.
double crossoverRate;
/// The rate to apply mutation to the new generated individual.
double mutationRate;
/// Use elitism criterias?
bool elitism;
/// Number of individuals selected to tournment.
int tournmentSize;
/// Instance (Sensor Network) configuration file path.
std::string instanceFilename;
/// Genetic Algorithm's setup serialization.
template<class Archive>
void serialize(Archive & archive, const unsigned int version) {
archive & BOOST_SERIALIZATION_NVP(populationSize);
archive & BOOST_SERIALIZATION_NVP(maximumGenerations);
archive & BOOST_SERIALIZATION_NVP(maximumExecutionTime);
archive & BOOST_SERIALIZATION_NVP(crossoverRate);
archive & BOOST_SERIALIZATION_NVP(mutationRate);
archive & BOOST_SERIALIZATION_NVP(elitism);
archive & BOOST_SERIALIZATION_NVP(tournmentSize);
archive & BOOST_SERIALIZATION_NVP(instanceFilename);
}
};
}
}
BOOST_CLASS_VERSION(geneticnet::GA::Setup, 1)
#endif
| renatorroliveira/dissertacao | src/GeneticAlgorithm/GeneticAlgorithm.hpp | C++ | gpl-3.0 | 3,334 |
<?php
require_once("../config.php");
$res= new PDO($mysql_server,$mysql_user,$mysql_pass);
require("../../codebase/tree_connector.php");
$tree = new TreeConnector($res, "PDO");
//
$tree->dynamic_loading(true);
$tree->render_table("tasks","taskId","taskName","","parentId");
?> | DHTMLX/connector-php | samples/tree/02_dynamic_loading_connector.php | PHP | gpl-3.0 | 296 |
/*****************************
* advance_settings_menu.cpp *
*****************************/
/****************************************************************************
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/
#include "../config.h"
#if ENABLED(TOUCH_UI_FTDI_EVE) && !defined(TOUCH_UI_LULZBOT_BIO)
#include "screens.h"
using namespace FTDI;
using namespace ExtUI;
using namespace Theme;
void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
if (what & BACKGROUND) {
CommandProcessor cmd;
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
.cmd(CLEAR(true,true,true));
}
#ifdef TOUCH_UI_PORTRAIT
#if EITHER(HAS_CASE_LIGHT, SENSORLESS_HOMING)
#define GRID_ROWS 9
#else
#define GRID_ROWS 8
#endif
#define GRID_COLS 2
#define RESTORE_DEFAULTS_POS BTN_POS(1,1), BTN_SIZE(2,1)
#define DISPLAY_POS BTN_POS(1,2), BTN_SIZE(1,1)
#define INTERFACE_POS BTN_POS(2,2), BTN_SIZE(1,1)
#define ZPROBE_ZOFFSET_POS BTN_POS(1,3), BTN_SIZE(1,1)
#define STEPS_PER_MM_POS BTN_POS(2,3), BTN_SIZE(1,1)
#define FILAMENT_POS BTN_POS(1,4), BTN_SIZE(1,1)
#define VELOCITY_POS BTN_POS(2,4), BTN_SIZE(1,1)
#define TMC_CURRENT_POS BTN_POS(1,5), BTN_SIZE(1,1)
#define ACCELERATION_POS BTN_POS(2,5), BTN_SIZE(1,1)
#define ENDSTOPS_POS BTN_POS(1,6), BTN_SIZE(1,1)
#define JERK_POS BTN_POS(2,6), BTN_SIZE(1,1)
#define OFFSETS_POS BTN_POS(1,7), BTN_SIZE(1,1)
#define BACKLASH_POS BTN_POS(2,7), BTN_SIZE(1,1)
#define CASE_LIGHT_POS BTN_POS(1,8), BTN_SIZE(1,1)
#define TMC_HOMING_THRS_POS BTN_POS(2,8), BTN_SIZE(1,1)
#if EITHER(HAS_CASE_LIGHT, SENSORLESS_HOMING)
#define BACK_POS BTN_POS(1,9), BTN_SIZE(2,1)
#else
#define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1)
#endif
#else
#define GRID_ROWS 6
#define GRID_COLS 3
#define ZPROBE_ZOFFSET_POS BTN_POS(1,1), BTN_SIZE(1,1)
#define CASE_LIGHT_POS BTN_POS(1,4), BTN_SIZE(1,1)
#define STEPS_PER_MM_POS BTN_POS(2,1), BTN_SIZE(1,1)
#define TMC_CURRENT_POS BTN_POS(3,1), BTN_SIZE(1,1)
#define TMC_HOMING_THRS_POS BTN_POS(3,2), BTN_SIZE(1,1)
#define BACKLASH_POS BTN_POS(3,3), BTN_SIZE(1,1)
#define FILAMENT_POS BTN_POS(1,3), BTN_SIZE(1,1)
#define ENDSTOPS_POS BTN_POS(3,4), BTN_SIZE(1,1)
#define DISPLAY_POS BTN_POS(3,5), BTN_SIZE(1,1)
#define INTERFACE_POS BTN_POS(1,5), BTN_SIZE(2,1)
#define RESTORE_DEFAULTS_POS BTN_POS(1,6), BTN_SIZE(2,1)
#define VELOCITY_POS BTN_POS(2,2), BTN_SIZE(1,1)
#define ACCELERATION_POS BTN_POS(2,3), BTN_SIZE(1,1)
#define JERK_POS BTN_POS(2,4), BTN_SIZE(1,1)
#define OFFSETS_POS BTN_POS(1,2), BTN_SIZE(1,1)
#define BACK_POS BTN_POS(3,6), BTN_SIZE(1,1)
#endif
if (what & FOREGROUND) {
CommandProcessor cmd;
cmd.colors(normal_btn)
.font(Theme::font_medium)
.enabled(ENABLED(HAS_BED_PROBE))
.tag(2) .button( ZPROBE_ZOFFSET_POS, GET_TEXT_F(MSG_ZPROBE_ZOFFSET))
.enabled(ENABLED(HAS_CASE_LIGHT))
.tag(16).button( CASE_LIGHT_POS, GET_TEXT_F(MSG_CASE_LIGHT))
.tag(3) .button( STEPS_PER_MM_POS, GET_TEXT_F(MSG_STEPS_PER_MM))
.enabled(ENABLED(HAS_TRINAMIC_CONFIG))
.tag(13).button( TMC_CURRENT_POS, GET_TEXT_F(MSG_TMC_CURRENT))
.enabled(ENABLED(SENSORLESS_HOMING))
.tag(14).button( TMC_HOMING_THRS_POS, GET_TEXT_F(MSG_TMC_HOMING_THRS))
.enabled(EITHER(HAS_MULTI_HOTEND, BLTOUCH))
.tag(4) .button( OFFSETS_POS, GET_TEXT_F(TERN(HAS_MULTI_HOTEND, MSG_OFFSETS_MENU, MSG_RESET_BLTOUCH)))
.enabled(EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR))
.tag(11).button( FILAMENT_POS, GET_TEXT_F(MSG_FILAMENT))
.tag(12).button( ENDSTOPS_POS, GET_TEXT_F(MSG_LCD_ENDSTOPS))
.tag(15).button( DISPLAY_POS, GET_TEXT_F(MSG_DISPLAY_MENU))
.tag(9) .button( INTERFACE_POS, GET_TEXT_F(MSG_INTERFACE))
.tag(10).button( RESTORE_DEFAULTS_POS, GET_TEXT_F(MSG_RESTORE_DEFAULTS))
.tag(5) .button( VELOCITY_POS, GET_TEXT_F(MSG_VELOCITY))
.tag(6) .button( ACCELERATION_POS, GET_TEXT_F(MSG_ACCELERATION))
.tag(7) .button( JERK_POS, GET_TEXT_F(TERN(HAS_JUNCTION_DEVIATION, MSG_JUNCTION_DEVIATION, MSG_JERK)))
.enabled(ENABLED(BACKLASH_GCODE))
.tag(8).button( BACKLASH_POS, GET_TEXT_F(MSG_BACKLASH))
.colors(action_btn)
.tag(1).button( BACK_POS, GET_TEXT_F(MSG_BACK));
}
}
bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
switch (tag) {
case 1: SaveSettingsDialogBox::promptToSaveSettings(); break;
#if HAS_BED_PROBE
case 2: GOTO_SCREEN(ZOffsetScreen); break;
#endif
case 3: GOTO_SCREEN(StepsScreen); break;
case 4:
#if HAS_MULTI_HOTEND
GOTO_SCREEN(NozzleOffsetScreen);
#elif ENABLED(BLTOUCH)
injectCommands_P(PSTR("M280 P0 S60"));
#endif
break;
case 5: GOTO_SCREEN(MaxVelocityScreen); break;
case 6: GOTO_SCREEN(DefaultAccelerationScreen); break;
case 7: GOTO_SCREEN(TERN(HAS_JUNCTION_DEVIATION, JunctionDeviationScreen, JerkScreen)); break;
#if ENABLED(BACKLASH_GCODE)
case 8: GOTO_SCREEN(BacklashCompensationScreen); break;
#endif
case 9: GOTO_SCREEN(InterfaceSettingsScreen); LockScreen::check_passcode(); break;
case 10: GOTO_SCREEN(RestoreFailsafeDialogBox); LockScreen::check_passcode(); break;
#if EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR)
case 11: GOTO_SCREEN(FilamentMenu); break;
#endif
case 12: GOTO_SCREEN(EndstopStatesScreen); break;
#if HAS_TRINAMIC_CONFIG
case 13: GOTO_SCREEN(StepperCurrentScreen); break;
#endif
#if ENABLED(SENSORLESS_HOMING)
case 14: GOTO_SCREEN(StepperBumpSensitivityScreen); break;
#endif
case 15: GOTO_SCREEN(DisplayTuningScreen); break;
#if HAS_CASE_LIGHT
case 16: GOTO_SCREEN(CaseLightScreen); break;
#endif
default: return false;
}
return true;
}
#endif // TOUCH_UI_FTDI_EVE
| KangDroid/Marlin | Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/advanced_settings_menu.cpp | C++ | gpl-3.0 | 7,646 |
<?php
/*
* This file is part of the 2amigos/yii2-usuario project.
*
* (c) 2amigOS! <http://2amigos.us/>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Da\User\Controller;
use Da\User\Query\ProfileQuery;
use Yii;
use yii\base\Module;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
class ProfileController extends Controller
{
protected $profileQuery;
/**
* ProfileController constructor.
*
* @param string $id
* @param Module $module
* @param ProfileQuery $profileQuery
* @param array $config
*/
public function __construct($id, Module $module, ProfileQuery $profileQuery, array $config = [])
{
$this->profileQuery = $profileQuery;
parent::__construct($id, $module, $config);
}
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'allow' => true,
'actions' => ['index'],
'roles' => ['@'],
],
[
'allow' => true,
'actions' => ['show'],
'roles' => ['?', '@'],
],
],
],
];
}
public function actionIndex()
{
return $this->redirect(['show', 'id' => Yii::$app->user->getId()]);
}
public function actionShow($id)
{
$profile = $this->profileQuery->whereUserId($id)->one();
if ($profile === null) {
throw new NotFoundHttpException();
}
return $this->render(
'show',
[
'profile' => $profile,
]
);
}
}
| patschwork/meta_grid | meta_grid/vendor/2amigos/yii2-usuario/src/User/Controller/ProfileController.php | PHP | gpl-3.0 | 1,984 |
/*
* Pixel Dungeon
* Copyright (C) 2012-2014 Oleg Dolya
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.watabou.legacy.items;
import java.util.ArrayList;
import com.watabou.legacy.Assets;
import com.watabou.legacy.actors.hero.Hero;
import com.watabou.legacy.effects.particles.PurpleParticle;
import com.watabou.legacy.items.armor.Armor;
import com.watabou.legacy.scenes.GameScene;
import com.watabou.legacy.sprites.ItemSpriteSheet;
import com.watabou.legacy.utils.GLog;
import com.watabou.legacy.windows.WndBag;
import com.watabou.noosa.audio.Sample;
public class Stylus extends Item {
private static final String TXT_SELECT_ARMOR = "Select an armor to inscribe on";
private static final String TXT_INSCRIBED = "you inscribed the %s on your %s";
private static final float TIME_TO_INSCRIBE = 2;
private static final String AC_INSCRIBE = "INSCRIBE";
{
name = "arcane stylus";
image = ItemSpriteSheet.STYLUS;
stackable = true;
}
@Override
public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero );
actions.add( AC_INSCRIBE );
return actions;
}
@Override
public void execute( Hero hero, String action ) {
if (action == AC_INSCRIBE) {
curUser = hero;
GameScene.selectItem( itemSelector, WndBag.Mode.ARMOR, TXT_SELECT_ARMOR );
} else {
super.execute( hero, action );
}
}
@Override
public boolean isUpgradable() {
return false;
}
@Override
public boolean isIdentified() {
return true;
}
private void inscribe( Armor armor ) {
detach( curUser.belongings.backpack );
Class<? extends Armor.Glyph> oldGlyphClass = armor.glyph != null ? armor.glyph.getClass() : null;
Armor.Glyph glyph = Armor.Glyph.random();
while (glyph.getClass() == oldGlyphClass) {
glyph = Armor.Glyph.random();
}
GLog.w( TXT_INSCRIBED, glyph.name(), armor.name() );
armor.inscribe( glyph );
curUser.sprite.operate( curUser.pos );
curUser.sprite.centerEmitter().start( PurpleParticle.BURST, 0.05f, 10 );
Sample.INSTANCE.play( Assets.SND_BURNING );
curUser.spend( TIME_TO_INSCRIBE );
curUser.busy();
}
@Override
public int price() {
return 50 * quantity;
}
@Override
public String info() {
return
"This arcane stylus is made of some dark, very hard stone. Using it you can inscribe " +
"a magical glyph on your armor, but you have no power over choosing what glyph it will be, " +
"the stylus will decide it for you.";
}
private final WndBag.Listener itemSelector = new WndBag.Listener() {
@Override
public void onSelect( Item item ) {
if (item != null) {
Stylus.this.inscribe( (Armor)item );
}
}
};
}
| sloanr333/opd-legacy | src/com/watabou/legacy/items/Stylus.java | Java | gpl-3.0 | 3,298 |
var __v=[
{
"Id": 2329,
"Chapter": 746,
"Name": "nodejs",
"Sort": 0
}
] | zuiwuchang/king-document | data/chapters/746.js | JavaScript | gpl-3.0 | 88 |
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Kalender_model extends CI_Model {
public function __construct()
{
}
public function tambah_kalender($data)
{
$this->db->insert('kalender_akademik', $data);
}
public function tampil_kalender()
{
$hasil=$this->db->get('kalender_akademik');
return $hasil->result();
}
public function hapus_kalender($data)
{
$this->db->delete('kalender_akademik', $data);
}
public function get_kalender($query)
{
$this->db->where($query);
$get = $this->db->get('kalender_akademik');
$query=$get->first_row();
return $query;
}
public function update_kalender($data)
{
$this->db->where('id_kalender',$data['id_kalender']);
$q = $this->db->update('kalender_akademik',$data);
return $q;
}
} | SisteminformasisekolahMANCibadak/Sistem-informasi-sekolah-menggunakan-framewok-codeigniter-dengan-sub-modul-akademik | aplikasi/SIA_mancib/application/models/Kalender_model.php | PHP | gpl-3.0 | 1,048 |
#!/bin/env python
# -*- coding: utf-8 -*-
PYS_SERVICE_MOD_PRE='pys_' # 模块名称的前缀
PYS_HEAD_LEN=12 # 报文头长度
PYS_MAX_BODY_LEN=10485760 # 最大报文长度
| dungeonsnd/test-code | dev_examples/pyserver/src/util/pys_define.py | Python | gpl-3.0 | 184 |
describe '/ticket/close' do
it 'should close ticket if staff member has the same department as ticket' do
Scripts.logout()
Scripts.createUser('closer@os4.com','closer','Closer')
Scripts.login('closer@os4.com','closer')
Scripts.createTicket('tickettoclose','thecontentoftickettoclose',1)
Scripts.createTicket('tickettoclose2','thecontentoftickettoclose2',3)
Scripts.createTicket('tickettoclose3','thecontentoftickettoclose3',3)
Scripts.logout()
Scripts.login($staff[:email], $staff[:password], true)
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
result = request('/ticket/close', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
(ticket['closed']).should.equal(1)
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('CLOSE')
end
it 'should close ticket if staff member does not serve to the department of the ticket but he is the author' do
request('/staff/edit', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
departments: '[1, 2]',
staffId: 1
})
Scripts.createTicket('thisisanewticket','thisisthecontentofthenewticket',3)
ticket = $database.getRow('ticket', 'thisisanewticket', 'title')
result = request('/ticket/close', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
ticket = $database.getRow('ticket', 'tickettoclose', 'title')
(ticket['closed']).should.equal(1)
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('CLOSE')
end
it 'should not close ticket if staff does not serve to the department of the ticket and he is not the author'do
ticket = $database.getRow('ticket', 'tickettoclose2', 'title')
result = request('/ticket/close', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('fail')
(result['message']).should.equal('NO_PERMISSION')
ticket = $database.getRow('ticket', 'tickettoclose2', 'title')
(ticket['closed']).should.equal(0)
request('/staff/edit', {
csrf_userid: $csrf_userid,
csrf_token: $csrf_token,
departments: '[1, 2, 3]',
staffId: 1
})
end
it 'should close ticket if User is the author' do
Scripts.logout()
Scripts.login('closer@os4.com','closer')
ticket = $database.getRow('ticket', 'tickettoclose3', 'title')
result = request('/ticket/close', {
ticketNumber: ticket['ticket_number'],
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
ticket = $database.getRow('ticket', 'tickettoclose3', 'title')
(ticket['closed']).should.equal(1)
lastLog = $database.getLastRow('log')
(lastLog['type']).should.equal('CLOSE')
Scripts.logout()
end
end
| opensupports/opensupports | tests/ticket/close.rb | Ruby | gpl-3.0 | 3,412 |
<?php
require_once('constants.php');
class TeacherConstants extends Constants{
// Teacher possible situations
const PERMANENT_SITUATION = "Permanente";
const COLLABORATOR_SITUATION = "Colaborador";
const SPECIFIC_ORIENTATION_SITUATION = "Orientação Específica";
public function getSituations(){
$situations = array(
self::PERMANENT_SITUATION => self::PERMANENT_SITUATION,
self::COLLABORATOR_SITUATION => self::COLLABORATOR_SITUATION,
self::SPECIFIC_ORIENTATION_SITUATION => self::SPECIFIC_ORIENTATION_SITUATION
);
return $situations;
}
} | fillipefeitosa/SiGA | application/constants/TeacherConstants.php | PHP | gpl-3.0 | 568 |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beans;
import dao.EstadoJpaController;
import dao.exceptions.NonexistentEntityException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import modelo.Estado;
import util.JPAUtil;
/**
*
* @author denis
*/
@ManagedBean
@RequestScoped
public class EstadoBean {
private Estado estado = new Estado();
EstadoJpaController daoEstado = new EstadoJpaController(JPAUtil.factory);
private String mensagem;
public EstadoBean() {
}
public void inserir() {
FacesContext context = FacesContext.getCurrentInstance();
try {
daoEstado.create(estado);
estado = new Estado();
} catch (Exception ex) {
context.addMessage("formEstado", new FacesMessage("Estado não pode ser inserido"));
Logger.getLogger(ViagemClienteBean.class.getName()).log(Level.SEVERE, null, ex);
}
context.addMessage("formEstado", new FacesMessage("Estado foi inserido com sucesso!"));
}
public List<modelo.RelatorioEstado> pesquisarInfoDosEstados() {
return daoEstado.pesquisarInfoDosEstados();
}
public void alterar() {
FacesContext context = FacesContext.getCurrentInstance();
try {
daoEstado.edit(estado);
estado = new Estado();
} catch (NonexistentEntityException ex) {
context.addMessage("formEstado", new FacesMessage("Estado não pode ser alterado"));
Logger.getLogger(EstadoBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception ex) {
context.addMessage("formEstado", new FacesMessage("Estado não pode ser alterado"));
Logger.getLogger(EstadoBean.class.getName()).log(Level.SEVERE, null, ex);
}
context.addMessage("formEstado", new FacesMessage("Estado foi inserido com sucesso!"));
}
public void excluir() {
FacesContext context = FacesContext.getCurrentInstance();
try {
daoEstado.destroy(estado.getId());
estado = new Estado();
} catch (Exception ex) {
context.addMessage("formEstado", new FacesMessage("Estado não pode ser excluido"));
Logger.getLogger(EstadoBean.class.getName()).log(Level.SEVERE, null, ex);
}
context.addMessage("formEstado", new FacesMessage("Estado foi inserido com sucesso"));
}
public Estado getEstado() {
return estado;
}
public void setEstado(Estado estado) {
this.estado = estado;
}
public List<Estado> getEstados() {
return daoEstado.findEstadoEntities();
}
public String getMensagem() {
return mensagem;
}
public void setMensagem(String mensagem) {
this.mensagem = mensagem;
}
}
| dnspinheiro/cooperTaxi | src/java/beans/EstadoBean.java | Java | gpl-3.0 | 3,051 |
// AForge Neural Net Library
// AForge.NET framework
// http://www.aforgenet.com/framework/
//
// Copyright © Andrew Kirillov, 2005-2009
// andrew.kirillov@aforgenet.com
//
namespace AForge.Neuro.Learning
{
using System;
/// <summary>
/// Supervised learning interface.
/// </summary>
///
/// <remarks><para>The interface describes methods, which should be implemented
/// by all supervised learning algorithms. Supervised learning is such
/// type of learning algorithms, where system's desired output is known on
/// the learning stage. So, given sample input values and desired outputs,
/// system should adopt its internals to produce correct (or close to correct)
/// result after the learning step is complete.</para></remarks>
///
public interface ISupervisedLearning
{
/// <summary>
/// Runs learning iteration.
/// </summary>
///
/// <param name="input">Input vector.</param>
/// <param name="output">Desired output vector.</param>
///
/// <returns>Returns learning error.</returns>
///
double Run( double[] input, double[] output );
/// <summary>
/// Runs learning epoch.
/// </summary>
///
/// <param name="input">Array of input vectors.</param>
/// <param name="output">Array of output vectors.</param>
///
/// <returns>Returns sum of learning errors.</returns>
///
double RunEpoch( double[][] input, double[][] output );
}
}
| unbornchikken/Neuroflow | _vault/NFBak/Neuroflow_vsonline/Neuroflow/Neuroflow/.lib/AForge/Sources/Neuro/Learning/ISupervisedLearning.cs | C# | gpl-3.0 | 1,569 |
/* -*- c++ -*- */
/*
* Copyright 2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "waterfall_sink_c_impl.h"
#include <gr_io_signature.h>
#include <string.h>
#include <volk/volk.h>
namespace gr {
namespace qtgui {
waterfall_sink_c::sptr
waterfall_sink_c::make(int fftsize, int wintype,
double fc, double bw,
const std::string &name,
QWidget *parent)
{
return gnuradio::get_initial_sptr
(new waterfall_sink_c_impl(fftsize, wintype,
fc, bw, name,
parent));
}
waterfall_sink_c_impl::waterfall_sink_c_impl(int fftsize, int wintype,
double fc, double bw,
const std::string &name,
QWidget *parent)
: gr_sync_block("waterfall_sink_c",
gr_make_io_signature(1, -1, sizeof(gr_complex)),
gr_make_io_signature(0, 0, 0)),
d_fftsize(fftsize), d_fftavg(1.0),
d_wintype((filter::firdes::win_type)(wintype)),
d_center_freq(fc), d_bandwidth(bw), d_name(name),
d_nconnections(1), d_parent(parent)
{
d_main_gui = NULL;
// Perform fftshift operation;
// this is usually desired when plotting
d_shift = true;
d_fft = new fft::fft_complex(d_fftsize, true);
d_fbuf = fft::malloc_float(d_fftsize);
memset(d_fbuf, 0, d_fftsize*sizeof(float));
d_index = 0;
for(int i = 0; i < d_nconnections; i++) {
d_residbufs.push_back(fft::malloc_complex(d_fftsize));
d_magbufs.push_back(fft::malloc_double(d_fftsize));
memset(d_residbufs[i], 0, d_fftsize*sizeof(float));
memset(d_magbufs[i], 0, d_fftsize*sizeof(double));
}
buildwindow();
initialize();
}
waterfall_sink_c_impl::~waterfall_sink_c_impl()
{
for(int i = 0; i < d_nconnections; i++) {
fft::free(d_residbufs[i]);
fft::free(d_magbufs[i]);
}
delete d_fft;
fft::free(d_fbuf);
}
void
waterfall_sink_c_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required)
{
unsigned int ninputs = ninput_items_required.size();
for (unsigned int i = 0; i < ninputs; i++) {
ninput_items_required[i] = std::min(d_fftsize, 8191);
}
}
void
waterfall_sink_c_impl::initialize()
{
if(qApp != NULL) {
d_qApplication = qApp;
}
else {
int argc=0;
char **argv = NULL;
d_qApplication = new QApplication(argc, argv);
}
d_main_gui = new WaterfallDisplayForm(d_nconnections, d_parent);
d_main_gui->SetFFTSize(d_fftsize);
d_main_gui->SetFFTWindowType(d_wintype);
d_main_gui->SetFrequencyRange(d_center_freq,
d_center_freq - d_bandwidth/2.0,
d_center_freq + d_bandwidth/2.0);
// initialize update time to 10 times a second
set_update_time(0.1);
d_last_time = 0;
}
void
waterfall_sink_c_impl::exec_()
{
d_qApplication->exec();
}
QWidget*
waterfall_sink_c_impl::qwidget()
{
return d_main_gui;
}
PyObject*
waterfall_sink_c_impl::pyqwidget()
{
PyObject *w = PyLong_FromVoidPtr((void*)d_main_gui);
PyObject *retarg = Py_BuildValue("N", w);
return retarg;
}
void
waterfall_sink_c_impl::set_fft_size(const int fftsize)
{
d_fftsize = fftsize;
d_main_gui->SetFFTSize(fftsize);
}
int
waterfall_sink_c_impl::fft_size() const
{
return d_fftsize;
}
void
waterfall_sink_c_impl::set_fft_average(const float fftavg)
{
d_fftavg = fftavg;
d_main_gui->SetFFTAverage(fftavg);
}
float
waterfall_sink_c_impl::fft_average() const
{
return d_fftavg;
}
void
waterfall_sink_c_impl::set_frequency_range(const double centerfreq,
const double bandwidth)
{
d_center_freq = centerfreq;
d_bandwidth = bandwidth;
d_main_gui->SetFrequencyRange(d_center_freq,
-d_bandwidth/2.0,
d_bandwidth/2.0);
}
void
waterfall_sink_c_impl::set_update_time(double t)
{
//convert update time to ticks
gruel::high_res_timer_type tps = gruel::high_res_timer_tps();
d_update_time = t * tps;
d_main_gui->setUpdateTime(t);
}
void
waterfall_sink_c_impl::set_title(const std::string &title)
{
d_main_gui->setTitle(0, title.c_str());
}
void
waterfall_sink_c_impl::set_color(const std::string &color)
{
d_main_gui->setColor(0, color.c_str());
}
void
waterfall_sink_c_impl::set_line_width(int width)
{
d_main_gui->setLineWidth(0, width);
}
void
waterfall_sink_c_impl::set_line_style(Qt::PenStyle style)
{
d_main_gui->setLineStyle(0, style);
}
void
waterfall_sink_c_impl::set_line_marker(QwtSymbol::Style marker)
{
d_main_gui->setLineMarker(0, marker);
}
void
waterfall_sink_c_impl::set_size(int width, int height)
{
d_main_gui->resize(QSize(width, height));
}
void
waterfall_sink_c_impl::fft(float *data_out, const gr_complex *data_in, int size)
{
if(d_window.size()) {
volk_32fc_32f_multiply_32fc_a(d_fft->get_inbuf(), data_in, &d_window.front(), size);
}
else {
memcpy(d_fft->get_inbuf(), data_in, sizeof(gr_complex)*size);
}
d_fft->execute(); // compute the fft
volk_32fc_s32f_x2_power_spectral_density_32f_a(data_out, d_fft->get_outbuf(),
size, 1.0, size);
// Perform shift operation
unsigned int len = (unsigned int)(floor(size/2.0));
float *tmp = (float*)malloc(sizeof(float)*len);
memcpy(tmp, &data_out[0], sizeof(float)*len);
memcpy(&data_out[0], &data_out[len], sizeof(float)*(size - len));
memcpy(&data_out[size - len], tmp, sizeof(float)*len);
free(tmp);
}
void
waterfall_sink_c_impl::windowreset()
{
filter::firdes::win_type newwintype;
newwintype = d_main_gui->GetFFTWindowType();
if(d_wintype != newwintype) {
d_wintype = newwintype;
buildwindow();
}
}
void
waterfall_sink_c_impl::buildwindow()
{
d_window.clear();
if(d_wintype != filter::firdes::WIN_NONE) {
d_window = filter::firdes::window(d_wintype, d_fftsize, 6.76);
}
}
void
waterfall_sink_c_impl::fftresize()
{
int newfftsize = d_main_gui->GetFFTSize();
d_fftavg = d_main_gui->GetFFTAverage();
if(newfftsize != d_fftsize) {
// Resize residbuf and replace data
for(int i = 0; i < d_nconnections; i++) {
fft::free(d_residbufs[i]);
fft::free(d_magbufs[i]);
d_residbufs[i] = fft::malloc_complex(newfftsize);
d_magbufs[i] = fft::malloc_double(newfftsize);
memset(d_residbufs[i], 0, newfftsize*sizeof(gr_complex));
memset(d_magbufs[i], 0, newfftsize*sizeof(double));
}
// Set new fft size and reset buffer index
// (throws away any currently held data, but who cares?)
d_fftsize = newfftsize;
d_index = 0;
// Reset window to reflect new size
buildwindow();
// Reset FFTW plan for new size
delete d_fft;
d_fft = new fft::fft_complex(d_fftsize, true);
fft::free(d_fbuf);
d_fbuf = fft::malloc_float(d_fftsize);
memset(d_fbuf, 0, d_fftsize*sizeof(float));
}
}
int
waterfall_sink_c_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
int j=0;
const gr_complex *in = (const gr_complex*)input_items[0];
// Update the FFT size from the application
fftresize();
windowreset();
for(int i=0; i < noutput_items; i+=d_fftsize) {
unsigned int datasize = noutput_items - i;
unsigned int resid = d_fftsize-d_index;
// If we have enough input for one full FFT, do it
if(datasize >= resid) {
for(int n = 0; n < d_nconnections; n++) {
// Fill up residbuf with d_fftsize number of items
in = (const gr_complex*)input_items[n];
memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*resid);
fft(d_fbuf, d_residbufs[n], d_fftsize);
for(int x = 0; x < d_fftsize; x++) {
d_magbufs[n][x] = (double)((1.0-d_fftavg)*d_magbufs[n][x] + (d_fftavg)*d_fbuf[x]);
}
//volk_32f_convert_64f_a(d_magbufs[n], d_fbuf, d_fftsize);
}
if(gruel::high_res_timer_now() - d_last_time > d_update_time) {
d_last_time = gruel::high_res_timer_now();
d_qApplication->postEvent(d_main_gui,
new WaterfallUpdateEvent(d_magbufs,
d_fftsize,
d_last_time));
}
d_index = 0;
j += resid;
}
// Otherwise, copy what we received into the residbuf for next time
else {
for(int n = 0; n < d_nconnections; n++) {
in = (const gr_complex*)input_items[n];
memcpy(d_residbufs[n]+d_index, &in[j], sizeof(gr_complex)*datasize);
}
d_index += datasize;
j += datasize;
}
}
return j;
}
} /* namespace qtgui */
} /* namespace gr */
| levelrf/level_basestation | gr-qtgui/lib/waterfall_sink_c_impl.cc | C++ | gpl-3.0 | 9,644 |
# -*- coding: utf-8 -*-
import hashlib, time
from django import forms
from django.contrib.auth.models import User, Group
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from poetry.models import Poem, Theme
from user.models import Contributor
my_default_errors = {
'required': 'Еңгізуге міндетті параметр'
}
error_messages = {'required': 'Толтыруға маңызды параметр'}
class UserAuthenticateForm(forms.ModelForm):
email = forms.EmailField(required=True, error_messages=error_messages)
password = forms.CharField(
required=True,
label='Құпиясөз',
error_messages=error_messages,
widget=forms.PasswordInput)
class Meta:
model = User
fields = ('email', 'password')
labels = {
'email': 'Email',
'password': 'Құпиясөз',
}
class UserCreateForm(UserCreationForm):
email = forms.EmailField(required=True, error_messages=error_messages)
full_name = forms.CharField(required=True, label='Есіміңіз', error_messages=error_messages)
password1 = forms.CharField(required=True, label='Құпиясөз', widget=forms.PasswordInput,
error_messages=error_messages)
password2 = forms.CharField(required=True, label='Құпиясөзді қайталаңыз', widget=forms.PasswordInput,
error_messages=error_messages)
class Meta:
model = User
fields = ('full_name', 'email', 'password1', 'password2')
def save(self, commit=True):
user = super(UserCreateForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
user.username = user.email
user.is_active = 0
hash = '%s%s' % (user.email, time.time())
if commit:
user.save()
user.contributor = Contributor(user_id=user, full_name=self.cleaned_data["full_name"],
activation_code=hashlib.md5(hash.encode('utf-8')).hexdigest())
user.contributor.save()
group = self.get_user_group()
user.groups.add(group)
else:
pass
return user
def get_user_group(self):
return Group.objects.get(name='site-users')
def clean_email(self):
email = self.cleaned_data.get('email')
user = User.objects.filter(email=email).first()
if user:
raise forms.ValidationError("Бұл email-мен колднушы тіркелген.")
return email
def clean_password2(self):
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
if not password2:
raise forms.ValidationError("Құпиясөзді растаңыз")
if password1 != password2:
raise forms.ValidationError("Құпиясөздер бір біріне сәйкес емес. Қайта теріңіз")
if len(password2) < 6:
raise forms.ValidationError('Кемінде 6 символ')
return super(UserCreateForm, self).clean_password2()
class UserEditForm(forms.ModelForm):
text_status = forms.CharField(
widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}),
label='Сайттағы статусыңыз (250 символ)',
error_messages=error_messages)
class Meta:
model = Contributor
fields = ('full_name', 'text_status')
labels = {
'full_name': 'Есіміңіз',
'text_status': 'Сайттағы статусыңыз (250 символ)',
}
error_messages = {
'full_name': error_messages
}
class OfferPoemFrom(forms.ModelForm):
theme = forms.MultipleChoiceField(
label="Тақырып",
widget=forms.SelectMultiple,
error_messages=error_messages,
choices=Theme.objects.values_list('id', 'name').all()
)
class Meta:
model = Poem
fields = ('author', 'title', 'content', 'theme',)
labels = {
'author': 'Автор',
'title': 'Шығарма аты',
'content': 'Текст',
}
error_messages = {
'author': error_messages,
'title': error_messages,
'content': error_messages,
'theme': error_messages
}
| ra1ski/poetrydb | user/forms.py | Python | gpl-3.0 | 4,469 |
<?php
/**
* AnimeDb package
*
* @package AnimeDb
* @author Peter Gribanov <info@peter-gribanov.ru>
* @copyright Copyright (c) 2011, Peter Gribanov
* @license http://opensource.org/licenses/GPL-3.0 GPL v3
*/
namespace AnimeDb\Bundle\ApiClientBundle\Tests\DependencyInjection;
use AnimeDb\Bundle\ApiClientBundle\DependencyInjection\AnimeDbApiClientExtension;
/**
* Test DependencyInjection
*
* @package AnimeDb\Bundle\ApiClientBundle\Tests\DependencyInjection
* @author Peter Gribanov <info@peter-gribanov.ru>
*/
class AnimeDbApiClientExtensionTest extends \PHPUnit_Framework_TestCase
{
/**
* Test load
*/
public function testLoad()
{
$di = new AnimeDbApiClientExtension();
$di->load([], $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'));
}
}
| anime-db/api-client-bundle | tests/DependencyInjection/AnimeDbApiClientExtensionTest.php | PHP | gpl-3.0 | 830 |
function content($slide) {
return $slide.children().first().nextAll();
}
function addReplToSlide($, deck, $slide) {
var endpoint = $[deck]('getOptions').repl.endpoint;
content($slide).wrapAll('<div class="repl-slide-column repl-text-column"></div>');
var replHtmlId = "console-" + $slide[0].id;
$('<div/>', { id: replHtmlId, class: 'repl-slide-column repl-console-column' })
.appendTo($slide);
$('<script></script>')
.append("$(function () { newConsole('" + endpoint + "', $('#" + replHtmlId + "')); });")
.appendTo($slide);
content($slide).wrapAll('<div class="repl-slide-columns"></div>');
}
function protocol() {
switch (location.protocol) {
case 'https:': return 'wss:';
default: return 'ws:';
}
}
function url(endpoint) {
return protocol() + endpoint;
}
function getContext(element) {
return element.attr('data-repl-context') || element.parents('[data-repl-context]').attr('data-repl-context');
}
function hasContext(element) {
var ctx = getContext(element);
return ctx !== undefined && ctx !== "";
}
function newConsole(endpoint, element) {
var replContext = getContext(element);
var jqconsole = element.jqconsole("", "> ");
var startPrompt;
var writeText = function(text) {
jqconsole.Write(text, 'jqconsole-output');
startPrompt();
};
var writeError = function(text) {
jqconsole.Write(text, 'jqconsole-error');
startPrompt();
}
jqconsole.Disable();
addFullscreenHint(element);
if (endpoint) {
var connect = function () {
var ws = new WebSocket(url(endpoint));
ws.onmessage = function(event) {
jqconsole.Enable();
writeText(event.data);
};
ws.onerror = function(event) {
writeError("Connection error\n");
};
ws.onopen = function(event) {
ws.send("/load " + replContext);
};
return ws;
}
var ws = connect();
startPrompt = function () {
jqconsole.Prompt(true, function (input) {
if (input === '/reconnect') {
ws = connect();
} else if (input !== '') {
if (ws.readyState === WebSocket.OPEN) {
ws.send(input);
} else {
writeError("Not connected.");
}
}
});
};
var setup = function() {
jqconsole.RegisterShortcut('L', reset);
startPrompt();
};
var reset = function() {
var history = jqconsole.GetHistory();
jqconsole.Reset();
jqconsole.SetHistory(history);
setup();
};
setup();
} else {
startPrompt = function() {};
writeText("REPL offline.\n" +
"No livecoding for you :-(");
jqconsole.Prompt(true, function() {});
}
};
function addFullscreenHint(element) {
$('<div/>', { class: 'repl-fullscreen-hint', text: 'Fullscreen — Hit F to quit' }).appendTo(element);
}
function toggleOrder(i, order) {
switch (order) {
case '0': return '1';
default: return '0';
}
}
function isKey(e, keyValue) {
return e.which === keyValue || $.inArray(e.which, keyValue) > -1;
}
(function($, deck, window, undefined) {
var $d = $(document);
/*
Extends defaults/options.
options.keys.replPositionToggle
Key to toggle REPL position between left and right (right by default).
Default key is 'T'.
options.keys.replFullscreenToggle
Key to toggle REPL to fullscreen, hiding the other column and slide title.
Default key is 'F'.
options.repl.endpoint
URL of the websocket endpoint to use for REPL without the protocol part.
*/
$.extend(true, $[deck].defaults, {
classes: {
repl: 'deck-repl'
},
keys: {
replPositionToggle: 84, // t
replFullscreenToggle: 70 // f
},
repl: {
endpoint: ''
}
});
$d.bind('deck.beforeInit', function() {
if ($[deck]('getOptions').repl.endpoint) {
warnAgainstCtrlW($);
}
$.each($[deck]('getSlides'), function(i, $slide) {
if ($slide.hasClass('repl') && hasContext($slide)) {
addReplToSlide($, deck, $slide);
}
});
});
/*
jQuery.deck('toggleReplPosition')
Toggles REPL position (right column first).
*/
$[deck]('extend', 'toggleReplPosition', function() {
$('.repl-console-column').css('order', toggleOrder);
});
$[deck]('extend', 'toggleReplFullscreen', function() {
$('.deck-current .repl-slide-columns').siblings().toggle();
$('.deck-current .repl-text-column').toggle();
$('.deck-current .repl-console-column').toggleClass('repl-console-column-fullscreen');
});
$d.bind('deck.init', function() {
var opts = $[deck]('getOptions');
// Bind key events
$d.unbind('keydown.deckrepl').bind('keydown.deckrepl', function(e) {
if (isKey(e, opts.keys.replPositionToggle)) {
$[deck]('toggleReplPosition');
e.preventDefault();
}
if (isKey(e, opts.keys.replFullscreenToggle)) {
$[deck]('toggleReplFullscreen');
e.preventDefault();
}
});
});
})(jQuery, 'deck', this);
function warnAgainstCtrlW($) {
$(window).on('beforeunload', function(e) {
return 'Bad habit of deleting words with Ctrl-W? ESC to stay here.';
});
}
| ptitfred/slidecoding | web/deckjs/extensions/repl/deck.repl.js | JavaScript | gpl-3.0 | 5,193 |
package toncc;
import javax.swing.*;
/** Utility class to run JFrame-based GUI classes.
*
* @author Bruce Eckel, Giacomo Parolini
*/
class SwingConsole {
private static void prepare(final JFrame f) {
f.setTitle(f.getClass().getSimpleName());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void run(final JFrame f,final int width,final int height) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
prepare(f);
f.setSize(width,height);
f.setVisible(true);
}
});
}
/** Don't manually set size, but pack. */
public static void run(final JFrame f) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
prepare(f);
f.pack();
f.setVisible(true);
}
});
}
/** Don't manually set size, but pack. */
public static void run(final JFrame f,final String title) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setTitle(title);
f.pack();
f.setVisible(true);
}
});
}
public static void run(final JFrame f,final int width,final int height,final String title) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setTitle(title);
f.setSize(width,height);
f.setVisible(true);
}
});
}
public static void runFullScreen(final JFrame f) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
prepare(f);
f.setExtendedState(JFrame.MAXIMIZED_BOTH);
f.setVisible(true);
}
});
}
public static void setSystemLookAndFeel() {
try {
// Set system L&F
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception ee) {
System.err.println("Caught exception while setting LookAndFeel: "+ee);
}
}
}
| silverweed/toncc | SwingConsole.java | Java | gpl-3.0 | 1,849 |
package controle.gui_jogo;
import controle.configuradores_gui.ConfiguradorVisualizadorDeCartas;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import modelo.jogo.Jogada;
import modelo.jogo.partida.InformacaoDoTurno;
import modelo.jogo.servidor.controleremoto.ControleRemoto;
import modelo.util.Observador;
import visao.GUIJogo;
import visao.GUIPortal;
import visao.janelas.FormVisualizadorDeCartas;
public class ObservadorDoControleRemoto implements Observador {
private GUIJogo _gj;
private ControleRemoto _ctr;
private GUIPortal gui;
public ObservadorDoControleRemoto(GUIJogo _gj, ControleRemoto _ctr, GUIPortal gui) {
this._gj = _gj;
this._ctr = _ctr;
this.gui = gui;
}
@Override
public void notificar(Object fonte, Object msg) {
if ("iniciar_turno".equals(msg)) {
_gj.habilitarMontarJogada(true);
return;
}
if ("jogada_realizada".equals(msg)) {
_gj.habilitarMontarJogada(false);
return;
}
if ("atualizar_pontuacao".equals(msg)) {
List<InformacaoDoTurno> info = _ctr.getListaInformacaoTurno();
_gj.atualizarPlacar(info);
return;
}
if ("fim_do_jogo".equals(msg)) {
_ctr.remover(this);
_gj.mostrasMensagem("Fim do jogo seu brucutu");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
_gj.mostrasMensagem(e.getMessage());
}
_gj.fechar();
return;
}
}
}
| vandaimer/TrabalhoEs | src/controle/gui_jogo/ObservadorDoControleRemoto.java | Java | gpl-3.0 | 1,791 |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-05-29 13:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0054_add_field_user_to_productionform'),
]
operations = [
migrations.AddField(
model_name='applicationform',
name='requires_development',
field=models.BooleanField(default=False, verbose_name='requires_development'),
),
]
| efornal/pulmo | app/migrations/0055_applicationform_requires_development.py | Python | gpl-3.0 | 523 |
package bigarrays;
/**
* @author vincent.gardeux@epfl.ch
*
* Class for representing a float static array requiring address space larger than 32 bits.
*/
public class FloatArray64
{
private static final int CHUNK_SIZE = 1024*1024*512;
private long size;
private float[][] data;
public FloatArray64(long size)
{
this.size = size;
if(size == 0) data = null;
else
{
int chunks = (int)(size/CHUNK_SIZE);
int remainder = (int)(size - ((long)chunks)*CHUNK_SIZE);
data = new float[chunks+(remainder==0?0:1)][];
for(int idx=chunks; --idx>=0; ) data[idx] = new float[(int)CHUNK_SIZE];
if(remainder != 0) data[chunks] = new float[remainder];
}
}
public static int chunkSize()
{
return CHUNK_SIZE;
}
public float[] toArray()
{
if(this.data.length == 1) return this.data[0];
return null;
}
public float get(long index)
{
if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Error attempting to access data element "+index+". Array is "+size+" elements long.");
int chunk = (int)(index / CHUNK_SIZE);
int offset = (int)(index - (((long)chunk) * CHUNK_SIZE));
return data[chunk][offset];
}
public float[] getByChunk(int chunk)
{
if(chunk >= data.length) throw new IndexOutOfBoundsException("Error attempting to access chunk "+chunk+". Array is "+size+" elements long [" + data.length + " chunks]");
return data[chunk];
}
public void set(long index, float b)
{
if(index<0 || index>=size) throw new IndexOutOfBoundsException("Error attempting to access data element "+index+". Array is "+size+" elements long.");
int chunk = (int)(index/CHUNK_SIZE);
int offset = (int)(index - (((long)chunk)*CHUNK_SIZE));
data[chunk][offset] = b;
}
public void set(int chunk, float[] b)
{
if(chunk >= data.length) throw new IndexOutOfBoundsException("Error attempting to access chunk "+chunk+". Array is "+size+" elements long [" + data.length + " chunks]");
data[chunk] = b;
}
public long size()
{
return this.size;
}
public IntArray64 toIntArray()
{
IntArray64 array = new IntArray64(this.size);
for(long i = 0; i < size; i++) array.set(i, (int)this.get(i));
return array;
}
} | DeplanckeLab/ASAP | Java/src/bigarrays/FloatArray64.java | Java | gpl-3.0 | 2,467 |
namespace UnityEditor
{
using System;
using UnityEngine;
internal class PopupWindowWithoutFocus : EditorWindow
{
private Rect m_ActivatorRect;
private float m_BorderWidth = 1f;
private Vector2 m_LastWantedSize = Vector2.zero;
private PopupLocationHelper.PopupLocation[] m_LocationPriorityOrder;
private PopupWindowContent m_WindowContent;
private static Rect s_LastActivatorRect;
private static double s_LastClosedTime;
private static PopupWindowWithoutFocus s_PopupWindowWithoutFocus;
private PopupWindowWithoutFocus()
{
base.hideFlags = HideFlags.DontSave;
}
private void FitWindowToContent()
{
Vector2 windowSize = this.m_WindowContent.GetWindowSize();
if (this.m_LastWantedSize != windowSize)
{
this.m_LastWantedSize = windowSize;
Vector2 minSize = windowSize + new Vector2(2f * this.m_BorderWidth, 2f * this.m_BorderWidth);
Rect rect = PopupLocationHelper.GetDropDownRect(this.m_ActivatorRect, minSize, minSize, null, this.m_LocationPriorityOrder);
base.m_Pos = rect;
Vector2 vector3 = new Vector2(rect.width, rect.height);
base.maxSize = vector3;
base.minSize = vector3;
}
}
public static void Hide()
{
if (s_PopupWindowWithoutFocus != null)
{
s_PopupWindowWithoutFocus.Close();
}
}
private void Init(Rect activatorRect, PopupWindowContent windowContent, PopupLocationHelper.PopupLocation[] locationPriorityOrder)
{
this.m_WindowContent = windowContent;
this.m_WindowContent.editorWindow = this;
this.m_ActivatorRect = GUIUtility.GUIToScreenRect(activatorRect);
this.m_LastWantedSize = windowContent.GetWindowSize();
this.m_LocationPriorityOrder = locationPriorityOrder;
Vector2 minSize = windowContent.GetWindowSize() + new Vector2(this.m_BorderWidth * 2f, this.m_BorderWidth * 2f);
base.position = PopupLocationHelper.GetDropDownRect(this.m_ActivatorRect, minSize, minSize, null, this.m_LocationPriorityOrder);
base.ShowPopup();
base.Repaint();
}
public static bool IsVisible()
{
return (s_PopupWindowWithoutFocus != null);
}
private void OnDisable()
{
s_LastClosedTime = EditorApplication.timeSinceStartup;
if (this.m_WindowContent != null)
{
this.m_WindowContent.OnClose();
}
s_PopupWindowWithoutFocus = null;
}
private void OnEnable()
{
s_PopupWindowWithoutFocus = this;
}
private static bool OnGlobalMouseOrKeyEvent(EventType type, KeyCode keyCode, Vector2 mousePosition)
{
if (s_PopupWindowWithoutFocus != null)
{
if ((type == EventType.KeyDown) && (keyCode == KeyCode.Escape))
{
s_PopupWindowWithoutFocus.Close();
return true;
}
if ((type == EventType.MouseDown) && !s_PopupWindowWithoutFocus.position.Contains(mousePosition))
{
s_PopupWindowWithoutFocus.Close();
return true;
}
}
return false;
}
internal void OnGUI()
{
this.FitWindowToContent();
Rect rect = new Rect(this.m_BorderWidth, this.m_BorderWidth, base.position.width - (2f * this.m_BorderWidth), base.position.height - (2f * this.m_BorderWidth));
this.m_WindowContent.OnGUI(rect);
GUI.Label(new Rect(0f, 0f, base.position.width, base.position.height), GUIContent.none, "grey_border");
}
private static bool ShouldShowWindow(Rect activatorRect)
{
if (((EditorApplication.timeSinceStartup - s_LastClosedTime) < 0.2) && !(activatorRect != s_LastActivatorRect))
{
return false;
}
s_LastActivatorRect = activatorRect;
return true;
}
public static void Show(Rect activatorRect, PopupWindowContent windowContent)
{
Show(activatorRect, windowContent, null);
}
internal static void Show(Rect activatorRect, PopupWindowContent windowContent, PopupLocationHelper.PopupLocation[] locationPriorityOrder)
{
if (ShouldShowWindow(activatorRect))
{
if (s_PopupWindowWithoutFocus == null)
{
s_PopupWindowWithoutFocus = ScriptableObject.CreateInstance<PopupWindowWithoutFocus>();
}
s_PopupWindowWithoutFocus.Init(activatorRect, windowContent, locationPriorityOrder);
}
}
}
}
| randomize/VimConfig | tags/unity5/UnityEditor/PopupWindowWithoutFocus.cs | C# | gpl-3.0 | 5,033 |
<?php
namespace MinSal\SidPla\DepUniBundle\EntityDao;
use MinSal\SidPla\DepUniBundle\Entity\TipoRRHumano;
use Doctrine\ORM\Query\ResultSetMapping;
class TipoRRHumanoDao {
var $doctrine;
var $repositorio;
var $em;
//Este es el constructor
function __construct($doctrine) {
$this->doctrine = $doctrine;
$this->em = $this->doctrine->getEntityManager();
$this->repositorio = $this->doctrine->getRepository('MinSalSidPlaDepUniBundle:TipoRRHumano');
}
/*
* Obtiene todos los tipos de recursos humanos
*/
public function getTipoRRHH() {
$notificaciones = $this->repositorio->findAll();
return $notificaciones;
}
/*
* Agregar Tipo Recurso Humano
*/
public function getTipoRRHHEspecifico($codigo) {
$tipoRRHH = $this->repositorio->find($codigo);
return $tipoRRHH;
}
public function agregarTipoRRHH($nombreTipo) {
$tipoRRHH = new TipoRRHumano();
$tipoRRHH->setDescripRRHH($nombreTipo);
$this->em->persist($tipoRRHH);
$this->em->flush();
$matrizMensajes = array('El proceso de almacenar el tipo recurso humano termino con exito');
return $matrizMensajes;
}
public function editarTipoRRHH($codTipo, $nombreTipo) {
$tipoRRHH = $this->getTipoRRHHEspecifico($codTipo);
$tipoRRHH->setDescripRRHH($nombreTipo);
$this->em->persist($tipoRRHH);
$this->em->flush();
$matrizMensajes = array('El proceso de editar el tipo recurso humano termino con exito');
return $matrizMensajes;
}
public function eliminarTipoRRHH($codTipo) {
$tipoRRHH = $this->getTipoRRHHEspecifico($codTipo);
$this->em->remove($tipoRRHH);
$this->em->flush();
$matrizMensajes = array('El proceso de eliminar el tipo recurso humano termino con exito');
return $matrizMensajes;
}
/*Para otras entidades*/
public function obtenerRRHHcadena() {
$cadena = "";
$tipoRRHH = $this->getTipoRRHH();
$aux = new TipoRRHumano();
$n = count($tipoRRHH);
$i = 1;
foreach ($tipoRRHH as $aux) {
if ($i < $n)
$cadena.=$aux->getCodTipoRRHH().":".$aux->getDescripRRHH().';';
else
$cadena.=$aux->getCodTipoRRHH().":".$aux->getDescripRRHH();
$i++;
}
return $cadena;
}
}
?>
| bagonzalez/sidpla-minsal | MinSal/SidPla/DepUniBundle/EntityDao/TipoRRHumanoDao.php | PHP | gpl-3.0 | 2,507 |
/* Gnomescroll, Copyright (c) 2013 Symbolic Analytics
* Licensed under GPLv3 */
#pragma once
#include <uuid/uuid.h>
#include <serializer/constants.hpp>
namespace serializer
{
// returns bytes written, excluding NUL
size_t write_uuid(char* str, size_t buffer_size, uuid_t uuid);
} // serializer
| Gnomescroll/Gnomescroll | src/c_lib/serializer/uuid.hpp | C++ | gpl-3.0 | 301 |
namespace GitUI.Properties
{
/// <summary>
/// DESIGNER USAGE INFO!
///
/// This partial class helps to modify the Resources.resx using the designer AND having some custom
/// code inside the designer generated Resources class.
/// The only thing to do whenever the Designer is used is to add the partial class modifier in Resources.Designer.cs
/// which is not generated by the designer code generator.
///
/// As soon as the preprocessor if statements are no longer necessary this class can / should be removed.
/// </summary>
internal partial class Resources
{
public static System.Drawing.Bitmap loadingpanel
{
get
{
return loadingpanel_animated;
}
}
}
}
| glen-nicol/gitextensions | GitUI/Properties/Resources.Custom.cs | C# | gpl-3.0 | 790 |
/*
***************************************************************************
* *
* Platform Independent *
* Bitmap Image Reader Writer Library *
* *
* Author: Arash Partow - 2002 *
* URL: http://partow.net/programming/bitmap/index.html *
* *
* Note: This library only supports 24-bits per pixel bitmap format files. *
* *
* Copyright notice: *
* Free use of the Platform Independent Bitmap Image Reader Writer Library *
* is permitted under the guidelines and in accordance with the most *
* current version of the Common Public License. *
* http://www.opensource.org/licenses/cpl1.0.php *
* *
***************************************************************************
*/
#ifndef INCLUDE_BITMAP_IMAGE_HPP
#define INCLUDE_BITMAP_IMAGE_HPP
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <limits>
#include <string>
class bitmap_image {
public:
enum channel_mode { rgb_mode = 0, bgr_mode = 1 };
enum color_plane { blue_plane = 0, green_plane = 1, red_plane = 2 };
bitmap_image()
: file_name_(""),
data_(0),
length_(0),
width_(0),
height_(0),
row_increment_(0),
bytes_per_pixel_(3),
channel_mode_(bgr_mode) {}
bitmap_image(const std::string& filename)
: file_name_(filename),
data_(0),
length_(0),
width_(0),
height_(0),
row_increment_(0),
bytes_per_pixel_(0),
channel_mode_(bgr_mode) {
load_bitmap();
}
bitmap_image(const unsigned int width, const unsigned int height)
: file_name_(""),
data_(0),
length_(0),
width_(width),
height_(height),
row_increment_(0),
bytes_per_pixel_(3),
channel_mode_(bgr_mode) {
create_bitmap();
}
bitmap_image(const bitmap_image& image)
: file_name_(image.file_name_),
data_(0),
width_(image.width_),
height_(image.height_),
row_increment_(0),
bytes_per_pixel_(3),
channel_mode_(bgr_mode) {
create_bitmap();
std::copy(image.data_, image.data_ + image.length_, data_);
}
~bitmap_image() { delete[] data_; }
bitmap_image& operator=(const bitmap_image& image) {
if (this != &image) {
file_name_ = image.file_name_;
bytes_per_pixel_ = image.bytes_per_pixel_;
width_ = image.width_;
height_ = image.height_;
row_increment_ = 0;
channel_mode_ = image.channel_mode_;
create_bitmap();
std::copy(image.data_, image.data_ + image.length_, data_);
}
return *this;
}
inline bool operator!() {
return (data_ == 0) || (length_ == 0) || (width_ == 0) || (height_ == 0) ||
(row_increment_ == 0);
}
inline void clear(const unsigned char v = 0x00) {
std::fill(data_, data_ + length_, v);
}
inline unsigned char red_channel(const unsigned int x,
const unsigned int y) const {
return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 2)];
}
inline unsigned char green_channel(const unsigned int x,
const unsigned int y) const {
return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 1)];
}
inline unsigned char blue_channel(const unsigned int x,
const unsigned int y) const {
return data_[(y * row_increment_) + (x * bytes_per_pixel_ + 0)];
}
inline void red_channel(const unsigned int x, const unsigned int y,
const unsigned char value) {
data_[(y * row_increment_) + (x * bytes_per_pixel_ + 2)] = value;
}
inline void green_channel(const unsigned int x, const unsigned int y,
const unsigned char value) {
data_[(y * row_increment_) + (x * bytes_per_pixel_ + 1)] = value;
}
inline void blue_channel(const unsigned int x, const unsigned int y,
const unsigned char value) {
data_[(y * row_increment_) + (x * bytes_per_pixel_ + 0)] = value;
}
inline unsigned char* row(unsigned int row_index) const {
return data_ + (row_index * row_increment_);
}
inline void get_pixel(const unsigned int x, const unsigned int y,
unsigned char& red, unsigned char& green,
unsigned char& blue) {
const unsigned int y_offset = y * row_increment_;
const unsigned int x_offset = x * bytes_per_pixel_;
blue = data_[y_offset + x_offset + 0];
green = data_[y_offset + x_offset + 1];
red = data_[y_offset + x_offset + 2];
}
inline void set_pixel(const unsigned int x, const unsigned int y,
const unsigned char red, const unsigned char green,
const unsigned char blue) {
const unsigned int y_offset = y * row_increment_;
const unsigned int x_offset = x * bytes_per_pixel_;
data_[y_offset + x_offset + 0] = blue;
data_[y_offset + x_offset + 1] = green;
data_[y_offset + x_offset + 2] = red;
}
inline bool copy_from(const bitmap_image& image) {
if ((image.height_ != height_) || (image.width_ != width_)) {
return false;
}
std::copy(image.data_, image.data_ + image.length_, data_);
return true;
}
inline bool copy_from(const bitmap_image& source_image,
const unsigned int& x_offset,
const unsigned int& y_offset) {
if ((x_offset + source_image.width_) > width_) {
return false;
}
if ((y_offset + source_image.height_) > height_) {
return false;
}
for (unsigned int y = 0; y < source_image.height_; ++y) {
unsigned char* itr1 = row(y + y_offset) + x_offset * bytes_per_pixel_;
const unsigned char* itr2 = source_image.row(y);
const unsigned char* itr2_end =
itr2 + source_image.width_ * bytes_per_pixel_;
std::copy(itr2, itr2_end, itr1);
}
return true;
}
inline bool region(const unsigned int& x, const unsigned int& y,
const unsigned int& width, const unsigned int& height,
bitmap_image& dest_image) {
if ((x + width) > width_) {
return false;
}
if ((y + height) > height_) {
return false;
}
if ((dest_image.width_ < width_) || (dest_image.height_ < height_)) {
dest_image.setwidth_height(width, height);
}
for (unsigned int r = 0; r < height; ++r) {
unsigned char* itr1 = row(r + y) + x * bytes_per_pixel_;
unsigned char* itr1_end = itr1 + (width * bytes_per_pixel_);
unsigned char* itr2 = dest_image.row(r);
std::copy(itr1, itr1_end, itr2);
}
return true;
}
inline bool set_region(const unsigned int& x, const unsigned int& y,
const unsigned int& width, const unsigned int& height,
const unsigned char& value) {
if ((x + width) > width_) {
return false;
}
if ((y + height) > height_) {
return false;
}
for (unsigned int r = 0; r < height; ++r) {
unsigned char* itr = row(r + y) + x * bytes_per_pixel_;
unsigned char* itr_end = itr + (width * bytes_per_pixel_);
std::fill(itr, itr_end, value);
}
return true;
}
inline bool set_region(const unsigned int& x, const unsigned int& y,
const unsigned int& width, const unsigned int& height,
const color_plane color, const unsigned char& value) {
if ((x + width) > width_) {
return false;
}
if ((y + height) > height_) {
return false;
}
const unsigned int color_plane_offset = offset(color);
for (unsigned int r = 0; r < height; ++r) {
unsigned char* itr =
row(r + y) + x * bytes_per_pixel_ + color_plane_offset;
unsigned char* itr_end = itr + (width * bytes_per_pixel_);
while (itr != itr_end) {
*itr = value;
itr += bytes_per_pixel_;
}
}
return true;
}
inline bool set_region(const unsigned int& x, const unsigned int& y,
const unsigned int& width, const unsigned int& height,
const unsigned char& red, const unsigned char& green,
const unsigned char& blue) {
if ((x + width) > width_) {
return false;
}
if ((y + height) > height_) {
return false;
}
for (unsigned int r = 0; r < height; ++r) {
unsigned char* itr = row(r + y) + x * bytes_per_pixel_;
unsigned char* itr_end = itr + (width * bytes_per_pixel_);
while (itr != itr_end) {
*(itr++) = blue;
*(itr++) = green;
*(itr++) = red;
}
}
return true;
}
void reflective_image(bitmap_image& image) {
image.setwidth_height(3 * width_, 3 * height_, true);
image.copy_from(*this, width_, height_);
vertical_flip();
image.copy_from(*this, width_, 0);
image.copy_from(*this, width_, 2 * height_);
vertical_flip();
horizontal_flip();
image.copy_from(*this, 0, height_);
image.copy_from(*this, 2 * width_, height_);
horizontal_flip();
}
inline unsigned int width() const { return width_; }
inline unsigned int height() const { return height_; }
inline unsigned int bytes_per_pixel() const { return bytes_per_pixel_; }
inline unsigned int pixel_count() const { return width_ * height_; }
inline void setwidth_height(const unsigned int width,
const unsigned int height,
const bool clear = false) {
delete[] data_;
data_ = 0;
width_ = width;
height_ = height;
create_bitmap();
if (clear) {
std::fill(data_, data_ + length_, 0x00);
}
}
void save_image(const std::string& file_name) {
std::ofstream stream(file_name.c_str(), std::ios::binary);
if (!stream) {
std::cout << "bitmap_image::save_image(): Error - Could not open file "
<< file_name << " for writing!" << std::endl;
return;
}
bitmap_file_header bfh;
bitmap_information_header bih;
bih.width = width_;
bih.height = height_;
bih.bit_count = static_cast<unsigned short>(bytes_per_pixel_ << 3);
bih.clr_important = 0;
bih.clr_used = 0;
bih.compression = 0;
bih.planes = 1;
bih.size = 40;
bih.x_pels_per_meter = 0;
bih.y_pels_per_meter = 0;
bih.size_image =
(((bih.width * bytes_per_pixel_) + 3) & 0x0000FFFC) * bih.height;
bfh.type = 19778;
bfh.size = 55 + bih.size_image;
bfh.reserved1 = 0;
bfh.reserved2 = 0;
bfh.off_bits = bih.struct_size() + bfh.struct_size();
write_bfh(stream, bfh);
write_bih(stream, bih);
unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
char padding_data[4] = {0x0, 0x0, 0x0, 0x0};
for (unsigned int i = 0; i < height_; ++i) {
unsigned char* data_ptr = data_ + (row_increment_ * (height_ - i - 1));
stream.write(reinterpret_cast<char*>(data_ptr),
sizeof(unsigned char) * bytes_per_pixel_ * width_);
stream.write(padding_data, padding);
}
stream.close();
}
inline void set_all_ith_bits_low(const unsigned int bitr_index) {
unsigned char mask = static_cast<unsigned char>(~(1 << bitr_index));
for (unsigned char* itr = data_; itr != data_ + length_; ++itr) {
*itr &= mask;
}
}
inline void set_all_ith_bits_high(const unsigned int bitr_index) {
unsigned char mask = static_cast<unsigned char>(1 << bitr_index);
for (unsigned char* itr = data_; itr != data_ + length_; ++itr) {
*itr |= mask;
}
}
inline void set_all_ith_channels(const unsigned int& channel,
const unsigned char& value) {
for (unsigned char* itr = (data_ + channel); itr < (data_ + length_);
itr += bytes_per_pixel_) {
*itr = value;
}
}
inline void set_channel(const color_plane color, const unsigned char& value) {
for (unsigned char* itr = (data_ + offset(color)); itr < (data_ + length_);
itr += bytes_per_pixel_) {
*itr = value;
}
}
inline void ror_channel(const color_plane color, const unsigned int& ror) {
for (unsigned char* itr = (data_ + offset(color)); itr < (data_ + length_);
itr += bytes_per_pixel_) {
*itr =
static_cast<unsigned char>(((*itr) >> ror) | ((*itr) << (8 - ror)));
}
}
inline void set_all_channels(const unsigned char& value) {
for (unsigned char* itr = data_; itr < (data_ + length_);) {
*(itr++) = value;
}
}
inline void set_all_channels(const unsigned char& r_value,
const unsigned char& g_value,
const unsigned char& b_value) {
for (unsigned char* itr = (data_ + 0); itr < (data_ + length_);
itr += bytes_per_pixel_) {
*(itr + 0) = b_value;
*(itr + 1) = g_value;
*(itr + 2) = r_value;
}
}
inline void invert_color_planes() {
for (unsigned char* itr = data_; itr < (data_ + length_);
*itr = ~(*itr), ++itr)
;
}
inline void add_to_color_plane(const color_plane color,
const unsigned char& value) {
for (unsigned char* itr = (data_ + offset(color)); itr < (data_ + length_);
(*itr) += value, itr += bytes_per_pixel_)
;
}
inline void convert_to_grayscale() {
double r_scaler = 0.299;
double g_scaler = 0.587;
double b_scaler = 0.114;
if (rgb_mode == channel_mode_) {
double tmp = r_scaler;
r_scaler = b_scaler;
b_scaler = tmp;
}
for (unsigned char* itr = data_; itr < (data_ + length_);) {
unsigned char gray_value = static_cast<unsigned char>(
(r_scaler * (*(itr + 2))) + (g_scaler * (*(itr + 1))) +
(b_scaler * (*(itr + 0))));
*(itr++) = gray_value;
*(itr++) = gray_value;
*(itr++) = gray_value;
}
}
inline const unsigned char* data() { return data_; }
inline void bgr_to_rgb() {
if ((bgr_mode == channel_mode_) && (3 == bytes_per_pixel_)) {
reverse_channels();
channel_mode_ = rgb_mode;
}
}
inline void rgb_to_bgr() {
if ((rgb_mode == channel_mode_) && (3 == bytes_per_pixel_)) {
reverse_channels();
channel_mode_ = bgr_mode;
}
}
inline void reverse() {
unsigned char* itr1 = data_;
unsigned char* itr2 = (data_ + length_) - bytes_per_pixel_;
while (itr1 < itr2) {
for (std::size_t i = 0; i < bytes_per_pixel_; ++i) {
unsigned char* citr1 = itr1 + i;
unsigned char* citr2 = itr2 + i;
unsigned char tmp = *citr1;
*citr1 = *citr2;
*citr2 = tmp;
}
itr1 += bytes_per_pixel_;
itr2 -= bytes_per_pixel_;
}
}
inline void horizontal_flip() {
for (unsigned int y = 0; y < height_; ++y) {
unsigned char* itr1 = row(y);
unsigned char* itr2 = itr1 + row_increment_ - bytes_per_pixel_;
while (itr1 < itr2) {
for (unsigned int i = 0; i < bytes_per_pixel_; ++i) {
unsigned char* p1 = (itr1 + i);
unsigned char* p2 = (itr2 + i);
unsigned char tmp = *p1;
*p1 = *p2;
*p2 = tmp;
}
itr1 += bytes_per_pixel_;
itr2 -= bytes_per_pixel_;
}
}
}
inline void vertical_flip() {
for (unsigned int y = 0; y < (height_ / 2); ++y) {
unsigned char* itr1 = row(y);
unsigned char* itr2 = row(height_ - y - 1);
for (std::size_t x = 0; x < row_increment_; ++x) {
unsigned char tmp = *(itr1 + x);
*(itr1 + x) = *(itr2 + x);
*(itr2 + x) = tmp;
}
}
}
inline void export_color_plane(const color_plane color,
unsigned char* image) {
for (unsigned char* itr = (data_ + offset(color)); itr < (data_ + length_);
++image, itr += bytes_per_pixel_) {
(*image) = (*itr);
}
}
inline void export_color_plane(const color_plane color, bitmap_image& image) {
if ((width_ != image.width_) || (height_ != image.height_)) {
image.setwidth_height(width_, height_);
}
image.clear();
unsigned char* itr1 = (data_ + offset(color));
unsigned char* itr1_end = (data_ + length_);
unsigned char* itr2 = (image.data_ + offset(color));
while (itr1 < itr1_end) {
(*itr2) = (*itr1);
itr1 += bytes_per_pixel_;
itr2 += bytes_per_pixel_;
}
}
inline void export_response_image(const color_plane color,
double* response_image) {
for (unsigned char* itr = (data_ + offset(color)); itr < (data_ + length_);
++response_image, itr += bytes_per_pixel_) {
(*response_image) = (1.0 * (*itr)) / 256.0;
}
}
inline void export_gray_scale_response_image(double* response_image) {
for (unsigned char* itr = data_; itr < (data_ + length_);
itr += bytes_per_pixel_) {
unsigned char gray_value = static_cast<unsigned char>(
(0.299 * (*(itr + 2))) + (0.587 * (*(itr + 1))) +
(0.114 * (*(itr + 0))));
(*response_image) = (1.0 * gray_value) / 256.0;
}
}
inline void export_rgb(double* red, double* green, double* blue) const {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
(*blue) = (1.0 * (*(itr++))) / 256.0;
(*green) = (1.0 * (*(itr++))) / 256.0;
(*red) = (1.0 * (*(itr++))) / 256.0;
}
}
inline void export_rgb(float* red, float* green, float* blue) const {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
(*blue) = (1.0f * (*(itr++))) / 256.0f;
(*green) = (1.0f * (*(itr++))) / 256.0f;
(*red) = (1.0f * (*(itr++))) / 256.0f;
}
}
inline void export_rgb(unsigned char* red, unsigned char* green,
unsigned char* blue) const {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
(*blue) = *(itr++);
(*green) = *(itr++);
(*red) = *(itr++);
}
}
inline void export_ycbcr(double* y, double* cb, double* cr) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_); ++y, ++cb, ++cr) {
double blue = (1.0 * (*(itr++)));
double green = (1.0 * (*(itr++)));
double red = (1.0 * (*(itr++)));
(*y) = clamp<double>(
16.0 +
(1.0 / 256.0) * (65.738 * red + 129.057 * green + 25.064 * blue),
1.0, 254);
(*cb) = clamp<double>(
128.0 +
(1.0 / 256.0) * (-37.945 * red - 74.494 * green + 112.439 * blue),
1.0, 254);
(*cr) = clamp<double>(
128.0 +
(1.0 / 256.0) * (112.439 * red - 94.154 * green - 18.285 * blue),
1.0, 254);
}
}
inline void export_rgb_normal(double* red, double* green,
double* blue) const {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
(*blue) = (1.0 * (*(itr++)));
(*green) = (1.0 * (*(itr++)));
(*red) = (1.0 * (*(itr++)));
}
}
inline void export_rgb_normal(float* red, float* green, float* blue) const {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
(*blue) = (1.0f * (*(itr++)));
(*green) = (1.0f * (*(itr++)));
(*red) = (1.0f * (*(itr++)));
}
}
inline void import_rgb(double* red, double* green, double* blue) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
*(itr++) = static_cast<unsigned char>(256.0 * (*blue));
*(itr++) = static_cast<unsigned char>(256.0 * (*green));
*(itr++) = static_cast<unsigned char>(256.0 * (*red));
}
}
inline void import_rgb(float* red, float* green, float* blue) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
*(itr++) = static_cast<unsigned char>(256.0f * (*blue));
*(itr++) = static_cast<unsigned char>(256.0f * (*green));
*(itr++) = static_cast<unsigned char>(256.0f * (*red));
}
}
inline void import_rgb(unsigned char* red, unsigned char* green,
unsigned char* blue) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
*(itr++) = (*blue);
*(itr++) = (*green);
*(itr++) = (*red);
}
}
inline void import_ycbcr(double* y, double* cb, double* cr) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_); ++y, ++cb, ++cr) {
double y_ = (*y);
double cb_ = (*cb);
double cr_ = (*cr);
*(itr++) = static_cast<unsigned char>(
clamp((298.082 * y_ + 516.412 * cb_) / 256.0 - 276.836, 0.0, 255.0));
*(itr++) = static_cast<unsigned char>(clamp(
(298.082 * y_ - 100.291 * cb_ - 208.120 * cr_) / 256.0 + 135.576, 0.0,
255.0));
*(itr++) = static_cast<unsigned char>(
clamp((298.082 * y_ + 408.583 * cr_) / 256.0 - 222.921, 0.0, 255.0));
}
}
inline void import_rgb_clamped(double* red, double* green, double* blue) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
*(itr++) = static_cast<unsigned char>(
clamp<double>(256.0 * (*blue), 0.0, 255.0));
*(itr++) = static_cast<unsigned char>(
clamp<double>(256.0 * (*green), 0.0, 255.0));
*(itr++) =
static_cast<unsigned char>(clamp<double>(256.0 * (*red), 0.0, 255.0));
}
}
inline void import_rgb_clamped(float* red, float* green, float* blue) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
*(itr++) = static_cast<unsigned char>(
clamp<double>(256.0f * (*blue), 0.0, 255.0));
*(itr++) = static_cast<unsigned char>(
clamp<double>(256.0f * (*green), 0.0, 255.0));
*(itr++) = static_cast<unsigned char>(
clamp<double>(256.0f * (*red), 0.0, 255.0));
}
}
inline void import_rgb_normal(double* red, double* green, double* blue) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
*(itr++) = static_cast<unsigned char>(*blue);
*(itr++) = static_cast<unsigned char>(*green);
*(itr++) = static_cast<unsigned char>(*red);
}
}
inline void import_rgb_normal(float* red, float* green, float* blue) {
if (bgr_mode != channel_mode_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
++red, ++green, ++blue) {
*(itr++) = static_cast<unsigned char>(*blue);
*(itr++) = static_cast<unsigned char>(*green);
*(itr++) = static_cast<unsigned char>(*red);
}
}
inline void subsample(bitmap_image& dest) {
/*
Half sub-sample of original image.
*/
unsigned int w = 0;
unsigned int h = 0;
bool odd_width = false;
bool odd_height = false;
if (0 == (width_ % 2))
w = width_ / 2;
else {
w = 1 + (width_ / 2);
odd_width = true;
}
if (0 == (height_ % 2))
h = height_ / 2;
else {
h = 1 + (height_ / 2);
odd_height = true;
}
unsigned int horizontal_upper = (odd_width) ? (w - 1) : w;
unsigned int vertical_upper = (odd_height) ? (h - 1) : h;
dest.setwidth_height(w, h);
dest.clear();
unsigned char* s_itr[3];
const unsigned char* itr1[3];
const unsigned char* itr2[3];
s_itr[0] = dest.data_ + 0;
s_itr[1] = dest.data_ + 1;
s_itr[2] = dest.data_ + 2;
itr1[0] = data_ + 0;
itr1[1] = data_ + 1;
itr1[2] = data_ + 2;
itr2[0] = data_ + row_increment_ + 0;
itr2[1] = data_ + row_increment_ + 1;
itr2[2] = data_ + row_increment_ + 2;
unsigned int total = 0;
for (unsigned int j = 0; j < vertical_upper; ++j) {
for (unsigned int i = 0; i < horizontal_upper; ++i) {
for (unsigned int k = 0; k < bytes_per_pixel_;
s_itr[k] += bytes_per_pixel_, ++k) {
total = 0;
total += *(itr1[k]);
itr1[k] += bytes_per_pixel_;
total += *(itr1[k]);
itr1[k] += bytes_per_pixel_;
total += *(itr2[k]);
itr2[k] += bytes_per_pixel_;
total += *(itr2[k]);
itr2[k] += bytes_per_pixel_;
*(s_itr[k]) = static_cast<unsigned char>(total >> 2);
}
}
if (odd_width) {
for (unsigned int k = 0; k < bytes_per_pixel_;
s_itr[k] += bytes_per_pixel_, ++k) {
total = 0;
total += *(itr1[k]);
itr1[k] += bytes_per_pixel_;
total += *(itr2[k]);
itr2[k] += bytes_per_pixel_;
*(s_itr[k]) = static_cast<unsigned char>(total >> 1);
}
}
for (unsigned int k = 0; k < bytes_per_pixel_;
itr1[k] += row_increment_, ++k)
;
if (j != (vertical_upper - 1)) {
for (unsigned int k = 0; k < bytes_per_pixel_;
itr2[k] += row_increment_, ++k)
;
}
}
if (odd_height) {
for (unsigned int i = 0; i < horizontal_upper; ++i) {
for (unsigned int k = 0; k < bytes_per_pixel_;
s_itr[k] += bytes_per_pixel_, ++k) {
total = 0;
total += *(itr1[k]);
itr1[k] += bytes_per_pixel_;
total += *(itr2[k]);
itr2[k] += bytes_per_pixel_;
*(s_itr[k]) = static_cast<unsigned char>(total >> 1);
}
}
if (odd_width) {
for (unsigned int k = 0; k < bytes_per_pixel_; ++k) {
(*(s_itr[k])) = *(itr1[k]);
}
}
}
}
inline void upsample(bitmap_image& dest) {
/*
2x up-sample of original image.
*/
dest.setwidth_height(2 * width_, 2 * height_);
dest.clear();
const unsigned char* s_itr[3];
unsigned char* itr1[3];
unsigned char* itr2[3];
s_itr[0] = data_ + 0;
s_itr[1] = data_ + 1;
s_itr[2] = data_ + 2;
itr1[0] = dest.data_ + 0;
itr1[1] = dest.data_ + 1;
itr1[2] = dest.data_ + 2;
itr2[0] = dest.data_ + dest.row_increment_ + 0;
itr2[1] = dest.data_ + dest.row_increment_ + 1;
itr2[2] = dest.data_ + dest.row_increment_ + 2;
for (unsigned int j = 0; j < height_; ++j) {
for (unsigned int i = 0; i < width_; ++i) {
for (unsigned int k = 0; k < bytes_per_pixel_;
s_itr[k] += bytes_per_pixel_, ++k) {
*(itr1[k]) = *(s_itr[k]);
itr1[k] += bytes_per_pixel_;
*(itr1[k]) = *(s_itr[k]);
itr1[k] += bytes_per_pixel_;
*(itr2[k]) = *(s_itr[k]);
itr2[k] += bytes_per_pixel_;
*(itr2[k]) = *(s_itr[k]);
itr2[k] += bytes_per_pixel_;
}
}
for (unsigned int k = 0; k < bytes_per_pixel_; ++k) {
itr1[k] += dest.row_increment_;
itr2[k] += dest.row_increment_;
}
}
}
inline void alpha_blend(const double& alpha, const bitmap_image& image) {
if ((image.width_ != width_) || (image.height_ != height_)) {
return;
}
if ((alpha < 0.0) || (alpha > 1.0)) {
return;
}
unsigned char* itr1 = data_;
unsigned char* itr1_end = data_ + length_;
unsigned char* itr2 = image.data_;
double alpha_compliment = 1.0 - alpha;
while (itr1 != itr1_end) {
*(itr1) = static_cast<unsigned char>((alpha * (*itr2)) +
(alpha_compliment * (*itr1)));
++itr1;
++itr2;
}
}
inline double psnr(const bitmap_image& image) {
if ((image.width_ != width_) || (image.height_ != height_)) {
return 0.0;
}
unsigned char* itr1 = data_;
unsigned char* itr2 = image.data_;
double mse = 0.0;
while (itr1 != (data_ + length_)) {
double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
mse += v * v;
++itr1;
++itr2;
}
if (mse <= 0.0000001) {
return 1000000.0;
} else {
mse /= (3.0 * width_ * height_);
return 20.0 * std::log10(255.0 / std::sqrt(mse));
}
}
inline double psnr(const unsigned int& x, const unsigned int& y,
const bitmap_image& image) {
if ((x + image.width()) > width_) {
return 0.0;
}
if ((y + image.height()) > height_) {
return 0.0;
}
double mse = 0.0;
const unsigned int height = image.height();
const unsigned int width = image.width();
for (unsigned int r = 0; r < height; ++r) {
unsigned char* itr1 = row(r + y) + x * bytes_per_pixel_;
unsigned char* itr1_end = itr1 + (width * bytes_per_pixel_);
const unsigned char* itr2 = image.row(r);
while (itr1 != itr1_end) {
double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
mse += v * v;
++itr1;
++itr2;
}
}
if (mse <= 0.0000001) {
return 1000000.0;
} else {
mse /= (3.0 * image.width() * image.height());
return 20.0 * std::log10(255.0 / std::sqrt(mse));
}
}
inline void histogram(const color_plane color, double hist[256]) {
std::fill(hist, hist + 256, 0.0);
for (unsigned char* itr = (data_ + offset(color)); itr < (data_ + length_);
itr += bytes_per_pixel_) {
++hist[(*itr)];
}
}
inline void histogram_normalized(const color_plane color, double hist[256]) {
histogram(color, hist);
double* h_itr = hist;
const double* h_end = hist + 256;
const double pixel_count = static_cast<double>(width_ * height_);
while (h_end != h_itr) {
*(h_itr++) /= pixel_count;
}
}
inline unsigned int offset(const color_plane color) {
switch (channel_mode_) {
case rgb_mode: {
switch (color) {
case red_plane:
return 0;
case green_plane:
return 1;
case blue_plane:
return 2;
default:
return std::numeric_limits<unsigned int>::max();
}
}
case bgr_mode: {
switch (color) {
case red_plane:
return 2;
case green_plane:
return 1;
case blue_plane:
return 0;
default:
return std::numeric_limits<unsigned int>::max();
}
}
default:
return std::numeric_limits<unsigned int>::max();
}
}
inline void incremental() {
unsigned char current_color = 0;
for (unsigned char* itr = data_; itr < (data_ + length_);) {
(*itr++) = (current_color);
(*itr++) = (current_color);
(*itr++) = (current_color);
++current_color;
}
}
private:
struct bitmap_file_header {
unsigned short type;
unsigned int size;
unsigned short reserved1;
unsigned short reserved2;
unsigned int off_bits;
unsigned int struct_size() {
return sizeof(type) + sizeof(size) + sizeof(reserved1) +
sizeof(reserved2) + sizeof(off_bits);
}
};
struct bitmap_information_header {
unsigned int size;
unsigned int width;
unsigned int height;
unsigned short planes;
unsigned short bit_count;
unsigned int compression;
unsigned int size_image;
unsigned int x_pels_per_meter;
unsigned int y_pels_per_meter;
unsigned int clr_used;
unsigned int clr_important;
unsigned int struct_size() {
return sizeof(size) + sizeof(width) + sizeof(height) + sizeof(planes) +
sizeof(bit_count) + sizeof(compression) + sizeof(size_image) +
sizeof(x_pels_per_meter) + sizeof(y_pels_per_meter) +
sizeof(clr_used) + sizeof(clr_important);
}
};
inline bool big_endian() {
unsigned int v = 0x01;
return (1 != reinterpret_cast<char*>(&v)[0]);
}
inline unsigned short flip(const unsigned short& v) {
return ((v >> 8) | (v << 8));
}
inline unsigned int flip(const unsigned int& v) {
return (((v & 0xFF000000) >> 0x18) | ((v & 0x000000FF) << 0x18) |
((v & 0x00FF0000) >> 0x08) | ((v & 0x0000FF00) << 0x08));
}
template <typename T>
inline void read_from_stream(std::ifstream& stream, T& t) {
stream.read(reinterpret_cast<char*>(&t), sizeof(T));
}
template <typename T>
inline void write_to_stream(std::ofstream& stream, const T& t) {
stream.write(reinterpret_cast<const char*>(&t), sizeof(T));
}
inline void read_bfh(std::ifstream& stream, bitmap_file_header& bfh) {
read_from_stream(stream, bfh.type);
read_from_stream(stream, bfh.size);
read_from_stream(stream, bfh.reserved1);
read_from_stream(stream, bfh.reserved2);
read_from_stream(stream, bfh.off_bits);
if (big_endian()) {
bfh.type = flip(bfh.type);
bfh.size = flip(bfh.size);
bfh.reserved1 = flip(bfh.reserved1);
bfh.reserved2 = flip(bfh.reserved2);
bfh.off_bits = flip(bfh.off_bits);
}
}
inline void write_bfh(std::ofstream& stream, const bitmap_file_header& bfh) {
if (big_endian()) {
write_to_stream(stream, flip(bfh.type));
write_to_stream(stream, flip(bfh.size));
write_to_stream(stream, flip(bfh.reserved1));
write_to_stream(stream, flip(bfh.reserved2));
write_to_stream(stream, flip(bfh.off_bits));
} else {
write_to_stream(stream, bfh.type);
write_to_stream(stream, bfh.size);
write_to_stream(stream, bfh.reserved1);
write_to_stream(stream, bfh.reserved2);
write_to_stream(stream, bfh.off_bits);
}
}
inline void read_bih(std::ifstream& stream, bitmap_information_header& bih) {
read_from_stream(stream, bih.size);
read_from_stream(stream, bih.width);
read_from_stream(stream, bih.height);
read_from_stream(stream, bih.planes);
read_from_stream(stream, bih.bit_count);
read_from_stream(stream, bih.compression);
read_from_stream(stream, bih.size_image);
read_from_stream(stream, bih.x_pels_per_meter);
read_from_stream(stream, bih.y_pels_per_meter);
read_from_stream(stream, bih.clr_used);
read_from_stream(stream, bih.clr_important);
if (big_endian()) {
bih.size = flip(bih.size);
bih.width = flip(bih.width);
bih.height = flip(bih.height);
bih.planes = flip(bih.planes);
bih.bit_count = flip(bih.bit_count);
bih.compression = flip(bih.compression);
bih.size_image = flip(bih.size_image);
bih.x_pels_per_meter = flip(bih.x_pels_per_meter);
bih.y_pels_per_meter = flip(bih.y_pels_per_meter);
bih.clr_used = flip(bih.clr_used);
bih.clr_important = flip(bih.clr_important);
}
}
inline void write_bih(std::ofstream& stream,
const bitmap_information_header& bih) {
if (big_endian()) {
write_to_stream(stream, flip(bih.size));
write_to_stream(stream, flip(bih.width));
write_to_stream(stream, flip(bih.height));
write_to_stream(stream, flip(bih.planes));
write_to_stream(stream, flip(bih.bit_count));
write_to_stream(stream, flip(bih.compression));
write_to_stream(stream, flip(bih.size_image));
write_to_stream(stream, flip(bih.x_pels_per_meter));
write_to_stream(stream, flip(bih.y_pels_per_meter));
write_to_stream(stream, flip(bih.clr_used));
write_to_stream(stream, flip(bih.clr_important));
} else {
write_to_stream(stream, bih.size);
write_to_stream(stream, bih.width);
write_to_stream(stream, bih.height);
write_to_stream(stream, bih.planes);
write_to_stream(stream, bih.bit_count);
write_to_stream(stream, bih.compression);
write_to_stream(stream, bih.size_image);
write_to_stream(stream, bih.x_pels_per_meter);
write_to_stream(stream, bih.y_pels_per_meter);
write_to_stream(stream, bih.clr_used);
write_to_stream(stream, bih.clr_important);
}
}
void create_bitmap() {
length_ = width_ * height_ * bytes_per_pixel_;
row_increment_ = width_ * bytes_per_pixel_;
if (0 != data_) {
delete[] data_;
}
data_ = new unsigned char[length_];
}
void load_bitmap() {
std::ifstream stream(file_name_.c_str(), std::ios::binary);
if (!stream) {
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - file "
<< file_name_ << " not found!" << std::endl;
return;
}
bitmap_file_header bfh;
bitmap_information_header bih;
read_bfh(stream, bfh);
read_bih(stream, bih);
if (bfh.type != 19778) {
stream.close();
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid "
"type value "
<< bfh.type << " expected 19778." << std::endl;
return;
}
if (bih.bit_count != 24) {
stream.close();
std::cerr << "bitmap_image::load_bitmap() ERROR: bitmap_image - Invalid "
"bit depth "
<< bih.bit_count << " expected 24." << std::endl;
return;
}
height_ = bih.height;
width_ = bih.width;
bytes_per_pixel_ = bih.bit_count >> 3;
unsigned int padding = (4 - ((3 * width_) % 4)) % 4;
char padding_data[4] = {0, 0, 0, 0};
create_bitmap();
for (unsigned int i = 0; i < height_; ++i) {
unsigned char* data_ptr =
row(height_ - i - 1); // read in inverted row order
stream.read(reinterpret_cast<char*>(data_ptr),
sizeof(char) * bytes_per_pixel_ * width_);
stream.read(padding_data, padding);
}
}
inline void reverse_channels() {
if (3 != bytes_per_pixel_) return;
for (unsigned char* itr = data_; itr < (data_ + length_);
itr += bytes_per_pixel_) {
unsigned char tmp = *(itr + 0);
*(itr + 0) = *(itr + 2);
*(itr + 2) = tmp;
}
}
template <typename T>
inline T clamp(const T& v, const T& lower_range, const T& upper_range) {
if (v < lower_range)
return lower_range;
else if (v > upper_range)
return upper_range;
else
return v;
}
std::string file_name_;
unsigned char* data_;
unsigned int length_;
unsigned int width_;
unsigned int height_;
unsigned int row_increment_;
unsigned int bytes_per_pixel_;
channel_mode channel_mode_;
};
struct rgb_store {
unsigned char red;
unsigned char green;
unsigned char blue;
};
inline void rgb_to_ycbcr(const unsigned int& length, double* red, double* green,
double* blue, double* y, double* cb, double* cr) {
unsigned int i = 0;
while (i < length) {
(*y) = 16.0 + (65.481 * (*red) + 128.553 * (*green) + 24.966 * (*blue));
(*cb) = 128.0 + (-37.797 * (*red) + -74.203 * (*green) + 112.000 * (*blue));
(*cr) = 128.0 + (112.000 * (*red) + -93.786 * (*green) - 18.214 * (*blue));
++i;
++red;
++green;
++blue;
++y;
++cb;
++cr;
}
}
inline void ycbcr_to_rgb(const unsigned int& length, double* y, double* cb,
double* cr, double* red, double* green, double* blue) {
unsigned int i = 0;
while (i < length) {
double y_ = (*y) - 16.0;
double cb_ = (*cb) - 128.0;
double cr_ = (*cr) - 128.0;
(*red) = 0.000456621 * y_ + 0.00625893 * cr_;
(*green) = 0.000456621 * y_ - 0.00153632 * cb_ - 0.00318811 * cr_;
(*blue) = 0.000456621 * y_ + 0.00791071 * cb_;
++i;
++red;
++green;
++blue;
++y;
++cb;
++cr;
}
}
inline void subsample(const unsigned int& width, const unsigned int& height,
const double* source, unsigned int& w, unsigned int& h,
double** dest) {
/* Single channel. */
w = 0;
h = 0;
bool odd_width = false;
bool odd_height = false;
if (0 == (width % 2))
w = width / 2;
else {
w = 1 + (width / 2);
odd_width = true;
}
if (0 == (height % 2))
h = height / 2;
else {
h = 1 + (height / 2);
odd_height = true;
}
unsigned int horizontal_upper = (odd_width) ? w - 1 : w;
unsigned int vertical_upper = (odd_height) ? h - 1 : h;
*dest = new double[w * h];
double* s_itr = *dest;
const double* itr1 = source;
const double* itr2 = source + width;
for (unsigned int j = 0; j < vertical_upper; ++j) {
for (unsigned int i = 0; i < horizontal_upper; ++i, ++s_itr) {
(*s_itr) = *(itr1++);
(*s_itr) += *(itr1++);
(*s_itr) += *(itr2++);
(*s_itr) += *(itr2++);
(*s_itr) /= 4.0;
}
if (odd_width) {
(*(s_itr++)) = ((*itr1++) + (*itr2++)) / 2.0;
}
itr1 += width;
if (j != (vertical_upper - 1)) {
itr2 += width;
}
}
if (odd_height) {
for (unsigned int i = 0; i < horizontal_upper; ++i, ++s_itr) {
(*s_itr) += (*(itr1++));
(*s_itr) += (*(itr1++));
(*s_itr) /= 2.0;
}
if (odd_width) {
(*(s_itr++)) = (*itr1);
}
}
}
inline void upsample(const unsigned int& width, const unsigned int& height,
const double* source, unsigned int& w, unsigned int& h,
double** dest) {
/* Single channel. */
w = 2 * width;
h = 2 * height;
*dest = new double[w * h];
const double* s_itr = source;
double* itr1 = *dest;
double* itr2 = *dest + w;
for (unsigned int j = 0; j < height; ++j) {
for (unsigned int i = 0; i < width; ++i, ++s_itr) {
*(itr1++) = (*s_itr);
*(itr1++) = (*s_itr);
*(itr2++) = (*s_itr);
*(itr2++) = (*s_itr);
}
itr1 += w;
itr2 += w;
}
}
inline void checkered_pattern(const unsigned int x_width,
const unsigned int y_width,
const unsigned char value,
const bitmap_image::color_plane color,
bitmap_image& image) {
if ((x_width >= image.width()) || (y_width >= image.height())) {
return;
}
bool setter_x = false;
bool setter_y = true;
const unsigned int color_plane_offset = image.offset(color);
const unsigned int height = image.height();
const unsigned int width = image.width();
for (unsigned int y = 0; y < height; ++y) {
if (0 == (y % y_width)) {
setter_y = !setter_y;
}
unsigned char* row = image.row(y) + color_plane_offset;
for (unsigned int x = 0; x < width; ++x, row += image.bytes_per_pixel()) {
if (0 == (x % x_width)) {
setter_x = !setter_x;
}
if (setter_x ^ setter_y) {
*row = value;
}
}
}
}
inline void checkered_pattern(const unsigned int x_width,
const unsigned int y_width,
const unsigned char red,
const unsigned char green,
const unsigned char blue, bitmap_image& image) {
if ((x_width >= image.width()) || (y_width >= image.height())) {
return;
}
bool setter_x = false;
bool setter_y = true;
const unsigned int height = image.height();
const unsigned int width = image.width();
for (unsigned int y = 0; y < height; ++y) {
if (0 == (y % y_width)) {
setter_y = !setter_y;
}
unsigned char* row = image.row(y);
for (unsigned int x = 0; x < width; ++x, row += image.bytes_per_pixel()) {
if (0 == (x % x_width)) {
setter_x = !setter_x;
}
if (setter_x ^ setter_y) {
*(row + 0) = blue;
*(row + 1) = green;
*(row + 2) = red;
}
}
}
}
inline void plasma(bitmap_image& image, const double& x, const double& y,
const double& width, const double& height, const double& c1,
const double& c2, const double& c3, const double& c4,
const double& roughness = 3.0,
const rgb_store colormap[] = 0) {
// Note: c1,c2,c3,c4 -> [0.0,1.0]
double half_width = (width / 2.0);
double half_height = (height / 2.0);
if ((width >= 1.0) || (height >= 1.0)) {
double corner1 = (c1 + c2) / 2.0;
double corner2 = (c2 + c3) / 2.0;
double corner3 = (c3 + c4) / 2.0;
double corner4 = (c4 + c1) / 2.0;
double center = (c1 + c2 + c3 + c4) / 4.0 +
((1.0 * ::rand() / (1.0 * RAND_MAX)) -
0.5) * // should use a better rng
((1.0 * half_width + half_height) /
(image.width() + image.height()) * roughness);
center = std::min<double>(std::max<double>(0.0, center), 1.0);
plasma(image, x, y, half_width, half_height, c1, corner1, center, corner4,
roughness, colormap);
plasma(image, x + half_width, y, half_width, half_height, corner1, c2,
corner2, center, roughness, colormap);
plasma(image, x + half_width, y + half_height, half_width, half_height,
center, corner2, c3, corner3, roughness, colormap);
plasma(image, x, y + half_height, half_width, half_height, corner4, center,
corner3, c4, roughness, colormap);
} else {
rgb_store color = colormap[static_cast<unsigned int>(
1000.0 * ((c1 + c2 + c3 + c4) / 4.0)) %
1000];
image.set_pixel(static_cast<unsigned int>(x), static_cast<unsigned int>(y),
color.red, color.green, color.blue);
}
}
inline double psnr_region(const unsigned int& x, const unsigned int& y,
const unsigned int& width, const unsigned int& height,
const bitmap_image& image1,
const bitmap_image& image2) {
if ((image1.width() != image2.width()) ||
(image1.height() != image2.height())) {
return 0.0;
}
if ((x + width) > image1.width()) {
return 0.0;
}
if ((y + height) > image1.height()) {
return 0.0;
}
double mse = 0.0;
for (unsigned int r = 0; r < height; ++r) {
const unsigned char* itr1 =
image1.row(r + y) + x * image1.bytes_per_pixel();
const unsigned char* itr1_end = itr1 + (width * image1.bytes_per_pixel());
const unsigned char* itr2 =
image2.row(r + y) + x * image2.bytes_per_pixel();
while (itr1 != itr1_end) {
double v = (static_cast<double>(*itr1) - static_cast<double>(*itr2));
mse += v * v;
++itr1;
++itr2;
}
}
if (mse <= 0.0000001) {
return 1000000.0;
} else {
mse /= (3.0 * width * height);
return 20.0 * std::log10(255.0 / std::sqrt(mse));
}
}
inline void hierarchical_psnr_r(const double& x, const double& y,
const double& width, const double& height,
const bitmap_image& image1,
bitmap_image& image2, const double& threshold,
const rgb_store colormap[]) {
if ((width <= 4.0) || (height <= 4.0)) {
double psnr =
psnr_region(static_cast<unsigned int>(x), static_cast<unsigned int>(y),
static_cast<unsigned int>(width),
static_cast<unsigned int>(height), image1, image2);
if (psnr < threshold) {
rgb_store c = colormap[static_cast<unsigned int>(
1000.0 * (1.0 - (psnr / threshold)))];
image2.set_region(
static_cast<unsigned int>(x), static_cast<unsigned int>(y),
static_cast<unsigned int>(width + 1),
static_cast<unsigned int>(height + 1), c.red, c.green, c.blue);
}
} else {
double half_width = (width / 2.0);
double half_height = (height / 2.0);
hierarchical_psnr_r(x, y, half_width, half_height, image1, image2,
threshold, colormap);
hierarchical_psnr_r(x + half_width, y, half_width, half_height, image1,
image2, threshold, colormap);
hierarchical_psnr_r(x + half_width, y + half_height, half_width,
half_height, image1, image2, threshold, colormap);
hierarchical_psnr_r(x, y + half_height, half_width, half_height, image1,
image2, threshold, colormap);
}
}
inline void hierarchical_psnr(bitmap_image& image1, bitmap_image& image2,
const double threshold,
const rgb_store colormap[]) {
if ((image1.width() != image2.width()) ||
(image1.height() != image2.height())) {
return;
}
double psnr =
psnr_region(0, 0, image1.width(), image1.height(), image1, image2);
if (psnr < threshold) {
hierarchical_psnr_r(0, 0, image1.width(), image1.height(), image1, image2,
threshold, colormap);
}
}
class image_drawer {
public:
image_drawer(bitmap_image& image)
: image_(image),
pen_width_(1),
pen_color_red_(0),
pen_color_green_(0),
pen_color_blue_(0) {}
void rectangle(int x1, int y1, int x2, int y2) {
line_segment(x1, y1, x2, y1);
line_segment(x2, y1, x2, y2);
line_segment(x2, y2, x1, y2);
line_segment(x1, y2, x1, y1);
}
void triangle(int x1, int y1, int x2, int y2, int x3, int y3) {
line_segment(x1, y1, x2, y2);
line_segment(x2, y2, x3, y3);
line_segment(x3, y3, x1, y1);
}
void quadix(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
line_segment(x1, y1, x2, y2);
line_segment(x2, y2, x3, y3);
line_segment(x3, y3, x4, y4);
line_segment(x4, y4, x1, y1);
}
void line_segment(int x1, int y1, int x2, int y2) {
int steep = 0;
int sx = ((x2 - x1) > 0) ? 1 : -1;
int sy = ((y2 - y1) > 0) ? 1 : -1;
int dx = abs(x2 - x1);
int dy = abs(y2 - y1);
if (dy > dx) {
steep = x1;
x1 = y1;
y1 = steep; /* swap x1 and y1 */
steep = dx;
dx = dy;
dy = steep; /* swap dx and dy */
steep = sx;
sx = sy;
sy = steep; /* swap sx and sy */
steep = 1;
}
int e = 2 * dy - dx;
for (int i = 0; i < dx; ++i) {
if (steep)
plot_pen_pixel(y1, x1);
else
plot_pen_pixel(x1, y1);
while (e >= 0) {
y1 += sy;
e -= (dx << 1);
}
x1 += sx;
e += (dy << 1);
}
plot_pen_pixel(x2, y2);
}
void horiztonal_line_segment(int x1, int x2, int y) {
if (x1 > x2) {
std::swap(x1, x2);
}
for (int i = 0; i < (x2 - x1); ++i) {
plot_pen_pixel(x1 + i, y);
}
}
void vertical_line_segment(int y1, int y2, int x) {
if (y1 > y2) {
std::swap(y1, y2);
}
for (int i = 0; i < (y2 - y1); ++i) {
plot_pen_pixel(x, y1 + i);
}
}
void ellipse(int centerx, int centery, int a, int b) {
int t1 = a * a;
int t2 = t1 << 1;
int t3 = t2 << 1;
int t4 = b * b;
int t5 = t4 << 1;
int t6 = t5 << 1;
int t7 = a * t5;
int t8 = t7 << 1;
int t9 = 0;
int d1 = t2 - t7 + (t4 >> 1);
int d2 = (t1 >> 1) - t8 + t5;
int x = a;
int y = 0;
int negative_tx = centerx - x;
int positive_tx = centerx + x;
int negative_ty = centery - y;
int positive_ty = centery + y;
while (d2 < 0) {
plot_pen_pixel(positive_tx, positive_ty);
plot_pen_pixel(positive_tx, negative_ty);
plot_pen_pixel(negative_tx, positive_ty);
plot_pen_pixel(negative_tx, negative_ty);
++y;
t9 = t9 + t3;
if (d1 < 0) {
d1 = d1 + t9 + t2;
d2 = d2 + t9;
} else {
x--;
t8 = t8 - t6;
d1 = d1 + (t9 + t2 - t8);
d2 = d2 + (t9 + t5 - t8);
negative_tx = centerx - x;
positive_tx = centerx + x;
}
negative_ty = centery - y;
positive_ty = centery + y;
}
do {
plot_pen_pixel(positive_tx, positive_ty);
plot_pen_pixel(positive_tx, negative_ty);
plot_pen_pixel(negative_tx, positive_ty);
plot_pen_pixel(negative_tx, negative_ty);
x--;
t8 = t8 - t6;
if (d2 < 0) {
++y;
t9 = t9 + t3;
d2 = d2 + (t9 + t5 - t8);
negative_ty = centery - y;
positive_ty = centery + y;
} else
d2 = d2 + (t5 - t8);
negative_tx = centerx - x;
positive_tx = centerx + x;
} while (x >= 0);
}
void circle(int centerx, int centery, int radius) {
int x = 0;
int d = (1 - radius) << 1;
while (radius >= 0) {
plot_pen_pixel(centerx + x, centery + radius);
plot_pen_pixel(centerx + x, centery - radius);
plot_pen_pixel(centerx - x, centery + radius);
plot_pen_pixel(centerx - x, centery - radius);
if ((d + radius) > 0) d -= ((--radius) << 1) - 1;
if (x > d) d += ((++x) << 1) + 1;
}
}
void plot_pen_pixel(int x, int y) {
switch (pen_width_) {
case 1:
plot_pixel(x, y);
break;
case 2: {
plot_pixel(x, y);
plot_pixel(x + 1, y);
plot_pixel(x + 1, y + 1);
plot_pixel(x, y + 1);
} break;
case 3: {
plot_pixel(x, y - 1);
plot_pixel(x - 1, y - 1);
plot_pixel(x + 1, y - 1);
plot_pixel(x, y);
plot_pixel(x - 1, y);
plot_pixel(x + 1, y);
plot_pixel(x, y + 1);
plot_pixel(x - 1, y + 1);
plot_pixel(x + 1, y + 1);
} break;
default:
plot_pixel(x, y);
break;
}
}
void plot_pixel(int x, int y) {
image_.set_pixel(x, y, pen_color_red_, pen_color_green_, pen_color_blue_);
}
void pen_width(const unsigned int& width) {
if ((width > 0) && (width < 4)) {
pen_width_ = width;
}
}
void pen_color(const unsigned char& red, const unsigned char& green,
const unsigned char& blue) {
pen_color_red_ = red;
pen_color_green_ = green;
pen_color_blue_ = blue;
}
private:
image_drawer(const image_drawer& id);
image_drawer& operator=(const image_drawer& id);
bitmap_image& image_;
unsigned int pen_width_;
unsigned char pen_color_red_;
unsigned char pen_color_green_;
unsigned char pen_color_blue_;
};
const rgb_store autumn_colormap[1000] = {
{255, 0, 0}, {255, 0, 0}, {255, 1, 0}, {255, 1, 0}, {255, 1, 0},
{255, 1, 0}, {255, 2, 0}, {255, 2, 0}, {255, 2, 0}, {255, 2, 0},
{255, 3, 0}, {255, 3, 0}, {255, 3, 0}, {255, 3, 0}, {255, 4, 0},
{255, 4, 0}, {255, 4, 0}, {255, 4, 0}, {255, 5, 0}, {255, 5, 0},
{255, 5, 0}, {255, 5, 0}, {255, 6, 0}, {255, 6, 0}, {255, 6, 0},
{255, 6, 0}, {255, 7, 0}, {255, 7, 0}, {255, 7, 0}, {255, 7, 0},
{255, 8, 0}, {255, 8, 0}, {255, 8, 0}, {255, 8, 0}, {255, 9, 0},
{255, 9, 0}, {255, 9, 0}, {255, 9, 0}, {255, 10, 0}, {255, 10, 0},
{255, 10, 0}, {255, 10, 0}, {255, 11, 0}, {255, 11, 0}, {255, 11, 0},
{255, 11, 0}, {255, 12, 0}, {255, 12, 0}, {255, 12, 0}, {255, 13, 0},
{255, 13, 0}, {255, 13, 0}, {255, 13, 0}, {255, 14, 0}, {255, 14, 0},
{255, 14, 0}, {255, 14, 0}, {255, 15, 0}, {255, 15, 0}, {255, 15, 0},
{255, 15, 0}, {255, 16, 0}, {255, 16, 0}, {255, 16, 0}, {255, 16, 0},
{255, 17, 0}, {255, 17, 0}, {255, 17, 0}, {255, 17, 0}, {255, 18, 0},
{255, 18, 0}, {255, 18, 0}, {255, 18, 0}, {255, 19, 0}, {255, 19, 0},
{255, 19, 0}, {255, 19, 0}, {255, 20, 0}, {255, 20, 0}, {255, 20, 0},
{255, 20, 0}, {255, 21, 0}, {255, 21, 0}, {255, 21, 0}, {255, 21, 0},
{255, 22, 0}, {255, 22, 0}, {255, 22, 0}, {255, 22, 0}, {255, 23, 0},
{255, 23, 0}, {255, 23, 0}, {255, 23, 0}, {255, 24, 0}, {255, 24, 0},
{255, 24, 0}, {255, 25, 0}, {255, 25, 0}, {255, 25, 0}, {255, 25, 0},
{255, 26, 0}, {255, 26, 0}, {255, 26, 0}, {255, 26, 0}, {255, 27, 0},
{255, 27, 0}, {255, 27, 0}, {255, 27, 0}, {255, 28, 0}, {255, 28, 0},
{255, 28, 0}, {255, 28, 0}, {255, 29, 0}, {255, 29, 0}, {255, 29, 0},
{255, 29, 0}, {255, 30, 0}, {255, 30, 0}, {255, 30, 0}, {255, 30, 0},
{255, 31, 0}, {255, 31, 0}, {255, 31, 0}, {255, 31, 0}, {255, 32, 0},
{255, 32, 0}, {255, 32, 0}, {255, 32, 0}, {255, 33, 0}, {255, 33, 0},
{255, 33, 0}, {255, 33, 0}, {255, 34, 0}, {255, 34, 0}, {255, 34, 0},
{255, 34, 0}, {255, 35, 0}, {255, 35, 0}, {255, 35, 0}, {255, 35, 0},
{255, 36, 0}, {255, 36, 0}, {255, 36, 0}, {255, 37, 0}, {255, 37, 0},
{255, 37, 0}, {255, 37, 0}, {255, 38, 0}, {255, 38, 0}, {255, 38, 0},
{255, 38, 0}, {255, 39, 0}, {255, 39, 0}, {255, 39, 0}, {255, 39, 0},
{255, 40, 0}, {255, 40, 0}, {255, 40, 0}, {255, 40, 0}, {255, 41, 0},
{255, 41, 0}, {255, 41, 0}, {255, 41, 0}, {255, 42, 0}, {255, 42, 0},
{255, 42, 0}, {255, 42, 0}, {255, 43, 0}, {255, 43, 0}, {255, 43, 0},
{255, 43, 0}, {255, 44, 0}, {255, 44, 0}, {255, 44, 0}, {255, 44, 0},
{255, 45, 0}, {255, 45, 0}, {255, 45, 0}, {255, 45, 0}, {255, 46, 0},
{255, 46, 0}, {255, 46, 0}, {255, 46, 0}, {255, 47, 0}, {255, 47, 0},
{255, 47, 0}, {255, 47, 0}, {255, 48, 0}, {255, 48, 0}, {255, 48, 0},
{255, 48, 0}, {255, 49, 0}, {255, 49, 0}, {255, 49, 0}, {255, 50, 0},
{255, 50, 0}, {255, 50, 0}, {255, 50, 0}, {255, 51, 0}, {255, 51, 0},
{255, 51, 0}, {255, 51, 0}, {255, 52, 0}, {255, 52, 0}, {255, 52, 0},
{255, 52, 0}, {255, 53, 0}, {255, 53, 0}, {255, 53, 0}, {255, 53, 0},
{255, 54, 0}, {255, 54, 0}, {255, 54, 0}, {255, 54, 0}, {255, 55, 0},
{255, 55, 0}, {255, 55, 0}, {255, 55, 0}, {255, 56, 0}, {255, 56, 0},
{255, 56, 0}, {255, 56, 0}, {255, 57, 0}, {255, 57, 0}, {255, 57, 0},
{255, 57, 0}, {255, 58, 0}, {255, 58, 0}, {255, 58, 0}, {255, 58, 0},
{255, 59, 0}, {255, 59, 0}, {255, 59, 0}, {255, 59, 0}, {255, 60, 0},
{255, 60, 0}, {255, 60, 0}, {255, 60, 0}, {255, 61, 0}, {255, 61, 0},
{255, 61, 0}, {255, 62, 0}, {255, 62, 0}, {255, 62, 0}, {255, 62, 0},
{255, 63, 0}, {255, 63, 0}, {255, 63, 0}, {255, 63, 0}, {255, 64, 0},
{255, 64, 0}, {255, 64, 0}, {255, 64, 0}, {255, 65, 0}, {255, 65, 0},
{255, 65, 0}, {255, 65, 0}, {255, 66, 0}, {255, 66, 0}, {255, 66, 0},
{255, 66, 0}, {255, 67, 0}, {255, 67, 0}, {255, 67, 0}, {255, 67, 0},
{255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 68, 0}, {255, 69, 0},
{255, 69, 0}, {255, 69, 0}, {255, 69, 0}, {255, 70, 0}, {255, 70, 0},
{255, 70, 0}, {255, 70, 0}, {255, 71, 0}, {255, 71, 0}, {255, 71, 0},
{255, 71, 0}, {255, 72, 0}, {255, 72, 0}, {255, 72, 0}, {255, 72, 0},
{255, 73, 0}, {255, 73, 0}, {255, 73, 0}, {255, 74, 0}, {255, 74, 0},
{255, 74, 0}, {255, 74, 0}, {255, 75, 0}, {255, 75, 0}, {255, 75, 0},
{255, 75, 0}, {255, 76, 0}, {255, 76, 0}, {255, 76, 0}, {255, 76, 0},
{255, 77, 0}, {255, 77, 0}, {255, 77, 0}, {255, 77, 0}, {255, 78, 0},
{255, 78, 0}, {255, 78, 0}, {255, 78, 0}, {255, 79, 0}, {255, 79, 0},
{255, 79, 0}, {255, 79, 0}, {255, 80, 0}, {255, 80, 0}, {255, 80, 0},
{255, 80, 0}, {255, 81, 0}, {255, 81, 0}, {255, 81, 0}, {255, 81, 0},
{255, 82, 0}, {255, 82, 0}, {255, 82, 0}, {255, 82, 0}, {255, 83, 0},
{255, 83, 0}, {255, 83, 0}, {255, 83, 0}, {255, 84, 0}, {255, 84, 0},
{255, 84, 0}, {255, 84, 0}, {255, 85, 0}, {255, 85, 0}, {255, 85, 0},
{255, 86, 0}, {255, 86, 0}, {255, 86, 0}, {255, 86, 0}, {255, 87, 0},
{255, 87, 0}, {255, 87, 0}, {255, 87, 0}, {255, 88, 0}, {255, 88, 0},
{255, 88, 0}, {255, 88, 0}, {255, 89, 0}, {255, 89, 0}, {255, 89, 0},
{255, 89, 0}, {255, 90, 0}, {255, 90, 0}, {255, 90, 0}, {255, 90, 0},
{255, 91, 0}, {255, 91, 0}, {255, 91, 0}, {255, 91, 0}, {255, 92, 0},
{255, 92, 0}, {255, 92, 0}, {255, 92, 0}, {255, 93, 0}, {255, 93, 0},
{255, 93, 0}, {255, 93, 0}, {255, 94, 0}, {255, 94, 0}, {255, 94, 0},
{255, 94, 0}, {255, 95, 0}, {255, 95, 0}, {255, 95, 0}, {255, 95, 0},
{255, 96, 0}, {255, 96, 0}, {255, 96, 0}, {255, 96, 0}, {255, 97, 0},
{255, 97, 0}, {255, 97, 0}, {255, 98, 0}, {255, 98, 0}, {255, 98, 0},
{255, 98, 0}, {255, 99, 0}, {255, 99, 0}, {255, 99, 0}, {255, 99, 0},
{255, 100, 0}, {255, 100, 0}, {255, 100, 0}, {255, 100, 0}, {255, 101, 0},
{255, 101, 0}, {255, 101, 0}, {255, 101, 0}, {255, 102, 0}, {255, 102, 0},
{255, 102, 0}, {255, 102, 0}, {255, 103, 0}, {255, 103, 0}, {255, 103, 0},
{255, 103, 0}, {255, 104, 0}, {255, 104, 0}, {255, 104, 0}, {255, 104, 0},
{255, 105, 0}, {255, 105, 0}, {255, 105, 0}, {255, 105, 0}, {255, 106, 0},
{255, 106, 0}, {255, 106, 0}, {255, 106, 0}, {255, 107, 0}, {255, 107, 0},
{255, 107, 0}, {255, 107, 0}, {255, 108, 0}, {255, 108, 0}, {255, 108, 0},
{255, 108, 0}, {255, 109, 0}, {255, 109, 0}, {255, 109, 0}, {255, 110, 0},
{255, 110, 0}, {255, 110, 0}, {255, 110, 0}, {255, 111, 0}, {255, 111, 0},
{255, 111, 0}, {255, 111, 0}, {255, 112, 0}, {255, 112, 0}, {255, 112, 0},
{255, 112, 0}, {255, 113, 0}, {255, 113, 0}, {255, 113, 0}, {255, 113, 0},
{255, 114, 0}, {255, 114, 0}, {255, 114, 0}, {255, 114, 0}, {255, 115, 0},
{255, 115, 0}, {255, 115, 0}, {255, 115, 0}, {255, 116, 0}, {255, 116, 0},
{255, 116, 0}, {255, 116, 0}, {255, 117, 0}, {255, 117, 0}, {255, 117, 0},
{255, 117, 0}, {255, 118, 0}, {255, 118, 0}, {255, 118, 0}, {255, 118, 0},
{255, 119, 0}, {255, 119, 0}, {255, 119, 0}, {255, 119, 0}, {255, 120, 0},
{255, 120, 0}, {255, 120, 0}, {255, 120, 0}, {255, 121, 0}, {255, 121, 0},
{255, 121, 0}, {255, 122, 0}, {255, 122, 0}, {255, 122, 0}, {255, 122, 0},
{255, 123, 0}, {255, 123, 0}, {255, 123, 0}, {255, 123, 0}, {255, 124, 0},
{255, 124, 0}, {255, 124, 0}, {255, 124, 0}, {255, 125, 0}, {255, 125, 0},
{255, 125, 0}, {255, 125, 0}, {255, 126, 0}, {255, 126, 0}, {255, 126, 0},
{255, 126, 0}, {255, 127, 0}, {255, 127, 0}, {255, 127, 0}, {255, 127, 0},
{255, 128, 0}, {255, 128, 0}, {255, 128, 0}, {255, 128, 0}, {255, 129, 0},
{255, 129, 0}, {255, 129, 0}, {255, 129, 0}, {255, 130, 0}, {255, 130, 0},
{255, 130, 0}, {255, 130, 0}, {255, 131, 0}, {255, 131, 0}, {255, 131, 0},
{255, 131, 0}, {255, 132, 0}, {255, 132, 0}, {255, 132, 0}, {255, 132, 0},
{255, 133, 0}, {255, 133, 0}, {255, 133, 0}, {255, 133, 0}, {255, 134, 0},
{255, 134, 0}, {255, 134, 0}, {255, 135, 0}, {255, 135, 0}, {255, 135, 0},
{255, 135, 0}, {255, 136, 0}, {255, 136, 0}, {255, 136, 0}, {255, 136, 0},
{255, 137, 0}, {255, 137, 0}, {255, 137, 0}, {255, 137, 0}, {255, 138, 0},
{255, 138, 0}, {255, 138, 0}, {255, 138, 0}, {255, 139, 0}, {255, 139, 0},
{255, 139, 0}, {255, 139, 0}, {255, 140, 0}, {255, 140, 0}, {255, 140, 0},
{255, 140, 0}, {255, 141, 0}, {255, 141, 0}, {255, 141, 0}, {255, 141, 0},
{255, 142, 0}, {255, 142, 0}, {255, 142, 0}, {255, 142, 0}, {255, 143, 0},
{255, 143, 0}, {255, 143, 0}, {255, 143, 0}, {255, 144, 0}, {255, 144, 0},
{255, 144, 0}, {255, 144, 0}, {255, 145, 0}, {255, 145, 0}, {255, 145, 0},
{255, 145, 0}, {255, 146, 0}, {255, 146, 0}, {255, 146, 0}, {255, 147, 0},
{255, 147, 0}, {255, 147, 0}, {255, 147, 0}, {255, 148, 0}, {255, 148, 0},
{255, 148, 0}, {255, 148, 0}, {255, 149, 0}, {255, 149, 0}, {255, 149, 0},
{255, 149, 0}, {255, 150, 0}, {255, 150, 0}, {255, 150, 0}, {255, 150, 0},
{255, 151, 0}, {255, 151, 0}, {255, 151, 0}, {255, 151, 0}, {255, 152, 0},
{255, 152, 0}, {255, 152, 0}, {255, 152, 0}, {255, 153, 0}, {255, 153, 0},
{255, 153, 0}, {255, 153, 0}, {255, 154, 0}, {255, 154, 0}, {255, 154, 0},
{255, 154, 0}, {255, 155, 0}, {255, 155, 0}, {255, 155, 0}, {255, 155, 0},
{255, 156, 0}, {255, 156, 0}, {255, 156, 0}, {255, 156, 0}, {255, 157, 0},
{255, 157, 0}, {255, 157, 0}, {255, 157, 0}, {255, 158, 0}, {255, 158, 0},
{255, 158, 0}, {255, 159, 0}, {255, 159, 0}, {255, 159, 0}, {255, 159, 0},
{255, 160, 0}, {255, 160, 0}, {255, 160, 0}, {255, 160, 0}, {255, 161, 0},
{255, 161, 0}, {255, 161, 0}, {255, 161, 0}, {255, 162, 0}, {255, 162, 0},
{255, 162, 0}, {255, 162, 0}, {255, 163, 0}, {255, 163, 0}, {255, 163, 0},
{255, 163, 0}, {255, 164, 0}, {255, 164, 0}, {255, 164, 0}, {255, 164, 0},
{255, 165, 0}, {255, 165, 0}, {255, 165, 0}, {255, 165, 0}, {255, 166, 0},
{255, 166, 0}, {255, 166, 0}, {255, 166, 0}, {255, 167, 0}, {255, 167, 0},
{255, 167, 0}, {255, 167, 0}, {255, 168, 0}, {255, 168, 0}, {255, 168, 0},
{255, 168, 0}, {255, 169, 0}, {255, 169, 0}, {255, 169, 0}, {255, 169, 0},
{255, 170, 0}, {255, 170, 0}, {255, 170, 0}, {255, 171, 0}, {255, 171, 0},
{255, 171, 0}, {255, 171, 0}, {255, 172, 0}, {255, 172, 0}, {255, 172, 0},
{255, 172, 0}, {255, 173, 0}, {255, 173, 0}, {255, 173, 0}, {255, 173, 0},
{255, 174, 0}, {255, 174, 0}, {255, 174, 0}, {255, 174, 0}, {255, 175, 0},
{255, 175, 0}, {255, 175, 0}, {255, 175, 0}, {255, 176, 0}, {255, 176, 0},
{255, 176, 0}, {255, 176, 0}, {255, 177, 0}, {255, 177, 0}, {255, 177, 0},
{255, 177, 0}, {255, 178, 0}, {255, 178, 0}, {255, 178, 0}, {255, 178, 0},
{255, 179, 0}, {255, 179, 0}, {255, 179, 0}, {255, 179, 0}, {255, 180, 0},
{255, 180, 0}, {255, 180, 0}, {255, 180, 0}, {255, 181, 0}, {255, 181, 0},
{255, 181, 0}, {255, 181, 0}, {255, 182, 0}, {255, 182, 0}, {255, 182, 0},
{255, 183, 0}, {255, 183, 0}, {255, 183, 0}, {255, 183, 0}, {255, 184, 0},
{255, 184, 0}, {255, 184, 0}, {255, 184, 0}, {255, 185, 0}, {255, 185, 0},
{255, 185, 0}, {255, 185, 0}, {255, 186, 0}, {255, 186, 0}, {255, 186, 0},
{255, 186, 0}, {255, 187, 0}, {255, 187, 0}, {255, 187, 0}, {255, 187, 0},
{255, 188, 0}, {255, 188, 0}, {255, 188, 0}, {255, 188, 0}, {255, 189, 0},
{255, 189, 0}, {255, 189, 0}, {255, 189, 0}, {255, 190, 0}, {255, 190, 0},
{255, 190, 0}, {255, 190, 0}, {255, 191, 0}, {255, 191, 0}, {255, 191, 0},
{255, 191, 0}, {255, 192, 0}, {255, 192, 0}, {255, 192, 0}, {255, 192, 0},
{255, 193, 0}, {255, 193, 0}, {255, 193, 0}, {255, 193, 0}, {255, 194, 0},
{255, 194, 0}, {255, 194, 0}, {255, 195, 0}, {255, 195, 0}, {255, 195, 0},
{255, 195, 0}, {255, 196, 0}, {255, 196, 0}, {255, 196, 0}, {255, 196, 0},
{255, 197, 0}, {255, 197, 0}, {255, 197, 0}, {255, 197, 0}, {255, 198, 0},
{255, 198, 0}, {255, 198, 0}, {255, 198, 0}, {255, 199, 0}, {255, 199, 0},
{255, 199, 0}, {255, 199, 0}, {255, 200, 0}, {255, 200, 0}, {255, 200, 0},
{255, 200, 0}, {255, 201, 0}, {255, 201, 0}, {255, 201, 0}, {255, 201, 0},
{255, 202, 0}, {255, 202, 0}, {255, 202, 0}, {255, 202, 0}, {255, 203, 0},
{255, 203, 0}, {255, 203, 0}, {255, 203, 0}, {255, 204, 0}, {255, 204, 0},
{255, 204, 0}, {255, 204, 0}, {255, 205, 0}, {255, 205, 0}, {255, 205, 0},
{255, 205, 0}, {255, 206, 0}, {255, 206, 0}, {255, 206, 0}, {255, 207, 0},
{255, 207, 0}, {255, 207, 0}, {255, 207, 0}, {255, 208, 0}, {255, 208, 0},
{255, 208, 0}, {255, 208, 0}, {255, 209, 0}, {255, 209, 0}, {255, 209, 0},
{255, 209, 0}, {255, 210, 0}, {255, 210, 0}, {255, 210, 0}, {255, 210, 0},
{255, 211, 0}, {255, 211, 0}, {255, 211, 0}, {255, 211, 0}, {255, 212, 0},
{255, 212, 0}, {255, 212, 0}, {255, 212, 0}, {255, 213, 0}, {255, 213, 0},
{255, 213, 0}, {255, 213, 0}, {255, 214, 0}, {255, 214, 0}, {255, 214, 0},
{255, 214, 0}, {255, 215, 0}, {255, 215, 0}, {255, 215, 0}, {255, 215, 0},
{255, 216, 0}, {255, 216, 0}, {255, 216, 0}, {255, 216, 0}, {255, 217, 0},
{255, 217, 0}, {255, 217, 0}, {255, 217, 0}, {255, 218, 0}, {255, 218, 0},
{255, 218, 0}, {255, 218, 0}, {255, 219, 0}, {255, 219, 0}, {255, 219, 0},
{255, 220, 0}, {255, 220, 0}, {255, 220, 0}, {255, 220, 0}, {255, 221, 0},
{255, 221, 0}, {255, 221, 0}, {255, 221, 0}, {255, 222, 0}, {255, 222, 0},
{255, 222, 0}, {255, 222, 0}, {255, 223, 0}, {255, 223, 0}, {255, 223, 0},
{255, 223, 0}, {255, 224, 0}, {255, 224, 0}, {255, 224, 0}, {255, 224, 0},
{255, 225, 0}, {255, 225, 0}, {255, 225, 0}, {255, 225, 0}, {255, 226, 0},
{255, 226, 0}, {255, 226, 0}, {255, 226, 0}, {255, 227, 0}, {255, 227, 0},
{255, 227, 0}, {255, 227, 0}, {255, 228, 0}, {255, 228, 0}, {255, 228, 0},
{255, 228, 0}, {255, 229, 0}, {255, 229, 0}, {255, 229, 0}, {255, 229, 0},
{255, 230, 0}, {255, 230, 0}, {255, 230, 0}, {255, 230, 0}, {255, 231, 0},
{255, 231, 0}, {255, 231, 0}, {255, 232, 0}, {255, 232, 0}, {255, 232, 0},
{255, 232, 0}, {255, 233, 0}, {255, 233, 0}, {255, 233, 0}, {255, 233, 0},
{255, 234, 0}, {255, 234, 0}, {255, 234, 0}, {255, 234, 0}, {255, 235, 0},
{255, 235, 0}, {255, 235, 0}, {255, 235, 0}, {255, 236, 0}, {255, 236, 0},
{255, 236, 0}, {255, 236, 0}, {255, 237, 0}, {255, 237, 0}, {255, 237, 0},
{255, 237, 0}, {255, 238, 0}, {255, 238, 0}, {255, 238, 0}, {255, 238, 0},
{255, 239, 0}, {255, 239, 0}, {255, 239, 0}, {255, 239, 0}, {255, 240, 0},
{255, 240, 0}, {255, 240, 0}, {255, 240, 0}, {255, 241, 0}, {255, 241, 0},
{255, 241, 0}, {255, 241, 0}, {255, 242, 0}, {255, 242, 0}, {255, 242, 0},
{255, 242, 0}, {255, 243, 0}, {255, 243, 0}, {255, 243, 0}, {255, 244, 0},
{255, 244, 0}, {255, 244, 0}, {255, 244, 0}, {255, 245, 0}, {255, 245, 0},
{255, 245, 0}, {255, 245, 0}, {255, 246, 0}, {255, 246, 0}, {255, 246, 0},
{255, 246, 0}, {255, 247, 0}, {255, 247, 0}, {255, 247, 0}, {255, 247, 0},
{255, 248, 0}, {255, 248, 0}, {255, 248, 0}, {255, 248, 0}, {255, 249, 0},
{255, 249, 0}, {255, 249, 0}, {255, 249, 0}, {255, 250, 0}, {255, 250, 0},
{255, 250, 0}, {255, 250, 0}, {255, 251, 0}, {255, 251, 0}, {255, 251, 0},
{255, 251, 0}, {255, 252, 0}, {255, 252, 0}, {255, 252, 0}, {255, 252, 0},
{255, 253, 0}, {255, 253, 0}, {255, 253, 0}, {255, 253, 0}, {255, 254, 0},
{255, 254, 0}, {255, 254, 0}, {255, 254, 0}, {255, 255, 0}, {255, 255, 0}};
const rgb_store copper_colormap[1000] = {
{0, 0, 0}, {0, 0, 0}, {1, 0, 0}, {1, 1, 0},
{1, 1, 1}, {2, 1, 1}, {2, 1, 1}, {2, 1, 1},
{3, 2, 1}, {3, 2, 1}, {3, 2, 1}, {4, 2, 1},
{4, 2, 2}, {4, 3, 2}, {4, 3, 2}, {5, 3, 2},
{5, 3, 2}, {5, 3, 2}, {6, 4, 2}, {6, 4, 2},
{6, 4, 3}, {7, 4, 3}, {7, 4, 3}, {7, 5, 3},
{8, 5, 3}, {8, 5, 3}, {8, 5, 3}, {9, 5, 3},
{9, 6, 4}, {9, 6, 4}, {10, 6, 4}, {10, 6, 4},
{10, 6, 4}, {11, 7, 4}, {11, 7, 4}, {11, 7, 4},
{11, 7, 5}, {12, 7, 5}, {12, 8, 5}, {12, 8, 5},
{13, 8, 5}, {13, 8, 5}, {13, 8, 5}, {14, 9, 5},
{14, 9, 6}, {14, 9, 6}, {15, 9, 6}, {15, 9, 6},
{15, 10, 6}, {16, 10, 6}, {16, 10, 6}, {16, 10, 6},
{17, 10, 7}, {17, 11, 7}, {17, 11, 7}, {18, 11, 7},
{18, 11, 7}, {18, 11, 7}, {19, 12, 7}, {19, 12, 7},
{19, 12, 8}, {19, 12, 8}, {20, 12, 8}, {20, 13, 8},
{20, 13, 8}, {21, 13, 8}, {21, 13, 8}, {21, 13, 9},
{22, 14, 9}, {22, 14, 9}, {22, 14, 9}, {23, 14, 9},
{23, 14, 9}, {23, 15, 9}, {24, 15, 9}, {24, 15, 10},
{24, 15, 10}, {25, 15, 10}, {25, 16, 10}, {25, 16, 10},
{26, 16, 10}, {26, 16, 10}, {26, 16, 10}, {26, 17, 11},
{27, 17, 11}, {27, 17, 11}, {27, 17, 11}, {28, 17, 11},
{28, 18, 11}, {28, 18, 11}, {29, 18, 11}, {29, 18, 12},
{29, 18, 12}, {30, 19, 12}, {30, 19, 12}, {30, 19, 12},
{31, 19, 12}, {31, 19, 12}, {31, 20, 12}, {32, 20, 13},
{32, 20, 13}, {32, 20, 13}, {33, 20, 13}, {33, 21, 13},
{33, 21, 13}, {34, 21, 13}, {34, 21, 13}, {34, 21, 14},
{34, 22, 14}, {35, 22, 14}, {35, 22, 14}, {35, 22, 14},
{36, 22, 14}, {36, 23, 14}, {36, 23, 14}, {37, 23, 15},
{37, 23, 15}, {37, 23, 15}, {38, 24, 15}, {38, 24, 15},
{38, 24, 15}, {39, 24, 15}, {39, 24, 15}, {39, 25, 16},
{40, 25, 16}, {40, 25, 16}, {40, 25, 16}, {41, 25, 16},
{41, 26, 16}, {41, 26, 16}, {41, 26, 17}, {42, 26, 17},
{42, 26, 17}, {42, 27, 17}, {43, 27, 17}, {43, 27, 17},
{43, 27, 17}, {44, 27, 17}, {44, 28, 18}, {44, 28, 18},
{45, 28, 18}, {45, 28, 18}, {45, 28, 18}, {46, 29, 18},
{46, 29, 18}, {46, 29, 18}, {47, 29, 19}, {47, 29, 19},
{47, 30, 19}, {48, 30, 19}, {48, 30, 19}, {48, 30, 19},
{48, 30, 19}, {49, 31, 19}, {49, 31, 20}, {49, 31, 20},
{50, 31, 20}, {50, 31, 20}, {50, 32, 20}, {51, 32, 20},
{51, 32, 20}, {51, 32, 20}, {52, 32, 21}, {52, 33, 21},
{52, 33, 21}, {53, 33, 21}, {53, 33, 21}, {53, 33, 21},
{54, 34, 21}, {54, 34, 21}, {54, 34, 22}, {55, 34, 22},
{55, 34, 22}, {55, 34, 22}, {56, 35, 22}, {56, 35, 22},
{56, 35, 22}, {56, 35, 22}, {57, 35, 23}, {57, 36, 23},
{57, 36, 23}, {58, 36, 23}, {58, 36, 23}, {58, 36, 23},
{59, 37, 23}, {59, 37, 23}, {59, 37, 24}, {60, 37, 24},
{60, 37, 24}, {60, 38, 24}, {61, 38, 24}, {61, 38, 24},
{61, 38, 24}, {62, 38, 25}, {62, 39, 25}, {62, 39, 25},
{63, 39, 25}, {63, 39, 25}, {63, 39, 25}, {63, 40, 25},
{64, 40, 25}, {64, 40, 26}, {64, 40, 26}, {65, 40, 26},
{65, 41, 26}, {65, 41, 26}, {66, 41, 26}, {66, 41, 26},
{66, 41, 26}, {67, 42, 27}, {67, 42, 27}, {67, 42, 27},
{68, 42, 27}, {68, 42, 27}, {68, 43, 27}, {69, 43, 27},
{69, 43, 27}, {69, 43, 28}, {70, 43, 28}, {70, 44, 28},
{70, 44, 28}, {71, 44, 28}, {71, 44, 28}, {71, 44, 28},
{71, 45, 28}, {72, 45, 29}, {72, 45, 29}, {72, 45, 29},
{73, 45, 29}, {73, 46, 29}, {73, 46, 29}, {74, 46, 29},
{74, 46, 29}, {74, 46, 30}, {75, 47, 30}, {75, 47, 30},
{75, 47, 30}, {76, 47, 30}, {76, 47, 30}, {76, 48, 30},
{77, 48, 30}, {77, 48, 31}, {77, 48, 31}, {78, 48, 31},
{78, 49, 31}, {78, 49, 31}, {78, 49, 31}, {79, 49, 31},
{79, 49, 31}, {79, 50, 32}, {80, 50, 32}, {80, 50, 32},
{80, 50, 32}, {81, 50, 32}, {81, 51, 32}, {81, 51, 32},
{82, 51, 33}, {82, 51, 33}, {82, 51, 33}, {83, 52, 33},
{83, 52, 33}, {83, 52, 33}, {84, 52, 33}, {84, 52, 33},
{84, 53, 34}, {85, 53, 34}, {85, 53, 34}, {85, 53, 34},
{86, 53, 34}, {86, 54, 34}, {86, 54, 34}, {86, 54, 34},
{87, 54, 35}, {87, 54, 35}, {87, 55, 35}, {88, 55, 35},
{88, 55, 35}, {88, 55, 35}, {89, 55, 35}, {89, 56, 35},
{89, 56, 36}, {90, 56, 36}, {90, 56, 36}, {90, 56, 36},
{91, 57, 36}, {91, 57, 36}, {91, 57, 36}, {92, 57, 36},
{92, 57, 37}, {92, 58, 37}, {93, 58, 37}, {93, 58, 37},
{93, 58, 37}, {93, 58, 37}, {94, 59, 37}, {94, 59, 37},
{94, 59, 38}, {95, 59, 38}, {95, 59, 38}, {95, 60, 38},
{96, 60, 38}, {96, 60, 38}, {96, 60, 38}, {97, 60, 38},
{97, 61, 39}, {97, 61, 39}, {98, 61, 39}, {98, 61, 39},
{98, 61, 39}, {99, 62, 39}, {99, 62, 39}, {99, 62, 39},
{100, 62, 40}, {100, 62, 40}, {100, 63, 40}, {101, 63, 40},
{101, 63, 40}, {101, 63, 40}, {101, 63, 40}, {102, 64, 41},
{102, 64, 41}, {102, 64, 41}, {103, 64, 41}, {103, 64, 41},
{103, 65, 41}, {104, 65, 41}, {104, 65, 41}, {104, 65, 42},
{105, 65, 42}, {105, 66, 42}, {105, 66, 42}, {106, 66, 42},
{106, 66, 42}, {106, 66, 42}, {107, 67, 42}, {107, 67, 43},
{107, 67, 43}, {108, 67, 43}, {108, 67, 43}, {108, 68, 43},
{108, 68, 43}, {109, 68, 43}, {109, 68, 43}, {109, 68, 44},
{110, 69, 44}, {110, 69, 44}, {110, 69, 44}, {111, 69, 44},
{111, 69, 44}, {111, 70, 44}, {112, 70, 44}, {112, 70, 45},
{112, 70, 45}, {113, 70, 45}, {113, 71, 45}, {113, 71, 45},
{114, 71, 45}, {114, 71, 45}, {114, 71, 45}, {115, 72, 46},
{115, 72, 46}, {115, 72, 46}, {116, 72, 46}, {116, 72, 46},
{116, 73, 46}, {116, 73, 46}, {117, 73, 46}, {117, 73, 47},
{117, 73, 47}, {118, 74, 47}, {118, 74, 47}, {118, 74, 47},
{119, 74, 47}, {119, 74, 47}, {119, 75, 47}, {120, 75, 48},
{120, 75, 48}, {120, 75, 48}, {121, 75, 48}, {121, 76, 48},
{121, 76, 48}, {122, 76, 48}, {122, 76, 49}, {122, 76, 49},
{123, 77, 49}, {123, 77, 49}, {123, 77, 49}, {123, 77, 49},
{124, 77, 49}, {124, 78, 49}, {124, 78, 50}, {125, 78, 50},
{125, 78, 50}, {125, 78, 50}, {126, 79, 50}, {126, 79, 50},
{126, 79, 50}, {127, 79, 50}, {127, 79, 51}, {127, 80, 51},
{128, 80, 51}, {128, 80, 51}, {128, 80, 51}, {129, 80, 51},
{129, 81, 51}, {129, 81, 51}, {130, 81, 52}, {130, 81, 52},
{130, 81, 52}, {130, 82, 52}, {131, 82, 52}, {131, 82, 52},
{131, 82, 52}, {132, 82, 52}, {132, 83, 53}, {132, 83, 53},
{133, 83, 53}, {133, 83, 53}, {133, 83, 53}, {134, 84, 53},
{134, 84, 53}, {134, 84, 53}, {135, 84, 54}, {135, 84, 54},
{135, 85, 54}, {136, 85, 54}, {136, 85, 54}, {136, 85, 54},
{137, 85, 54}, {137, 86, 54}, {137, 86, 55}, {138, 86, 55},
{138, 86, 55}, {138, 86, 55}, {138, 87, 55}, {139, 87, 55},
{139, 87, 55}, {139, 87, 55}, {140, 87, 56}, {140, 88, 56},
{140, 88, 56}, {141, 88, 56}, {141, 88, 56}, {141, 88, 56},
{142, 89, 56}, {142, 89, 57}, {142, 89, 57}, {143, 89, 57},
{143, 89, 57}, {143, 90, 57}, {144, 90, 57}, {144, 90, 57},
{144, 90, 57}, {145, 90, 58}, {145, 91, 58}, {145, 91, 58},
{145, 91, 58}, {146, 91, 58}, {146, 91, 58}, {146, 92, 58},
{147, 92, 58}, {147, 92, 59}, {147, 92, 59}, {148, 92, 59},
{148, 93, 59}, {148, 93, 59}, {149, 93, 59}, {149, 93, 59},
{149, 93, 59}, {150, 94, 60}, {150, 94, 60}, {150, 94, 60},
{151, 94, 60}, {151, 94, 60}, {151, 95, 60}, {152, 95, 60},
{152, 95, 60}, {152, 95, 61}, {153, 95, 61}, {153, 96, 61},
{153, 96, 61}, {153, 96, 61}, {154, 96, 61}, {154, 96, 61},
{154, 97, 61}, {155, 97, 62}, {155, 97, 62}, {155, 97, 62},
{156, 97, 62}, {156, 98, 62}, {156, 98, 62}, {157, 98, 62},
{157, 98, 62}, {157, 98, 63}, {158, 99, 63}, {158, 99, 63},
{158, 99, 63}, {159, 99, 63}, {159, 99, 63}, {159, 100, 63},
{160, 100, 63}, {160, 100, 64}, {160, 100, 64}, {160, 100, 64},
{161, 101, 64}, {161, 101, 64}, {161, 101, 64}, {162, 101, 64},
{162, 101, 65}, {162, 101, 65}, {163, 102, 65}, {163, 102, 65},
{163, 102, 65}, {164, 102, 65}, {164, 102, 65}, {164, 103, 65},
{165, 103, 66}, {165, 103, 66}, {165, 103, 66}, {166, 103, 66},
{166, 104, 66}, {166, 104, 66}, {167, 104, 66}, {167, 104, 66},
{167, 104, 67}, {168, 105, 67}, {168, 105, 67}, {168, 105, 67},
{168, 105, 67}, {169, 105, 67}, {169, 106, 67}, {169, 106, 67},
{170, 106, 68}, {170, 106, 68}, {170, 106, 68}, {171, 107, 68},
{171, 107, 68}, {171, 107, 68}, {172, 107, 68}, {172, 107, 68},
{172, 108, 69}, {173, 108, 69}, {173, 108, 69}, {173, 108, 69},
{174, 108, 69}, {174, 109, 69}, {174, 109, 69}, {175, 109, 69},
{175, 109, 70}, {175, 109, 70}, {175, 110, 70}, {176, 110, 70},
{176, 110, 70}, {176, 110, 70}, {177, 110, 70}, {177, 111, 70},
{177, 111, 71}, {178, 111, 71}, {178, 111, 71}, {178, 111, 71},
{179, 112, 71}, {179, 112, 71}, {179, 112, 71}, {180, 112, 71},
{180, 112, 72}, {180, 113, 72}, {181, 113, 72}, {181, 113, 72},
{181, 113, 72}, {182, 113, 72}, {182, 114, 72}, {182, 114, 73},
{183, 114, 73}, {183, 114, 73}, {183, 114, 73}, {183, 115, 73},
{184, 115, 73}, {184, 115, 73}, {184, 115, 73}, {185, 115, 74},
{185, 116, 74}, {185, 116, 74}, {186, 116, 74}, {186, 116, 74},
{186, 116, 74}, {187, 117, 74}, {187, 117, 74}, {187, 117, 75},
{188, 117, 75}, {188, 117, 75}, {188, 118, 75}, {189, 118, 75},
{189, 118, 75}, {189, 118, 75}, {190, 118, 75}, {190, 119, 76},
{190, 119, 76}, {190, 119, 76}, {191, 119, 76}, {191, 119, 76},
{191, 120, 76}, {192, 120, 76}, {192, 120, 76}, {192, 120, 77},
{193, 120, 77}, {193, 121, 77}, {193, 121, 77}, {194, 121, 77},
{194, 121, 77}, {194, 121, 77}, {195, 122, 77}, {195, 122, 78},
{195, 122, 78}, {196, 122, 78}, {196, 122, 78}, {196, 123, 78},
{197, 123, 78}, {197, 123, 78}, {197, 123, 78}, {198, 123, 79},
{198, 124, 79}, {198, 124, 79}, {198, 124, 79}, {199, 124, 79},
{199, 124, 79}, {199, 125, 79}, {200, 125, 79}, {200, 125, 80},
{200, 125, 80}, {201, 125, 80}, {201, 126, 80}, {201, 126, 80},
{202, 126, 80}, {202, 126, 80}, {202, 126, 81}, {203, 127, 81},
{203, 127, 81}, {203, 127, 81}, {204, 127, 81}, {204, 127, 81},
{204, 128, 81}, {205, 128, 81}, {205, 128, 82}, {205, 128, 82},
{205, 128, 82}, {206, 129, 82}, {206, 129, 82}, {206, 129, 82},
{207, 129, 82}, {207, 129, 82}, {207, 130, 83}, {208, 130, 83},
{208, 130, 83}, {208, 130, 83}, {209, 130, 83}, {209, 131, 83},
{209, 131, 83}, {210, 131, 83}, {210, 131, 84}, {210, 131, 84},
{211, 132, 84}, {211, 132, 84}, {211, 132, 84}, {212, 132, 84},
{212, 132, 84}, {212, 133, 84}, {212, 133, 85}, {213, 133, 85},
{213, 133, 85}, {213, 133, 85}, {214, 134, 85}, {214, 134, 85},
{214, 134, 85}, {215, 134, 85}, {215, 134, 86}, {215, 135, 86},
{216, 135, 86}, {216, 135, 86}, {216, 135, 86}, {217, 135, 86},
{217, 136, 86}, {217, 136, 86}, {218, 136, 87}, {218, 136, 87},
{218, 136, 87}, {219, 137, 87}, {219, 137, 87}, {219, 137, 87},
{220, 137, 87}, {220, 137, 87}, {220, 138, 88}, {220, 138, 88},
{221, 138, 88}, {221, 138, 88}, {221, 138, 88}, {222, 139, 88},
{222, 139, 88}, {222, 139, 89}, {223, 139, 89}, {223, 139, 89},
{223, 140, 89}, {224, 140, 89}, {224, 140, 89}, {224, 140, 89},
{225, 140, 89}, {225, 141, 90}, {225, 141, 90}, {226, 141, 90},
{226, 141, 90}, {226, 141, 90}, {227, 142, 90}, {227, 142, 90},
{227, 142, 90}, {227, 142, 91}, {228, 142, 91}, {228, 143, 91},
{228, 143, 91}, {229, 143, 91}, {229, 143, 91}, {229, 143, 91},
{230, 144, 91}, {230, 144, 92}, {230, 144, 92}, {231, 144, 92},
{231, 144, 92}, {231, 145, 92}, {232, 145, 92}, {232, 145, 92},
{232, 145, 92}, {233, 145, 93}, {233, 146, 93}, {233, 146, 93},
{234, 146, 93}, {234, 146, 93}, {234, 146, 93}, {235, 147, 93},
{235, 147, 93}, {235, 147, 94}, {235, 147, 94}, {236, 147, 94},
{236, 148, 94}, {236, 148, 94}, {237, 148, 94}, {237, 148, 94},
{237, 148, 94}, {238, 149, 95}, {238, 149, 95}, {238, 149, 95},
{239, 149, 95}, {239, 149, 95}, {239, 150, 95}, {240, 150, 95},
{240, 150, 95}, {240, 150, 96}, {241, 150, 96}, {241, 151, 96},
{241, 151, 96}, {242, 151, 96}, {242, 151, 96}, {242, 151, 96},
{242, 152, 97}, {243, 152, 97}, {243, 152, 97}, {243, 152, 97},
{244, 152, 97}, {244, 153, 97}, {244, 153, 97}, {245, 153, 97},
{245, 153, 98}, {245, 153, 98}, {246, 154, 98}, {246, 154, 98},
{246, 154, 98}, {247, 154, 98}, {247, 154, 98}, {247, 155, 98},
{248, 155, 99}, {248, 155, 99}, {248, 155, 99}, {249, 155, 99},
{249, 156, 99}, {249, 156, 99}, {250, 156, 99}, {250, 156, 99},
{250, 156, 100}, {250, 157, 100}, {251, 157, 100}, {251, 157, 100},
{251, 157, 100}, {252, 157, 100}, {252, 158, 100}, {252, 158, 100},
{253, 158, 101}, {253, 158, 101}, {253, 158, 101}, {253, 159, 101},
{253, 159, 101}, {254, 159, 101}, {254, 159, 101}, {254, 159, 101},
{254, 160, 102}, {254, 160, 102}, {254, 160, 102}, {254, 160, 102},
{254, 160, 102}, {255, 161, 102}, {255, 161, 102}, {255, 161, 102},
{255, 161, 103}, {255, 161, 103}, {255, 162, 103}, {255, 162, 103},
{255, 162, 103}, {255, 162, 103}, {255, 162, 103}, {255, 163, 103},
{255, 163, 104}, {255, 163, 104}, {255, 163, 104}, {255, 163, 104},
{255, 164, 104}, {255, 164, 104}, {255, 164, 104}, {255, 164, 105},
{255, 164, 105}, {255, 165, 105}, {255, 165, 105}, {255, 165, 105},
{255, 165, 105}, {255, 165, 105}, {255, 166, 105}, {255, 166, 106},
{255, 166, 106}, {255, 166, 106}, {255, 166, 106}, {255, 167, 106},
{255, 167, 106}, {255, 167, 106}, {255, 167, 106}, {255, 167, 107},
{255, 168, 107}, {255, 168, 107}, {255, 168, 107}, {255, 168, 107},
{255, 168, 107}, {255, 168, 107}, {255, 169, 107}, {255, 169, 108},
{255, 169, 108}, {255, 169, 108}, {255, 169, 108}, {255, 170, 108},
{255, 170, 108}, {255, 170, 108}, {255, 170, 108}, {255, 170, 109},
{255, 171, 109}, {255, 171, 109}, {255, 171, 109}, {255, 171, 109},
{255, 171, 109}, {255, 172, 109}, {255, 172, 109}, {255, 172, 110},
{255, 172, 110}, {255, 172, 110}, {255, 173, 110}, {255, 173, 110},
{255, 173, 110}, {255, 173, 110}, {255, 173, 110}, {255, 174, 111},
{255, 174, 111}, {255, 174, 111}, {255, 174, 111}, {255, 174, 111},
{255, 175, 111}, {255, 175, 111}, {255, 175, 111}, {255, 175, 112},
{255, 175, 112}, {255, 176, 112}, {255, 176, 112}, {255, 176, 112},
{255, 176, 112}, {255, 176, 112}, {255, 177, 113}, {255, 177, 113},
{255, 177, 113}, {255, 177, 113}, {255, 177, 113}, {255, 178, 113},
{255, 178, 113}, {255, 178, 113}, {255, 178, 114}, {255, 178, 114},
{255, 179, 114}, {255, 179, 114}, {255, 179, 114}, {255, 179, 114},
{255, 179, 114}, {255, 180, 114}, {255, 180, 115}, {255, 180, 115},
{255, 180, 115}, {255, 180, 115}, {255, 181, 115}, {255, 181, 115},
{255, 181, 115}, {255, 181, 115}, {255, 181, 116}, {255, 182, 116},
{255, 182, 116}, {255, 182, 116}, {255, 182, 116}, {255, 182, 116},
{255, 183, 116}, {255, 183, 116}, {255, 183, 117}, {255, 183, 117},
{255, 183, 117}, {255, 184, 117}, {255, 184, 117}, {255, 184, 117},
{255, 184, 117}, {255, 184, 117}, {255, 185, 118}, {255, 185, 118},
{255, 185, 118}, {255, 185, 118}, {255, 185, 118}, {255, 186, 118},
{255, 186, 118}, {255, 186, 118}, {255, 186, 119}, {255, 186, 119},
{255, 187, 119}, {255, 187, 119}, {255, 187, 119}, {255, 187, 119},
{255, 187, 119}, {255, 188, 119}, {255, 188, 120}, {255, 188, 120},
{255, 188, 120}, {255, 188, 120}, {255, 189, 120}, {255, 189, 120},
{255, 189, 120}, {255, 189, 121}, {255, 189, 121}, {255, 190, 121},
{255, 190, 121}, {255, 190, 121}, {255, 190, 121}, {255, 190, 121},
{255, 191, 121}, {255, 191, 122}, {255, 191, 122}, {255, 191, 122},
{255, 191, 122}, {255, 192, 122}, {255, 192, 122}, {255, 192, 122},
{255, 192, 122}, {255, 192, 123}, {255, 193, 123}, {255, 193, 123},
{255, 193, 123}, {255, 193, 123}, {255, 193, 123}, {255, 194, 123},
{255, 194, 123}, {255, 194, 124}, {255, 194, 124}, {255, 194, 124},
{255, 195, 124}, {255, 195, 124}, {255, 195, 124}, {255, 195, 124},
{255, 195, 124}, {255, 196, 125}, {255, 196, 125}, {255, 196, 125},
{255, 196, 125}, {255, 196, 125}, {255, 197, 125}, {255, 197, 125},
{255, 197, 125}, {255, 197, 126}, {255, 197, 126}, {255, 198, 126},
{255, 198, 126}, {255, 198, 126}, {255, 198, 126}, {255, 198, 126},
{255, 199, 126}, {255, 199, 127}, {255, 199, 127}, {255, 199, 127}};
const rgb_store gray_colormap[1000] = {
{255}, {255}, {254, 254, 254}, {254, 254, 254},
{254, 254, 254}, {254, 254, 254}, {253, 253, 253}, {253, 253, 253},
{253, 253, 253}, {253, 253, 253}, {252, 252, 252}, {252, 252, 252},
{252, 252, 252}, {252, 252, 252}, {251, 251, 251}, {251, 251, 251},
{251, 251, 251}, {251, 251, 251}, {250, 250, 250}, {250, 250, 250},
{250, 250, 250}, {250, 250, 250}, {249, 249, 249}, {249, 249, 249},
{249, 249, 249}, {249, 249, 249}, {248, 248, 248}, {248, 248, 248},
{248, 248, 248}, {248, 248, 248}, {247, 247, 247}, {247, 247, 247},
{247, 247, 247}, {247, 247, 247}, {246, 246, 246}, {246, 246, 246},
{246, 246, 246}, {246, 246, 246}, {245, 245, 245}, {245, 245, 245},
{245, 245, 245}, {245, 245, 245}, {244, 244, 244}, {244, 244, 244},
{244, 244, 244}, {244, 244, 244}, {243, 243, 243}, {243, 243, 243},
{243, 243, 243}, {242, 242, 242}, {242, 242, 242}, {242, 242, 242},
{242, 242, 242}, {241, 241, 241}, {241, 241, 241}, {241, 241, 241},
{241, 241, 241}, {240, 240, 240}, {240, 240, 240}, {240, 240, 240},
{240, 240, 240}, {239, 239, 239}, {239, 239, 239}, {239, 239, 239},
{239, 239, 239}, {238, 238, 238}, {238, 238, 238}, {238, 238, 238},
{238, 238, 238}, {237, 237, 237}, {237, 237, 237}, {237, 237, 237},
{237, 237, 237}, {236, 236, 236}, {236, 236, 236}, {236, 236, 236},
{236, 236, 236}, {235, 235, 235}, {235, 235, 235}, {235, 235, 235},
{235, 235, 235}, {234, 234, 234}, {234, 234, 234}, {234, 234, 234},
{234, 234, 234}, {233, 233, 233}, {233, 233, 233}, {233, 233, 233},
{233, 233, 233}, {232, 232, 232}, {232, 232, 232}, {232, 232, 232},
{232, 232, 232}, {231, 231, 231}, {231, 231, 231}, {231, 231, 231},
{230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230},
{229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229},
{228, 228, 228}, {228, 228, 228}, {228, 228, 228}, {228, 228, 228},
{227, 227, 227}, {227, 227, 227}, {227, 227, 227}, {227, 227, 227},
{226, 226, 226}, {226, 226, 226}, {226, 226, 226}, {226, 226, 226},
{225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225},
{224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224},
{223, 223, 223}, {223, 223, 223}, {223, 223, 223}, {223, 223, 223},
{222, 222, 222}, {222, 222, 222}, {222, 222, 222}, {222, 222, 222},
{221, 221, 221}, {221, 221, 221}, {221, 221, 221}, {221, 221, 221},
{220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220},
{219, 219, 219}, {219, 219, 219}, {219, 219, 219}, {218, 218, 218},
{218, 218, 218}, {218, 218, 218}, {218, 218, 218}, {217, 217, 217},
{217, 217, 217}, {217, 217, 217}, {217, 217, 217}, {216, 216, 216},
{216, 216, 216}, {216, 216, 216}, {216, 216, 216}, {215, 215, 215},
{215, 215, 215}, {215, 215, 215}, {215, 215, 215}, {214, 214, 214},
{214, 214, 214}, {214, 214, 214}, {214, 214, 214}, {213, 213, 213},
{213, 213, 213}, {213, 213, 213}, {213, 213, 213}, {212, 212, 212},
{212, 212, 212}, {212, 212, 212}, {212, 212, 212}, {211, 211, 211},
{211, 211, 211}, {211, 211, 211}, {211, 211, 211}, {210, 210, 210},
{210, 210, 210}, {210, 210, 210}, {210, 210, 210}, {209, 209, 209},
{209, 209, 209}, {209, 209, 209}, {209, 209, 209}, {208, 208, 208},
{208, 208, 208}, {208, 208, 208}, {208, 208, 208}, {207, 207, 207},
{207, 207, 207}, {207, 207, 207}, {207, 207, 207}, {206, 206, 206},
{206, 206, 206}, {206, 206, 206}, {205, 205, 205}, {205, 205, 205},
{205, 205, 205}, {205, 205, 205}, {204, 204, 204}, {204, 204, 204},
{204, 204, 204}, {204, 204, 204}, {203, 203, 203}, {203, 203, 203},
{203, 203, 203}, {203, 203, 203}, {202, 202, 202}, {202, 202, 202},
{202, 202, 202}, {202, 202, 202}, {201, 201, 201}, {201, 201, 201},
{201, 201, 201}, {201, 201, 201}, {200, 200, 200}, {200, 200, 200},
{200, 200, 200}, {200, 200, 200}, {199, 199, 199}, {199, 199, 199},
{199, 199, 199}, {199, 199, 199}, {198, 198, 198}, {198, 198, 198},
{198, 198, 198}, {198, 198, 198}, {197, 197, 197}, {197, 197, 197},
{197, 197, 197}, {197, 197, 197}, {196, 196, 196}, {196, 196, 196},
{196, 196, 196}, {196, 196, 196}, {195, 195, 195}, {195, 195, 195},
{195, 195, 195}, {195, 195, 195}, {194, 194, 194}, {194, 194, 194},
{194, 194, 194}, {193, 193, 193}, {193, 193, 193}, {193, 193, 193},
{193, 193, 193}, {192, 192, 192}, {192, 192, 192}, {192, 192, 192},
{192, 192, 192}, {191, 191, 191}, {191, 191, 191}, {191, 191, 191},
{191, 191, 191}, {190, 190, 190}, {190, 190, 190}, {190, 190, 190},
{190, 190, 190}, {189, 189, 189}, {189, 189, 189}, {189, 189, 189},
{189, 189, 189}, {188, 188, 188}, {188, 188, 188}, {188, 188, 188},
{188, 188, 188}, {187, 187, 187}, {187, 187, 187}, {187, 187, 187},
{187, 187, 187}, {186, 186, 186}, {186, 186, 186}, {186, 186, 186},
{186, 186, 186}, {185, 185, 185}, {185, 185, 185}, {185, 185, 185},
{185, 185, 185}, {184, 184, 184}, {184, 184, 184}, {184, 184, 184},
{184, 184, 184}, {183, 183, 183}, {183, 183, 183}, {183, 183, 183},
{183, 183, 183}, {182, 182, 182}, {182, 182, 182}, {182, 182, 182},
{181, 181, 181}, {181, 181, 181}, {181, 181, 181}, {181, 181, 181},
{180, 180, 180}, {180, 180, 180}, {180, 180, 180}, {180, 180, 180},
{179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179},
{178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178},
{177, 177, 177}, {177, 177, 177}, {177, 177, 177}, {177, 177, 177},
{176, 176, 176}, {176, 176, 176}, {176, 176, 176}, {176, 176, 176},
{175, 175, 175}, {175, 175, 175}, {175, 175, 175}, {175, 175, 175},
{174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174},
{173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173},
{172, 172, 172}, {172, 172, 172}, {172, 172, 172}, {172, 172, 172},
{171, 171, 171}, {171, 171, 171}, {171, 171, 171}, {171, 171, 171},
{170, 170, 170}, {170, 170, 170}, {170, 170, 170}, {169, 169, 169},
{169, 169, 169}, {169, 169, 169}, {169, 169, 169}, {168, 168, 168},
{168, 168, 168}, {168, 168, 168}, {168, 168, 168}, {167, 167, 167},
{167, 167, 167}, {167, 167, 167}, {167, 167, 167}, {166, 166, 166},
{166, 166, 166}, {166, 166, 166}, {166, 166, 166}, {165, 165, 165},
{165, 165, 165}, {165, 165, 165}, {165, 165, 165}, {164, 164, 164},
{164, 164, 164}, {164, 164, 164}, {164, 164, 164}, {163, 163, 163},
{163, 163, 163}, {163, 163, 163}, {163, 163, 163}, {162, 162, 162},
{162, 162, 162}, {162, 162, 162}, {162, 162, 162}, {161, 161, 161},
{161, 161, 161}, {161, 161, 161}, {161, 161, 161}, {160, 160, 160},
{160, 160, 160}, {160, 160, 160}, {160, 160, 160}, {159, 159, 159},
{159, 159, 159}, {159, 159, 159}, {159, 159, 159}, {158, 158, 158},
{158, 158, 158}, {158, 158, 158}, {157, 157, 157}, {157, 157, 157},
{157, 157, 157}, {157, 157, 157}, {156, 156, 156}, {156, 156, 156},
{156, 156, 156}, {156, 156, 156}, {155, 155, 155}, {155, 155, 155},
{155, 155, 155}, {155, 155, 155}, {154, 154, 154}, {154, 154, 154},
{154, 154, 154}, {154, 154, 154}, {153, 153, 153}, {153, 153, 153},
{153, 153, 153}, {153, 153, 153}, {152, 152, 152}, {152, 152, 152},
{152, 152, 152}, {152, 152, 152}, {151, 151, 151}, {151, 151, 151},
{151, 151, 151}, {151, 151, 151}, {150, 150, 150}, {150, 150, 150},
{150, 150, 150}, {150, 150, 150}, {149, 149, 149}, {149, 149, 149},
{149, 149, 149}, {149, 149, 149}, {148, 148, 148}, {148, 148, 148},
{148, 148, 148}, {148, 148, 148}, {147, 147, 147}, {147, 147, 147},
{147, 147, 147}, {147, 147, 147}, {146, 146, 146}, {146, 146, 146},
{146, 146, 146}, {145, 145, 145}, {145, 145, 145}, {145, 145, 145},
{145, 145, 145}, {144, 144, 144}, {144, 144, 144}, {144, 144, 144},
{144, 144, 144}, {143, 143, 143}, {143, 143, 143}, {143, 143, 143},
{143, 143, 143}, {142, 142, 142}, {142, 142, 142}, {142, 142, 142},
{142, 142, 142}, {141, 141, 141}, {141, 141, 141}, {141, 141, 141},
{141, 141, 141}, {140, 140, 140}, {140, 140, 140}, {140, 140, 140},
{140, 140, 140}, {139, 139, 139}, {139, 139, 139}, {139, 139, 139},
{139, 139, 139}, {138, 138, 138}, {138, 138, 138}, {138, 138, 138},
{138, 138, 138}, {137, 137, 137}, {137, 137, 137}, {137, 137, 137},
{137, 137, 137}, {136, 136, 136}, {136, 136, 136}, {136, 136, 136},
{136, 136, 136}, {135, 135, 135}, {135, 135, 135}, {135, 135, 135},
{135, 135, 135}, {134, 134, 134}, {134, 134, 134}, {134, 134, 134},
{133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133},
{132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132},
{131, 131, 131}, {131, 131, 131}, {131, 131, 131}, {131, 131, 131},
{130, 130, 130}, {130, 130, 130}, {130, 130, 130}, {130, 130, 130},
{129, 129, 129}, {129, 129, 129}, {129, 129, 129}, {129, 129, 129},
{128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
{127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127},
{126, 126, 126}, {126, 126, 126}, {126, 126, 126}, {126, 126, 126},
{125, 125, 125}, {125, 125, 125}, {125, 125, 125}, {125, 125, 125},
{124, 124, 124}, {124, 124, 124}, {124, 124, 124}, {124, 124, 124},
{123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123},
{122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122},
{121, 121, 121}, {121, 121, 121}, {121, 121, 121}, {120, 120, 120},
{120, 120, 120}, {120, 120, 120}, {120, 120, 120}, {119, 119, 119},
{119, 119, 119}, {119, 119, 119}, {119, 119, 119}, {118, 118, 118},
{118, 118, 118}, {118, 118, 118}, {118, 118, 118}, {117, 117, 117},
{117, 117, 117}, {117, 117, 117}, {117, 117, 117}, {116, 116, 116},
{116, 116, 116}, {116, 116, 116}, {116, 116, 116}, {115, 115, 115},
{115, 115, 115}, {115, 115, 115}, {115, 115, 115}, {114, 114, 114},
{114, 114, 114}, {114, 114, 114}, {114, 114, 114}, {113, 113, 113},
{113, 113, 113}, {113, 113, 113}, {113, 113, 113}, {112, 112, 112},
{112, 112, 112}, {112, 112, 112}, {112, 112, 112}, {111, 111, 111},
{111, 111, 111}, {111, 111, 111}, {111, 111, 111}, {110, 110, 110},
{110, 110, 110}, {110, 110, 110}, {110, 110, 110}, {109, 109, 109},
{109, 109, 109}, {109, 109, 109}, {108, 108, 108}, {108, 108, 108},
{108, 108, 108}, {108, 108, 108}, {107, 107, 107}, {107, 107, 107},
{107, 107, 107}, {107, 107, 107}, {106, 106, 106}, {106, 106, 106},
{106, 106, 106}, {106, 106, 106}, {105, 105, 105}, {105, 105, 105},
{105, 105, 105}, {105, 105, 105}, {104, 104, 104}, {104, 104, 104},
{104, 104, 104}, {104, 104, 104}, {103, 103, 103}, {103, 103, 103},
{103, 103, 103}, {103, 103, 103}, {102, 102, 102}, {102, 102, 102},
{102, 102, 102}, {102, 102, 102}, {101, 101, 101}, {101, 101, 101},
{101, 101, 101}, {101, 101, 101}, {100, 100, 100}, {100, 100, 100},
{100, 100, 100}, {100, 100, 100}, {99, 99, 99}, {99, 99, 99},
{99, 99, 99}, {99, 99, 99}, {98, 98, 98}, {98, 98, 98},
{98, 98, 98}, {98, 98, 98}, {97, 97, 97}, {97, 97, 97},
{97, 97, 97}, {96, 96, 96}, {96, 96, 96}, {96, 96, 96},
{96, 96, 96}, {95, 95, 95}, {95, 95, 95}, {95, 95, 95},
{95, 95, 95}, {94, 94, 94}, {94, 94, 94}, {94, 94, 94},
{94, 94, 94}, {93, 93, 93}, {93, 93, 93}, {93, 93, 93},
{93, 93, 93}, {92, 92, 92}, {92, 92, 92}, {92, 92, 92},
{92, 92, 92}, {91, 91, 91}, {91, 91, 91}, {91, 91, 91},
{91, 91, 91}, {90, 90, 90}, {90, 90, 90}, {90, 90, 90},
{90, 90, 90}, {89, 89, 89}, {89, 89, 89}, {89, 89, 89},
{89, 89, 89}, {88, 88, 88}, {88, 88, 88}, {88, 88, 88},
{88, 88, 88}, {87, 87, 87}, {87, 87, 87}, {87, 87, 87},
{87, 87, 87}, {86, 86, 86}, {86, 86, 86}, {86, 86, 86},
{86, 86, 86}, {85, 85, 85}, {85, 85, 85}, {85, 85, 85},
{84, 84, 84}, {84, 84, 84}, {84, 84, 84}, {84, 84, 84},
{83, 83, 83}, {83, 83, 83}, {83, 83, 83}, {83, 83, 83},
{82, 82, 82}, {82, 82, 82}, {82, 82, 82}, {82, 82, 82},
{81, 81, 81}, {81, 81, 81}, {81, 81, 81}, {81, 81, 81},
{80, 80, 80}, {80, 80, 80}, {80, 80, 80}, {80, 80, 80},
{79, 79, 79}, {79, 79, 79}, {79, 79, 79}, {79, 79, 79},
{78, 78, 78}, {78, 78, 78}, {78, 78, 78}, {78, 78, 78},
{77, 77, 77}, {77, 77, 77}, {77, 77, 77}, {77, 77, 77},
{76, 76, 76}, {76, 76, 76}, {76, 76, 76}, {76, 76, 76},
{75, 75, 75}, {75, 75, 75}, {75, 75, 75}, {75, 75, 75},
{74, 74, 74}, {74, 74, 74}, {74, 74, 74}, {74, 74, 74},
{73, 73, 73}, {73, 73, 73}, {73, 73, 73}, {72, 72, 72},
{72, 72, 72}, {72, 72, 72}, {72, 72, 72}, {71, 71, 71},
{71, 71, 71}, {71, 71, 71}, {71, 71, 71}, {70, 70, 70},
{70, 70, 70}, {70, 70, 70}, {70, 70, 70}, {69, 69, 69},
{69, 69, 69}, {69, 69, 69}, {69, 69, 69}, {68, 68, 68},
{68, 68, 68}, {68, 68, 68}, {68, 68, 68}, {67, 67, 67},
{67, 67, 67}, {67, 67, 67}, {67, 67, 67}, {66, 66, 66},
{66, 66, 66}, {66, 66, 66}, {66, 66, 66}, {65, 65, 65},
{65, 65, 65}, {65, 65, 65}, {65, 65, 65}, {64, 64, 64},
{64, 64, 64}, {64, 64, 64}, {64, 64, 64}, {63, 63, 63},
{63, 63, 63}, {63, 63, 63}, {63, 63, 63}, {62, 62, 62},
{62, 62, 62}, {62, 62, 62}, {62, 62, 62}, {61, 61, 61},
{61, 61, 61}, {61, 61, 61}, {60, 60, 60}, {60, 60, 60},
{60, 60, 60}, {60, 60, 60}, {59, 59, 59}, {59, 59, 59},
{59, 59, 59}, {59, 59, 59}, {58, 58, 58}, {58, 58, 58},
{58, 58, 58}, {58, 58, 58}, {57, 57, 57}, {57, 57, 57},
{57, 57, 57}, {57, 57, 57}, {56, 56, 56}, {56, 56, 56},
{56, 56, 56}, {56, 56, 56}, {55, 55, 55}, {55, 55, 55},
{55, 55, 55}, {55, 55, 55}, {54, 54, 54}, {54, 54, 54},
{54, 54, 54}, {54, 54, 54}, {53, 53, 53}, {53, 53, 53},
{53, 53, 53}, {53, 53, 53}, {52, 52, 52}, {52, 52, 52},
{52, 52, 52}, {52, 52, 52}, {51, 51, 51}, {51, 51, 51},
{51, 51, 51}, {51, 51, 51}, {50, 50, 50}, {50, 50, 50},
{50, 50, 50}, {50, 50, 50}, {49, 49, 49}, {49, 49, 49},
{49, 49, 49}, {48, 48, 48}, {48, 48, 48}, {48, 48, 48},
{48, 48, 48}, {47, 47, 47}, {47, 47, 47}, {47, 47, 47},
{47, 47, 47}, {46, 46, 46}, {46, 46, 46}, {46, 46, 46},
{46, 46, 46}, {45, 45, 45}, {45, 45, 45}, {45, 45, 45},
{45, 45, 45}, {44, 44, 44}, {44, 44, 44}, {44, 44, 44},
{44, 44, 44}, {43, 43, 43}, {43, 43, 43}, {43, 43, 43},
{43, 43, 43}, {42, 42, 42}, {42, 42, 42}, {42, 42, 42},
{42, 42, 42}, {41, 41, 41}, {41, 41, 41}, {41, 41, 41},
{41, 41, 41}, {40, 40, 40}, {40, 40, 40}, {40, 40, 40},
{40, 40, 40}, {39, 39, 39}, {39, 39, 39}, {39, 39, 39},
{39, 39, 39}, {38, 38, 38}, {38, 38, 38}, {38, 38, 38},
{38, 38, 38}, {37, 37, 37}, {37, 37, 37}, {37, 37, 37},
{37, 37, 37}, {36, 36, 36}, {36, 36, 36}, {36, 36, 36},
{35, 35, 35}, {35, 35, 35}, {35, 35, 35}, {35, 35, 35},
{34, 34, 34}, {34, 34, 34}, {34, 34, 34}, {34, 34, 34},
{33, 33, 33}, {33, 33, 33}, {33, 33, 33}, {33, 33, 33},
{32, 32, 32}, {32, 32, 32}, {32, 32, 32}, {32, 32, 32},
{31, 31, 31}, {31, 31, 31}, {31, 31, 31}, {31, 31, 31},
{30, 30, 30}, {30, 30, 30}, {30, 30, 30}, {30, 30, 30},
{29, 29, 29}, {29, 29, 29}, {29, 29, 29}, {29, 29, 29},
{28, 28, 28}, {28, 28, 28}, {28, 28, 28}, {28, 28, 28},
{27, 27, 27}, {27, 27, 27}, {27, 27, 27}, {27, 27, 27},
{26, 26, 26}, {26, 26, 26}, {26, 26, 26}, {26, 26, 26},
{25, 25, 25}, {25, 25, 25}, {25, 25, 25}, {25, 25, 25},
{24, 24, 24}, {24, 24, 24}, {24, 24, 24}, {23, 23, 23},
{23, 23, 23}, {23, 23, 23}, {23, 23, 23}, {22, 22, 22},
{22, 22, 22}, {22, 22, 22}, {22, 22, 22}, {21, 21, 21},
{21, 21, 21}, {21, 21, 21}, {21, 21, 21}, {20, 20, 20},
{20, 20, 20}, {20, 20, 20}, {20, 20, 20}, {19, 19, 19},
{19, 19, 19}, {19, 19, 19}, {19, 19, 19}, {18, 18, 18},
{18, 18, 18}, {18, 18, 18}, {18, 18, 18}, {17, 17, 17},
{17, 17, 17}, {17, 17, 17}, {17, 17, 17}, {16, 16, 16},
{16, 16, 16}, {16, 16, 16}, {16, 16, 16}, {15, 15, 15},
{15, 15, 15}, {15, 15, 15}, {15, 15, 15}, {14, 14, 14},
{14, 14, 14}, {14, 14, 14}, {14, 14, 14}, {13, 13, 13},
{13, 13, 13}, {13, 13, 13}, {13, 13, 13}, {12, 12, 12},
{12, 12, 12}, {12, 12, 12}, {11, 11, 11}, {11, 11, 11},
{11, 11, 11}, {11, 11, 11}, {10, 10, 10}, {10, 10, 10},
{10, 10, 10}, {10, 10, 10}, {9, 9, 9}, {9, 9, 9},
{9, 9, 9}, {9, 9, 9}, {8, 8, 8}, {8, 8, 8},
{8, 8, 8}, {8, 8, 8}, {7, 7, 7}, {7, 7, 7},
{7, 7, 7}, {7, 7, 7}, {6, 6, 6}, {6, 6, 6},
{6, 6, 6}, {6, 6, 6}, {5, 5, 5}, {5, 5, 5},
{5, 5, 5}, {5, 5, 5}, {4, 4, 4}, {4, 4, 4},
{4, 4, 4}, {4, 4, 4}, {3, 3, 3}, {3, 3, 3},
{3, 3, 3}, {3, 3, 3}, {2, 2, 2}, {2, 2, 2},
{2, 2, 2}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1},
{1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}};
const rgb_store hot_colormap[1000] = {
{11, 0, 0}, {11, 0, 0}, {12, 0, 0}, {13, 0, 0},
{13, 0, 0}, {14, 0, 0}, {15, 0, 0}, {15, 0, 0},
{16, 0, 0}, {17, 0, 0}, {17, 0, 0}, {18, 0, 0},
{19, 0, 0}, {19, 0, 0}, {20, 0, 0}, {21, 0, 0},
{21, 0, 0}, {22, 0, 0}, {23, 0, 0}, {23, 0, 0},
{24, 0, 0}, {25, 0, 0}, {25, 0, 0}, {26, 0, 0},
{27, 0, 0}, {27, 0, 0}, {28, 0, 0}, {29, 0, 0},
{29, 0, 0}, {30, 0, 0}, {31, 0, 0}, {31, 0, 0},
{32, 0, 0}, {33, 0, 0}, {33, 0, 0}, {34, 0, 0},
{35, 0, 0}, {35, 0, 0}, {36, 0, 0}, {37, 0, 0},
{37, 0, 0}, {38, 0, 0}, {39, 0, 0}, {39, 0, 0},
{40, 0, 0}, {41, 0, 0}, {41, 0, 0}, {42, 0, 0},
{43, 0, 0}, {43, 0, 0}, {44, 0, 0}, {45, 0, 0},
{45, 0, 0}, {46, 0, 0}, {47, 0, 0}, {47, 0, 0},
{48, 0, 0}, {49, 0, 0}, {49, 0, 0}, {50, 0, 0},
{51, 0, 0}, {51, 0, 0}, {52, 0, 0}, {53, 0, 0},
{54, 0, 0}, {54, 0, 0}, {55, 0, 0}, {56, 0, 0},
{56, 0, 0}, {57, 0, 0}, {58, 0, 0}, {58, 0, 0},
{59, 0, 0}, {60, 0, 0}, {60, 0, 0}, {61, 0, 0},
{62, 0, 0}, {62, 0, 0}, {63, 0, 0}, {64, 0, 0},
{64, 0, 0}, {65, 0, 0}, {66, 0, 0}, {66, 0, 0},
{67, 0, 0}, {68, 0, 0}, {68, 0, 0}, {69, 0, 0},
{70, 0, 0}, {70, 0, 0}, {71, 0, 0}, {72, 0, 0},
{72, 0, 0}, {73, 0, 0}, {74, 0, 0}, {74, 0, 0},
{75, 0, 0}, {76, 0, 0}, {76, 0, 0}, {77, 0, 0},
{78, 0, 0}, {78, 0, 0}, {79, 0, 0}, {80, 0, 0},
{80, 0, 0}, {81, 0, 0}, {82, 0, 0}, {82, 0, 0},
{83, 0, 0}, {84, 0, 0}, {84, 0, 0}, {85, 0, 0},
{86, 0, 0}, {86, 0, 0}, {87, 0, 0}, {88, 0, 0},
{88, 0, 0}, {89, 0, 0}, {90, 0, 0}, {90, 0, 0},
{91, 0, 0}, {92, 0, 0}, {92, 0, 0}, {93, 0, 0},
{94, 0, 0}, {94, 0, 0}, {95, 0, 0}, {96, 0, 0},
{96, 0, 0}, {97, 0, 0}, {98, 0, 0}, {98, 0, 0},
{99, 0, 0}, {100, 0, 0}, {100, 0, 0}, {101, 0, 0},
{102, 0, 0}, {102, 0, 0}, {103, 0, 0}, {104, 0, 0},
{104, 0, 0}, {105, 0, 0}, {106, 0, 0}, {106, 0, 0},
{107, 0, 0}, {108, 0, 0}, {108, 0, 0}, {109, 0, 0},
{110, 0, 0}, {110, 0, 0}, {111, 0, 0}, {112, 0, 0},
{112, 0, 0}, {113, 0, 0}, {114, 0, 0}, {114, 0, 0},
{115, 0, 0}, {116, 0, 0}, {116, 0, 0}, {117, 0, 0},
{118, 0, 0}, {119, 0, 0}, {119, 0, 0}, {120, 0, 0},
{121, 0, 0}, {121, 0, 0}, {122, 0, 0}, {123, 0, 0},
{123, 0, 0}, {124, 0, 0}, {125, 0, 0}, {125, 0, 0},
{126, 0, 0}, {127, 0, 0}, {127, 0, 0}, {128, 0, 0},
{129, 0, 0}, {129, 0, 0}, {130, 0, 0}, {131, 0, 0},
{131, 0, 0}, {132, 0, 0}, {133, 0, 0}, {133, 0, 0},
{134, 0, 0}, {135, 0, 0}, {135, 0, 0}, {136, 0, 0},
{137, 0, 0}, {137, 0, 0}, {138, 0, 0}, {139, 0, 0},
{139, 0, 0}, {140, 0, 0}, {141, 0, 0}, {141, 0, 0},
{142, 0, 0}, {143, 0, 0}, {143, 0, 0}, {144, 0, 0},
{145, 0, 0}, {145, 0, 0}, {146, 0, 0}, {147, 0, 0},
{147, 0, 0}, {148, 0, 0}, {149, 0, 0}, {149, 0, 0},
{150, 0, 0}, {151, 0, 0}, {151, 0, 0}, {152, 0, 0},
{153, 0, 0}, {153, 0, 0}, {154, 0, 0}, {155, 0, 0},
{155, 0, 0}, {156, 0, 0}, {157, 0, 0}, {157, 0, 0},
{158, 0, 0}, {159, 0, 0}, {159, 0, 0}, {160, 0, 0},
{161, 0, 0}, {161, 0, 0}, {162, 0, 0}, {163, 0, 0},
{163, 0, 0}, {164, 0, 0}, {165, 0, 0}, {165, 0, 0},
{166, 0, 0}, {167, 0, 0}, {167, 0, 0}, {168, 0, 0},
{169, 0, 0}, {169, 0, 0}, {170, 0, 0}, {171, 0, 0},
{171, 0, 0}, {172, 0, 0}, {173, 0, 0}, {173, 0, 0},
{174, 0, 0}, {175, 0, 0}, {175, 0, 0}, {176, 0, 0},
{177, 0, 0}, {177, 0, 0}, {178, 0, 0}, {179, 0, 0},
{179, 0, 0}, {180, 0, 0}, {181, 0, 0}, {181, 0, 0},
{182, 0, 0}, {183, 0, 0}, {183, 0, 0}, {184, 0, 0},
{185, 0, 0}, {186, 0, 0}, {186, 0, 0}, {187, 0, 0},
{188, 0, 0}, {188, 0, 0}, {189, 0, 0}, {190, 0, 0},
{190, 0, 0}, {191, 0, 0}, {192, 0, 0}, {192, 0, 0},
{193, 0, 0}, {194, 0, 0}, {194, 0, 0}, {195, 0, 0},
{196, 0, 0}, {196, 0, 0}, {197, 0, 0}, {198, 0, 0},
{198, 0, 0}, {199, 0, 0}, {200, 0, 0}, {200, 0, 0},
{201, 0, 0}, {202, 0, 0}, {202, 0, 0}, {203, 0, 0},
{204, 0, 0}, {204, 0, 0}, {205, 0, 0}, {206, 0, 0},
{206, 0, 0}, {207, 0, 0}, {208, 0, 0}, {208, 0, 0},
{209, 0, 0}, {210, 0, 0}, {210, 0, 0}, {211, 0, 0},
{212, 0, 0}, {212, 0, 0}, {213, 0, 0}, {214, 0, 0},
{214, 0, 0}, {215, 0, 0}, {216, 0, 0}, {216, 0, 0},
{217, 0, 0}, {218, 0, 0}, {218, 0, 0}, {219, 0, 0},
{220, 0, 0}, {220, 0, 0}, {221, 0, 0}, {222, 0, 0},
{222, 0, 0}, {223, 0, 0}, {224, 0, 0}, {224, 0, 0},
{225, 0, 0}, {226, 0, 0}, {226, 0, 0}, {227, 0, 0},
{228, 0, 0}, {228, 0, 0}, {229, 0, 0}, {230, 0, 0},
{230, 0, 0}, {231, 0, 0}, {232, 0, 0}, {232, 0, 0},
{233, 0, 0}, {234, 0, 0}, {234, 0, 0}, {235, 0, 0},
{236, 0, 0}, {236, 0, 0}, {237, 0, 0}, {238, 0, 0},
{238, 0, 0}, {239, 0, 0}, {240, 0, 0}, {240, 0, 0},
{241, 0, 0}, {242, 0, 0}, {242, 0, 0}, {243, 0, 0},
{244, 0, 0}, {244, 0, 0}, {245, 0, 0}, {246, 0, 0},
{246, 0, 0}, {247, 0, 0}, {248, 0, 0}, {248, 0, 0},
{249, 0, 0}, {250, 0, 0}, {251, 0, 0}, {251, 0, 0},
{252, 0, 0}, {253, 0, 0}, {253, 0, 0}, {254, 0, 0},
{255, 0, 0}, {255, 0, 0}, {255, 1, 0}, {255, 2, 0},
{255, 2, 0}, {255, 3, 0}, {255, 4, 0}, {255, 4, 0},
{255, 5, 0}, {255, 6, 0}, {255, 6, 0}, {255, 7, 0},
{255, 8, 0}, {255, 8, 0}, {255, 9, 0}, {255, 10, 0},
{255, 10, 0}, {255, 11, 0}, {255, 12, 0}, {255, 12, 0},
{255, 13, 0}, {255, 14, 0}, {255, 14, 0}, {255, 15, 0},
{255, 16, 0}, {255, 16, 0}, {255, 17, 0}, {255, 18, 0},
{255, 18, 0}, {255, 19, 0}, {255, 20, 0}, {255, 20, 0},
{255, 21, 0}, {255, 22, 0}, {255, 22, 0}, {255, 23, 0},
{255, 24, 0}, {255, 24, 0}, {255, 25, 0}, {255, 26, 0},
{255, 26, 0}, {255, 27, 0}, {255, 28, 0}, {255, 28, 0},
{255, 29, 0}, {255, 30, 0}, {255, 30, 0}, {255, 31, 0},
{255, 32, 0}, {255, 32, 0}, {255, 33, 0}, {255, 34, 0},
{255, 34, 0}, {255, 35, 0}, {255, 36, 0}, {255, 36, 0},
{255, 37, 0}, {255, 38, 0}, {255, 38, 0}, {255, 39, 0},
{255, 40, 0}, {255, 40, 0}, {255, 41, 0}, {255, 42, 0},
{255, 42, 0}, {255, 43, 0}, {255, 44, 0}, {255, 44, 0},
{255, 45, 0}, {255, 46, 0}, {255, 46, 0}, {255, 47, 0},
{255, 48, 0}, {255, 48, 0}, {255, 49, 0}, {255, 50, 0},
{255, 50, 0}, {255, 51, 0}, {255, 52, 0}, {255, 52, 0},
{255, 53, 0}, {255, 54, 0}, {255, 54, 0}, {255, 55, 0},
{255, 56, 0}, {255, 56, 0}, {255, 57, 0}, {255, 58, 0},
{255, 58, 0}, {255, 59, 0}, {255, 60, 0}, {255, 60, 0},
{255, 61, 0}, {255, 62, 0}, {255, 63, 0}, {255, 63, 0},
{255, 64, 0}, {255, 65, 0}, {255, 65, 0}, {255, 66, 0},
{255, 67, 0}, {255, 67, 0}, {255, 68, 0}, {255, 69, 0},
{255, 69, 0}, {255, 70, 0}, {255, 71, 0}, {255, 71, 0},
{255, 72, 0}, {255, 73, 0}, {255, 73, 0}, {255, 74, 0},
{255, 75, 0}, {255, 75, 0}, {255, 76, 0}, {255, 77, 0},
{255, 77, 0}, {255, 78, 0}, {255, 79, 0}, {255, 79, 0},
{255, 80, 0}, {255, 81, 0}, {255, 81, 0}, {255, 82, 0},
{255, 83, 0}, {255, 83, 0}, {255, 84, 0}, {255, 85, 0},
{255, 85, 0}, {255, 86, 0}, {255, 87, 0}, {255, 87, 0},
{255, 88, 0}, {255, 89, 0}, {255, 89, 0}, {255, 90, 0},
{255, 91, 0}, {255, 91, 0}, {255, 92, 0}, {255, 93, 0},
{255, 93, 0}, {255, 94, 0}, {255, 95, 0}, {255, 95, 0},
{255, 96, 0}, {255, 97, 0}, {255, 97, 0}, {255, 98, 0},
{255, 99, 0}, {255, 99, 0}, {255, 100, 0}, {255, 101, 0},
{255, 101, 0}, {255, 102, 0}, {255, 103, 0}, {255, 103, 0},
{255, 104, 0}, {255, 105, 0}, {255, 105, 0}, {255, 106, 0},
{255, 107, 0}, {255, 107, 0}, {255, 108, 0}, {255, 109, 0},
{255, 109, 0}, {255, 110, 0}, {255, 111, 0}, {255, 111, 0},
{255, 112, 0}, {255, 113, 0}, {255, 113, 0}, {255, 114, 0},
{255, 115, 0}, {255, 115, 0}, {255, 116, 0}, {255, 117, 0},
{255, 117, 0}, {255, 118, 0}, {255, 119, 0}, {255, 119, 0},
{255, 120, 0}, {255, 121, 0}, {255, 121, 0}, {255, 122, 0},
{255, 123, 0}, {255, 123, 0}, {255, 124, 0}, {255, 125, 0},
{255, 125, 0}, {255, 126, 0}, {255, 127, 0}, {255, 128, 0},
{255, 128, 0}, {255, 129, 0}, {255, 130, 0}, {255, 130, 0},
{255, 131, 0}, {255, 132, 0}, {255, 132, 0}, {255, 133, 0},
{255, 134, 0}, {255, 134, 0}, {255, 135, 0}, {255, 136, 0},
{255, 136, 0}, {255, 137, 0}, {255, 138, 0}, {255, 138, 0},
{255, 139, 0}, {255, 140, 0}, {255, 140, 0}, {255, 141, 0},
{255, 142, 0}, {255, 142, 0}, {255, 143, 0}, {255, 144, 0},
{255, 144, 0}, {255, 145, 0}, {255, 146, 0}, {255, 146, 0},
{255, 147, 0}, {255, 148, 0}, {255, 148, 0}, {255, 149, 0},
{255, 150, 0}, {255, 150, 0}, {255, 151, 0}, {255, 152, 0},
{255, 152, 0}, {255, 153, 0}, {255, 154, 0}, {255, 154, 0},
{255, 155, 0}, {255, 156, 0}, {255, 156, 0}, {255, 157, 0},
{255, 158, 0}, {255, 158, 0}, {255, 159, 0}, {255, 160, 0},
{255, 160, 0}, {255, 161, 0}, {255, 162, 0}, {255, 162, 0},
{255, 163, 0}, {255, 164, 0}, {255, 164, 0}, {255, 165, 0},
{255, 166, 0}, {255, 166, 0}, {255, 167, 0}, {255, 168, 0},
{255, 168, 0}, {255, 169, 0}, {255, 170, 0}, {255, 170, 0},
{255, 171, 0}, {255, 172, 0}, {255, 172, 0}, {255, 173, 0},
{255, 174, 0}, {255, 174, 0}, {255, 175, 0}, {255, 176, 0},
{255, 176, 0}, {255, 177, 0}, {255, 178, 0}, {255, 178, 0},
{255, 179, 0}, {255, 180, 0}, {255, 180, 0}, {255, 181, 0},
{255, 182, 0}, {255, 182, 0}, {255, 183, 0}, {255, 184, 0},
{255, 184, 0}, {255, 185, 0}, {255, 186, 0}, {255, 186, 0},
{255, 187, 0}, {255, 188, 0}, {255, 188, 0}, {255, 189, 0},
{255, 190, 0}, {255, 190, 0}, {255, 191, 0}, {255, 192, 0},
{255, 192, 0}, {255, 193, 0}, {255, 194, 0}, {255, 195, 0},
{255, 195, 0}, {255, 196, 0}, {255, 197, 0}, {255, 197, 0},
{255, 198, 0}, {255, 199, 0}, {255, 199, 0}, {255, 200, 0},
{255, 201, 0}, {255, 201, 0}, {255, 202, 0}, {255, 203, 0},
{255, 203, 0}, {255, 204, 0}, {255, 205, 0}, {255, 205, 0},
{255, 206, 0}, {255, 207, 0}, {255, 207, 0}, {255, 208, 0},
{255, 209, 0}, {255, 209, 0}, {255, 210, 0}, {255, 211, 0},
{255, 211, 0}, {255, 212, 0}, {255, 213, 0}, {255, 213, 0},
{255, 214, 0}, {255, 215, 0}, {255, 215, 0}, {255, 216, 0},
{255, 217, 0}, {255, 217, 0}, {255, 218, 0}, {255, 219, 0},
{255, 219, 0}, {255, 220, 0}, {255, 221, 0}, {255, 221, 0},
{255, 222, 0}, {255, 223, 0}, {255, 223, 0}, {255, 224, 0},
{255, 225, 0}, {255, 225, 0}, {255, 226, 0}, {255, 227, 0},
{255, 227, 0}, {255, 228, 0}, {255, 229, 0}, {255, 229, 0},
{255, 230, 0}, {255, 231, 0}, {255, 231, 0}, {255, 232, 0},
{255, 233, 0}, {255, 233, 0}, {255, 234, 0}, {255, 235, 0},
{255, 235, 0}, {255, 236, 0}, {255, 237, 0}, {255, 237, 0},
{255, 238, 0}, {255, 239, 0}, {255, 239, 0}, {255, 240, 0},
{255, 241, 0}, {255, 241, 0}, {255, 242, 0}, {255, 243, 0},
{255, 243, 0}, {255, 244, 0}, {255, 245, 0}, {255, 245, 0},
{255, 246, 0}, {255, 247, 0}, {255, 247, 0}, {255, 248, 0},
{255, 249, 0}, {255, 249, 0}, {255, 250, 0}, {255, 251, 0},
{255, 251, 0}, {255, 252, 0}, {255, 253, 0}, {255, 253, 0},
{255, 254, 0}, {255, 255, 0}, {255, 255, 1}, {255, 255, 2},
{255, 255, 3}, {255, 255, 4}, {255, 255, 5}, {255, 255, 6},
{255, 255, 7}, {255, 255, 8}, {255, 255, 9}, {255, 255, 10},
{255, 255, 11}, {255, 255, 12}, {255, 255, 13}, {255, 255, 14},
{255, 255, 15}, {255, 255, 16}, {255, 255, 17}, {255, 255, 18},
{255, 255, 19}, {255, 255, 20}, {255, 255, 21}, {255, 255, 22},
{255, 255, 23}, {255, 255, 24}, {255, 255, 25}, {255, 255, 26},
{255, 255, 27}, {255, 255, 28}, {255, 255, 29}, {255, 255, 30},
{255, 255, 31}, {255, 255, 32}, {255, 255, 33}, {255, 255, 34},
{255, 255, 35}, {255, 255, 36}, {255, 255, 37}, {255, 255, 38},
{255, 255, 39}, {255, 255, 40}, {255, 255, 41}, {255, 255, 42},
{255, 255, 43}, {255, 255, 44}, {255, 255, 45}, {255, 255, 46},
{255, 255, 47}, {255, 255, 48}, {255, 255, 49}, {255, 255, 50},
{255, 255, 51}, {255, 255, 52}, {255, 255, 53}, {255, 255, 54},
{255, 255, 55}, {255, 255, 56}, {255, 255, 57}, {255, 255, 58},
{255, 255, 59}, {255, 255, 60}, {255, 255, 61}, {255, 255, 62},
{255, 255, 63}, {255, 255, 64}, {255, 255, 65}, {255, 255, 66},
{255, 255, 67}, {255, 255, 68}, {255, 255, 69}, {255, 255, 70},
{255, 255, 71}, {255, 255, 72}, {255, 255, 73}, {255, 255, 74},
{255, 255, 75}, {255, 255, 76}, {255, 255, 77}, {255, 255, 78},
{255, 255, 79}, {255, 255, 80}, {255, 255, 81}, {255, 255, 82},
{255, 255, 83}, {255, 255, 84}, {255, 255, 85}, {255, 255, 86},
{255, 255, 87}, {255, 255, 88}, {255, 255, 89}, {255, 255, 90},
{255, 255, 91}, {255, 255, 92}, {255, 255, 93}, {255, 255, 94},
{255, 255, 95}, {255, 255, 96}, {255, 255, 97}, {255, 255, 98},
{255, 255, 99}, {255, 255, 100}, {255, 255, 101}, {255, 255, 102},
{255, 255, 103}, {255, 255, 104}, {255, 255, 105}, {255, 255, 106},
{255, 255, 107}, {255, 255, 108}, {255, 255, 109}, {255, 255, 110},
{255, 255, 111}, {255, 255, 112}, {255, 255, 113}, {255, 255, 114},
{255, 255, 115}, {255, 255, 116}, {255, 255, 117}, {255, 255, 118},
{255, 255, 119}, {255, 255, 120}, {255, 255, 121}, {255, 255, 122},
{255, 255, 123}, {255, 255, 124}, {255, 255, 125}, {255, 255, 126},
{255, 255, 127}, {255, 255, 128}, {255, 255, 129}, {255, 255, 130},
{255, 255, 131}, {255, 255, 132}, {255, 255, 133}, {255, 255, 134},
{255, 255, 135}, {255, 255, 136}, {255, 255, 137}, {255, 255, 138},
{255, 255, 139}, {255, 255, 140}, {255, 255, 141}, {255, 255, 142},
{255, 255, 143}, {255, 255, 144}, {255, 255, 145}, {255, 255, 146},
{255, 255, 147}, {255, 255, 148}, {255, 255, 149}, {255, 255, 150},
{255, 255, 151}, {255, 255, 152}, {255, 255, 153}, {255, 255, 154},
{255, 255, 155}, {255, 255, 157}, {255, 255, 158}, {255, 255, 159},
{255, 255, 160}, {255, 255, 161}, {255, 255, 162}, {255, 255, 163},
{255, 255, 164}, {255, 255, 165}, {255, 255, 166}, {255, 255, 167},
{255, 255, 168}, {255, 255, 169}, {255, 255, 170}, {255, 255, 171},
{255, 255, 172}, {255, 255, 173}, {255, 255, 174}, {255, 255, 175},
{255, 255, 176}, {255, 255, 177}, {255, 255, 178}, {255, 255, 179},
{255, 255, 180}, {255, 255, 181}, {255, 255, 182}, {255, 255, 183},
{255, 255, 184}, {255, 255, 185}, {255, 255, 186}, {255, 255, 187},
{255, 255, 188}, {255, 255, 189}, {255, 255, 190}, {255, 255, 191},
{255, 255, 192}, {255, 255, 193}, {255, 255, 194}, {255, 255, 195},
{255, 255, 196}, {255, 255, 197}, {255, 255, 198}, {255, 255, 199},
{255, 255, 200}, {255, 255, 201}, {255, 255, 202}, {255, 255, 203},
{255, 255, 204}, {255, 255, 205}, {255, 255, 206}, {255, 255, 207},
{255, 255, 208}, {255, 255, 209}, {255, 255, 210}, {255, 255, 211},
{255, 255, 212}, {255, 255, 213}, {255, 255, 214}, {255, 255, 215},
{255, 255, 216}, {255, 255, 217}, {255, 255, 218}, {255, 255, 219},
{255, 255, 220}, {255, 255, 221}, {255, 255, 222}, {255, 255, 223},
{255, 255, 224}, {255, 255, 225}, {255, 255, 226}, {255, 255, 227},
{255, 255, 228}, {255, 255, 229}, {255, 255, 230}, {255, 255, 231},
{255, 255, 232}, {255, 255, 233}, {255, 255, 234}, {255, 255, 235},
{255, 255, 236}, {255, 255, 237}, {255, 255, 238}, {255, 255, 239},
{255, 255, 240}, {255, 255, 241}, {255, 255, 242}, {255, 255, 243},
{255, 255, 244}, {255, 255, 245}, {255, 255, 246}, {255, 255, 247},
{255, 255, 248}, {255, 255, 249}, {255, 255, 250}, {255, 255, 251},
{255, 255, 252}, {255, 255, 253}, {255, 255, 254}, {255}};
const rgb_store hsv_colormap[1000] = {
{255, 0, 0}, {255, 2, 0}, {255, 3, 0}, {255, 5, 0}, {255, 6, 0},
{255, 8, 0}, {255, 9, 0}, {255, 11, 0}, {255, 12, 0}, {255, 14, 0},
{255, 15, 0}, {255, 17, 0}, {255, 18, 0}, {255, 20, 0}, {255, 21, 0},
{255, 23, 0}, {255, 24, 0}, {255, 26, 0}, {255, 27, 0}, {255, 29, 0},
{255, 30, 0}, {255, 32, 0}, {255, 33, 0}, {255, 35, 0}, {255, 36, 0},
{255, 38, 0}, {255, 39, 0}, {255, 41, 0}, {255, 42, 0}, {255, 44, 0},
{255, 45, 0}, {255, 47, 0}, {255, 48, 0}, {255, 50, 0}, {255, 51, 0},
{255, 53, 0}, {255, 54, 0}, {255, 56, 0}, {255, 57, 0}, {255, 59, 0},
{255, 60, 0}, {255, 62, 0}, {255, 63, 0}, {255, 65, 0}, {255, 66, 0},
{255, 68, 0}, {255, 69, 0}, {255, 71, 0}, {255, 72, 0}, {255, 74, 0},
{255, 75, 0}, {255, 77, 0}, {255, 78, 0}, {255, 80, 0}, {255, 81, 0},
{255, 83, 0}, {255, 84, 0}, {255, 86, 0}, {255, 87, 0}, {255, 89, 0},
{255, 90, 0}, {255, 92, 0}, {255, 93, 0}, {255, 95, 0}, {255, 96, 0},
{255, 98, 0}, {255, 100, 0}, {255, 101, 0}, {255, 103, 0}, {255, 104, 0},
{255, 106, 0}, {255, 107, 0}, {255, 109, 0}, {255, 110, 0}, {255, 112, 0},
{255, 113, 0}, {255, 115, 0}, {255, 116, 0}, {255, 118, 0}, {255, 119, 0},
{255, 121, 0}, {255, 122, 0}, {255, 124, 0}, {255, 125, 0}, {255, 127, 0},
{255, 128, 0}, {255, 130, 0}, {255, 131, 0}, {255, 133, 0}, {255, 134, 0},
{255, 136, 0}, {255, 137, 0}, {255, 139, 0}, {255, 140, 0}, {255, 142, 0},
{255, 143, 0}, {255, 145, 0}, {255, 146, 0}, {255, 148, 0}, {255, 149, 0},
{255, 151, 0}, {255, 152, 0}, {255, 154, 0}, {255, 155, 0}, {255, 157, 0},
{255, 158, 0}, {255, 160, 0}, {255, 161, 0}, {255, 163, 0}, {255, 164, 0},
{255, 166, 0}, {255, 167, 0}, {255, 169, 0}, {255, 170, 0}, {255, 172, 0},
{255, 173, 0}, {255, 175, 0}, {255, 176, 0}, {255, 178, 0}, {255, 179, 0},
{255, 181, 0}, {255, 182, 0}, {255, 184, 0}, {255, 185, 0}, {255, 187, 0},
{255, 188, 0}, {255, 190, 0}, {255, 191, 0}, {255, 193, 0}, {255, 194, 0},
{255, 196, 0}, {255, 197, 0}, {255, 199, 0}, {255, 201, 0}, {255, 202, 0},
{255, 204, 0}, {255, 205, 0}, {255, 207, 0}, {255, 208, 0}, {255, 210, 0},
{255, 211, 0}, {255, 213, 0}, {255, 214, 0}, {255, 216, 0}, {255, 217, 0},
{255, 219, 0}, {255, 220, 0}, {255, 222, 0}, {255, 223, 0}, {255, 225, 0},
{255, 226, 0}, {255, 228, 0}, {255, 229, 0}, {255, 231, 0}, {255, 232, 0},
{255, 234, 0}, {255, 235, 0}, {255, 237, 0}, {255, 238, 0}, {255, 239, 0},
{254, 240, 0}, {254, 242, 0}, {253, 243, 0}, {253, 244, 0}, {252, 245, 0},
{252, 246, 0}, {251, 247, 0}, {251, 248, 0}, {250, 249, 0}, {250, 250, 0},
{249, 251, 0}, {249, 252, 0}, {248, 253, 0}, {248, 254, 0}, {247, 255, 0},
{246, 255, 0}, {245, 255, 0}, {243, 255, 0}, {242, 255, 0}, {240, 255, 0},
{239, 255, 0}, {237, 255, 0}, {236, 255, 0}, {234, 255, 0}, {233, 255, 0},
{231, 255, 0}, {230, 255, 0}, {228, 255, 0}, {227, 255, 0}, {225, 255, 0},
{224, 255, 0}, {222, 255, 0}, {221, 255, 0}, {219, 255, 0}, {218, 255, 0},
{216, 255, 0}, {215, 255, 0}, {213, 255, 0}, {211, 255, 0}, {210, 255, 0},
{208, 255, 0}, {207, 255, 0}, {205, 255, 0}, {204, 255, 0}, {202, 255, 0},
{201, 255, 0}, {199, 255, 0}, {198, 255, 0}, {196, 255, 0}, {195, 255, 0},
{193, 255, 0}, {192, 255, 0}, {190, 255, 0}, {189, 255, 0}, {187, 255, 0},
{186, 255, 0}, {184, 255, 0}, {183, 255, 0}, {181, 255, 0}, {180, 255, 0},
{178, 255, 0}, {177, 255, 0}, {175, 255, 0}, {174, 255, 0}, {172, 255, 0},
{171, 255, 0}, {169, 255, 0}, {168, 255, 0}, {166, 255, 0}, {165, 255, 0},
{163, 255, 0}, {162, 255, 0}, {160, 255, 0}, {159, 255, 0}, {157, 255, 0},
{156, 255, 0}, {154, 255, 0}, {153, 255, 0}, {151, 255, 0}, {150, 255, 0},
{148, 255, 0}, {147, 255, 0}, {145, 255, 0}, {144, 255, 0}, {142, 255, 0},
{141, 255, 0}, {139, 255, 0}, {138, 255, 0}, {136, 255, 0}, {135, 255, 0},
{133, 255, 0}, {132, 255, 0}, {130, 255, 0}, {129, 255, 0}, {127, 255, 0},
{126, 255, 0}, {124, 255, 0}, {123, 255, 0}, {121, 255, 0}, {120, 255, 0},
{118, 255, 0}, {117, 255, 0}, {115, 255, 0}, {114, 255, 0}, {112, 255, 0},
{110, 255, 0}, {109, 255, 0}, {107, 255, 0}, {106, 255, 0}, {104, 255, 0},
{103, 255, 0}, {101, 255, 0}, {100, 255, 0}, {98, 255, 0}, {97, 255, 0},
{95, 255, 0}, {94, 255, 0}, {92, 255, 0}, {91, 255, 0}, {89, 255, 0},
{88, 255, 0}, {86, 255, 0}, {85, 255, 0}, {83, 255, 0}, {82, 255, 0},
{80, 255, 0}, {79, 255, 0}, {77, 255, 0}, {76, 255, 0}, {74, 255, 0},
{73, 255, 0}, {71, 255, 0}, {70, 255, 0}, {68, 255, 0}, {67, 255, 0},
{65, 255, 0}, {64, 255, 0}, {62, 255, 0}, {61, 255, 0}, {59, 255, 0},
{58, 255, 0}, {56, 255, 0}, {55, 255, 0}, {53, 255, 0}, {52, 255, 0},
{50, 255, 0}, {49, 255, 0}, {47, 255, 0}, {46, 255, 0}, {44, 255, 0},
{43, 255, 0}, {41, 255, 0}, {40, 255, 0}, {38, 255, 0}, {37, 255, 0},
{35, 255, 0}, {34, 255, 0}, {32, 255, 0}, {31, 255, 0}, {29, 255, 0},
{28, 255, 0}, {26, 255, 0}, {25, 255, 0}, {23, 255, 0}, {22, 255, 0},
{20, 255, 0}, {19, 255, 0}, {17, 255, 0}, {16, 255, 0}, {14, 255, 0},
{12, 255, 0}, {11, 255, 0}, {9, 255, 0}, {8, 255, 0}, {7, 255, 1},
{7, 255, 2}, {6, 255, 3}, {6, 255, 4}, {5, 255, 5}, {5, 255, 6},
{4, 255, 7}, {4, 255, 8}, {3, 255, 9}, {3, 255, 10}, {2, 255, 11},
{2, 255, 12}, {1, 255, 13}, {1, 255, 14}, {0, 255, 15}, {0, 255, 16},
{0, 255, 18}, {0, 255, 19}, {0, 255, 21}, {0, 255, 22}, {0, 255, 24},
{0, 255, 25}, {0, 255, 27}, {0, 255, 28}, {0, 255, 30}, {0, 255, 31},
{0, 255, 33}, {0, 255, 34}, {0, 255, 36}, {0, 255, 37}, {0, 255, 39},
{0, 255, 40}, {0, 255, 42}, {0, 255, 43}, {0, 255, 45}, {0, 255, 46},
{0, 255, 48}, {0, 255, 49}, {0, 255, 51}, {0, 255, 52}, {0, 255, 54},
{0, 255, 55}, {0, 255, 57}, {0, 255, 58}, {0, 255, 60}, {0, 255, 61},
{0, 255, 63}, {0, 255, 64}, {0, 255, 66}, {0, 255, 67}, {0, 255, 69},
{0, 255, 70}, {0, 255, 72}, {0, 255, 73}, {0, 255, 75}, {0, 255, 76},
{0, 255, 78}, {0, 255, 79}, {0, 255, 81}, {0, 255, 82}, {0, 255, 84},
{0, 255, 86}, {0, 255, 87}, {0, 255, 89}, {0, 255, 90}, {0, 255, 92},
{0, 255, 93}, {0, 255, 95}, {0, 255, 96}, {0, 255, 98}, {0, 255, 99},
{0, 255, 101}, {0, 255, 102}, {0, 255, 104}, {0, 255, 105}, {0, 255, 107},
{0, 255, 108}, {0, 255, 110}, {0, 255, 111}, {0, 255, 113}, {0, 255, 114},
{0, 255, 116}, {0, 255, 117}, {0, 255, 119}, {0, 255, 120}, {0, 255, 122},
{0, 255, 123}, {0, 255, 125}, {0, 255, 126}, {0, 255, 128}, {0, 255, 129},
{0, 255, 131}, {0, 255, 132}, {0, 255, 134}, {0, 255, 135}, {0, 255, 137},
{0, 255, 138}, {0, 255, 140}, {0, 255, 141}, {0, 255, 143}, {0, 255, 144},
{0, 255, 146}, {0, 255, 147}, {0, 255, 149}, {0, 255, 150}, {0, 255, 152},
{0, 255, 153}, {0, 255, 155}, {0, 255, 156}, {0, 255, 158}, {0, 255, 159},
{0, 255, 161}, {0, 255, 162}, {0, 255, 164}, {0, 255, 165}, {0, 255, 167},
{0, 255, 168}, {0, 255, 170}, {0, 255, 171}, {0, 255, 173}, {0, 255, 174},
{0, 255, 176}, {0, 255, 177}, {0, 255, 179}, {0, 255, 180}, {0, 255, 182},
{0, 255, 183}, {0, 255, 185}, {0, 255, 187}, {0, 255, 188}, {0, 255, 190},
{0, 255, 191}, {0, 255, 193}, {0, 255, 194}, {0, 255, 196}, {0, 255, 197},
{0, 255, 199}, {0, 255, 200}, {0, 255, 202}, {0, 255, 203}, {0, 255, 205},
{0, 255, 206}, {0, 255, 208}, {0, 255, 209}, {0, 255, 211}, {0, 255, 212},
{0, 255, 214}, {0, 255, 215}, {0, 255, 217}, {0, 255, 218}, {0, 255, 220},
{0, 255, 221}, {0, 255, 223}, {0, 255, 224}, {0, 255, 226}, {0, 255, 227},
{0, 255, 229}, {0, 255, 230}, {0, 255, 232}, {0, 255, 233}, {0, 255, 235},
{0, 255, 236}, {0, 255, 238}, {0, 255, 239}, {0, 255, 241}, {0, 255, 242},
{0, 255, 244}, {0, 255, 245}, {0, 255, 247}, {0, 255, 248}, {0, 255, 250},
{0, 255, 251}, {0, 255, 253}, {0, 255, 254}, {0, 254, 255}, {0, 253, 255},
{0, 251, 255}, {0, 250, 255}, {0, 248, 255}, {0, 247, 255}, {0, 245, 255},
{0, 244, 255}, {0, 242, 255}, {0, 241, 255}, {0, 239, 255}, {0, 238, 255},
{0, 236, 255}, {0, 235, 255}, {0, 233, 255}, {0, 232, 255}, {0, 230, 255},
{0, 229, 255}, {0, 227, 255}, {0, 225, 255}, {0, 224, 255}, {0, 222, 255},
{0, 221, 255}, {0, 219, 255}, {0, 218, 255}, {0, 216, 255}, {0, 215, 255},
{0, 213, 255}, {0, 212, 255}, {0, 210, 255}, {0, 209, 255}, {0, 207, 255},
{0, 206, 255}, {0, 204, 255}, {0, 203, 255}, {0, 201, 255}, {0, 200, 255},
{0, 198, 255}, {0, 197, 255}, {0, 195, 255}, {0, 194, 255}, {0, 192, 255},
{0, 191, 255}, {0, 189, 255}, {0, 188, 255}, {0, 186, 255}, {0, 185, 255},
{0, 183, 255}, {0, 182, 255}, {0, 180, 255}, {0, 179, 255}, {0, 177, 255},
{0, 176, 255}, {0, 174, 255}, {0, 173, 255}, {0, 171, 255}, {0, 170, 255},
{0, 168, 255}, {0, 167, 255}, {0, 165, 255}, {0, 164, 255}, {0, 162, 255},
{0, 161, 255}, {0, 159, 255}, {0, 158, 255}, {0, 156, 255}, {0, 155, 255},
{0, 153, 255}, {0, 152, 255}, {0, 150, 255}, {0, 149, 255}, {0, 147, 255},
{0, 146, 255}, {0, 144, 255}, {0, 143, 255}, {0, 141, 255}, {0, 140, 255},
{0, 138, 255}, {0, 137, 255}, {0, 135, 255}, {0, 134, 255}, {0, 132, 255},
{0, 131, 255}, {0, 129, 255}, {0, 128, 255}, {0, 126, 255}, {0, 124, 255},
{0, 123, 255}, {0, 121, 255}, {0, 120, 255}, {0, 118, 255}, {0, 117, 255},
{0, 115, 255}, {0, 114, 255}, {0, 112, 255}, {0, 111, 255}, {0, 109, 255},
{0, 108, 255}, {0, 106, 255}, {0, 105, 255}, {0, 103, 255}, {0, 102, 255},
{0, 100, 255}, {0, 99, 255}, {0, 97, 255}, {0, 96, 255}, {0, 94, 255},
{0, 93, 255}, {0, 91, 255}, {0, 90, 255}, {0, 88, 255}, {0, 87, 255},
{0, 85, 255}, {0, 84, 255}, {0, 82, 255}, {0, 81, 255}, {0, 79, 255},
{0, 78, 255}, {0, 76, 255}, {0, 75, 255}, {0, 73, 255}, {0, 72, 255},
{0, 70, 255}, {0, 69, 255}, {0, 67, 255}, {0, 66, 255}, {0, 64, 255},
{0, 63, 255}, {0, 61, 255}, {0, 60, 255}, {0, 58, 255}, {0, 57, 255},
{0, 55, 255}, {0, 54, 255}, {0, 52, 255}, {0, 51, 255}, {0, 49, 255},
{0, 48, 255}, {0, 46, 255}, {0, 45, 255}, {0, 43, 255}, {0, 42, 255},
{0, 40, 255}, {0, 39, 255}, {0, 37, 255}, {0, 36, 255}, {0, 34, 255},
{0, 33, 255}, {0, 31, 255}, {0, 30, 255}, {0, 28, 255}, {0, 26, 255},
{0, 25, 255}, {0, 23, 255}, {0, 22, 255}, {0, 20, 255}, {0, 19, 255},
{0, 17, 255}, {0, 16, 255}, {1, 15, 255}, {1, 14, 255}, {2, 13, 255},
{2, 12, 255}, {3, 11, 255}, {3, 10, 255}, {4, 9, 255}, {4, 8, 255},
{5, 7, 255}, {5, 6, 255}, {6, 5, 255}, {6, 4, 255}, {7, 3, 255},
{7, 2, 255}, {8, 1, 255}, {8, 0, 255}, {10, 0, 255}, {11, 0, 255},
{13, 0, 255}, {14, 0, 255}, {16, 0, 255}, {17, 0, 255}, {19, 0, 255},
{20, 0, 255}, {22, 0, 255}, {23, 0, 255}, {25, 0, 255}, {26, 0, 255},
{28, 0, 255}, {29, 0, 255}, {31, 0, 255}, {32, 0, 255}, {34, 0, 255},
{35, 0, 255}, {37, 0, 255}, {38, 0, 255}, {40, 0, 255}, {41, 0, 255},
{43, 0, 255}, {44, 0, 255}, {46, 0, 255}, {47, 0, 255}, {49, 0, 255},
{50, 0, 255}, {52, 0, 255}, {53, 0, 255}, {55, 0, 255}, {56, 0, 255},
{58, 0, 255}, {59, 0, 255}, {61, 0, 255}, {62, 0, 255}, {64, 0, 255},
{65, 0, 255}, {67, 0, 255}, {68, 0, 255}, {70, 0, 255}, {72, 0, 255},
{73, 0, 255}, {75, 0, 255}, {76, 0, 255}, {78, 0, 255}, {79, 0, 255},
{81, 0, 255}, {82, 0, 255}, {84, 0, 255}, {85, 0, 255}, {87, 0, 255},
{88, 0, 255}, {90, 0, 255}, {91, 0, 255}, {93, 0, 255}, {94, 0, 255},
{96, 0, 255}, {97, 0, 255}, {99, 0, 255}, {100, 0, 255}, {102, 0, 255},
{103, 0, 255}, {105, 0, 255}, {106, 0, 255}, {108, 0, 255}, {109, 0, 255},
{111, 0, 255}, {112, 0, 255}, {114, 0, 255}, {115, 0, 255}, {117, 0, 255},
{118, 0, 255}, {120, 0, 255}, {121, 0, 255}, {123, 0, 255}, {124, 0, 255},
{126, 0, 255}, {127, 0, 255}, {129, 0, 255}, {130, 0, 255}, {132, 0, 255},
{133, 0, 255}, {135, 0, 255}, {136, 0, 255}, {138, 0, 255}, {139, 0, 255},
{141, 0, 255}, {142, 0, 255}, {144, 0, 255}, {145, 0, 255}, {147, 0, 255},
{148, 0, 255}, {150, 0, 255}, {151, 0, 255}, {153, 0, 255}, {154, 0, 255},
{156, 0, 255}, {157, 0, 255}, {159, 0, 255}, {160, 0, 255}, {162, 0, 255},
{163, 0, 255}, {165, 0, 255}, {166, 0, 255}, {168, 0, 255}, {169, 0, 255},
{171, 0, 255}, {173, 0, 255}, {174, 0, 255}, {176, 0, 255}, {177, 0, 255},
{179, 0, 255}, {180, 0, 255}, {182, 0, 255}, {183, 0, 255}, {185, 0, 255},
{186, 0, 255}, {188, 0, 255}, {189, 0, 255}, {191, 0, 255}, {192, 0, 255},
{194, 0, 255}, {195, 0, 255}, {197, 0, 255}, {198, 0, 255}, {200, 0, 255},
{201, 0, 255}, {203, 0, 255}, {204, 0, 255}, {206, 0, 255}, {207, 0, 255},
{209, 0, 255}, {210, 0, 255}, {212, 0, 255}, {213, 0, 255}, {215, 0, 255},
{216, 0, 255}, {218, 0, 255}, {219, 0, 255}, {221, 0, 255}, {222, 0, 255},
{224, 0, 255}, {225, 0, 255}, {227, 0, 255}, {228, 0, 255}, {230, 0, 255},
{231, 0, 255}, {233, 0, 255}, {234, 0, 255}, {236, 0, 255}, {237, 0, 255},
{239, 0, 255}, {240, 0, 255}, {242, 0, 255}, {243, 0, 255}, {245, 0, 255},
{246, 0, 255}, {247, 0, 254}, {248, 0, 253}, {248, 0, 252}, {249, 0, 251},
{249, 0, 250}, {250, 0, 249}, {250, 0, 248}, {251, 0, 247}, {251, 0, 246},
{252, 0, 245}, {252, 0, 244}, {253, 0, 243}, {253, 0, 242}, {254, 0, 241},
{254, 0, 240}, {255, 0, 239}, {255, 0, 238}, {255, 0, 236}, {255, 0, 235},
{255, 0, 233}, {255, 0, 232}, {255, 0, 230}, {255, 0, 229}, {255, 0, 227},
{255, 0, 226}, {255, 0, 224}, {255, 0, 223}, {255, 0, 221}, {255, 0, 220},
{255, 0, 218}, {255, 0, 217}, {255, 0, 215}, {255, 0, 214}, {255, 0, 212},
{255, 0, 211}, {255, 0, 209}, {255, 0, 208}, {255, 0, 206}, {255, 0, 205},
{255, 0, 203}, {255, 0, 202}, {255, 0, 200}, {255, 0, 199}, {255, 0, 197},
{255, 0, 196}, {255, 0, 194}, {255, 0, 193}, {255, 0, 191}, {255, 0, 190},
{255, 0, 188}, {255, 0, 187}, {255, 0, 185}, {255, 0, 184}, {255, 0, 182},
{255, 0, 181}, {255, 0, 179}, {255, 0, 178}, {255, 0, 176}, {255, 0, 175},
{255, 0, 173}, {255, 0, 172}, {255, 0, 170}, {255, 0, 169}, {255, 0, 167},
{255, 0, 166}, {255, 0, 164}, {255, 0, 163}, {255, 0, 161}, {255, 0, 160},
{255, 0, 158}, {255, 0, 157}, {255, 0, 155}, {255, 0, 154}, {255, 0, 152},
{255, 0, 151}, {255, 0, 149}, {255, 0, 148}, {255, 0, 146}, {255, 0, 145},
{255, 0, 143}, {255, 0, 141}, {255, 0, 140}, {255, 0, 138}, {255, 0, 137},
{255, 0, 135}, {255, 0, 134}, {255, 0, 132}, {255, 0, 131}, {255, 0, 129},
{255, 0, 128}, {255, 0, 126}, {255, 0, 125}, {255, 0, 123}, {255, 0, 122},
{255, 0, 120}, {255, 0, 119}, {255, 0, 117}, {255, 0, 116}, {255, 0, 114},
{255, 0, 113}, {255, 0, 111}, {255, 0, 110}, {255, 0, 108}, {255, 0, 107},
{255, 0, 105}, {255, 0, 104}, {255, 0, 102}, {255, 0, 101}, {255, 0, 99},
{255, 0, 98}, {255, 0, 96}, {255, 0, 95}, {255, 0, 93}, {255, 0, 92},
{255, 0, 90}, {255, 0, 89}, {255, 0, 87}, {255, 0, 86}, {255, 0, 84},
{255, 0, 83}, {255, 0, 81}, {255, 0, 80}, {255, 0, 78}, {255, 0, 77},
{255, 0, 75}, {255, 0, 74}, {255, 0, 72}, {255, 0, 71}, {255, 0, 69},
{255, 0, 68}, {255, 0, 66}, {255, 0, 65}, {255, 0, 63}, {255, 0, 62},
{255, 0, 60}, {255, 0, 59}, {255, 0, 57}, {255, 0, 56}, {255, 0, 54},
{255, 0, 53}, {255, 0, 51}, {255, 0, 50}, {255, 0, 48}, {255, 0, 47},
{255, 0, 45}, {255, 0, 44}, {255, 0, 42}, {255, 0, 40}, {255, 0, 39},
{255, 0, 37}, {255, 0, 36}, {255, 0, 34}, {255, 0, 33}, {255, 0, 31},
{255, 0, 30}, {255, 0, 28}, {255, 0, 27}, {255, 0, 25}, {255, 0, 24}};
const rgb_store jet_colormap[1000] = {
{29, 0, 102}, {23, 0, 107}, {17, 0, 112}, {12, 0, 117},
{6, 0, 122}, {0, 0, 127}, {0, 0, 128}, {0, 0, 129},
{0, 0, 129}, {0, 0, 130}, {0, 0, 131}, {0, 0, 132},
{0, 0, 133}, {0, 0, 133}, {0, 0, 134}, {0, 0, 135},
{0, 0, 136}, {0, 0, 137}, {0, 0, 138}, {0, 0, 140},
{0, 0, 141}, {0, 0, 142}, {0, 0, 143}, {0, 0, 145},
{0, 0, 146}, {0, 0, 147}, {0, 0, 148}, {0, 0, 150},
{0, 0, 151}, {0, 0, 152}, {0, 0, 153}, {0, 0, 154},
{0, 0, 156}, {0, 0, 157}, {0, 0, 158}, {0, 0, 159},
{0, 0, 160}, {0, 0, 161}, {0, 0, 163}, {0, 0, 164},
{0, 0, 165}, {0, 0, 166}, {0, 0, 168}, {0, 0, 169},
{0, 0, 170}, {0, 0, 171}, {0, 0, 173}, {0, 0, 174},
{0, 0, 175}, {0, 0, 176}, {0, 0, 178}, {0, 0, 179},
{0, 0, 180}, {0, 0, 181}, {0, 0, 183}, {0, 0, 184},
{0, 0, 185}, {0, 0, 186}, {0, 0, 188}, {0, 0, 189},
{0, 0, 190}, {0, 0, 191}, {0, 0, 193}, {0, 0, 194},
{0, 0, 195}, {0, 0, 196}, {0, 0, 197}, {0, 0, 198},
{0, 0, 200}, {0, 0, 201}, {0, 0, 202}, {0, 0, 203},
{0, 0, 204}, {0, 0, 206}, {0, 0, 207}, {0, 0, 208},
{0, 0, 209}, {0, 0, 211}, {0, 0, 212}, {0, 0, 213},
{0, 0, 214}, {0, 0, 216}, {0, 0, 217}, {0, 0, 218},
{0, 0, 219}, {0, 0, 221}, {0, 0, 222}, {0, 0, 223},
{0, 0, 225}, {0, 0, 226}, {0, 0, 227}, {0, 0, 228},
{0, 0, 230}, {0, 0, 231}, {0, 0, 232}, {0, 0, 233},
{0, 0, 234}, {0, 0, 234}, {0, 0, 235}, {0, 0, 236},
{0, 0, 237}, {0, 0, 238}, {0, 0, 239}, {0, 0, 239},
{0, 0, 240}, {0, 0, 241}, {0, 0, 242}, {0, 0, 243},
{0, 0, 244}, {0, 0, 246}, {0, 0, 247}, {0, 0, 248},
{0, 0, 249}, {0, 0, 250}, {0, 0, 251}, {0, 0, 253},
{0, 0, 254}, {0, 0, 254}, {0, 0, 254}, {0, 0, 254},
{0, 0, 254}, {0, 0, 254}, {0, 0, 255}, {0, 0, 255},
{0, 0, 255}, {0, 0, 255}, {0, 0, 255}, {0, 0, 255},
{0, 1, 255}, {0, 1, 255}, {0, 2, 255}, {0, 3, 255},
{0, 3, 255}, {0, 4, 255}, {0, 5, 255}, {0, 6, 255},
{0, 6, 255}, {0, 7, 255}, {0, 8, 255}, {0, 9, 255},
{0, 10, 255}, {0, 11, 255}, {0, 12, 255}, {0, 13, 255},
{0, 14, 255}, {0, 15, 255}, {0, 16, 255}, {0, 17, 255},
{0, 18, 255}, {0, 19, 255}, {0, 21, 255}, {0, 22, 255},
{0, 23, 255}, {0, 24, 255}, {0, 25, 255}, {0, 26, 255},
{0, 27, 255}, {0, 28, 255}, {0, 29, 255}, {0, 30, 255},
{0, 31, 255}, {0, 32, 255}, {0, 34, 255}, {0, 35, 255},
{0, 36, 255}, {0, 37, 255}, {0, 38, 255}, {0, 39, 255},
{0, 40, 255}, {0, 41, 255}, {0, 42, 255}, {0, 43, 255},
{0, 44, 255}, {0, 45, 255}, {0, 46, 255}, {0, 48, 255},
{0, 49, 255}, {0, 50, 255}, {0, 51, 255}, {0, 52, 255},
{0, 53, 255}, {0, 54, 255}, {0, 55, 255}, {0, 56, 255},
{0, 57, 255}, {0, 58, 255}, {0, 58, 255}, {0, 59, 255},
{0, 60, 255}, {0, 60, 255}, {0, 61, 255}, {0, 62, 255},
{0, 63, 255}, {0, 63, 255}, {0, 64, 255}, {0, 65, 255},
{0, 66, 255}, {0, 67, 255}, {0, 68, 255}, {0, 69, 255},
{0, 71, 255}, {0, 72, 255}, {0, 73, 255}, {0, 74, 255},
{0, 75, 255}, {0, 76, 255}, {0, 77, 255}, {0, 78, 255},
{0, 79, 255}, {0, 80, 255}, {0, 81, 255}, {0, 82, 255},
{0, 84, 255}, {0, 85, 255}, {0, 86, 255}, {0, 87, 255},
{0, 88, 255}, {0, 89, 255}, {0, 90, 255}, {0, 91, 255},
{0, 92, 255}, {0, 93, 255}, {0, 94, 255}, {0, 95, 255},
{0, 96, 255}, {0, 98, 255}, {0, 99, 255}, {0, 100, 255},
{0, 101, 255}, {0, 102, 255}, {0, 103, 255}, {0, 104, 255},
{0, 105, 255}, {0, 106, 255}, {0, 107, 255}, {0, 108, 255},
{0, 109, 255}, {0, 111, 255}, {0, 112, 255}, {0, 113, 255},
{0, 114, 255}, {0, 115, 255}, {0, 116, 255}, {0, 117, 255},
{0, 118, 255}, {0, 119, 255}, {0, 120, 255}, {0, 121, 255},
{0, 122, 255}, {0, 123, 255}, {0, 125, 255}, {0, 126, 255},
{0, 127, 255}, {0, 128, 255}, {0, 129, 255}, {0, 130, 255},
{0, 131, 255}, {0, 132, 255}, {0, 133, 255}, {0, 134, 255},
{0, 135, 255}, {0, 136, 255}, {0, 138, 255}, {0, 139, 255},
{0, 140, 255}, {0, 141, 255}, {0, 142, 255}, {0, 143, 255},
{0, 144, 255}, {0, 145, 255}, {0, 146, 255}, {0, 147, 255},
{0, 148, 255}, {0, 149, 255}, {0, 150, 255}, {0, 150, 255},
{0, 151, 255}, {0, 152, 255}, {0, 153, 255}, {0, 153, 255},
{0, 154, 255}, {0, 155, 255}, {0, 155, 255}, {0, 156, 255},
{0, 157, 255}, {0, 158, 255}, {0, 159, 255}, {0, 161, 255},
{0, 162, 255}, {0, 163, 255}, {0, 164, 255}, {0, 165, 255},
{0, 166, 255}, {0, 167, 255}, {0, 168, 255}, {0, 169, 255},
{0, 170, 255}, {0, 171, 255}, {0, 172, 255}, {0, 173, 255},
{0, 175, 255}, {0, 176, 255}, {0, 177, 255}, {0, 178, 255},
{0, 179, 255}, {0, 180, 255}, {0, 181, 255}, {0, 182, 255},
{0, 183, 255}, {0, 184, 255}, {0, 185, 255}, {0, 186, 255},
{0, 188, 255}, {0, 189, 255}, {0, 190, 255}, {0, 191, 255},
{0, 192, 255}, {0, 193, 255}, {0, 194, 255}, {0, 195, 255},
{0, 196, 255}, {0, 197, 255}, {0, 198, 255}, {0, 199, 255},
{0, 200, 255}, {0, 202, 255}, {0, 203, 255}, {0, 204, 255},
{0, 205, 255}, {0, 206, 255}, {0, 207, 255}, {0, 208, 255},
{0, 209, 255}, {0, 210, 255}, {0, 211, 255}, {0, 212, 255},
{0, 213, 255}, {0, 215, 255}, {0, 216, 255}, {0, 217, 255},
{0, 218, 254}, {0, 219, 253}, {0, 220, 252}, {0, 221, 252},
{0, 222, 251}, {0, 223, 250}, {0, 224, 250}, {0, 225, 249},
{0, 226, 248}, {0, 227, 247}, {0, 229, 247}, {1, 230, 246},
{2, 231, 245}, {3, 232, 244}, {3, 233, 243}, {4, 234, 242},
{5, 235, 241}, {5, 236, 240}, {6, 237, 239}, {7, 238, 238},
{8, 239, 238}, {8, 240, 237}, {9, 241, 236}, {10, 242, 236},
{10, 242, 235}, {11, 243, 235}, {11, 244, 234}, {12, 245, 234},
{13, 245, 233}, {13, 246, 232}, {14, 247, 232}, {15, 247, 231},
{15, 248, 231}, {16, 249, 230}, {17, 249, 229}, {18, 250, 228},
{18, 251, 227}, {19, 251, 226}, {20, 252, 225}, {21, 253, 224},
{22, 253, 224}, {23, 254, 223}, {23, 254, 222}, {24, 255, 221},
{25, 255, 220}, {26, 255, 219}, {27, 255, 218}, {28, 255, 218},
{29, 255, 217}, {30, 255, 216}, {30, 255, 215}, {31, 255, 214},
{32, 255, 214}, {33, 255, 213}, {34, 255, 212}, {35, 255, 211},
{36, 255, 210}, {37, 255, 209}, {38, 255, 208}, {39, 255, 207},
{39, 255, 207}, {40, 255, 206}, {41, 255, 205}, {42, 255, 204},
{43, 255, 203}, {44, 255, 202}, {45, 255, 201}, {46, 255, 200},
{47, 255, 199}, {48, 255, 198}, {48, 255, 198}, {49, 255, 197},
{50, 255, 196}, {51, 255, 195}, {52, 255, 194}, {53, 255, 193},
{54, 255, 192}, {55, 255, 191}, {55, 255, 191}, {56, 255, 190},
{57, 255, 189}, {58, 255, 188}, {59, 255, 187}, {60, 255, 186},
{60, 255, 186}, {61, 255, 185}, {62, 255, 184}, {63, 255, 183},
{64, 255, 182}, {65, 255, 181}, {65, 255, 181}, {66, 255, 180},
{67, 255, 179}, {68, 255, 178}, {69, 255, 177}, {70, 255, 176},
{71, 255, 175}, {72, 255, 174}, {73, 255, 173}, {74, 255, 172},
{74, 255, 172}, {75, 255, 171}, {76, 255, 170}, {77, 255, 169},
{78, 255, 168}, {79, 255, 167}, {80, 255, 166}, {81, 255, 165},
{82, 255, 164}, {83, 255, 163}, {83, 255, 163}, {84, 255, 162},
{84, 255, 162}, {85, 255, 161}, {85, 255, 161}, {86, 255, 160},
{87, 255, 159}, {87, 255, 159}, {88, 255, 158}, {88, 255, 158},
{89, 255, 157}, {89, 255, 157}, {90, 255, 156}, {91, 255, 155},
{92, 255, 154}, {93, 255, 153}, {94, 255, 152}, {95, 255, 151},
{96, 255, 150}, {97, 255, 149}, {97, 255, 149}, {98, 255, 148},
{99, 255, 147}, {100, 255, 146}, {101, 255, 145}, {102, 255, 144},
{102, 255, 143}, {103, 255, 142}, {104, 255, 141}, {105, 255, 140},
{106, 255, 140}, {107, 255, 139}, {107, 255, 138}, {108, 255, 137},
{109, 255, 136}, {110, 255, 135}, {111, 255, 134}, {112, 255, 134},
{113, 255, 133}, {114, 255, 132}, {114, 255, 131}, {115, 255, 130},
{116, 255, 130}, {117, 255, 129}, {118, 255, 128}, {119, 255, 127},
{120, 255, 126}, {121, 255, 125}, {122, 255, 124}, {123, 255, 123},
{123, 255, 123}, {124, 255, 122}, {125, 255, 121}, {126, 255, 120},
{127, 255, 119}, {128, 255, 118}, {129, 255, 117}, {130, 255, 116},
{130, 255, 115}, {131, 255, 114}, {132, 255, 114}, {133, 255, 113},
{134, 255, 112}, {134, 255, 111}, {135, 255, 110}, {136, 255, 109},
{137, 255, 108}, {138, 255, 107}, {139, 255, 107}, {140, 255, 106},
{140, 255, 105}, {141, 255, 104}, {142, 255, 103}, {143, 255, 102},
{144, 255, 102}, {145, 255, 101}, {146, 255, 100}, {147, 255, 99},
{148, 255, 98}, {149, 255, 97}, {149, 255, 97}, {150, 255, 96},
{151, 255, 95}, {152, 255, 94}, {153, 255, 93}, {154, 255, 92},
{155, 255, 91}, {156, 255, 90}, {157, 255, 89}, {157, 255, 89},
{158, 255, 88}, {158, 255, 88}, {159, 255, 87}, {159, 255, 87},
{160, 255, 86}, {161, 255, 85}, {161, 255, 85}, {162, 255, 84},
{162, 255, 84}, {163, 255, 83}, {163, 255, 83}, {164, 255, 82},
{165, 255, 81}, {166, 255, 80}, {167, 255, 79}, {168, 255, 78},
{169, 255, 77}, {170, 255, 76}, {171, 255, 75}, {172, 255, 74},
{172, 255, 74}, {173, 255, 73}, {174, 255, 72}, {175, 255, 71},
{176, 255, 70}, {177, 255, 69}, {178, 255, 68}, {179, 255, 67},
{180, 255, 66}, {181, 255, 65}, {181, 255, 65}, {182, 255, 64},
{183, 255, 63}, {184, 255, 62}, {185, 255, 61}, {186, 255, 60},
{186, 255, 60}, {187, 255, 59}, {188, 255, 58}, {189, 255, 57},
{190, 255, 56}, {191, 255, 55}, {191, 255, 55}, {192, 255, 54},
{193, 255, 53}, {194, 255, 52}, {195, 255, 51}, {196, 255, 50},
{197, 255, 49}, {198, 255, 48}, {198, 255, 48}, {199, 255, 47},
{200, 255, 46}, {201, 255, 45}, {202, 255, 44}, {203, 255, 43},
{204, 255, 42}, {205, 255, 41}, {206, 255, 40}, {207, 255, 39},
{207, 255, 39}, {208, 255, 38}, {209, 255, 37}, {210, 255, 36},
{211, 255, 35}, {212, 255, 34}, {213, 255, 33}, {214, 255, 32},
{214, 255, 31}, {215, 255, 30}, {216, 255, 30}, {217, 255, 29},
{218, 255, 28}, {218, 255, 27}, {219, 255, 26}, {220, 255, 25},
{221, 255, 24}, {222, 255, 23}, {223, 255, 23}, {224, 255, 22},
{224, 255, 21}, {225, 255, 20}, {226, 255, 19}, {227, 255, 18},
{228, 255, 18}, {229, 255, 17}, {230, 255, 16}, {231, 255, 15},
{231, 255, 15}, {232, 255, 14}, {232, 255, 13}, {233, 255, 13},
{234, 255, 12}, {234, 255, 11}, {235, 255, 11}, {235, 255, 10},
{236, 255, 10}, {236, 255, 9}, {237, 255, 8}, {238, 254, 8},
{238, 253, 7}, {239, 252, 6}, {240, 251, 5}, {241, 250, 5},
{242, 249, 4}, {243, 248, 3}, {244, 247, 3}, {245, 246, 2},
{246, 246, 1}, {247, 245, 0}, {247, 243, 0}, {248, 242, 0},
{249, 242, 0}, {250, 241, 0}, {250, 240, 0}, {251, 239, 0},
{252, 238, 0}, {252, 237, 0}, {253, 236, 0}, {254, 235, 0},
{255, 234, 0}, {255, 233, 0}, {255, 232, 0}, {255, 231, 0},
{255, 230, 0}, {255, 229, 0}, {255, 228, 0}, {255, 227, 0},
{255, 226, 0}, {255, 225, 0}, {255, 224, 0}, {255, 223, 0},
{255, 222, 0}, {255, 221, 0}, {255, 220, 0}, {255, 219, 0},
{255, 218, 0}, {255, 217, 0}, {255, 216, 0}, {255, 215, 0},
{255, 214, 0}, {255, 213, 0}, {255, 212, 0}, {255, 211, 0},
{255, 210, 0}, {255, 209, 0}, {255, 208, 0}, {255, 207, 0},
{255, 206, 0}, {255, 205, 0}, {255, 204, 0}, {255, 203, 0},
{255, 202, 0}, {255, 201, 0}, {255, 200, 0}, {255, 199, 0},
{255, 198, 0}, {255, 197, 0}, {255, 196, 0}, {255, 195, 0},
{255, 194, 0}, {255, 193, 0}, {255, 192, 0}, {255, 191, 0},
{255, 190, 0}, {255, 189, 0}, {255, 188, 0}, {255, 187, 0},
{255, 186, 0}, {255, 185, 0}, {255, 184, 0}, {255, 183, 0},
{255, 182, 0}, {255, 180, 0}, {255, 179, 0}, {255, 178, 0},
{255, 177, 0}, {255, 176, 0}, {255, 176, 0}, {255, 175, 0},
{255, 175, 0}, {255, 174, 0}, {255, 173, 0}, {255, 173, 0},
{255, 172, 0}, {255, 171, 0}, {255, 171, 0}, {255, 170, 0},
{255, 169, 0}, {255, 168, 0}, {255, 167, 0}, {255, 166, 0},
{255, 165, 0}, {255, 164, 0}, {255, 163, 0}, {255, 162, 0},
{255, 161, 0}, {255, 160, 0}, {255, 159, 0}, {255, 158, 0},
{255, 157, 0}, {255, 156, 0}, {255, 155, 0}, {255, 154, 0},
{255, 153, 0}, {255, 152, 0}, {255, 151, 0}, {255, 150, 0},
{255, 150, 0}, {255, 149, 0}, {255, 147, 0}, {255, 146, 0},
{255, 146, 0}, {255, 145, 0}, {255, 144, 0}, {255, 143, 0},
{255, 142, 0}, {255, 141, 0}, {255, 140, 0}, {255, 139, 0},
{255, 138, 0}, {255, 137, 0}, {255, 136, 0}, {255, 135, 0},
{255, 134, 0}, {255, 133, 0}, {255, 132, 0}, {255, 131, 0},
{255, 130, 0}, {255, 129, 0}, {255, 128, 0}, {255, 127, 0},
{255, 126, 0}, {255, 125, 0}, {255, 124, 0}, {255, 123, 0},
{255, 122, 0}, {255, 121, 0}, {255, 120, 0}, {255, 119, 0},
{255, 118, 0}, {255, 117, 0}, {255, 116, 0}, {255, 115, 0},
{255, 114, 0}, {255, 113, 0}, {255, 112, 0}, {255, 111, 0},
{255, 109, 0}, {255, 108, 0}, {255, 107, 0}, {255, 106, 0},
{255, 105, 0}, {255, 104, 0}, {255, 103, 0}, {255, 102, 0},
{255, 101, 0}, {255, 100, 0}, {255, 99, 0}, {255, 98, 0},
{255, 97, 0}, {255, 96, 0}, {255, 95, 0}, {255, 94, 0},
{255, 93, 0}, {255, 92, 0}, {255, 91, 0}, {255, 91, 0},
{255, 90, 0}, {255, 90, 0}, {255, 89, 0}, {255, 88, 0},
{255, 88, 0}, {255, 87, 0}, {255, 86, 0}, {255, 86, 0},
{255, 85, 0}, {255, 84, 0}, {255, 83, 0}, {255, 82, 0},
{255, 81, 0}, {255, 80, 0}, {255, 79, 0}, {255, 78, 0},
{255, 77, 0}, {255, 76, 0}, {255, 75, 0}, {255, 74, 0},
{255, 73, 0}, {255, 72, 0}, {255, 71, 0}, {255, 70, 0},
{255, 69, 0}, {255, 68, 0}, {255, 67, 0}, {255, 66, 0},
{255, 65, 0}, {255, 64, 0}, {255, 63, 0}, {255, 62, 0},
{255, 61, 0}, {255, 60, 0}, {255, 59, 0}, {255, 58, 0},
{255, 57, 0}, {255, 56, 0}, {255, 55, 0}, {255, 54, 0},
{255, 54, 0}, {255, 53, 0}, {255, 51, 0}, {255, 50, 0},
{255, 49, 0}, {255, 48, 0}, {255, 47, 0}, {255, 46, 0},
{255, 45, 0}, {255, 44, 0}, {255, 43, 0}, {255, 42, 0},
{255, 41, 0}, {255, 40, 0}, {255, 39, 0}, {255, 38, 0},
{255, 37, 0}, {255, 36, 0}, {255, 35, 0}, {255, 34, 0},
{255, 33, 0}, {255, 32, 0}, {255, 31, 0}, {255, 30, 0},
{255, 29, 0}, {255, 28, 0}, {255, 27, 0}, {255, 26, 0},
{255, 25, 0}, {255, 24, 0}, {254, 23, 0}, {254, 22, 0},
{254, 21, 0}, {254, 20, 0}, {254, 19, 0}, {254, 18, 0},
{253, 17, 0}, {251, 16, 0}, {250, 15, 0}, {249, 14, 0},
{248, 13, 0}, {247, 12, 0}, {246, 11, 0}, {244, 10, 0},
{243, 9, 0}, {242, 8, 0}, {241, 7, 0}, {240, 6, 0},
{239, 6, 0}, {239, 5, 0}, {238, 4, 0}, {237, 4, 0},
{236, 3, 0}, {235, 3, 0}, {234, 2, 0}, {234, 1, 0},
{233, 1, 0}, {232, 0, 0}, {231, 0, 0}, {230, 0, 0},
{228, 0, 0}, {227, 0, 0}, {226, 0, 0}, {225, 0, 0},
{223, 0, 0}, {222, 0, 0}, {221, 0, 0}, {219, 0, 0},
{218, 0, 0}, {217, 0, 0}, {216, 0, 0}, {214, 0, 0},
{213, 0, 0}, {212, 0, 0}, {211, 0, 0}, {209, 0, 0},
{208, 0, 0}, {207, 0, 0}, {206, 0, 0}, {204, 0, 0},
{203, 0, 0}, {202, 0, 0}, {201, 0, 0}, {200, 0, 0},
{198, 0, 0}, {197, 0, 0}, {196, 0, 0}, {195, 0, 0},
{194, 0, 0}, {193, 0, 0}, {191, 0, 0}, {190, 0, 0},
{189, 0, 0}, {188, 0, 0}, {186, 0, 0}, {185, 0, 0},
{184, 0, 0}, {183, 0, 0}, {181, 0, 0}, {180, 0, 0},
{179, 0, 0}, {178, 0, 0}, {176, 0, 0}, {175, 0, 0},
{174, 0, 0}, {173, 0, 0}, {171, 0, 0}, {170, 0, 0},
{169, 0, 0}, {168, 0, 0}, {166, 0, 0}, {165, 0, 0},
{164, 0, 0}, {163, 0, 0}, {161, 0, 0}, {160, 0, 0},
{159, 0, 0}, {158, 0, 0}, {157, 0, 0}, {156, 0, 0},
{154, 0, 0}, {153, 0, 0}, {152, 0, 0}, {151, 0, 0},
{150, 0, 0}, {148, 0, 0}, {147, 0, 0}, {146, 0, 0},
{145, 0, 0}, {143, 0, 0}, {142, 0, 0}, {141, 0, 0},
{140, 0, 0}, {138, 0, 0}, {137, 0, 0}, {136, 0, 0},
{135, 0, 0}, {134, 0, 0}, {133, 0, 0}, {133, 0, 0},
{132, 0, 0}, {131, 0, 0}, {130, 0, 0}, {129, 0, 0},
{129, 0, 0}, {128, 0, 0}, {127, 0, 0}, {122, 0, 9},
{117, 0, 18}, {112, 0, 27}, {107, 0, 36}, {102, 0, 45}};
const rgb_store prism_colormap[1000] = {
{255, 0, 0}, {255, 2, 0}, {255, 4, 0}, {255, 6, 0}, {255, 8, 0},
{255, 10, 0}, {255, 11, 0}, {255, 13, 0}, {255, 15, 0}, {255, 17, 0},
{255, 19, 0}, {255, 21, 0}, {255, 23, 0}, {255, 25, 0}, {255, 27, 0},
{255, 29, 0}, {255, 31, 0}, {255, 33, 0}, {255, 34, 0}, {255, 36, 0},
{255, 38, 0}, {255, 40, 0}, {255, 42, 0}, {255, 44, 0}, {255, 46, 0},
{255, 48, 0}, {255, 50, 0}, {255, 52, 0}, {255, 54, 0}, {255, 56, 0},
{255, 57, 0}, {255, 59, 0}, {255, 61, 0}, {255, 63, 0}, {255, 65, 0},
{255, 67, 0}, {255, 69, 0}, {255, 71, 0}, {255, 73, 0}, {255, 75, 0},
{255, 77, 0}, {255, 78, 0}, {255, 80, 0}, {255, 82, 0}, {255, 84, 0},
{255, 86, 0}, {255, 88, 0}, {255, 90, 0}, {255, 92, 0}, {255, 94, 0},
{255, 96, 0}, {255, 98, 0}, {255, 100, 0}, {255, 101, 0}, {255, 103, 0},
{255, 105, 0}, {255, 107, 0}, {255, 109, 0}, {255, 111, 0}, {255, 113, 0},
{255, 115, 0}, {255, 117, 0}, {255, 119, 0}, {255, 121, 0}, {255, 123, 0},
{255, 124, 0}, {255, 126, 0}, {255, 128, 0}, {255, 130, 0}, {255, 132, 0},
{255, 134, 0}, {255, 136, 0}, {255, 138, 0}, {255, 140, 0}, {255, 142, 0},
{255, 144, 0}, {255, 145, 0}, {255, 147, 0}, {255, 149, 0}, {255, 151, 0},
{255, 153, 0}, {255, 155, 0}, {255, 157, 0}, {255, 159, 0}, {255, 161, 0},
{255, 163, 0}, {255, 165, 0}, {255, 167, 0}, {255, 168, 0}, {255, 170, 0},
{255, 172, 0}, {255, 174, 0}, {255, 176, 0}, {255, 178, 0}, {255, 180, 0},
{255, 182, 0}, {255, 184, 0}, {255, 186, 0}, {255, 188, 0}, {255, 190, 0},
{255, 191, 0}, {255, 193, 0}, {255, 195, 0}, {255, 197, 0}, {255, 199, 0},
{255, 201, 0}, {255, 203, 0}, {255, 205, 0}, {255, 207, 0}, {255, 209, 0},
{255, 211, 0}, {255, 212, 0}, {255, 214, 0}, {255, 216, 0}, {255, 218, 0},
{255, 220, 0}, {255, 222, 0}, {255, 224, 0}, {255, 226, 0}, {255, 228, 0},
{255, 230, 0}, {255, 232, 0}, {255, 234, 0}, {255, 235, 0}, {255, 237, 0},
{255, 239, 0}, {255, 241, 0}, {255, 243, 0}, {255, 245, 0}, {255, 247, 0},
{255, 249, 0}, {255, 251, 0}, {255, 253, 0}, {255, 255, 0}, {252, 255, 0},
{248, 255, 0}, {244, 255, 0}, {240, 255, 0}, {237, 255, 0}, {233, 255, 0},
{229, 255, 0}, {225, 255, 0}, {221, 255, 0}, {217, 255, 0}, {214, 255, 0},
{210, 255, 0}, {206, 255, 0}, {202, 255, 0}, {198, 255, 0}, {195, 255, 0},
{191, 255, 0}, {187, 255, 0}, {183, 255, 0}, {179, 255, 0}, {175, 255, 0},
{172, 255, 0}, {168, 255, 0}, {164, 255, 0}, {160, 255, 0}, {156, 255, 0},
{152, 255, 0}, {149, 255, 0}, {145, 255, 0}, {141, 255, 0}, {137, 255, 0},
{133, 255, 0}, {129, 255, 0}, {126, 255, 0}, {122, 255, 0}, {118, 255, 0},
{114, 255, 0}, {110, 255, 0}, {106, 255, 0}, {103, 255, 0}, {99, 255, 0},
{95, 255, 0}, {91, 255, 0}, {87, 255, 0}, {83, 255, 0}, {80, 255, 0},
{76, 255, 0}, {72, 255, 0}, {68, 255, 0}, {64, 255, 0}, {60, 255, 0},
{57, 255, 0}, {53, 255, 0}, {49, 255, 0}, {45, 255, 0}, {41, 255, 0},
{38, 255, 0}, {34, 255, 0}, {30, 255, 0}, {26, 255, 0}, {22, 255, 0},
{18, 255, 0}, {15, 255, 0}, {11, 255, 0}, {7, 255, 0}, {3, 255, 0},
{0, 254, 1}, {0, 250, 5}, {0, 247, 8}, {0, 243, 12}, {0, 239, 16},
{0, 235, 20}, {0, 231, 24}, {0, 227, 28}, {0, 224, 31}, {0, 220, 35},
{0, 216, 39}, {0, 212, 43}, {0, 208, 47}, {0, 204, 51}, {0, 201, 54},
{0, 197, 58}, {0, 193, 62}, {0, 189, 66}, {0, 185, 70}, {0, 181, 74},
{0, 178, 77}, {0, 174, 81}, {0, 170, 85}, {0, 166, 89}, {0, 162, 93},
{0, 159, 96}, {0, 155, 100}, {0, 151, 104}, {0, 147, 108}, {0, 143, 112},
{0, 139, 116}, {0, 136, 119}, {0, 132, 123}, {0, 128, 127}, {0, 124, 131},
{0, 120, 135}, {0, 116, 139}, {0, 113, 142}, {0, 109, 146}, {0, 105, 150},
{0, 101, 154}, {0, 97, 158}, {0, 93, 162}, {0, 90, 165}, {0, 86, 169},
{0, 82, 173}, {0, 78, 177}, {0, 74, 181}, {0, 70, 185}, {0, 67, 188},
{0, 63, 192}, {0, 59, 196}, {0, 55, 200}, {0, 51, 204}, {0, 47, 208},
{0, 44, 211}, {0, 40, 215}, {0, 36, 219}, {0, 32, 223}, {0, 28, 227},
{0, 25, 230}, {0, 21, 234}, {0, 17, 238}, {0, 13, 242}, {0, 9, 246},
{0, 5, 250}, {0, 2, 253}, {2, 0, 255}, {4, 0, 255}, {7, 0, 255},
{9, 0, 255}, {12, 0, 255}, {14, 0, 255}, {17, 0, 255}, {19, 0, 255},
{22, 0, 255}, {25, 0, 255}, {27, 0, 255}, {30, 0, 255}, {32, 0, 255},
{35, 0, 255}, {37, 0, 255}, {40, 0, 255}, {42, 0, 255}, {45, 0, 255},
{47, 0, 255}, {50, 0, 255}, {53, 0, 255}, {55, 0, 255}, {58, 0, 255},
{60, 0, 255}, {63, 0, 255}, {65, 0, 255}, {68, 0, 255}, {70, 0, 255},
{73, 0, 255}, {76, 0, 255}, {78, 0, 255}, {81, 0, 255}, {83, 0, 255},
{86, 0, 255}, {88, 0, 255}, {91, 0, 255}, {93, 0, 255}, {96, 0, 255},
{99, 0, 255}, {101, 0, 255}, {104, 0, 255}, {106, 0, 255}, {109, 0, 255},
{111, 0, 255}, {114, 0, 255}, {116, 0, 255}, {119, 0, 255}, {122, 0, 255},
{124, 0, 255}, {127, 0, 255}, {129, 0, 255}, {132, 0, 255}, {134, 0, 255},
{137, 0, 255}, {139, 0, 255}, {142, 0, 255}, {144, 0, 255}, {147, 0, 255},
{150, 0, 255}, {152, 0, 255}, {155, 0, 255}, {157, 0, 255}, {160, 0, 255},
{162, 0, 255}, {165, 0, 255}, {167, 0, 255}, {170, 0, 255}, {171, 0, 251},
{173, 0, 247}, {174, 0, 244}, {175, 0, 240}, {176, 0, 236}, {178, 0, 232},
{179, 0, 228}, {180, 0, 224}, {181, 0, 221}, {183, 0, 217}, {184, 0, 213},
{185, 0, 209}, {187, 0, 205}, {188, 0, 201}, {189, 0, 198}, {190, 0, 194},
{192, 0, 190}, {193, 0, 186}, {194, 0, 182}, {196, 0, 178}, {197, 0, 175},
{198, 0, 171}, {199, 0, 167}, {201, 0, 163}, {202, 0, 159}, {203, 0, 155},
{204, 0, 152}, {206, 0, 148}, {207, 0, 144}, {208, 0, 140}, {210, 0, 136},
{211, 0, 132}, {212, 0, 129}, {213, 0, 125}, {215, 0, 121}, {216, 0, 117},
{217, 0, 113}, {218, 0, 110}, {220, 0, 106}, {221, 0, 102}, {222, 0, 98},
{224, 0, 94}, {225, 0, 90}, {226, 0, 87}, {227, 0, 83}, {229, 0, 79},
{230, 0, 75}, {231, 0, 71}, {233, 0, 67}, {234, 0, 64}, {235, 0, 60},
{236, 0, 56}, {238, 0, 52}, {239, 0, 48}, {240, 0, 44}, {241, 0, 41},
{243, 0, 37}, {244, 0, 33}, {245, 0, 29}, {247, 0, 25}, {248, 0, 21},
{249, 0, 18}, {250, 0, 14}, {252, 0, 10}, {253, 0, 6}, {254, 0, 2},
{255, 1, 0}, {255, 3, 0}, {255, 5, 0}, {255, 7, 0}, {255, 8, 0},
{255, 10, 0}, {255, 12, 0}, {255, 14, 0}, {255, 16, 0}, {255, 18, 0},
{255, 20, 0}, {255, 22, 0}, {255, 24, 0}, {255, 26, 0}, {255, 28, 0},
{255, 29, 0}, {255, 31, 0}, {255, 33, 0}, {255, 35, 0}, {255, 37, 0},
{255, 39, 0}, {255, 41, 0}, {255, 43, 0}, {255, 45, 0}, {255, 47, 0},
{255, 49, 0}, {255, 51, 0}, {255, 52, 0}, {255, 54, 0}, {255, 56, 0},
{255, 58, 0}, {255, 60, 0}, {255, 62, 0}, {255, 64, 0}, {255, 66, 0},
{255, 68, 0}, {255, 70, 0}, {255, 72, 0}, {255, 74, 0}, {255, 75, 0},
{255, 77, 0}, {255, 79, 0}, {255, 81, 0}, {255, 83, 0}, {255, 85, 0},
{255, 87, 0}, {255, 89, 0}, {255, 91, 0}, {255, 93, 0}, {255, 95, 0},
{255, 96, 0}, {255, 98, 0}, {255, 100, 0}, {255, 102, 0}, {255, 104, 0},
{255, 106, 0}, {255, 108, 0}, {255, 110, 0}, {255, 112, 0}, {255, 114, 0},
{255, 116, 0}, {255, 118, 0}, {255, 119, 0}, {255, 121, 0}, {255, 123, 0},
{255, 125, 0}, {255, 127, 0}, {255, 129, 0}, {255, 131, 0}, {255, 133, 0},
{255, 135, 0}, {255, 137, 0}, {255, 139, 0}, {255, 141, 0}, {255, 142, 0},
{255, 144, 0}, {255, 146, 0}, {255, 148, 0}, {255, 150, 0}, {255, 152, 0},
{255, 154, 0}, {255, 156, 0}, {255, 158, 0}, {255, 160, 0}, {255, 162, 0},
{255, 163, 0}, {255, 165, 0}, {255, 167, 0}, {255, 169, 0}, {255, 171, 0},
{255, 173, 0}, {255, 175, 0}, {255, 177, 0}, {255, 179, 0}, {255, 181, 0},
{255, 183, 0}, {255, 185, 0}, {255, 186, 0}, {255, 188, 0}, {255, 190, 0},
{255, 192, 0}, {255, 194, 0}, {255, 196, 0}, {255, 198, 0}, {255, 200, 0},
{255, 202, 0}, {255, 204, 0}, {255, 206, 0}, {255, 208, 0}, {255, 209, 0},
{255, 211, 0}, {255, 213, 0}, {255, 215, 0}, {255, 217, 0}, {255, 219, 0},
{255, 221, 0}, {255, 223, 0}, {255, 225, 0}, {255, 227, 0}, {255, 229, 0},
{255, 230, 0}, {255, 232, 0}, {255, 234, 0}, {255, 236, 0}, {255, 238, 0},
{255, 240, 0}, {255, 242, 0}, {255, 244, 0}, {255, 246, 0}, {255, 248, 0},
{255, 250, 0}, {255, 252, 0}, {255, 253, 0}, {254, 255, 0}, {250, 255, 0},
{247, 255, 0}, {243, 255, 0}, {239, 255, 0}, {235, 255, 0}, {231, 255, 0},
{227, 255, 0}, {224, 255, 0}, {220, 255, 0}, {216, 255, 0}, {212, 255, 0},
{208, 255, 0}, {204, 255, 0}, {201, 255, 0}, {197, 255, 0}, {193, 255, 0},
{189, 255, 0}, {185, 255, 0}, {181, 255, 0}, {178, 255, 0}, {174, 255, 0},
{170, 255, 0}, {166, 255, 0}, {162, 255, 0}, {159, 255, 0}, {155, 255, 0},
{151, 255, 0}, {147, 255, 0}, {143, 255, 0}, {139, 255, 0}, {136, 255, 0},
{132, 255, 0}, {128, 255, 0}, {124, 255, 0}, {120, 255, 0}, {116, 255, 0},
{113, 255, 0}, {109, 255, 0}, {105, 255, 0}, {101, 255, 0}, {97, 255, 0},
{93, 255, 0}, {90, 255, 0}, {86, 255, 0}, {82, 255, 0}, {78, 255, 0},
{74, 255, 0}, {70, 255, 0}, {67, 255, 0}, {63, 255, 0}, {59, 255, 0},
{55, 255, 0}, {51, 255, 0}, {47, 255, 0}, {44, 255, 0}, {40, 255, 0},
{36, 255, 0}, {32, 255, 0}, {28, 255, 0}, {25, 255, 0}, {21, 255, 0},
{17, 255, 0}, {13, 255, 0}, {9, 255, 0}, {5, 255, 0}, {2, 255, 0},
{0, 253, 2}, {0, 249, 6}, {0, 245, 10}, {0, 241, 14}, {0, 237, 18},
{0, 234, 21}, {0, 230, 25}, {0, 226, 29}, {0, 222, 33}, {0, 218, 37},
{0, 214, 41}, {0, 211, 44}, {0, 207, 48}, {0, 203, 52}, {0, 199, 56},
{0, 195, 60}, {0, 191, 64}, {0, 188, 67}, {0, 184, 71}, {0, 180, 75},
{0, 176, 79}, {0, 172, 83}, {0, 168, 87}, {0, 165, 90}, {0, 161, 94},
{0, 157, 98}, {0, 153, 102}, {0, 149, 106}, {0, 145, 110}, {0, 142, 113},
{0, 138, 117}, {0, 134, 121}, {0, 130, 125}, {0, 126, 129}, {0, 123, 132},
{0, 119, 136}, {0, 115, 140}, {0, 111, 144}, {0, 107, 148}, {0, 103, 152},
{0, 100, 155}, {0, 96, 159}, {0, 92, 163}, {0, 88, 167}, {0, 84, 171},
{0, 80, 175}, {0, 77, 178}, {0, 73, 182}, {0, 69, 186}, {0, 65, 190},
{0, 61, 194}, {0, 57, 198}, {0, 54, 201}, {0, 50, 205}, {0, 46, 209},
{0, 42, 213}, {0, 38, 217}, {0, 34, 221}, {0, 31, 224}, {0, 27, 228},
{0, 23, 232}, {0, 19, 236}, {0, 15, 240}, {0, 11, 244}, {0, 8, 247},
{0, 4, 251}, {0, 0, 255}, {3, 0, 255}, {5, 0, 255}, {8, 0, 255},
{10, 0, 255}, {13, 0, 255}, {15, 0, 255}, {18, 0, 255}, {20, 0, 255},
{23, 0, 255}, {26, 0, 255}, {28, 0, 255}, {31, 0, 255}, {33, 0, 255},
{36, 0, 255}, {38, 0, 255}, {41, 0, 255}, {43, 0, 255}, {46, 0, 255},
{48, 0, 255}, {51, 0, 255}, {54, 0, 255}, {56, 0, 255}, {59, 0, 255},
{61, 0, 255}, {64, 0, 255}, {66, 0, 255}, {69, 0, 255}, {71, 0, 255},
{74, 0, 255}, {77, 0, 255}, {79, 0, 255}, {82, 0, 255}, {84, 0, 255},
{87, 0, 255}, {89, 0, 255}, {92, 0, 255}, {94, 0, 255}, {97, 0, 255},
{100, 0, 255}, {102, 0, 255}, {105, 0, 255}, {107, 0, 255}, {110, 0, 255},
{112, 0, 255}, {115, 0, 255}, {117, 0, 255}, {120, 0, 255}, {123, 0, 255},
{125, 0, 255}, {128, 0, 255}, {130, 0, 255}, {133, 0, 255}, {135, 0, 255},
{138, 0, 255}, {140, 0, 255}, {143, 0, 255}, {145, 0, 255}, {148, 0, 255},
{151, 0, 255}, {153, 0, 255}, {156, 0, 255}, {158, 0, 255}, {161, 0, 255},
{163, 0, 255}, {166, 0, 255}, {168, 0, 255}, {171, 0, 253}, {172, 0, 250},
{173, 0, 246}, {174, 0, 242}, {176, 0, 238}, {177, 0, 234}, {178, 0, 230},
{179, 0, 227}, {181, 0, 223}, {182, 0, 219}, {183, 0, 215}, {185, 0, 211},
{186, 0, 208}, {187, 0, 204}, {188, 0, 200}, {190, 0, 196}, {191, 0, 192},
{192, 0, 188}, {193, 0, 185}, {195, 0, 181}, {196, 0, 177}, {197, 0, 173},
{199, 0, 169}, {200, 0, 165}, {201, 0, 162}, {202, 0, 158}, {204, 0, 154},
{205, 0, 150}, {206, 0, 146}, {208, 0, 142}, {209, 0, 139}, {210, 0, 135},
{211, 0, 131}, {213, 0, 127}, {214, 0, 123}, {215, 0, 119}, {216, 0, 116},
{218, 0, 112}, {219, 0, 108}, {220, 0, 104}, {222, 0, 100}, {223, 0, 96},
{224, 0, 93}, {225, 0, 89}, {227, 0, 85}, {228, 0, 81}, {229, 0, 77},
{230, 0, 74}, {232, 0, 70}, {233, 0, 66}, {234, 0, 62}, {236, 0, 58},
{237, 0, 54}, {238, 0, 51}, {239, 0, 47}, {241, 0, 43}, {242, 0, 39},
{243, 0, 35}, {245, 0, 31}, {246, 0, 28}, {247, 0, 24}, {248, 0, 20},
{250, 0, 16}, {251, 0, 12}, {252, 0, 8}, {253, 0, 5}, {255, 0, 1},
{255, 2, 0}, {255, 3, 0}, {255, 5, 0}, {255, 7, 0}, {255, 9, 0},
{255, 11, 0}, {255, 13, 0}, {255, 15, 0}, {255, 17, 0}, {255, 19, 0},
{255, 21, 0}, {255, 23, 0}, {255, 25, 0}, {255, 26, 0}, {255, 28, 0},
{255, 30, 0}, {255, 32, 0}, {255, 34, 0}, {255, 36, 0}, {255, 38, 0},
{255, 40, 0}, {255, 42, 0}, {255, 44, 0}, {255, 46, 0}, {255, 47, 0},
{255, 49, 0}, {255, 51, 0}, {255, 53, 0}, {255, 55, 0}, {255, 57, 0},
{255, 59, 0}, {255, 61, 0}, {255, 63, 0}, {255, 65, 0}, {255, 67, 0},
{255, 69, 0}, {255, 70, 0}, {255, 72, 0}, {255, 74, 0}, {255, 76, 0},
{255, 78, 0}, {255, 80, 0}, {255, 82, 0}, {255, 84, 0}, {255, 86, 0},
{255, 88, 0}, {255, 90, 0}, {255, 92, 0}, {255, 93, 0}, {255, 95, 0},
{255, 97, 0}, {255, 99, 0}, {255, 101, 0}, {255, 103, 0}, {255, 105, 0},
{255, 107, 0}, {255, 109, 0}, {255, 111, 0}, {255, 113, 0}, {255, 114, 0},
{255, 116, 0}, {255, 118, 0}, {255, 120, 0}, {255, 122, 0}, {255, 124, 0},
{255, 126, 0}, {255, 128, 0}, {255, 130, 0}, {255, 132, 0}, {255, 134, 0},
{255, 136, 0}, {255, 137, 0}, {255, 139, 0}, {255, 141, 0}, {255, 143, 0},
{255, 145, 0}, {255, 147, 0}, {255, 149, 0}, {255, 151, 0}, {255, 153, 0},
{255, 155, 0}, {255, 157, 0}, {255, 159, 0}, {255, 160, 0}, {255, 162, 0},
{255, 164, 0}, {255, 166, 0}, {255, 168, 0}, {255, 170, 0}, {255, 172, 0},
{255, 174, 0}, {255, 176, 0}, {255, 178, 0}, {255, 180, 0}, {255, 181, 0},
{255, 183, 0}, {255, 185, 0}, {255, 187, 0}, {255, 189, 0}, {255, 191, 0},
{255, 193, 0}, {255, 195, 0}, {255, 197, 0}, {255, 199, 0}, {255, 201, 0},
{255, 203, 0}, {255, 204, 0}, {255, 206, 0}, {255, 208, 0}, {255, 210, 0},
{255, 212, 0}, {255, 214, 0}, {255, 216, 0}, {255, 218, 0}, {255, 220, 0},
{255, 222, 0}, {255, 224, 0}, {255, 226, 0}, {255, 227, 0}, {255, 229, 0},
{255, 231, 0}, {255, 233, 0}, {255, 235, 0}, {255, 237, 0}, {255, 239, 0},
{255, 241, 0}, {255, 243, 0}, {255, 245, 0}, {255, 247, 0}, {255, 248, 0},
{255, 250, 0}, {255, 252, 0}, {255, 254, 0}, {253, 255, 0}, {249, 255, 0},
{245, 255, 0}, {241, 255, 0}, {237, 255, 0}, {234, 255, 0}, {230, 255, 0},
{226, 255, 0}, {222, 255, 0}, {218, 255, 0}, {214, 255, 0}, {211, 255, 0},
{207, 255, 0}, {203, 255, 0}, {199, 255, 0}, {195, 255, 0}, {191, 255, 0},
{188, 255, 0}, {184, 255, 0}, {180, 255, 0}, {176, 255, 0}, {172, 255, 0},
{168, 255, 0}, {165, 255, 0}, {161, 255, 0}, {157, 255, 0}, {153, 255, 0},
{149, 255, 0}, {145, 255, 0}, {142, 255, 0}, {138, 255, 0}, {134, 255, 0},
{130, 255, 0}, {126, 255, 0}, {123, 255, 0}, {119, 255, 0}, {115, 255, 0},
{111, 255, 0}, {107, 255, 0}, {103, 255, 0}, {100, 255, 0}, {96, 255, 0},
{92, 255, 0}, {88, 255, 0}, {84, 255, 0}, {80, 255, 0}, {77, 255, 0},
{73, 255, 0}, {69, 255, 0}, {65, 255, 0}, {61, 255, 0}, {57, 255, 0},
{54, 255, 0}, {50, 255, 0}, {46, 255, 0}, {42, 255, 0}, {38, 255, 0},
{34, 255, 0}, {31, 255, 0}, {27, 255, 0}, {23, 255, 0}, {19, 255, 0},
{15, 255, 0}, {11, 255, 0}, {8, 255, 0}, {4, 255, 0}, {0, 255, 0}};
const rgb_store vga_colormap[1000] = {
{255}, {254, 254, 254}, {253, 253, 253}, {252, 252, 252},
{251, 251, 251}, {250, 250, 250}, {249, 249, 249}, {248, 248, 248},
{247, 247, 247}, {246, 246, 246}, {245, 245, 245}, {244, 244, 244},
{244, 244, 244}, {243, 243, 243}, {242, 242, 242}, {241, 241, 241},
{240, 240, 240}, {239, 239, 239}, {238, 238, 238}, {237, 237, 237},
{236, 236, 236}, {235, 235, 235}, {234, 234, 234}, {233, 233, 233},
{232, 232, 232}, {231, 231, 231}, {230, 230, 230}, {229, 229, 229},
{228, 228, 228}, {227, 227, 227}, {226, 226, 226}, {225, 225, 225},
{224, 224, 224}, {223, 223, 223}, {222, 222, 222}, {221, 221, 221},
{221, 221, 221}, {220, 220, 220}, {219, 219, 219}, {218, 218, 218},
{217, 217, 217}, {216, 216, 216}, {215, 215, 215}, {214, 214, 214},
{213, 213, 213}, {212, 212, 212}, {211, 211, 211}, {210, 210, 210},
{209, 209, 209}, {208, 208, 208}, {207, 207, 207}, {206, 206, 206},
{205, 205, 205}, {204, 204, 204}, {203, 203, 203}, {202, 202, 202},
{201, 201, 201}, {200, 200, 200}, {199, 199, 199}, {199, 199, 199},
{198, 198, 198}, {197, 197, 197}, {196, 196, 196}, {195, 195, 195},
{194, 194, 194}, {193, 193, 193}, {192, 192, 192}, {192, 190, 190},
{193, 187, 187}, {194, 184, 184}, {195, 181, 181}, {195, 179, 179},
{196, 176, 176}, {197, 173, 173}, {198, 170, 170}, {199, 167, 167},
{200, 164, 164}, {201, 161, 161}, {202, 159, 159}, {203, 156, 156},
{204, 153, 153}, {205, 150, 150}, {206, 147, 147}, {207, 144, 144},
{208, 141, 141}, {209, 138, 138}, {210, 136, 136}, {211, 133, 133},
{212, 130, 130}, {213, 127, 127}, {214, 124, 124}, {215, 121, 121},
{216, 118, 118}, {217, 115, 115}, {217, 113, 113}, {218, 110, 110},
{219, 107, 107}, {220, 104, 104}, {221, 101, 101}, {222, 98, 98},
{223, 95, 95}, {224, 92, 92}, {225, 90, 90}, {226, 87, 87},
{227, 84, 84}, {228, 81, 81}, {229, 78, 78}, {230, 75, 75},
{231, 72, 72}, {232, 69, 69}, {233, 67, 67}, {234, 64, 64},
{235, 61, 61}, {236, 58, 58}, {237, 55, 55}, {238, 52, 52},
{239, 49, 49}, {239, 47, 47}, {240, 44, 44}, {241, 41, 41},
{242, 38, 38}, {243, 35, 35}, {244, 32, 32}, {245, 29, 29},
{246, 26, 26}, {247, 24, 24}, {248, 21, 21}, {249, 18, 18},
{250, 15, 15}, {251, 12, 12}, {252, 9, 9}, {253, 6, 6},
{254, 3, 3}, {255, 1, 1}, {255, 3, 0}, {255, 7, 0},
{255, 11, 0}, {255, 15, 0}, {255, 18, 0}, {255, 22, 0},
{255, 26, 0}, {255, 30, 0}, {255, 34, 0}, {255, 38, 0},
{255, 41, 0}, {255, 45, 0}, {255, 49, 0}, {255, 53, 0},
{255, 57, 0}, {255, 60, 0}, {255, 64, 0}, {255, 68, 0},
{255, 72, 0}, {255, 76, 0}, {255, 80, 0}, {255, 83, 0},
{255, 87, 0}, {255, 91, 0}, {255, 95, 0}, {255, 99, 0},
{255, 103, 0}, {255, 106, 0}, {255, 110, 0}, {255, 114, 0},
{255, 118, 0}, {255, 122, 0}, {255, 126, 0}, {255, 129, 0},
{255, 133, 0}, {255, 137, 0}, {255, 141, 0}, {255, 145, 0},
{255, 149, 0}, {255, 152, 0}, {255, 156, 0}, {255, 160, 0},
{255, 164, 0}, {255, 168, 0}, {255, 172, 0}, {255, 175, 0},
{255, 179, 0}, {255, 183, 0}, {255, 187, 0}, {255, 191, 0},
{255, 195, 0}, {255, 198, 0}, {255, 202, 0}, {255, 206, 0},
{255, 210, 0}, {255, 214, 0}, {255, 217, 0}, {255, 221, 0},
{255, 225, 0}, {255, 229, 0}, {255, 233, 0}, {255, 237, 0},
{255, 240, 0}, {255, 244, 0}, {255, 248, 0}, {255, 252, 0},
{254, 255, 0}, {250, 255, 0}, {247, 255, 0}, {243, 255, 0},
{239, 255, 0}, {235, 255, 0}, {231, 255, 0}, {227, 255, 0},
{224, 255, 0}, {220, 255, 0}, {216, 255, 0}, {212, 255, 0},
{208, 255, 0}, {204, 255, 0}, {201, 255, 0}, {197, 255, 0},
{193, 255, 0}, {189, 255, 0}, {185, 255, 0}, {181, 255, 0},
{178, 255, 0}, {174, 255, 0}, {170, 255, 0}, {166, 255, 0},
{162, 255, 0}, {159, 255, 0}, {155, 255, 0}, {151, 255, 0},
{147, 255, 0}, {143, 255, 0}, {139, 255, 0}, {136, 255, 0},
{132, 255, 0}, {128, 255, 0}, {124, 255, 0}, {120, 255, 0},
{116, 255, 0}, {113, 255, 0}, {109, 255, 0}, {105, 255, 0},
{101, 255, 0}, {97, 255, 0}, {93, 255, 0}, {90, 255, 0},
{86, 255, 0}, {82, 255, 0}, {78, 255, 0}, {74, 255, 0},
{70, 255, 0}, {67, 255, 0}, {63, 255, 0}, {59, 255, 0},
{55, 255, 0}, {51, 255, 0}, {47, 255, 0}, {44, 255, 0},
{40, 255, 0}, {36, 255, 0}, {32, 255, 0}, {28, 255, 0},
{25, 255, 0}, {21, 255, 0}, {17, 255, 0}, {13, 255, 0},
{9, 255, 0}, {5, 255, 0}, {2, 255, 0}, {0, 255, 2},
{0, 255, 6}, {0, 255, 10}, {0, 255, 14}, {0, 255, 18},
{0, 255, 21}, {0, 255, 25}, {0, 255, 29}, {0, 255, 33},
{0, 255, 37}, {0, 255, 41}, {0, 255, 44}, {0, 255, 48},
{0, 255, 52}, {0, 255, 56}, {0, 255, 60}, {0, 255, 64},
{0, 255, 67}, {0, 255, 71}, {0, 255, 75}, {0, 255, 79},
{0, 255, 83}, {0, 255, 87}, {0, 255, 90}, {0, 255, 94},
{0, 255, 98}, {0, 255, 102}, {0, 255, 106}, {0, 255, 110},
{0, 255, 113}, {0, 255, 117}, {0, 255, 121}, {0, 255, 125},
{0, 255, 129}, {0, 255, 132}, {0, 255, 136}, {0, 255, 140},
{0, 255, 144}, {0, 255, 148}, {0, 255, 152}, {0, 255, 155},
{0, 255, 159}, {0, 255, 163}, {0, 255, 167}, {0, 255, 171},
{0, 255, 175}, {0, 255, 178}, {0, 255, 182}, {0, 255, 186},
{0, 255, 190}, {0, 255, 194}, {0, 255, 198}, {0, 255, 201},
{0, 255, 205}, {0, 255, 209}, {0, 255, 213}, {0, 255, 217},
{0, 255, 221}, {0, 255, 224}, {0, 255, 228}, {0, 255, 232},
{0, 255, 236}, {0, 255, 240}, {0, 255, 244}, {0, 255, 247},
{0, 255, 251}, {0, 255, 255}, {0, 251, 255}, {0, 247, 255},
{0, 244, 255}, {0, 240, 255}, {0, 236, 255}, {0, 232, 255},
{0, 228, 255}, {0, 224, 255}, {0, 221, 255}, {0, 217, 255},
{0, 213, 255}, {0, 209, 255}, {0, 205, 255}, {0, 201, 255},
{0, 198, 255}, {0, 194, 255}, {0, 190, 255}, {0, 186, 255},
{0, 182, 255}, {0, 178, 255}, {0, 175, 255}, {0, 171, 255},
{0, 167, 255}, {0, 163, 255}, {0, 159, 255}, {0, 155, 255},
{0, 152, 255}, {0, 148, 255}, {0, 144, 255}, {0, 140, 255},
{0, 136, 255}, {0, 132, 255}, {0, 129, 255}, {0, 125, 255},
{0, 121, 255}, {0, 117, 255}, {0, 113, 255}, {0, 110, 255},
{0, 106, 255}, {0, 102, 255}, {0, 98, 255}, {0, 94, 255},
{0, 90, 255}, {0, 87, 255}, {0, 83, 255}, {0, 79, 255},
{0, 75, 255}, {0, 71, 255}, {0, 67, 255}, {0, 64, 255},
{0, 60, 255}, {0, 56, 255}, {0, 52, 255}, {0, 48, 255},
{0, 44, 255}, {0, 41, 255}, {0, 37, 255}, {0, 33, 255},
{0, 29, 255}, {0, 25, 255}, {0, 21, 255}, {0, 18, 255},
{0, 14, 255}, {0, 10, 255}, {0, 6, 255}, {0, 2, 255},
{2, 0, 255}, {5, 0, 255}, {9, 0, 255}, {13, 0, 255},
{17, 0, 255}, {21, 0, 255}, {25, 0, 255}, {28, 0, 255},
{32, 0, 255}, {36, 0, 255}, {40, 0, 255}, {44, 0, 255},
{47, 0, 255}, {51, 0, 255}, {55, 0, 255}, {59, 0, 255},
{63, 0, 255}, {67, 0, 255}, {70, 0, 255}, {74, 0, 255},
{78, 0, 255}, {82, 0, 255}, {86, 0, 255}, {90, 0, 255},
{93, 0, 255}, {97, 0, 255}, {101, 0, 255}, {105, 0, 255},
{109, 0, 255}, {113, 0, 255}, {116, 0, 255}, {120, 0, 255},
{124, 0, 255}, {128, 0, 255}, {132, 0, 255}, {136, 0, 255},
{139, 0, 255}, {143, 0, 255}, {147, 0, 255}, {151, 0, 255},
{155, 0, 255}, {159, 0, 255}, {162, 0, 255}, {166, 0, 255},
{170, 0, 255}, {174, 0, 255}, {178, 0, 255}, {181, 0, 255},
{185, 0, 255}, {189, 0, 255}, {193, 0, 255}, {197, 0, 255},
{201, 0, 255}, {204, 0, 255}, {208, 0, 255}, {212, 0, 255},
{216, 0, 255}, {220, 0, 255}, {224, 0, 255}, {227, 0, 255},
{231, 0, 255}, {235, 0, 255}, {239, 0, 255}, {243, 0, 255},
{247, 0, 255}, {250, 0, 255}, {254, 0, 255}, {252, 0, 252},
{248, 0, 248}, {244, 0, 244}, {240, 0, 240}, {237, 0, 237},
{233, 0, 233}, {229, 0, 229}, {225, 0, 225}, {221, 0, 221},
{217, 0, 217}, {214, 0, 214}, {210, 0, 210}, {206, 0, 206},
{202, 0, 202}, {198, 0, 198}, {195, 0, 195}, {191, 0, 191},
{187, 0, 187}, {183, 0, 183}, {179, 0, 179}, {175, 0, 175},
{172, 0, 172}, {168, 0, 168}, {164, 0, 164}, {160, 0, 160},
{156, 0, 156}, {152, 0, 152}, {149, 0, 149}, {145, 0, 145},
{141, 0, 141}, {137, 0, 137}, {133, 0, 133}, {129, 0, 129},
{126, 0, 126}, {122, 0, 122}, {118, 0, 118}, {114, 0, 114},
{110, 0, 110}, {106, 0, 106}, {103, 0, 103}, {99, 0, 99},
{95, 0, 95}, {91, 0, 91}, {87, 0, 87}, {83, 0, 83},
{80, 0, 80}, {76, 0, 76}, {72, 0, 72}, {68, 0, 68},
{64, 0, 64}, {60, 0, 60}, {57, 0, 57}, {53, 0, 53},
{49, 0, 49}, {45, 0, 45}, {41, 0, 41}, {38, 0, 38},
{34, 0, 34}, {30, 0, 30}, {26, 0, 26}, {22, 0, 22},
{18, 0, 18}, {15, 0, 15}, {11, 0, 11}, {7, 0, 7},
{3, 0, 3}, {0, 0, 0}, {2, 2, 2}, {4, 4, 4},
{6, 6, 6}, {8, 8, 8}, {10, 10, 10}, {12, 12, 12},
{14, 14, 14}, {16, 16, 16}, {18, 18, 18}, {20, 20, 20},
{21, 21, 21}, {23, 23, 23}, {25, 25, 25}, {27, 27, 27},
{29, 29, 29}, {31, 31, 31}, {33, 33, 33}, {35, 35, 35},
{37, 37, 37}, {39, 39, 39}, {41, 41, 41}, {43, 43, 43},
{44, 44, 44}, {46, 46, 46}, {48, 48, 48}, {50, 50, 50},
{52, 52, 52}, {54, 54, 54}, {56, 56, 56}, {58, 58, 58},
{60, 60, 60}, {62, 62, 62}, {64, 64, 64}, {65, 65, 65},
{67, 67, 67}, {69, 69, 69}, {71, 71, 71}, {73, 73, 73},
{75, 75, 75}, {77, 77, 77}, {79, 79, 79}, {81, 81, 81},
{83, 83, 83}, {85, 85, 85}, {87, 87, 87}, {88, 88, 88},
{90, 90, 90}, {92, 92, 92}, {94, 94, 94}, {96, 96, 96},
{98, 98, 98}, {100, 100, 100}, {102, 102, 102}, {104, 104, 104},
{106, 106, 106}, {108, 108, 108}, {110, 110, 110}, {111, 111, 111},
{113, 113, 113}, {115, 115, 115}, {117, 117, 117}, {119, 119, 119},
{121, 121, 121}, {123, 123, 123}, {125, 125, 125}, {127, 127, 127},
{128, 126, 126}, {128, 124, 124}, {128, 123, 123}, {128, 121, 121},
{128, 119, 119}, {128, 117, 117}, {128, 115, 115}, {128, 113, 113},
{128, 111, 111}, {128, 109, 109}, {128, 107, 107}, {128, 105, 105},
{128, 103, 103}, {128, 101, 101}, {128, 100, 100}, {128, 98, 98},
{128, 96, 96}, {128, 94, 94}, {128, 92, 92}, {128, 90, 90},
{128, 88, 88}, {128, 86, 86}, {128, 84, 84}, {128, 82, 82},
{128, 80, 80}, {128, 78, 78}, {128, 77, 77}, {128, 75, 75},
{128, 73, 73}, {128, 71, 71}, {128, 69, 69}, {128, 67, 67},
{128, 65, 65}, {128, 63, 63}, {128, 61, 61}, {128, 59, 59},
{128, 57, 57}, {128, 56, 56}, {128, 54, 54}, {128, 52, 52},
{128, 50, 50}, {128, 48, 48}, {128, 46, 46}, {128, 44, 44},
{128, 42, 42}, {128, 40, 40}, {128, 38, 38}, {128, 36, 36},
{128, 34, 34}, {128, 33, 33}, {128, 31, 31}, {128, 29, 29},
{128, 27, 27}, {128, 25, 25}, {128, 23, 23}, {128, 21, 21},
{128, 19, 19}, {128, 17, 17}, {128, 15, 15}, {128, 13, 13},
{128, 11, 11}, {128, 10, 10}, {128, 8, 8}, {128, 6, 6},
{128, 4, 4}, {128, 2, 2}, {128, 0, 0}, {128, 2, 0},
{128, 4, 0}, {128, 6, 0}, {128, 8, 0}, {128, 10, 0},
{128, 11, 0}, {128, 13, 0}, {128, 15, 0}, {128, 17, 0},
{128, 19, 0}, {128, 21, 0}, {128, 23, 0}, {128, 25, 0},
{128, 27, 0}, {128, 29, 0}, {128, 31, 0}, {128, 33, 0},
{128, 34, 0}, {128, 36, 0}, {128, 38, 0}, {128, 40, 0},
{128, 42, 0}, {128, 44, 0}, {128, 46, 0}, {128, 48, 0},
{128, 50, 0}, {128, 52, 0}, {128, 54, 0}, {128, 56, 0},
{128, 57, 0}, {128, 59, 0}, {128, 61, 0}, {128, 63, 0},
{128, 65, 0}, {128, 67, 0}, {128, 69, 0}, {128, 71, 0},
{128, 73, 0}, {128, 75, 0}, {128, 77, 0}, {128, 78, 0},
{128, 80, 0}, {128, 82, 0}, {128, 84, 0}, {128, 86, 0},
{128, 88, 0}, {128, 90, 0}, {128, 92, 0}, {128, 94, 0},
{128, 96, 0}, {128, 98, 0}, {128, 100, 0}, {128, 101, 0},
{128, 103, 0}, {128, 105, 0}, {128, 107, 0}, {128, 109, 0},
{128, 111, 0}, {128, 113, 0}, {128, 115, 0}, {128, 117, 0},
{128, 119, 0}, {128, 121, 0}, {128, 123, 0}, {128, 124, 0},
{128, 126, 0}, {127, 128, 0}, {125, 128, 0}, {123, 128, 0},
{121, 128, 0}, {119, 128, 0}, {117, 128, 0}, {115, 128, 0},
{113, 128, 0}, {111, 128, 0}, {110, 128, 0}, {108, 128, 0},
{106, 128, 0}, {104, 128, 0}, {102, 128, 0}, {100, 128, 0},
{98, 128, 0}, {96, 128, 0}, {94, 128, 0}, {92, 128, 0},
{90, 128, 0}, {88, 128, 0}, {87, 128, 0}, {85, 128, 0},
{83, 128, 0}, {81, 128, 0}, {79, 128, 0}, {77, 128, 0},
{75, 128, 0}, {73, 128, 0}, {71, 128, 0}, {69, 128, 0},
{67, 128, 0}, {65, 128, 0}, {64, 128, 0}, {62, 128, 0},
{60, 128, 0}, {58, 128, 0}, {56, 128, 0}, {54, 128, 0},
{52, 128, 0}, {50, 128, 0}, {48, 128, 0}, {46, 128, 0},
{44, 128, 0}, {43, 128, 0}, {41, 128, 0}, {39, 128, 0},
{37, 128, 0}, {35, 128, 0}, {33, 128, 0}, {31, 128, 0},
{29, 128, 0}, {27, 128, 0}, {25, 128, 0}, {23, 128, 0},
{21, 128, 0}, {20, 128, 0}, {18, 128, 0}, {16, 128, 0},
{14, 128, 0}, {12, 128, 0}, {10, 128, 0}, {8, 128, 0},
{6, 128, 0}, {4, 128, 0}, {2, 128, 0}, {0, 128, 0},
{0, 128, 2}, {0, 128, 3}, {0, 128, 5}, {0, 128, 7},
{0, 128, 9}, {0, 128, 11}, {0, 128, 13}, {0, 128, 15},
{0, 128, 17}, {0, 128, 19}, {0, 128, 21}, {0, 128, 23},
{0, 128, 25}, {0, 128, 26}, {0, 128, 28}, {0, 128, 30},
{0, 128, 32}, {0, 128, 34}, {0, 128, 36}, {0, 128, 38},
{0, 128, 40}, {0, 128, 42}, {0, 128, 44}, {0, 128, 46},
{0, 128, 47}, {0, 128, 49}, {0, 128, 51}, {0, 128, 53},
{0, 128, 55}, {0, 128, 57}, {0, 128, 59}, {0, 128, 61},
{0, 128, 63}, {0, 128, 65}, {0, 128, 67}, {0, 128, 69},
{0, 128, 70}, {0, 128, 72}, {0, 128, 74}, {0, 128, 76},
{0, 128, 78}, {0, 128, 80}, {0, 128, 82}, {0, 128, 84},
{0, 128, 86}, {0, 128, 88}, {0, 128, 90}, {0, 128, 92},
{0, 128, 93}, {0, 128, 95}, {0, 128, 97}, {0, 128, 99},
{0, 128, 101}, {0, 128, 103}, {0, 128, 105}, {0, 128, 107},
{0, 128, 109}, {0, 128, 111}, {0, 128, 113}, {0, 128, 114},
{0, 128, 116}, {0, 128, 118}, {0, 128, 120}, {0, 128, 122},
{0, 128, 124}, {0, 128, 126}, {0, 127, 128}, {0, 125, 128},
{0, 123, 128}, {0, 121, 128}, {0, 119, 128}, {0, 118, 128},
{0, 116, 128}, {0, 114, 128}, {0, 112, 128}, {0, 110, 128},
{0, 108, 128}, {0, 106, 128}, {0, 104, 128}, {0, 102, 128},
{0, 100, 128}, {0, 98, 128}, {0, 96, 128}, {0, 95, 128},
{0, 93, 128}, {0, 91, 128}, {0, 89, 128}, {0, 87, 128},
{0, 85, 128}, {0, 83, 128}, {0, 81, 128}, {0, 79, 128},
{0, 77, 128}, {0, 75, 128}, {0, 74, 128}, {0, 72, 128},
{0, 70, 128}, {0, 68, 128}, {0, 66, 128}, {0, 64, 128},
{0, 62, 128}, {0, 60, 128}, {0, 58, 128}, {0, 56, 128},
{0, 54, 128}, {0, 52, 128}, {0, 51, 128}, {0, 49, 128},
{0, 47, 128}, {0, 45, 128}, {0, 43, 128}, {0, 41, 128},
{0, 39, 128}, {0, 37, 128}, {0, 35, 128}, {0, 33, 128},
{0, 31, 128}, {0, 29, 128}, {0, 28, 128}, {0, 26, 128},
{0, 24, 128}, {0, 22, 128}, {0, 20, 128}, {0, 18, 128},
{0, 16, 128}, {0, 14, 128}, {0, 12, 128}, {0, 10, 128},
{0, 8, 128}, {0, 7, 128}, {0, 5, 128}, {0, 3, 128},
{0, 1, 128}, {1, 0, 128}, {3, 0, 128}, {5, 0, 128},
{7, 0, 128}, {9, 0, 128}, {11, 0, 128}, {13, 0, 128},
{15, 0, 128}, {16, 0, 128}, {18, 0, 128}, {20, 0, 128},
{22, 0, 128}, {24, 0, 128}, {26, 0, 128}, {28, 0, 128},
{30, 0, 128}, {32, 0, 128}, {34, 0, 128}, {36, 0, 128},
{38, 0, 128}, {39, 0, 128}, {41, 0, 128}, {43, 0, 128},
{45, 0, 128}, {47, 0, 128}, {49, 0, 128}, {51, 0, 128},
{53, 0, 128}, {55, 0, 128}, {57, 0, 128}, {59, 0, 128},
{60, 0, 128}, {62, 0, 128}, {64, 0, 128}, {66, 0, 128},
{68, 0, 128}, {70, 0, 128}, {72, 0, 128}, {74, 0, 128},
{76, 0, 128}, {78, 0, 128}, {80, 0, 128}, {82, 0, 128},
{83, 0, 128}, {85, 0, 128}, {87, 0, 128}, {89, 0, 128},
{91, 0, 128}, {93, 0, 128}, {95, 0, 128}, {97, 0, 128},
{99, 0, 128}, {101, 0, 128}, {103, 0, 128}, {105, 0, 128},
{106, 0, 128}, {108, 0, 128}, {110, 0, 128}, {112, 0, 128},
{114, 0, 128}, {116, 0, 128}, {118, 0, 128}, {120, 0, 128},
{122, 0, 128}, {124, 0, 128}, {126, 0, 128}, {128, 0, 128}};
const rgb_store yarg_colormap[1000] = {
{0, 0, 0}, {0, 0, 0}, {1, 1, 1}, {1, 1, 1},
{1, 1, 1}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2},
{2, 2, 2}, {2, 2, 2}, {3, 3, 3}, {3, 3, 3},
{3, 3, 3}, {3, 3, 3}, {4, 4, 4}, {4, 4, 4},
{4, 4, 4}, {4, 4, 4}, {5, 5, 5}, {5, 5, 5},
{5, 5, 5}, {5, 5, 5}, {6, 6, 6}, {6, 6, 6},
{6, 6, 6}, {6, 6, 6}, {7, 7, 7}, {7, 7, 7},
{7, 7, 7}, {7, 7, 7}, {8, 8, 8}, {8, 8, 8},
{8, 8, 8}, {8, 8, 8}, {9, 9, 9}, {9, 9, 9},
{9, 9, 9}, {9, 9, 9}, {10, 10, 10}, {10, 10, 10},
{10, 10, 10}, {10, 10, 10}, {11, 11, 11}, {11, 11, 11},
{11, 11, 11}, {11, 11, 11}, {12, 12, 12}, {12, 12, 12},
{12, 12, 12}, {13, 13, 13}, {13, 13, 13}, {13, 13, 13},
{13, 13, 13}, {14, 14, 14}, {14, 14, 14}, {14, 14, 14},
{14, 14, 14}, {15, 15, 15}, {15, 15, 15}, {15, 15, 15},
{15, 15, 15}, {16, 16, 16}, {16, 16, 16}, {16, 16, 16},
{16, 16, 16}, {17, 17, 17}, {17, 17, 17}, {17, 17, 17},
{17, 17, 17}, {18, 18, 18}, {18, 18, 18}, {18, 18, 18},
{18, 18, 18}, {19, 19, 19}, {19, 19, 19}, {19, 19, 19},
{19, 19, 19}, {20, 20, 20}, {20, 20, 20}, {20, 20, 20},
{20, 20, 20}, {21, 21, 21}, {21, 21, 21}, {21, 21, 21},
{21, 21, 21}, {22, 22, 22}, {22, 22, 22}, {22, 22, 22},
{22, 22, 22}, {23, 23, 23}, {23, 23, 23}, {23, 23, 23},
{23, 23, 23}, {24, 24, 24}, {24, 24, 24}, {24, 24, 24},
{25, 25, 25}, {25, 25, 25}, {25, 25, 25}, {25, 25, 25},
{26, 26, 26}, {26, 26, 26}, {26, 26, 26}, {26, 26, 26},
{27, 27, 27}, {27, 27, 27}, {27, 27, 27}, {27, 27, 27},
{28, 28, 28}, {28, 28, 28}, {28, 28, 28}, {28, 28, 28},
{29, 29, 29}, {29, 29, 29}, {29, 29, 29}, {29, 29, 29},
{30, 30, 30}, {30, 30, 30}, {30, 30, 30}, {30, 30, 30},
{31, 31, 31}, {31, 31, 31}, {31, 31, 31}, {31, 31, 31},
{32, 32, 32}, {32, 32, 32}, {32, 32, 32}, {32, 32, 32},
{33, 33, 33}, {33, 33, 33}, {33, 33, 33}, {33, 33, 33},
{34, 34, 34}, {34, 34, 34}, {34, 34, 34}, {34, 34, 34},
{35, 35, 35}, {35, 35, 35}, {35, 35, 35}, {35, 35, 35},
{36, 36, 36}, {36, 36, 36}, {36, 36, 36}, {37, 37, 37},
{37, 37, 37}, {37, 37, 37}, {37, 37, 37}, {38, 38, 38},
{38, 38, 38}, {38, 38, 38}, {38, 38, 38}, {39, 39, 39},
{39, 39, 39}, {39, 39, 39}, {39, 39, 39}, {40, 40, 40},
{40, 40, 40}, {40, 40, 40}, {40, 40, 40}, {41, 41, 41},
{41, 41, 41}, {41, 41, 41}, {41, 41, 41}, {42, 42, 42},
{42, 42, 42}, {42, 42, 42}, {42, 42, 42}, {43, 43, 43},
{43, 43, 43}, {43, 43, 43}, {43, 43, 43}, {44, 44, 44},
{44, 44, 44}, {44, 44, 44}, {44, 44, 44}, {45, 45, 45},
{45, 45, 45}, {45, 45, 45}, {45, 45, 45}, {46, 46, 46},
{46, 46, 46}, {46, 46, 46}, {46, 46, 46}, {47, 47, 47},
{47, 47, 47}, {47, 47, 47}, {47, 47, 47}, {48, 48, 48},
{48, 48, 48}, {48, 48, 48}, {48, 48, 48}, {49, 49, 49},
{49, 49, 49}, {49, 49, 49}, {50, 50, 50}, {50, 50, 50},
{50, 50, 50}, {50, 50, 50}, {51, 51, 51}, {51, 51, 51},
{51, 51, 51}, {51, 51, 51}, {52, 52, 52}, {52, 52, 52},
{52, 52, 52}, {52, 52, 52}, {53, 53, 53}, {53, 53, 53},
{53, 53, 53}, {53, 53, 53}, {54, 54, 54}, {54, 54, 54},
{54, 54, 54}, {54, 54, 54}, {55, 55, 55}, {55, 55, 55},
{55, 55, 55}, {55, 55, 55}, {56, 56, 56}, {56, 56, 56},
{56, 56, 56}, {56, 56, 56}, {57, 57, 57}, {57, 57, 57},
{57, 57, 57}, {57, 57, 57}, {58, 58, 58}, {58, 58, 58},
{58, 58, 58}, {58, 58, 58}, {59, 59, 59}, {59, 59, 59},
{59, 59, 59}, {59, 59, 59}, {60, 60, 60}, {60, 60, 60},
{60, 60, 60}, {60, 60, 60}, {61, 61, 61}, {61, 61, 61},
{61, 61, 61}, {62, 62, 62}, {62, 62, 62}, {62, 62, 62},
{62, 62, 62}, {63, 63, 63}, {63, 63, 63}, {63, 63, 63},
{63, 63, 63}, {64, 64, 64}, {64, 64, 64}, {64, 64, 64},
{64, 64, 64}, {65, 65, 65}, {65, 65, 65}, {65, 65, 65},
{65, 65, 65}, {66, 66, 66}, {66, 66, 66}, {66, 66, 66},
{66, 66, 66}, {67, 67, 67}, {67, 67, 67}, {67, 67, 67},
{67, 67, 67}, {68, 68, 68}, {68, 68, 68}, {68, 68, 68},
{68, 68, 68}, {69, 69, 69}, {69, 69, 69}, {69, 69, 69},
{69, 69, 69}, {70, 70, 70}, {70, 70, 70}, {70, 70, 70},
{70, 70, 70}, {71, 71, 71}, {71, 71, 71}, {71, 71, 71},
{71, 71, 71}, {72, 72, 72}, {72, 72, 72}, {72, 72, 72},
{72, 72, 72}, {73, 73, 73}, {73, 73, 73}, {73, 73, 73},
{74, 74, 74}, {74, 74, 74}, {74, 74, 74}, {74, 74, 74},
{75, 75, 75}, {75, 75, 75}, {75, 75, 75}, {75, 75, 75},
{76, 76, 76}, {76, 76, 76}, {76, 76, 76}, {76, 76, 76},
{77, 77, 77}, {77, 77, 77}, {77, 77, 77}, {77, 77, 77},
{78, 78, 78}, {78, 78, 78}, {78, 78, 78}, {78, 78, 78},
{79, 79, 79}, {79, 79, 79}, {79, 79, 79}, {79, 79, 79},
{80, 80, 80}, {80, 80, 80}, {80, 80, 80}, {80, 80, 80},
{81, 81, 81}, {81, 81, 81}, {81, 81, 81}, {81, 81, 81},
{82, 82, 82}, {82, 82, 82}, {82, 82, 82}, {82, 82, 82},
{83, 83, 83}, {83, 83, 83}, {83, 83, 83}, {83, 83, 83},
{84, 84, 84}, {84, 84, 84}, {84, 84, 84}, {84, 84, 84},
{85, 85, 85}, {85, 85, 85}, {85, 85, 85}, {86, 86, 86},
{86, 86, 86}, {86, 86, 86}, {86, 86, 86}, {87, 87, 87},
{87, 87, 87}, {87, 87, 87}, {87, 87, 87}, {88, 88, 88},
{88, 88, 88}, {88, 88, 88}, {88, 88, 88}, {89, 89, 89},
{89, 89, 89}, {89, 89, 89}, {89, 89, 89}, {90, 90, 90},
{90, 90, 90}, {90, 90, 90}, {90, 90, 90}, {91, 91, 91},
{91, 91, 91}, {91, 91, 91}, {91, 91, 91}, {92, 92, 92},
{92, 92, 92}, {92, 92, 92}, {92, 92, 92}, {93, 93, 93},
{93, 93, 93}, {93, 93, 93}, {93, 93, 93}, {94, 94, 94},
{94, 94, 94}, {94, 94, 94}, {94, 94, 94}, {95, 95, 95},
{95, 95, 95}, {95, 95, 95}, {95, 95, 95}, {96, 96, 96},
{96, 96, 96}, {96, 96, 96}, {96, 96, 96}, {97, 97, 97},
{97, 97, 97}, {97, 97, 97}, {98, 98, 98}, {98, 98, 98},
{98, 98, 98}, {98, 98, 98}, {99, 99, 99}, {99, 99, 99},
{99, 99, 99}, {99, 99, 99}, {100, 100, 100}, {100, 100, 100},
{100, 100, 100}, {100, 100, 100}, {101, 101, 101}, {101, 101, 101},
{101, 101, 101}, {101, 101, 101}, {102, 102, 102}, {102, 102, 102},
{102, 102, 102}, {102, 102, 102}, {103, 103, 103}, {103, 103, 103},
{103, 103, 103}, {103, 103, 103}, {104, 104, 104}, {104, 104, 104},
{104, 104, 104}, {104, 104, 104}, {105, 105, 105}, {105, 105, 105},
{105, 105, 105}, {105, 105, 105}, {106, 106, 106}, {106, 106, 106},
{106, 106, 106}, {106, 106, 106}, {107, 107, 107}, {107, 107, 107},
{107, 107, 107}, {107, 107, 107}, {108, 108, 108}, {108, 108, 108},
{108, 108, 108}, {108, 108, 108}, {109, 109, 109}, {109, 109, 109},
{109, 109, 109}, {110, 110, 110}, {110, 110, 110}, {110, 110, 110},
{110, 110, 110}, {111, 111, 111}, {111, 111, 111}, {111, 111, 111},
{111, 111, 111}, {112, 112, 112}, {112, 112, 112}, {112, 112, 112},
{112, 112, 112}, {113, 113, 113}, {113, 113, 113}, {113, 113, 113},
{113, 113, 113}, {114, 114, 114}, {114, 114, 114}, {114, 114, 114},
{114, 114, 114}, {115, 115, 115}, {115, 115, 115}, {115, 115, 115},
{115, 115, 115}, {116, 116, 116}, {116, 116, 116}, {116, 116, 116},
{116, 116, 116}, {117, 117, 117}, {117, 117, 117}, {117, 117, 117},
{117, 117, 117}, {118, 118, 118}, {118, 118, 118}, {118, 118, 118},
{118, 118, 118}, {119, 119, 119}, {119, 119, 119}, {119, 119, 119},
{119, 119, 119}, {120, 120, 120}, {120, 120, 120}, {120, 120, 120},
{120, 120, 120}, {121, 121, 121}, {121, 121, 121}, {121, 121, 121},
{122, 122, 122}, {122, 122, 122}, {122, 122, 122}, {122, 122, 122},
{123, 123, 123}, {123, 123, 123}, {123, 123, 123}, {123, 123, 123},
{124, 124, 124}, {124, 124, 124}, {124, 124, 124}, {124, 124, 124},
{125, 125, 125}, {125, 125, 125}, {125, 125, 125}, {125, 125, 125},
{126, 126, 126}, {126, 126, 126}, {126, 126, 126}, {126, 126, 126},
{127, 127, 127}, {127, 127, 127}, {127, 127, 127}, {127, 127, 127},
{128, 128, 128}, {128, 128, 128}, {128, 128, 128}, {128, 128, 128},
{129, 129, 129}, {129, 129, 129}, {129, 129, 129}, {129, 129, 129},
{130, 130, 130}, {130, 130, 130}, {130, 130, 130}, {130, 130, 130},
{131, 131, 131}, {131, 131, 131}, {131, 131, 131}, {131, 131, 131},
{132, 132, 132}, {132, 132, 132}, {132, 132, 132}, {132, 132, 132},
{133, 133, 133}, {133, 133, 133}, {133, 133, 133}, {133, 133, 133},
{134, 134, 134}, {134, 134, 134}, {134, 134, 134}, {135, 135, 135},
{135, 135, 135}, {135, 135, 135}, {135, 135, 135}, {136, 136, 136},
{136, 136, 136}, {136, 136, 136}, {136, 136, 136}, {137, 137, 137},
{137, 137, 137}, {137, 137, 137}, {137, 137, 137}, {138, 138, 138},
{138, 138, 138}, {138, 138, 138}, {138, 138, 138}, {139, 139, 139},
{139, 139, 139}, {139, 139, 139}, {139, 139, 139}, {140, 140, 140},
{140, 140, 140}, {140, 140, 140}, {140, 140, 140}, {141, 141, 141},
{141, 141, 141}, {141, 141, 141}, {141, 141, 141}, {142, 142, 142},
{142, 142, 142}, {142, 142, 142}, {142, 142, 142}, {143, 143, 143},
{143, 143, 143}, {143, 143, 143}, {143, 143, 143}, {144, 144, 144},
{144, 144, 144}, {144, 144, 144}, {144, 144, 144}, {145, 145, 145},
{145, 145, 145}, {145, 145, 145}, {145, 145, 145}, {146, 146, 146},
{146, 146, 146}, {146, 146, 146}, {147, 147, 147}, {147, 147, 147},
{147, 147, 147}, {147, 147, 147}, {148, 148, 148}, {148, 148, 148},
{148, 148, 148}, {148, 148, 148}, {149, 149, 149}, {149, 149, 149},
{149, 149, 149}, {149, 149, 149}, {150, 150, 150}, {150, 150, 150},
{150, 150, 150}, {150, 150, 150}, {151, 151, 151}, {151, 151, 151},
{151, 151, 151}, {151, 151, 151}, {152, 152, 152}, {152, 152, 152},
{152, 152, 152}, {152, 152, 152}, {153, 153, 153}, {153, 153, 153},
{153, 153, 153}, {153, 153, 153}, {154, 154, 154}, {154, 154, 154},
{154, 154, 154}, {154, 154, 154}, {155, 155, 155}, {155, 155, 155},
{155, 155, 155}, {155, 155, 155}, {156, 156, 156}, {156, 156, 156},
{156, 156, 156}, {156, 156, 156}, {157, 157, 157}, {157, 157, 157},
{157, 157, 157}, {157, 157, 157}, {158, 158, 158}, {158, 158, 158},
{158, 158, 158}, {159, 159, 159}, {159, 159, 159}, {159, 159, 159},
{159, 159, 159}, {160, 160, 160}, {160, 160, 160}, {160, 160, 160},
{160, 160, 160}, {161, 161, 161}, {161, 161, 161}, {161, 161, 161},
{161, 161, 161}, {162, 162, 162}, {162, 162, 162}, {162, 162, 162},
{162, 162, 162}, {163, 163, 163}, {163, 163, 163}, {163, 163, 163},
{163, 163, 163}, {164, 164, 164}, {164, 164, 164}, {164, 164, 164},
{164, 164, 164}, {165, 165, 165}, {165, 165, 165}, {165, 165, 165},
{165, 165, 165}, {166, 166, 166}, {166, 166, 166}, {166, 166, 166},
{166, 166, 166}, {167, 167, 167}, {167, 167, 167}, {167, 167, 167},
{167, 167, 167}, {168, 168, 168}, {168, 168, 168}, {168, 168, 168},
{168, 168, 168}, {169, 169, 169}, {169, 169, 169}, {169, 169, 169},
{169, 169, 169}, {170, 170, 170}, {170, 170, 170}, {170, 170, 170},
{171, 171, 171}, {171, 171, 171}, {171, 171, 171}, {171, 171, 171},
{172, 172, 172}, {172, 172, 172}, {172, 172, 172}, {172, 172, 172},
{173, 173, 173}, {173, 173, 173}, {173, 173, 173}, {173, 173, 173},
{174, 174, 174}, {174, 174, 174}, {174, 174, 174}, {174, 174, 174},
{175, 175, 175}, {175, 175, 175}, {175, 175, 175}, {175, 175, 175},
{176, 176, 176}, {176, 176, 176}, {176, 176, 176}, {176, 176, 176},
{177, 177, 177}, {177, 177, 177}, {177, 177, 177}, {177, 177, 177},
{178, 178, 178}, {178, 178, 178}, {178, 178, 178}, {178, 178, 178},
{179, 179, 179}, {179, 179, 179}, {179, 179, 179}, {179, 179, 179},
{180, 180, 180}, {180, 180, 180}, {180, 180, 180}, {180, 180, 180},
{181, 181, 181}, {181, 181, 181}, {181, 181, 181}, {181, 181, 181},
{182, 182, 182}, {182, 182, 182}, {182, 182, 182}, {183, 183, 183},
{183, 183, 183}, {183, 183, 183}, {183, 183, 183}, {184, 184, 184},
{184, 184, 184}, {184, 184, 184}, {184, 184, 184}, {185, 185, 185},
{185, 185, 185}, {185, 185, 185}, {185, 185, 185}, {186, 186, 186},
{186, 186, 186}, {186, 186, 186}, {186, 186, 186}, {187, 187, 187},
{187, 187, 187}, {187, 187, 187}, {187, 187, 187}, {188, 188, 188},
{188, 188, 188}, {188, 188, 188}, {188, 188, 188}, {189, 189, 189},
{189, 189, 189}, {189, 189, 189}, {189, 189, 189}, {190, 190, 190},
{190, 190, 190}, {190, 190, 190}, {190, 190, 190}, {191, 191, 191},
{191, 191, 191}, {191, 191, 191}, {191, 191, 191}, {192, 192, 192},
{192, 192, 192}, {192, 192, 192}, {192, 192, 192}, {193, 193, 193},
{193, 193, 193}, {193, 193, 193}, {193, 193, 193}, {194, 194, 194},
{194, 194, 194}, {194, 194, 194}, {195, 195, 195}, {195, 195, 195},
{195, 195, 195}, {195, 195, 195}, {196, 196, 196}, {196, 196, 196},
{196, 196, 196}, {196, 196, 196}, {197, 197, 197}, {197, 197, 197},
{197, 197, 197}, {197, 197, 197}, {198, 198, 198}, {198, 198, 198},
{198, 198, 198}, {198, 198, 198}, {199, 199, 199}, {199, 199, 199},
{199, 199, 199}, {199, 199, 199}, {200, 200, 200}, {200, 200, 200},
{200, 200, 200}, {200, 200, 200}, {201, 201, 201}, {201, 201, 201},
{201, 201, 201}, {201, 201, 201}, {202, 202, 202}, {202, 202, 202},
{202, 202, 202}, {202, 202, 202}, {203, 203, 203}, {203, 203, 203},
{203, 203, 203}, {203, 203, 203}, {204, 204, 204}, {204, 204, 204},
{204, 204, 204}, {204, 204, 204}, {205, 205, 205}, {205, 205, 205},
{205, 205, 205}, {205, 205, 205}, {206, 206, 206}, {206, 206, 206},
{206, 206, 206}, {207, 207, 207}, {207, 207, 207}, {207, 207, 207},
{207, 207, 207}, {208, 208, 208}, {208, 208, 208}, {208, 208, 208},
{208, 208, 208}, {209, 209, 209}, {209, 209, 209}, {209, 209, 209},
{209, 209, 209}, {210, 210, 210}, {210, 210, 210}, {210, 210, 210},
{210, 210, 210}, {211, 211, 211}, {211, 211, 211}, {211, 211, 211},
{211, 211, 211}, {212, 212, 212}, {212, 212, 212}, {212, 212, 212},
{212, 212, 212}, {213, 213, 213}, {213, 213, 213}, {213, 213, 213},
{213, 213, 213}, {214, 214, 214}, {214, 214, 214}, {214, 214, 214},
{214, 214, 214}, {215, 215, 215}, {215, 215, 215}, {215, 215, 215},
{215, 215, 215}, {216, 216, 216}, {216, 216, 216}, {216, 216, 216},
{216, 216, 216}, {217, 217, 217}, {217, 217, 217}, {217, 217, 217},
{217, 217, 217}, {218, 218, 218}, {218, 218, 218}, {218, 218, 218},
{218, 218, 218}, {219, 219, 219}, {219, 219, 219}, {219, 219, 219},
{220, 220, 220}, {220, 220, 220}, {220, 220, 220}, {220, 220, 220},
{221, 221, 221}, {221, 221, 221}, {221, 221, 221}, {221, 221, 221},
{222, 222, 222}, {222, 222, 222}, {222, 222, 222}, {222, 222, 222},
{223, 223, 223}, {223, 223, 223}, {223, 223, 223}, {223, 223, 223},
{224, 224, 224}, {224, 224, 224}, {224, 224, 224}, {224, 224, 224},
{225, 225, 225}, {225, 225, 225}, {225, 225, 225}, {225, 225, 225},
{226, 226, 226}, {226, 226, 226}, {226, 226, 226}, {226, 226, 226},
{227, 227, 227}, {227, 227, 227}, {227, 227, 227}, {227, 227, 227},
{228, 228, 228}, {228, 228, 228}, {228, 228, 228}, {228, 228, 228},
{229, 229, 229}, {229, 229, 229}, {229, 229, 229}, {229, 229, 229},
{230, 230, 230}, {230, 230, 230}, {230, 230, 230}, {230, 230, 230},
{231, 231, 231}, {231, 231, 231}, {231, 231, 231}, {232, 232, 232},
{232, 232, 232}, {232, 232, 232}, {232, 232, 232}, {233, 233, 233},
{233, 233, 233}, {233, 233, 233}, {233, 233, 233}, {234, 234, 234},
{234, 234, 234}, {234, 234, 234}, {234, 234, 234}, {235, 235, 235},
{235, 235, 235}, {235, 235, 235}, {235, 235, 235}, {236, 236, 236},
{236, 236, 236}, {236, 236, 236}, {236, 236, 236}, {237, 237, 237},
{237, 237, 237}, {237, 237, 237}, {237, 237, 237}, {238, 238, 238},
{238, 238, 238}, {238, 238, 238}, {238, 238, 238}, {239, 239, 239},
{239, 239, 239}, {239, 239, 239}, {239, 239, 239}, {240, 240, 240},
{240, 240, 240}, {240, 240, 240}, {240, 240, 240}, {241, 241, 241},
{241, 241, 241}, {241, 241, 241}, {241, 241, 241}, {242, 242, 242},
{242, 242, 242}, {242, 242, 242}, {242, 242, 242}, {243, 243, 243},
{243, 243, 243}, {243, 243, 243}, {244, 244, 244}, {244, 244, 244},
{244, 244, 244}, {244, 244, 244}, {245, 245, 245}, {245, 245, 245},
{245, 245, 245}, {245, 245, 245}, {246, 246, 246}, {246, 246, 246},
{246, 246, 246}, {246, 246, 246}, {247, 247, 247}, {247, 247, 247},
{247, 247, 247}, {247, 247, 247}, {248, 248, 248}, {248, 248, 248},
{248, 248, 248}, {248, 248, 248}, {249, 249, 249}, {249, 249, 249},
{249, 249, 249}, {249, 249, 249}, {250, 250, 250}, {250, 250, 250},
{250, 250, 250}, {250, 250, 250}, {251, 251, 251}, {251, 251, 251},
{251, 251, 251}, {251, 251, 251}, {252, 252, 252}, {252, 252, 252},
{252, 252, 252}, {252, 252, 252}, {253, 253, 253}, {253, 253, 253},
{253, 253, 253}, {253, 253, 253}, {254, 254, 254}, {254, 254, 254},
{254, 254, 254}, {254, 254, 254}, {255}, {255}};
#endif
| MrCappuccino/Tracey | src/bitmap_image.hpp | C++ | gpl-3.0 | 207,672 |
/*
* Monomial.hh, part of the RotationShield program
* Copyright (c) 2007-2014 Michael P. Mendenhall
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/// \file "Monomial.hh" \brief Templatized monomial term for a polynomial
#ifndef MONOMIAL_HH
/// Make sure this header is only loaded once
#define MONOMIAL_HH
#include "Vec.hh"
#include <iostream>
#include <iomanip>
#include <exception>
/// general exception for polynomial problems
class PolynomialException: public std::exception {
virtual const char* what() const throw() {
return "Monomial Problem!";
}
};
/// exception for attempts to use inconsistent units
class InconsistentMonomialException: public PolynomialException {
virtual const char* what() const throw() {
return "Incomparable monomial terms!";
}
};
template<unsigned int N, typename T, typename P>
class Monomial {
public:
/// constructor
Monomial(T v, Vec<N,P> d): val(v), dimensions(d) { }
/// constructor for dimensionless
Monomial(T v): val(v), dimensions(Vec<N,P>()) { }
/// destructor
virtual ~Monomial() {}
/// check Monomial consistency
bool consistentWith(const Monomial<N,T,P>& u) const { return dimensions == u.dimensions; }
/// throw error if inconsistent
virtual void assertConsistent(const Monomial<N,T,P>& u) const { if(!consistentWith(u)) throw(InconsistentMonomialException()); }
/// output representation in algebraic form
std::ostream& algebraicForm(std::ostream& o) const;
/// output representation in data table form
std::ostream& tableForm(std::ostream& o) const;
/// output representation in LaTeX form
std::ostream& latexForm(std::ostream& o) const;
/// convert to dimensionless quantity of given unit
double in(const Monomial<N,T,P>& u) const { assertConsistent(u); return val/u.val; }
/// unary minus
const Monomial<N,T,P> operator-() const;
/// inverse Monomial
const Monomial<N,T,P> inverse() const;
/// evaluate value at given point
T operator()(const Vec<N,T>& v) const;
/// inplace addition
Monomial<N,T,P>& operator+=(const Monomial<N,T,P>& rhs);
/// inplace subtraction
Monomial<N,T,P>& operator-=(const Monomial<N,T,P>& rhs);
/// inplace multiplication
Monomial<N,T,P>& operator*=(const Monomial<N,T,P>& rhs);
/// inplace division
Monomial<N,T,P>& operator/=(const Monomial<N,T,P>& rhs);
/// inplace multiplication
Monomial<N,T,P>& operator*=(T rhs);
/// inplace division
Monomial<N,T,P>& operator/=(T rhs);
/// addition operator
const Monomial<N,T,P> operator+(const Monomial<N,T,P>& other) const;
/// subtraction operator
const Monomial<N,T,P> operator-(const Monomial<N,T,P>& other) const;
/// multiplication operator
const Monomial<N,T,P> operator*(const Monomial<N,T,P>& other) const;
/// division operator
const Monomial<N,T,P> operator/(const Monomial<N,T,P>& other) const;
/// multiplication operator
const Monomial<N,T,P> operator*(T other) const;
/// division operator
const Monomial<N,T,P> operator/(T other) const;
T val; ///< dimensionless value
Vec<N,P> dimensions; ///< unit dimensions
static const char* vletters; ///< letters for variable names
};
template<unsigned int N, typename T, typename P>
const char* Monomial<N,T,P>::vletters = "xyztuvwabcdefghijklmnopqrs";
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::operator-() const {
Monomial<N,T,P> u = *this;
u.val = -val;
return u;
}
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::inverse() const {
Monomial<N,T,P> u = *this;
u.val = 1./val;
u.dimensions = -u.dimensions;
return u;
}
template<unsigned int N, typename T, typename P>
T Monomial<N,T,P>::operator()(const Vec<N,T>& v) const {
T s = val;
for(unsigned int i=0; i<N; i++)
s *= pow(v[i],dimensions[i]);
return s;
}
template<unsigned int N, typename T, typename P>
Monomial<N,T,P>& Monomial<N,T,P>::operator+=(const Monomial<N,T,P>& rhs) {
assertConsistent(rhs);
val += rhs.val;
return *this;
}
template<unsigned int N, typename T, typename P>
Monomial<N,T,P>& Monomial<N,T,P>::operator-=(const Monomial<N,T,P>& rhs) {
assertConsistent(rhs);
val -= rhs.val;
return *this;
}
template<unsigned int N, typename T, typename P>
Monomial<N,T,P>& Monomial<N,T,P>::operator*=(const Monomial<N,T,P>& rhs) {
dimensions += rhs.dimensions;
val *= rhs.val;
return *this;
}
template<unsigned int N, typename T, typename P>
Monomial<N,T,P>& Monomial<N,T,P>::operator/=(const Monomial<N,T,P>& rhs) {
dimensions -= rhs.dimensions;
val /= rhs.val;
return *this;
}
template<unsigned int N, typename T, typename P>
Monomial<N,T,P>& Monomial<N,T,P>::operator*=(T rhs) {
val *= rhs;
return *this;
}
template<unsigned int N, typename T, typename P>
Monomial<N,T,P>& Monomial<N,T,P>::operator/=(T rhs) {
val /= rhs;
return *this;
}
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::operator+(const Monomial<N,T,P>& other) const {
Monomial<N,T,P> result = *this;
result += other;
return result;
}
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::operator-(const Monomial<N,T,P>& other) const {
Monomial<N,T,P> result = *this;
result -= other;
return result;
}
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::operator*(const Monomial<N,T,P>& other) const {
Monomial<N,T,P> result = *this;
result *= other;
return result;
}
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::operator/(const Monomial<N,T,P>& other) const {
Monomial<N,T,P> result = *this;
result /= other;
return result;
}
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::operator*(T other) const {
Monomial<N,T,P> result = *this;
result *= other;
return result;
}
template<unsigned int N, typename T, typename P>
const Monomial<N,T,P> Monomial<N,T,P>::operator/(T other) const {
Monomial<N,T,P> result = *this;
result /= other;
return result;
}
template<unsigned int N, typename T, typename P>
std::ostream& Monomial<N,T,P>::algebraicForm(std::ostream& o) const {
o << std::showpos << val << std::noshowpos;
for(P i=0; i<N; i++) {
if(dimensions[i] > 0) {
if(dimensions[i] == 1)
o << vletters[i];
else
o << vletters[i] << "^" << dimensions[i];
}
}
return o;
}
template<unsigned int N, typename T, typename P>
std::ostream& Monomial<N,T,P>::latexForm(std::ostream& o) const {
o << std::showpos << val << std::noshowpos;
for(P i=0; i<N; i++) {
if(dimensions[i] > 0) {
if(dimensions[i] == 1) {
o << vletters[i];
} else {
o << vletters[i] << "^";
if(dimensions[i] < 10)
o << dimensions[i] ;
else
o << "{" << dimensions[i] << "}";
}
}
}
return o;
}
template<unsigned int N, typename T, typename P>
std::ostream& Monomial<N,T,P>::tableForm(std::ostream& o) const {
o << std::setw(20) << std::setprecision(10) << val << "\t";
for(P i=0; i<N; i++)
o << " " << std::setw(0) << dimensions[i];
return o;
}
/// output representation
template<unsigned int N, typename T, typename P>
std::ostream& operator<<(std::ostream& o, const Monomial<N,T,P>& u) {
o << "[ " << u.val << " " << u.dimensions << " ]";
return o;
}
#endif
| mpmendenhall/rotationshield | MathUtils/Monomial.hh | C++ | gpl-3.0 | 8,516 |
vti_encoding:SR|utf8-nl
vti_timelastmodified:TW|21 Aug 2014 19:09:59 -0000
vti_extenderversion:SR|12.0.0.0
vti_author:SR|Office-PC\\Rafael
vti_modifiedby:SR|Office-PC\\Rafael
vti_timecreated:TR|01 Nov 2014 09:09:51 -0000
vti_backlinkinfo:VX|
vti_nexttolasttimemodified:TW|21 Aug 2014 19:09:59 -0000
vti_cacheddtm:TX|03 Nov 2015 20:40:16 -0000
vti_filesize:IR|1046
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|utf-8
vti_syncofs_mydatalogger.de\:22/%2fvar/www/vhosts/s16851491.onlinehome-server.info/kaufreund.de:TW|21 Aug 2014 19:09:59 -0000
vti_syncwith_mydatalogger.de\:22/%2fvar/www/vhosts/s16851491.onlinehome-server.info/kaufreund.de:TW|03 Nov 2015 20:40:16 -0000
| Vitronic/kaufreund.de | admin/language/de_DE/user/_vti_cnf/user_group.php | PHP | gpl-3.0 | 754 |
<?PHP
/******************************************************************************
* *
* Copyright (c) 1999-2006 Horizon Wimba, All Rights Reserved. *
* *
* COPYRIGHT: *
* This software is the property of Horizon Wimba. *
* You can redistribute it and/or modify it under the terms of *
* the GNU General Public License as published by the *
* Free Software Foundation. *
* *
* WARRANTIES: *
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with the Horizon Wimba Moodle Integration; *
* if not, write to the Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
* *
*
* *
* Date: September 2006 *
* *
******************************************************************************/
/* $Id: welcome.php 70214 2008-11-12 00:13:01Z thomasr $ */
/// This page creates a link between the CMS and the component
error_reporting(E_ERROR);
require_once("../../config.php");
require_once("lib.php");
$firstPage= "generateXmlMainPanel.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Voice Board</title>
<link rel="STYLESHEET" href="css/StyleSheet.css" type="text/css" />
<!--[if lt IE 7]>
<script type="text/javascript" src="lib/web/js/lib/iepngfix/iepngfix_tilebg.js"></script>
<![endif]-->
<script type="text/javascript" src="lib/web/js/lib/prototype/prototype.js"></script>
<script type="text/javascript" src="lib/web/js/wimba_commons.js"></script>
<script type="text/javascript" src="lib/web/js/wimba_ajax.js"></script>
<script type="text/javascript" src="lib/web/js/verifForm.js"></script>
<script type="text/javascript" src="lib/web/js/constants.js"></script>
<script>
if(navigator.userAgent.indexOf( 'Safari' ) != -1)
{
document.write('<script type=\"text/javascript\" src=\"lib/web/js/lib/ajaxslt/xslt.js\"></' + 'script>');
document.write('<script type=\"text/javascript\" src=\"lib/web/js/lib/ajaxslt/util.js\"></' + 'script>');
document.write('<script type=\"text/javascript\" src=\"lib/web/js/lib/ajaxslt/xmltoken.js\"></' + 'script>');
document.write('<script type=\"text/javascript\" src=\"lib/web/js/lib/ajaxslt/dom.js\"></' + 'script>');
document.write('<script type=\"text/javascript\" src=\"lib/web/js/lib/ajaxslt/xpath.js\"></' + 'script>');
}
function display()
{
DisplayFirstPage('<?php echo $firstPage ?>','all','','');
}
function doOpenAddActivity(url,param)
{
if(currentId!="")
{
var complete_url=url+'?rid='+currentId+'&id='+session["courseId"]+'&'+param;
window.open(complete_url,"_top");
}
}
currentProduct="voiceboard";
initPath('lib/web/js/xsl/wimba.xsl','lib/web/pictures');
addLoadEvent(display);
</script>
<style>
*{
margin:0;
padding:0;
}
</style>
</head>
<body id="body">
<div id="all" class="general_font" style="display:block;background-color:white;overflow:hidden;border:solid 1px #808080;width:700px;height:400px;"></div>
<div id="loading" class="general_font" style="display:none;background-color:white;border:solid 1px #808080;width:700px;height:400px;overflow:hidden">
<div class="headerBar">
<div class="headerBarLeft" >
<span>Blackboard Collaborate</span>
</div>
</div>
<div style="height: 300px; width: 700px; padding-top: 150px; padding-left: 300px;text-indent:10">
<img src="lib/web/pictures/items/wheel-24.gif"><br>
<span style="font-color:#666666">Loading...</span>
</div>
</div>
</body>
</html>
| junwan6/cdhpoodll | mod/voiceboard/welcome.php | PHP | gpl-3.0 | 5,245 |
#include "message_value.h"
//#include <iostream>
MessageValue::MessageValue() : message_array(NULL), sequence_name(NULL) {}
MessageValue::MessageValue(char type, char* name) : message_type(type) {
sequence_name = name;
length = 1 + strlen(sequence_name) + 1;
if (message_array != NULL) {
delete[] message_array;
message_array = NULL;
}
message_array = new char[length];
message_array[0] = message_type;
strcpy(&message_array[1], sequence_name);
}
MessageValue::MessageValue(char* message) {
if (message[0] == CURRENT_LABEL || message[0] == INCOMING_LABEL || message[0] == NEIGHBOR_NODE) {
message_type = message[0];
sequence_name = &message[1];
} else {
message_type = NEIGHBOR_NODE;
sequence_name = message;
}
length = 1 + strlen(sequence_name) + 1;
if (message_array != NULL) {
delete[] message_array;
message_array = NULL;
}
message_array = new char[length];
message_array[0] = message_type;
strcpy(&message_array[1], sequence_name);
}
MessageValue::~MessageValue() {
if (message_array) {
//std::cout << "deleting array " << std::endl;
//std::cout << message_array << std::endl;
delete[] message_array;
message_array = NULL;
//std::cout << "it's now deleted" << std::endl;
}
//std::cout << "exiting destructor" << std::endl;
}
MessageValue::MessageValue(const MessageValue& rhs) {
this -> length = rhs.length;
this -> sequence_name = rhs.sequence_name;
this -> message_type = rhs.message_type;
if (this -> message_array != NULL) {
delete[] (this -> message_array);
this -> message_array = NULL;
}
this -> message_array = new char[length];
memcpy(this -> message_array, rhs.message_array, length);
}
char* MessageValue::get_message_array() {
return message_array;
}
void MessageValue::set_name(char* name) {
strcpy(sequence_name, name);
}
char* MessageValue::get_name() {
return sequence_name;
}
void MessageValue::set_type(char type) {
message_type = type;
if (message_array != NULL) {
message_array[0] = type;
}
}
char MessageValue::get_type() {
return message_type;
}
MessageValue& MessageValue::operator=( const MessageValue& rhs ) {
if (this -> message_array != NULL) {
delete[] (this -> message_array);
this -> message_array = NULL;
}
this -> length = rhs.length;
this -> sequence_name = rhs.sequence_name;
this -> message_type = rhs.message_type;
this -> message_array = new char[length];
memcpy(this -> message_array, rhs.message_array, length);
}
bool MessageValue::operator==(MessageValue& rhs) {
return ( !strcmp( this -> sequence_name, rhs.get_name() ) &&
this -> message_type == rhs.get_type() );
}
void MessageValue::assign(MessageValue* rhs) {
this -> message_type = rhs -> get_type();
this -> sequence_name = rhs -> get_name();
if (this -> message_array != NULL) {
delete[] message_array;
message_array = NULL;
}
length = rhs -> get_length();
message_array = new char[length];
strcpy( this -> message_array, rhs -> get_message_array());
}
int MessageValue::get_length() {
return length;
}
| armenabnousi/minhash_clustering | src/message_value.cpp | C++ | gpl-3.0 | 3,012 |
/*
* Biocep: R-based Platform for Computational e-Science.
*
* Copyright (C) 2007-2009 Karim Chine - karim.chine@m4x.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.kchine.r.server;
public interface GenericCallbackDevice extends Device, RCallBack, RConsoleActionListener, RCollaborationListener{
}
| rforge/biocep | src_server_common/org/kchine/r/server/GenericCallbackDevice.java | Java | gpl-3.0 | 949 |
// Decompiled with JetBrains decompiler
// Type: Wb.Lpw.Platform.Protocol.LogCodes.Services.Registry.UpdatePersistentRoom.Info
// Assembly: Wb.Lpw.Protocol, Version=2.13.83.0, Culture=neutral, PublicKeyToken=null
// MVID: A621984F-C936-438B-B744-D121BF336087
// Assembly location: C:\Users\CGA Computer\Desktop\LEGO Universe Stuff\LOCO Server\Unity Web Player Extractor\Saved Files\LOCO Server.unity3d_unpacked\Wb.Lpw.Protocol.dll
using Wb.Lpw.Platform.Protocol.LogCodes;
namespace Wb.Lpw.Platform.Protocol.LogCodes.Services.Registry.UpdatePersistentRoom
{
public abstract class Info
{
public static LogCode New_Code_Info = new LogCode("Services", "Registry", "UpdatePersistentRoom", Severity.Info, "New_Code_Info", 629498);
public static LogCode Success = new LogCode("Services", "Registry", "UpdatePersistentRoom", Severity.Info, "Success ", 629503);
}
}
| mater06/LEGOChimaOnlineReloaded | LoCO Client Files/Decompressed Client/Extracted DLL/Wb.Lpw.Protocol/LogCodes/Services/Registry/UpdatePersistentRoom/Info.cs | C# | gpl-3.0 | 876 |
<?php
/**
* The template for displaying 404.
*
* @package 9Pixels.
*/
get_header();
?>
<div class="wrap">
<div id="custom-page">
<div class="fullwidth-page-title">
<?php
if ( get_theme_mod( 'denta_lite_404_general_title', 'Error' ) ) {
echo '<h3>'. esc_attr( get_theme_mod( 'denta_lite_404_general_title', 'Error' ) ) .'</h3>';
}
?>
</div><!--/.fullwidth-page-title-->
<div class="custom-page-content">
<?php
if ( get_theme_mod( 'denta_lite_404_general_subtitle', 'The page you were looking for was not found.' ) ) {
echo '<h2>'. esc_attr( get_theme_mod( 'denta_lite_404_general_subtitle', 'The page you were looking for was not found.' ) ) .'</h2>';
}
?>
<div class="page-content-entry">
<?php
if ( get_theme_mod( 'denta_lite_404_general_entry', 'The page you are looking for does not exist, I can take you to the <a href="'. esc_url( home_url() ) .'" title="'. __( 'home page', 'denta-lite' ) .'">home page</a>.' ) ) {
echo get_theme_mod( 'denta_lite_404_general_entry', 'The page you are looking for does not exist, I can take you to the <a href="'. esc_url( home_url() ) .'" title="'. __( 'home page', 'denta-lite' ) .'">home page</a>.' );
}
?>
</div><!--/.page-content-entry-->
</div><!--/.custom-page-content-->
<?php
if ( get_theme_mod( 'denta_lite_404_contact_title', 'Contact' ) || get_theme_mod( 'denta_lite_404_contact_email', 'contact@yourwebsite.com' ) || get_theme_mod( 'denta_lite_404_contact_telephone', '0001234567' ) || get_theme_mod( 'denta_lite_404_contact_url', 'http://www.yourwebsite.com' ) ) { ?>
<div class="custom-page-info">
<?php
if ( get_theme_mod( 'denta_lite_404_contact_title', 'Contact' ) ) {
echo '<h2>'. esc_attr( get_theme_mod( 'denta_lite_404_contact_title', 'Contact' ) ) .'</h2>';
}
if ( get_theme_mod( 'denta_lite_404_contact_email', 'contact@yourwebsite.com' ) || get_theme_mod( 'denta_lite_404_contact_telephone', '0001234567' ) || get_theme_mod( 'denta_lite_404_contact_url', 'http://www.yourwebsite.com' ) ) { ?>
<ul>
<?php
if ( get_theme_mod( 'denta_lite_404_contact_email', 'contact@yourwebsite.com' ) ) {
echo '<li><i class="fa fa-envelope"></i><a href="mailto:'. get_theme_mod( 'denta_lite_404_contact_email', 'contact@yourwebsite.com' ) .'" title="'. get_theme_mod( 'denta_lite_404_contact_email', 'contact@yourwebsite.com' ) .'">'. get_theme_mod( 'denta_lite_404_contact_email', 'contact@yourwebsite.com' ) .'</a></li>';
}
if ( get_theme_mod( 'denta_lite_404_contact_telephone', '0001234567' ) ) {
echo '<li><i class="fa fa-phone"></i><a href="tel:'. esc_attr( get_theme_mod( 'denta_lite_404_contact_telephone', '0001234567' ) ) .'" title="'. esc_attr( get_theme_mod( 'denta_lite_404_contact_telephone', '0001234567' ) ) .'">'. esc_attr( get_theme_mod( 'denta_lite_404_contact_telephone', '0001234567' ) ) .'</a></li>';
}
if ( get_theme_mod( 'denta_lite_404_contact_url', 'http://www.yourwebsite.com' ) ) {
echo '<li><i class="fa fa-home"></i><a href="'. esc_url( get_theme_mod( 'denta_lite_404_contact_url', 'http://www.yourwebsite.com' ) ) .'" title="'. esc_url( get_theme_mod( 'denta_lite_404_contact_url', 'http://www.yourwebsite.com' ) ) .'">'. esc_url( get_theme_mod( 'denta_lite_404_contact_url', 'http://www.yourwebsite.com' ) ) .'</a></li>';
}
?>
</ul>
<?php }
?>
</div><!--/.custom-page-info-->
<?php }
?>
</div><!--/#custom-page-->
</div><!--/.wrap-->
<?php get_footer(); ?> | Codeinwp/dentatheme-lite | 404.php | PHP | gpl-3.0 | 3,540 |
<?php
/**
Copyright 2012-2017 Nick Korbel
This file is part of Booked Scheduler.
Booked Scheduler is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Booked Scheduler is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
*/
define('ROOT_DIR', '../../');
require_once(ROOT_DIR . 'lib/WebService/namespace.php');
require_once(ROOT_DIR . 'lib/WebService/Slim/namespace.php');
require_once(ROOT_DIR . 'WebServices/AuthenticationWebService.php');
require_once(ROOT_DIR . 'WebServices/ReservationsWebService.php');
require_once(ROOT_DIR . 'WebServices/ReservationWriteWebService.php');
require_once(ROOT_DIR . 'WebServices/ResourcesWebService.php');
require_once(ROOT_DIR . 'WebServices/ResourcesWriteWebService.php');
require_once(ROOT_DIR . 'WebServices/UsersWebService.php');
require_once(ROOT_DIR . 'WebServices/UsersWriteWebService.php');
require_once(ROOT_DIR . 'WebServices/SchedulesWebService.php');
require_once(ROOT_DIR . 'WebServices/AttributesWebService.php');
require_once(ROOT_DIR . 'WebServices/AttributesWriteWebService.php');
require_once(ROOT_DIR . 'WebServices/GroupsWebService.php');
require_once(ROOT_DIR . 'WebServices/AccessoriesWebService.php');
require_once(ROOT_DIR . 'Web/Services/Help/ApiHelpPage.php');
if (!Configuration::Instance()->GetSectionKey(ConfigSection::API, ConfigKeys::API_ENABLED, new BooleanConverter()))
{
die("Booked Scheduler API has been configured as disabled.<br/><br/>Set \$conf['settings']['api']['enabled'] = 'true' to enable.");
}
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$server = new SlimServer($app);
$registry = new SlimWebServiceRegistry($app);
RegisterHelp($registry, $app);
RegisterAuthentication($server, $registry);
RegisterReservations($server, $registry);
RegisterResources($server, $registry);
RegisterUsers($server, $registry);
RegisterSchedules($server, $registry);
RegisterAttributes($server, $registry);
RegisterGroups($server, $registry);
RegisterAccessories($server, $registry);
$app->hook('slim.before.dispatch', function () use ($app, $server, $registry)
{
$routeName = $app->router()->getCurrentRoute()->getName();
if ($registry->IsSecure($routeName))
{
$security = new WebServiceSecurity(new UserSessionRepository());
$wasHandled = $security->HandleSecureRequest($server, $registry->IsLimitedToAdmin($routeName));
if (!$wasHandled)
{
$app->halt(RestResponse::UNAUTHORIZED_CODE,
'You must be authenticated in order to access this service.<br/>' . $server->GetFullServiceUrl(WebServices::Login));
}
}
});
$app->error(function (\Exception $e) use ($app)
{
require_once(ROOT_DIR . 'lib/Common/Logging/Log.php');
Log::Error('Slim Exception. %s', $e);
$app->response()->header('Content-Type', 'application/json');
$app->response()->status(RestResponse::SERVER_ERROR);
$app->response()->write('Exception was logged.');
});
$app->run();
function RegisterHelp(SlimWebServiceRegistry $registry, \Slim\Slim $app)
{
$app->get('/', function () use ($registry, $app)
{
// Print API documentation
ApiHelpPage::Render($registry, $app);
})->name("Default");
$app->get('/Help', function () use ($registry, $app)
{
// Print API documentation
ApiHelpPage::Render($registry, $app);
})->name("Help");
}
function RegisterAuthentication(SlimServer $server, SlimWebServiceRegistry $registry)
{
$webService = new AuthenticationWebService($server, new WebServiceAuthentication(PluginManager::Instance()->LoadAuthentication(), new UserSessionRepository()));
$category = new SlimWebServiceRegistryCategory('Authentication');
$category->AddPost('SignOut/', array($webService, 'SignOut'), WebServices::Logout);
$category->AddPost('Authenticate/', array($webService, 'Authenticate'), WebServices::Login);
$registry->AddCategory($category);
}
function RegisterReservations(SlimServer $server, SlimWebServiceRegistry $registry)
{
$readService = new ReservationsWebService($server, new ReservationViewRepository(), new PrivacyFilter(new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization())), new AttributeService(new AttributeRepository()));
$writeService = new ReservationWriteWebService($server, new ReservationSaveController(new ReservationPresenterFactory()));
$category = new SlimWebServiceRegistryCategory('Reservations');
$category->AddSecurePost('/', array($writeService, 'Create'), WebServices::CreateReservation);
$category->AddSecureGet('/', array($readService, 'GetReservations'), WebServices::AllReservations);
$category->AddSecureGet('/:referenceNumber', array($readService, 'GetReservation'), WebServices::GetReservation);
$category->AddSecurePost('/:referenceNumber', array($writeService, 'Update'), WebServices::UpdateReservation);
$category->AddSecurePost('/:referenceNumber/Approval', array($writeService, 'Approve'), WebServices::ApproveReservation);
$category->AddSecurePost('/:referenceNumber/CheckIn', array($writeService, 'Checkin'), WebServices::CheckinReservation);
$category->AddSecurePost('/:referenceNumber/CheckOut', array($writeService, 'Checkout'), WebServices::CheckoutReservation);
$category->AddSecureDelete('/:referenceNumber', array($writeService, 'Delete'), WebServices::DeleteReservation);
$registry->AddCategory($category);
}
function RegisterResources(SlimServer $server, SlimWebServiceRegistry $registry)
{
$resourceRepository = new ResourceRepository();
$attributeService = new AttributeService(new AttributeRepository());
$webService = new ResourcesWebService($server, $resourceRepository, $attributeService, new ReservationViewRepository());
$writeWebService = new ResourcesWriteWebService($server, new ResourceSaveController($resourceRepository, new ResourceRequestValidator($attributeService)));
$category = new SlimWebServiceRegistryCategory('Resources');
$category->AddGet('/Status', array($webService, 'GetStatuses'), WebServices::GetStatuses);
$category->AddSecureGet('/', array($webService, 'GetAll'), WebServices::AllResources);
$category->AddSecureGet('/Status/Reasons', array($webService, 'GetStatusReasons'), WebServices::GetStatusReasons);
$category->AddSecureGet('/Availability', array($webService, 'GetAvailability'), WebServices::AllAvailability);
$category->AddSecureGet('/Groups', array($webService, 'GetGroups'), WebServices::GetResourceGroups);
$category->AddSecureGet('/:resourceId', array($webService, 'GetResource'), WebServices::GetResource);
$category->AddSecureGet('/:resourceId/Availability', array($webService, 'GetAvailability'), WebServices::GetResourceAvailability);
$category->AddAdminPost('/', array($writeWebService, 'Create'), WebServices::CreateResource);
$category->AddAdminPost('/:resourceId', array($writeWebService, 'Update'), WebServices::UpdateResource);
$category->AddAdminDelete('/:resourceId', array($writeWebService, 'Delete'), WebServices::DeleteResource);
$registry->AddCategory($category);
}
function RegisterAccessories(SlimServer $server, SlimWebServiceRegistry $registry)
{
$webService = new AccessoriesWebService($server, new ResourceRepository(), new AccessoryRepository());
$category = new SlimWebServiceRegistryCategory('Accessories');
$category->AddSecureGet('/', array($webService, 'GetAll'), WebServices::AllAccessories);
$category->AddSecureGet('/:accessoryId', array($webService, 'GetAccessory'), WebServices::GetAccessory);
$registry->AddCategory($category);
}
function RegisterUsers(SlimServer $server, SlimWebServiceRegistry $registry)
{
$attributeService = new AttributeService(new AttributeRepository());
$webService = new UsersWebService($server, new UserRepositoryFactory(), $attributeService);
$writeWebService = new UsersWriteWebService($server,
new UserSaveController(new ManageUsersServiceFactory(), new UserRequestValidator($attributeService, new UserRepository())));
$category = new SlimWebServiceRegistryCategory('Users');
$category->AddSecureGet('/', array($webService, 'GetUsers'), WebServices::AllUsers);
$category->AddSecureGet('/:userId', array($webService, 'GetUser'), WebServices::GetUser);
$category->AddAdminPost('/', array($writeWebService, 'Create'), WebServices::CreateUser);
$category->AddAdminPost('/:userId', array($writeWebService, 'Update'), WebServices::UpdateUser);
$category->AddAdminPost('/:userId/Password', array($writeWebService, 'UpdatePassword'), WebServices::UpdatePassword);
$category->AddAdminDelete('/:userId', array($writeWebService, 'Delete'), WebServices::DeleteUser);
$registry->AddCategory($category);
}
function RegisterSchedules(SlimServer $server, SlimWebServiceRegistry $registry)
{
$webService = new SchedulesWebService($server, new ScheduleRepository(), new PrivacyFilter(new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization())));
$category = new SlimWebServiceRegistryCategory('Schedules');
$category->AddSecureGet('/', array($webService, 'GetSchedules'), WebServices::AllSchedules);
$category->AddSecureGet('/:scheduleId', array($webService, 'GetSchedule'), WebServices::GetSchedule);
$category->AddSecureGet('/:scheduleId/Slots', array($webService, 'GetSlots'), WebServices::GetScheduleSlots);
$registry->AddCategory($category);
}
function RegisterAttributes(SlimServer $server, SlimWebServiceRegistry $registry)
{
$webService = new AttributesWebService($server, new AttributeService(new AttributeRepository()));
$writeWebService = new AttributesWriteWebService($server, new AttributeSaveController(new AttributeRepository()));
$category = new SlimWebServiceRegistryCategory('Attributes');
$category->AddSecureGet('Category/:categoryId', array($webService, 'GetAttributes'), WebServices::AllCustomAttributes);
$category->AddSecureGet('/:attributeId', array($webService, 'GetAttribute'), WebServices::GetCustomAttribute);
$category->AddAdminPost('/', array($writeWebService, 'Create'), WebServices::CreateCustomAttribute);
$category->AddAdminPost('/:attributeId', array($writeWebService, 'Update'), WebServices::UpdateCustomAttribute);
$category->AddAdminDelete('/:attributeId', array($writeWebService, 'Delete'), WebServices::DeleteCustomAttribute);
$registry->AddCategory($category);
}
function RegisterGroups(SlimServer $server, SlimWebServiceRegistry $registry)
{
$groupRepository = new GroupRepository();
$webService = new GroupsWebService($server, $groupRepository, $groupRepository);
$category = new SlimWebServiceRegistryCategory('Groups');
$category->AddSecureGet('/', array($webService, 'GetGroups'), WebServices::AllGroups);
$category->AddSecureGet('/:groupId', array($webService, 'GetGroup'), WebServices::GetGroup);
$registry->AddCategory($category);
}
| rafaelperazzo/ufca-web | booked/Web/Services/index.php | PHP | gpl-3.0 | 11,284 |
package com.avygeil.GrandVide;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class GVDatabaseHelper
{
private final GrandVide gv;
private final String url;
private final String driverClass;
private final String user;
private final String password;
public static String DB_REGIONS_SCHEME;
public static String DB_STATS_SCHEME;
public static String AUTOINCREMENT;
public static String NOCASE;
private Connection connection = null;
private Statement statement = null;
private PreparedStatement prepared = null;
GVDatabaseHelper(GrandVide grandvide)
{
this.gv = grandvide;
if (gv.configurationHandler.sqlDriver.equalsIgnoreCase("sqlite"))
{
url = "jdbc:sqlite:plugins/GrandVide/grandvide.db";
driverClass = "org.sqlite.JDBC";
user = "";
password = "";
AUTOINCREMENT = "AUTOINCREMENT";
NOCASE = "COLLATE NOCASE";
}
else if (gv.configurationHandler.sqlDriver.equalsIgnoreCase("mysql"))
{
url = "jdbc:mysql://" + gv.configurationHandler.mysqlHost + ":" + gv.configurationHandler.mysqlPort + "/" + gv.configurationHandler.mysqlDatabase;
driverClass = "com.mysql.jdbc.Driver";
user = gv.configurationHandler.mysqlUser;
password = gv.configurationHandler.mysqlPassword;
AUTOINCREMENT = "AUTO_INCREMENT";
NOCASE = "";
}
else
{
url = null;
driverClass = null;
user = null;
password = null;
AUTOINCREMENT = null;
NOCASE = null;
}
DB_REGIONS_SCHEME = "CREATE TABLE IF NOT EXISTS " + gv.configurationHandler.mysqlPrefix + "regions(id INTEGER PRIMARY KEY " + AUTOINCREMENT + ", name TEXT, world TEXT, container BLOB, teams BLOB, power BLOB)";
DB_STATS_SCHEME = "CREATE TABLE IF NOT EXISTS " + gv.configurationHandler.mysqlPrefix + "stats(id INTEGER PRIMARY KEY " + AUTOINCREMENT + ", player TEXT, kills INTEGER, deaths INTEGER, damage_dealt INTEGER, damage_taken INTEGER, block_break INTEGER, block_place INTEGER, games_joined INTEGER, games_finished INTEGER)";
}
public void setConnection() throws Exception
{
Class.forName(driverClass);
try
{
gv.getLogger().info("Connexion a " + url + "...");
connection = DriverManager.getConnection(url, user, password);
}
catch (SQLException e)
{
gv.getLogger().severe("Impossible d'etablir la connexion a la base de donnees");
throw e;
}
try
{
statement = connection.createStatement();
}
catch (Exception e)
{
try { connection.close(); } catch (Exception ignore) {}
connection = null;
gv.getLogger().severe("Une erreur s'est produite avec la base de donnees");
throw e;
}
}
public void closeConnection()
{
if (statement != null)
try { statement.close(); } catch (Exception ignore) {}
if (connection != null)
try { connection.close(); } catch (Exception ignore) {}
}
public void closeResultSet(ResultSet rs)
{
if (rs != null)
try { rs.close(); } catch (Exception ignore) {}
}
public void execute(String instruction) throws Exception
{
try
{
statement.executeUpdate(instruction);
}
catch (SQLException e)
{
gv.getLogger().warning("La demande SQL n'a pas pu etre executee");
throw new Exception(e.getMessage());
}
}
public ResultSet query(String query) throws Exception
{
try
{
return statement.executeQuery(query);
}
catch (SQLException e)
{
gv.getLogger().warning("La requete SQL n'a pas pu etre executee");
throw new Exception(e.getMessage());
}
}
public PreparedStatement getPrepared()
{
return prepared;
}
public void prepare(String query) throws Exception
{
try
{
prepared = connection.prepareStatement(query);
}
catch (SQLException e)
{
gv.getLogger().warning("La requete preparee SQL n'a pas pu etre executee");
throw new Exception(e.getMessage());
}
}
public void finalize() throws Exception
{
try
{
prepared.execute();
}
catch (SQLException e)
{
gv.getLogger().warning("La requete preparee SQL n'a pas pu etre finalisee");
throw new Exception(e.getMessage());
}
finally
{
if (prepared != null)
try { prepared.close(); } catch (Exception ignore) {}
}
}
}
| riking/GrandVide | src/com/avygeil/GrandVide/GVDatabaseHelper.java | Java | gpl-3.0 | 4,268 |
package cf.energizingcoalition.energizingcoalition.proxy;
public class ClientProxy extends CommonProxy
{
@Override
public void registerRenderers()
{
}
}
| energizingcoalition/energizingcoalition | src/main/java/cf/energizingcoalition/energizingcoalition/proxy/ClientProxy.java | Java | gpl-3.0 | 161 |
/* addition.cc
*
* KNOWN BUGS: will fail if entered with a tsp with identical pos_t's.
*
* nearest addition and fathest insertion, with initial convex hull and
* maximal angle selections for euclidean.
*
* orig ceh 12-91
*
* c++ conversion ceh 12-93
* added farthest insertion functionality 9-94
#define PRINTIT
*/
#define MAX_SUM_COST MAX_COST
/*
#define MAX_SUM_COST MAX_SUM
*/
#include "addition.h"
#include <assert.h>
inline void AdditionHeuristic :: internal_add(const city_id_t to,
city_id_t &from)
{
city_id_t i;
assert(to != NO_ID);
if (from == NO_ID) {
if (cities_traveled == degree)
i = last_traveled = to;
else
i = traveled[last_traveled];
from = last_traveled;
}
else
i = traveled[from];
#ifdef PRINTIT
dump.form("%6d put %d<-%d<-%d\n", (int)(matrix->val(to,traveled[from])
+matrix->val(from,to)-matrix->val(from,traveled[from])),
(int)traveled[from],(int)to,(int)from);
#endif
last_traveled = traveled[from] = to;
traveled[to] = i;
}
inline double AdditionHeuristic :: dot_product(const pos_t *p1, const pos_t *p2,
const pos_t *p3)
{
return (p1->x-p2->x)*(p3->x-p2->x) + (p1->y-p2->y)*(p3->y-p2->y);
}
inline void AdditionHeuristic :: farthest_internal_select(city_id_t &to,
city_id_t &from)
{
sum_t the_lowest, save_cost;
city_id_t *t, j;
cost_t *outcost;
/*
pos_t *p1;
*/
the_lowest = COST_MAX;
to = farthestcity;
/*
p1 = matrix->pos+to;
*/
for (t = traveled; t<traveled_end; t++) { /*2*/
if (*t == NO_ID)
continue;
outcost = matrix->cost[(city_id_t)(t-traveled)];
j = *t;
/*
save_cost = dot_product(matrix->pos+(t-traveled), p1, matrix->pos+j)
/ (outcost[to] * matrix->val(to,j));
*/
save_cost = matrix->val(to,j) + outcost[to] - outcost[j];
if (save_cost < the_lowest) {
the_lowest = save_cost;
from = (city_id_t)(t-traveled);
}
}
assert(the_lowest != COST_MAX);
}
// travel "to_travel" after city "from" in the tour so far
void AdditionHeuristic :: farthest_add(city_id_t to_travel)
{
cost_t farthestcost;
cost_t *fcost = nearcost, *outcost;
city_id_t *t, from = NO_ID;
if (to_travel == NO_ID)
farthest_internal_select(to_travel, from);
internal_add(to_travel, from);
if (--cities_traveled == 0)
return;
farthestcost = MIN_COST;
farthestcity = NO_ID;
outcost = matrix->cost[to_travel];
for (t = traveled; t<traveled_end; t++, fcost++) {
if (*t != NO_ID)
continue;
if (*fcost > outcost[(city_id_t)(t-traveled)])
*fcost = outcost[(city_id_t)(t-traveled)];
if (farthestcost < *fcost) {
farthestcost = *fcost;
farthestcity = (city_id_t)(t-traveled);
}
}
assert(nearestcity != NO_ID);
assert(farthestcity != NO_ID);
}
inline void AdditionHeuristic :: addition_internal_select(city_id_t &to,
city_id_t &from)
{
to = nearestcity;
from = farthestcity;
}
void AdditionHeuristic :: addition_add(city_id_t to_travel)
{
cost_t *ncost = nearcost, nearestcost;
cost_t back_cost, back_cost2, *outcost, *jcost, *outcost2, necost;
city_id_t *t, from = NO_ID, to_to, j, *fcity = farcity;
/*
pos_t *p1, *p2, *p3, *p4;
*/
if (to_travel == NO_ID)
addition_internal_select(to_travel, from);
internal_add(to_travel, from);
if (--cities_traveled == 0)
return;
assert(from != NO_ID);
nearestcost = MAX_SUM_COST;
nearestcity = NO_ID;
to_to = traveled[to_travel];
outcost = matrix->cost[to_travel];
outcost2 = matrix->cost[from];
/*
p1 = matrix->pos+from;
p3 = matrix->pos+to_travel;
p4 = matrix->pos+to_to;
*/
if (to_travel == to_to)
back_cost = 0;
else
back_cost = outcost[to_to];
if (to_travel == from)
back_cost2 = 0;
else
back_cost2 = outcost2[to_travel];
for (t = traveled; t<traveled_end; t++, ncost++, fcity++) {
if (*t != NO_ID)
continue;
j = (city_id_t)(t-traveled);
/*
p2 = matrix->pos+j;
*/
jcost = matrix->cost[j];
if (*fcity == from) {
city_id_t *tt;
for (*ncost = MAX_SUM_COST, tt = traveled; tt<traveled_end; tt++) {
if (*tt == NO_ID)
continue;
outcost = matrix->cost[(city_id_t)(tt-traveled)];
/*
p1 = matrix->pos+(tt-traveled);
p3 = matrix->pos+*tt;
necost = dot_product(p1, p2, p3)/(outcost[j] * jcost[*tt]);
*/
necost = outcost[j] + jcost[*tt] - outcost[*tt];
if (*ncost > necost) {
*ncost = necost;
*fcity = (city_id_t)(tt-traveled);
}
}
outcost = matrix->cost[to_travel];
/*
p1 = matrix->pos+from;
p3 = matrix->pos+to_travel;
*/
}
else {
/*
necost = dot_product(p3, p2, p4) / (outcost[j]*jcost[to_to]);
*/
necost = outcost[j] + jcost[to_to] - back_cost;
if (*ncost > necost) {
*ncost = necost;
*fcity = to_travel;
}
/*
necost = dot_product(p1, p2, p3) / (outcost2[j]*jcost[to_travel]);
*/
necost = outcost2[j] + jcost[to_travel] - back_cost2;
if (*ncost > necost) {
*ncost = necost;
*fcity = from;
}
}
if (nearestcost > *ncost) {
nearestcost = *ncost;
nearestcity = j;
farthestcity = *fcity;
}
}
assert(nearestcity != NO_ID);
}
/* Point *1*: find nearest (farthest) cities from tour cities.
*
* Point *2*: find best insertion of nearest (farthest) city
*/
int AdditionHeuristic :: run()
{
city_id_t k, l;
assert(cities_traveled != degree);
if (type == SPLIT_ADDITION) {
city_id_t *t, *tt, *fcity = farcity, j;
sum_t necost, nearestcost;
cost_t *ncost = nearcost, *outcost, *jcost;
while (cities_traveled > 3*degree/4)
(this->*to_add)(NO_ID);
nearestcost = MAX_SUM_COST;
for (t = traveled; t<traveled_end; t++, ncost++, fcity++) {
if (*t != NO_ID)
continue;
j = (city_id_t)(t-traveled);
jcost = matrix->cost[j];
for (*ncost = MAX_SUM_COST, tt = traveled; tt<traveled_end; tt++) {
if (*tt == NO_ID)
continue;
outcost = matrix->cost[(city_id_t)(tt-traveled)];
necost = outcost[j] + jcost[*tt] - outcost[*tt];
if (*ncost > necost) {
*fcity = (city_id_t)(tt-traveled);
if (nearestcost > (*ncost = necost)) {
nearestcost = necost;
nearestcity = j;
farthestcity = *fcity;
}
}
}
}
to_add = &AdditionHeuristic::addition_add;
}
while (cities_traveled)
(this->*to_add)(NO_ID);
for (k = l = 0; l<degree; l++)
tour->travel(k = traveled[k]);
return 0;
}
/* Define a struct to hold positions and sites to be sorted by qsort
*/
class poses_t {
public:
inline poses_t() {};
pos_t pos;
city_id_t site;
};
/* compare_poses
*
* the compare function to pass to qsort to sort the list of all edges
*/
static int compare_poses(const void *p1, const void *p2)
{
double t = (((poses_t *)p1)->pos.x - ((poses_t *)p2)->pos.x);
if (t > 0.0)
return 1;
if (t < 0.0)
return -1;
return 0;
}
/* LINE_T
*
* a line structure to be a part of a convex hull, with slope and
* y-intercept.
*/
class line_t {
public:
inline line_t() {};
double slope;
double y_intercept;
poses_t *last_pose;
city_id_t site;
};
#define MAX_LINES 100
/* HULL_T
*
* a convex hull structure, 4 of which are created to drape around the
* set of points at the four corners..
*/
class hull_t {
public:
inline hull_t() {};
line_t lines[MAX_LINES];
short line;
poses_t *last_pose;
void add_line_to_hull(poses_t *pose);
void climb_under_hull(poses_t *end_pose, int inc);
void climb_over_hull(poses_t *end_pose, int inc);
};
/* add_line_to_hull
*
* simply add a line to the end of the hull, that will connect the new point
* to the last point in the hull
*/
void hull_t :: add_line_to_hull(poses_t *pose)
{
line_t *h_line = lines+line;
double save;
h_line->site = pose->site;
if ((save = pose->pos.x-last_pose->pos.x) == 0.0) {
h_line->slope = FLOAT_MAX;
h_line->y_intercept = FLOAT_MAX;
}
else {
h_line->slope = (pose->pos.y-last_pose->pos.y) / save;
h_line->y_intercept = pose->pos.y - (h_line->slope * pose->pos.x);
}
lines[line++].last_pose = last_pose;
assert (line <= MAX_LINES);
last_pose = pose;
}
/* Macros to determine if a line is higher/lower than a point
*
* Note the '>' and '<' are warped because pixels are upside down from
* a mathematical graph...
*/
#define line_lower(line,point) \
((point)->pos.y > \
(((line)->slope)*((point)->pos.x)) + (line)->y_intercept)
#define line_higher(line,point) \
((point)->pos.y < \
(((line)->slope)*((point)->pos.x)) + (line)->y_intercept)
/* climb_hull()
*
* here we try to all lines to hull until we reach the maximum point.
*
* end_pose
* we are given a hull with a single line in it that *_2_*
* represents the lower edge, we then insert convex \1
* lines until we reach the upper edge..... pose*
* \0
* climb_over_hull() will climb over the edges assumnig you *
* start from a side and want to convex up. climb_under_hull()
* will climb under, if you wish to cover the underside of points
* once started for the side most point.
*/
void hull_t :: climb_over_hull(poses_t *end_pose, int inc)
{
short here_line = (short)(line-1);
poses_t *pose = last_pose, *last_pose = pose;
/* HI stuff ONLY */
while (pose != end_pose) {
pose += inc;
if (pose->pos.y < last_pose->pos.y) /* if point is lower than last line */
continue; /* then the point isn't worth it */
/* find a line in hull which will enable a convex line
*/
if (here_line >= 0) {
while (line_lower(lines+here_line, pose)) {
if (--here_line<0)
break;
}
}
if (line != ++here_line) {
last_pose = lines[here_line].last_pose;
line = here_line;
}
add_line_to_hull(pose);
last_pose = pose;
}
}
/* the only difference in the function below (climb_under_hull)() and the
* function above is the line where "line_lower" is replaced by "line_higher"
*
*/
void hull_t :: climb_under_hull(poses_t *end_pose, int inc)
{
short here_line = (short)(line-1);
poses_t *pose = last_pose, *last_pose = pose;
/* HI stuff ONLY */
while (pose != end_pose) {
pose += inc;
if (pose->pos.y > last_pose->pos.y) /* if point is lower than last line */
continue; /* then the point isn't worth it */
/* find a line in hull which will enable a convex line
*/
if (here_line >= 0) {
while (line_higher(lines+here_line, pose)) {
if (--here_line<0)
break;
}
}
if (line != ++here_line) {
last_pose = lines[here_line].last_pose;
line = here_line;
}
add_line_to_hull(pose);
last_pose = pose;
}
}
int AdditionHeuristic :: can_run(const Matrix *) const
{
return 1;
}
AdditionHeuristic :: ~AdditionHeuristic()
{
delete traveled;
delete nearcost;
}
#define HILEFT (Hulls[0])
#define LOLEFT (Hulls[1])
#define HIRIGHT (Hulls[2])
#define LORIGHT (Hulls[3])
// hull_t HILEFT, LOLEFT, HIRIGHT, LORIGHT;
AdditionHeuristic :: AdditionHeuristic(const Matrix *m, int ty) : TourFinder(m)
{
cost_t *ncost;
city_id_t x, x_high, x_low, *t;
poses_t *y_highest = NULL, *y_lowest = NULL, *poses;
double highest_y = 0., lowest_y = COST_MAX;
double save;
short line_right;
switch (ty&TYPEMASK_ADDITION) {
case SPLIT_ADDITION: case FARTHEST_ADDITION:
to_add = &AdditionHeuristic::farthest_add;
break;
case ANGLE_ADDITION:
/*
if (m->is_geometric_2d())
to_add = angle_add;
else
to_add = addition_add;
break;
*/
default:
case NORMAL_ADDITION: to_add = &AdditionHeuristic::addition_add; break;
}
type = ty;
ncost = nearcost = new cost_t[degree];
traveled = new city_id_t[degree*2];
farcity = traveled+degree;
traveled_end = traveled+degree;
for (t = traveled; t<traveled_end; t++, ncost++) {
*t = NO_ID;
*ncost = MAX_SUM_COST;
}
cities_traveled = degree;
farthestcity = NO_ID;
if (!m->is_geometric_2d() || degree < 4) {
city_id_t init;
init = param.initial_choice;
if (init == NO_ID)
init = 0;
(this->*to_add)(init);
return;
}
poses = new poses_t[degree];
for (x = 0; x<degree; x++) {
poses[x].site = x;
poses[x].pos = matrix->pos[x];
}
qsort(poses, (size_t)degree, (size_t)sizeof(poses_t), compare_poses);
for (x = 0; x<degree; x++) {
save = poses[x].pos.y;
if (save > highest_y) {
highest_y = save;
y_highest = poses+x;
}
if (save < lowest_y) {
lowest_y = save;
y_lowest = poses+x;
}
#ifdef PRINTIT
dump.form("%d at (%lf,%lf) %lx\n", (int)poses[x].site, poses[x].pos.x,
save, (long)(poses+x));
#endif
}
assert(y_lowest != NULL && y_highest != NULL);
/* Initialize the four hulls that will drape the points...
* HIRIGHT is the upper right corner, LOLEFT is the lower left corner
* the LORIGHT is in mathematical quadrant I.
*/
hull_t *Hulls = new hull_t[4];
HIRIGHT.line = HILEFT.line = LORIGHT.line = LOLEFT.line = 0;
HIRIGHT.last_pose = poses+(degree-1);
LORIGHT.last_pose = poses+(degree-1);
HILEFT.last_pose = poses;
LOLEFT.last_pose = poses;
x_high = (poses+(degree-1))->site;
x_low = (poses)->site;
HIRIGHT.climb_over_hull(y_highest, -1);
HILEFT.climb_over_hull(y_highest, 1);
LORIGHT.climb_under_hull(y_lowest, -1);
LOLEFT.climb_under_hull(y_lowest, 1);
delete poses;
line_right = 0;
if (HIRIGHT.line>0) { /* Only do if there is >1 line(s) */
(this->*to_add)(x_high);
while (line_right < HIRIGHT.line-1) {
(this->*to_add)(HIRIGHT.lines[line_right].site);
line_right++;
}
}
line_right = (short)(HILEFT.line-1);
while (line_right >= 0) {
(this->*to_add)(HILEFT.lines[line_right].site);
line_right--;
}
line_right = 0;
if (LOLEFT.line>0) { /* Only do if there is >1 line(s) */
(this->*to_add)(x_low);
while (line_right < LOLEFT.line-1) {
(this->*to_add)(LOLEFT.lines[line_right].site);
line_right++;
}
}
line_right = (short)(LORIGHT.line-1);
while (line_right >= 0) {
(this->*to_add)(LORIGHT.lines[line_right].site);
line_right--;
}
delete Hulls;
}
| catacopil/memoco-course-project | letteratura/tsp_solve-1.3.6/addition.cc | C++ | gpl-3.0 | 15,119 |
/*
* @Date : Shandagames2018/09/02
* @Author : IceCory (icecory520@gmail.com)
* @Copyright(C): GPL 3.0
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
// 输入三元组(x,y,z)数量n
// 一个值a
// logn 的复杂度内找到所有的三元组(满足 y <= a <= z)并升序输出x
int main(int argc, char *argv[]) {
using LogType = std::tuple<int, int, int>;
size_t t = 0;
std::cin >> t;
int a;
std::cin >> a;
std::vector<LogType> log;
log.reserve(10000);
for (size_t i = 0; i < t; ++i) {
int x, y, z;
std::cin >> x >> y >> z;
log.emplace_back(x, y, z);
}
auto cmp = [](const LogType &l1, const LogType &l2) -> bool {
if (std::get<1>(l1) != std::get<1>(l2))
return std::get<1>(l1) < std::get<1>(l2);
if (std::get<2>(l1) != std::get<2>(l2))
return std::get<2>(l1) < std::get<2>(l2);
};
std::sort(log.begin(), log.end(), cmp);
auto A = std::make_tuple(0, a, -1);
auto iter = std::upper_bound(log.begin(), log.end(), A, cmp);
std::vector<int> ans;
auto iter1 = iter;
ans.reserve(10000);
while (iter1 != log.end()) {
if (a > std::get<2>(*iter))break;
if (a < std::get<1>(*iter))break;
ans.push_back(std::get<0>(*iter));
iter1++;
}
iter--;
while (iter != log.begin()) {
if (a > std::get<2>(*iter))break;
if (a < std::get<1>(*iter))break;
ans.push_back(std::get<0>(*iter));
iter--;
if (iter == log.begin()) {
if (std::get<1>(*iter) <= a <= std::get<2>(*iter))ans.push_back(std::get<0>(*iter));
}
}
std::sort(ans.begin(), ans.end(), std::less<int>());
for (auto &i:ans) {
std::cout << i << std::endl;
}
// std::cout << ans << std::endl;
return 0;
} | bitwater1997/ACM | Contest/Ctrip2018/2.cpp | C++ | gpl-3.0 | 1,874 |
import os
import re
import sys
"""
* Perform initial configuration to ensure that the server is set up to work with Burton's format
sudo chown -R ubuntu:ubuntu /var/www
mkdir -p /var/www/default/public_html
mv /var/www/html/index.html /var/www/default/public_html # Ubuntu >=14.04
mv /var/www/index.html /var/www/default/public_html # Ubuntu <14.04
rm -rf /var/www/html
sudo vim /etc/apache2/sites-available/000-default.conf # Ubuntu >=14.04
sudo vim /etc/apache2/sites-available/default # Ubuntu <14.04
sudo a2enmod ssl
sudo service apache2 restart
* Enable / disable .htaccess for a site
* PHP configuration
"""
environment = ''
def main(env):
global environment
environment = env
while True:
print("\nConfigure Websites\n")
print("Please select an operation:")
print(" 1. Restart Apache")
print(" 2. Add a new website")
print(" 3. Add SSL to website")
print(" 0. Go Back")
print(" -. Exit")
operation = input(environment.prompt)
if operation == '0':
return True
elif operation == '-':
sys.exit()
elif operation == '1':
restart_apache()
elif operation == '2':
add_website()
elif operation == '3':
add_ssl()
else:
print("Invalid input.")
def restart_apache():
print("\nAttempting to restart Apache:")
# TODO: Print an error when the user does not have permissions to perform the action.
result = os.system("sudo service apache2 restart")
print(result)
return True
def add_website():
global environment
print('\nAdd website.\n')
input_file = open('./example-files/apache-site', 'r')
input_file_text = input_file.read()
input_file.close()
site_name = input('Website name (without www or http)' + environment.prompt)
new_filename = '/etc/apache2/sites-available/%s.conf' % (site_name,)
tmp_filename = '/tmp/%s.conf' % (site_name,)
# TODO: Check that site_name is legal for both a domain name and a filename.
while os.path.isfile(new_filename):
print('Site exists! Please choose another.')
site_name = input('Website name (without www or http)' + environment.prompt)
new_filename = '/etc/apache2/sites-available/%s.conf' % (site_name,)
tmp_filename = '/tmp/%s.conf' % (site_name,)
new_config = re.sub('SITE', site_name, input_file_text)
try:
output_file = open(tmp_filename, 'w')
output_file.write(new_config)
output_file.close()
tmp_move = os.system("sudo mv %s %s" % (tmp_filename, new_filename))
except PermissionError as e:
print('\n\nError!')
print('The current user does not have permission to perform this action.')
#print('Please run Burton with elevated permissions to resolve this error.\n\n')
if tmp_move != 0:
print('\n\nError!')
print('The current user does not have permission to perform this action.')
#print('Please run Burton with elevated permissions to resolve this error.\n\n')
current_user = str(os.getuid())
result = os.system('sudo mkdir -p /var/www/%s/public_html/' % (site_name,))
result = os.system('sudo mkdir -p /var/www/%s/logs/' % (site_name,))
result = os.system('sudo chown -R %s:%s /var/www/%s/' % (current_user, current_user,))
result = os.system('sudo a2ensite %s.conf' % (site_name,))
restart_apache()
return True
def add_ssl():
global environment
print("\nAdd SSL to website.\n")
print("Please enter the URL of the website.\n")
site_name = input(environment.prompt)
print("Is this a wildcard certificate? (y/N)\n")
wildcard = input(environment.prompt)
if wildcard.lower()=='y':
print("Generating wildcard cert for *.%s" % (site_name,))
wildcard = '*.'
else:
print("Generating cert for %s" % (site_name,))
wildcard = ''
# http://serverfault.com/questions/649990/non-interactive-creation-of-ssl-certificate-requests
#command_template = 'openssl req -new -newkey rsa:2048 -nodes -sha256 -keyout foobar.com.key -out foobar.com.csr -subj "/C=US/ST=New foobar/L=foobar/O=foobar foobar, Inc./CN=foobar.com/emailAddress=foobar@foobar.com"'
command_template = "openssl req -new -newkey rsa:2048 -nodes -sha256 -keyout %s.key -out %s.csr -subj \"/CN=%s%s\""
print(command_template % (site_name, site_name, wildcard, site_name))
return True
| dotancohen/burton | configure_websites.py | Python | gpl-3.0 | 4,169 |
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.command;
import com.sk89q.minecraft.util.commands.CommandException;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Thrown when a command is not used properly.
*
* <p>When handling this exception, print the error message if it is not null.
* Print a one line help instruction unless {@link #isFullHelpSuggested()}
* is true, which, in that case, the full help of the command should be
* shown.</p>
*
* <p>If no error message is set and full help is not to be shown, then a generic
* "you used this command incorrectly" message should be shown.</p>
*/
@SuppressWarnings("serial")
public class InvalidUsageException extends CommandException {
private final CommandCallable command;
private final boolean fullHelpSuggested;
/**
* Create a new instance with no error message and with no suggestion
* that full and complete help for the command should be shown. This will
* result in a generic error message.
*
* @param command the command
*/
public InvalidUsageException(CommandCallable command) {
this(null, command);
}
/**
* Create a new instance with a message and with no suggestion
* that full and complete help for the command should be shown.
*
* @param message the message
* @param command the command
*/
public InvalidUsageException(@Nullable String message, CommandCallable command) {
this(message, command, false);
}
/**
* Create a new instance with a message.
*
* @param message the message
* @param command the command
* @param fullHelpSuggested true if the full help for the command should be shown
*/
public InvalidUsageException(@Nullable String message, CommandCallable command, boolean fullHelpSuggested) {
super(message);
checkNotNull(command);
this.command = command;
this.fullHelpSuggested = fullHelpSuggested;
}
/**
* Get the command.
*
* @return the command
*/
public CommandCallable getCommand() {
return command;
}
/**
* Get a simple usage string.
*
* @param prefix the command shebang (such as "/") -- may be blank
* @return a usage string
*/
public String getSimpleUsageString(String prefix) {
return getCommandUsed(prefix, command.getDescription().getUsage());
}
/**
* Return whether the full usage of the command should be shown.
*
* @return show full usage
*/
public boolean isFullHelpSuggested() {
return fullHelpSuggested;
}
}
| UnlimitedFreedom/UF-WorldEdit | worldedit-core/src/main/java/com/sk89q/worldedit/util/command/InvalidUsageException.java | Java | gpl-3.0 | 3,497 |
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^(\d+)/$', 'onpsx.gallery.views.index'),
(r'^$', 'onpsx.gallery.views.index'),
)
| chrizel/onpsx | src/onpsx/gallery/urls.py | Python | gpl-3.0 | 160 |
# -*- coding: utf-8 -*-
#
# Copyright (C) Pootle contributors.
#
# This file is a part of the Pootle project. It is distributed under the GPL3
# or later license. See the LICENSE file for a copy of the license and the
# AUTHORS file for copyright and authorship information.
import io
import os
import six
import pytest
from pytest_pootle.factories import (
LanguageDBFactory, ProjectDBFactory, StoreDBFactory,
TranslationProjectFactory)
from pytest_pootle.utils import update_store
from translate.storage.factory import getclass
from django.db.models import Max
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import SimpleUploadedFile
from pootle.core.delegate import (
config, format_classes, format_diffs, formats)
from pootle.core.models import Revision
from pootle.core.delegate import deserializers, serializers
from pootle.core.url_helpers import to_tp_relative_path
from pootle.core.plugin import provider
from pootle.core.serializers import Serializer, Deserializer
from pootle_app.models import Directory
from pootle_config.exceptions import ConfigurationError
from pootle_format.exceptions import UnrecognizedFiletype
from pootle_format.formats.po import PoStoreSyncer
from pootle_format.models import Format
from pootle_language.models import Language
from pootle_project.models import Project
from pootle_statistics.models import (
SubmissionFields, SubmissionTypes)
from pootle_store.constants import (
NEW, OBSOLETE, PARSED, POOTLE_WINS, TRANSLATED)
from pootle_store.diff import DiffableStore, StoreDiff
from pootle_store.models import Store
from pootle_store.util import parse_pootle_revision
from pootle_translationproject.models import TranslationProject
def _update_from_upload_file(store, update_file,
content_type="text/x-gettext-translation",
user=None, submission_type=None):
with open(update_file, "r") as f:
upload = SimpleUploadedFile(os.path.basename(update_file),
f.read(),
content_type)
test_store = getclass(upload)(upload.read())
store_revision = parse_pootle_revision(test_store)
store.update(test_store, store_revision=store_revision,
user=user, submission_type=submission_type)
def _store_as_string(store):
ttk = store.syncer.convert(store.syncer.file_class)
if hasattr(ttk, "updateheader"):
# FIXME We need those headers on import
# However some formats just don't support setting metadata
ttk.updateheader(
add=True, X_Pootle_Path=store.pootle_path)
ttk.updateheader(
add=True, X_Pootle_Revision=store.get_max_unit_revision())
return str(ttk)
@pytest.mark.django_db
def test_delete_mark_obsolete(project0_nongnu, project0, store0):
"""Tests that the in-DB Store and Directory are marked as obsolete
after the on-disk file ceased to exist.
Refs. #269.
"""
tp = TranslationProjectFactory(
project=project0, language=LanguageDBFactory())
store = StoreDBFactory(
translation_project=tp,
parent=tp.directory)
store.update(store.deserialize(store0.serialize()))
store.sync()
pootle_path = store.pootle_path
# Remove on-disk file
os.remove(store.file.path)
# Update stores by rescanning TP
tp.scan_files()
# Now files that ceased to exist should be marked as obsolete
updated_store = Store.objects.get(pootle_path=pootle_path)
assert updated_store.obsolete
# The units they contained are obsolete too
assert not updated_store.units.exists()
assert updated_store.unit_set.filter(state=OBSOLETE).exists()
obs_unit = updated_store.unit_set.filter(state=OBSOLETE).first()
obs_unit.submission_set.count() == 0
@pytest.mark.django_db
def test_sync(project0_nongnu, project0, store0):
"""Tests that the new on-disk file is created after sync for existing
in-DB Store if the corresponding on-disk file ceased to exist.
"""
tp = TranslationProjectFactory(
project=project0, language=LanguageDBFactory())
store = StoreDBFactory(
translation_project=tp,
parent=tp.directory)
store.update(store.deserialize(store0.serialize()))
assert not store.file.exists()
store.sync()
assert store.file.exists()
os.remove(store.file.path)
assert not store.file.exists()
store.sync()
assert store.file.exists()
@pytest.mark.django_db
def test_update_from_ts(store0, test_fs, member):
store0.parsed = True
orig_units = store0.units.count()
existing_created_at = store0.units.aggregate(
Max("creation_time"))["creation_time__max"]
existing_mtime = store0.units.aggregate(
Max("mtime"))["mtime__max"]
old_revision = store0.data.max_unit_revision
with test_fs.open(['data', 'ts', 'tutorial', 'en', 'tutorial.ts']) as f:
store = getclass(f)(f.read())
store0.update(
store,
submission_type=SubmissionTypes.UPLOAD,
user=member)
assert not store0.units[orig_units].hasplural()
unit = store0.units[orig_units + 1]
assert unit.submission_set.count() == 0
assert unit.hasplural()
assert unit.creation_time >= existing_created_at
assert unit.creation_time >= existing_mtime
unit_source = unit.unit_source
assert unit_source.created_with == SubmissionTypes.UPLOAD
assert unit_source.created_by == member
assert unit.change.changed_with == SubmissionTypes.UPLOAD
assert unit.change.submitted_by == member
assert unit.change.submitted_on >= unit.creation_time
assert unit.change.reviewed_by is None
assert unit.change.reviewed_on is None
assert unit.revision > old_revision
@pytest.mark.django_db
def test_update_ts_plurals(store_po, test_fs, ts):
project = store_po.translation_project.project
filetype_tool = project.filetype_tool
project.filetypes.add(ts)
filetype_tool.set_store_filetype(store_po, ts)
with test_fs.open(['data', 'ts', 'add_plurals.ts']) as f:
file_store = getclass(f)(f.read())
store_po.update(file_store)
unit = store_po.units[0]
assert unit.hasplural()
assert unit.submission_set.count() == 0
with test_fs.open(['data', 'ts', 'update_plurals.ts']) as f:
file_store = getclass(f)(f.read())
store_po.update(file_store)
unit = store_po.units[0]
assert unit.hasplural()
assert unit.submission_set.count() == 1
update_sub = unit.submission_set.first()
assert update_sub.revision == unit.revision
assert update_sub.creation_time == unit.change.submitted_on
assert update_sub.submitter == unit.change.submitted_by
assert update_sub.new_value == unit.target
assert update_sub.type == unit.change.changed_with
assert update_sub.field == SubmissionFields.TARGET
# this fails 8(
# from pootle.core.utils.multistring import unparse_multistring
# assert (
# unparse_multistring(update_sub.new_value)
# == unparse_multistring(unit.target))
@pytest.mark.django_db
def test_update_with_non_ascii(store0, test_fs):
store0.state = PARSED
orig_units = store0.units.count()
path = 'data', 'po', 'tutorial', 'en', 'tutorial_non_ascii.po'
with test_fs.open(path) as f:
store = getclass(f)(f.read())
store0.update(store)
last_unit = store0.units[orig_units]
updated_target = "Hèḽḽě, ŵôrḽḓ"
assert last_unit.target == updated_target
assert last_unit.submission_set.count() == 0
# last_unit.target = "foo"
# last_unit.save()
# this should now have a submission with the old target
# but it fails
# assert last_unit.submission_set.count() == 1
# update_sub = last_unit.submission_set.first()
# assert update_sub.old_value == updated_target
# assert update_sub.new_value == "foo"
@pytest.mark.django_db
def test_update_unit_order(project0_nongnu, ordered_po, ordered_update_ttk):
"""Tests unit order after a specific update.
"""
# Set last sync revision
ordered_po.sync()
assert ordered_po.file.exists()
expected_unit_list = ['1->2', '2->4', '3->3', '4->5']
updated_unit_list = [unit.unitid for unit in ordered_po.units]
assert expected_unit_list == updated_unit_list
original_revision = ordered_po.get_max_unit_revision()
ordered_po.update(
ordered_update_ttk,
store_revision=original_revision)
expected_unit_list = [
'X->1', '1->2', '3->3', '2->4',
'4->5', 'X->6', 'X->7', 'X->8']
updated_unit_list = [unit.unitid for unit in ordered_po.units]
assert expected_unit_list == updated_unit_list
unit = ordered_po.units.first()
assert unit.revision > original_revision
assert unit.submission_set.count() == 0
@pytest.mark.django_db
def test_update_save_changed_units(project0_nongnu, store0, member, system):
"""Tests that any update saves changed units only.
"""
# not sure if this is testing anything
store = store0
# Set last sync revision
store.sync()
store.update(store.file.store)
unit_list = list(store.units)
store.file = 'tutorial/ru/update_save_changed_units_updated.po'
store.update(store.file.store, user=member)
updated_unit_list = list(store.units)
# nothing changed
for index in range(0, len(unit_list)):
unit = unit_list[index]
updated_unit = updated_unit_list[index]
assert unit.revision == updated_unit.revision
assert unit.mtime == updated_unit.mtime
assert unit.target == updated_unit.target
@pytest.mark.django_db
def test_update_set_last_sync_revision(project0_nongnu, tp0, store0, test_fs):
"""Tests setting last_sync_revision after store creation.
"""
unit = store0.units.first()
unit.target = "UPDATED TARGET"
unit.save()
store0.sync()
# Store is already parsed and store.last_sync_revision should be equal to
# max unit revision
assert store0.last_sync_revision == store0.get_max_unit_revision()
# store.last_sync_revision is not changed after empty update
saved_last_sync_revision = store0.last_sync_revision
store0.updater.update_from_disk()
assert store0.last_sync_revision == saved_last_sync_revision
orig = str(store0)
update_file = test_fs.open(
"data/po/tutorial/ru/update_set_last_sync_revision_updated.po",
"r")
with update_file as sourcef:
with open(store0.file.path, "wb") as targetf:
targetf.write(sourcef.read())
store0 = Store.objects.get(pk=store0.pk)
# any non-empty update sets last_sync_revision to next global revision
next_revision = Revision.get() + 1
store0.updater.update_from_disk()
assert store0.last_sync_revision == next_revision
# store.last_sync_revision is not changed after empty update (even if it
# has unsynced units)
item_index = 0
next_unit_revision = Revision.get() + 1
dbunit = store0.units.first()
dbunit.target = "ANOTHER DB TARGET UPDATE"
dbunit.save()
assert dbunit.revision == next_unit_revision
store0.updater.update_from_disk()
assert store0.last_sync_revision == next_revision
# Non-empty update sets store.last_sync_revision to next global revision
# (even the store has unsynced units). There is only one unsynced unit in
# this case so its revision should be set next to store.last_sync_revision
next_revision = Revision.get() + 1
with open(store0.file.path, "wb") as targetf:
targetf.write(orig)
store0 = Store.objects.get(pk=store0.pk)
store0.updater.update_from_disk()
assert store0.last_sync_revision == next_revision
# Get unsynced unit in DB. Its revision should be greater
# than store.last_sync_revision to allow to keep this change during
# update from a file
dbunit = store0.units[item_index]
assert dbunit.revision == store0.last_sync_revision + 1
@pytest.mark.django_db
def test_update_upload_defaults(store0, system):
store0.state = PARSED
unit = store0.units.first()
original_revision = unit.revision
last_sub_pk = unit.submission_set.order_by(
"id").values_list("id", flat=True).last() or 0
update_store(
store0,
[(unit.source, "%s UPDATED" % unit.source, False)],
store_revision=Revision.get() + 1)
unit = store0.units[0]
assert unit.change.submitted_by == system
assert unit.change.submitted_on >= unit.creation_time
assert unit.change.submitted_by == system
assert (
unit.submission_set.last().type
== SubmissionTypes.SYSTEM)
assert unit.revision > original_revision
new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id")
# there should be 2 new subs - state_change and target_change
new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id")
assert new_subs.count() == 2
target_sub = new_subs[0]
assert target_sub.old_value == ""
assert target_sub.new_value == unit.target
assert target_sub.field == SubmissionFields.TARGET
assert target_sub.type == SubmissionTypes.SYSTEM
assert target_sub.submitter == system
assert target_sub.revision == unit.revision
assert target_sub.creation_time == unit.change.submitted_on
state_sub = new_subs[1]
assert state_sub.old_value == "0"
assert state_sub.new_value == "200"
assert state_sub.field == SubmissionFields.STATE
assert state_sub.type == SubmissionTypes.SYSTEM
assert state_sub.submitter == system
assert state_sub.revision == unit.revision
assert state_sub.creation_time == unit.change.submitted_on
@pytest.mark.django_db
def test_update_upload_member_user(store0, system, member):
store0.state = PARSED
original_unit = store0.units.first()
original_revision = original_unit.revision
last_sub_pk = original_unit.submission_set.order_by(
"id").values_list("id", flat=True).last() or 0
update_store(
store0,
[(original_unit.source, "%s UPDATED" % original_unit.source, False)],
user=member,
store_revision=Revision.get() + 1,
submission_type=SubmissionTypes.UPLOAD)
unit = store0.units[0]
assert unit.change.submitted_by == member
assert unit.change.changed_with == SubmissionTypes.UPLOAD
assert unit.change.submitted_on >= unit.creation_time
assert unit.change.reviewed_on is None
assert unit.revision > original_revision
unit_source = unit.unit_source
unit_source.created_by == system
unit_source.created_with == SubmissionTypes.SYSTEM
# there should be 2 new subs - state_change and target_change
new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id")
assert new_subs.count() == 2
target_sub = new_subs[0]
assert target_sub.old_value == ""
assert target_sub.new_value == unit.target
assert target_sub.field == SubmissionFields.TARGET
assert target_sub.type == SubmissionTypes.UPLOAD
assert target_sub.submitter == member
assert target_sub.revision == unit.revision
assert target_sub.creation_time == unit.change.submitted_on
state_sub = new_subs[1]
assert state_sub.old_value == "0"
assert state_sub.new_value == "200"
assert state_sub.field == SubmissionFields.STATE
assert state_sub.type == SubmissionTypes.UPLOAD
assert state_sub.submitter == member
assert state_sub.revision == unit.revision
assert state_sub.creation_time == unit.change.submitted_on
@pytest.mark.django_db
def test_update_upload_submission_type(store0):
store0.state = PARSED
unit = store0.units.first()
last_sub_pk = unit.submission_set.order_by(
"id").values_list("id", flat=True).last() or 0
update_store(
store0,
[(unit.source, "%s UPDATED" % unit.source, False)],
submission_type=SubmissionTypes.UPLOAD,
store_revision=Revision.get() + 1)
unit_source = store0.units[0].unit_source
unit_change = store0.units[0].change
assert unit_source.created_with == SubmissionTypes.SYSTEM
assert unit_change.changed_with == SubmissionTypes.UPLOAD
# there should be 2 new subs - state_change and target_change
# and both should show as by UPLOAD
new_subs = unit.submission_set.filter(id__gt=last_sub_pk)
assert (
list(new_subs.values_list("type", flat=True))
== [SubmissionTypes.UPLOAD] * 2)
@pytest.mark.django_db
def test_update_upload_new_revision(store0, member):
original_revision = store0.data.max_unit_revision
old_unit = store0.units.first()
update_store(
store0,
[("Hello, world", "Hello, world UPDATED", False)],
submission_type=SubmissionTypes.UPLOAD,
store_revision=Revision.get() + 1,
user=member)
old_unit.refresh_from_db()
assert old_unit.state == OBSOLETE
assert len(store0.units) == 1
unit = store0.units[0]
unit_source = unit.unit_source
assert unit.revision > original_revision
assert unit_source.created_by == member
assert unit.change.submitted_by == member
assert unit.creation_time == unit.change.submitted_on
assert unit.change.reviewed_by is None
assert unit.change.reviewed_on is None
assert unit.target == "Hello, world UPDATED"
assert unit.submission_set.count() == 0
@pytest.mark.django_db
def test_update_upload_again_new_revision(store0, member, member2):
store = store0
assert store.state == NEW
original_unit = store0.units[0]
update_store(
store,
[("Hello, world", "Hello, world UPDATED", False)],
submission_type=SubmissionTypes.UPLOAD,
store_revision=Revision.get() + 1,
user=member)
original_unit.refresh_from_db()
assert original_unit.state == OBSOLETE
store = Store.objects.get(pk=store0.pk)
assert store.state == PARSED
created_unit = store.units[0]
assert created_unit.target == "Hello, world UPDATED"
assert created_unit.state == TRANSLATED
assert created_unit.submission_set.count() == 0
old_unit_revision = store.data.max_unit_revision
update_store(
store0,
[("Hello, world", "Hello, world UPDATED AGAIN", False)],
submission_type=SubmissionTypes.WEB,
user=member2,
store_revision=Revision.get() + 1)
assert created_unit.submission_set.count() == 1
update_sub = created_unit.submission_set.first()
store = Store.objects.get(pk=store0.pk)
assert store.state == PARSED
unit = store.units[0]
unit_source = unit.unit_source
assert unit.revision > old_unit_revision
assert unit.target == "Hello, world UPDATED AGAIN"
assert unit_source.created_by == member
assert unit_source.created_with == SubmissionTypes.UPLOAD
assert unit.change.submitted_by == member2
assert unit.change.submitted_on >= unit.creation_time
assert unit.change.reviewed_by is None
assert unit.change.reviewed_on is None
assert unit.change.changed_with == SubmissionTypes.WEB
assert update_sub.creation_time == unit.change.submitted_on
assert update_sub.type == unit.change.changed_with
assert update_sub.field == SubmissionFields.TARGET
assert update_sub.submitter == unit.change.submitted_by
assert update_sub.old_value == created_unit.target
assert update_sub.new_value == unit.target
assert update_sub.revision == unit.revision
@pytest.mark.django_db
def test_update_upload_old_revision_unit_conflict(store0, admin, member):
original_revision = Revision.get()
original_unit = store0.units[0]
update_store(
store0,
[("Hello, world", "Hello, world UPDATED", False)],
submission_type=SubmissionTypes.UPLOAD,
store_revision=original_revision + 1,
user=admin)
unit = store0.units[0]
unit_source = unit.unit_source
assert unit_source.created_by == admin
updated_revision = unit.revision
assert (
unit_source.created_with
== SubmissionTypes.UPLOAD)
assert unit.change.submitted_by == admin
assert (
unit.change.changed_with
== SubmissionTypes.UPLOAD)
last_submit_time = unit.change.submitted_on
assert last_submit_time >= unit.creation_time
# load update with expired revision and conflicting unit
update_store(
store0,
[("Hello, world", "Hello, world CONFLICT", False)],
submission_type=SubmissionTypes.WEB,
store_revision=original_revision,
user=member)
unit = store0.units[0]
assert unit.submission_set.count() == 0
unit_source = unit.unit_source
# unit target is not updated and revision remains the same
assert store0.units[0].target == "Hello, world UPDATED"
assert unit.revision == updated_revision
unit_source = original_unit.unit_source
unit_source.created_by == admin
assert unit_source.created_with == SubmissionTypes.SYSTEM
unit.change.changed_with == SubmissionTypes.UPLOAD
unit.change.submitted_by == admin
unit.change.submitted_on == last_submit_time
unit.change.reviewed_by is None
unit.change.reviewed_on is None
# but suggestion is added
suggestion = store0.units[0].get_suggestions()[0]
assert suggestion.target == "Hello, world CONFLICT"
assert suggestion.user == member
@pytest.mark.django_db
def test_update_upload_new_revision_new_unit(store0, member):
file_name = "pytest_pootle/data/po/tutorial/en/tutorial_update_new_unit.po"
store0.state = PARSED
old_unit_revision = store0.data.max_unit_revision
_update_from_upload_file(
store0,
file_name,
user=member,
submission_type=SubmissionTypes.WEB)
unit = store0.units.last()
unit_source = unit.unit_source
# the new unit has been added
assert unit.submission_set.count() == 0
assert unit.revision > old_unit_revision
assert unit.target == 'Goodbye, world'
assert unit_source.created_by == member
assert unit_source.created_with == SubmissionTypes.WEB
assert unit.change.submitted_by == member
assert unit.change.changed_with == SubmissionTypes.WEB
@pytest.mark.django_db
def test_update_upload_old_revision_new_unit(store0, member2):
store0.units.delete()
store0.state = PARSED
old_unit_revision = store0.data.max_unit_revision
# load initial update
_update_from_upload_file(
store0,
"pytest_pootle/data/po/tutorial/en/tutorial_update.po")
# load old revision with new unit
file_name = "pytest_pootle/data/po/tutorial/en/tutorial_update_old_unit.po"
_update_from_upload_file(
store0,
file_name,
user=member2,
submission_type=SubmissionTypes.WEB)
# the unit has been added because its not already obsoleted
assert store0.units.count() == 2
unit = store0.units.last()
unit_source = unit.unit_source
# the new unit has been added
assert unit.submission_set.count() == 0
assert unit.revision > old_unit_revision
assert unit.target == 'Goodbye, world'
assert unit_source.created_by == member2
assert unit_source.created_with == SubmissionTypes.WEB
assert unit.change.submitted_by == member2
assert unit.change.changed_with == SubmissionTypes.WEB
def _test_store_update_indexes(store, *test_args):
# make sure indexes are not fooed indexes only have to be unique
indexes = [x.index for x in store.units]
assert len(indexes) == len(set(indexes))
def _test_store_update_units_before(*test_args):
# test what has happened to the units that were present before the update
(store, units_update, store_revision, resolve_conflict,
units_before, member_, member2) = test_args
updates = {unit[0]: unit[1] for unit in units_update}
for unit, change in units_before:
updated_unit = store.unit_set.get(unitid=unit.unitid)
if unit.source not in updates:
# unit is not in update, target should be left unchanged
assert updated_unit.target == unit.target
assert updated_unit.change.submitted_by == change.submitted_by
# depending on unit/store_revision should be obsoleted
if unit.isobsolete() or store_revision >= unit.revision:
assert updated_unit.isobsolete()
else:
assert not updated_unit.isobsolete()
else:
# unit is in update
if store_revision >= unit.revision:
assert not updated_unit.isobsolete()
elif unit.isobsolete():
# the unit has been obsoleted since store_revision
assert updated_unit.isobsolete()
else:
assert not updated_unit.isobsolete()
if not updated_unit.isobsolete():
if store_revision >= unit.revision:
# file store wins outright
assert updated_unit.target == updates[unit.source]
if unit.target != updates[unit.source]:
# unit has changed, or was resurrected
assert updated_unit.change.submitted_by == member2
# damn mysql microsecond precision
if change.submitted_on.time().microsecond != 0:
assert (
updated_unit.change.submitted_on
!= change.submitted_on)
elif unit.isobsolete():
# unit has changed, or was resurrected
assert updated_unit.change.reviewed_by == member2
# damn mysql microsecond precision
if change.reviewed_on.time().microsecond != 0:
assert (
updated_unit.change.reviewed_on
!= change.reviewed_on)
else:
assert (
updated_unit.change.submitted_by
== change.submitted_by)
assert (
updated_unit.change.submitted_on
== change.submitted_on)
assert updated_unit.get_suggestions().count() == 0
else:
# conflict found
suggestion = updated_unit.get_suggestions()[0]
if resolve_conflict == POOTLE_WINS:
assert updated_unit.target == unit.target
assert (
updated_unit.change.submitted_by
== change.submitted_by)
assert suggestion.target == updates[unit.source]
assert suggestion.user == member2
else:
assert updated_unit.target == updates[unit.source]
assert updated_unit.change.submitted_by == member2
assert suggestion.target == unit.target
assert suggestion.user == change.submitted_by
def _test_store_update_ordering(*test_args):
(store, units_update, store_revision, resolve_conflict_,
units_before, member_, member2_) = test_args
updates = {unit[0]: unit[1] for unit in units_update}
old_units = {unit.source: unit for unit, change in units_before}
# test ordering
new_unit_list = []
for unit, change_ in units_before:
add_unit = (not unit.isobsolete()
and unit.source not in updates
and unit.revision > store_revision)
if add_unit:
new_unit_list.append(unit.source)
for source, target_, is_fuzzy_ in units_update:
if source in old_units:
old_unit = old_units[source]
should_add = (not old_unit.isobsolete()
or old_unit.revision <= store_revision)
if should_add:
new_unit_list.append(source)
else:
new_unit_list.append(source)
assert new_unit_list == [x.source for x in store.units]
def _test_store_update_units_now(*test_args):
(store, units_update, store_revision, resolve_conflict_,
units_before, member_, member2_) = test_args
# test that all the current units should be there
updates = {unit[0]: unit[1] for unit in units_update}
old_units = {unit.source: unit for unit, change in units_before}
for unit in store.units:
assert (
unit.source in updates
or (old_units[unit.source].revision > store_revision
and not old_units[unit.source].isobsolete()))
@pytest.mark.django_db
def test_store_update(param_update_store_test):
_test_store_update_indexes(*param_update_store_test)
_test_store_update_units_before(*param_update_store_test)
_test_store_update_units_now(*param_update_store_test)
_test_store_update_ordering(*param_update_store_test)
@pytest.mark.django_db
def test_store_file_diff(store_diff_tests):
diff, store, update_units, store_revision = store_diff_tests
assert diff.target_store == store
assert diff.source_revision == store_revision
assert (
update_units
== [(x.source, x.target, x.isfuzzy())
for x in diff.source_store.units[1:]]
== [(v['source'], v['target'], v['state'] == 50)
for v in diff.source_units.values()])
assert diff.active_target_units == [x.source for x in store.units]
assert diff.target_revision == store.get_max_unit_revision()
assert (
diff.target_units
== {unit["source_f"]: unit
for unit
in store.unit_set.values("source_f", "index", "target_f",
"state", "unitid", "id", "revision",
"developer_comment", "translator_comment",
"locations", "context")})
diff_diff = diff.diff()
if diff_diff is not None:
assert (
sorted(diff_diff.keys())
== ["add", "index", "obsolete", "update"])
# obsoleted units have no index - so just check they are all they match
obsoleted = (store.unit_set.filter(state=OBSOLETE)
.filter(revision__gt=store_revision)
.values_list("source_f", flat=True))
assert len(diff.obsoleted_target_units) == obsoleted.count()
assert all(x in diff.obsoleted_target_units for x in obsoleted)
assert (
diff.updated_target_units
== list(store.units.filter(revision__gt=store_revision)
.values_list("source_f", flat=True)))
@pytest.mark.django_db
def test_store_repr():
store = Store.objects.first()
assert str(store) == str(store.syncer.convert(store.syncer.file_class))
assert repr(store) == u"<Store: %s>" % store.pootle_path
@pytest.mark.django_db
def test_store_po_deserializer(test_fs, store_po):
with test_fs.open("data/po/complex.po") as test_file:
test_string = test_file.read()
ttk_po = getclass(test_file)(test_string)
store_po.update(store_po.deserialize(test_string))
assert len(ttk_po.units) - 1 == store_po.units.count()
@pytest.mark.django_db
def test_store_po_serializer(test_fs, store_po):
with test_fs.open("data/po/complex.po") as test_file:
test_string = test_file.read()
ttk_po = getclass(test_file)(test_string)
store_po.update(store_po.deserialize(test_string))
store_io = io.BytesIO(store_po.serialize())
store_ttk = getclass(store_io)(store_io.read())
assert len(store_ttk.units) == len(ttk_po.units)
@pytest.mark.django_db
def test_store_po_serializer_custom(test_fs, store_po):
class SerializerCheck(object):
original_data = None
context = None
checker = SerializerCheck()
class EGSerializer(Serializer):
@property
def output(self):
checker.original_data = self.original_data
checker.context = self.context
@provider(serializers, sender=Project)
def provide_serializers(**kwargs):
return dict(eg_serializer=EGSerializer)
with test_fs.open("data/po/complex.po") as test_file:
test_string = test_file.read()
# ttk_po = getclass(test_file)(test_string)
store_po.update(store_po.deserialize(test_string))
# add config to the project
project = store_po.translation_project.project
config.get(project.__class__, instance=project).set_config(
"pootle.core.serializers",
["eg_serializer"])
store_po.serialize()
assert checker.context == store_po
assert (
not isinstance(checker.original_data, six.text_type)
and isinstance(checker.original_data, str))
assert checker.original_data == _store_as_string(store_po)
@pytest.mark.django_db
def test_store_po_deserializer_custom(test_fs, store_po):
class DeserializerCheck(object):
original_data = None
context = None
checker = DeserializerCheck()
class EGDeserializer(Deserializer):
@property
def output(self):
checker.context = self.context
checker.original_data = self.original_data
return self.original_data
@provider(deserializers, sender=Project)
def provide_deserializers(**kwargs):
return dict(eg_deserializer=EGDeserializer)
with test_fs.open("data/po/complex.po") as test_file:
test_string = test_file.read()
# add config to the project
project = store_po.translation_project.project
config.get().set_config(
"pootle.core.deserializers",
["eg_deserializer"],
project)
store_po.deserialize(test_string)
assert checker.original_data == test_string
assert checker.context == store_po
@pytest.mark.django_db
def test_store_base_serializer(store_po):
original_data = "SOME DATA"
serializer = Serializer(store_po, original_data)
assert serializer.context == store_po
assert serializer.data == original_data
@pytest.mark.django_db
def test_store_base_deserializer(store_po):
original_data = "SOME DATA"
deserializer = Deserializer(store_po, original_data)
assert deserializer.context == store_po
assert deserializer.data == original_data
@pytest.mark.django_db
def test_store_set_bad_deserializers(store_po):
project = store_po.translation_project.project
with pytest.raises(ConfigurationError):
config.get(project.__class__, instance=project).set_config(
"pootle.core.deserializers",
["DESERIALIZER_DOES_NOT_EXIST"])
class EGDeserializer(object):
pass
@provider(deserializers)
def provide_deserializers(**kwargs):
return dict(eg_deserializer=EGDeserializer)
# must be list
with pytest.raises(ConfigurationError):
config.get(project.__class__, instance=project).set_config(
"pootle.core.deserializers",
"eg_deserializer")
with pytest.raises(ConfigurationError):
config.get(project.__class__, instance=project).set_config(
"pootle.core.deserializers",
dict(serializer="eg_deserializer"))
config.get(project.__class__, instance=project).set_config(
"pootle.core.deserializers",
["eg_deserializer"])
@pytest.mark.django_db
def test_store_set_bad_serializers(store_po):
project = store_po.translation_project.project
with pytest.raises(ConfigurationError):
config.get(project.__class__, instance=project).set_config(
"pootle.core.serializers",
["SERIALIZER_DOES_NOT_EXIST"])
class EGSerializer(Serializer):
pass
@provider(serializers)
def provide_serializers(**kwargs):
return dict(eg_serializer=EGSerializer)
# must be list
with pytest.raises(ConfigurationError):
config.get(project.__class__, instance=project).set_config(
"pootle.core.serializers",
"eg_serializer")
with pytest.raises(ConfigurationError):
config.get(project.__class__, instance=project).set_config(
"pootle.core.serializers",
dict(serializer="eg_serializer"))
config.get(project.__class__, instance=project).set_config(
"pootle.core.serializers",
["eg_serializer"])
@pytest.mark.django_db
def test_store_create_by_bad_path(project0):
# bad project name
with pytest.raises(Project.DoesNotExist):
Store.objects.create_by_path(
"/language0/does/not/exist.po")
# bad language code
with pytest.raises(Language.DoesNotExist):
Store.objects.create_by_path(
"/does/project0/not/exist.po")
# project and project code dont match
with pytest.raises(ValueError):
Store.objects.create_by_path(
"/language0/project1/store.po",
project=project0)
# bad store.ext
with pytest.raises(ValueError):
Store.objects.create_by_path(
"/language0/project0/store_by_path.foo")
# subdir doesnt exist
path = '/language0/project0/path/to/subdir.po'
with pytest.raises(Directory.DoesNotExist):
Store.objects.create_by_path(
path, create_directory=False)
path = '/%s/project0/notp.po' % LanguageDBFactory().code
with pytest.raises(TranslationProject.DoesNotExist):
Store.objects.create_by_path(
path, create_tp=False)
@pytest.mark.django_db
def test_store_create_by_path(po_directory):
# create in tp
path = '/language0/project0/path.po'
store = Store.objects.create_by_path(path)
assert store.pootle_path == path
# "create" in tp again - get existing store
store = Store.objects.create_by_path(path)
assert store.pootle_path == path
# create in existing subdir
path = '/language0/project0/subdir0/exists.po'
store = Store.objects.create_by_path(path)
assert store.pootle_path == path
# create in new subdir
path = '/language0/project0/path/to/subdir.po'
store = Store.objects.create_by_path(path)
assert store.pootle_path == path
@pytest.mark.django_db
def test_store_create_by_path_with_project(project0):
# create in tp with project
path = '/language0/project0/path2.po'
store = Store.objects.create_by_path(
path, project=project0)
assert store.pootle_path == path
# create in existing subdir with project
path = '/language0/project0/subdir0/exists2.po'
store = Store.objects.create_by_path(
path, project=project0)
assert store.pootle_path == path
# create in new subdir with project
path = '/language0/project0/path/to/subdir2.po'
store = Store.objects.create_by_path(
path, project=project0)
assert store.pootle_path == path
@pytest.mark.django_db
def test_store_create_by_new_tp_path(po_directory):
language = LanguageDBFactory()
path = '/%s/project0/tp.po' % language.code
store = Store.objects.create_by_path(path)
assert store.pootle_path == path
assert store.translation_project.language == language
language = LanguageDBFactory()
path = '/%s/project0/with/subdir/tp.po' % language.code
store = Store.objects.create_by_path(path)
assert store.pootle_path == path
assert store.translation_project.language == language
@pytest.mark.django_db
def test_store_create(tp0):
tp = tp0
project = tp.project
registry = formats.get()
po = Format.objects.get(name="po")
po2 = registry.register("special_po_2", "po")
po3 = registry.register("special_po_3", "po")
xliff = Format.objects.get(name="xliff")
project.filetypes.add(xliff)
project.filetypes.add(po2)
project.filetypes.add(po3)
store = Store.objects.create(
name="store.po",
parent=tp.directory,
translation_project=tp)
assert store.filetype == po
assert not store.is_template
store = Store.objects.create(
name="store.pot",
parent=tp.directory,
translation_project=tp)
# not in source_language folder
assert not store.is_template
assert store.filetype == po
store = Store.objects.create(
name="store.xliff",
parent=tp.directory,
translation_project=tp)
assert store.filetype == xliff
# push po to the back of the queue
project.filetypes.remove(po)
project.filetypes.add(po)
store = Store.objects.create(
name="another_store.po",
parent=tp.directory,
translation_project=tp)
assert store.filetype == po2
store = Store.objects.create(
name="another_store.pot",
parent=tp.directory,
translation_project=tp)
assert store.filetype == po
store = Store.objects.create(
name="another_store.xliff",
parent=tp.directory,
translation_project=tp)
with pytest.raises(UnrecognizedFiletype):
store = Store.objects.create(
name="another_store.foo",
parent=tp.directory,
translation_project=tp)
@pytest.mark.django_db
def test_store_create_name_with_slashes_or_backslashes(tp0):
"""Test Stores are not created with (back)slashes on their name."""
with pytest.raises(ValidationError):
Store.objects.create(name="slashed/name.po", parent=tp0.directory,
translation_project=tp0)
with pytest.raises(ValidationError):
Store.objects.create(name="backslashed\\name.po", parent=tp0.directory,
translation_project=tp0)
@pytest.mark.django_db
def test_store_get_file_class():
store = Store.objects.filter(
translation_project__project__code="project0",
translation_project__language__code="language0").first()
# this matches because po is recognised by ttk
assert store.syncer.file_class == getclass(store)
# file_class is cached so lets delete it
del store.syncer.__dict__["file_class"]
class CustomFormatClass(object):
pass
@provider(format_classes)
def format_class_provider(**kwargs):
return dict(po=CustomFormatClass)
# we get the CutomFormatClass as it was registered
assert store.syncer.file_class is CustomFormatClass
# the Store.filetype is used in this case not the name
store.name = "new_store_name.foo"
del store.syncer.__dict__["file_class"]
assert store.syncer.file_class is CustomFormatClass
# lets register a foo filetype
format_registry = formats.get()
foo_filetype = format_registry.register("foo", "foo")
store.filetype = foo_filetype
store.save()
# oh no! not recognised by ttk
del store.syncer.__dict__["file_class"]
with pytest.raises(ValueError):
store.syncer.file_class
@provider(format_classes)
def another_format_class_provider(**kwargs):
return dict(foo=CustomFormatClass)
# works now
assert store.syncer.file_class is CustomFormatClass
format_classes.disconnect(format_class_provider)
format_classes.disconnect(another_format_class_provider)
@pytest.mark.django_db
def test_store_get_template_file_class(po_directory, templates):
project = ProjectDBFactory(source_language=templates)
tp = TranslationProjectFactory(language=templates, project=project)
format_registry = formats.get()
foo_filetype = format_registry.register("foo", "foo", template_extension="bar")
tp.project.filetypes.add(foo_filetype)
store = Store.objects.create(
name="mystore.bar",
translation_project=tp,
parent=tp.directory)
# oh no! not recognised by ttk
with pytest.raises(ValueError):
store.syncer.file_class
class CustomFormatClass(object):
pass
@provider(format_classes)
def format_class_provider(**kwargs):
return dict(foo=CustomFormatClass)
assert store.syncer.file_class == CustomFormatClass
format_classes.disconnect(format_class_provider)
@pytest.mark.django_db
def test_store_create_templates(po_directory, templates):
project = ProjectDBFactory(source_language=templates)
tp = TranslationProjectFactory(language=templates, project=project)
po = Format.objects.get(name="po")
store = Store.objects.create(
name="mystore.pot",
translation_project=tp,
parent=tp.directory)
assert store.filetype == po
assert store.is_template
@pytest.mark.django_db
def test_store_get_or_create_templates(po_directory, templates):
project = ProjectDBFactory(source_language=templates)
tp = TranslationProjectFactory(language=templates, project=project)
po = Format.objects.get(name="po")
store = Store.objects.get_or_create(
name="mystore.pot",
translation_project=tp,
parent=tp.directory)[0]
assert store.filetype == po
assert store.is_template
@pytest.mark.django_db
def test_store_diff(diffable_stores):
target_store, source_store = diffable_stores
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() + 1)
# no changes
assert not differ.diff()
assert differ.target_store == target_store
assert differ.source_store == source_store
@pytest.mark.django_db
def test_store_diff_delete_target_unit(diffable_stores):
target_store, source_store = diffable_stores
# delete a unit in the target store
remove_unit = target_store.units.first()
remove_unit.delete()
# the unit will always be re-added (as its not obsolete)
# with source_revision to the max
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision())
result = differ.diff()
assert result["add"][0][0].source_f == remove_unit.source_f
assert len(result["add"]) == 1
assert len(result["index"]) == 0
assert len(result["obsolete"]) == 0
assert result['update'] == (set(), {})
# and source_revision to 0
differ = StoreDiff(
target_store,
source_store,
0)
result = differ.diff()
assert result["add"][0][0].source_f == remove_unit.source_f
assert len(result["add"]) == 1
assert len(result["index"]) == 0
assert len(result["obsolete"]) == 0
assert result['update'] == (set(), {})
@pytest.mark.django_db
def test_store_diff_delete_source_unit(diffable_stores):
target_store, source_store = diffable_stores
# delete a unit in the source store
remove_unit = source_store.units.first()
remove_unit.delete()
# set the source_revision to max and the unit will be obsoleted
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision())
result = differ.diff()
to_remove = target_store.units.get(unitid=remove_unit.unitid)
assert result["obsolete"] == [to_remove.pk]
assert len(result["obsolete"]) == 1
assert len(result["add"]) == 0
assert len(result["index"]) == 0
# set the source_revision to less that than the target_stores' max_revision
# and the unit will be ignored, as its assumed to have been previously
# deleted
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() - 1)
assert not differ.diff()
@pytest.mark.django_db
def test_store_diff_delete_obsoleted_target_unit(diffable_stores):
target_store, source_store = diffable_stores
# delete a unit in the source store
remove_unit = source_store.units.first()
remove_unit.delete()
# and obsolete the same unit in the target
obsolete_unit = target_store.units.get(unitid=remove_unit.unitid)
obsolete_unit.makeobsolete()
obsolete_unit.save()
# as the unit is already obsolete - nothing
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() + 1)
assert not differ.diff()
@pytest.mark.django_db
def test_store_diff_obsoleted_target_unit(diffable_stores):
target_store, source_store = diffable_stores
# obsolete a unit in target
obsolete_unit = target_store.units.first()
obsolete_unit.makeobsolete()
obsolete_unit.save()
# as the revision is higher it gets unobsoleted
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() + 1)
result = differ.diff()
assert result["update"][0] == set([obsolete_unit.pk])
assert len(result["update"][1]) == 1
assert result["update"][1][obsolete_unit.unitid]["dbid"] == obsolete_unit.pk
# if the revision is less - no change
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() - 1)
assert not differ.diff()
@pytest.mark.django_db
def test_store_diff_update_target_unit(diffable_stores):
target_store, source_store = diffable_stores
# update a unit in target
update_unit = target_store.units.first()
update_unit.target_f = "Some other string"
update_unit.save()
# the unit is always marked for update
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() + 1)
result = differ.diff()
assert result["update"][0] == set([update_unit.pk])
assert result["update"][1] == {}
assert len(result["add"]) == 0
assert len(result["index"]) == 0
differ = StoreDiff(
target_store,
source_store,
0)
result = differ.diff()
assert result["update"][0] == set([update_unit.pk])
assert result["update"][1] == {}
assert len(result["add"]) == 0
assert len(result["index"]) == 0
@pytest.mark.django_db
def test_store_diff_update_source_unit(diffable_stores):
target_store, source_store = diffable_stores
# update a unit in source
update_unit = source_store.units.first()
update_unit.target_f = "Some other string"
update_unit.save()
target_unit = target_store.units.get(
unitid=update_unit.unitid)
# the unit is always marked for update
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() + 1)
result = differ.diff()
assert result["update"][0] == set([target_unit.pk])
assert result["update"][1] == {}
assert len(result["add"]) == 0
assert len(result["index"]) == 0
differ = StoreDiff(
target_store,
source_store,
0)
result = differ.diff()
assert result["update"][0] == set([target_unit.pk])
assert result["update"][1] == {}
assert len(result["add"]) == 0
assert len(result["index"]) == 0
@pytest.mark.django_db
def test_store_diff_custom(diffable_stores):
target_store, source_store = diffable_stores
class CustomDiffableStore(DiffableStore):
pass
@provider(format_diffs)
def format_diff_provider(**kwargs):
return {
target_store.filetype.name: CustomDiffableStore}
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() + 1)
assert isinstance(
differ.diffable, CustomDiffableStore)
@pytest.mark.django_db
def test_store_diff_delete_obsoleted_source_unit(diffable_stores):
target_store, source_store = diffable_stores
# delete a unit in the target store
remove_unit = target_store.units.first()
remove_unit.delete()
# and obsolete the same unit in the target
obsolete_unit = source_store.units.get(unitid=remove_unit.unitid)
obsolete_unit.makeobsolete()
obsolete_unit.save()
# as the unit is already obsolete - nothing
differ = StoreDiff(
target_store,
source_store,
target_store.get_max_unit_revision() + 1)
assert not differ.diff()
@pytest.mark.django_db
def test_store_syncer(tp0):
store = tp0.stores.live().first()
assert isinstance(store.syncer, PoStoreSyncer)
assert store.syncer.file_class == getclass(store)
assert store.syncer.translation_project == store.translation_project
assert (
store.syncer.language
== store.translation_project.language)
assert (
store.syncer.project
== store.translation_project.project)
assert (
store.syncer.source_language
== store.translation_project.project.source_language)
@pytest.mark.django_db
def test_store_syncer_obsolete_unit(tp0):
store = tp0.stores.live().first()
unit = store.units.filter(state=TRANSLATED).first()
unit_syncer = store.syncer.unit_sync_class(unit)
newunit = unit_syncer.create_unit(store.syncer.file_class.UnitClass)
# unit is untranslated, its always just deleted
obsolete, deleted = store.syncer.obsolete_unit(newunit, True)
assert not obsolete
assert deleted
obsolete, deleted = store.syncer.obsolete_unit(newunit, False)
assert not obsolete
assert deleted
# set unit to translated
newunit.target = unit.target
# if conservative, nothings changed
obsolete, deleted = store.syncer.obsolete_unit(newunit, True)
assert not obsolete
assert not deleted
# not conservative and the unit is deleted
obsolete, deleted = store.syncer.obsolete_unit(newunit, False)
assert obsolete
assert not deleted
@pytest.mark.django_db
def test_store_syncer_sync_store(tp0, dummy_store_syncer):
store = tp0.stores.live().first()
DummyStoreSyncer, __, expected = dummy_store_syncer
disk_store = store.syncer.convert()
dummy_syncer = DummyStoreSyncer(store, expected=expected)
result = dummy_syncer.sync(
disk_store,
expected["last_revision"],
update_structure=expected["update_structure"],
conservative=expected["conservative"])
assert result[0] is True
assert result[1]["updated"] == expected["changes"]
# conservative makes no diff here
expected["conservative"] = False
dummy_syncer = DummyStoreSyncer(store, expected=expected)
result = dummy_syncer.sync(
disk_store,
expected["last_revision"],
update_structure=expected["update_structure"],
conservative=expected["conservative"])
assert result[0] is True
assert result[1]["updated"] == expected["changes"]
@pytest.mark.django_db
def test_store_syncer_sync_store_no_changes(tp0, dummy_store_syncer):
store = tp0.stores.live().first()
DummyStoreSyncer, __, expected = dummy_store_syncer
disk_store = store.syncer.convert()
dummy_syncer = DummyStoreSyncer(store, expected=expected)
# no changes
expected["changes"] = []
expected["conservative"] = True
dummy_syncer = DummyStoreSyncer(store, expected=expected)
result = dummy_syncer.sync(
disk_store,
expected["last_revision"],
expected["update_structure"],
expected["conservative"])
assert result[0] is False
assert not result[1].get("updated")
# conservative makes no diff here
expected["conservative"] = False
dummy_syncer = DummyStoreSyncer(store, expected=expected)
result = dummy_syncer.sync(
disk_store,
expected["last_revision"],
expected["update_structure"],
expected["conservative"])
assert result[0] is False
assert not result[1].get("updated")
@pytest.mark.django_db
def test_store_syncer_sync_store_structure(tp0, dummy_store_syncer):
store = tp0.stores.live().first()
DummyStoreSyncer, DummyDiskStore, expected = dummy_store_syncer
disk_store = DummyDiskStore(expected)
expected["update_structure"] = True
expected["changes"] = []
dummy_syncer = DummyStoreSyncer(store, expected=expected)
result = dummy_syncer.sync(
disk_store,
expected["last_revision"],
expected["update_structure"],
expected["conservative"])
assert result[0] is True
assert result[1]["updated"] == []
assert result[1]["obsolete"] == 8
assert result[1]["deleted"] == 9
assert result[1]["added"] == 10
expected["obsolete_units"] = []
expected["new_units"] = []
expected["changes"] = []
dummy_syncer = DummyStoreSyncer(store, expected=expected)
result = dummy_syncer.sync(
disk_store,
expected["last_revision"],
expected["update_structure"],
expected["conservative"])
assert result[0] is False
@pytest.mark.django_db
def test_store_syncer_sync_update_structure(dummy_store_structure_syncer, tp0):
store = tp0.stores.live().first()
DummyStoreSyncer, DummyDiskStore, DummyUnit = dummy_store_structure_syncer
expected = dict(
unit_class="FOO",
conservative=True,
obsolete_delete=(True, True),
obsolete_units=["a", "b", "c"])
expected["new_units"] = [
DummyUnit(unit, expected=expected)
for unit in ["5", "6", "7"]]
syncer = DummyStoreSyncer(store, expected=expected)
disk_store = DummyDiskStore(expected)
result = syncer.update_structure(
disk_store,
expected["obsolete_units"],
expected["new_units"],
expected["conservative"])
obsolete_units = (
len(expected["obsolete_units"])
if expected["obsolete_delete"][0]
else 0)
deleted_units = (
len(expected["obsolete_units"])
if expected["obsolete_delete"][1]
else 0)
new_units = len(expected["new_units"])
assert result == (obsolete_units, deleted_units, new_units)
def _test_get_new(results, syncer, old_ids, new_ids):
assert list(results) == list(
syncer.store.findid_bulk(
[syncer.dbid_index.get(uid)
for uid
in new_ids - old_ids]))
def _test_get_obsolete(results, disk_store, syncer, old_ids, new_ids):
assert list(results) == list(
disk_store.findid(uid)
for uid
in old_ids - new_ids
if (disk_store.findid(uid)
and not disk_store.findid(uid).isobsolete()))
@pytest.mark.django_db
def test_store_syncer_obsolete_units(dummy_store_syncer_units, tp0):
store = tp0.stores.live().first()
disk_store = store.syncer.convert()
expected = dict(
old_ids=set(),
new_ids=set(),
disk_ids={})
syncer = dummy_store_syncer_units(store, expected=expected)
results = syncer.get_units_to_obsolete(
disk_store, expected["old_ids"], expected["new_ids"])
_test_get_obsolete(
results, disk_store, syncer,
expected["old_ids"], expected["new_ids"])
expected = dict(
old_ids=set(["2", "3", "4"]),
new_ids=set(["3", "4", "5"]),
disk_ids={"3": "foo", "4": "bar", "5": "baz"})
results = syncer.get_units_to_obsolete(
disk_store, expected["old_ids"], expected["new_ids"])
_test_get_obsolete(
results, disk_store, syncer, expected["old_ids"], expected["new_ids"])
@pytest.mark.django_db
def test_store_syncer_new_units(dummy_store_syncer_units, tp0):
store = tp0.stores.live().first()
expected = dict(
old_ids=set(),
new_ids=set(),
disk_ids={},
db_ids={})
syncer = dummy_store_syncer_units(store, expected=expected)
results = syncer.get_new_units(
expected["old_ids"], expected["new_ids"])
_test_get_new(
results, syncer, expected["old_ids"], expected["new_ids"])
expected = dict(
old_ids=set(["2", "3", "4"]),
new_ids=set(["3", "4", "5"]),
db_ids={"3": "foo", "4": "bar", "5": "baz"})
syncer = dummy_store_syncer_units(store, expected=expected)
results = syncer.get_new_units(
expected["old_ids"], expected["new_ids"])
_test_get_new(
results, syncer, expected["old_ids"], expected["new_ids"])
@pytest.mark.django_db
def test_store_path(store0):
assert store0.path == to_tp_relative_path(store0.pootle_path)
@pytest.mark.django_db
def test_store_sync_empty(project0_nongnu, tp0, caplog):
store = StoreDBFactory(
name="empty.po",
translation_project=tp0,
parent=tp0.directory)
store.sync()
assert os.path.exists(store.file.path)
modified = os.stat(store.file.path).st_mtime
store.sync()
assert modified == os.stat(store.file.path).st_mtime
# warning message - nothing changes
store.sync(conservative=True, only_newer=False)
assert "nothing changed" in caplog.records[-1].message
assert modified == os.stat(store.file.path).st_mtime
@pytest.mark.django_db
def test_store_sync_template(project0_nongnu, templates_project0, caplog):
template = templates_project0.stores.first()
template.sync()
modified = os.stat(template.file.path).st_mtime
unit = template.units.first()
unit.target = "NEW TARGET"
unit.save()
template.sync(conservative=True)
assert modified == os.stat(template.file.path).st_mtime
template.sync(conservative=False)
assert not modified == os.stat(template.file.path).st_mtime
@pytest.mark.django_db
def test_store_update_with_state_change(store0, admin):
units = dict([(x.id, (x.source, x.target, not x.isfuzzy()))
for x in store0.units])
update_store(
store0,
units=units.values(),
store_revision=store0.data.max_unit_revision,
user=admin)
for unit_id, unit in units.items():
assert unit[2] == store0.units.get(id=unit_id).isfuzzy()
@pytest.mark.django_db
def test_update_xliff(store_po, test_fs, xliff):
project = store_po.translation_project.project
filetype_tool = project.filetype_tool
project.filetypes.add(xliff)
filetype_tool.set_store_filetype(store_po, xliff)
with test_fs.open(['data', 'xliff', 'welcome.xliff']) as f:
file_store = getclass(f)(f.read())
store_po.update(file_store)
unit = store_po.units[0]
assert unit.istranslated()
with test_fs.open(['data', 'xliff', 'updated_welcome.xliff']) as f:
file_store = getclass(f)(f.read())
store_po.update(file_store)
updated_unit = store_po.units.get(id=unit.id)
assert unit.source != updated_unit.source
@pytest.mark.django_db
def test_update_resurrect(store_po, test_fs):
with test_fs.open(['data', 'po', 'obsolete.po']) as f:
file_store = getclass(f)(f.read())
store_po.update(file_store)
obsolete_units = store_po.unit_set.filter(state=OBSOLETE)
obsolete_ids = list(obsolete_units.values_list('id', flat=True))
assert len(obsolete_ids) > 0
with test_fs.open(['data', 'po', 'resurrected.po']) as f:
file_store = getclass(f)(f.read())
store_revision = store_po.data.max_unit_revision
# set store_revision as we do in update_stores cli command
store_po.update(file_store, store_revision=store_revision - 1)
obsolete_units = store_po.unit_set.filter(state=OBSOLETE)
assert obsolete_units.count() == len(obsolete_ids)
for unit in obsolete_units.filter(id__in=obsolete_ids):
assert unit.isobsolete()
# set store_revision as we do in update_stores cli command
store_po.update(file_store, store_revision=store_revision)
units = store_po.units.filter(id__in=obsolete_ids)
assert units.count() == len(obsolete_ids)
for unit in units:
assert not unit.isobsolete()
@pytest.mark.django_db
def test_store_comment_update(store0, member):
ttk = store0.deserialize(store0.serialize())
fileunit = ttk.units[-1]
fileunit.removenotes()
fileunit.addnote("A new comment")
unit = store0.findid(fileunit.getid())
last_sub_pk = unit.submission_set.order_by(
"id").values_list("id", flat=True).last() or 0
store0.update(
ttk, store_revision=store0.data.max_unit_revision + 1,
user=member
)
assert ttk.units[-1].getnotes("translator") == "A new comment"
unit = store0.units.get(id=unit.id)
assert unit.translator_comment == "A new comment"
assert unit.change.commented_by == member
new_subs = unit.submission_set.filter(id__gt=last_sub_pk).order_by("id")
assert new_subs.count() == 1
comment_sub = new_subs[0]
assert comment_sub.old_value == ""
assert comment_sub.new_value == "A new comment"
assert comment_sub.field == SubmissionFields.COMMENT
assert comment_sub.type == SubmissionTypes.SYSTEM
assert comment_sub.submitter == member
assert comment_sub.revision == unit.revision
assert comment_sub.creation_time == unit.change.commented_on
| ta2-1/pootle | tests/models/store.py | Python | gpl-3.0 | 64,439 |
<?php
namespace MP\Mapper;
use Dibi\Connection;
use MP\Util\Lang\Lang;
use MP\Util\Transaction\DibiTransaction;
/**
* Vychozi databazovy mapper.
*
* @author Martin Odstrcilik <martin.odstrcilik@gmail.com>
*/
class DatabaseMapper implements IMapper
{
/** @var Context */
protected $context;
/** @var Connection */
protected $connection;
/** @var DibiTransaction */
protected $transaction;
/** @var Lang */
protected $lang;
/** @var string */
protected $table;
/**
* @param Context $context
* @param Connection $connection
* @param DibiTransaction $transaction
* @param Lang $lang
*/
public function __construct(Context $context, Connection $connection, DibiTransaction $transaction, Lang $lang)
{
$this->context = $context;
$this->connection = $connection;
$this->transaction = $transaction;
$this->lang = $lang;
}
/**
* Vrati nazev spravovane databazove tabulky.
*
* @return string
*/
public function getTable()
{
return $this->table;
}
/**
* Nastavi nazev spravovane databazove tabulky.
*
* @param string $table
*/
public function setTable($table)
{
$this->table = $table;
}
/**
* @param array|null $restrictor
* @param array|null $order
* @param int|null $limit
* @param int|null $offset
*
* @return array|null
* @throws \Dibi\Exception
*/
public function selectAll($restrictor = null, $order = null, $limit = null, $offset = null)
{
$result = [];
$query = $this->buildSelectAllQuery($restrictor, $order, $limit, $offset);
$rows = $this->executeQuery($query)->fetchAll();
if ($rows) {
foreach ($rows as $row) {
$result[] = $row->toArray();
}
}
return $result;
}
/**
* @param array $restrictor
* @param array|null $order
*
* @return array|null
* @throws \Dibi\Exception
*/
public function selectOne(array $restrictor, $order = null)
{
$result = null;
$query = $this->buildSelectAllQuery($restrictor, $order);
$query = array_merge($query, ["%lmt", 1]);
$row = $this->executeQuery($query)->fetch();
if ($row) {
$result = $row->toArray();
}
return $result;
}
/**
* @param array $values
* @return int
*/
public function insert(array $values)
{
if (!isset($values[IMapper::ID])) {
$values[IMapper::ID] = $this->getNextId();
}
$query = ["INSERT INTO %n", $this->table, $values];
$this->executeQuery($query);
return $values[IMapper::ID];
}
/**
* @param array $values
* @param array $restrictor
* @param string|null $returning
* @return \Dibi\Result|int
* @throws \Dibi\Exception
*/
public function update(array $values, array $restrictor, $returning = null)
{
$query = ["UPDATE %n", $this->table, "SET", $values];
$query = $this->buildWhere($restrictor, $query);
if (null !== $returning) {
$query[] = " RETURNING %n";
$query[] = $returning;
}
$result = $this->executeQuery($query);
return $result;
}
/**
* @param array $restrictor
* @return \Dibi\Result|int
*/
public function delete(array $restrictor)
{
$query = ["DELETE FROM %n", $this->table];
$query = $this->buildWhere($restrictor, $query);
$result = $this->executeQuery($query);
return $result;
}
/**
* @param array|null $restrictor
*
* @return int|null
* @throws \Dibi\Exception
*/
public function count($restrictor)
{
$result = null;
$query = ["SELECT COUNT(*) FROM %n", $this->table];
$this->buildWhere($restrictor, $query);
$result = $this->executeQuery($query)->fetchSingle();
return $result;
}
/**
* @param array|null $restrictor
* @param array|null $order
* @param int|null $limit
* @param int|null $offset
*
* @return array|\string[]
*/
protected function buildSelectAllQuery($restrictor = null, $order = null, $limit = null, $offset = null)
{
$this->buildSelect($query);
$this->buildWhere($restrictor, $query);
$this->buildOrder($order, $query);
$this->buildLimitOffset($limit, $offset, $query);
return $query;
}
/**
* Sestavi SELECT cast dostazu.
*
* @param string[] $query
* @return array
*/
protected function buildSelect(&$query)
{
$query = ["SELECT * FROM %n", $this->table];
return $query;
}
/**
* Sestavu WHERE cast dotazu
*
* @param array|null $restrictor
* @param string[] $query aktualne sestavena cast query, ke ktere je pripojena WHERE cast dotazu
*
* @return string[] query
*/
protected function buildWhere($restrictor = null, &$query)
{
if (null !== $restrictor) {
$query[] = "WHERE %and";
$query[] = $restrictor;
}
return $query;
}
/**
* Sestavi ORDER BY cast dotazu
*
* @param array|null $order
* @param string[] $query
*
* @return string[]
*/
protected function buildOrder($order, &$query)
{
if (null === $order) {
$order = [];
}
if (is_array($order)) {
$order = array_merge($order, [IMapper::ID => IMapper::ORDER_ASC]);
$query = array_merge($query, ["ORDER BY %by", $order]);
}
return $query;
}
/**
* Sestavi LIMIT a OFFSET cast dotazu.
*
* @param int|null $limit
* @param int|null $offset
* @param string[] $query
*
* @return string[]
*/
protected function buildLimitOffset($limit, $offset, &$query)
{
if (null !== $limit) {
$query = array_merge($query, ["%lmt", (int)$limit]);
}
if (null !== $offset) {
$query = array_merge($query, ["%ofs", (int)$offset]);
}
return $query;
}
/**
* @param array|string $query
*
* @param bool $rollbackOnError
* @return \Dibi\Result|int
* @throws \Dibi\Exception
*/
protected function executeQuery($query, $rollbackOnError = true)
{
try {
$result = $this->connection->query($query);
} catch (\Dibi\Exception $e) {
if ($rollbackOnError && $this->transaction->isRunning()) {
$this->transaction->rollback();
}
throw $e;
}
return $result;
}
/**
* Vraci dalsi ID ze sekcence pro tabulku mapperu.
*/
protected function getNextId()
{
$id = null;
$query = ["SELECT nextval(%s)", $this->getSequenceName()];
$result = $this->executeQuery($query);
if ($result) {
$id = $result->fetchSingle();
}
if (empty($id) || false === is_numeric($id)) {
throw new \Nette\UnexpectedValueException("Sequence generation returned non-numeric value.");
}
return $id;
}
/**
* Dle nazvu mapperem spravovane tabulky vraci nazev sekvence pro IDcka.
*
* @return string
*/
protected function getSequenceName()
{
return "{$this->table}_id_seq";
}
}
| Mapybezbarier/mapybezbarier | app/Mapper/DatabaseMapper.php | PHP | gpl-3.0 | 7,587 |
/**
* ByteCart, ByteCart Redux
* Copyright (C) Catageek
* Copyright (C) phroa
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
*/
package com.github.catageek.bytecart.sign;
import com.github.catageek.bytecart.address.Address;
import com.github.catageek.bytecart.address.AddressFactory;
import com.github.catageek.bytecart.address.AddressString;
import com.github.catageek.bytecart.hardware.RegistryBoth;
import com.github.catageek.bytecart.hardware.RegistryInput;
import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.entity.Entity;
import java.util.Random;
/**
* Gives random address to a cart
*/
final class BC7019 extends BC7010 implements Triggerable {
BC7019(BlockSnapshot block, Entity vehicle) {
super(block, vehicle);
this.storageCartAllowed = true;
}
@Override
public String getName() {
return "BC7019";
}
@Override
public String getFriendlyName() {
return "Random Destination";
}
@Override
protected Address getAddressToWrite() {
int startRegion = getInput(3).getValue();
int endRegion = getInput(0).getValue();
int newRegion = startRegion + (new Random()).nextInt(endRegion - startRegion + 1);
int startTrack = getInput(4).getValue();
int endTrack = getInput(1).getValue();
int newTrack = startTrack + (new Random()).nextInt(endTrack - startTrack + 1);
int startStation = getInput(5).getValue();
int endStation = getInput(2).getValue();
int newStation = startStation + (new Random()).nextInt(endStation - startStation + 1);
return new AddressString(String.format("%d.%d.%d", newRegion, newTrack, newStation), false);
}
protected void addIO() {
// add input [0], [1] and [2] from 4th line
this.addAddressAsInputs(AddressFactory.getAddress(getBlock(), 3));
// add input [3], [4] and [5] from 3th line
this.addAddressAsInputs(AddressFactory.getAddress(getBlock(), 2));
}
private void addAddressAsInputs(Address addr) {
if (addr.isValid()) {
RegistryInput region = addr.getRegion();
this.addInputRegistry(region);
RegistryInput track = addr.getTrack();
this.addInputRegistry(track);
RegistryBoth station = addr.getStation();
this.addInputRegistry(station);
}
}
}
| phroa/ByteCartRedux | src/main/java/com/github/catageek/bytecart/sign/BC7019.java | Java | gpl-3.0 | 3,023 |
import {grpc, Code, Metadata} from "grpc-web-client";
import {DummyService} from "../_proto/dummy/dummy_service_pb_service";
import {CreateGameRequest, CreateGameResponse} from "../_proto/dummy/dummy_service_pb";
declare const USE_TLS: boolean;
const host = USE_TLS ? "https://web.ae.28k.ch:9091" : "http://web.ae.28k.ch:9090";
function createGame() {
const createGameRequest = new CreateGameRequest();
grpc.unary(DummyService.CreateGame, {
request: createGameRequest,
host: host,
onEnd: r => {
const {status, message} = r;
var wtf = (m: CreateGameResponse) => { return m.getId(); }
if (status === Code.OK && message) {
var response = message as CreateGameResponse;
console.log("getBook.onEnd.message", message.toObject());
wtf(response);
}
}
});
}
createGame();
| eplundberg/crispy-bassoon | src/ts/src/index.ts | TypeScript | gpl-3.0 | 829 |
package com.javarush.test.level07.lesson12.home01;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/* Вывести числа в обратном порядке
Ввести с клавиатуры 10 чисел и заполнить ими список.
Вывести их в обратном порядке.
Использовать только цикл for.
*/
public class Solution
{
public static void main(String[] args) throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> integers = new ArrayList<>();
for (int i = 0; i < 10; i++) {
integers.add(Integer.parseInt(reader.readLine()));
}
for (int i = 0; i < integers.size(); i++) {
System.out.println(integers.get(integers.size() - i - 1));
}
}
}
| andrey-gabchak/JavaRushLabs | com/javarush/test/level07/lesson12/home01/Solution.java | Java | gpl-3.0 | 958 |
package com.game.clean;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.concurrent.*;
/**
* Created by wanggq on 2016/11/9.
*/
public class MainUI {
Logger logger = Logger.getLogger(this.getClass());
JFrame frame;
JBallPanel[] panels;
static final int ROWS = 13, COLUMNS = 13;
static int[] step_length = {-COLUMNS, 1, COLUMNS, -1};
// 背景色
static final Color LIGHT = new Color(42, 59, 77), DEEP = new Color(35, 49, 64);
static final String[] ball_color = {"", "红", "黄", "蓝", "绿", "青", "紫", "灰"};
// 球的颜色
static Color[] Ball_color = {null, new Color(200, 20, 3)
, new Color(190, 68, 22)
, new Color(211, 154, 27)
, new Color(0, 169, 29)
, new Color(0, 224, 224)
, new Color(32, 67, 251)
, new Color(169, 33, 168)
, new Color(76, 76, 76)};
// 球的图片
static Image[] Ball_image = {
null, new ImageIcon("./src/com/game/clean/icon/1.jpg").getImage()
, new ImageIcon("./src/com/game/clean/icon/2.jpg").getImage()
, new ImageIcon("./src/com/game/clean/icon/3.jpg").getImage()
, new ImageIcon("./src/com/game/clean/icon/4.jpg").getImage()
, new ImageIcon("./src/com/game/clean/icon/5.jpg").getImage()
, new ImageIcon("./src/com/game/clean/icon/6.jpg").getImage()
, new ImageIcon("./src/com/game/clean/icon/7.jpg").getImage()
, new ImageIcon("./src/com/game/clean/icon/8.jpg").getImage()
};
int[] map = {
8, 8, 3, 0, 0, 7, 0, 0, 8, 0, 8, 0, 6,
6, 7, 0, 6, 1, 0, 6, 0, 0, 0, 2, 0, 0,
0, 0, 2, 0, 6, 5, 1, 3, 0, 3, 0, 6, 0,
0, 2, 0, 6, 5, 7, 7, 0, 1, 6, 1, 1, 1,
3, 2, 0, 8, 0, 0, 0, 5, 7, 0, 7, 2, 0,
7, 8, 2, 3, 0, 0, 0, 8, 0, 0, 0, 5, 0,
0, 5, 8, 4, 5, 7, 0, 7, 4, 6, 2, 0, 3,
2, 1, 1, 1, 0, 0, 5, 2, 3, 2, 0, 0, 3,
5, 0, 4, 5, 0, 4, 0, 0, 6, 0, 4, 0, 3,
0, 0, 8, 0, 3, 8, 0, 0, 4, 1, 0, 7, 7,
0, 0, 8, 3, 6, 4, 4, 2, 0, 0, 5, 4, 0,
1, 0, 0, 0, 8, 1, 0, 5, 0, 0, 4, 4, 2,
0, 0, 5, 0, 0, 0, 7, 4, 0, 6, 3, 0, 0
};
// 评分: 一次消2个得2分, 一次消3个得4分, 一次消4个得10分
int[] score_map = {0, 0, 2, 4, 10}, total_ball;
static String[] btn_name = {"开始", "暂停"};
int start_time = 0; // 开始时间统计
int click_total = 0; // 点击次数统计
int score = 0; // 分数统计
JLabel stepLabel, timeLabel, scoreLabel;
JButton startButton;
Timer timer, animationTimer;
LinkedList<int[]> stack;
public MainUI() {
frame = new JFrame("消弹珠");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(60 * COLUMNS, 60 * ROWS + 40);
// 头部Bar
JPanel topPanel = new JPanel();
topPanel.setLayout(new GridLayout(1, 3));
topPanel.setBackground(Color.LIGHT_GRAY);
JPanel leftPanel = new JPanel(new GridLayout(1, 2, 0, 10));
topPanel.add(leftPanel);
JPanel clickPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
leftPanel.add(clickPanel);
JLabel click_lab = new JLabel("点击:");
clickPanel.add(click_lab);
stepLabel = new JLabel("0");
stepLabel.setFont(new Font("Courier New", Font.BOLD, 20));
clickPanel.add(stepLabel);
JPanel scorePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
leftPanel.add(scorePanel);
JLabel score_lab = new JLabel("得分:");
scorePanel.add(score_lab);
scoreLabel = new JLabel("0");
scoreLabel.setFont(new Font("Courier New", Font.BOLD, 20));
scorePanel.add(scoreLabel);
JPanel centerPanel = new JPanel();
topPanel.add(centerPanel);
startButton = new JButton("开始");
startButton.setName("0");
startButton.addMouseListener(startMouseAdapter);
centerPanel.add(startButton);
JPanel rightPanel = new JPanel(new GridLayout(1, 2, 0, 10));
topPanel.add(rightPanel);
JPanel timePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
timeLabel = new JLabel("00:00");
timeLabel.setFont(new Font("Courier New", Font.BOLD, 20));
timeLabel.setLayout(new FlowLayout(FlowLayout.LEFT));
timePanel.add(timeLabel);
rightPanel.add(timePanel);
JPanel tiPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton helpButton = new JButton("提示");
helpButton.setSize(60, rightPanel.getHeight());
helpButton.setLayout(new FlowLayout(FlowLayout.RIGHT));
helpButton.addMouseListener(helpMouseAdapter);
tiPanel.add(helpButton);
rightPanel.add(tiPanel);
frame.add(topPanel, BorderLayout.NORTH);
// 游戏区
JPanel bodyPanel = new JPanel();
bodyPanel.setLayout(new GridLayout(ROWS, COLUMNS));
bodyPanel.setSize(frame.getWidth(), frame.getHeight() - topPanel.getHeight());
frame.add(bodyPanel);
// 画格子
panels = new JBallPanel[ROWS * COLUMNS];
for (int i = 0, len = panels.length; i < len; i++) {
panels[i] = new JBallPanel();
panels[i].setBackground((i & 1) == 0 ? DEEP : LIGHT);
panels[i].setName(String.valueOf(i));
bodyPanel.add(panels[i]);
// panels[i].setNo(String.valueOf(i)); // TODO debug
}
// 初始化弹珠的个数
total_ball = new int[9];
for (int i = 0; i < map.length; i++) {
total_ball[map[i]]++;
}
// 增加全局键盘事件
Toolkit.getDefaultToolkit().addAWTEventListener(e -> {
if (e.getID() == KeyEvent.KEY_PRESSED) {
KeyEvent ke = (KeyEvent) e;
int code = ke.getKeyCode();
switch (code) {
// 空格暂停
case KeyEvent.VK_SPACE:
pause();
break;
// backspace, delete, 左键反悔一步
case KeyEvent.VK_DELETE:
case KeyEvent.VK_BACK_SPACE:
case KeyEvent.VK_LEFT:
backward();
break;
}
}
}, AWTEvent.KEY_EVENT_MASK);
frame.setVisible(true);
stack = new LinkedList<>();
}
/**
* 画球以及擦除球
*
* @param display true:显示 false:隐藏
*/
void drawBall(boolean display) {
// 画球 按赤橙黄绿青蓝紫灰的顺序分别用1-8表示
if (display) {
for (int i = 0, len = map.length; i < len; i++) {
int n;
if ((n = map[i]) != 0) {
// TODO 暂时使用颜色代替
panels[i].setColor(Ball_color[n]);
} else {
// 没有画球的空地增加鼠标点击事件
panels[i].addMouseListener(checkMouseAdapter);
}
}
// 初始化计时器
if (timer == null) {
timer = new Timer(1000, e -> timeLabel.setText(timeFormat(++start_time)));
}
timer.start();
if (animationTimer == null) {
animationTimer = new Timer(150, null);
}
} else {
for (int i = 0, len = map.length; i < len; i++) {
if (map[i] != 0) {
panels[i].deleteIcon();
} else {
// 不显示球的时候同时去除鼠标事件
panels[i].removeMouseListener(checkMouseAdapter);
}
}
timer.stop(); // 暂停计时
}
}
/**
* 鼠标点击空格子后的处理
*
* @param index 格子的下标
*/
int[] check(int index) {
int row = index / COLUMNS, col = index % ROWS;
// 横向查找
int xs = index, xn = index, xl = row * COLUMNS, xu = (row + 1) * COLUMNS - 1;
while (xs - 1 >= xl && map[--xs] == 0) ;
while (xn + 1 <= xu && map[++xn] == 0) ;
// 纵向查找
int ys = index, yn = index, yl = col, yu = map.length - (COLUMNS - col);
while (ys - COLUMNS >= yl && map[ys -= COLUMNS] == 0) ;
while (yn + COLUMNS <= yu && map[yn += COLUMNS] == 0) ;
logger.info("xs:" + xs + ", xl:" + xn + ", ys:" + ys + ", yl:" + yn);
return check0(xs, xn, ys, yn);
}
/**
* 扫描4个方向是否有相同颜色的球
*
* @param n
*/
private int[] check0(int... n) {
int[] clone = n.clone();
for (int i = 0, len = n.length - 1; i < len; i++) {
if (clone[i] == -1) continue;
for (int j = i + 1; j < len + 1; j++) {
if (clone[j] == -1) continue;
if (map[n[j]] != 0 && map[n[i]] == map[n[j]]) {
clone[i] = -1;
clone[j] = -1;
}
}
}
int[] log = new int[n.length];
int index = 0;
for (int i = 0; i < clone.length; i++) {
if (clone[i] == -1) {
log[index++] = n[i];
}
}
logger.info("消除[" + index + "]个球.");
return index > 0 ? Arrays.copyOf(log, index) : null;
}
/**
* 消除球体
*
* @param indexs
*/
void delete(int... indexs) {
ActionListener[] actions = animationTimer.getActionListeners();
for (ActionListener action : actions) {
animationTimer.removeActionListener(action);
int info = ((AnimationListener) action).get();
whenError(info);
}
for (int i = 0; i < indexs.length; i++) {
int index = indexs[i], cc = map[index];
indexs[i] = index * 10 + map[index];
map[index] = 0;
total_ball[cc]--;
panels[index].deleteIcon();
// 消除球体之后会留下一个空的格子, 要给空格子加上鼠标点击事件
panels[index].addMouseListener(checkMouseAdapter);
// int last = index - c, t = last / COLUMNS, s, l;
// if (t > 0) {
// s = t;
// l = COLUMNS;
// } else if (t < 0) {
// s = -t;
// l = -COLUMNS;
// } else if (last > 0) {
// s = last;
// l = 1;
// } else {
// s = -last;
// l = -1;
// }
animationTimer.addActionListener(new AnimationListener(index, cc));
}
animationTimer.start();
stack.push(indexs);
markScore(stack.peek().length);
}
/**
* 评分: 一次消2个得2分, 一次消3个得4分, 一次消4个得10分
*
* @param size >0:消除 <0:反回
* @return
*/
void markScore(int size) {
int s;
if (size > 0) {
s = score_map[size];
} else {
s = -score_map[-size];
}
scoreLabel.setText(String.valueOf(score += s));
Color c;
if (score > 150) {
c = Color.RED;
} else if (score > 100) {
c = Color.PINK;
} else if (score > 50) {
c = Color.BLUE;
} else c = Color.BLACK;
scoreLabel.setForeground(c);
}
/**
* 时间格式化, 将秒格式化为00:00
*
* @param time 秒
* @return
*/
String timeFormat(int time) {
int m = time / 60, s = time % 60;
char[] cs = {'0', '0', ':', '0', '0'};
cs[0] += m / 10;
cs[1] += m % 10;
cs[3] += s / 10;
cs[4] += s % 10;
return new String(cs);
}
/**
* 暂停
*/
void pause() {
// 暂停->开始/开始->暂停
int i = Integer.parseInt(startButton.getName());
drawBall(i == 0);
i = i == 0 ? 1 : 0;
startButton.setName(String.valueOf(i));
startButton.setText(btn_name[i]);
}
/**
* 回退
*/
void backward() {
if (stack.isEmpty()) {
logger.info("stack is empty.");
return;
}
int[] log = stack.pop();
for (int l : log) {
int index = l / 10, color = l % 10;
map[index] = color;
panels[index].setColor(Ball_color[color]);
}
markScore(-log.length);
}
/**
* 提示
*/
void smartHelp() {
// TODO 优先找最大可消除位置
int n;
if ((n = fastFail()) > 0) {
JOptionPane.showMessageDialog(frame, "剩余["+ball_color[n]+"色]弹珠无法完全.");
}
// 1.查找空格子
// 2.记录可以消除的弹珠数
// 3.比较大小然后得到最大的数
// 4.查检剩余的弹珠是否能完全消除
}
/**
* 快速失败
* @return
*/
int fastFail() {
// 1.如果该颜色只有1个
for (int i = 0; i < total_ball.length; i++) {
if (total_ball[i] == 1) return i;
}
// 2.同一颜色有多个
for (int i = 0; i < map.length; i++) {
if (i == 0) continue;
int row = i / COLUMNS, col = i % ROWS, c = map[i];
// 横向查找
int xs = i, xn = i, xl = row * COLUMNS, xu = (row + 1) * COLUMNS - 1;
while (xs - 1 >= xl && map[--xs] == c) ;
while (xn + 1 <= xu && map[++xn] == c) ;
// 纵向查找
int ys = i, yn = i, yl = col, yu = map.length - (COLUMNS - col);
while (ys - COLUMNS >= yl && map[ys -= COLUMNS] == c) ;
while (yn + COLUMNS <= yu && map[yn += COLUMNS] == c) ;
// 2.1.同颜色相邻
if ((xs != xn || ys != yn) && (xn - xs + yn - ys == total_ball[c])) {
return c;
}
// 2.2.同颜色在同一直线且中间隔着其它颜色
// 横向查找
int n = 0, _n = -1;
for (int j = xl; j < xu; j++) {
if (map[j] == c) {
if (_n == -1) _n = n;
else if (_n == 9999) _n = 999;
n++;
} else {
if (_n != -1) _n = 9999;
}
}
if (n == total_ball[c] && _n == 999) {
return c;
}
n = 0; _n = -1;
// 纵向查找
for (int j = yl; j < yu; j+=COLUMNS) {
if (map[j] == c) {
if (_n == -1) _n = n;
else if (_n == 9999) _n = 999;
n++;
} else {
if (_n != -1) _n = 9999;
}
}
if (n == total_ball[c] && _n == 999) {
return c;
}
}
return 0;
}
/**
* 动画过程中出现错误时将十字路经上的背景使用修改为正确背景
*
* @param c
*/
void whenError(int c) {
panels[c].deleteIcon();
}
void animation(int s, int c, int l) {
while (--s > 1) {
panels[c].setBackground((c & 1) == 0 ? DEEP : LIGHT);
panels[c += l].setBackground(Color.CYAN);
try {
Thread.sleep(150);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
panels[c].setBackground((c & 1) == 0 ? DEEP : LIGHT);
panels[c + l].deleteIcon();
// 消除球体之后会留下一个空的格子, 要给空格子加上鼠标点击事件
panels[c + l].addMouseListener(checkMouseAdapter);
}
// 鼠标点击事件--点击空格子
MouseAdapter checkMouseAdapter = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
JBallPanel panel = (JBallPanel) e.getSource();
int current = Integer.parseInt(panel.getName());
int[] log = check(current);
if (log != null) delete(log);
stepLabel.setText(String.valueOf(++click_total));
}
}
// 鼠标点击事件--开始/暂停 按钮
, startMouseAdapter = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
pause();
}
}
// 鼠标点击事件--提示
, helpMouseAdapter = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
smartHelp();
}
};
// /**
// * 动画类
// */
// class AnimationService implements Callable<Integer> {
// private int s, c, l;
//
// public AnimationService(int s, int c, int l) {
// this.s = s;
// this.c = c;
// this.l = l;
// }
//
// public int[] get() {
// return new int[]{s, c, l};
// }
//
// @Override
// public Integer call() throws Exception {
// while (--s > 1) {
// SwingUtilities.invokeLater(() -> {
// panels[c].setBackground((c & 1) == 0 ? DEEP : LIGHT);
// panels[c].updateUI();
// panels[c += l].setBackground(Color.CYAN);
// panels[c].updateUI();
// });
// Thread.sleep(150);
// }
//// SwingUtilities.invokeLater(() -> {
// panels[c].setBackground((c & 1) == 0 ? DEEP : LIGHT);
// panels[c].updateUI();
// panels[c + l].deleteIcon();
// panels[c + 1].updateUI();
// // 消除球体之后会留下一个空的格子, 要给空格子加上鼠标点击事件
// panels[c + l].addMouseListener(checkMouseAdapter);
//// });
// return s - 1;
// }
// }
class AnimationListener implements ActionListener {
private int c, cc, n = 4;
public AnimationListener(int c, int cc) {
this.c = c;
this.cc = cc;
}
public int get() {
return c;
}
@Override
public void actionPerformed(ActionEvent e) {
if (n-- > 0) {
Color color = panels[c].getColor(), backColor = (c & 1) == 0 ? DEEP : LIGHT;
panels[c].setColor(color == Ball_color[cc] ? backColor : Ball_color[cc]);
} else animationTimer.stop();
}
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(() -> new MainUI());
}
}
| wangguanquan/wsjob | src/main/java/cn/colvin/game/MainUI.java | Java | gpl-3.0 | 19,036 |
/*
LEADERS OF AN ARRAY
The task is to find all leaders in an array, where
a leader is an array element which is greater than all the elements
on its right side
*/
import java.util.Scanner;
class Leaders_Of_Array {
public static void main(String args[]) {
int num;
System.out.println("Enter the size of array : ");
Scanner s = new Scanner(System.in);
num = s.nextInt();
int a[] = new int[num];
System.out.println("Enter array elements");
for (int i = 0; i < num; i++) {
a[i] = s.nextInt();
}
int maximum = a[num - 1];
System.out.println("The following are the leaders of array : ");
System.out.print(a[num - 1] + " ");
for (int i = num - 2; i >= 0; i--) {
if (a[i] > maximum) {
System.out.print(a[i] + " ");
}
}
}
}
/*
Input : num = 5
Array = [13, 4, 12, 1, 5]
Output :
The following are the leaders of array :
5 12 13
*/
| jainaman224/Algo_Ds_Notes | Leaders_Of_Array/Leaders_Of_Array.java | Java | gpl-3.0 | 1,031 |
package net.minecraft.server;
import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
public class EntityIronGolem extends EntityGolem {
private int e = 0;
Village d = null;
private int f;
private int g;
public EntityIronGolem(World world) {
super(world);
this.texture = "/mob/villager_golem.png";
this.a(1.4F, 2.9F);
this.getNavigation().a(true);
this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, 0.25F, true));
this.goalSelector.a(2, new PathfinderGoalMoveTowardsTarget(this, 0.22F, 32.0F));
this.goalSelector.a(3, new PathfinderGoalMoveThroughVillage(this, 0.16F, true));
this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, 0.16F));
this.goalSelector.a(5, new PathfinderGoalOfferFlower(this));
this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 0.16F));
this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
this.targetSelector.a(1, new PathfinderGoalDefendVillage(this));
this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false));
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityMonster.class, 16.0F, 0, false, true));
}
protected void a() {
super.a();
this.datawatcher.a(16, Byte.valueOf((byte) 0));
}
public boolean aV() {
return true;
}
protected void bd() {
if (--this.e <= 0) {
this.e = 70 + this.random.nextInt(50);
this.d = this.world.villages.getClosestVillage(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 32);
if (this.d == null) {
this.aE();
} else {
ChunkCoordinates chunkcoordinates = this.d.getCenter();
this.b(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, this.d.getSize());
}
}
super.bd();
}
public int getMaxHealth() {
return 100;
}
protected int h(int i) {
return i;
}
public void d() {
super.d();
if (this.f > 0) {
--this.f;
}
if (this.g > 0) {
--this.g;
}
if (this.motX * this.motX + this.motZ * this.motZ > 2.500000277905201E-7D && this.random.nextInt(5) == 0) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
int k = MathHelper.floor(this.locZ);
int l = this.world.getTypeId(i, j, k);
if (l > 0) {
this.world.a("tilecrack_" + l, this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, 4.0D * ((double) this.random.nextFloat() - 0.5D), 0.5D, ((double) this.random.nextFloat() - 0.5D) * 4.0D);
}
}
}
public boolean a(Class oclass) {
return this.q() && EntityHuman.class.isAssignableFrom(oclass) ? false : super.a(oclass);
}
public boolean k(Entity entity) {
this.f = 10;
this.world.broadcastEntityEffect(this, (byte) 4);
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), 7 + this.random.nextInt(15));
if (flag) {
entity.motY += 0.4000000059604645D;
}
this.world.makeSound(this, "mob.irongolem.throw", 1.0F, 1.0F);
return flag;
}
public Village n() {
return this.d;
}
public void e(boolean flag) {
this.g = flag ? 400 : 0;
this.world.broadcastEntityEffect(this, (byte) 11);
}
protected String aQ() {
return "none";
}
protected String aR() {
return "mob.irongolem.hit";
}
protected String aS() {
return "mob.irongolem.death";
}
protected void a(int i, int j, int k, int l) {
this.world.makeSound(this, "mob.irongolem.walk", 1.0F, 1.0F);
}
protected void dropDeathLoot(boolean flag, int i) {
// CraftBukkit start
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.random.nextInt(3);
int k;
if (j > 0) {
loot.add(new CraftItemStack(Block.RED_ROSE.id, j));
}
k = 3 + this.random.nextInt(3);
if (k > 0) {
loot.add(new CraftItemStack(Item.IRON_INGOT.id, k));
}
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
public int p() {
return this.g;
}
public boolean q() {
return (this.datawatcher.getByte(16) & 1) != 0;
}
public void f(boolean flag) {
byte b0 = this.datawatcher.getByte(16);
if (flag) {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1)));
} else {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -2)));
}
}
}
| Irokue/Craftbukkit-1.3 | src/main/java/net/minecraft/server/EntityIronGolem.java | Java | gpl-3.0 | 5,216 |
/*
* JasperReports - Free Java Reporting Library.
* Copyright (C) 2001 - 2014 TIBCO Software Inc. All rights reserved.
* http://www.jaspersoft.com
*
* Unless you have purchased a commercial license agreement from Jaspersoft,
* the following license terms apply:
*
* This program is part of JasperReports.
*
* JasperReports is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JasperReports is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.jasperreports.engine.util;
/**
* An XML namespace.
*
* @author Lucian Chirita (lucianc@users.sourceforge.net)
* @see JRXmlWriteHelper#startElement(String, XmlNamespace)
*/
public class XmlNamespace
{
private final String nsURI;
private final String prefix;
private final String schemaURI;
/**
* Creates an XML namespace.
*
* @param uri the namespace URI
* @param prefix the namespace prefix
* @param schemaURI the URI of the XML schema associated with the namespace
*/
public XmlNamespace(String uri, String prefix, String schemaURI)
{
this.prefix = prefix;
this.schemaURI = schemaURI;
this.nsURI = uri;
}
/**
* Returns the namespace URI.
*
* @return the namespace URI
*/
public String getNamespaceURI()
{
return nsURI;
}
/**
* Returns the namespace prefix.
*
* @return the namespace prefix
*/
public String getPrefix()
{
return prefix;
}
/**
* Returns the URI of the XML schema associated with the namespace.
*
* @return the namespace XML schema URI
*/
public String getSchemaURI()
{
return schemaURI;
}
}
| aleatorio12/ProVentasConnector | jasperreports-6.2.1-project/jasperreports-6.2.1/src/net/sf/jasperreports/engine/util/XmlNamespace.java | Java | gpl-3.0 | 2,097 |
/**
* TiempoBus - Informacion sobre tiempos de paso de autobuses en Alicante
* Copyright (C) 2012 Alberto Montiel
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package alberapps.java.exception;
/**
*
*/
public class TiempoBusException extends Exception {
/**
*
*/
private static final long serialVersionUID = -2041443242078108937L;
public static int ERROR_STATUS_SERVICIO = 1;
public static String ERROR_STATUS_SERVICIO_MSG = "Error en el status del servicio";
public static int ERROR_005_SERVICIO = 2;
public static int ERROR_NO_DEFINIDO = 3;
private int codigo;
/**
*
*/
public TiempoBusException() {
}
public TiempoBusException(int cod) {
super(ERROR_STATUS_SERVICIO_MSG);
codigo = cod;
}
/**
* @param detailMessage
*/
public TiempoBusException(String detailMessage) {
super(detailMessage);
}
/**
* @param throwable
*/
public TiempoBusException(Throwable throwable) {
super(throwable);
}
/**
* @param detailMessage
* @param throwable
*/
public TiempoBusException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
public int getCodigo() {
return codigo;
}
public void setCodigo(int codigo) {
this.codigo = codigo;
}
}
| alberapps/tiempobus | TiempoBus/src/alberapps/java/exception/TiempoBusException.java | Java | gpl-3.0 | 2,003 |
import pilas
import json
from pilas.escena import Base
from general import General
from individual import Individual
class jugadores(Base):
def __init__(self):
Base.__init__(self)
def fondo(self):
pilas.fondos.Fondo("data/img/fondos/aplicacion.jpg")
def general(self):
self.sonido_boton.reproducir()
pilas.almacenar_escena(General())
def individual(self):
self.sonido_boton.reproducir()
pilas.almacenar_escena(Individual())
def volver(self):
self.sonido_boton.reproducir()
pilas.recuperar_escena()
def iniciar(self):
self.fondo()
self.sonido_boton = pilas.sonidos.cargar("data/audio/boton.ogg")
self.interfaz()
self.mostrar()
def interfaz(self):
opcion= [("General",self.general),("Individual",self.individual),("Volver",self.volver)]
menu = pilas.actores.Menu(opcion, y=50, fuente="data/fonts/American Captain.ttf")
menu.escala = 1.3
enunciado = pilas.actores.Actor("data/img/enunciados/estadisticas.png",y=250)
enunciado.escala = 0.3 | gercordero/va_de_vuelta | src/estadisticas.py | Python | gpl-3.0 | 1,023 |
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
****************************************************************************/
#include "internalproperty.h"
#include "internalbindingproperty.h"
#include "internalvariantproperty.h"
#include "internalnodelistproperty.h"
#include "internalnodeproperty.h"
#include "internalsignalhandlerproperty.h"
#include "internalnode_p.h"
namespace QmlDesigner {
namespace Internal {
// Creates invalid InternalProperty
InternalProperty::InternalProperty()
{
}
InternalProperty::~InternalProperty()
{
}
InternalProperty::InternalProperty(const PropertyName &name, const InternalNode::Pointer &propertyOwner)
: m_name(name),
m_propertyOwner(propertyOwner)
{
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "Name of property cannot be empty");
}
InternalProperty::Pointer InternalProperty::internalPointer() const
{
Q_ASSERT(!m_internalPointer.isNull());
return m_internalPointer.toStrongRef();
}
void InternalProperty::setInternalWeakPointer(const Pointer &pointer)
{
Q_ASSERT(!pointer.isNull());
m_internalPointer = pointer;
}
bool InternalProperty::isValid() const
{
return m_propertyOwner && !m_name.isEmpty();
}
PropertyName InternalProperty::name() const
{
return m_name;
}
bool InternalProperty::isBindingProperty() const
{
return false;
}
bool InternalProperty::isVariantProperty() const
{
return false;
}
QSharedPointer<InternalBindingProperty> InternalProperty::toBindingProperty() const
{
Q_ASSERT(internalPointer().dynamicCast<InternalBindingProperty>());
return internalPointer().staticCast<InternalBindingProperty>();
}
bool InternalProperty::isNodeListProperty() const
{
return false;
}
bool InternalProperty::isNodeProperty() const
{
return false;
}
bool InternalProperty::isNodeAbstractProperty() const
{
return false;
}
bool InternalProperty::isSignalHandlerProperty() const
{
return false;
}
QSharedPointer<InternalVariantProperty> InternalProperty::toVariantProperty() const
{
Q_ASSERT(internalPointer().dynamicCast<InternalVariantProperty>());
return internalPointer().staticCast<InternalVariantProperty>();
}
InternalNode::Pointer InternalProperty::propertyOwner() const
{
return m_propertyOwner.toStrongRef();
}
QSharedPointer<InternalNodeListProperty> InternalProperty::toNodeListProperty() const
{
Q_ASSERT(internalPointer().dynamicCast<InternalNodeListProperty>());
return internalPointer().staticCast<InternalNodeListProperty>();
}
QSharedPointer<InternalNodeProperty> InternalProperty::toNodeProperty() const
{
Q_ASSERT(internalPointer().dynamicCast<InternalNodeProperty>());
return internalPointer().staticCast<InternalNodeProperty>();
}
QSharedPointer<InternalNodeAbstractProperty> InternalProperty::toNodeAbstractProperty() const
{
Q_ASSERT(internalPointer().dynamicCast<InternalNodeAbstractProperty>());
return internalPointer().staticCast<InternalNodeAbstractProperty>();
}
QSharedPointer<InternalSignalHandlerProperty> InternalProperty::toSignalHandlerProperty() const
{
Q_ASSERT(internalPointer().dynamicCast<InternalSignalHandlerProperty>());
return internalPointer().staticCast<InternalSignalHandlerProperty>();
}
void InternalProperty::remove()
{
propertyOwner()->removeProperty(name());
m_propertyOwner.clear();
}
TypeName InternalProperty::dynamicTypeName() const
{
return m_dynamicType;
}
void InternalProperty::setDynamicTypeName(const TypeName &name)
{
m_dynamicType = name;
}
void InternalProperty::resetDynamicTypeName()
{
m_dynamicType.clear();
}
} //namespace Internal
} //namespace QmlDesigner
| frostasm/qt-creator | src/plugins/qmldesigner/designercore/model/internalproperty.cpp | C++ | gpl-3.0 | 4,688 |
// Decompiled with JetBrains decompiler
// Type: System.Net.Cache.MetadataUpdateStream
// Assembly: System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 5ABD58FD-DF31-44FD-A492-63F2B47CC9AF
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.dll
using System;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Runtime;
using System.Threading;
namespace System.Net.Cache
{
internal class MetadataUpdateStream : BaseWrapperStream, ICloseEx
{
private RequestCache m_Cache;
private string m_Key;
private DateTime m_Expires;
private DateTime m_LastModified;
private DateTime m_LastSynchronized;
private TimeSpan m_MaxStale;
private StringCollection m_EntryMetadata;
private StringCollection m_SystemMetadata;
private bool m_CacheDestroy;
private bool m_IsStrictCacheErrors;
private int _Disposed;
public override bool CanRead
{
get
{
return this.WrappedStream.CanRead;
}
}
public override bool CanSeek
{
get
{
return this.WrappedStream.CanSeek;
}
}
public override bool CanWrite
{
get
{
return this.WrappedStream.CanWrite;
}
}
public override long Length
{
get
{
return this.WrappedStream.Length;
}
}
public override long Position
{
get
{
return this.WrappedStream.Position;
}
set
{
this.WrappedStream.Position = value;
}
}
public override bool CanTimeout
{
get
{
return this.WrappedStream.CanTimeout;
}
}
public override int ReadTimeout
{
get
{
return this.WrappedStream.ReadTimeout;
}
set
{
this.WrappedStream.ReadTimeout = value;
}
}
public override int WriteTimeout
{
get
{
return this.WrappedStream.WriteTimeout;
}
set
{
this.WrappedStream.WriteTimeout = value;
}
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
internal MetadataUpdateStream(Stream parentStream, RequestCache cache, string key, DateTime expiresGMT, DateTime lastModifiedGMT, DateTime lastSynchronizedGMT, TimeSpan maxStale, StringCollection entryMetadata, StringCollection systemMetadata, bool isStrictCacheErrors)
: base(parentStream)
{
this.m_Cache = cache;
this.m_Key = key;
this.m_Expires = expiresGMT;
this.m_LastModified = lastModifiedGMT;
this.m_LastSynchronized = lastSynchronizedGMT;
this.m_MaxStale = maxStale;
this.m_EntryMetadata = entryMetadata;
this.m_SystemMetadata = systemMetadata;
this.m_IsStrictCacheErrors = isStrictCacheErrors;
}
private MetadataUpdateStream(Stream parentStream, RequestCache cache, string key, bool isStrictCacheErrors)
: base(parentStream)
{
this.m_Cache = cache;
this.m_Key = key;
this.m_CacheDestroy = true;
this.m_IsStrictCacheErrors = isStrictCacheErrors;
}
public override long Seek(long offset, SeekOrigin origin)
{
return this.WrappedStream.Seek(offset, origin);
}
public override void SetLength(long value)
{
this.WrappedStream.SetLength(value);
}
public override void Write(byte[] buffer, int offset, int count)
{
this.WrappedStream.Write(buffer, offset, count);
}
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
return this.WrappedStream.BeginWrite(buffer, offset, count, callback, state);
}
public override void EndWrite(IAsyncResult asyncResult)
{
this.WrappedStream.EndWrite(asyncResult);
}
public override void Flush()
{
this.WrappedStream.Flush();
}
public override int Read(byte[] buffer, int offset, int count)
{
return this.WrappedStream.Read(buffer, offset, count);
}
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
return this.WrappedStream.BeginRead(buffer, offset, count, callback, state);
}
public override int EndRead(IAsyncResult asyncResult)
{
return this.WrappedStream.EndRead(asyncResult);
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
protected override sealed void Dispose(bool disposing)
{
this.Dispose(disposing, CloseExState.Normal);
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
void ICloseEx.CloseEx(CloseExState closeState)
{
this.Dispose(true, closeState);
}
protected virtual void Dispose(bool disposing, CloseExState closeState)
{
try
{
if (Interlocked.Increment(ref this._Disposed) != 1 || !disposing)
return;
ICloseEx closeEx = this.WrappedStream as ICloseEx;
if (closeEx != null)
closeEx.CloseEx(closeState);
else
this.WrappedStream.Close();
if (this.m_CacheDestroy)
{
if (this.m_IsStrictCacheErrors)
this.m_Cache.Remove(this.m_Key);
else
this.m_Cache.TryRemove(this.m_Key);
}
else if (this.m_IsStrictCacheErrors)
this.m_Cache.Update(this.m_Key, this.m_Expires, this.m_LastModified, this.m_LastSynchronized, this.m_MaxStale, this.m_EntryMetadata, this.m_SystemMetadata);
else
this.m_Cache.TryUpdate(this.m_Key, this.m_Expires, this.m_LastModified, this.m_LastSynchronized, this.m_MaxStale, this.m_EntryMetadata, this.m_SystemMetadata);
}
finally
{
base.Dispose(disposing);
}
}
}
}
| mater06/LEGOChimaOnlineReloaded | LoCO Client Files/Decompressed Client/Extracted DLL/System/System/Net/Cache/MetadataUpdateStream.cs | C# | gpl-3.0 | 5,953 |
/*
* Copyright (C) 2017 Jonas Zeiger <jonas.zeiger@talpidae.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.talpidae.base.client;
import net.talpidae.base.insect.config.SlaveSettings;
import java.io.IOException;
import java.util.Optional;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.ext.Provider;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import static com.google.common.base.Strings.isNullOrEmpty;
/**
* Adds the insect name to the user-agent header value.
*/
@Singleton
@Provider
@Slf4j
public class InsectNameUserAgentRequestFilter implements ClientRequestFilter
{
private final String insectName;
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
@Inject
public InsectNameUserAgentRequestFilter(Optional<SlaveSettings> slaveSettings)
{
insectName = slaveSettings.map(SlaveSettings::getName).orElse(null);
}
@Override
public void filter(ClientRequestContext requestContext) throws IOException
{
if (insectName != null)
{
val userAgent = requestContext.getHeaderString(HttpHeaders.USER_AGENT);
val nextUserAgent = isNullOrEmpty(userAgent) ? insectName : insectName + "/" + userAgent;
requestContext.getHeaders().putSingle(HttpHeaders.USER_AGENT, nextUserAgent);
}
}
}
| lyind/base | src/main/java/net/talpidae/base/client/InsectNameUserAgentRequestFilter.java | Java | gpl-3.0 | 2,100 |
package org.smap.sdal.model;
public class TaskAssignmentPair {
public int taskId;
public int assignmentId;
}
| smap-consulting/smapserver | sdDAL/src/org/smap/sdal/model/TaskAssignmentPair.java | Java | gpl-3.0 | 112 |
<?php
require_once 'users/init.php';
global $errors, $successes, $thisUserID;
require_once 'usersc/includes/general.php';
global $abs_us_root, $us_url_root;
global $PERMISSION, $UPLOADS, $seasonsArray;
require_once $abs_us_root . $us_url_root . 'users/includes/header.php';
// This should be set before including navigation
$queryParameter = "player=" . (string)Input::get('player');
require_once $abs_us_root . $us_url_root . 'users/includes/navigation.php';
require_once $abs_us_root . $us_url_root . 'usersc/classes/PlayerStats.php';
require_once $abs_us_root . $us_url_root . 'usersc/classes/Player.php';
if (!securePage($_SERVER['PHP_SELF'])) die();
//Check if user has the required permission
if ($user->isLoggedIn())
{
$thisUserID = $user->data()->id;
$data = $user->data();
$permission = (checkMenu($PERMISSION['administrator'], $user->data()->id));
} else {
$permission = false;
}
$player = Input::get('player');
$history = $player ? PlayerStats::getSeasonElo($season,$player) : null;
?>
<div id="page-wrapper">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading"><strong>ELO History</strong></div>
<div class="panel-body">
This a report for a browse the ELO's changes in the season <span class="strong"><?= $seasonsArray[$season]['reference'] ?></span> for the player
<span class="strong"><?= Player::getNameByID($player); ?></span> <?= printID($player); ?>.
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 beforeLoad">
<div class="table-responsive well center">
<h2>... LOADING ...</h2>
</div>
</div>
<?php if (!count($history)) { ?>
<?php include($abs_us_root . $us_url_root . 'usersc/includes/no_results.php'); ?>
<?php } else { ?>
<div class="col-md-12 afterLoad">
<div class="well table-responsive">
<div class="pager">
<form>
<i class="fa icon pager-action fa-step-backward first"></i>
<i class="fa icon pager-action fa-backward prev"></i>
<!-- the "pagedisplay" can be any element, including an input -->
<span class="pagedisplay" data-pager-output-filtered="{startRow:input} – {endRow} / {filteredRows} of {totalRows} total rows"></span>
<i class="fa icon pager-action fa-forward next"></i>
<i class="fa icon pager-action fa-step-forward last"></i>
<select class="pagesize">
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="all">All Rows</option>
</select>
</form>
</div>
<table id="player_elo" class="tablesorter">
<thead>
<tr>
<th class="fit-70 center">Order</th>
<th class="fit-110">Date</th>
<th>Opponent</th>
<th class="fit-90 center">Result</th>
<th class="fit-110 center">Opponent's ELO</th>
<th class="fit-110 center">Player's ELO</th>
<th class="fit-110 center">ELO Change</th>
<th class="fit-110 center">Player's new ELO</th>
</tr>
</thead>
<tbody>
<?php
$count = 0;
foreach ($history as $row) { $count++; ?>
<tr>
<td class="fit-70 center"><?= $count; ?></td>
<td class="fit-110 no-wrap"><?= $row['date']; ?></td>
<td class="fit-240">
<span class="strong"><?= Player::getNameByID($row['opponent']); ?></span> <?= printID($row['opponent']) ?> <?= Player::getNickByID($row['opponent']) ? '(' . Player::getNickByID($row['opponent']) . ')' : "" ; ?>
</td>
<td class="fit-90 center">
<?php
if ($row['winner'] == $row['opponent'])
{
echo 'Loss';
} elseif ($row['winner'] == $player) {
echo 'Win';
} else {
echo 'Draw';
}
?>
</td>
<td class="fit-90 center"><?= round($row['oldOpELO'], $PRECISION);?></td>
<td class="fit-90 center"><?= round($row['oldELO'], $PRECISION); ?></td>
<td class="fit-90 center strong <?= $row['ELOChange'] > 0 ? 'ELOgreen' : 'ELOred' ?>"><?=$row['ELOChange'] > 0 ? '+' : '' ?><?= round($row['ELOChange'], $PRECISION); ?></td>
<td class="fit-90 center"><?= round($row['newELO'], $PRECISION); ?></td>
<?php } ?>
</tbody>
</table>
<div class="pager">
<form>
<i class="fa icon pager-action fa-step-backward first"></i>
<i class="fa icon pager-action fa-backward prev"></i>
<!-- the "pagedisplay" can be any element, including an input -->
<span class="pagedisplay" data-pager-output-filtered="{startRow:input} – {endRow} / {filteredRows} of {totalRows} total rows"></span>
<i class="fa icon pager-action fa-forward next"></i>
<i class="fa icon pager-action fa-step-forward last"></i>
<select class="pagesize">
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="all">All Rows</option>
</select>
</form>
</div>
</div>
</div><!-- /.col -->
<?php } ?>
</div><!-- /.row -->
</div> <!-- /.container -->
</div> <!-- /.wrapper -->
<!-- footers -->
<?php require_once $abs_us_root . $us_url_root . 'users/includes/page_footer.php'; // the final html footer copyright row + the external js calls ?>
<script type="text/javascript" src="usersc/js/3rd/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="usersc/js/3rd/jquery.tablesorter.widgets.js"></script>
<script type="text/javascript" src="usersc/js/3rd/widget-pager.js"></script>
<script type="text/javascript" src="usersc/js/3rd/jquery.redirect.js"></script>
<script type="text/javascript" src="usersc/js/player_elo.js"></script>
<?php require_once $abs_us_root . $us_url_root . 'users/includes/html_footer.php'; // currently just the closing /body and /html ?> | klaymen/mk.ladder | player_elo.php | PHP | gpl-3.0 | 7,864 |
import logging
logging.basicConfig()
from enum import Enum
logger = logging.getLogger('loopabull')
logger.setLevel(logging.INFO)
class Result(Enum):
runfinished = 1
runerrored = 2
unrouted = 3
error = 4
# vim: set expandtab sw=4 sts=4 ts=4
| maxamillion/loopabull | loopabull/__init__.py | Python | gpl-3.0 | 261 |
<?php
/**
* Students Metabox on admin panel
*
* @package LifterLMS/Templates/Admin
*
* @since 3.0.0
* @version 3.13.0
*/
defined( 'ABSPATH' ) || exit;
if ( ! is_admin() ) {
exit;
}
$table = new LLMS_Table_StudentManagement();
$table->get_results();
?>
<div class="llms-metabox llms-metabox-students">
<?php do_action( 'lifterlms_before_students_metabox' ); ?>
<div class="llms-metabox-section llms-metabox-students-enrollments no-top-margin">
<?php echo $table->get_table_html(); ?>
</div>
<?php if ( current_user_can( 'enroll' ) ) : ?>
<div class="llms-metabox-section llms-metabox-students-add-new">
<h2><?php echo __( 'Enroll New Students', 'lifterlms' ); ?></h2>
<div class="llms-metabox-field d-all">
<select id="llms-add-student-select" multiple="multiple" name="_llms_add_student"></select>
</div>
<div class="llms-metabox-field d-all d-right">
<button class="llms-button-primary" id="llms-enroll-students" type="button"><?php _e( 'Enroll Students', 'lifterlms' ); ?></button>
</div>
<div class="clear"></div>
</div>
<?php endif; ?>
<?php do_action( 'lifterlms_after_students_metabox' ); ?>
</div>
| gocodebox/lifterlms | templates/admin/post-types/students.php | PHP | gpl-3.0 | 1,164 |
/*
* Ipsum is a rapid development API for Minecraft, developer by Relicum
* Copyright (C) 2015. Chris Lutte
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.relicum.ipsum.Menus;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import com.relicum.ipsum.Conversations.MMPlayer;
/**
* Name: RunCommand.java Created: 21 January 2015
*
* @author Relicum
* @version 0.0.1
*/
public class RunCommand implements Perform {
private List<String> commands;
@Getter
private boolean useConsole;
@Getter
private MMPlayer player;
public RunCommand() {
this.commands = new ArrayList<>();
}
@Override
public void addCommand(String cmd) {
commands.add(cmd);
}
@Override
public List<String> getCommands() {
return commands;
}
@Override
public void setUseConsole(boolean use) {
Validate.notNull(use);
this.useConsole = use;
}
@Override
public void addPlayer(MMPlayer player) {
Validate.notNull(player);
this.player = player;
}
@Override
public void perform() {
for (String cmd : commands) {
if (useConsole)
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd.replaceAll("\\\\", ""));
else
this.player.performCommand(cmd.replaceAll("\\\\", "/"));
}
}
}
| Relicum/Ipsum | src/main/java/com/relicum/ipsum/Menus/RunCommand.java | Java | gpl-3.0 | 2,079 |
<?php
namespace AppBundle\Services;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class FileUploader
{
private $targetDir;
public function __construct($targetDir)
{
$this->targetDir = $targetDir;
}
public function upload(UploadedFile $file)
{
$fileName = md5(uniqid()).'.'.$file->guessExtension();
$file->move($this->targetDir, $fileName);
return $fileName;
}
public function getTargetDir()
{
return $this->targetDir;
}
} | Bosswell/FileUploader | FileUploader.php | PHP | gpl-3.0 | 547 |
# Cookbook:: web_server
# Server Spec:: nginx
require 'serverspec'
set :backend, :exec
def nginx_spec(app_name, ips, https, www: false, site_down: true)
if os[:family] == 'ubuntu'
ip_regex = Regexp.escape(ips[os[:release]])
if www
server_name = /^\s+server_name\s+#{ip_regex}\s+www\.#{ip_regex};$/
else
server_name = /^\s+server_name\s+#{ip_regex};$/
end
describe command( 'ufw status numbered' ) do
expected_rules = [
%r{^\[(\s|\d)\d\]\s+22/tcp\s+ALLOW IN\s+Anywhere\s*$},
%r{^\[(\s|\d)\d\]\s+80/tcp\s+ALLOW IN\s+Anywhere\s*$},
%r{^\[(\s|\d)\d\]\s+22/tcp\s+\(v6\)\s+ALLOW IN\s+Anywhere\s+\(v6\)\s*$},
%r{^\[(\s|\d)\d\]\s+80/tcp\s+\(v6\)\s+ALLOW IN\s+Anywhere\s+\(v6\)\s*$},
%r{^\[(\s|\d)\d\]\s+22,53,80,443/tcp\s+ALLOW OUT\s+Anywhere\s+\(out\)$},
%r{^\[(\s|\d)\d\]\s+53,67,68/udp\s+ALLOW OUT\s+Anywhere\s+\(out\)$},
%r{^\[(\s|\d)\d\]\s+22,53,80,443/tcp\s+\(v6\)\s+ALLOW OUT\s+Anywhere\s+\(v6\)\s+\(out\)$},
%r{^\[(\s|\d)\d\]\s+53,67,68/udp\s+\(v6\)\s+ALLOW OUT\s+Anywhere\s+\(v6\)\s+\(out\)$}
]
https_rules = [
%r{^\[(\s|\d)\d\]\s+443/tcp\s+ALLOW IN\s+Anywhere\s*$},
%r{^\[(\s|\d)\d\]\s+443/tcp\s+\(v6\)\s+ALLOW IN\s+Anywhere\s+\(v6\)\s*$}
]
if https
expected_rules += https_rules
end
its(:stdout) { should match(/Status: active/) }
expected_rules.each do |r|
its(:stdout) { should match(r) }
end
end
describe package('nginx') do
it { should be_installed }
end
describe service('nginx') do
it { should be_enabled }
it { should be_running }
end
# installs a python runtime
if os[:release] == '14.04'
describe package('python3.4') do
it { should be_installed }
end
describe file('/usr/bin/python3.4') do
it { should exist }
it { should be_file }
end
describe command ( 'pip -V' ) do
pip3_version = %r(pip \d+\.\d+\.\d+ from /usr/local/lib/python3\.4/dist-packages \(python 3\.4\))
its(:stdout) { should match(pip3_version)}
end
describe package('python3.4-dev') do
it { should be_installed }
end
describe command ('pip list | grep virtualenv') do
its(:stdout) { should match(/virtualenv\s+\(\d+\.\d+\.\d+\)/)}
end
end
if os[:release] == '16.04'
describe package('python3.5') do
it { should be_installed }
end
describe file('/usr/bin/python3.5') do
it { should exist }
it { should be_file }
end
describe command ( 'pip3 -V' ) do
pip3_version = %r(pip \d+\.\d+\.\d+ from /usr/local/lib/python3\.5/dist-packages \(python 3\.5\))
its(:stdout) { should match(pip3_version)}
end
describe package('python3.5-dev') do
it { should be_installed }
end
describe package('python3-pip') do
it { should be_installed }
end
describe package('python3-venv') do
it { should be_installed }
end
end
describe file("/etc/nginx/sites-available/#{app_name}.conf") do
params = [
/^# #{app_name}.conf$/,
%r(^\s+server unix:///home/app_user/sites/#{app_name}/sockets/#{app_name}\.sock; # for a file socket$),
/^\s+# server 127\.0\.0\.1:8001; # for a web port socket/,
/^\s+listen\s+80;$/,
server_name,
%r(^\s+alias /home/web_user/sites/#{app_name}/media;),
%r(^\s+alias /home/web_user/sites/#{app_name}/static;),
%r(^\s+include\s+/home/web_user/sites/#{app_name}/uwsgi/uwsgi_params;$)
]
it { should exist }
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 400 }
params.each do |p|
its(:content) { should match(p) }
end
end
site_down_conf = %W(/etc/nginx/sites-available/#{app_name}_down.conf
/etc/nginx/sites-enabled/#{app_name}_down.conf)
site_down_conf.each() do |f|
describe file(f) do
params = [
/^# #{app_name}_down.conf$/,
%r(^\s+index index.html;$),
/^\s+listen\s+80;$/,
server_name,
%r(^\s+root /home/web_user/sites/#{app_name}/down;)
]
if f == "/etc/nginx/sites-available/#{app_name}_down.conf"
it { should exist }
it { should be_file }
it { should be_mode 400 }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
params.each do |p|
its(:content) { should match(p) }
end
elsif f == "/etc/nginx/sites-enabled/#{app_name}_down.conf"
if site_down
it { should exist }
else
it { should_not exist }
end
end
end
end
describe file('/home/web_user/sites') do
it {should exist}
it {should be_directory}
it {should be_owned_by 'web_user'}
it {should be_grouped_into 'www-data'}
it {should be_mode 550}
end
describe file("/home/web_user/sites/#{app_name}") do
it {should exist}
it {should be_directory}
it {should be_owned_by 'web_user'}
it {should be_grouped_into 'www-data'}
it {should be_mode 550}
end
site_paths = %w(static media uwsgi down)
site_paths.each do |s|
describe file("/home/web_user/sites/#{app_name}/#{s}") do
it {should exist}
it {should be_directory}
it {should be_owned_by 'web_user'}
it {should be_grouped_into 'www-data'}
it {should be_mode 550}
end
end
describe file("/home/web_user/sites/#{app_name}/down/index.html") do
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'www-data' }
it { should be_mode 440 }
its(:content) { should match(%r(^\s+<title id="head-title">#{app_name}(\.eu|\.org){0,1} site down</title>$)i) }
end
# Install scripts should be present
describe file("/home/web_user/sites/#{app_name}/scripts") do
it { should exist }
it { should be_directory }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'web_user' }
it { should be_mode 500 }
end
scripts = ['webserver.py', 'djangoapp.py']
scripts.each do |s|
describe file "/home/web_user/sites/#{app_name}/scripts/#{s}" do
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'web_user' }
it { should be_mode 500 }
end
end
describe file "/home/web_user/sites/#{app_name}/scripts/utilities/commandfileutils.py" do
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'web_user' }
it { should be_mode 400 }
end
# Scripts dependencies should be present
describe package('python3-pip') do
it { should be_installed }
end
describe command ('pip3 list | grep psutil') do
its(:stdout) { should match(/psutil\s+\(\d+\.\d+\.\d+\)/)}
end
# Config file for for installation scripts should be present
describe file("/home/web_user/sites/#{app_name}/scripts/conf.py") do
params = [
%r(^DIST_VERSION = '#{os[:release]}'$),
%r(^LOG_LEVEL = 'DEBUG'$),
%r(^NGINX_CONF = ''$),
%r(^APP_HOME = ''$),
%r(^APP_HOME_TMP = '/home/web_user/sites/#{app_name}/source'$),
%r(^APP_USER = ''$),
%r(^WEB_USER = 'web_user'$),
%r(^WEBSERVER_USER = 'www-data'$),
%r(^GIT_REPO = 'https://github\.com/globz-eu/#{app_name}\.git'$),
%r(^STATIC_PATH = '/home/web_user/sites/#{app_name}/static'$),
%r(^MEDIA_PATH = '/home/web_user/sites/#{app_name}/media'$),
%r(^UWSGI_PATH = '/home/web_user/sites/#{app_name}/uwsgi'$),
%r(^VENV = '/home/web_user/.envs/#{app_name}'$),
%r(^REQS_FILE = ''$),
%r(^SYS_DEPS_FILE = ''$),
%r(^LOG_FILE = '/var/log/#{app_name}/serve_static\.log'$),
%r(^FIFO_DIR = ''$)
]
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'web_user' }
it { should be_mode 400 }
params.each do |p|
its(:content) { should match(p)}
end
end
# settings.json file should be present
describe file("/home/web_user/sites/#{app_name}/conf.d") do
it {should exist}
it {should be_directory}
it {should be_owned_by 'web_user'}
it {should be_grouped_into 'web_user'}
it {should be_mode 750}
end
describe file("/home/web_user/sites/#{app_name}/conf.d/settings.json") do
params = [
%r(^\s+"SECRET_KEY": "n\)#o5pw7kelvr982iol48tz--n#q!\*8681k3sv0\^\*q#-lddwv!",$),
%r(^\s+"DEBUG": false,$),
%r(^\s+"ALLOWED_HOSTS": \[""\],$),
%r(^\s+"DB_ENGINE": "",$),
%r(^\s+"DB_NAME": "",$),
%r(^\s+"DB_USER": "",$),
%r(^\s+"DB_PASSWORD": "",$),
%r(^\s+"DB_ADMIN_USER": "",$),
%r(^\s+"DB_ADMIN_PASSWORD": "",$),
%r(^\s+"DB_HOST": "",$),
%r(^\s+"TEST_DB_NAME": "",$),
%r(^\s+"BROKER_URL": "",$),
%r(^\s+"CELERY_RESULT_BACKEND": "",$),
%r(^\s+"SECURE_SSL_REDIRECT": false,$),
%r(^\s+"SECURE_PROXY_SSL_HEADER": \[\],$),
%r(^\s+"CHROME_DRIVER": "",$),
%r(^\s+"FIREFOX_BINARY": "",$),
%r(^\s+"SERVER_URL": "",$),
%r(^\s+"HEROKU": false$),
]
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'web_user' }
it { should be_mode 400 }
params.each do |p|
its(:content) { should match(p)}
end
end
# Static files should be present
describe file("/home/web_user/sites/#{app_name}/static/bootstrap") do
it { should exist }
it { should be_directory }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'www-data' }
it { should be_mode 550 }
end
describe file("/home/web_user/sites/#{app_name}/static/bootstrap/css/bootstrap.css") do
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'www-data' }
it { should be_mode 440 }
end
describe file("/home/web_user/sites/#{app_name}/media/media.txt") do
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'www-data' }
it { should be_mode 440 }
end
describe file("/home/web_user/sites/#{app_name}/uwsgi/uwsgi_params") do
it { should exist }
it { should be_file }
it { should be_owned_by 'web_user' }
it { should be_grouped_into 'www-data' }
it { should be_mode 440 }
end
# App log directory should be present
describe file("/var/log/#{app_name}") do
it { should exist }
it { should be_directory }
it { should be_owned_by 'root' }
it { should be_grouped_into 'loggers' }
it { should be_mode 775 }
end
describe file('/etc/nginx/sites-enabled/default') do
it { should_not exist }
end
end
end
| globz-eu/infrastructure | chef-repo/cookbooks/standalone_app_server/test/integration/helpers/serverspec/nginx.rb | Ruby | gpl-3.0 | 11,500 |
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace DrakSolz.Tiles {
public class CorruptBanner : ModTile {
public override void SetDefaults() {
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileLavaDeath[Type] = true;
TileObjectData.newTile.CopyFrom(TileObjectData.Style1x2Top);
TileObjectData.newTile.Height = 3;
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16 };
TileObjectData.newTile.StyleHorizontal = true;
TileObjectData.newTile.StyleWrapLimit = 111;
TileObjectData.addTile(Type);
dustType = -1;
disableSmartCursor = true;
ModTranslation name = CreateMapEntryName();
name.SetDefault("Banner");
AddMapEntry(new Color(13, 88, 130), name);
}
public override void KillMultiTile(int i, int j, int frameX, int frameY) {
int style = frameX / 18;
string item;
switch (style) {
case 0:
item = "DeepfireDevourerBanner";
break;
case 1:
item = "CarrionCollectorBanner";
break;
case 2:
item = "HexclawBanner";
break;
case 3:
item = "DesolatorBanner";
break;
case 4:
item = "SoulWraithBanner";
break;
case 5:
item = "VorpalReaverBanner";
break;
case 6:
item = "BlackSolusBanner";
break;
case 7:
item = "GibbetBanner";
break;
default:
return;
}
Item.NewItem(i * 16, j * 16, 16, 48, DrakSolz.instance.ItemType(item));
}
public override void NearbyEffects(int i, int j, bool closer) {
if (closer) {
Player player = Main.LocalPlayer;
int style = Main.tile[i, j].frameX / 18;
string type;
switch (style) {
case 0:
type = "DeepfireDevourer";
break;
case 1:
type = "CarrionCollector";
break;
case 2:
type = "Hexclaw";
break;
case 3:
type = "Desolator";
break;
case 4:
type = "SoulWraith";
break;
case 5:
type = "VorpalReaver";
break;
case 6:
type = "BlackSolus";
break;
case 7:
type = "Gibbet";
break;
default:
return;
}
player.NPCBannerBuff[DrakSolz.instance.NPCType(type)] = true;
player.hasBanner = true;
}
}
public override void SetSpriteEffects(int i, int j, ref SpriteEffects spriteEffects) {
if (i % 2 == 1) {
spriteEffects = SpriteEffects.FlipHorizontally;
}
}
}
} | Xahlicem/DrakSolz | Tiles/CorruptBanner.cs | C# | gpl-3.0 | 3,563 |
class FrameTime
def initialize(&blk)
@t_blk = blk
@last_time = @t_blk.call
end
def dt
current_time = @t_blk.call
delta_time = current_time - @last_time
@last_time = current_time
return delta_time
end
end
| jvranish/shape-loader | frame_time.rb | Ruby | gpl-3.0 | 241 |
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Shell Hu
* Copyright (C) 2013 Shell Hu
*/
#include <shogun/structure/FactorGraphModel.h>
#include <shogun/structure/Factor.h>
#include <shogun/features/FactorGraphFeatures.h>
#include <shogun/mathematics/Math.h>
#include <shogun/mathematics/linalg/LinalgNamespace.h>
#include <unordered_map>
typedef std::unordered_map<int32_t, int32_t> factor_counts_type;
using namespace shogun;
CFactorGraphModel::CFactorGraphModel()
: CStructuredModel()
{
init();
}
CFactorGraphModel::CFactorGraphModel(CFeatures* features, CStructuredLabels* labels,
EMAPInferType inf_type, bool verbose) : CStructuredModel(features, labels)
{
init();
m_inf_type = inf_type;
m_verbose = verbose;
}
CFactorGraphModel::~CFactorGraphModel()
{
SG_UNREF(m_factor_types);
}
void CFactorGraphModel::init()
{
SG_ADD((CSGObject**)&m_factor_types, "factor_types", "Array of factor types", MS_NOT_AVAILABLE);
SG_ADD(&m_w_cache, "w_cache", "Cache of global parameters", MS_NOT_AVAILABLE);
SG_ADD(&m_w_map, "w_map", "Parameter mapping", MS_NOT_AVAILABLE);
m_inf_type = TREE_MAX_PROD;
m_factor_types = new CDynamicObjectArray();
m_verbose = false;
SG_REF(m_factor_types);
}
void CFactorGraphModel::add_factor_type(CFactorType* ftype)
{
REQUIRE(ftype->get_w_dim() > 0, "%s::add_factor_type(): number of parameters can't be 0!\n",
get_name());
// check whether this ftype has been added
int32_t id = ftype->get_type_id();
for (int32_t fi = 0; fi < m_factor_types->get_num_elements(); ++fi)
{
CFactorType* ft= dynamic_cast<CFactorType*>(m_factor_types->get_element(fi));
if (id == ft->get_type_id())
{
SG_UNREF(ft);
SG_PRINT("%s::add_factor_type(): factor_type (id = %d) has been added!\n",
get_name(), id);
return;
}
SG_UNREF(ft);
}
SGVector<int32_t> w_map_cp = m_w_map.clone();
m_w_map.resize_vector(w_map_cp.size() + ftype->get_w_dim());
for (int32_t mi = 0; mi < w_map_cp.size(); mi++)
{
m_w_map[mi] = w_map_cp[mi];
}
// add new mapping in the end
for (int32_t mi = w_map_cp.size(); mi < m_w_map.size(); mi++)
{
m_w_map[mi] = id;
}
// push factor type
m_factor_types->push_back(ftype);
// initialize w cache
fparams_to_w();
if (m_verbose)
{
m_w_map.display_vector("add_factor_type(): m_w_map");
}
}
void CFactorGraphModel::del_factor_type(const int32_t ftype_id)
{
int w_dim = 0;
// delete from m_factor_types
for (int32_t fi = 0; fi < m_factor_types->get_num_elements(); ++fi)
{
CFactorType* ftype = dynamic_cast<CFactorType*>(m_factor_types->get_element(fi));
if (ftype_id == ftype->get_type_id())
{
w_dim = ftype->get_w_dim();
SG_UNREF(ftype);
m_factor_types->delete_element(fi);
break;
}
SG_UNREF(ftype);
}
ASSERT(w_dim != 0);
SGVector<int32_t> w_map_cp = m_w_map.clone();
m_w_map.resize_vector(w_map_cp.size() - w_dim);
int ind = 0;
for (int32_t mi = 0; mi < w_map_cp.size(); mi++)
{
if (w_map_cp[mi] == ftype_id)
continue;
m_w_map[ind++] = w_map_cp[mi];
}
ASSERT(ind == m_w_map.size());
}
CDynamicObjectArray* CFactorGraphModel::get_factor_types() const
{
SG_REF(m_factor_types);
return m_factor_types;
}
CFactorType* CFactorGraphModel::get_factor_type(const int32_t ftype_id) const
{
for (int32_t fi = 0; fi < m_factor_types->get_num_elements(); ++fi)
{
CFactorType* ftype = dynamic_cast<CFactorType*>(m_factor_types->get_element(fi));
if (ftype_id == ftype->get_type_id())
return ftype;
SG_UNREF(ftype);
}
return NULL;
}
SGVector<int32_t> CFactorGraphModel::get_global_params_mapping() const
{
return m_w_map.clone();
}
SGVector<int32_t> CFactorGraphModel::get_params_mapping(const int32_t ftype_id)
{
return m_w_map.find(ftype_id);
}
int32_t CFactorGraphModel::get_dim() const
{
return m_w_map.size();
}
SGVector<float64_t> CFactorGraphModel::fparams_to_w()
{
REQUIRE(m_factor_types != NULL, "%s::fparams_to_w(): no factor types!\n", get_name());
if (m_w_cache.size() != get_dim())
m_w_cache.resize_vector(get_dim());
int32_t offset = 0;
for (int32_t fi = 0; fi < m_factor_types->get_num_elements(); ++fi)
{
CFactorType* ftype = dynamic_cast<CFactorType*>(m_factor_types->get_element(fi));
int32_t w_dim = ftype->get_w_dim();
offset += w_dim;
SGVector<float64_t> fw = ftype->get_w();
SGVector<int32_t> fw_map = get_params_mapping(ftype->get_type_id());
ASSERT(fw_map.size() == fw.size());
for (int32_t wi = 0; wi < w_dim; wi++)
m_w_cache[fw_map[wi]] = fw[wi];
SG_UNREF(ftype);
}
ASSERT(offset == m_w_cache.size());
return m_w_cache;
}
void CFactorGraphModel::w_to_fparams(SGVector<float64_t> w)
{
// if nothing changed
if (m_w_cache.equals(w))
return;
if (m_verbose)
SG_SPRINT("****** update m_w_cache!\n");
ASSERT(w.size() == m_w_cache.size());
m_w_cache = w.clone();
int32_t offset = 0;
for (int32_t fi = 0; fi < m_factor_types->get_num_elements(); ++fi)
{
CFactorType* ftype = dynamic_cast<CFactorType*>(m_factor_types->get_element(fi));
int32_t w_dim = ftype->get_w_dim();
offset += w_dim;
SGVector<float64_t> fw(w_dim);
SGVector<int32_t> fw_map = get_params_mapping(ftype->get_type_id());
for (int32_t wi = 0; wi < w_dim; wi++)
fw[wi] = m_w_cache[fw_map[wi]];
ftype->set_w(fw);
SG_UNREF(ftype);
}
ASSERT(offset == m_w_cache.size());
}
SGVector< float64_t > CFactorGraphModel::get_joint_feature_vector(int32_t feat_idx, CStructuredData* y)
{
// factor graph instance
CFactorGraphFeatures* mf = CFactorGraphFeatures::obtain_from_generic(m_features);
CFactorGraph* fg = mf->get_sample(feat_idx);
// ground truth states
CFactorGraphObservation* fg_states = CFactorGraphObservation::obtain_from_generic(y);
SGVector<int32_t> states = fg_states->get_data();
// initialize psi
SGVector<float64_t> psi(get_dim());
psi.zero();
// construct unnormalized psi
CDynamicObjectArray* facs = fg->get_factors();
for (int32_t fi = 0; fi < facs->get_num_elements(); ++fi)
{
CFactor* fac = dynamic_cast<CFactor*>(facs->get_element(fi));
CTableFactorType* ftype = fac->get_factor_type();
int32_t id = ftype->get_type_id();
SGVector<int32_t> w_map = get_params_mapping(id);
ASSERT(w_map.size() == ftype->get_w_dim());
SGVector<float64_t> dat = fac->get_data();
int32_t dat_size = dat.size();
ASSERT(w_map.size() == dat_size * ftype->get_num_assignments());
int32_t ei = ftype->index_from_universe_assignment(states, fac->get_variables());
for (int32_t di = 0; di < dat_size; di++)
psi[w_map[ei*dat_size + di]] += dat[di];
SG_UNREF(ftype);
SG_UNREF(fac);
}
// negation (-E(x,y) = <w,phi(x,y)>)
psi.scale(-1.0);
SG_UNREF(facs);
SG_UNREF(fg);
return psi;
}
// E(x_i, y; w) - E(x_i, y_i; w) >= L(y_i, y) - xi_i
// xi_i >= max oracle
// max oracle := argmax_y { L(y_i, y) - E(x_i, y; w) + E(x_i, y_i; w) }
// := argmin_y { -L(y_i, y) + E(x_i, y; w) } - E(x_i, y_i; w)
// we do energy minimization in inference, so get back to max oracle value is:
// [ L(y_i, y_star) - E(x_i, y_star; w) ] + E(x_i, y_i; w)
CResultSet* CFactorGraphModel::argmax(SGVector<float64_t> w, int32_t feat_idx, bool const training)
{
// factor graph instance
CFactorGraphFeatures* mf = CFactorGraphFeatures::obtain_from_generic(m_features);
CFactorGraph* fg = mf->get_sample(feat_idx);
// prepare factor graph
fg->connect_components();
if (m_inf_type == TREE_MAX_PROD)
{
ASSERT(fg->is_tree_graph());
}
if (m_verbose)
SG_SPRINT("\n------ example %d\n", feat_idx);
// update factor parameters
w_to_fparams(w);
fg->compute_energies();
if (m_verbose)
{
SG_SPRINT("energy table before loss-aug:\n");
fg->evaluate_energies();
}
// prepare CResultSet
CResultSet* ret = new CResultSet();
SG_REF(ret);
ret->psi_computed = true;
// y_truth
CFactorGraphObservation* y_truth =
CFactorGraphObservation::obtain_from_generic(m_labels->get_label(feat_idx));
SGVector<int32_t> states_gt = y_truth->get_data();
// E(x_i, y_i; w)
ret->psi_truth = get_joint_feature_vector(feat_idx, y_truth);
float64_t energy_gt = fg->evaluate_energy(states_gt);
ret->score = energy_gt;
// - min_y [ E(x_i, y; w) - delta(y_i, y) ]
if (training)
{
fg->loss_augmentation(y_truth); // wrong assignments -delta()
if (m_verbose)
{
SG_SPRINT("energy table after loss-aug:\n");
fg->evaluate_energies();
}
}
CMAPInference infer_met(fg, m_inf_type);
infer_met.inference();
// y_star
CFactorGraphObservation* y_star = infer_met.get_structured_outputs();
SGVector<int32_t> states_star = y_star->get_data();
ret->argmax = y_star;
ret->psi_pred = get_joint_feature_vector(feat_idx, y_star);
float64_t l_energy_pred = fg->evaluate_energy(states_star);
ret->score -= l_energy_pred;
ret->delta = delta_loss(y_truth, y_star);
if (m_verbose)
{
float64_t dot_pred = linalg::dot(w, ret->psi_pred);
float64_t dot_truth = linalg::dot(w, ret->psi_truth);
float64_t slack = dot_pred + ret->delta - dot_truth;
SG_SPRINT("\n");
w.display_vector("w");
ret->psi_pred.display_vector("psi_pred");
states_star.display_vector("state_pred");
SG_SPRINT("dot_pred = %f, energy_pred = %f, delta = %f\n\n", dot_pred, l_energy_pred, ret->delta);
ret->psi_truth.display_vector("psi_truth");
states_gt.display_vector("state_gt");
SG_SPRINT("dot_truth = %f, energy_gt = %f\n\n", dot_truth, energy_gt);
SG_SPRINT("slack = %f, score = %f\n\n", slack, ret->score);
}
SG_UNREF(y_truth);
SG_UNREF(fg);
return ret;
}
float64_t CFactorGraphModel::delta_loss(CStructuredData* y1, CStructuredData* y2)
{
CFactorGraphObservation* y_truth = CFactorGraphObservation::obtain_from_generic(y1);
CFactorGraphObservation* y_pred = CFactorGraphObservation::obtain_from_generic(y2);
SGVector<int32_t> s_truth = y_truth->get_data();
SGVector<int32_t> s_pred = y_pred->get_data();
ASSERT(s_pred.size() == s_truth.size());
float64_t loss = 0.0;
for (int32_t si = 0; si < s_pred.size(); si++)
{
if (s_pred[si] != s_truth[si])
loss += y_truth->get_loss_weights()[si];
}
return loss;
}
void CFactorGraphModel::init_training()
{
}
void CFactorGraphModel::init_primal_opt(
float64_t regularization,
SGMatrix< float64_t > & A,
SGVector< float64_t > a,
SGMatrix< float64_t > B,
SGVector< float64_t > & b,
SGVector< float64_t > & lb,
SGVector< float64_t > & ub,
SGMatrix< float64_t > & C)
{
C = SGMatrix< float64_t >::create_identity_matrix(get_dim(), regularization);
REQUIRE(m_factor_types != NULL, "%s::init_primal_opt(): no factor types!\n", get_name());
int32_t dim_w = get_dim();
switch (m_inf_type)
{
case GRAPH_CUT:
lb.resize_vector(dim_w);
ub.resize_vector(dim_w);
SGVector< float64_t >::fill_vector(lb.vector, lb.vlen, -CMath::INFTY);
SGVector< float64_t >::fill_vector(ub.vector, ub.vlen, CMath::INFTY);
for (int32_t fi = 0; fi < m_factor_types->get_num_elements(); ++fi)
{
CFactorType* ftype = dynamic_cast<CFactorType*>(m_factor_types->get_element(fi));
int32_t w_dim = ftype->get_w_dim();
SGVector<int32_t> card = ftype->get_cardinalities();
// TODO: Features of pairwise factor are assume to be 1. Consider more general case, e.g., edge features are availabel.
// for pairwise factors with binary labels
if (card.size() == 2 && card[0] == 2 && card[1] == 2)
{
REQUIRE(w_dim == 4, "GraphCut doesn't support edge features currently.");
SGVector<float64_t> fw = ftype->get_w();
SGVector<int32_t> fw_map = get_params_mapping(ftype->get_type_id());
ASSERT(fw_map.size() == fw.size());
// submodularity constrain
// E(0,1) + E(1,0) - E(0,0) + E(1,1) > 0
// For pairwise factors, data term = 1,
// energy table indeces are defined as follows:
// w[0]*1 = E(0, 0)
// w[1]*1 = E(1, 0)
// w[2]*1 = E(0, 1)
// w[3]*1 = E(1, 1)
// thus, w[2] + w[1] - w[0] - w[3] > 0
// since factor graph model is over-parametering,
// the constrain can be written as w[2] > 0, w[1] > 0, w[0] = 0, w[3] = 0
lb[fw_map[0]] = 0;
ub[fw_map[0]] = 0;
lb[fw_map[3]] = 0;
ub[fw_map[3]] = 0;
lb[fw_map[1]] = 0;
lb[fw_map[2]] = 0;
}
SG_UNREF(ftype);
}
break;
case TREE_MAX_PROD:
case LOOPY_MAX_PROD:
case LP_RELAXATION:
case TRWS_MAX_PROD:
case GEMPLP:
break;
}
}
| cfjhallgren/shogun | src/shogun/structure/FactorGraphModel.cpp | C++ | gpl-3.0 | 12,485 |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tcc.curriculo;
import java.net.URL;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javax.swing.JOptionPane;
import tcc.dominio.Cursando;
import tcc.dominio.Curso;
import tcc.dominio.Uteis;
import tcc.dominio.dados.CursandoDados;
import tcc.dominio.dados.CursoDados;
public class CursandoFXMLController implements Initializable{
@FXML private TextField txtIngresso;
@FXML private TextField txtConclusao;
@FXML private TextField txtTitulo;
@FXML private ComboBox<Curso> cmbCurso;
@FXML private TextField txtArea;
@FXML private ComboBox<String> cmbPeriodo;
Cursando cursando = new Cursando();
CursoDados cursodados = new CursoDados();
@Override
public void initialize(URL url, ResourceBundle rb) {
cmbPeriodo.getItems().add("Manhã");
cmbPeriodo.getItems().add("Tarde");
cmbPeriodo.getItems().add("Noite");
try {
cmbCurso.getItems().addAll(cursodados.listarCursos());
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Select falhou");
}
}
private void preencher() {
SimpleDateFormat dateFormats = new SimpleDateFormat("d/M/y");
try {
cursando.setIngresso(dateFormats.parse(txtIngresso.getText()));
cursando.setConclusao(dateFormats.parse(txtConclusao.getText()));
cursando.setPeriodo(cmbPeriodo.getSelectionModel().getSelectedItem());
cursando.setCurso(cmbCurso.getSelectionModel().getSelectedItem());
} catch (ParseException ex) {
ex.printStackTrace();
Uteis.mensagemPreencherCampos();
}
}
private void PreencherCampos(){
txtIngresso.setText("20/02/2000");
txtConclusao.setText("20/02/2000");
}
@FXML
public void btnNext(ActionEvent evento){
PreencherCampos();
preencher();
CursandoDados cursandodados = new CursandoDados();
try {
cursandodados.salvarCursando(cursando);
Uteis.mensagemSalvo();
FXMLDocumentController principal = new FXMLDocumentController();
PrincipalController.chamaTela("ExperienciaFXML.fxml");
} catch (Exception e) {
Uteis.mensagemNaoSalvo();
e.printStackTrace();
}
}
}
| RenanVictor/Projeto-TCC | src/tcc/curriculo/CursandoFXMLController.java | Java | gpl-3.0 | 2,957 |
package vshevel.goit.module3.task3;
public class Trumpet extends MusicalInstrument {
@Override
public void howDoesThisSound() {
System.out.println("It's sound not like Piano or Guitar");
}
}
| VladimirShevel/GoItOnline | vshevel/goit/module3/task3/Trumpet.java | Java | gpl-3.0 | 213 |
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: LocateIPResponse.php,v 1.1.2.1 2011-05-30 08:31:04 root Exp $
*/
/**
* @see Zend_Service_DeveloperGarden_Response_BaseType
*/
require_once 'Zend/Service/DeveloperGarden/Response/BaseType.php';
/**
* @category Zend
* @package Zend_Service
* @subpackage DeveloperGarden
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @author Marco Kaiser
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponse
extends Zend_Service_DeveloperGarden_Response_BaseType
{
/**
* internal data object array of
* elements
*
* @var array
*/
public $ipAddressLocation = array();
/**
* constructor
*
* @param Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponseType $response
*/
public function __construct(
Zend_Service_DeveloperGarden_Response_IpLocation_LocateIPResponseType $response
) {
if ($response->ipAddressLocation instanceof Zend_Service_DeveloperGarden_Response_IpLocation_IPAddressLocationType) {
if (is_array($response->ipAddressLocation)) {
foreach ($response->ipAddressLocation as $location) {
$this->ipAddressLocation[] = $location;
}
} else {
$this->ipAddressLocation[] = $response->ipAddressLocation;
}
} elseif (is_array($response->ipAddressLocation)) {
$this->ipAddressLocation = $response->ipAddressLocation;
}
$this->errorCode = $response->getErrorCode();
$this->errorMessage = $response->getErrorMessage();
$this->statusCode = $response->getStatusCode();
$this->statusMessage = $response->getStatusMessage();
}
/**
* implement own parsing mechanism to fix broken wsdl implementation
*/
public function parse()
{
parent::parse();
if (is_array($this->ipAddressLocation)) {
foreach ($this->ipAddressLocation as $address) {
$address->parse();
}
} elseif ($this->ipAddressLocation instanceof Zend_Service_DeveloperGarden_Response_IpLocation_IPAddressLocationType) {
$this->ipAddressLocation->parse();
}
return $this;
}
/**
* @return array
*/
public function getIpAddressLocation()
{
return $this->ipAddressLocation;
}
}
| MailCleaner/MailCleaner | www/framework/Zend/Service/DeveloperGarden/Response/IpLocation/LocateIPResponse.php | PHP | gpl-3.0 | 3,227 |
package Game.generation;
import Game.base.BlockBase;
import Game.base.World;
/**
*
* @author maximumtech
*/
public class StructureGenTree extends StructureGenBase {
public StructureGenTree(World world) {
super(world);
}
public void generate(int x, int y) {
int height = 13 + rand.nextInt(5);
int leavesProg = height / 2;
boolean passedLast = false;
for (int i = 0; leavesProg > 0 || i < height; i++) {
int yy = y + i;
if (leavesProg == 0) {
leavesProg = 1;
}
BlockBase block1 = world.getBlock(x, yy);
if (i < height - 1 && (block1 == null || block1.canBeReplaced(world, x, y, BlockBase.woodLog))) {
world.setBlock(x, yy, BlockBase.woodLog, (short) 1);
}
if (i > height - 11 && leavesProg > 0) {
for (int o = x - leavesProg; o <= x + leavesProg; o++) {
BlockBase block2 = world.getBlock(o, yy);
if (block2 == null || block2.canBeReplaced(world, x, y, BlockBase.woodLog)) {
if (o != x) {
world.setBlock(o, yy, BlockBase.leaves);
} else if (i >= height - 1) {
world.setBlock(o, yy, BlockBase.leaves, (short) 1);
}
}
}
//if(leavesProg > 4) {
// hitDelim = true;
//}
//if(hitDelim) {
if (rand.nextInt(4) == 0 || passedLast) {
leavesProg--;
passedLast = false;
} else {
passedLast = true;
}
//}else{
// leavesProg++;
//}
} else if (i == height - 11) {
world.setBlock(x + 1, yy, BlockBase.leaves);
world.setBlock(x - 1, yy, BlockBase.leaves);
}
}
}
}
| maximumtech/Game | Game/src/Game/generation/StructureGenTree.java | Java | gpl-3.0 | 2,033 |
namespace Mervalito.Membership {
export interface LoginRequest extends Serenity.ServiceRequest {
Username?: string;
Password?: string;
}
}
| ldvalido/Mervalito | Mervalito/Mervalito.Web/Imports/ServerTypings/Membership.LoginRequest.ts | TypeScript | gpl-3.0 | 167 |
package edu.wayne.ograph.analysis;
import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ArrayAccess;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.ReturnStatement;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.junit.Assert;
import edu.cmu.cs.aliasjava.Constants;
import edu.cmu.cs.crystal.annotations.ICrystalAnnotation;
import edu.cmu.cs.crystal.tac.eclipse.EclipseTAC;
import edu.cmu.cs.crystal.tac.model.CopyInstruction;
import edu.cmu.cs.crystal.tac.model.LoadArrayInstruction;
import edu.cmu.cs.crystal.tac.model.LoadFieldInstruction;
import edu.cmu.cs.crystal.tac.model.MethodCallInstruction;
import edu.cmu.cs.crystal.tac.model.ReturnInstruction;
import edu.cmu.cs.crystal.tac.model.SourceVariable;
import edu.cmu.cs.crystal.tac.model.SourceVariableDeclaration;
import edu.cmu.cs.crystal.tac.model.StoreFieldInstruction;
import edu.cmu.cs.crystal.tac.model.ThisVariable;
import edu.cmu.cs.crystal.tac.model.TypeVariable;
import edu.cmu.cs.crystal.tac.model.Variable;
import edu.wayne.alias.FieldVariable;
import edu.wayne.auxiliary.Utils;
import edu.wayne.flowgraph.FlowAnnot;
import edu.wayne.flowgraph.FlowAnnotType;
import edu.wayne.flowgraph.FlowGraphEdge;
import edu.wayne.flowgraph.FlowGraphNode;
import edu.wayne.ograph.internal.DomainP;
import edu.wayne.ograph.internal.IDDictionary;
import edu.wayne.ograph.internal.OOGContext;
import edu.wayne.ograph.internal.OObject;
import edu.wayne.ograph.internal.OwnershipType;
import edu.wayne.ograph.internal.QualifiedClassName;
import edu.wayne.pointsto.PointsToAnalysis;
public class ValueFlowTransferFunctions extends NodesOOGTransferFunctions {
private Map<String, Set<Variable>> returnVariables;
// private Map<String, Integer> methodInvocations;
private static long invocation;
public ValueFlowTransferFunctions(PointsToAnalysis pointsToAnalysis) {
super(pointsToAnalysis);
returnVariables = new Hashtable<String, Set<Variable>>();
invocation = 0;
}
@Override
public OOGContext transfer(CopyInstruction instr, OOGContext value) {
QualifiedClassName cthis = getC_THIS(value);
List<DomainP> actDomains = getTargetActualDomains(instr.getTarget(), instr, value.getGamma(), cthis);
if (actDomains != null) {
value.getGamma().put(instr.getTarget(), actDomains);
if (actDomains.size() > 0) {
Variable source = instr.getOperand();
List<DomainP> list = value.getGamma().get(source);
if (list != null && list.size() > 0) {
DomainP sourceDomain = list.get(0);
FlowGraphNode src = new FlowGraphNode(value.getO(), source, sourceDomain);
FlowGraphNode dst = new FlowGraphNode(value.getO(), instr.getTarget(), actDomains.get(0));
value.getFG().addInfoFlow(new FlowGraphEdge(src, dst, FlowAnnot.getEmpty()));
} else {
// cannot find domain for righthandside
int debug = 0;
debug++;
}
}
}
return super.transfer(instr, value);
}
@Override
public OOGContext transfer(LoadArrayInstruction instr, OOGContext value) {
// System.out.println("LoadArray: " + instr.getNode() + " O=" +
// value.getO());
QualifiedClassName cthis = value.getO().getQCN();
Variable recv = instr.getSourceArray();
if (recv.resolveType().isArray()) {
QualifiedClassName receiverClass = new QualifiedClassName(getRecvPreciseClass(recv, value.getO()), cthis);
List<DomainP> receiverActualDomains = getReceiverActualDomains(recv, instr, value.getGamma(), cthis);
if (receiverActualDomains != null) {
ArrayAccess aa = (ArrayAccess) instr.getNode();
List<DomainP> formalTKDomains = getArrayAccessActualDomains(aa, cthis);
if (formalTKDomains != null) {
ITypeBinding fieldKClass = instr.getSourceArray().resolveType().getElementType();
value.getGamma().put(instr.getTarget(), formalTKDomains);
QualifiedClassName labelClass = new QualifiedClassName(fieldKClass, cthis);
Variable fk = instr.getArrayIndex();
Variable l = instr.getTarget();
addValueFlow(value, receiverClass, receiverActualDomains, labelClass, formalTKDomains, fk, formalTKDomains, l );
}
}
}
return super.transfer(instr, value);
}
@Override
public OOGContext transfer(LoadFieldInstruction instr, OOGContext value) {
// System.out.println("FieldRead: " + instr.getNode() + " O=" +
// value.getO());
// System.out.println("Gamma: " + value.getGamma());
if (!instr.isStaticFieldAccess()) {
OObject o = value.getO();
QualifiedClassName cthis = o.getQCN();
Variable recv = instr.getSourceObject();
if (!recv.resolveType().isArray()) {
QualifiedClassName receiverClass = new QualifiedClassName(getRecvPreciseClass(recv, o),
cthis);
List<DomainP> receiverActualDomains = getReceiverActualDomains(recv, instr, value.getGamma(), cthis);
Set<OObject> oRecvs = auxLookup(value, o, receiverClass, receiverActualDomains);
for (OObject or : oRecvs) {
TypeVariable that = new TypeVariable(or.getQCN().getTypeBinding());
if (that != null) {
DomainP thatOwner = new DomainP(or.getQCN(), Constants.OWNER);
FlowGraphNode srcr = new FlowGraphNode(o, recv, receiverActualDomains.get(0));
FlowGraphNode dstr = new FlowGraphNode(or, that, thatOwner);
FlowAnnot flowAnnot = FlowAnnot.getEmpty();
value.getFG().addInfoFlow(new FlowGraphEdge(srcr, dstr, flowAnnot));
}
}
if (receiverActualDomains != null) {
// IN TR: call fields with substitution
Map<String, List<DomainP>> fieldActualTypes = auxFields(recv, receiverClass, receiverActualDomains);
// !!! NOT IN TR: call fields without substitution since we
// call
// lookup(O_i,...)
Map<String, OwnershipType> fieldFormalTypes = auxFieldsWithoutSubst(receiverClass);
OwnershipType oType = fieldFormalTypes.get(instr.getFieldName());
if (oType != null) {
List<DomainP> formalTKDomains = oType.getValue();
List<DomainP> actualTKDomains = fieldActualTypes.get(instr.getFieldName());
Variable target = instr.getTarget();
ITypeBinding fieldKClass = target.resolveType();
value.getGamma().put(target, actualTKDomains);
QualifiedClassName labelClass = new QualifiedClassName(fieldKClass, cthis);
Variable fk = getFieldVariable(receiverClass.getTypeBinding(), instr);
addValueFlow(value, receiverClass, receiverActualDomains, labelClass, formalTKDomains, fk,
actualTKDomains, target);
}
}
}
}
return super.transfer(instr, value);
}
@Override
public OOGContext transfer(MethodCallInstruction instr, OOGContext value) {
Variable receiver = instr.getReceiverOperand();
IMethodBinding mb = instr.resolveBinding();
QualifiedClassName cthis = getC_THIS(value);
if (receiver != null) {
// not a static method call
QualifiedClassName recvClass = new QualifiedClassName(getRecvPreciseClass(receiver, value.getO()), cthis);
List<DomainP> receiverActualDomains = getReceiverActualDomains(receiver, instr, value.getGamma(), cthis);
OObject o = value.getO();
IMethodBinding mb1 = instr.resolveBinding();
FlowAnnot flowAnnot = new FlowAnnot(getInvocation(o,instr), FlowAnnotType.CALL);
//mb1 = mb1.getMethodDeclaration();
Set<OObject> oRecvs = auxLookup(value, o, recvClass, receiverActualDomains);
for (OObject or : oRecvs) {
TypeDeclaration typeDecl = pointsToAnalysis.getTypeDecl(or.getC());
//TODO: XXX: replace such that we do not create a separate variable instance at every pass.
TypeVariable that = new TypeVariable(or.getQCN().getTypeBinding());
if (that != null) {
QualifiedClassName tThat = new QualifiedClassName(that.resolveType(), cthis);
DomainP thatOwner = new DomainP(tThat, Constants.OWNER);
FlowGraphNode srcr = new FlowGraphNode(o, receiver, receiverActualDomains.get(0));
FlowGraphNode dstr = new FlowGraphNode(or, that, thatOwner);
value.getFG().addInfoFlow(new FlowGraphEdge(srcr, dstr, flowAnnot));
}
List<Variable> fparams = getFormalParams(mb1, typeDecl);
List<Variable> argOperands = instr.getArgOperands();
for (Variable arg : argOperands) {
List<DomainP> argDomains = getArgActualDomains(arg, instr, value.getGamma(), cthis);
boolean condition =argDomains != null
&& argDomains.size()>0
&& fparams != null
&& fparams.size()==argOperands.size()
&& (!arg.resolveType().isPrimitive());
if (condition) {
Variable fParam = fparams.get(argOperands.indexOf(arg));
List<DomainP> formalDomains = getDomainsOfFormalParams(mb1, typeDecl, cthis, argOperands.indexOf(arg));
if (formalDomains != null && argDomains.size() > 0 && formalDomains.size() > 0) {
FlowGraphNode src = new FlowGraphNode(o, arg, argDomains.get(0));
FlowGraphNode dst = new FlowGraphNode(or, fParam, formalDomains.get(0));
value.getFG().addInfoFlow(new FlowGraphEdge(src, dst, flowAnnot));
}
else{
this.pointsToAnalysis.addWarning(instr.getNode(),
"Cannot find domains for " + fParam);
}
} else {
if (!arg.resolveType().isPrimitive())
this.pointsToAnalysis.addWarning(instr.getNode(),
"Cannot find corresponding formal param for " + arg);
}
}
if (!mb.getReturnType().isPrimitive()) {
List<DomainP> methFormalRetDoms = auxMTypeRetWithoutSubst(mb1, recvClass);
List<DomainP> methActualRetDoms = auxMTypeRet(mb1, receiver, recvClass, receiverActualDomains);
value.getGamma().put(instr.getTarget(), methActualRetDoms);
Set<Variable> retVars = getRetVar(mb1);
if ((methFormalRetDoms != null && methFormalRetDoms.size() > 0)
&& (methActualRetDoms != null && methActualRetDoms.size() > 0))
for (Variable ret : retVars) {
FlowGraphNode src = new FlowGraphNode(or, ret, methFormalRetDoms.get(0));
FlowGraphNode dst = new FlowGraphNode(o, instr.getTarget(), methActualRetDoms.get(0));
// TODO: FIXME FlowAnnot closei = new
FlowAnnot flowAnnot1 = new FlowAnnot(getInvocation(o,instr), FlowAnnotType.RETURN);
value.getFG().addInfoFlow(new FlowGraphEdge(src, dst, flowAnnot1));
}
} else {
// do nothing for primitive types
}
}
}
return super.transfer(instr, value);
}
// private void addInvocation() {
// invocation++;
// }
@Override
public OOGContext transfer(ReturnInstruction instr, OOGContext value) {
Variable returnedVariable = instr.getReturnedVariable();
ASTNode node = instr.getNode();
if (node instanceof ReturnStatement) {
ReturnStatement rs = (ReturnStatement) node;
MethodDeclaration md = getMethodDeclaration(rs);
addToCachedDeclaration(md.resolveBinding(), returnedVariable);
}
return super.transfer(instr, value);
}
private void addToCachedDeclaration(IMethodBinding resolveBinding, Variable returnedVariable) {
String key = resolveBinding.getKey();
if (returnVariables.containsKey(key)) {
returnVariables.get(key).add(returnedVariable);
} else {
Set<Variable> vars = new HashSet<Variable>();
vars.add(returnedVariable);
returnVariables.put(key, vars);
}
}
private MethodDeclaration getMethodDeclaration(ASTNode rs) {
ASTNode parent = rs.getParent();
if (parent instanceof MethodDeclaration)
return (MethodDeclaration) parent;
else
return getMethodDeclaration(parent);
}
@Override
public OOGContext transfer(StoreFieldInstruction instr, OOGContext value) {
if (!Utils.isNullAssignment(instr)) {
QualifiedClassName cthis = value.getO().getQCN();
Variable recv = instr.getDestinationObject();
QualifiedClassName recvClass = new QualifiedClassName(getRecvPreciseClass(recv, value.getO()), cthis);
List<DomainP> recvActualDomains = getReceiverActualDomains(recv, instr, value.getGamma(), cthis);
if (recvActualDomains != null) {
Map<String, OwnershipType> auxFieldsWithoutSubst = auxFieldsWithoutSubst(recvClass);
OwnershipType fieldType = auxFieldsWithoutSubst.get(instr.getFieldName());
List<DomainP> rDomains = getSourceActualDomains(instr, value.getGamma(), cthis);
// TODO:XXX fix me, what if the right hand side is a SimpleName?
if (fieldType != null && fieldType.getValue() != null && rDomains!=null) {
Variable fk = new FieldVariable(instr.resolveFieldBinding());
Variable r = instr.getSourceOperand();
if (!addValueFlow2(value, recvClass, recvActualDomains,
new QualifiedClassName(fieldType.getKey(), cthis), fieldType.getValue(), fk, r, rDomains)){
pointsToAnalysis.addWarning(instr.getNode(), MISSING_DOMAINS);
}
}
}
}
return super.transfer(instr, value);
}
@Override
public OOGContext transfer(SourceVariableDeclaration instr, OOGContext value) {
QualifiedClassName declaringClass = value.getO().getQCN();
if (declaringClass != null) {
SourceVariable v = instr.getDeclaredVariable();
getDeclaredVarDomains(v, value.getGamma(), declaringClass);
}
return super.transfer(instr, value);
}
private Variable getFieldVariable(ITypeBinding typeBinding, LoadFieldInstruction instr) {
Variable ffield = null;
IVariableBinding field = instr.resolveFieldBinding();
return new FieldVariable(field);
// BodyDeclaration bd =
// Utils.getEnclosingFieldMethodDeclaration(instr.getNode());
// if (bd instanceof MethodDeclaration) {
// MethodDeclaration md = (MethodDeclaration) bd;
// EclipseTAC methodTAC =
// this.pointsToAnalysis.getSavedInput().getMethodTAC(md);
// return methodTAC.sourceVariable(field);
// } else {
// this.pointsToAnalysis.getTypeDecl(Type.createFrom());
// }
//
// return ffield;
}
private void addValueFlow(OOGContext value, QualifiedClassName receiverClass, List<DomainP> receiverActualDomains,
QualifiedClassName labelClass, List<DomainP> formalTKDomains, Variable fk, List<DomainP> actualTKDomains, Variable l) {
if (formalTKDomains != null && formalTKDomains.size() > 0) {
OObject o = value.getO();
Set<OObject> oRecvs = auxLookup(value, o, receiverClass, receiverActualDomains);
for (OObject or : oRecvs) {
FlowGraphNode src = new FlowGraphNode(or, fk, formalTKDomains.get(0));
FlowGraphNode dst = new FlowGraphNode(o, l, actualTKDomains.get(0));
value.getFG().addInfoFlow(new FlowGraphEdge(src, dst, FlowAnnot.getEmpty()));
}
} else {
int debug = 0;
debug++;
}
}
private Set<Variable> getRetVar(IMethodBinding mb) {
Set<Variable> set = this.returnVariables.get(mb.getKey());
if (set != null)
return Collections.unmodifiableSet(set);
else
return Collections.unmodifiableSet(new HashSet<Variable>());
}
private boolean addValueFlow2(OOGContext value, QualifiedClassName recvClass, List<DomainP> recvActualDomains,
QualifiedClassName labelQCN, List<DomainP> labelActualDomains, Variable fk, Variable r, List<DomainP> rDomains) {
if (rDomains.isEmpty()) return false;
if (labelActualDomains.isEmpty()) return false;
OObject o = value.getO();
Set<OObject> oRecvs = auxLookup(value, o, recvClass, recvActualDomains);
for (OObject or : oRecvs) {
FlowGraphNode src = new FlowGraphNode(o, r, rDomains.get(0));
FlowGraphNode dst = new FlowGraphNode(or, fk, labelActualDomains.get(0));
value.getFG().addInfoFlow(new FlowGraphEdge(src, dst, FlowAnnot.getSTAR()));
}
return true;
}
}
| aroog/code | PointsToOOG/src/edu/wayne/ograph/analysis/ValueFlowTransferFunctions.java | Java | gpl-3.0 | 16,047 |
// Decompiled with JetBrains decompiler
// Type: System.Security.Policy.IMembershipCondition
// Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 255ABCDF-D9D6-4E3D-BAD4-F74D4CE3D7A8
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
using System.Runtime.InteropServices;
using System.Security;
namespace System.Security.Policy
{
/// <summary>
/// Defines the test to determine whether a code assembly is a member of a code group.
/// </summary>
[ComVisible(true)]
public interface IMembershipCondition : ISecurityEncodable, ISecurityPolicyEncodable
{
/// <summary>
/// Determines whether the specified evidence satisfies the membership condition.
/// </summary>
///
/// <returns>
/// true if the specified evidence satisfies the membership condition; otherwise, false.
/// </returns>
/// <param name="evidence">The evidence set against which to make the test. </param>
bool Check(Evidence evidence);
/// <summary>
/// Creates an equivalent copy of the membership condition.
/// </summary>
///
/// <returns>
/// A new, identical copy of the current membership condition.
/// </returns>
IMembershipCondition Copy();
/// <summary>
/// Creates and returns a string representation of the membership condition.
/// </summary>
///
/// <returns>
/// A string representation of the state of the current membership condition.
/// </returns>
string ToString();
/// <summary>
/// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
/// </summary>
///
/// <returns>
/// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
/// </returns>
/// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>. </param>
bool Equals(object obj);
}
}
| mater06/LEGOChimaOnlineReloaded | LoCO Client Files/Decompressed Client/Extracted DLL/mscorlib/System/Security/Policy/IMembershipCondition.cs | C# | gpl-3.0 | 2,054 |
/**
*
* @author xedushx
*/
$(document).bind("touchmove", function (event) {
event.preventDefault();
});
/*
* Función que permite bloquear la pantalla mientras esta procesando
*/
$(function () {
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
});
/*
* Función que bloquea la tecla F5 y Enter de la pagina y detectar tecla arriba y abajo
*/
$(function () {
$(document).keydown(function (e) {
if ($('#formulario\\:menu').length) {
var code = (e.keyCode ? e.keyCode : e.which);
//if(code == 116 || code == 13) {
if (code == 13) {
e.preventDefault();
}
if (code == 40) {
teclaAbajo();
e.preventDefault();
}
if (code == 38) {
teclaArriba();
e.preventDefault();
}
}
});
});
/*
*Función Desabilitar el clik derecho
*/
//$(function() {
// $(document).ready(function(){
// $(document).bind("contextmenu",function(e){
// return false;
// });
// });
//});
/*
* Funcion que calcula y asigna el ancho y el alto del navegador
*/
function dimiensionesNavegador() {
var na = $(window).height();
document.getElementById('formulario:alto').value = na;
var ancho = $(window).width();
document.getElementById('formulario:ancho').value = ancho;
}
/*
* Funcion que calcula y asigna el ancho y el alto disponible sin la barra de menu
*/
function dimensionesDisponibles() {
var na = $(window).height();
var me = $('#formulario\\:menu').height();
var alto = na - me - 45;
alto = parseInt(alto);
document.getElementById('formulario:ith_alto').value = alto;
document.getElementById('formulario:alto').value = na;
var ancho = $(window).width();
document.getElementById('formulario:ancho').value = ancho;
}
/*
* Para poner los calendarios, las horas en español
*/
PrimeFaces.locales['es'] = {
closeText: 'Cerrar',
prevText: 'Anterior',
nextText: 'Siguiente',
monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
monthNamesShort: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'],
dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
dayNamesShort: ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab'],
dayNamesMin: ['D', 'L', 'M', 'M', 'J', 'V', 'S'],
weekHeader: 'Semana',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: '',
timeOnlyTitle: 'Sólo hora',
timeText: 'Tiempo',
hourText: 'Hora',
minuteText: 'Minuto',
secondText: 'Segundo',
currentText: 'Hora actual',
ampm: false,
month: 'Mes',
week: 'Semana',
day: 'Día',
allDayText: 'Todo el día'
};
function abrirPopUp(dir) {
var w = window.open(dir, "sistemadj", "width=" + screen.availWidth + ", height=" + screen.availHeight + ", screenX=0,screenY=0, top=0, left=0, status=0 , resizable=yes, scrollbars=yes");
w.focus();
}
function abrirNuevoPopUp(dir) {
var w = window.open(dir, "", "width=" + screen.availWidth + ", height=" + screen.availHeight + ", screenX=0,screenY=0, top=0, left=0, status=0 , resizable=yes, scrollbars=yes");
w.focus();
}
| xedushx/erpxprime | erpxprime/web/resources/sistema/sistema.js | JavaScript | gpl-3.0 | 3,385 |
// CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08)
// This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com)
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineMode("perl",function(){
// http://perldoc.perl.org
var PERL={ // null - magic touch
// 1 - keyword
// 2 - def
// 3 - atom
// 4 - operator
// 5 - variable-2 (predefined)
// [x,y] - x=1,2,3; y=must be defined if x{...}
// PERL operators
'->' : 4,
'++' : 4,
'--' : 4,
'**' : 4,
// ! ~ \ and unary + and -
'=~' : 4,
'!~' : 4,
'*' : 4,
'/' : 4,
'%' : 4,
'x' : 4,
'+' : 4,
'-' : 4,
'.' : 4,
'<<' : 4,
'>>' : 4,
// named unary operators
'<' : 4,
'>' : 4,
'<=' : 4,
'>=' : 4,
'lt' : 4,
'gt' : 4,
'le' : 4,
'ge' : 4,
'==' : 4,
'!=' : 4,
'<=>' : 4,
'eq' : 4,
'ne' : 4,
'cmp' : 4,
'~~' : 4,
'&' : 4,
'|' : 4,
'^' : 4,
'&&' : 4,
'||' : 4,
'//' : 4,
'..' : 4,
'...' : 4,
'?' : 4,
':' : 4,
'=' : 4,
'+=' : 4,
'-=' : 4,
'*=' : 4, // etc. ???
',' : 4,
'=>' : 4,
'::' : 4,
// list operators (rightward)
'not' : 4,
'and' : 4,
'or' : 4,
'xor' : 4,
// PERL predefined variables (I know, what this is a paranoid idea, but may be needed for people, who learn PERL, and for me as well, ...and may be for you?;)
'BEGIN' : [5,1],
'END' : [5,1],
'PRINT' : [5,1],
'PRINTF' : [5,1],
'GETC' : [5,1],
'READ' : [5,1],
'READLINE' : [5,1],
'DESTROY' : [5,1],
'TIE' : [5,1],
'TIEHANDLE' : [5,1],
'UNTIE' : [5,1],
'STDIN' : 5,
'STDIN_TOP' : 5,
'STDOUT' : 5,
'STDOUT_TOP' : 5,
'STDERR' : 5,
'STDERR_TOP' : 5,
'$ARG' : 5,
'$_' : 5,
'@ARG' : 5,
'@_' : 5,
'$LIST_SEPARATOR' : 5,
'$"' : 5,
'$PROCESS_ID' : 5,
'$PID' : 5,
'$$' : 5,
'$REAL_GROUP_ID' : 5,
'$GID' : 5,
'$(' : 5,
'$EFFECTIVE_GROUP_ID' : 5,
'$EGID' : 5,
'$)' : 5,
'$PROGRAM_NAME' : 5,
'$0' : 5,
'$SUBSCRIPT_SEPARATOR' : 5,
'$SUBSEP' : 5,
'$;' : 5,
'$REAL_USER_ID' : 5,
'$UID' : 5,
'$<' : 5,
'$EFFECTIVE_USER_ID' : 5,
'$EUID' : 5,
'$>' : 5,
'$a' : 5,
'$b' : 5,
'$COMPILING' : 5,
'$^C' : 5,
'$DEBUGGING' : 5,
'$^D' : 5,
'${^ENCODING}' : 5,
'$ENV' : 5,
'%ENV' : 5,
'$SYSTEM_FD_MAX' : 5,
'$^F' : 5,
'@F' : 5,
'${^GLOBAL_PHASE}' : 5,
'$^H' : 5,
'%^H' : 5,
'@INC' : 5,
'%INC' : 5,
'$INPLACE_EDIT' : 5,
'$^I' : 5,
'$^M' : 5,
'$OSNAME' : 5,
'$^O' : 5,
'${^OPEN}' : 5,
'$PERLDB' : 5,
'$^P' : 5,
'$SIG' : 5,
'%SIG' : 5,
'$BASETIME' : 5,
'$^T' : 5,
'${^TAINT}' : 5,
'${^UNICODE}' : 5,
'${^UTF8CACHE}' : 5,
'${^UTF8LOCALE}' : 5,
'$PERL_VERSION' : 5,
'$^V' : 5,
'${^WIN32_SLOPPY_STAT}' : 5,
'$EXECUTABLE_NAME' : 5,
'$^X' : 5,
'$1' : 5, // - regexp $1, $2...
'$MATCH' : 5,
'$&' : 5,
'${^MATCH}' : 5,
'$PREMATCH' : 5,
'$`' : 5,
'${^PREMATCH}' : 5,
'$POSTMATCH' : 5,
"$'" : 5,
'${^POSTMATCH}' : 5,
'$LAST_PAREN_MATCH' : 5,
'$+' : 5,
'$LAST_SUBMATCH_RESULT' : 5,
'$^N' : 5,
'@LAST_MATCH_END' : 5,
'@+' : 5,
'%LAST_PAREN_MATCH' : 5,
'%+' : 5,
'@LAST_MATCH_START' : 5,
'@-' : 5,
'%LAST_MATCH_START' : 5,
'%-' : 5,
'$LAST_REGEXP_CODE_RESULT' : 5,
'$^R' : 5,
'${^RE_DEBUG_FLAGS}' : 5,
'${^RE_TRIE_MAXBUF}' : 5,
'$ARGV' : 5,
'@ARGV' : 5,
'ARGV' : 5,
'ARGVOUT' : 5,
'$OUTPUT_FIELD_SEPARATOR' : 5,
'$OFS' : 5,
'$,' : 5,
'$INPUT_LINE_NUMBER' : 5,
'$NR' : 5,
'$.' : 5,
'$INPUT_RECORD_SEPARATOR' : 5,
'$RS' : 5,
'$/' : 5,
'$OUTPUT_RECORD_SEPARATOR' : 5,
'$ORS' : 5,
'$\\' : 5,
'$OUTPUT_AUTOFLUSH' : 5,
'$|' : 5,
'$ACCUMULATOR' : 5,
'$^A' : 5,
'$FORMAT_FORMFEED' : 5,
'$^L' : 5,
'$FORMAT_PAGE_NUMBER' : 5,
'$%' : 5,
'$FORMAT_LINES_LEFT' : 5,
'$-' : 5,
'$FORMAT_LINE_BREAK_CHARACTERS' : 5,
'$:' : 5,
'$FORMAT_LINES_PER_PAGE' : 5,
'$=' : 5,
'$FORMAT_TOP_NAME' : 5,
'$^' : 5,
'$FORMAT_NAME' : 5,
'$~' : 5,
'${^CHILD_ERROR_NATIVE}' : 5,
'$EXTENDED_OS_ERROR' : 5,
'$^E' : 5,
'$EXCEPTIONS_BEING_CAUGHT' : 5,
'$^S' : 5,
'$WARNING' : 5,
'$^W' : 5,
'${^WARNING_BITS}' : 5,
'$OS_ERROR' : 5,
'$ERRNO' : 5,
'$!' : 5,
'%OS_ERROR' : 5,
'%ERRNO' : 5,
'%!' : 5,
'$CHILD_ERROR' : 5,
'$?' : 5,
'$EVAL_ERROR' : 5,
'$@' : 5,
'$OFMT' : 5,
'$#' : 5,
'$*' : 5,
'$ARRAY_BASE' : 5,
'$[' : 5,
'$OLD_PERL_VERSION' : 5,
'$]' : 5,
// PERL blocks
'if' :[1,1],
elsif :[1,1],
'else' :[1,1],
'while' :[1,1],
unless :[1,1],
'for' :[1,1],
foreach :[1,1],
// PERL functions
'abs' :1, // - absolute value function
accept :1, // - accept an incoming socket connect
alarm :1, // - schedule a SIGALRM
'atan2' :1, // - arctangent of Y/X in the range -PI to PI
bind :1, // - binds an address to a socket
binmode :1, // - prepare binary files for I/O
bless :1, // - create an object
bootstrap :1, //
'break' :1, // - break out of a "given" block
caller :1, // - get context of the current subroutine call
chdir :1, // - change your current working directory
chmod :1, // - changes the permissions on a list of files
chomp :1, // - remove a trailing record separator from a string
chop :1, // - remove the last character from a string
chown :1, // - change the owership on a list of files
chr :1, // - get character this number represents
chroot :1, // - make directory new root for path lookups
close :1, // - close file (or pipe or socket) handle
closedir :1, // - close directory handle
connect :1, // - connect to a remote socket
'continue' :[1,1], // - optional trailing block in a while or foreach
'cos' :1, // - cosine function
crypt :1, // - one-way passwd-style encryption
dbmclose :1, // - breaks binding on a tied dbm file
dbmopen :1, // - create binding on a tied dbm file
'default' :1, //
defined :1, // - test whether a value, variable, or function is defined
'delete' :1, // - deletes a value from a hash
die :1, // - raise an exception or bail out
'do' :1, // - turn a BLOCK into a TERM
dump :1, // - create an immediate core dump
each :1, // - retrieve the next key/value pair from a hash
endgrent :1, // - be done using group file
endhostent :1, // - be done using hosts file
endnetent :1, // - be done using networks file
endprotoent :1, // - be done using protocols file
endpwent :1, // - be done using passwd file
endservent :1, // - be done using services file
eof :1, // - test a filehandle for its end
'eval' :1, // - catch exceptions or compile and run code
'exec' :1, // - abandon this program to run another
exists :1, // - test whether a hash key is present
exit :1, // - terminate this program
'exp' :1, // - raise I to a power
fcntl :1, // - file control system call
fileno :1, // - return file descriptor from filehandle
flock :1, // - lock an entire file with an advisory lock
fork :1, // - create a new process just like this one
format :1, // - declare a picture format with use by the write() function
formline :1, // - internal function used for formats
getc :1, // - get the next character from the filehandle
getgrent :1, // - get next group record
getgrgid :1, // - get group record given group user ID
getgrnam :1, // - get group record given group name
gethostbyaddr :1, // - get host record given its address
gethostbyname :1, // - get host record given name
gethostent :1, // - get next hosts record
getlogin :1, // - return who logged in at this tty
getnetbyaddr :1, // - get network record given its address
getnetbyname :1, // - get networks record given name
getnetent :1, // - get next networks record
getpeername :1, // - find the other end of a socket connection
getpgrp :1, // - get process group
getppid :1, // - get parent process ID
getpriority :1, // - get current nice value
getprotobyname :1, // - get protocol record given name
getprotobynumber :1, // - get protocol record numeric protocol
getprotoent :1, // - get next protocols record
getpwent :1, // - get next passwd record
getpwnam :1, // - get passwd record given user login name
getpwuid :1, // - get passwd record given user ID
getservbyname :1, // - get services record given its name
getservbyport :1, // - get services record given numeric port
getservent :1, // - get next services record
getsockname :1, // - retrieve the sockaddr for a given socket
getsockopt :1, // - get socket options on a given socket
given :1, //
glob :1, // - expand filenames using wildcards
gmtime :1, // - convert UNIX time into record or string using Greenwich time
'goto' :1, // - create spaghetti code
grep :1, // - locate elements in a list test true against a given criterion
hex :1, // - convert a string to a hexadecimal number
'import' :1, // - patch a module's namespace into your own
index :1, // - find a substring within a string
'int' :1, // - get the integer portion of a number
ioctl :1, // - system-dependent device control system call
'join' :1, // - join a list into a string using a separator
keys :1, // - retrieve list of indices from a hash
kill :1, // - send a signal to a process or process group
last :1, // - exit a block prematurely
lc :1, // - return lower-case version of a string
lcfirst :1, // - return a string with just the next letter in lower case
length :1, // - return the number of bytes in a string
'link' :1, // - create a hard link in the filesytem
listen :1, // - register your socket as a server
local : 2, // - create a temporary value for a global variable (dynamic scoping)
localtime :1, // - convert UNIX time into record or string using local time
lock :1, // - get a thread lock on a variable, subroutine, or method
'log' :1, // - retrieve the natural logarithm for a number
lstat :1, // - stat a symbolic link
m :null, // - match a string with a regular expression pattern
map :1, // - apply a change to a list to get back a new list with the changes
mkdir :1, // - create a directory
msgctl :1, // - SysV IPC message control operations
msgget :1, // - get SysV IPC message queue
msgrcv :1, // - receive a SysV IPC message from a message queue
msgsnd :1, // - send a SysV IPC message to a message queue
my : 2, // - declare and assign a local variable (lexical scoping)
'new' :1, //
next :1, // - iterate a block prematurely
no :1, // - unimport some module symbols or semantics at compile time
oct :1, // - convert a string to an octal number
open :1, // - open a file, pipe, or descriptor
opendir :1, // - open a directory
ord :1, // - find a character's numeric representation
our : 2, // - declare and assign a package variable (lexical scoping)
pack :1, // - convert a list into a binary representation
'package' :1, // - declare a separate global namespace
pipe :1, // - open a pair of connected filehandles
pop :1, // - remove the last element from an array and return it
pos :1, // - find or set the offset for the last/next m//g search
print :1, // - output a list to a filehandle
printf :1, // - output a formatted list to a filehandle
prototype :1, // - get the prototype (if any) of a subroutine
push :1, // - append one or more elements to an array
q :null, // - singly quote a string
qq :null, // - doubly quote a string
qr :null, // - Compile pattern
quotemeta :null, // - quote regular expression magic characters
qw :null, // - quote a list of words
qx :null, // - backquote quote a string
rand :1, // - retrieve the next pseudorandom number
read :1, // - fixed-length buffered input from a filehandle
readdir :1, // - get a directory from a directory handle
readline :1, // - fetch a record from a file
readlink :1, // - determine where a symbolic link is pointing
readpipe :1, // - execute a system command and collect standard output
recv :1, // - receive a message over a Socket
redo :1, // - start this loop iteration over again
ref :1, // - find out the type of thing being referenced
rename :1, // - change a filename
require :1, // - load in external functions from a library at runtime
reset :1, // - clear all variables of a given name
'return' :1, // - get out of a function early
reverse :1, // - flip a string or a list
rewinddir :1, // - reset directory handle
rindex :1, // - right-to-left substring search
rmdir :1, // - remove a directory
s :null, // - replace a pattern with a string
say :1, // - print with newline
scalar :1, // - force a scalar context
seek :1, // - reposition file pointer for random-access I/O
seekdir :1, // - reposition directory pointer
select :1, // - reset default output or do I/O multiplexing
semctl :1, // - SysV semaphore control operations
semget :1, // - get set of SysV semaphores
semop :1, // - SysV semaphore operations
send :1, // - send a message over a socket
setgrent :1, // - prepare group file for use
sethostent :1, // - prepare hosts file for use
setnetent :1, // - prepare networks file for use
setpgrp :1, // - set the process group of a process
setpriority :1, // - set a process's nice value
setprotoent :1, // - prepare protocols file for use
setpwent :1, // - prepare passwd file for use
setservent :1, // - prepare services file for use
setsockopt :1, // - set some socket options
shift :1, // - remove the first element of an array, and return it
shmctl :1, // - SysV shared memory operations
shmget :1, // - get SysV shared memory segment identifier
shmread :1, // - read SysV shared memory
shmwrite :1, // - write SysV shared memory
shutdown :1, // - close down just half of a socket connection
'sin' :1, // - return the sine of a number
sleep :1, // - block for some number of seconds
socket :1, // - create a socket
socketpair :1, // - create a pair of sockets
'sort' :1, // - sort a list of values
splice :1, // - add or remove elements anywhere in an array
'split' :1, // - split up a string using a regexp delimiter
sprintf :1, // - formatted print into a string
'sqrt' :1, // - square root function
srand :1, // - seed the random number generator
stat :1, // - get a file's status information
state :1, // - declare and assign a state variable (persistent lexical scoping)
study :1, // - optimize input data for repeated searches
'sub' :1, // - declare a subroutine, possibly anonymously
'substr' :1, // - get or alter a portion of a stirng
symlink :1, // - create a symbolic link to a file
syscall :1, // - execute an arbitrary system call
sysopen :1, // - open a file, pipe, or descriptor
sysread :1, // - fixed-length unbuffered input from a filehandle
sysseek :1, // - position I/O pointer on handle used with sysread and syswrite
system :1, // - run a separate program
syswrite :1, // - fixed-length unbuffered output to a filehandle
tell :1, // - get current seekpointer on a filehandle
telldir :1, // - get current seekpointer on a directory handle
tie :1, // - bind a variable to an object class
tied :1, // - get a reference to the object underlying a tied variable
time :1, // - return number of seconds since 1970
times :1, // - return elapsed time for self and child processes
tr :null, // - transliterate a string
truncate :1, // - shorten a file
uc :1, // - return upper-case version of a string
ucfirst :1, // - return a string with just the next letter in upper case
umask :1, // - set file creation mode mask
undef :1, // - remove a variable or function definition
unlink :1, // - remove one link to a file
unpack :1, // - convert binary structure into normal perl variables
unshift :1, // - prepend more elements to the beginning of a list
untie :1, // - break a tie binding to a variable
use :1, // - load in a module at compile time
utime :1, // - set a file's last access and modify times
values :1, // - return a list of the values in a hash
vec :1, // - test or set particular bits in a string
wait :1, // - wait for any child process to die
waitpid :1, // - wait for a particular child process to die
wantarray :1, // - get void vs scalar vs list context of current subroutine call
warn :1, // - print debugging info
when :1, //
write :1, // - print a picture record
y :null}; // - transliterate a string
var RXstyle="string-2";
var RXmodifiers=/[goseximacplud]/; // NOTE: "m", "s", "y" and "tr" need to correct real modifiers for each regexp type
function tokenChain(stream,state,chain,style,tail){ // NOTE: chain.length > 2 is not working now (it's for s[...][...]geos;)
state.chain=null; // 12 3tail
state.style=null;
state.tail=null;
state.tokenize=function(stream,state){
var e=false,c,i=0;
while(c=stream.next()){
if(c===chain[i]&&!e){
if(chain[++i]!==undefined){
state.chain=chain[i];
state.style=style;
state.tail=tail;}
else if(tail)
stream.eatWhile(tail);
state.tokenize=tokenPerl;
return style;}
e=!e&&c=="\\";}
return style;};
return state.tokenize(stream,state);}
function tokenSOMETHING(stream,state,string){
state.tokenize=function(stream,state){
if(stream.string==string)
state.tokenize=tokenPerl;
stream.skipToEnd();
return "string";};
return state.tokenize(stream,state);}
function tokenPerl(stream,state){
if(stream.eatSpace())
return null;
if(state.chain)
return tokenChain(stream,state,state.chain,state.style,state.tail);
if(stream.match(/^\-?[\d\.]/,false))
if(stream.match(/^(\-?(\d*\.\d+(e[+-]?\d+)?|\d+\.\d*)|0x[\da-fA-F]+|0b[01]+|\d+(e[+-]?\d+)?)/))
return 'number';
if(stream.match(/^<<(?=\w)/)){ // NOTE: <<SOMETHING\n...\nSOMETHING\n
stream.eatWhile(/\w/);
return tokenSOMETHING(stream,state,stream.current().substr(2));}
if(stream.sol()&&stream.match(/^\=item(?!\w)/)){// NOTE: \n=item...\n=cut\n
return tokenSOMETHING(stream,state,'=cut');}
var ch=stream.next();
if(ch=='"'||ch=="'"){ // NOTE: ' or " or <<'SOMETHING'\n...\nSOMETHING\n or <<"SOMETHING"\n...\nSOMETHING\n
if(prefix(stream, 3)=="<<"+ch){
var p=stream.pos;
stream.eatWhile(/\w/);
var n=stream.current().substr(1);
if(n&&stream.eat(ch))
return tokenSOMETHING(stream,state,n);
stream.pos=p;}
return tokenChain(stream,state,[ch],"string");}
if(ch=="q"){
var c=look(stream, -2);
if(!(c&&/\w/.test(c))){
c=look(stream, 0);
if(c=="x"){
c=look(stream, 1);
if(c=="("){
eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}
if(c=="["){
eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}
if(c=="{"){
eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}
if(c=="<"){
eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}
if(/[\^'"!~\/]/.test(c)){
eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}
else if(c=="q"){
c=look(stream, 1);
if(c=="("){
eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],"string");}
if(c=="["){
eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],"string");}
if(c=="{"){
eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],"string");}
if(c=="<"){
eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],"string");}
if(/[\^'"!~\/]/.test(c)){
eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],"string");}}
else if(c=="w"){
c=look(stream, 1);
if(c=="("){
eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],"bracket");}
if(c=="["){
eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],"bracket");}
if(c=="{"){
eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],"bracket");}
if(c=="<"){
eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],"bracket");}
if(/[\^'"!~\/]/.test(c)){
eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],"bracket");}}
else if(c=="r"){
c=look(stream, 1);
if(c=="("){
eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}
if(c=="["){
eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}
if(c=="{"){
eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}
if(c=="<"){
eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}
if(/[\^'"!~\/]/.test(c)){
eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}
else if(/[\^'"!~\/(\[{<]/.test(c)){
if(c=="("){
eatSuffix(stream, 1);
return tokenChain(stream,state,[")"],"string");}
if(c=="["){
eatSuffix(stream, 1);
return tokenChain(stream,state,["]"],"string");}
if(c=="{"){
eatSuffix(stream, 1);
return tokenChain(stream,state,["}"],"string");}
if(c=="<"){
eatSuffix(stream, 1);
return tokenChain(stream,state,[">"],"string");}
if(/[\^'"!~\/]/.test(c)){
return tokenChain(stream,state,[stream.eat(c)],"string");}}}}
if(ch=="m"){
var c=look(stream, -2);
if(!(c&&/\w/.test(c))){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
if(/[\^'"!~\/]/.test(c)){
return tokenChain(stream,state,[c],RXstyle,RXmodifiers);}
if(c=="("){
return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}
if(c=="["){
return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}
if(c=="{"){
return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}
if(c=="<"){
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}}}}
if(ch=="s"){
var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
if(c=="[")
return tokenChain(stream,state,["]","]"],RXstyle,RXmodifiers);
if(c=="{")
return tokenChain(stream,state,["}","}"],RXstyle,RXmodifiers);
if(c=="<")
return tokenChain(stream,state,[">",">"],RXstyle,RXmodifiers);
if(c=="(")
return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);
return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}
if(ch=="y"){
var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
if(c=="[")
return tokenChain(stream,state,["]","]"],RXstyle,RXmodifiers);
if(c=="{")
return tokenChain(stream,state,["}","}"],RXstyle,RXmodifiers);
if(c=="<")
return tokenChain(stream,state,[">",">"],RXstyle,RXmodifiers);
if(c=="(")
return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);
return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}
if(ch=="t"){
var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat("r");if(c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
if(c=="[")
return tokenChain(stream,state,["]","]"],RXstyle,RXmodifiers);
if(c=="{")
return tokenChain(stream,state,["}","}"],RXstyle,RXmodifiers);
if(c=="<")
return tokenChain(stream,state,[">",">"],RXstyle,RXmodifiers);
if(c=="(")
return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);
return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}}
if(ch=="`"){
return tokenChain(stream,state,[ch],"variable-2");}
if(ch=="/"){
if(!/~\s*$/.test(prefix(stream)))
return "operator";
else
return tokenChain(stream,state,[ch],RXstyle,RXmodifiers);}
if(ch=="$"){
var p=stream.pos;
if(stream.eatWhile(/\d/)||stream.eat("{")&&stream.eatWhile(/\d/)&&stream.eat("}"))
return "variable-2";
else
stream.pos=p;}
if(/[$@%]/.test(ch)){
var p=stream.pos;
if(stream.eat("^")&&stream.eat(/[A-Z]/)||!/[@$%&]/.test(look(stream, -2))&&stream.eat(/[=|\\\-#?@;:&`~\^!\[\]*'"$+.,\/<>()]/)){
var c=stream.current();
if(PERL[c])
return "variable-2";}
stream.pos=p;}
if(/[$@%&]/.test(ch)){
if(stream.eatWhile(/[\w$\[\]]/)||stream.eat("{")&&stream.eatWhile(/[\w$\[\]]/)&&stream.eat("}")){
var c=stream.current();
if(PERL[c])
return "variable-2";
else
return "variable";}}
if(ch=="#"){
if(look(stream, -2)!="$"){
stream.skipToEnd();
return "comment";}}
if(/[:+\-\^*$&%@=<>!?|\/~\.]/.test(ch)){
var p=stream.pos;
stream.eatWhile(/[:+\-\^*$&%@=<>!?|\/~\.]/);
if(PERL[stream.current()])
return "operator";
else
stream.pos=p;}
if(ch=="_"){
if(stream.pos==1){
if(suffix(stream, 6)=="_END__"){
return tokenChain(stream,state,['\0'],"comment");}
else if(suffix(stream, 7)=="_DATA__"){
return tokenChain(stream,state,['\0'],"variable-2");}
else if(suffix(stream, 7)=="_C__"){
return tokenChain(stream,state,['\0'],"string");}}}
if(/\w/.test(ch)){
var p=stream.pos;
if(look(stream, -2)=="{"&&(look(stream, 0)=="}"||stream.eatWhile(/\w/)&&look(stream, 0)=="}"))
return "string";
else
stream.pos=p;}
if(/[A-Z]/.test(ch)){
var l=look(stream, -2);
var p=stream.pos;
stream.eatWhile(/[A-Z_]/);
if(/[\da-z]/.test(look(stream, 0))){
stream.pos=p;}
else{
var c=PERL[stream.current()];
if(!c)
return "meta";
if(c[1])
c=c[0];
if(l!=":"){
if(c==1)
return "keyword";
else if(c==2)
return "def";
else if(c==3)
return "atom";
else if(c==4)
return "operator";
else if(c==5)
return "variable-2";
else
return "meta";}
else
return "meta";}}
if(/[a-zA-Z_]/.test(ch)){
var l=look(stream, -2);
stream.eatWhile(/\w/);
var c=PERL[stream.current()];
if(!c)
return "meta";
if(c[1])
c=c[0];
if(l!=":"){
if(c==1)
return "keyword";
else if(c==2)
return "def";
else if(c==3)
return "atom";
else if(c==4)
return "operator";
else if(c==5)
return "variable-2";
else
return "meta";}
else
return "meta";}
return null;}
return{
startState:function(){
return{
tokenize:tokenPerl,
chain:null,
style:null,
tail:null};},
token:function(stream,state){
return (state.tokenize||tokenPerl)(stream,state);},
electricChars:"{}"};});
CodeMirror.registerHelper("wordChars", "perl", /[\\w$]/);
CodeMirror.defineMIME("text/x-perl", "perl");
// it's like "peek", but need for look-ahead or look-behind if index < 0
function look(stream, c){
return stream.string.charAt(stream.pos+(c||0));
}
// return a part of prefix of current stream from current position
function prefix(stream, c){
if(c){
var x=stream.pos-c;
return stream.string.substr((x>=0?x:0),c);}
else{
return stream.string.substr(0,stream.pos-1);
}
}
// return a part of suffix of current stream from current position
function suffix(stream, c){
var y=stream.string.length;
var x=y-stream.pos+1;
return stream.string.substr(stream.pos,(c&&c<y?c:x));
}
// eating and vomiting a part of stream from current position
function eatSuffix(stream, c){
var x=stream.pos+c;
var y;
if(x<=0)
stream.pos=0;
else if(x>=(y=stream.string.length-1))
stream.pos=y;
else
stream.pos=x;
}
});
| soliton4/promiseLand-website | src/codemirror4/mode/perl/perl.js | JavaScript | gpl-3.0 | 56,018 |
// Decompiled with JetBrains decompiler
// Type: System.Threading.TimerQueue
// Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 255ABCDF-D9D6-4E3D-BAD4-F74D4CE3D7A8
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security;
namespace System.Threading
{
internal class TimerQueue
{
private static TimerQueue s_queue = new TimerQueue();
[SecurityCritical]
private TimerQueue.AppDomainTimerSafeHandle m_appDomainTimer;
private bool m_isAppDomainTimerScheduled;
private int m_currentAppDomainTimerStartTicks;
private uint m_currentAppDomainTimerDuration;
private TimerQueueTimer m_timers;
private static WaitCallback s_fireQueuedTimerCompletion;
public static TimerQueue Instance
{
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
{
return TimerQueue.s_queue;
}
}
private static int TickCount
{
[SecuritySafeCritical] get
{
if (!Environment.IsWindows8OrAbove)
return Environment.TickCount;
ulong UnbiasedTime;
if (!Win32Native.QueryUnbiasedInterruptTime(out UnbiasedTime))
throw Marshal.GetExceptionForHR(Marshal.GetLastWin32Error());
return (int) (uint) (UnbiasedTime / 10000UL);
}
}
private TimerQueue()
{
}
[SecuritySafeCritical]
internal static void AppDomainTimerCallback()
{
TimerQueue.Instance.FireNextTimers();
}
[SuppressUnmanagedCodeSecurity]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[SecurityCritical]
[DllImport("QCall", CharSet = CharSet.Unicode)]
private static extern bool DeleteAppDomainTimer(IntPtr handle);
public bool UpdateTimer(TimerQueueTimer timer, uint dueTime, uint period)
{
if ((int) timer.m_dueTime == -1)
{
timer.m_next = this.m_timers;
timer.m_prev = (TimerQueueTimer) null;
if (timer.m_next != null)
timer.m_next.m_prev = timer;
this.m_timers = timer;
}
timer.m_dueTime = dueTime;
timer.m_period = (int) period == 0 ? uint.MaxValue : period;
timer.m_startTicks = TimerQueue.TickCount;
return this.EnsureAppDomainTimerFiresBy(dueTime);
}
public void DeleteTimer(TimerQueueTimer timer)
{
if ((int) timer.m_dueTime == -1)
return;
if (timer.m_next != null)
timer.m_next.m_prev = timer.m_prev;
if (timer.m_prev != null)
timer.m_prev.m_next = timer.m_next;
if (this.m_timers == timer)
this.m_timers = timer.m_next;
timer.m_dueTime = uint.MaxValue;
timer.m_period = uint.MaxValue;
timer.m_startTicks = 0;
timer.m_prev = (TimerQueueTimer) null;
timer.m_next = (TimerQueueTimer) null;
}
[SecuritySafeCritical]
private bool EnsureAppDomainTimerFiresBy(uint requestedDuration)
{
uint dueTime = Math.Min(requestedDuration, 268435455U);
if (this.m_isAppDomainTimerScheduled)
{
uint num1 = (uint) (TimerQueue.TickCount - this.m_currentAppDomainTimerStartTicks);
if (num1 >= this.m_currentAppDomainTimerDuration)
return true;
uint num2 = this.m_currentAppDomainTimerDuration - num1;
if (dueTime >= num2)
return true;
}
if (this.m_appDomainTimer == null || this.m_appDomainTimer.IsInvalid)
{
this.m_appDomainTimer = TimerQueue.CreateAppDomainTimer(dueTime);
if (this.m_appDomainTimer.IsInvalid)
return false;
this.m_isAppDomainTimerScheduled = true;
this.m_currentAppDomainTimerStartTicks = TimerQueue.TickCount;
this.m_currentAppDomainTimerDuration = dueTime;
return true;
}
if (!TimerQueue.ChangeAppDomainTimer(this.m_appDomainTimer, dueTime))
return false;
this.m_isAppDomainTimerScheduled = true;
this.m_currentAppDomainTimerStartTicks = TimerQueue.TickCount;
this.m_currentAppDomainTimerDuration = dueTime;
return true;
}
[SecurityCritical]
[SuppressUnmanagedCodeSecurity]
[DllImport("QCall", CharSet = CharSet.Unicode)]
private static extern TimerQueue.AppDomainTimerSafeHandle CreateAppDomainTimer(uint dueTime);
[SuppressUnmanagedCodeSecurity]
[SecurityCritical]
[DllImport("QCall", CharSet = CharSet.Unicode)]
private static extern bool ChangeAppDomainTimer(TimerQueue.AppDomainTimerSafeHandle handle, uint dueTime);
private void FireNextTimers()
{
TimerQueueTimer timerQueueTimer = (TimerQueueTimer) null;
lock (this)
{
try
{
}
finally
{
this.m_isAppDomainTimerScheduled = false;
bool local_1 = false;
uint local_2 = uint.MaxValue;
int local_3 = TimerQueue.TickCount;
TimerQueueTimer local_4 = this.m_timers;
while (local_4 != null)
{
uint local_5 = (uint) (local_3 - local_4.m_startTicks);
if (local_5 >= local_4.m_dueTime)
{
TimerQueueTimer local_6 = local_4.m_next;
if ((int) local_4.m_period != -1)
{
local_4.m_startTicks = local_3;
local_4.m_dueTime = local_4.m_period;
if (local_4.m_dueTime < local_2)
{
local_1 = true;
local_2 = local_4.m_dueTime;
}
}
else
this.DeleteTimer(local_4);
if (timerQueueTimer == null)
timerQueueTimer = local_4;
else
TimerQueue.QueueTimerCompletion(local_4);
local_4 = local_6;
}
else
{
uint local_7 = local_4.m_dueTime - local_5;
if (local_7 < local_2)
{
local_1 = true;
local_2 = local_7;
}
local_4 = local_4.m_next;
}
}
if (local_1)
this.EnsureAppDomainTimerFiresBy(local_2);
}
}
if (timerQueueTimer == null)
return;
timerQueueTimer.Fire();
}
[SecuritySafeCritical]
private static void QueueTimerCompletion(TimerQueueTimer timer)
{
WaitCallback callBack = TimerQueue.s_fireQueuedTimerCompletion;
if (callBack == null)
TimerQueue.s_fireQueuedTimerCompletion = callBack = new WaitCallback(TimerQueue.FireQueuedTimerCompletion);
ThreadPool.UnsafeQueueUserWorkItem(callBack, (object) timer);
}
private static void FireQueuedTimerCompletion(object state)
{
((TimerQueueTimer) state).Fire();
}
[SecurityCritical]
private class AppDomainTimerSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
{
public AppDomainTimerSafeHandle()
: base(true)
{
}
[SecurityCritical]
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
protected override bool ReleaseHandle()
{
return TimerQueue.DeleteAppDomainTimer(this.handle);
}
}
}
}
| mater06/LEGOChimaOnlineReloaded | LoCO Client Files/Decompressed Client/Extracted DLL/mscorlib/System/Threading/TimerQueue.cs | C# | gpl-3.0 | 7,413 |
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
class userlicallocrep {
// Find completion data. $courseid=0 means all courses
// for that company.
public static function get_completion( $userid, $courseid, $showhistoric=false ) {
global $DB;
// Going to build an array for the data.
$data = array();
// Count the three statii for the graph.
$notstarted = 0;
$inprogress = 0;
$completed = 0;
// Get completion data for course.
// Get course object.
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
error( 'unable to find course record' );
}
$datum = new stdclass();
$datum->coursename = $course->fullname;
// Instantiate completion info thingy.
$info = new completion_info( $course );
// Set up the temporary table for all the completion information to go into.
$tempcomptablename = 'tmp_ccomp_comp_'.uniqid();
// Populate the temporary completion table.
list($compdbman, $comptable) = self::populate_temporary_completion($tempcomptablename, $userid, $courseid, $showhistoric);
// Get gradebook details.
$gbsql = "select gg.finalgrade as result from {grade_grades} gg, {grade_items} gi
WHERE gi.courseid=$courseid AND gi.itemtype='course' AND gg.userid=$userid
AND gi.id=gg.itemid";
if (!$gradeinfo = $DB->get_record_sql($gbsql)) {
$gradeinfo = new stdclass();
$gradeinfo->result = null;
}
// If completion is not enabled on the course
// there's no point carrying on.
if (!$info->is_enabled()) {
$datum->enabled = false;
$data[ $courseid ] = $datum;
// Drop the temp table.
$compdbman->drop_table($comptable);
return false;
} else {
$datum->enabled = true;
}
// Get criteria for coursed.
// This is an array of tracked activities (only tracked ones).
$criteria = $info->get_criteria();
// Number of tracked activities to complete.
$trackedcount = count( $criteria );
$datum->trackedcount = $trackedcount;
$datum->completion = new stdclass();
$u = new stdclass();
$data[$courseid] = new stdclass();
// Iterate over users to get info.
// Find user's completion info for this course.
if ($completionsinfo = $DB->get_records_sql("SELECT DISTINCT id as uniqueid, userid,courseid,timeenrolled,timestarted,timecompleted,finalscore
FROM {".$tempcomptablename."}
ORDER BY timeenrolled DESC")) {
foreach ($completionsinfo as $testcompletioninfo) {
$u = new stdclass();
// get the first occurrance of this info.
if ($completioninfo = $DB->get_record_sql("SELECT * FROM {".$tempcomptablename."}
WHERE userid = :userid
AND courseid = :courseid
AND timeenrolled = :timeenrolled
AND timestarted = :timestarted
AND timecompleted = :timecompleted
LIMIT 1",
(array) $testcompletioninfo)) {
$u->certsource = null;
if (!empty($completioninfo->timeenrolled)) {
$u->timeenrolled = $completioninfo->timeenrolled;
} else {
$u->timeenrolled = '';
}
if (!empty($completioninfo->timestarted)) {
$u->timestarted = $completioninfo->timestarted;
if (!empty($completioninfo->timecompleted)) {
$u->timecompleted = $completioninfo->timecompleted;
$u->status = 'completed';
$u->certsource = $completioninfo->certsource;
++$completed;
} else {
$u->timecompleted = 0;
$u->status = 'inprogress';
++$inprogress;
}
} else {
$u->timestarted = 0;
$u->status = 'notstarted';
++$notstarted;
}
if (!empty($completioninfo->finalscore)) {
$u->result = round($completioninfo->finalscore, 0);
} else {
$u->result = '';
}
$datum->completion->{$completioninfo->id} = $u;
$data[$courseid] = $datum;
} else {
// Does the user have a license for this course?
if ($DB->get_record('companylicense_users', array('licensecourseid' => $courseid, 'userid' => $userid, 'isusing' => 0))) {
$u->timeenrolled = 0;
$u->timecompleted = 0;
$u->timestarted = 0;
$u->status = 'notstarted';
$u->certsource = null;
++$notstarted;
$datum->completion->$courseid = $u;
}
}
}
$data[$courseid] = $datum;
} else {
// Does the user have a license for this course?
if ($DB->get_record('companylicense_users', array('licensecourseid' => $courseid, 'userid' => $userid, 'isusing' => 0))) {
$u->timeenrolled = 0;
$u->timecompleted = 0;
$u->timestarted = 0;
$u->status = 'notstarted';
$u->certsource = null;
++$notstarted;
$datum->completion->$courseid = $u;
$data[$courseid] = $datum;
}
// user is in the course and hasn't accessed it yet.
if ($enrolinfo = $DB->get_record_sql("SELECT ue.* FROM {user_enrolments} ue JOIN {enrol} e ON (ue.enrolid = e.id)
WHERE e.status = 0
AND e.courseid = :courseid
AND ue.userid = :userid",
array('courseid' => $courseid, 'userid' => $userid))) {
$u->timeenrolled = $enrolinfo->timestart;
$u->timecompleted = 0;
$u->timestarted = 0;
$u->status = 'notstarted';
$u->certsource = null;
++$notstarted;
$datum->completion->$courseid = $u;
$data[$courseid] = $datum;
}
}
// Make return object.
$returnobj = new stdclass();
$returnobj->data = $data;
$returnobj->criteria = $criteria;
// Drop the temp table.
$compdbman->drop_table($comptable);
return $returnobj;
}
/**
* Get users into temporary table
*/
private static function populate_temporary_completion($tempcomptablename, $userid, $courseid=0, $showhistoric=false) {
global $DB;
// Create a temporary table to hold the userids.
$dbman = $DB->get_manager();
// Define table user to be created.
$table = new xmldb_table($tempcomptablename);
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_field('timeenrolled', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_field('timestarted', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_field('timecompleted', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_field('finalscore', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_field('certsource', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_field('trackid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$dbman->create_temp_table($table);
// Populate it.
$tempcreatesql = "INSERT INTO {".$tempcomptablename."} (userid, courseid, timeenrolled, timestarted, timecompleted, finalscore, certsource)
SELECT cc.userid, cc.course, ue.timestart, cc.timestarted, cc.timecompleted, gg.finalgrade, 0
FROM {course_completions} cc LEFT JOIN {grade_grades} gg ON (gg.userid = cc.userid)
JOIN {grade_items} gi
ON (cc.course = gi.courseid
AND gg.itemid = gi.id
AND gi.itemtype = 'course')
JOIN {user_enrolments} ue ON (cc.userid = ue.userid)
JOIN {enrol} e ON (cc.course = e.courseid AND e.id = ue.enrolid)
WHERE cc.userid = :userid ";
if (!empty($courseid)) {
$tempcreatesql .= " AND cc.course = ".$courseid;
}
$DB->execute($tempcreatesql, array('userid' => $userid, 'courseid' => $courseid));
// Are we also adding in historic data?
if ($showhistoric) {
// Populate it.
$tempcreatesql = "INSERT INTO {".$tempcomptablename."} (userid, courseid, timeenrolled, timestarted, timecompleted, finalscore, certsource)
SELECT it.userid, it.courseid, it.timeenrolled, it.timestarted, it.timecompleted, it.finalscore, it.id
FROM {local_iomad_track} it
WHERE it.userid = :userid";
if (!empty($courseid)) {
$tempcreatesql .= " AND it.courseid = :courseid";
}
$DB->execute($tempcreatesql, array('userid' => $userid, 'courseid' => $courseid));
}
// deal with NULLs as it breaks the code.
$DB->execute("UPDATE {".$tempcomptablename."} SET timecompleted = 0 WHERE timecompleted is NULL");
return array($dbman, $table);
}
/**
* 'Delete' user from course
* @param int userid
* @param int courseid
*/
public static function delete_user($userid, $courseid, $action = '') {
global $DB, $CFG;
// Remove enrolments
$plugins = enrol_get_plugins(true);
$instances = enrol_get_instances($courseid, true);
foreach ($instances as $instance) {
$plugin = $plugins[$instance->enrol];
$plugin->unenrol_user($instance, $userid);
}
// Remove completions
$DB->delete_records('course_completions', array('userid' => $userid, 'course' => $courseid));
if ($compitems = $DB->get_records('course_completion_criteria', array('course' => $courseid))) {
foreach ($compitems as $compitem) {
$DB->delete_records('course_completion_crit_compl', array('userid' => $userid,
'criteriaid' => $compitem->id));
}
}
if ($modules = $DB->get_records_sql("SELECT id FROM {course_modules} WHERE course = :course AND completion != 0", array('course' => $courseid))) {
foreach ($modules as $module) {
$DB->delete_records('course_modules_completion', array('userid' => $userid, 'coursemoduleid' => $module->id));
}
}
// Remove grades
if ($items = $DB->get_records('grade_items', array('courseid' => $courseid))) {
foreach ($items as $item) {
$DB->delete_records('grade_grades', array('userid' => $userid, 'itemid' => $item->id));
}
}
// Remove quiz entries.
if ($quizzes = $DB->get_records('quiz', array('course' => $courseid))) {
// We have quiz(zes) so clear them down.
foreach ($quizzes as $quiz) {
$DB->execute("DELETE FROM {quiz_attempts} WHERE quiz=:quiz AND userid = :userid", array('quiz' => $quiz->id, 'userid' => $userid));
$DB->execute("DELETE FROM {quiz_grades} WHERE quiz=:quiz AND userid = :userid", array('quiz' => $quiz->id, 'userid' => $userid));
$DB->execute("DELETE FROM {quiz_overrides} WHERE quiz=:quiz AND userid = :userid", array('quiz' => $quiz->id, 'userid' => $userid));
}
}
// Remove certificate info.
if ($certificates = $DB->get_records('iomadcertificate', array('course' => $courseid))) {
foreach ($certificates as $certificate) {
$DB->execute("DELETE FROM {iomadcertificate_issues} WHERE iomadcertificateid = :certid AND userid = :userid", array('certid' => $certificate->id, 'userid' => $userid));
}
}
// Remove feedback info.
if ($feedbacks = $DB->get_records('feedback', array('course' => $courseid))) {
foreach ($feedbacks as $feedback) {
$DB->execute("DELETE FROM {feedback_completed} WHERE feedback = :feedbackid AND userid = :userid", array('feedbackid' => $feedback->id, 'userid' => $userid));
$DB->execute("DELETE FROM {feedback_completedtmp} WHERE feedback = :feedbackid AND userid = :userid", array('feedbackid' => $feedback->id, 'userid' => $userid));
$DB->execute("DELETE FROM {feedback_tracking} WHERE feedback = :feedbackid AND userid = :userid", array('feedbackid' => $feedback->id, 'userid' => $userid));
}
}
// Remove lesson info.
if ($lessons = $DB->get_records('lesson', array('course' => $courseid))) {
foreach ($lessons as $lesson) {
$DB->execute("DELETE FROM {lesson_attempts} WHERE lessonid = :lessonid AND userid = :userid", array('lessonid' => $lesson->id, 'userid' => $userid));
$DB->execute("DELETE FROM {lesson_grades} WHERE lessonid = :lessonid AND userid = :userid", array('lessonid' => $lesson->id, 'userid' => $userid));
$DB->execute("DELETE FROM {lesson_branch} WHERE lessonid = :lessonid AND userid = :userid", array('lessonid' => $lesson->id, 'userid' => $userid));
$DB->execute("DELETE FROM {lesson_timer} WHERE lessonid = :lessonid AND userid = :userid", array('lessonid' => $lesson->id, 'userid' => $userid));
}
}
// Fix company licenses
if ($licenses = $DB->get_records('companylicense_users', array('licensecourseid' => $courseid, 'userid' =>$userid, 'isusing' => 1))) {
$license = array_pop($licenses);
if ($action == 'delete') {
$DB->delete_records('companylicense_users', array('id' => $license->id));
// Fix the usagecount.
$licenserecord = $DB->get_record('companylicense', array('id' => $license->licenseid));
$licenserecord->used = $DB->count_records('companylicense_users', array('licenseid' => $license->licenseid));
$DB->update_record('companylicense', $licenserecord);
} else if ($action == 'clear') {
$newlicense = $license;
$license->timecompleted = time();
$DB->update_record('companylicense_users', $license);
$newlicense->isusing = 0;
$newlicense->issuedate = time();
$newlicense->timecompleted = null;
$licenserecord = $DB->get_record('companylicense', array('id' => $license->licenseid));
if ($licenserecord->used < $licenserecord->allocation) {
$DB->insert_record('companylicense_users', (array) $newlicense);
$licenserecord->used = $DB->count_records('companylicense_users', array('licenseid' => $license->licenseid));
$DB->update_record('companylicense', $licenserecord);
}
}
}
}
}
| lernlink/iomad-ll | local/report_user_license_allocations/lib.php | PHP | gpl-3.0 | 17,341 |
// T4 code generation is enabled for model 'D:\PRV\GitHub\WhoLends\WhoLends\WhoLends.Data\WLModel.edmx'.
// To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
// property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
// is open in the designer.
// If no context and entity classes have been generated, it may be because you created an empty model but
// have not yet chosen which version of Entity Framework to use. To generate a context class and entity
// classes for your model, open the model in the designer, right-click on the designer surface, and
// select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
// Item...'. | mbarmettler/WhoLends | WhoLends/WhoLends.Data/WLModel.Designer.cs | C# | gpl-3.0 | 765 |
/**
* Standalone Window.
*
* A window in standalone display mode.
*/
/**
* Standalone Window Constructor.
*
* @extends BaseWindow.
* @param {number} id Window ID to give standalone window.
* @param {string} url URL to navigate to.
* @param {Object} webApp WebApp with metadata to generate window from.
*/
var StandaloneWindow = function(id, url, webApp) {
this.currentUrl = url;
if (webApp && webApp.name) {
this.name = webApp.name;
} else if (webApp && webApp.shortName) {
this.name = webApp.shortName;
} else {
try {
this.name = new URL(url).hostname;
} catch(e) {
this.name = '';
}
}
if (webApp && webApp.themeColor) {
this.themeColor = webApp.themeColor;
}
BaseWindow.call(this, id);
return this;
};
StandaloneWindow.prototype = Object.create(BaseWindow.prototype);
/**
* Window View.
*/
StandaloneWindow.prototype.view = function() {
var titleBarStyle = '';
var titleBarClass = 'standalone-window-title-bar';
if (this.themeColor) {
titleBarStyle = 'background-color: ' + this.themeColor + ';';
var rgb = this.hexToRgb(this.themeColor);
backgroundBrightness = this.darkOrLight(rgb);
titleBarClass += ' ' + backgroundBrightness;
}
return '<div id="window' + this.id + '"class="standalone-window">' +
'<div class="' + titleBarClass + '" style="' + titleBarStyle + '">' +
'<span id="standalone-window-title' + this.id +
'" class="standalone-window-title">' + this.name + '</span>' +
'<button type="button" id="close-window-button' + this.id + '" ' +
'class="close-window-button">' +
'</div>' +
'<webview src="' + this.currentUrl + '" id="standalone-window-frame' +
this.id + '" class="standalone-window-frame">' +
'</div>';
};
/**
* Render the window.
*/
StandaloneWindow.prototype.render = function() {
this.container.insertAdjacentHTML('beforeend', this.view());
this.element = document.getElementById('window' + this.id);
this.title = document.getElementById('standalone-window-title' + this.id);
this.closeButton = document.getElementById('close-window-button' + this.id);
this.closeButton.addEventListener('click', this.close.bind(this));
this.frame = document.getElementById('standalone-window-frame' + this.id);
this.frame.addEventListener('did-navigate',
this.handleLocationChange.bind(this));
this.frame.addEventListener('did-navigate-in-page',
this.handleLocationChange.bind(this));
this.frame.addEventListener('new-window',
this.handleOpenWindow.bind(this));
};
/**
* Show the Window.
*/
StandaloneWindow.prototype.show = function() {
this.element.classList.remove('hidden');
};
/**
* Hide the window.
*/
StandaloneWindow.prototype.hide = function() {
this.element.classList.add('hidden');
};
/**
* Handle location change.
*
* @param {Event} e mozbrowserlocationchange event.
*/
StandaloneWindow.prototype.handleLocationChange = function(e) {
this.currentUrl = e.url;
};
/**
* Convert hex color value to rgb.
*
* @argument {String} hex color string e.g. #ff0000
* @returns {Object} RGB object with separate r, g and b properties
*/
StandaloneWindow.prototype.hexToRgb = function(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
};
/**
* Measure whether color is dark or light.
*
* @param {Object} RGB object with r, g, b properties.
* @return {String} 'dark' or 'light'.
*/
StandaloneWindow.prototype.darkOrLight = function(rgb) {
if ((rgb.r*0.299 + rgb.g*0.587 + rgb.b*0.114) > 186) {
return 'light';
} else {
return 'dark';
}
};
| webianproject/shell | chrome/desktop/js/StandaloneWindow.js | JavaScript | gpl-3.0 | 3,719 |
package com.fxs.platform.web.controller;
import java.util.List;
import com.fxs.platform.security.core.support.ResponseMessage;
import com.fxs.platform.security.core.support.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.support.SessionStatus;
import com.fxs.platform.domain.Answer;
import com.fxs.platform.domain.DisputeInfo;
import com.fxs.platform.domain.Question;
import com.fxs.platform.service.AnswerService;
import com.fxs.platform.service.FalltypusService;
import com.fxs.platform.service.QuestionService;
import com.fxs.platform.utils.ResponseCodeEnum;
@Controller
@RequestMapping("/disputeInfo")
public class DisputeInfoController {
@Autowired
private AnswerService answerService;
@Autowired
private QuestionService questionService;
@Autowired
FalltypusService falltypusService;
/**
* 获取所有的纷争信息
*
* @param map
* @return
*/
@GetMapping("/getAllDisputeInfo")
public String getAllDisputeInfo(ModelMap map) {
map.addAttribute("questionList", questionService.getAllQuestion());
map.addAttribute("availableFalltypus", falltypusService.findAll());
return "public_list_dispute_info";
}
/**
* 根据案件类型过滤已绑定的问题
*
* @param filter
* @param map
* @return
*/
@GetMapping("/filterDisputeInfo/{filter}")
public String getDisputeInfoWithFilter(@PathVariable("filter") String filter, ModelMap map) {
if (! ObjectUtils.isEmpty(filter) && !filter.equals("-1")) {
map.addAttribute("questionList", questionService.filterAllQuestionsByFalltypus(filter));
} else {
map.addAttribute("questionList", questionService.getAllQuestion());
}
map.addAttribute("availableFalltypus", falltypusService.findAll());
return "public_list_dispute_info :: questionBlock-fragment";
}
/**
* 创建问题
* @param disputeInfo
* @param bindingResult
* @param map
* @return
*/
@GetMapping(value = "/createDisputeInfo")
public String newDisputeInfoForm(@ModelAttribute(value = "disputeInfo") DisputeInfo disputeInfo,
BindingResult bindingResult, ModelMap map) {
return "public_add_dispute_info";
}
@PostMapping(value = "/createDisputeInfo")
public String create(DisputeInfo disputeInfo, BindingResult result,
SessionStatus status) {
List<String> questions = disputeInfo.getQuestion();
Question ques = null;
if (!ObjectUtils.isEmpty(questions)) {
for (String question : questions) {
ques = new Question();
ques.setDescription(question);
ques.setIsRootQuestion(disputeInfo.getIsRootQuestion());
ques.setQuestionType(disputeInfo.getQuestionType());
//ques.setDisputeInfo(disputeInfo);
questionService.save(ques);
List<String> answers = disputeInfo.getAnswer();
Answer answer = null;
if (answers != null) {
for (int i = 0; i < answers.size(); i++) {
if(!ObjectUtils.isEmpty(answers.get(i))) {
answer = new Answer();
answer.setDescription(answers.get(i));
answer.setQuestion(ques);
answerService.save(answer);
}
}
}
}
}
return "redirect:/disputeInfo/getAllDisputeInfo";
}
@GetMapping(value = "/viewDisputeInfo/{id}")
public String view(@PathVariable("id") String id, ModelMap map) {
Question question = questionService.getByQuestionId(id);
map.addAttribute("availableFalltypus", falltypusService.findAll());
map.addAttribute("availableQuestions", questionService.getAllQuestion());
if(!ObjectUtils.isEmpty(question)) {
map.addAttribute("mappedQuestionAnswers", answerService.getAllAnswerByQuestionId(question.getId()));
map.addAttribute("question", question);
} else {
map.addAttribute("mappedQuestionAnswers", null);
map.addAttribute("question", null);
}
return "public_view_dispute_info";
}
@DeleteMapping(value = "/question/delete/{id}")
@ResponseBody
public ResponseMessage<String> deleteQuestion(@PathVariable("id") String id) {
questionService.delete(id);
return Result.success("success");
}
@DeleteMapping(value = "/answer/delete/{id}")
@ResponseBody
public ResponseMessage<String> deleteAnswer(@PathVariable("id") String id) {
answerService.delete(id);
return Result.success("success");
}
@PostMapping(value = "/updateAnswer")
public String update(@ModelAttribute(value = "answer") Answer answer, BindingResult result,
SessionStatus status) {
//List<Integer> nextQuestionIds = question.getDisputeInfo().getNextQuestion();
//List<String> answers = question.getDisputeInfo().getAnswer();
/*if (answers != null) {
for (int i = 0; i < answers.size(); i++) {
//answerService.updateNextQuestion(answers.get(i));
}
}*/
status.setComplete();
return "redirect:/disputeInfo/getAllDisputeInfo";
}
/**
* 更新问题信息
*
* @param question
* @return
*/
@PutMapping(value = "/update/question/basic")
@ResponseBody
public ResponseMessage<String> updateQuestionBasicInfo(@RequestBody Question question) {
Question qInfo = questionService.getByQuestionId(question.getId());
Question rootQuestion = null;
//在编辑问题的时候,如果将当前问题设置为根问题,则需要判断当前选择的带绑定的案件类型下是否已经有绑定根问题,如有则不能重复绑定
if ("Y".equals(question.getIsRootQuestion())) {
rootQuestion = questionService.findCurrentRootQuestion(question.getBelongsToFalltypus());
}
if(!ObjectUtils.isEmpty(rootQuestion) && !rootQuestion.getBelongsToFalltypus().equals(qInfo.getBelongsToFalltypus())) {
return Result.error(String.valueOf(ResponseCodeEnum.ERROR.getCode()), "同一个案件类型不能绑定多个根问题");
}
if(!ObjectUtils.isEmpty(qInfo)) {
//如果当前选择的待绑定的案件类型与原数据不一致,则重新绑定
if(! question.getBelongsToFalltypus().equals(qInfo.getBelongsToFalltypus())) {
questionService.updateQFMapping(question);
}
//更新问题的基本信息
questionService.update(question);
}
return Result.success("success");
}
/**
* 解除问题和案件类型的绑定关系
*
* @param question
* @return
*/
@PutMapping(value = "/update/question/qfMapping")
@ResponseBody
public ResponseMessage<String> updateQuestionFalltypusMapping(@RequestBody Question question) {
Question qInfo = questionService.getByQuestionId(question.getId());
if(!ObjectUtils.isEmpty(qInfo)) {
//如果当前选择的待绑定的案件类型与原数据不一致,则重新绑定,
if(!qInfo.getBelongsToFalltypus().equals(question.getBelongsToFalltypus())) {
questionService.updateQFMapping(question);
}
}
return Result.success("success");
}
/**
* 更新问题信息
*
* @param answer
* @return
*/
@PutMapping(value = "/update/answer/basic")
@ResponseBody
public ResponseMessage<String> updateAnswerBasicInfo(@RequestBody Answer answer) {
Answer answerInfo = answerService.getByAnswerId(answer.getId());
if(!ObjectUtils.isEmpty(answerInfo)) {
//如果当前选择的待绑定的案件类型与原数据不一致,则重新绑定,
if(!answer.getNextQuestionId().equals(answerInfo.getNextQuestionId())) {
answerService.updateNextQuestion(answer);
}
//更新问题的基本信息
answer.getQuestion().setId(answerInfo.getQuestion().getId());
answer.setOther(answerInfo.getOther());
answerService.update(answer);
}
return Result.success("success");
}
/**
* 解除答案和案件类型的绑定关系
*
* @param answer
* @return
*/
@PutMapping(value = "/update/answer/qaMapping")
@ResponseBody
public ResponseMessage<String> updateAnswerFalltypusMapping(@RequestBody Answer answer) {
Answer answerInfo = answerService.getByAnswerId(answer.getId());
if(!ObjectUtils.isEmpty(answerInfo)) {
//如果当前选择的待绑定的案件类型与原数据不一致,则重新绑定,
if(!answerInfo.getNextQuestionId().equals(answer.getNextQuestionId())) {
answerService.updateNextQuestion(answer);
}
}
return Result.success("success");
}
}
| charlesyao/FXS-Platform | fxs-platform-web/src/main/java/com/fxs/platform/web/controller/DisputeInfoController.java | Java | gpl-3.0 | 8,398 |
#include <iostream>
#include <string>
#include <algorithm>
#include <fstream>
#define IN cin
using namespace std;
//bool sort_logic(int i, int j);
//void pr(int data[], int length);
// EOF Termination
int main(){
int __initial_input, max_index, rear;
int register i;
//ifstream input;
//input.open("input.txt");
for(IN >> __initial_input; __initial_input != 0; IN >> __initial_input){
int data[__initial_input][3];
for(i = 0; i < __initial_input; i++){
IN >> data[i][0] >> data[i][1] >> data[i][2];
}
for(i = 0, max_index = 0; i < __initial_input; i++){
if(data[i][2] > data[max_index][2]){
max_index = i;
}
}
// Cheacking if has any equeal
int max_volumes[__initial_input];
rear = 0;
for(i = 0; i < __initial_input; i++){
if(data[max_index][2] == data[i][2]){
max_volumes[rear] = i;
rear++;
}
}
// Piciking up the optimal result
for(i = 0, max_index = max_volumes[i]; i < rear; i++){
if( (data[max_volumes[i]][0] * data[max_volumes[i]][1] * data[max_volumes[i]][2]) > (data[max_index][0] * data[max_index][1] * data[max_index][2]) ){
max_index = max_volumes[i];
}
}
cout << (data[max_index][0] * data[max_index][1] * data[max_index][2]) << endl;
}
//input.close();
return 0;
}
// Input Termination
/*int main(){
int __initial_input;
for(cin >> __initial_input; __initial_input != 0; cin >> __initial_input){
cout << "Initail Input ::" << __initial_input << endl;
}
return 0;
}*/
// Case Number
/*int main(){
int __initial_input, __case_number;
//ifstream input;
//input.open("input.txt");
for(IN >> __initial_input, __case_number = 1; __case_number <= __initial_input; __case_number++){
cout << "Case #" << __case_number << endl;
}
//input.close();
return 0;
}
bool sort_logic(int i, int j){
return i > j;
}
void pr(int data[], int length){
int i;
for(i = 0; i< length; i++) cout << data[i] << " ";
cout << endl;
}
*/
| aihimel/contestprogramming | Dhaka SIte Regional/2013/(solved)12709(Falling Ants)/12709(Falling_Ants).cpp | C++ | gpl-3.0 | 2,070 |
/*
* PropertySaver.java
*
* Created on October 9, 2007, 3:13 PM
*
* Trieda, ktoru nainicializuje objekt PropertyReader, pri starte programu
* WebAnalyzer. Tento objekt bude jedinacik a bude poskytovat vlastnosti, ktore
* potrebuju jednotlive moduly WebAnalyzatoru.
*
*/
package org.apache.analyzer.config;
/**
*
* @author praso
*/
public class PropertySaver {
public static final PropertySaver INSTANCE = new PropertySaver();
private int crawlerPropertyMaxUrls;
private int crawlerPropertyTimeout;
/**
* Creates a new instance of PropertySaver
*/
private PropertySaver() {
}
public int getCrawlerPropertyMaxUrls() {
return crawlerPropertyMaxUrls;
}
public void setCrawlerPropertyMaxUrls(int crawlerPropertyMaxUrls) {
this.crawlerPropertyMaxUrls = crawlerPropertyMaxUrls;
}
public int getCrawlerPropertyTimeout() {
return crawlerPropertyTimeout;
}
public void setCrawlerPropertyTimeout(int crawlerPropertyTimeout) {
this.crawlerPropertyTimeout = crawlerPropertyTimeout;
}
}
| WebArchivCZ/webanalyzer | src/org/apache/analyzer/config/PropertySaver.java | Java | gpl-3.0 | 1,116 |
/*
* Copyright (C) 2020 The Android Open Source Project
*
* 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.
*/
package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.LauncherState.HINT_STATE;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
import static com.android.launcher3.util.VibratorWrapper.OVERVIEW_HAPTIC;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.graphics.PointF;
import android.util.Log;
import android.view.MotionEvent;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.graphics.OverviewScrim;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.states.StateAnimationConfig;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.util.VibratorWrapper;
import com.android.quickstep.util.AnimatorControllerWithResistance;
import com.android.quickstep.util.OverviewToHomeAnim;
import com.android.quickstep.views.RecentsView;
/**
* Touch controller which handles swipe and hold from the nav bar to go to Overview. Swiping above
* the nav bar falls back to go to All Apps. Swiping from the nav bar without holding goes to the
* first home screen instead of to Overview.
*/
public class NoButtonNavbarToOverviewTouchController extends FlingAndHoldTouchController {
// How much of the movement to use for translating overview after swipe and hold.
private static final float OVERVIEW_MOVEMENT_FACTOR = 0.25f;
private static final long TRANSLATION_ANIM_MIN_DURATION_MS = 80;
private static final float TRANSLATION_ANIM_VELOCITY_DP_PER_MS = 0.8f;
private final RecentsView mRecentsView;
private boolean mDidTouchStartInNavBar;
private boolean mReachedOverview;
// The last recorded displacement before we reached overview.
private PointF mStartDisplacement = new PointF();
private float mStartY;
private AnimatorPlaybackController mOverviewResistYAnim;
// Normal to Hint animation has flag SKIP_OVERVIEW, so we update this scrim with this animator.
private ObjectAnimator mNormalToHintOverviewScrimAnimator;
public NoButtonNavbarToOverviewTouchController(Launcher l) {
super(l);
mRecentsView = l.getOverviewPanel();
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.PAUSE_NOT_DETECTED, "NoButtonNavbarToOverviewTouchController.ctor");
}
}
@Override
protected float getMotionPauseMaxDisplacement() {
// No need to disallow pause when swiping up all the way up the screen (unlike
// FlingAndHoldTouchController where user is probably intending to go to all apps).
return Float.MAX_VALUE;
}
@Override
protected boolean canInterceptTouch(MotionEvent ev) {
mDidTouchStartInNavBar = (ev.getEdgeFlags() & EDGE_NAV_BAR) != 0;
return super.canInterceptTouch(ev);
}
@Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
if (fromState == NORMAL && mDidTouchStartInNavBar) {
return HINT_STATE;
} else if (fromState == OVERVIEW && isDragTowardPositive) {
// Don't allow swiping up to all apps.
return OVERVIEW;
}
return super.getTargetState(fromState, isDragTowardPositive);
}
@Override
protected float initCurrentAnimation(int animComponents) {
float progressMultiplier = super.initCurrentAnimation(animComponents);
if (mToState == HINT_STATE) {
// Track the drag across the entire height of the screen.
progressMultiplier = -1 / getShiftRange();
}
return progressMultiplier;
}
@Override
public void onDragStart(boolean start, float startDisplacement) {
super.onDragStart(start, startDisplacement);
if (mFromState == NORMAL && mToState == HINT_STATE) {
mNormalToHintOverviewScrimAnimator = ObjectAnimator.ofFloat(
mLauncher.getDragLayer().getOverviewScrim(),
OverviewScrim.SCRIM_PROGRESS,
mFromState.getOverviewScrimAlpha(mLauncher),
mToState.getOverviewScrimAlpha(mLauncher));
}
mReachedOverview = false;
mOverviewResistYAnim = null;
}
@Override
protected void updateProgress(float fraction) {
super.updateProgress(fraction);
if (mNormalToHintOverviewScrimAnimator != null) {
mNormalToHintOverviewScrimAnimator.setCurrentFraction(fraction);
}
}
@Override
public void onDragEnd(float velocity) {
super.onDragEnd(velocity);
mNormalToHintOverviewScrimAnimator = null;
if (mLauncher.isInState(OVERVIEW)) {
// Normally we would cleanup the state based on mCurrentAnimation, but since we stop
// using that when we pause to go to Overview, we need to clean up ourselves.
clearState();
}
}
@Override
protected void updateSwipeCompleteAnimation(ValueAnimator animator, long expectedDuration,
LauncherState targetState, float velocity, boolean isFling) {
super.updateSwipeCompleteAnimation(animator, expectedDuration, targetState, velocity,
isFling);
if (targetState == HINT_STATE) {
// Normally we compute the duration based on the velocity and distance to the given
// state, but since the hint state tracks the entire screen without a clear endpoint, we
// need to manually set the duration to a reasonable value.
animator.setDuration(HINT_STATE.getTransitionDuration(mLauncher));
}
}
@Override
protected void onMotionPauseChanged(boolean isPaused) {
if (mCurrentAnimation == null) {
return;
}
mNormalToHintOverviewScrimAnimator = null;
mCurrentAnimation.dispatchOnCancelWithoutCancelRunnable(() -> {
mLauncher.getStateManager().goToState(OVERVIEW, true, () -> {
mOverviewResistYAnim = AnimatorControllerWithResistance
.createRecentsResistanceFromOverviewAnim(mLauncher, null)
.createPlaybackController();
mReachedOverview = true;
maybeSwipeInteractionToOverviewComplete();
});
});
VibratorWrapper.INSTANCE.get(mLauncher).vibrate(OVERVIEW_HAPTIC);
}
private void maybeSwipeInteractionToOverviewComplete() {
if (mReachedOverview && mDetector.isSettlingState()) {
onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE);
}
}
@Override
protected boolean handlingOverviewAnim() {
return mDidTouchStartInNavBar && super.handlingOverviewAnim();
}
@Override
public boolean onDrag(float yDisplacement, float xDisplacement, MotionEvent event) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.PAUSE_NOT_DETECTED, "NoButtonNavbarToOverviewTouchController");
}
if (mMotionPauseDetector.isPaused()) {
if (!mReachedOverview) {
mStartDisplacement.set(xDisplacement, yDisplacement);
mStartY = event.getY();
} else {
mRecentsView.setTranslationX((xDisplacement - mStartDisplacement.x)
* OVERVIEW_MOVEMENT_FACTOR);
float yProgress = (mStartDisplacement.y - yDisplacement) / mStartY;
if (yProgress > 0 && mOverviewResistYAnim != null) {
mOverviewResistYAnim.setPlayFraction(yProgress);
} else {
mRecentsView.setTranslationY((yDisplacement - mStartDisplacement.y)
* OVERVIEW_MOVEMENT_FACTOR);
}
}
// Stay in Overview.
return true;
}
return super.onDrag(yDisplacement, xDisplacement, event);
}
@Override
protected void goToOverviewOnDragEnd(float velocity) {
float velocityDp = dpiFromPx(velocity);
boolean isFling = Math.abs(velocityDp) > 1;
StateManager<LauncherState> stateManager = mLauncher.getStateManager();
boolean goToHomeInsteadOfOverview = isFling;
if (goToHomeInsteadOfOverview) {
new OverviewToHomeAnim(mLauncher, ()-> onSwipeInteractionCompleted(NORMAL, Touch.FLING))
.animateWithVelocity(velocity);
}
if (mReachedOverview) {
float distanceDp = dpiFromPx(Math.max(
Math.abs(mRecentsView.getTranslationX()),
Math.abs(mRecentsView.getTranslationY())));
long duration = (long) Math.max(TRANSLATION_ANIM_MIN_DURATION_MS,
distanceDp / TRANSLATION_ANIM_VELOCITY_DP_PER_MS);
mRecentsView.animate()
.translationX(0)
.translationY(0)
.setInterpolator(ACCEL_DEACCEL)
.setDuration(duration)
.withEndAction(goToHomeInsteadOfOverview
? null
: this::maybeSwipeInteractionToOverviewComplete);
if (!goToHomeInsteadOfOverview) {
// Return to normal properties for the overview state.
StateAnimationConfig config = new StateAnimationConfig();
config.duration = duration;
LauncherState state = mLauncher.getStateManager().getState();
mLauncher.getStateManager().createAtomicAnimation(state, state, config).start();
}
}
}
private float dpiFromPx(float pixels) {
return Utilities.dpiFromPx(pixels, mLauncher.getResources().getDisplayMetrics());
}
}
| Deletescape-Media/Lawnchair | quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java | Java | gpl-3.0 | 10,748 |
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2021 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.queue;
import java.util.HashMap;
import java.util.Map;
public enum LightingMode {
NONE(0),
PLACEMENT(1),
REPLACEMENT(2),
ALL(3);
private static final Map<Integer, LightingMode> map = new HashMap<>();
static {
for (LightingMode mode : LightingMode.values()) {
map.put(mode.mode, mode);
}
}
private final int mode;
LightingMode(int mode) {
this.mode = mode;
}
public static LightingMode valueOf(int mode) {
return map.get(mode);
}
public int getMode() {
return mode;
}
}
| IntellectualCrafters/PlotSquared | Core/src/main/java/com/plotsquared/core/queue/LightingMode.java | Java | gpl-3.0 | 1,929 |
using System.Runtime.Serialization;
namespace CastReporting.Domain
{
/// <summary>
///
/// </summary>
[DataContract(Name = "remedialAction")]
public class RemedialAction
{
[DataMember(Name = "status")]
public string Status { get; set; }
[DataMember(Name = "priority")]
public string Priority { get; set; }
[DataMember(Name = "comment")]
public string Comment { get; set; }
[DataMember(Name = "dates")]
public RemedialDates Dates { get; set; }
}
} | CAST-projects/ReportGenerator | CastReporting.Domain/DataObject/RemedialAction.cs | C# | gpl-3.0 | 555 |
/*
* emucpu -- Emulates processors
* Copyright (C) 2009 Joseph Freeman (jfree143dev AT gmail DOT com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
@file Immediate.hh
@brief Read-only implementation of INumberReadableWritable for immediate values.
*/
#ifndef EMUCPU__IMMEDIATE_HH
#define EMUCPU__IMMEDIATE_HH
#include "INumberReadableWritable.hh"
#include <iostream>
#include "Types.hh"
/**
@class Immediate
@brief Read-only implementation of INumberReadableWritable for immediate values.
*/
template<typename T>
class Immediate : public INumberReadableWritable<T> {
T *m_num;
bool m_deletable;
public:
/** */
Immediate () {
m_num = new T ();
m_deletable = true;
}
/** */
Immediate (const Immediate<T> &src) {
//if (src.m_deletable) {
m_num = new T ();
*m_num = *(src.m_num);
m_deletable = true;
/*
}
else {
m_num = src.m_num;
m_deletable = false;
}
*/
}
/** */
Immediate (T &r, bool cp=false) {
if (cp) {
m_num = new T ();
*m_num = r;
m_deletable = true;
}
else {
m_num = &r;
m_deletable = false;
}
}
/** */
Immediate (const T &r) {
m_num = new T ();
*m_num = r;
m_deletable = true;
}
/** */
virtual ~Immediate () {
if (m_deletable) {
delete m_num;
}
}
private:
void reinitialize (T &r) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
}
void reinitialize (const T &r) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
}
public:
/** @brief Implicit cast to stored value. */
virtual operator const T& () const {
return *m_num;
}
/** @brief Get the stored value. */
virtual const T& getValue () const {
return *m_num;
}
private:
virtual uint16 getSegment () const {
std::cerr << "Debug: class Immediate has no segment" << std::endl;
return 0;
}
virtual uint16 getOffset () const {
std::cerr << "Debug: class Immediate has no offset" << std::endl;
return 0;
}
virtual const INumberReadableWritable<T>& operator++ () {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual const T operator++ (int32) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *m_num;
}
virtual const INumberReadableWritable<T>& operator-- () {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual const T operator-- (int32) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *m_num;
}
virtual INumberReadableWritable<T>& operator= (const T &right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator= (const INumberReadableWritable<T> &right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator= (const Immediate<T> &right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator+= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator-= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator*= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator/= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator%= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator^= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator&= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator|= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator>>= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
virtual INumberReadableWritable<T>& operator<<= (const T& right) {
std::cerr << "Debug: class Immediate is read-only" << std::endl;
return *this;
}
}; //end class Immediate
#endif //EMUCPU__IMMEDIATE_HH
| sundrythoughts/EmuCpu | src/Immediate.hh | C++ | gpl-3.0 | 5,180 |
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.map.writer.model;
import java.util.Arrays;
import org.mapsforge.core.model.Coordinates;
import org.mapsforge.map.writer.OSMTagMapping;
import org.mapsforge.map.writer.util.OSMUtils;
import org.openstreetmap.osmosis.core.domain.v0_6.Node;
/**
* @author bross
*/
public class TDNode {
// private static final Logger LOGGER = Logger.getLogger(TDNode.class.getName());
private static final byte ZOOM_HOUSENUMBER = (byte) 18;
// private static final byte ZOOM_NAME = (byte) 16;
private final long id;
private final int latitude;
private final int longitude;
private final short elevation; // NOPMD by bross on 25.12.11 12:55
private final String houseNumber;
private final byte layer;
private final String name;
private short[] tags; // NOPMD by bross on 25.12.11 12:55
/**
* Constructs a new TDNode from a given osmosis node entity. Checks the validity of the entity.
*
* @param node
* the osmosis entity
* @param preferredLanguage
* the preferred language or null if no preference
* @return a new TDNode
*/
public static TDNode fromNode(Node node, String preferredLanguage) {
SpecialTagExtractionResult ster = OSMUtils.extractSpecialFields(node, preferredLanguage);
short[] knownWayTags = OSMUtils.extractKnownPOITags(node); // NOPMD by bross on 25.12.11 12:55
java.util.Arrays.sort(knownWayTags);
return new TDNode(node.getId(), Coordinates.degreesToMicrodegrees(node.getLatitude()),
Coordinates.degreesToMicrodegrees(node.getLongitude()), ster.getElevation(), ster.getLayer(),
ster.getHousenumber(), ster.getName(), knownWayTags);
}
/**
* @param id
* the OSM id
* @param latitude
* the latitude
* @param longitude
* the longitude
* @param elevation
* the elevation if existent
* @param layer
* the layer if existent
* @param houseNumber
* the house number if existent
* @param name
* the name if existent
*/
public TDNode(long id, int latitude, int longitude, short elevation, byte layer, String houseNumber, // NOPMD
// by
// bross
// on
// 25.12.11
// 12:55
String name) {
this.id = id;
this.latitude = latitude;
this.longitude = longitude;
this.elevation = elevation;
this.houseNumber = houseNumber;
this.layer = layer;
this.name = name;
}
/**
* @param id
* the OSM id
* @param latitude
* the latitude
* @param longitude
* the longitude
* @param elevation
* the elevation if existent
* @param layer
* the layer if existent
* @param houseNumber
* the house number if existent
* @param name
* the name if existent
* @param tags
* the
*/
public TDNode(long id, int latitude, int longitude, short elevation, byte layer, String houseNumber, // NOPMD
// by
// bross
// on
// 25.12.11
// 12:55
String name, short[] tags) { // NOPMD by bross on 25.12.11 12:58
this.id = id;
this.latitude = latitude;
this.longitude = longitude;
this.elevation = elevation;
this.houseNumber = houseNumber;
this.layer = layer;
this.name = name;
this.tags = tags;
}
/**
* @return true if the node represents a POI
*/
public boolean isPOI() {
return this.houseNumber != null || this.elevation != 0 || this.tags.length > 0;
}
/**
* @return the zoom level on which the node appears first
*/
public byte getZoomAppear() {
if (this.tags == null || this.tags.length == 0) {
if (this.houseNumber != null) {
return ZOOM_HOUSENUMBER;
}
return Byte.MAX_VALUE;
}
return OSMTagMapping.getInstance().getZoomAppearPOI(this.tags);
}
/**
* @return the id
*/
public long getId() {
return this.id;
}
/**
* @return the tags
*/
public short[] getTags() { // NOPMD by bross on 25.12.11 12:58
return this.tags; // NOPMD by bross on 25.12.11 12:56
}
/**
* @param tags
* the tags to set
*/
public void setTags(short[] tags) { // NOPMD by bross on 25.12.11 12:58
this.tags = tags;
}
/**
* @return the latitude
*/
public int getLatitude() {
return this.latitude;
}
/**
* @return the longitude
*/
public int getLongitude() {
return this.longitude;
}
/**
* @return the elevation
*/
public short getElevation() { // NOPMD by bross on 25.12.11 12:58
return this.elevation;
}
/**
* @return the houseNumber
*/
public String getHouseNumber() {
return this.houseNumber;
}
/**
* @return the layer
*/
public byte getLayer() {
return this.layer;
}
/**
* @return the name
*/
public String getName() {
return this.name;
}
@Override
public int hashCode() {
final int prime = 31; // NOPMD by bross on 25.12.11 12:56
int result = 1;
result = prime * result + (int) (this.id ^ (this.id >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
TDNode other = (TDNode) obj;
if (this.id != other.id) {
return false;
}
return true;
}
@Override
public final String toString() {
return "TDNode [id=" + this.id + ", latitude=" + this.latitude + ", longitude=" + this.longitude + ", name="
+ this.name + ", tags=" + Arrays.toString(this.tags) + "]";
}
}
| opensciencemap/VectorTileMap | map-writer-osmosis/src/main/java/org/mapsforge/map/writer/model/TDNode.java | Java | gpl-3.0 | 6,372 |
#include "../Resource/ResourceManager.h"
#include "../Resource/Handle/DLHandle.h"
#include "../Resource/Handle/DAHandle.h"
#include "../Err/FlashToolErrorCodeDef.h"
#include "../Conn/Connection.h"
#include "../Err/Exception.h"
#include "../Logger/Log.h"
#include "EfuseCommand.h"
#include "../Utility/IniItem.h"
#define sbc_pub_key_hash \
sbc_pub_key_u.r_sbc_pub_key_hash
#define _sbc_key_E \
sbc_pub_key_u.w_sbc_pub_key.key_e
#define _sbc_key_N \
sbc_pub_key_u.w_sbc_pub_key.key_n
#define sbc_pub_key_hash1 \
sbc_pub_key1_u.r_sbc_pub_key_hash1
#define _sbc_key1_E \
sbc_pub_key1_u.w_sbc_pub_key1.key_e
#define _sbc_key1_N \
sbc_pub_key1_u.w_sbc_pub_key1.key_n
#define EfuseOpt2Text(opt) \
((opt)==EFUSE_ENABLE ? "on" : "off")
#define DumpEfuseOpt(p, sec) \
LOGI(#sec " = %s", EfuseOpt2Text(p->sec))
#define DumpEfuseOptEx(p, sec, key) \
LOGI("%s = %s", key.c_str(), EfuseOpt2Text(p.sec))
#define DumpInteger(p, sec) \
LOGI(#sec " = %d", p->sec)
#define DumpIntegerEx(p, sec, key) \
LOGI("%s = %d", key.c_str(), p.sec)
#define DumpShortHex(p, sec) \
LOGI(#sec " = %04x", p->sec)
#define DumpIntHex(p, sec) \
LOGI(#sec " = %08x", p->sec)
#define DumpIntHexEx(p, sec, key) \
LOGI("%s = %08x", key.c_str(), p.sec)
#define DumpText(p, sec) \
LOGI(#sec " = %s", (p->sec).buf)
#define DumpTextEx(p, sec, key) \
LOGI("%s = %s", key.c_str(), (p.sec).buf)
#define DumpBinary(p, sec) \
LOGI(#sec " = %s", Binary2Str(p->sec).c_str())
#define DumpBinaryEx(p, sec, key) \
LOGI("%s = %s", key.c_str(), Binary2Str(p.sec).c_str())
#define DumpEfuseSTBOpt(p, sec) \
LOGI(#sec " = %s", EfuseOpt2Text(p.sec))
#define DumpSTBKeyName(p, sec) \
LOGI(#sec " = %s", p.sec)
#define DumpSTBText(p, sec) \
LOGI(#sec " = %s", (p.sec).buf)
#define DumpSTBBinary(p, sec) \
LOGI(#sec " = %s", Binary2Str(p.sec).c_str())
#define SaveEfuseOpt(f, p, sec) \
fprintf(f, #sec " = %s\r\n", EfuseOpt2Text(p->sec))
#define SaveEfuseOptEx(f, p, sec, key) \
fprintf(f, "%s =%s\r\n", key.c_str(), EfuseOpt2Text(p.sec))
#define SaveInteger(f, p, sec) \
fprintf(f, #sec " = %d\r\n", p->sec)
#define SaveIntegerEx(f, p, sec, key) \
fprintf(f, "%s = %d\r\n", key.c_str(), p.sec)
#define SaveShortHex(f, p, sec) \
fprintf(f, #sec " = %04x\r\n", p->sec)
#define SaveIntHex(f, p, sec) \
fprintf(f, #sec " = %08x\r\n", p->sec)
#define SaveIntHexEx(f, p, sec, key) \
fprintf(f, "%s = %08x\r\n", key.c_str(), p->sec)
#define SaveBinary(f, p, sec) \
fprintf(f, #sec " = %s\r\n", Binary2Str(p->sec).c_str())
#define SaveBinaryEx(f, p, sec, key) \
fprintf(f, "%s = %s\r\n", key.c_str(), Binary2Str(p.sec).c_str())
#define SaveSTBKeyName(f, p, sec) \
fprintf(f, #sec " = %s\r\n", p.sec)
#define SaveSTBBinary(f, p, sec) \
fprintf(f, #sec " = %s\r\n", Binary2Str(p.sec).c_str())
using std::string;
namespace APCore
{
// class EfuseCommand
EfuseCommand::EfuseCommand(
APKey key,
EfuseSetting *p)
: ICommand(key),
p_setting_(p),
read_only_(false),
stb_lock_enable_(false),
stb_key_enable_(false)
{
}
EfuseCommand::~EfuseCommand()
{
}
void EfuseCommand::exec(
const QSharedPointer<Connection> &conn)
{
Q_ASSERT(p_setting_ != NULL);
Connect(conn.data());
if(!read_only_)
WriteAll(conn.data());
ReadAll(conn.data());
}
void EfuseCommand::Connect(Connection *conn)
{
conn->ConnectBROM();
IniItem item("option.ini", "BLOWN", "brom");
bool brom_blown = item.GetBooleanValue();
switch (conn->boot_result().m_bbchip_type)
{
case MT6573:
case MT6575:
case MT6577:
case MT6589:
break;
case MT8135:
TryConnectDA(conn);
break;
default:
if(!brom_blown){
conn->ConnectDA();
}
break;
}
}
void EfuseCommand::TryConnectDA(Connection *conn)
{
if (GET_DA_HANDLE_T(conn->ap_key()) != NULL &&
GET_DL_HANDLE_T(conn->ap_key()) != NULL)
{
conn->ConnectDA();
}
}
void EfuseCommand::WriteAll(Connection *conn)
{
DumpSetting();
LOGI("Writing Efuse registers...");
int ret = FlashTool_WriteEfuseAll_Ex(
conn->FTHandle(),
p_setting_->CommonArg(),
p_setting_->SecureArg(),
p_setting_->LockArg(),
p_setting_->StbKeyArg(),
p_setting_->extraArg());
if (S_DONE != ret)
{
LOGI("Write Efuse registers failed: %s",
StatusToString(ret));
THROW_APP_EXCEPTION(ret, "");
}
else
{
LOGI("Efuse registers written successfully");
}
}
void EfuseCommand::ReadAll(Connection *conn)
{
string rb_file = p_setting_->ReadbackFile();
if (!rb_file.empty())
{
Efuse_Common_Arg common_arg;// = { 0 };
memset(&common_arg, 0, sizeof(common_arg));
Efuse_Secure_Arg secure_arg;// = { 0 };
memset(&secure_arg, 0, sizeof(secure_arg));
Efuse_Lock_Arg lock_arg;// = { 0 };
memset(&lock_arg, 0, sizeof(lock_arg));
Efuse_STB_Key_Arg stb_arg;// = { 0 };
memset(&stb_arg, 0, sizeof(stb_arg));
Efuse_Extra_Arg extra_arg;// = { 0 };
memset(&extra_arg, 0, sizeof(extra_arg));
char spare_buf[64] = { 0 };
char ackey_buf[16] = { 0 };
char sbcpk_buf[32] = { 0 };
char sbcpk1_buf[32] = { 0 };
char stbkey_bufs[EFUSE_STK_KEY_NUMBER][32] = {{0}};
char stbkey_names[EFUSE_STK_KEY_NUMBER][64] = {{0}};
common_arg.spare.buf = spare_buf;
common_arg.spare.buf_len = sizeof(spare_buf);
secure_arg.ac_key.buf = ackey_buf;
secure_arg.ac_key.buf_len = sizeof(ackey_buf);
secure_arg.sbc_pub_key_hash.buf = sbcpk_buf;
secure_arg.sbc_pub_key_hash.buf_len = sizeof(sbcpk_buf);
secure_arg.sbc_pub_key_hash1.buf = sbcpk1_buf;
secure_arg.sbc_pub_key_hash1.buf_len = sizeof(sbcpk1_buf);
char extra_bufs[END_KEY][64] = {{0}};
for(int i = 0; i < EFUSE_STK_KEY_NUMBER; i++)
{
stb_arg.stb_blow_keys[i].key_name = stbkey_names[i];
stb_arg.stb_blow_keys[i].stb_key.buf = stbkey_bufs[i];
stb_arg.stb_blow_keys[i].stb_key.buf_len = sizeof(stbkey_bufs[i]);
}
for(int i = 0; i < END_KEY; i++)
{
extra_arg.items[i].data.key_pair.key.buf = extra_bufs[i];
}
LOGI("Reading Efuse registers...");
int ret = FlashTool_ReadEfuseAll_Ex(
conn->FTHandle(),
&common_arg,
&secure_arg,
&lock_arg,
&stb_arg,
&extra_arg);
if (S_DONE != ret)
{
LOGI("Read Efuse registers failed: %s",
StatusToString(ret));
THROW_APP_EXCEPTION(ret, "");
}
else
{
LOGI("Efuse registers read successfully");
DumpResult(rb_file,
&common_arg,
&secure_arg,
&lock_arg,
&stb_arg,
&extra_arg);
}
LOGI("Efuse Dump done");
}
}
string EfuseCommand::Binary2Str(
const _BUFFER &ref)
{
string str;
char tmp[16];
for (U32 i=0; i<ref.buf_len; i+=sizeof(U32))
{
sprintf(tmp, "%08X ", *(U32*)(ref.buf+i));
str += tmp;
}
return str;
}
void EfuseCommand::DumpCommonArg(
const Efuse_Common_Arg *common,
bool to_write /*= true*/)
{
LOGI("========== Efuse Common Setting ==========");
DumpEfuseOpt(common, emmc_boot_dis);
DumpEfuseOpt(common, nand_boot_dis);
DumpEfuseOpt(common, nand_boot_speedup_dis);
DumpEfuseOpt(common, pid_vid_custom_en);
DumpEfuseOpt(common, ufs_boot_dis);
DumpEfuseOpt(common, sbc_pub_hash_dis);
DumpEfuseOpt(common, sbc_pub_hash1_dis);
if (to_write)
{
DumpEfuseOpt(common, spare_blow);
}
if (common->spare.buf_len > 0)
{
if (to_write)
DumpText(common, spare);
else
DumpBinary(common, spare);
}
DumpInteger(common, usbdl_type);
if (to_write)
{
DumpEfuseOpt(common, usb_id_blow);
}
if (common->usb_id_blow == EFUSE_ENABLE || !to_write)
{
DumpShortHex(common, usb_pid);
DumpShortHex(common, usb_vid);
}
}
void EfuseCommand::DumpSecureArg(
const Efuse_Secure_Arg *secure,
bool to_write /*= true*/)
{
LOGI("========== Efuse Secure Setting ==========");
DumpEfuseOpt(secure, acc_en);
DumpEfuseOpt(secure, sbc_en);
DumpEfuseOpt(secure, daa_en);
DumpEfuseOpt(secure, sla_en);
DumpEfuseOpt(secure, ack_en);
DumpEfuseOpt(secure, jtag_dis);
DumpEfuseOpt(secure, jtag_sw_con);
DumpEfuseOpt(secure, dbgport_lock_dis);
DumpEfuseOpt(secure, md1_sbc_en);
DumpEfuseOpt(secure, c2k_sbc_en);
DumpEfuseOpt(secure, pl_ar_en);
DumpEfuseOpt(secure, pk_cus_en);
if (to_write)
{
DumpEfuseOpt(secure, ac_key_blow);
}
if(secure->ac_key.buf_len > 0)
{
if (to_write)
DumpText(secure, ac_key);
else
DumpBinary(secure, ac_key);
}
if (to_write)
{
DumpEfuseOpt(secure, sbc_pubk_blow);
if(secure->_sbc_key_E.buf_len > 0)
{
LOGI("sbc_public_key_e = %s",
secure->_sbc_key_E.buf);
}
if(secure->_sbc_key_N.buf_len > 0)
{
LOGI("sbc_public_key_n = %s",
secure->_sbc_key_N.buf);
}
}
else if (secure->sbc_pub_key_hash.buf_len > 0)
{
DumpBinary(secure, sbc_pub_key_hash);
}
if (to_write)
{
DumpEfuseOpt(secure, sbc_pubk1_blow);
if(secure->_sbc_key1_E.buf_len > 0)
{
LOGI("sbc_public_key1_e = %s",
secure->_sbc_key1_E.buf);
}
if(secure->_sbc_key1_N.buf_len > 0)
{
LOGI("sbc_public_key1_n = %s",
secure->_sbc_key1_N.buf);
}
}
else if (secure->sbc_pub_key_hash1.buf_len > 0)
{
DumpBinary(secure, sbc_pub_key_hash1);
}
}
void EfuseCommand::DumpLockArg(
const Efuse_Lock_Arg *lock)
{
LOGI("========== Efuse Lock Setting ==========");
DumpEfuseOpt(lock, common_ctrl_lock);
DumpEfuseOpt(lock, usb_id_lock);
DumpEfuseOpt(lock, spare_lock);
DumpEfuseOpt(lock, sec_ctrl_lock);
DumpEfuseOpt(lock, ackey_lock);
DumpEfuseOpt(lock, sbc_pubk_hash_lock);
DumpEfuseOpt(lock, sec_msc_lock);
DumpEfuseOpt(lock, custk_lock);
DumpEfuseOpt(lock, sbc_pubk_hash1_lock);
}
void EfuseCommand::DumpSTBLockArg(const STB_Lock_PARAM *stb_lock)
{
LOGI("========== Efuse STB Lock Setting ==========");
DumpEfuseOpt(stb_lock, stb_key_g7_lock);
DumpEfuseOpt(stb_lock, stb_key_g6_lock);
DumpEfuseOpt(stb_lock, stb_key_g5_lock);
DumpEfuseOpt(stb_lock, stb_key_g4_lock);
DumpEfuseOpt(stb_lock, stb_key_g3_lock);
DumpEfuseOpt(stb_lock, stb_key_g2_lock);
DumpEfuseOpt(stb_lock, stb_key_g1_lock);
DumpEfuseOpt(stb_lock, stb_key_g0_lock);
DumpEfuseOpt(stb_lock, stb_key_operatorid_lock);
DumpEfuseOpt(stb_lock, stb_key_chipid_lock);
DumpEfuseOpt(stb_lock, stb_key_sn_lock);
}
void EfuseCommand::DumpSTBArg(const Efuse_STB_Key_Arg *stb,
bool to_write)
{
if(stb_lock_enable_)
DumpSTBLockArg(&stb->stb_lock);
if(!stb_key_enable_)
return;
LOGI("========== Efuse STB Key Setting ==========");
if (to_write)
{
DumpEfuseOpt(stb, stb_key_chipid_blow);
}
if (stb->stb_key_chipid_blow == EFUSE_ENABLE || !to_write)
{
DumpShortHex(stb, stb_key_chipID);
}
if(to_write)
{
DumpEfuseOpt(stb, stb_key_operatorid_blow);
}
if(stb->stb_key_operatorid_blow == EFUSE_ENABLE || !to_write)
{
DumpShortHex(stb, stb_key_operatorid);
}
for(int i = 0; i < 16; i++)
{
if (to_write)
{
DumpEfuseSTBOpt(stb->stb_blow_keys[i], key_blow);
}
if(stb->stb_blow_keys[i].stb_key.buf_len > 0 &&
stb->stb_blow_keys[i].key_name != NULL &&
strlen(stb->stb_blow_keys[i].key_name) > 0)
{
DumpSTBKeyName(stb->stb_blow_keys[i], key_name);
if (to_write)
DumpSTBText(stb->stb_blow_keys[i], stb_key);
else
DumpSTBBinary(stb->stb_blow_keys[i], stb_key);
}
}
}
#define KeyToString(key) EfuseExtraKeyToString(key)
void EfuseCommand::DumpExtraArg(const Efuse_Extra_Arg *extra,
bool to_write)
{
LOGI("========== Efuse Extra Setting ==========");
for(int i = 0; i < END_KEY; i++)
{
std::string key = KeyToString((EFUSE_KEY)extra->items[i].key);
switch(extra->items[i].type)
{
case T_BOOLEAN:
DumpEfuseOptEx(extra->items[i], data.enable, key);
break;
case T_INT:
DumpIntHexEx(extra->items[i], data.iPair.value, key);
break;
case T_BUF:
if(extra->items[i].data.key_pair.key.buf_len > 0)
{
if(to_write)
DumpTextEx(extra->items[i], data.key_pair.key, key);
else
DumpBinaryEx(extra->items[i], data.key_pair.key, key);
}
break;
}
}
}
void EfuseCommand::DumpSetting()
{
DumpCommonArg(p_setting_->CommonArg());
DumpSecureArg(p_setting_->SecureArg());
DumpLockArg(p_setting_->LockArg());
DumpSTBArg(p_setting_->StbKeyArg());
DumpExtraArg(p_setting_->extraArg());
}
void EfuseCommand::DumpResult(
const std::string &rb_file,
const Efuse_Common_Arg *common,
const Efuse_Secure_Arg *secure,
const Efuse_Lock_Arg *lock,
const Efuse_STB_Key_Arg *stb,
const Efuse_Extra_Arg *extra)
{
FILE *fp = fopen(rb_file.c_str(), "wb");
if (NULL == fp)
{
LOGE("Failed to open file: %s",
rb_file.c_str());
}
else
{
SaveCommonArg(fp, common);
SaveSecureArgR(fp, secure);
SaveLockArg(fp, lock);
SaveStbArg(fp, stb);
SaveExtraArg(fp, extra);
fclose(fp);
}
DumpCommonArg(common, false);
DumpSecureArg(secure, false);
DumpLockArg(lock);
DumpSTBArg(stb, false);
DumpExtraArg(extra, false);
}
void EfuseCommand::SaveCommonArg(
FILE *rb_file,
const Efuse_Common_Arg *common)
{
fprintf(rb_file,
"========== Efuse Common Setting ==========\r\n");
SaveEfuseOpt(rb_file, common, emmc_boot_dis);
SaveEfuseOpt(rb_file, common, nand_boot_dis);
SaveEfuseOpt(rb_file, common, nand_boot_speedup_dis);
SaveEfuseOpt(rb_file, common, pid_vid_custom_en);
SaveEfuseOpt(rb_file, common, sbc_pub_hash_dis);
SaveEfuseOpt(rb_file, common, sbc_pub_hash1_dis);
if (common->spare.buf_len > 0)
{
SaveBinary(rb_file, common, spare);
}
SaveInteger(rb_file, common, usbdl_type);
if (common->usb_id_blow == EFUSE_ENABLE)
{
SaveShortHex(rb_file, common, usb_pid);
SaveShortHex(rb_file, common, usb_vid);
}
fprintf(rb_file, "\r\n");
}
void EfuseCommand::SaveSecureArgR(
FILE *rb_file,
const Efuse_Secure_Arg *secure)
{
fprintf(rb_file,
"========== Efuse Secure Setting ==========\r\n");
SaveEfuseOpt(rb_file, secure, acc_en);
SaveEfuseOpt(rb_file, secure, sbc_en);
SaveEfuseOpt(rb_file, secure, daa_en);
SaveEfuseOpt(rb_file, secure, sla_en);
SaveEfuseOpt(rb_file, secure, ack_en);
SaveEfuseOpt(rb_file, secure, jtag_dis);
SaveEfuseOpt(rb_file, secure, jtag_sw_con);
SaveEfuseOpt(rb_file, secure, rom_cmd_dis);
SaveEfuseOpt(rb_file, secure, dbgport_lock_dis);
SaveEfuseOpt(rb_file, secure, md1_sbc_en);
SaveEfuseOpt(rb_file, secure, c2k_sbc_en);
SaveEfuseOpt(rb_file, secure, pl_ar_en);
SaveEfuseOpt(rb_file, secure, pk_cus_en);
if (secure->ac_key.buf_len > 0)
{
SaveBinary(rb_file, secure, ac_key);
}
if (secure->sbc_pub_key_hash.buf_len > 0)
{
SaveBinary(rb_file, secure, sbc_pub_key_hash);
}
if (secure->sbc_pub_key_hash1.buf_len > 0)
{
SaveBinary(rb_file, secure, sbc_pub_key_hash1);
}
fprintf(rb_file, "\r\n");
}
void EfuseCommand::SaveLockArg(
FILE *rb_file,
const Efuse_Lock_Arg *lock)
{
fprintf(rb_file,
"========== Efuse Lock Setting ==========\r\n");
SaveEfuseOpt(rb_file, lock, common_ctrl_lock);
SaveEfuseOpt(rb_file, lock, usb_id_lock);
SaveEfuseOpt(rb_file, lock, spare_lock);
SaveEfuseOpt(rb_file, lock, sec_ctrl_lock);
SaveEfuseOpt(rb_file, lock, ackey_lock);
SaveEfuseOpt(rb_file, lock, sbc_pubk_hash_lock);
SaveEfuseOpt(rb_file, lock, sec_msc_lock);
SaveEfuseOpt(rb_file, lock, custk_lock);
SaveEfuseOpt(rb_file, lock, sbc_pubk_hash1_lock);
fprintf(rb_file, "\r\n");
}
void EfuseCommand::SaveStbArg(FILE *rb_file,
const Efuse_STB_Key_Arg *stb)
{
if(stb_lock_enable_)
SaveSTBKeyLockArg(rb_file, &stb->stb_lock);
if(!stb_key_enable_)
return;
fprintf(rb_file,
"========== Efuse STB Key Setting ==========\r\n");
if (stb->stb_key_chipid_blow == EFUSE_ENABLE)
{
SaveShortHex(rb_file, stb, stb_key_chipID);
}
if(stb->stb_key_operatorid_blow == EFUSE_ENABLE)
{
SaveShortHex(rb_file, stb, stb_key_operatorid);
}
for(int i = 0; i < 16; i++)
{
if(stb->stb_blow_keys[i].stb_key.buf_len > 0 &&
stb->stb_blow_keys[i].key_name != NULL &&
strlen(stb->stb_blow_keys[i].key_name) > 0)
{
SaveSTBKeyName(rb_file, stb->stb_blow_keys[i], key_name);
SaveSTBBinary(rb_file, stb->stb_blow_keys[i], stb_key);
}
}
fprintf(rb_file, "\r\n");
}
void EfuseCommand::SaveSTBKeyLockArg(FILE *rb_file,
const STB_Lock_PARAM *stb_lock)
{
fprintf(rb_file,
"========== Efuse STB Key Lock Setting ==========\r\n");
SaveEfuseOpt(rb_file, stb_lock, stb_key_g7_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_g6_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_g5_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_g4_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_g3_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_g2_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_g1_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_g0_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_operatorid_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_chipid_lock);
SaveEfuseOpt(rb_file, stb_lock, stb_key_sn_lock);
fprintf(rb_file, "\r\n");
}
void EfuseCommand::SaveExtraArg(FILE *rb_file,
const Efuse_Extra_Arg *extra)
{
fprintf(rb_file,
"==========Efuse Extra Setting =======\r\n");
for(int i = 0; i < END_KEY; i++)
{
std::string key = KeyToString((EFUSE_KEY)extra->items[i].key);
switch(extra->items[i].type)
{
case T_BOOLEAN:
SaveEfuseOptEx(rb_file, extra->items[i], data.enable, key);
break;
case T_INT:
SaveIntegerEx(rb_file, extra->items[i], data.iPair.value, key);
break;
case T_BUF:
if(extra->items[i].data.key_pair.key.buf_len > 0)
{
SaveBinaryEx(rb_file, extra->items[i], data.key_pair.key, key);
}
break;
}
}
fprintf(rb_file, "\r\n");
}
} /*namespace APCore*/
| eret1k/SP-Flash-Tool-src | Cmd/EfuseCommand.cpp | C++ | gpl-3.0 | 19,960 |