text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<title>R: Color Schemes for Dichromats</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />

 Color Schemes for Dichromats

Documentation for package ‘dichromat’ version 2.0-0

DESCRIPTION file.

Help Pages

colorschemes
Color Schemes

dalton
Effects of Daltonism (Red-Green Color Blindness)

dalton.colors
Effects of Daltonism (Red-Green Color Blindness)

dichromat
Remove Red-Green or Green-Blue Contrasts from Colors


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

namespace School
{
    public class Course
    {
        private const int MAX_NUMBER_OF_STUDENTS = 30;

        private ICollection<Student> students;

        public Course()
        {
            this.Students = new List<Student>();
        }

        public Course(ICollection<Student> students)
        {
            this.Students = students;
        }

        public ICollection<Student> Students
        {
            get
            {
                return this.students;
            }
            set
            {
                if (value.Count >= MAX_NUMBER_OF_STUDENTS)
                {
                    throw new ArgumentOutOfRangeException(string.Format("The number of students in course must be less than {0}!", MAX_NUMBER_OF_STUDENTS));
                }

                this.students = value;
            }
        }

        public void AddStudent(Student student)
        {
            if (this.Students.Count >= MAX_NUMBER_OF_STUDENTS)
            {
                throw new ArgumentOutOfRangeException(string.Format("The number of students in course must be less than {0}!", MAX_NUMBER_OF_STUDENTS));
            }

            this.Students.Add(student);
        }

        public void RemoveStudent(Student student)
        {
            if (!this.Students.Contains(student))
            {
                throw new ArgumentException("There is no such student!");
            }

            this.Students.Remove(student);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package cn.com.aqiuqiu.commons.utils;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Random;

import javax.imageio.ImageIO;

/**
 * 工具类,生成验证码图片
 * @author Helen.z
 *
 */
public class SecurityImage {

    /**
     * 生成验证码图片
     * @param securityCode   验证码字符
     * @return  BufferedImage  图片
     */
    public static BufferedImage createImage(String securityCode){

        //验证码长度
        int codeLength=securityCode.length();
        //字体大小
        int fSize = 15;
        int fWidth = fSize + 1;
        //图片宽度
        int width = codeLength * fWidth + 6 ;
        //图片高度
        int height = fSize * 2 + 1;

        //图片
        BufferedImage image=new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g=image.createGraphics();

        //设置背景色
        g.setColor(Color.WHITE);
        //填充背景
        g.fillRect(0, 0, width, height);

        //设置边框颜色
        g.setColor(Color.LIGHT_GRAY);
        //边框字体样式
        g.setFont(new Font("Arial", Font.BOLD, height - 2));
        //绘制边框
        g.drawRect(0, 0, width - 1, height -1);

        //绘制噪点
        Random rand = new Random();
        //设置噪点颜色
        g.setColor(Color.LIGHT_GRAY);
        for(int i = 0;i < codeLength * 6;i++){
            int x = rand.nextInt(width);
            int y = rand.nextInt(height);
            //绘制1*1大小的矩形
            g.drawRect(x, y, 1, 1);
        }
        for (int i = 0; i < codeLength; i++) {
            // 设置随机颜色
            g.setColor(getRandomColor());
            // 随机画线
            g.drawLine(rand.nextInt(width), rand.nextInt(height),
            		 rand.nextInt(width), rand.nextInt(height));
        }
        //绘制验证码
        int codeY = height - 10;
        //设置字体颜色和样式
        g.setColor(new Color(19,148,246));
        g.setFont(new Font("Georgia", Font.BOLD, fSize));
        for(int i = 0; i < codeLength;i++){
            g.drawString(String.valueOf(securityCode.charAt(i)), i * 16 + 5, codeY);
        }
        //关闭资源
        g.dispose();

        return image;
    }

    /**
     * 随机取色
     */
    public static Color getRandomColor() {
        Random ran = new Random();
        Color color = new Color(ran.nextInt(256),
                ran.nextInt(256), ran.nextInt(256));
        return color;
    }
    /**
     * 返回验证码图片的流格式
     * @param securityCode  验证码
     * @return ByteArrayInputStream 图片流
     */
    public static ByteArrayInputStream getImageAsInputStream(String securityCode){

        BufferedImage image = createImage(securityCode);
        return convertImageToStream(image);
    }

    /**
     * 将BufferedImage转换成ByteArrayInputStream
     * @param image  图片
     * @return ByteArrayInputStream 流
     */
	private static ByteArrayInputStream convertImageToStream(BufferedImage image){

        ByteArrayInputStream inputStream = null;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            ImageIO.write(image,"JPEG",bos);
            byte[] bts = bos.toByteArray();
            inputStream = new ByteArrayInputStream(bts);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return inputStream;
    }

}


text:
module.exports = {
  get: require('./get')
}


text:
**Table of Contents**  *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [camunda BPM example: Task Name Beautifier](#camunda-bpm-example-task-name-beautifier)
	- [What does it demonstrate?](#what-does-it-demonstrate)
	- [Technical environment](#technical-environment)
	- [Remarks to run this application](#remarks-to-run-this-application)
	- [Introduction](#introduction)
	- [Example Process](#example-process)
	- [Task Listener](#task-listener)
	- [Adding the Task Listener to all User Tasks of all Processes](#adding-the-task-listener-to-all-user-tasks-of-all-processes)
	- [Usage with camunda BPM platform](#usage-with-camunda-bpm-platform)
	- [Installation on JBoss AS 7](#installation-on-jboss-as-7)
		- [1. Switch Process Engine Configuration in JBoss AS 7](#1-switch-process-engine-configuration-in-jboss-as-7)
		- [2. Task Name Beautifier as a JBoss Module](#2-task-name-beautifier-as-a-jboss-module)
	- [Source Code Location](#source-code-location)
	- [Steps to run the showcase](#steps-to-run-the-showcase)
	- [Known Issues](#known-issues)
	- [Improvements Backlog](#improvements-backlog)

## What does it demonstrate?
- How to dynamically modify a task during its creation in a task list
- How to add an [execution listener or task listener](http://docs.camunda.org/api-references/bpmn20/#!/concepts/listeners) globally to all processes
- How to customize the process engine configuration inside the [camunda BPM platform](http://camunda.org)

## Technical environment
- [camunda BPM platform](http://camunda.org) (tested on JBoss AS 7)

## Remarks to run this application
This demo must be manually "installed" on your [camunda BPM platform](http://camunda.org)
depending on the application server you use.
See below for instructions on how to do it with JBoss AS7.

Alternatively, you can run the unit tests in the following package in Eclipse:

    org.camunda.bpm.example.task_name_beautifier.nonarquillian

## Introduction
This demo shows how to dynamically modify the names of human tasks, during their creation in a task list.
Therefore, a [TaskListener](http://docs.camunda.org/api-references/bpmn20/#!/concepts/listeners)
is added to all [BPMN User Tasks](http://docs.camunda.org/api-references/bpmn20/#!/tasks/user-task)
by a [BpmnParseListener](https://app.camunda.com/confluence/display/foxUserGuide/Add+your+own+BpmnParseListener),
which is added to the process engine configuration of the [camunda BPM platform](http://camunda.org).

## Example Process
The example process shown below contains a user task with a very long name. For better readability, the modeler of this process decided to add a hyphen to the task name. However, this hyphen is then also shown later in the task list of the users of this process, e.g., an entry like 'Task with terri-  bly long name'.

![BPMN Process containing a User Task with a very long name](https://raw.github.com/camunda/camunda-consulting/master/snippets/task-name-beautifier/src/test/resources/process.png)

## Task Listener
In order to make this a little more beautiful, you can implement a
[TaskListener](http://docs.camunda.org/api-references/bpmn20/#!/concepts/listeners)
that changes the name of the task as it is created in the task list:
```java
public class TaskNameBeautifier implements TaskListener {

  @Override
  public void notify(DelegateTask task) {
    String name = task.getName();
    String beautifiedName = beautifyTaskName(name);
    task.setName(beautifiedName);
  }

  public String beautifyTaskName(String name) {
    String beautifiedName = name.replaceAll("(\\w)-\\s*([a-z])", "$1$2");
    return beautifiedName;
  }

}
```

...and add it to that user task:
```xml
<bpmn2:userTask id="UserTask_1" name="Task with terri- bly long name">
  <bpmn2:extensionElements>
    <camunda:taskListener class="org.camunda.bpm.example.task_name_beautifier.TaskNameBeautifier" event="create"/>
  </bpmn2:extensionElements>
</bpmn2:userTask>
```

## Adding the Task Listener to all User Tasks of all Processes
Doing this additional configuration for all user tasks that have a long name
is a rather cumbersome solution.
In addition to that, any process application that wants to use it,
needs to include the TaskListener class in its WAR or EAR.

Hence, it would be nice to add this Task Listener to all user tasks in a more central location. The camunda engine allows that through a so called [BpmnParseListener](https://app.camunda.com/confluence/display/foxUserGuide/Add+your+own+BpmnParseListener):
```java
public class TaskNameBeautifierBpmnParseListener extends AbstractBpmnParseListener {

  @Override
  public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
    ActivityBehavior behavior = activity.getActivityBehavior();
    if (behavior instanceof UserTaskActivityBehavior) {
      ((UserTaskActivityBehavior) behavior).getTaskDefinition()
          .addTaskListener(TaskListener.EVENTNAME_CREATE,  new ClassDelegate(TaskNameBeautifier.class, null));
    }
  }

}
```

...which can be added to a standalone process engine configuration
([camunda.cfg.xml](https://raw.github.com/camunda/camunda-consulting/master/snippets/task-name-beautifier/src/test/resources/camunda.cfg.xml))
like that:
```xml
  <bean id="processEngineConfiguration"
    class="org.camunda.bpm.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
    <property name="customPostBPMNParseListeners">
      <list>
        <bean class="org.camunda.bpm.example.task_name_beautifier.TaskNameBeautifierBpmnParseListener" />
      </list>
    </property>
  </bean>
```

## Usage with camunda BPM platform

In the camunda BPM platform the process engine configuration can be extended programmatically:
```java
public class TaskNameBeautifierProcessEngineConfiguration
        extends ManagedJtaProcessEngineConfiguration {

	@Override
	protected void init() {
		initCustomPostParseListener();
		super.init();
	}

	protected void initCustomPostParseListener() {
		// normally no parse listeners should be set, so create an own list for it
		if (getCustomPostBPMNParseListeners() == null) {
			setCustomPostBPMNParseListeners(new ArrayList<BpmnParseListener>());
		}

		// add parse listener
		getCustomPostBPMNParseListeners().add(new TaskNameBeautifierBpmnParseListener());

	}

}
```

## Installation on JBoss AS 7

### 1. Switch Process Engine Configuration in JBoss AS 7
Place the [JAR file with the configuration and parse listener class](https://raw.github.com/camunda/camunda-consulting/master/snippets/task-name-beautifier/task-name-beautifier.jar)
in the directory `$JBOSS_HOME/modules/org/camunda/bpm/jboss/camunda-jboss-subsystem/main`.
Add a dependency to the JAR file in
`$JBOSS_HOME/modules/org/camunda/bpm/jboss/camunda-jboss-subsystem/main/module.xml`
so that the [camunda BPM platform](http://camunda.org)
can find the alternative `ProcessEngineConfiguration` provided by the module:
```xml
  <resources>
    <resource-root path="camunda-jboss-subsystem-7.0.0-Final.jar" />
    <resource-root path="task-name-beautifier.jar" />
  </resources>
```

Please, remember that you have to repeat this step when you upgrade your server to a newer version of camunda BPM.

To enable the configuration class,
add it to the process engine parameters in your standalone.xml or domain.xml:
```xml
    <subsystem xmlns="urn:org.camunda.bpm.jboss:1.1">
        <process-engines>
            <process-engine name="default" default="true">
                <configuration>
                    org.camunda.bpm.example.task_name_beautifier.TaskNameBeautifierProcessEngineConfiguration
                </configuration>
                ...
            </process-engine>
            ...
        </process-engines>
        ...
    </subsystem>
```

### 2. Task Name Beautifier as a JBoss Module
Since the Task Listener is added to all processes,
it needs to be in the classpath of all applications.
This can be achieved by creating a global JBoss module.
For that you create a folder `$JBOSS_HOME/modules/org/camunda/bpm/task-name-beautifier/main/`
and in there a file called
[module.xml](https://raw.github.com/camunda/camunda-consulting/master/snippets/task-name-beautifier/src/test/resources/module.xml)
with the following contents:
```xml
<module xmlns="urn:jboss:module:1.0" name="org.camunda.bpm.task-name-beautifier">
  <resources>
    <resource-root path="task-name-beautifier.jar" />
  </resources>

  <dependencies>
    <module name="org.camunda.bpm.camunda-engine" />
  </dependencies>
</module>
```
Place the [JAR file with the task listener class](https://raw.github.com/camunda/camunda-consulting/master/snippets/task-name-beautifier/task-name-beautifier.jar) next to it.

Finally, you can add the TaskListener to the classpath of all applications
by adding a global dependeny in your standalone.xml or domain.xml:
```xml
    <subsystem xmlns="urn:jboss:domain:ee:1.1">
        <global-modules>
            <module name="org.camunda.bpm.task-name-beautifier" slot="main"/>
            ...
        </global-modules>
        ...
    </subsystem>
```

## Source Code Location
- [GitHub](https://github.com/camunda/camunda-consulting/tree/master/snippets/task-name-beautifier)
- [Download Source Code as ZIP](https://github.com/camunda/camunda-consulting/archive/master.zip)
- Pre-built JAR: [task-name-beautifier.jar](https://raw.github.com/camunda/camunda-consulting/master/snippets/task-name-beautifier/task-name-beautifier.jar)
- JBoss	AS7 module descriptor: [module.xml](https://raw.github.com/camunda/camunda-consulting/master/snippets/task-name-beautifier/src/test/resources/module.xml)

## Steps to run the showcase
0. [Clone the project via Git](https://github.com/camunda/camunda-consulting)
   **OR** [Download the sources as ZIP](https://github.com/camunda/camunda-consulting/archive/master.zip)
1. For an easy start, you can import the Maven project in Eclipse and run the JUnit tests in the package:

        org.camunda.bpm.example.task_name_beautifier.nonarquillian

2. For the whole show, follow these steps:
    1. [Download camunda BPM for JBoss AS7](http://www.camunda.org/download/) and [install it](http://docs.camunda.org/guides/installation-guide/jboss/)
    2. Run a Maven build in Eclipse **OR** Build with command line:

                mvn clean install

    3. Follow the instructions for installing the module in JBoss AS7 described above
    4. Start the server
    5. Run the Arquillian test case, which by default connects to a camunda BPM platform running locally on JBoss AS 7
        1. Run the class `ArquillianTest` as a JUnit test in Eclipse
        **OR** Run test with Maven on the command line using:

                mvn clean install -Parq-jbossas-remote

## Known Issues
- Currently the camunda BPM platform supports only one configuration extension. If you
  want to have other configuration changes as well, you need to put them into
  the same `ProcessEngineConfiguration` class.

## Improvements Backlog


text:
<?xml version="1.0"?>

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
	<portlet>
		<portlet-name>Projects</portlet-name>
		<display-name>Projects</display-name>
		<portlet-class>RenderParameterSenderPortlet</portlet-class>
		<init-param>
			<name>view-template</name>
			<value>/view.jsp</value>
		</init-param>
		<expiration-cache>0</expiration-cache>
		<supports>
			<mime-type>text/html</mime-type>
		</supports>
		<portlet-info>
			<title>Projects</title>
			<short-title>Projects</short-title>
			<keywords>Projects</keywords>
		</portlet-info>
		<security-role-ref>
			<role-name>administrator</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>guest</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>power-user</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>user</role-name>
		</security-role-ref>
		<supported-public-render-parameter>pname</supported-public-render-parameter>
		<supported-public-render-parameter>pid</supported-public-render-parameter>
	</portlet>
	<public-render-parameter>
		<identifier>pname</identifier>
		<qname xmlns:x="http://proliferay.com/public">x:pname</qname>
	</public-render-parameter>
	<public-render-parameter>
		<identifier>pid</identifier>
		<qname xmlns:x="http://proliferay.com/public">pid</qname>
	</public-render-parameter>
</portlet-app>


text:
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Home controller.
 *
 * @package App
 * @category Controller
 * @author Ardi Soebrata
 */
class Home extends Admin_Controller {

	public function index()
	{
		$this->template
				->set_css('timeline')
				->set_css('../bower_components/morrisjs/morris')
				->set_js('../bower_components/raphael/raphael.min', TRUE)
				->set_js('../bower_components/morrisjs/morris.min', TRUE)
				->set_js('morris-data', TRUE)
				->build('dashboard/index');
	}
}


text:
import { PureComponent } from 'react';
import classnames from 'classnames';
import { Link } from 'react-router-dom';

import type { EmptyProps } from 'types/utils';
import storage from 'storage';
import { HACKTOBERFEST } from 'storage/keys';
import { Heart } from 'react-feather';
import CloseButton from 'views/components/CloseButton';
import styles from './Announcements.scss';

type Props = EmptyProps;
type State = {
  isOpen: boolean;
};

const today = new Date();

export default class HacktoberfestBanner extends PureComponent<Props, State> {
  state: State = {
    isOpen: !storage.getItem(HACKTOBERFEST) && (today.getMonth() === 9 || today.getMonth() === 10),
  };

  dismiss = () => {
    storage.setItem(HACKTOBERFEST, true);
    this.setState({ isOpen: false });
  };

  render() {
    if (!this.state.isOpen) return null;

    return (

        <Heart className={styles.backgroundIcon} />

Hacktoberfest 2018 now open!

Improve NUSMods by writing code and get free T-shirts at the same time!

          <Link to="/hacktoberfest" className="btn btn-info">
            Find out more
          </Link>

          <CloseButton className={styles.closeButton} onClick={this.dismiss} />

    );
  }
}


text:
<?php

namespace Src\App\__projectName__\__version__\__Call\__serviceName__\Source\__bundleName__\Src\__srcName__;

use Src\App\__projectName__\__version__\__Call\__serviceName__\App;

class __className__ extends app
{

    /**
     * for bundle src service
     * get method is main run.
     * @return mixed
     */
    public function get()
    {
        //return source
        return ["__projectName__ bundle __serviceName__ __bundleName__ __srcName__"];
    }
}


text:
#include "skin_parser.hpp"
#include "../src/os_factory.hpp"
#include "interpreter.hpp"
#include <math.h>

SkinParser::SkinParser( intf_thread_t *pIntf, const string &rFileName,
                        const string &rPath, BuilderData *pData ):
    XMLParser( pIntf, rFileName ), m_path( rPath ), m_pData( pData ),
    m_ownData( pData == NULL ), m_xOffset( 0 ), m_yOffset( 0 )
{
    // Make sure the data is allocated
    if( m_pData == NULL )
    {
        m_pData = new BuilderData();
    }

    // Special id, we don't want any control to have the same one
    m_idSet.insert( "none" );
    // At the beginning, there is no Panel
    m_panelStack.push_back( "none" );
}

SkinParser::~SkinParser()
{
    if( m_ownData )
    {
        delete m_pData;
    }
}

inline bool SkinParser::MissingAttr( AttrList_t &attr, const string &name,
                                     const char *a )
{
    if( attr.find(a) == attr.end() )
    {
        msg_Err( getIntf(), "bad theme (element: %s, missing attribute: %s)",
                 name.c_str(), a );
        m_errors = true; return true;
    }
    return false;
}

void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr )
{
#define RequireAttr( attr, name, a ) \
    if( MissingAttr( attr, name, a ) ) return;

    if( rName == "Include" )
    {
        RequireAttr( attr, rName, "file" );

        OSFactory *pFactory = OSFactory::instance( getIntf() );
        string fullPath = m_path + pFactory->getDirSeparator() + attr["file"];
        msg_Dbg( getIntf(), "opening included XML file: %s", fullPath.c_str() );
        SkinParser subParser( getIntf(), fullPath.c_str(), m_path, m_pData );
        subParser.parse();
    }

    else if( rName == "IniFile" )
    {
        RequireAttr( attr, rName, "id" );
        RequireAttr( attr, rName, "file" );

        const BuilderData::IniFile iniFile( uniqueId( attr["id"] ),
                attr["file"] );
        m_pData->m_listIniFile.push_back( iniFile );
    }

    else if( rName == "Anchor" )
    {
        RequireAttr( attr, rName, "priority" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "points", "(0,0)" );
        DefaultAttr( attr, "range", "10" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        const BuilderData::Anchor anchor( x + m_xOffset,
                y + m_yOffset, attr["lefttop"],
                atoi( attr["range"] ), atoi( attr["priority"] ),
                attr["points"], m_curLayoutId );
        m_pData->m_listAnchor.push_back( anchor );
    }

    else if( rName == "Bitmap" )
    {
        RequireAttr( attr, rName, "id" );
        RequireAttr( attr, rName, "file" );
        RequireAttr( attr, rName, "alphacolor" );
        DefaultAttr( attr, "nbframes", "1" );
        DefaultAttr( attr, "fps", "4" );
        DefaultAttr( attr, "loop", "0" );

        m_curBitmapId = uniqueId( attr["id"] );
        const BuilderData::Bitmap bitmap( m_curBitmapId,
                attr["file"], convertColor( attr["alphacolor"] ),
                atoi( attr["nbframes"] ), atoi( attr["fps"] ),
                atoi( attr["loop"] ) );
        m_pData->m_listBitmap.push_back( bitmap );
    }

    else if( rName == "SubBitmap" )
    {
        RequireAttr( attr, rName, "id" );
        RequireAttr( attr, rName, "x" );
        RequireAttr( attr, rName, "y" );
        RequireAttr( attr, rName, "width" );
        RequireAttr( attr, rName, "height" );
        DefaultAttr( attr, "nbframes", "1" );
        DefaultAttr( attr, "fps", "4" );
        DefaultAttr( attr, "loop", "0" );

        const BuilderData::SubBitmap bitmap( uniqueId( attr["id"] ),
                m_curBitmapId, atoi( attr["x"] ), atoi( attr["y"] ),
                atoi( attr["width"] ), atoi( attr["height"] ),
                atoi( attr["nbframes"] ), atoi( attr["fps"] ),
                atoi( attr["loop"] ) );
        m_pData->m_listSubBitmap.push_back( bitmap );
    }

    else if( rName == "BitmapFont" )
    {
        RequireAttr( attr, rName, "id" );
        RequireAttr( attr, rName, "file" );
        DefaultAttr( attr, "type", "digits" );

        const BuilderData::BitmapFont font( uniqueId( attr["id"] ),
                attr["file"], attr["type"] );
        m_pData->m_listBitmapFont.push_back( font );
    }

    else if( rName == "PopupMenu" )
    {
        RequireAttr( attr, rName, "id" );

        m_popupPosList.push_back(0);
        m_curPopupId = uniqueId( attr["id"] );
        const BuilderData::PopupMenu popup( m_curPopupId );
        m_pData->m_listPopupMenu.push_back( popup );
    }

    else if( rName == "MenuItem" )
    {
        RequireAttr( attr, rName, "label" );
        DefaultAttr( attr, "action", "none" );

        const BuilderData::MenuItem item( attr["label"], attr["action"],
                                          m_popupPosList.back(),
                                          m_curPopupId );
        m_pData->m_listMenuItem.push_back( item );
        m_popupPosList.back()++;
    }

    else if( rName == "MenuSeparator" )
    {
        const BuilderData::MenuSeparator sep( m_popupPosList.back(),
                                              m_curPopupId );
        m_pData->m_listMenuSeparator.push_back( sep );
        m_popupPosList.back()++;
    }

    else if( rName == "Button" )
    {
        RequireAttr( attr, rName, "up" );
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "down", "none" );
        DefaultAttr( attr, "over", "none" );
        DefaultAttr( attr, "action", "none" );
        DefaultAttr( attr, "tooltiptext", "" );
        DefaultAttr( attr, "help", "" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        const BuilderData::Button button( uniqueId( attr["id"] ),
                x + m_xOffset, y + m_yOffset,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ), attr["visible"],
                attr["up"], attr["down"], attr["over"], attr["action"],
                attr["tooltiptext"], attr["help"],
                m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listButton.push_back( button );
    }

    else if( rName == "Checkbox" )
    {
        RequireAttr( attr, rName, "up1" );
        RequireAttr( attr, rName, "up2" );
        RequireAttr( attr, rName, "state" );
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "down1", "none" );
        DefaultAttr( attr, "over1", "none" );
        DefaultAttr( attr, "down2", "none" );
        DefaultAttr( attr, "over2", "none" );
        DefaultAttr( attr, "action1", "none" );
        DefaultAttr( attr, "action2", "none" );
        DefaultAttr( attr, "tooltiptext1", "" );
        DefaultAttr( attr, "tooltiptext2", "" );
        DefaultAttr( attr, "help", "" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        const BuilderData::Checkbox checkbox( uniqueId( attr["id"] ),
                x + m_xOffset, y + m_yOffset,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ), attr["visible"],
                attr["up1"], attr["down1"], attr["over1"],
                attr["up2"], attr["down2"], attr["over2"], attr["state"],
                attr["action1"], attr["action2"], attr["tooltiptext1"],
                attr["tooltiptext2"], attr["help"], m_curLayer, m_curWindowId,
                m_curLayoutId, m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listCheckbox.push_back( checkbox );
    }

    else if( rName == "Font" )
    {
        RequireAttr( attr, rName, "id" );
        RequireAttr( attr, rName, "file" );
        DefaultAttr( attr, "size", "12" );

        const BuilderData::Font fontData( uniqueId( attr["id"] ),
                attr["file"], atoi( attr["size"] ) );
        m_pData->m_listFont.push_back( fontData );
    }

    else if( rName == "Group" )
    {
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );

        m_xOffset += atoi( attr["x"] );
        m_yOffset += atoi( attr["y"] );
        m_xOffsetList.push_back( atoi( attr["x"] ) );
        m_yOffsetList.push_back( atoi( attr["y"] ) );
    }

    else if( rName == "Image" )
    {
        RequireAttr( attr, rName, "image" );
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "width", "-1" );
        DefaultAttr( attr, "height", "-1" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "action", "none" );
        DefaultAttr( attr, "action2", "none" );
        DefaultAttr( attr, "resize", "mosaic" );
        DefaultAttr( attr, "help", "" );
        DefaultAttr( attr, "art", "false" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        int width = getDimension( attr["width"], refWidth );
        int height = getDimension( attr["height"], refHeight );
        const BuilderData::Image imageData( uniqueId( attr["id"] ),
                x + m_xOffset, y + m_yOffset, width, height,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ), attr["visible"],
                attr["image"], attr["action"], attr["action2"], attr["resize"],
                attr["help"], convertBoolean( attr["art"] ),
                m_curLayer, m_curWindowId, m_curLayoutId,
                m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listImage.push_back( imageData );
    }

    else if( rName == "Layout" )
    {
        RequireAttr( attr, rName, "width" );
        RequireAttr( attr, rName, "height" );
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "minwidth", "-1" );
        DefaultAttr( attr, "maxwidth", "-1" );
        DefaultAttr( attr, "minheight", "-1" );
        DefaultAttr( attr, "maxheight", "-1" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, true );
        int width = getDimension( attr["width"], refWidth );
        int height = getDimension( attr["height"], refHeight );

        m_curLayoutId = uniqueId( attr["id"] );
        const BuilderData::Layout layout( m_curLayoutId,
                width, height,
                getDimension( attr["minwidth"], refWidth ),
                getDimension( attr["maxwidth"], refWidth ),
                getDimension( attr["minheight"], refHeight ),
                getDimension( attr["maxheight"], refHeight ),
                m_curWindowId );

        updateWindowPos( width, height );
        m_pData->m_listLayout.push_back( layout );
        m_curLayer = 0;
    }

    else if( rName == "Panel" )
    {
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        RequireAttr( attr, rName, "width" );
        RequireAttr( attr, rName, "height" );
        DefaultAttr( attr, "position", "-1" );
        DefaultAttr( attr, "xoffset", "0" );
        DefaultAttr( attr, "yoffset", "0" );
        DefaultAttr( attr, "xmargin", "0" );
        DefaultAttr( attr, "ymargin", "0" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        int width = getDimension( attr["width"], refWidth );
        int height = getDimension( attr["height"], refHeight );
        convertPosition( attr["position"],
                         attr["xoffset"], attr["yoffset"],
                         attr["xmargin"], attr["ymargin"],
                         width, height, refWidth, refHeight, &x, &y );

        string panelId = uniqueId( "none" );
        const BuilderData::Panel panel( panelId,
                x + m_xOffset, y + m_yOffset,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ),
                width, height,
                m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listPanel.push_back( panel );
        // Add the panel to the stack
        m_panelStack.push_back( panelId );
    }

    else if( rName == "Playlist" )
    {
        RequireAttr( attr, rName, "id" );
        RequireAttr( attr, rName, "font" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "flat", "true" ); // Only difference here
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "width", "0" );
        DefaultAttr( attr, "height", "0" );
        DefaultAttr( attr, "position", "-1" );
        DefaultAttr( attr, "xoffset", "0" );
        DefaultAttr( attr, "yoffset", "0" );
        DefaultAttr( attr, "xmargin", "0" );
        DefaultAttr( attr, "ymargin", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "bgimage", "none" );
        DefaultAttr( attr, "itemimage", "none" );
        DefaultAttr( attr, "openimage", "none" );
        DefaultAttr( attr, "closedimage", "none" );
        DefaultAttr( attr, "fgcolor", "#000000" );
        DefaultAttr( attr, "playcolor", "#FF0000" );
        DefaultAttr( attr, "bgcolor1", "#FFFFFF" );
        DefaultAttr( attr, "bgcolor2", "#FFFFFF" );
        DefaultAttr( attr, "selcolor", "#0000FF" );
        DefaultAttr( attr, "help", "" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        int width = getDimension( attr["width"], refWidth );
        int height = getDimension( attr["height"], refHeight );
        convertPosition( attr["position"],
                         attr["xoffset"], attr["yoffset"],
                         attr["xmargin"], attr["ymargin"],
                         width, height, refWidth, refHeight, &x, &y );

        m_curTreeId = uniqueId( attr["id"] );
        const BuilderData::Tree treeData( m_curTreeId,
                x + m_xOffset, y + m_yOffset, attr["visible"],
                attr["flat"],
                width, height,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ),
                attr["font"], "playtree",
                attr["bgimage"], attr["itemimage"],
                attr["openimage"], attr["closedimage"],
                attr["fgcolor"],
                attr["playcolor"],
                attr["bgcolor1"],
                attr["bgcolor2"],
                attr["selcolor"], attr["help"],
                m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listTree.push_back( treeData );
    }
    else if( rName == "Playtree" )
    {
        RequireAttr( attr, rName, "id" );
        RequireAttr( attr, rName, "font" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "flat", "false" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "width", "0" );
        DefaultAttr( attr, "height", "0" );
        DefaultAttr( attr, "position", "-1" );
        DefaultAttr( attr, "xoffset", "0" );
        DefaultAttr( attr, "yoffset", "0" );
        DefaultAttr( attr, "xmargin", "0" );
        DefaultAttr( attr, "ymargin", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "bgimage", "none" );
        DefaultAttr( attr, "itemimage", "none" );
        DefaultAttr( attr, "openimage", "none" );
        DefaultAttr( attr, "closedimage", "none" );
        DefaultAttr( attr, "fgcolor", "#000000" );
        DefaultAttr( attr, "playcolor", "#FF0000" );
        DefaultAttr( attr, "bgcolor1", "#FFFFFF" );
        DefaultAttr( attr, "bgcolor2", "#FFFFFF" );
        DefaultAttr( attr, "selcolor", "#0000FF" );
        DefaultAttr( attr, "help", "" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        int width = getDimension( attr["width"], refWidth );
        int height = getDimension( attr["height"], refHeight );
        convertPosition( attr["position"],
                         attr["xoffset"], attr["yoffset"],
                         attr["xmargin"], attr["ymargin"],
                         width, height, refWidth, refHeight, &x, &y );

        m_curTreeId = uniqueId( attr["id"] );
        const BuilderData::Tree treeData( m_curTreeId,
                x + m_xOffset, y + m_yOffset, attr["visible"],
                attr["flat"],
                width, height,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ),
                attr["font"], "playtree",
                attr["bgimage"], attr["itemimage"],
                attr["openimage"], attr["closedimage"],
                attr["fgcolor"], attr["playcolor"],
                attr["bgcolor1"], attr["bgcolor2"],
                attr["selcolor"], attr["help"],
                m_curLayer, m_curWindowId, m_curLayoutId, m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listTree.push_back( treeData );
    }

    else if( rName == "RadialSlider" )
    {
        RequireAttr( attr, rName, "sequence" );
        RequireAttr( attr, rName, "nbimages" );
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "minangle", "0" );
        DefaultAttr( attr, "maxangle", "360" );
        DefaultAttr( attr, "value", "none" );
        DefaultAttr( attr, "tooltiptext", "" );
        DefaultAttr( attr, "help", "" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        const BuilderData::RadialSlider radial( uniqueId( attr["id"] ),
                attr["visible"],
                x + m_xOffset, y + m_yOffset,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ), attr["sequence"],
                atoi( attr["nbimages"] ), atof( attr["minangle"] ) * M_PI /180,
                atof( attr["maxangle"] ) * M_PI / 180, attr["value"],
                attr["tooltiptext"], attr["help"], m_curLayer, m_curWindowId,
                m_curLayoutId, m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listRadialSlider.push_back( radial );
    }

    else if( rName == "Slider" )
    {
        RequireAttr( attr, rName, "up" );
        RequireAttr( attr, rName, "points" );
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "width", "-1" );
        DefaultAttr( attr, "height", "-1" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "down", "none" );
        DefaultAttr( attr, "over", "none" );
        DefaultAttr( attr, "thickness", "10" );
        DefaultAttr( attr, "value", "none" );
        DefaultAttr( attr, "tooltiptext", "" );
        DefaultAttr( attr, "help", "" );

        string newValue = attr["value"];
        if( m_curTreeId != "" )
        {
            // Slider associated to a tree
            newValue = "playtree.slider";
        }

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        int width = getDimension( attr["width"], refWidth );
        int height = getDimension( attr["height"], refHeight );
        const BuilderData::Slider slider( uniqueId( attr["id"] ),
                attr["visible"], x + m_xOffset, y + m_yOffset,
                width, height, attr["lefttop"],
                attr["rightbottom"], convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ), attr["up"], attr["down"],
                attr["over"], attr["points"], atoi( attr["thickness"] ),
                newValue, "none", 0, 0, 0, 0, attr["tooltiptext"],
                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId,
                m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listSlider.push_back( slider );
    }

    else if( rName == "SliderBackground" )
    {
        RequireAttr( attr, rName, "image" );
        DefaultAttr( attr, "nbhoriz", "1" );
        DefaultAttr( attr, "nbvert", "1" );
        DefaultAttr( attr, "padhoriz", "0" );
        DefaultAttr( attr, "padvert", "0" );

        // Retrieve the current slider data
        BuilderData::Slider &slider = m_pData->m_listSlider.back();

        slider.m_imageId = attr["image"];
        slider.m_nbHoriz = atoi( attr["nbhoriz"] );
        slider.m_nbVert = atoi( attr["nbvert"] );
        slider.m_padHoriz = atoi( attr["padhoriz"] );
        slider.m_padVert = atoi( attr["padvert"] );
    }

    else if( rName == "Text" )
    {
        RequireAttr( attr, rName, "font" );
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "text", "" );
        DefaultAttr( attr, "color", "#000000" );
        DefaultAttr( attr, "scrolling", "auto" );
        DefaultAttr( attr, "alignment", "left" );
        DefaultAttr( attr, "focus", "true" );
        DefaultAttr( attr, "width", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "help", "" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        int width = getDimension( attr["width"], refWidth );

        const BuilderData::Text textData( uniqueId( attr["id"] ),
                x + m_xOffset, y + m_yOffset,
                attr["visible"], attr["font"],
                attr["text"],
                width,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ),
                convertColor( attr["color"] ),
                attr["scrolling"], attr["alignment"],
                attr["focus"], attr["help"],
                m_curLayer, m_curWindowId, m_curLayoutId,
                m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listText.push_back( textData );
    }

    else if( rName == "Theme" )
    {
        RequireAttr( attr, rName, "version" );
        DefaultAttr( attr, "tooltipfont", "defaultfont" );
        DefaultAttr( attr, "magnet", "15" );
        DefaultAttr( attr, "alpha", "255" );
        DefaultAttr( attr, "movealpha", "255" );

        // Check the version
        if( strcmp( attr["version"], SKINS_DTD_VERSION ) )
        {
            msg_Err( getIntf(), "bad theme version : %s (you need version %s)",
                     attr["version"], SKINS_DTD_VERSION );
            m_errors = true;
            return;
        }
        const BuilderData::Theme theme( attr["tooltipfont"],
                atoi( attr["magnet"] ),
                convertInRange( attr["alpha"], 1, 255, "alpha" ),
                convertInRange( attr["movealpha"], 1, 255, "movealpha" ) );
        m_pData->m_listTheme.push_back( theme );
    }

    else if( rName == "ThemeInfo" )
    {
        DefaultAttr( attr, "name", "" );
        DefaultAttr( attr, "author", "" );
        DefaultAttr( attr, "email", "" );
        DefaultAttr( attr, "website", "" );
        msg_Info( getIntf(), "skin: %s  author: %s", attr["name"],
                  attr["author"] );
    }

    else if( rName == "Video" )
    {
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "width", "0" );
        DefaultAttr( attr, "height", "0" );
        DefaultAttr( attr, "position", "-1" );
        DefaultAttr( attr, "xoffset", "0" );
        DefaultAttr( attr, "yoffset", "0" );
        DefaultAttr( attr, "xmargin", "0" );
        DefaultAttr( attr, "ymargin", "0" );
        DefaultAttr( attr, "lefttop", "lefttop" );
        DefaultAttr( attr, "rightbottom", "lefttop" );
        DefaultAttr( attr, "xkeepratio", "false" );
        DefaultAttr( attr, "ykeepratio", "false" );
        DefaultAttr( attr, "autoresize", "true" );
        DefaultAttr( attr, "help", "" );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, false );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        int width = getDimension( attr["width"], refWidth );
        int height = getDimension( attr["height"], refHeight );
        convertPosition( attr["position"],
                         attr["xoffset"], attr["yoffset"],
                         attr["xmargin"], attr["ymargin"],
                         width, height, refWidth, refHeight, &x, &y );

        const BuilderData::Video videoData( uniqueId( attr["id"] ),
                x + m_xOffset, y + m_yOffset, width, height,
                attr["lefttop"], attr["rightbottom"],
                convertBoolean( attr["xkeepratio"] ),
                convertBoolean( attr["ykeepratio"] ),
                attr["visible"], convertBoolean( attr["autoresize"] ),
                attr["help"], m_curLayer, m_curWindowId, m_curLayoutId,
                m_panelStack.back() );
        m_curLayer++;
        m_pData->m_listVideo.push_back( videoData );
    }

    else if( rName == "Window" )
    {
        DefaultAttr( attr, "id", "none" );
        DefaultAttr( attr, "visible", "true" );
        DefaultAttr( attr, "x", "0" );
        DefaultAttr( attr, "y", "0" );
        DefaultAttr( attr, "position", "-1" );
        DefaultAttr( attr, "xoffset", "0" );
        DefaultAttr( attr, "yoffset", "0" );
        DefaultAttr( attr, "xmargin", "0" );
        DefaultAttr( attr, "ymargin", "0" );
        DefaultAttr( attr, "dragdrop", "true" );
        DefaultAttr( attr, "playondrop", "true" );

        m_curWindowId = uniqueId( attr["id"] );

        int refWidth, refHeight;
        getRefDimensions( refWidth, refHeight, true );
        int x = getDimension( attr["x"], refWidth );
        int y = getDimension( attr["y"], refHeight );
        const BuilderData::Window window( m_curWindowId,
                x + m_xOffset, y + m_yOffset,
                attr["position"],
                attr["xoffset"], attr["yoffset"],
                attr["xmargin"], attr["ymargin"],
                convertBoolean( attr["visible"] ),
                convertBoolean( attr["dragdrop"] ),
                convertBoolean( attr["playondrop"] ) );
        m_pData->m_listWindow.push_back( window );
    }
#undef  RequireAttr
}

void SkinParser::handleEndElement( const string &rName )
{
    if( rName == "Group" )
    {
        m_xOffset -= m_xOffsetList.back();
        m_yOffset -= m_yOffsetList.back();
        m_xOffsetList.pop_back();
        m_yOffsetList.pop_back();
    }
    else if( rName == "Playtree" || rName == "Playlist" )
    {
        m_curTreeId = "";
    }
    else if( rName == "Popup" )
    {
        m_curPopupId = "";
        m_popupPosList.pop_back();
    }
    else if( rName == "Panel" )
    {
        m_panelStack.pop_back();
    }
}

bool SkinParser::convertBoolean( const char *value ) const
{
    return strcmp( value, "true" ) == 0;
}

int SkinParser::convertColor( const char *transcolor )
{
    // TODO: move to the builder
    unsigned long iRed, iGreen, iBlue;
    iRed = iGreen = iBlue = 0;
    sscanf( transcolor, "#%2lX%2lX%2lX", &iRed, &iGreen, &iBlue );
    return ( iRed << 16 | iGreen << 8 | iBlue );
}

int SkinParser::convertInRange( const char *value, int minValue, int maxValue,
                                const string &rAttribute ) const
{
    int intValue = atoi( value );

    if( intValue < minValue )
    {
        msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the "
                  "expected range [%i, %i], using %i instead",
                  rAttribute.c_str(), intValue, minValue, maxValue, minValue );
        return minValue;
    }
    else if( intValue > maxValue )
    {
        msg_Warn( getIntf(), "value of \"%s\" attribute (%i) is out of the "
                  "expected range [%i, %i], using %i instead",
                  rAttribute.c_str(), intValue, minValue, maxValue, maxValue );
        return maxValue;
    }
    else
    {
        return intValue;
    }
}

const string SkinParser::generateId() const
{
    static int i = 1;

    char genId[5];
    snprintf( genId, 4, "%i", i++ );

    string base = "_ReservedId_" + (string)genId;

    return base;
}

const string SkinParser::uniqueId( const string &id )
{
    string newId;

    if( m_idSet.find( id ) != m_idSet.end() )
    {
        // The id was already used
        if( id != "none" )
        {
            msg_Warn( getIntf(), "non-unique id: %s", id.c_str() );
        }
        newId = generateId();
    }
    else
    {
        // OK, this is a new id
        newId = id;
    }

    // Add the id to the set
    m_idSet.insert( newId );

    return newId;
}

void SkinParser::getRefDimensions( int &rWidth, int &rHeight, bool toScreen )
{
    if( toScreen )
    {
        OSFactory *pOsFactory = OSFactory::instance( getIntf() );
        rWidth = pOsFactory->getScreenWidth();
        rHeight = pOsFactory->getScreenHeight();
        return;
    }

    string panelId = m_panelStack.back();
    if( panelId != "none" )
    {
        list<BuilderData::Panel>::const_iterator it;
        for( it = m_pData->m_listPanel.begin();
             it != m_pData->m_listPanel.end(); ++it )
        {
            if( it->m_id == panelId )
            {
                rWidth = it->m_width;
                rHeight = it->m_height;
                return;
            }
        }
    }
    else
    {
        const BuilderData::Layout layout = m_pData->m_listLayout.back();
        rWidth = layout.m_width;
        rHeight = layout.m_height;
        return;
    }
    msg_Err( getIntf(), "failure to retrieve parent panel or layout" );
}

int SkinParser::getDimension( string value, int refDimension )
{
    string::size_type leftPos;

    leftPos = value.find( "%" );
    if( leftPos != string::npos )
    {
        int val = atoi( value.substr( 0, leftPos ).c_str() );
        return  val * refDimension / 100;
    }

    leftPos = value.find( "px" );
    if( leftPos != string::npos )
    {
        int val = atoi( value.substr( 0, leftPos ).c_str() );
        return val;
    }

    return atoi( value.c_str() );
}

int SkinParser::getPosition( string position )
{
    if( position == "-1" )
        return POS_UNDEF;
    else if( position == "Center" )
        return POS_CENTER;
    else if( position == "North" )
        return POS_TOP;
    else if( position == "South" )
        return POS_BOTTOM;
    else if( position == "West" )
        return POS_LEFT;
    else if( position == "East" )
        return POS_RIGHT;
    else if( position == "NorthWest" )
        return POS_TOP | POS_LEFT;
    else if( position == "NorthEast" )
        return POS_TOP | POS_RIGHT;
    else if( position == "SouthWest" )
        return POS_BOTTOM | POS_LEFT;
    else if( position == "SouthEast" )
        return POS_BOTTOM | POS_RIGHT;

    msg_Err( getIntf(), "unknown value '%s' for position",
                          position.c_str() );
    return POS_UNDEF;
}

void SkinParser::convertPosition( string position, string xOffset,
                          string yOffset, string xMargin,
                          string yMargin, int width, int height,
                          int refWidth, int refHeight, int* p_x, int* p_y )
{
    int iPosition = getPosition( position );
    if( iPosition != POS_UNDEF )
    {
        // compute offset against the parent object size
        // for backward compatibility
        int i_xOffset = getDimension( xOffset, refWidth );
        int i_yOffset = getDimension( yOffset, refHeight );
        int i_xMargin = getDimension( xMargin, refWidth );
        int i_yMargin = getDimension( yMargin, refHeight );

        // compute *p_x
        if( iPosition & POS_LEFT )
            *p_x = i_xMargin;
        else if( iPosition & POS_RIGHT )
            *p_x = refWidth - width - i_xMargin;
        else
            *p_x = ( refWidth - width ) / 2;

        // compute *p_y
        if( iPosition & POS_TOP )
            *p_y = i_yMargin;
        else if( iPosition & POS_BOTTOM )
            *p_y = refHeight - height - i_yMargin;
        else
            *p_y = ( refHeight - height ) / 2;

        // add offset
        *p_x += i_xOffset;
        *p_y += i_yOffset;
    }
    else
    {
        // compute offset against the current object size
        int i_xOffset = getDimension( xOffset, width );
        int i_yOffset = getDimension( yOffset, height );

        // add offset
        *p_x += i_xOffset;
        *p_y += i_yOffset;
    }
}

void SkinParser::updateWindowPos( int width, int height )
{
    BuilderData::Window win = m_pData->m_listWindow.back();
    m_pData->m_listWindow.pop_back();

    int refWidth, refHeight;
    getRefDimensions( refWidth, refHeight, true );
    convertPosition( win.m_position,
                     win.m_xOffset, win.m_yOffset,
                     win.m_xMargin, win.m_yMargin,
                     width, height, refWidth, refHeight,
                     &win.m_xPos, &win.m_yPos );

    m_pData->m_listWindow.push_back( win );
}


text:
#include "UnrealCVPrivate.h"
#include "ExecStatus.h"

/** Begin of FPromise functions */

FExecStatus FPromise::CheckStatus()
{
	check(this);
	check(PromiseDelegate.IsBound());
	return PromiseDelegate.Execute();
}

/** Begin of FExecStatus functions */
bool operator==(const FExecStatus& ExecStatus, const FExecStatusType& ExecStatusType)
{
	return (ExecStatus.ExecStatusType == ExecStatusType);
}

bool operator!=(const FExecStatus& ExecStatus, const FExecStatusType& ExecStatusType)
{
	return (ExecStatus.ExecStatusType != ExecStatusType);
}

FExecStatus& FExecStatus::operator+=(const FExecStatus& Src)
{
	this->BinaryData += Src.BinaryData;
	this->MessageBody += "\n" + Src.MessageBody;
	return *this;
}

// DECLARE_DELEGATE_OneParam(FDispatcherDelegate, const TArray< FString >&);
FExecStatus FExecStatus::InvalidArgument = FExecStatus(FExecStatusType::Error, "Argument Invalid");

FPromise& FExecStatus::GetPromise()
{
	check(this->ExecStatusType == FExecStatusType::AsyncQuery);
	// Check should be in a single line, make it easier to read and debug
	// The promise is set only when the operation is async and ExecStatus is pending
	return this->Promise;
}

FExecStatus FExecStatus::OK(FString InMessage)
{
	return FExecStatus(FExecStatusType::OK, InMessage);
}

FExecStatus FExecStatus::Pending(FString InMessage)
{
	return FExecStatus(FExecStatusType::Pending, InMessage);
}

FExecStatus FExecStatus::AsyncQuery(FPromise InPromise)
{
	return FExecStatus(FExecStatusType::AsyncQuery, InPromise);
}

FExecStatus FExecStatus::Error(FString ErrorMessage)
{
	return FExecStatus(FExecStatusType::Error, ErrorMessage);
}

FString FExecStatus::GetMessage() const // Define how to format the reply string
{
	FString TypeName;
	switch (ExecStatusType)
	{
	case FExecStatusType::OK:
		if (MessageBody == "")
			return "ok";
		else
			return MessageBody;
	case FExecStatusType::Error:
		TypeName = "error"; break;
	case FExecStatusType::AsyncQuery:
		TypeName = "async"; break;
	case FExecStatusType::Pending:
		TypeName = "pending"; break;
	default:
		TypeName = "unknown FExecStatus Type";
	}
	FString Message = FString::Printf(TEXT("%s %s"), *TypeName, *MessageBody);
	return Message;
}

FExecStatus::FExecStatus(FExecStatusType InExecStatusType, FPromise InPromise)
{
	ExecStatusType = InExecStatusType;
	Promise = InPromise;
}

FExecStatus::FExecStatus(FExecStatusType InExecStatusType, FString InMessage)
{
	ExecStatusType = InExecStatusType;
	MessageBody = InMessage;
}

FExecStatus::~FExecStatus()
{
}

FExecStatus FExecStatus::Binary(TArray<uint8>& BinaryData)
{
	return FExecStatus(FExecStatusType::OK, BinaryData);
}

FExecStatus::FExecStatus(FExecStatusType InExecStatusType, TArray<uint8>& InBinaryData)
{
	ExecStatusType = InExecStatusType;
	BinaryData = InBinaryData;
}

TArray<uint8> FExecStatus::GetData() const // Define how to format the reply string
{
	if (this->BinaryData.Num() != 0)
	{
		return BinaryData;
	}
	FString TypeName;
	FString Message;
	switch (ExecStatusType)
	{
	case FExecStatusType::OK:
		if (MessageBody == "")
			Message = "ok";
		else
			Message = MessageBody;
	case FExecStatusType::Error:
		TypeName = "error"; break;
	case FExecStatusType::AsyncQuery:
		TypeName = "async"; break;
	case FExecStatusType::Pending:
		TypeName = "pending"; break;
	default:
		TypeName = "unknown FExecStatus Type";
	}
	if (ExecStatusType != FExecStatusType::OK)
	{
		Message = FString::Printf(TEXT("%s %s"), *TypeName, *MessageBody);
	}
	TArray<uint8> FormatedBinaryData;
	BinaryArrayFromString(Message, FormatedBinaryData);

	return FormatedBinaryData;
}

void FExecStatus::BinaryArrayFromString(const FString& Message, TArray<uint8>& OutBinaryArray)
{
	FTCHARToUTF8 Convert(*Message);
	OutBinaryArray.Empty();
	OutBinaryArray.Append((UTF8CHAR*)Convert.Get(), Convert.Length());
}


text:
<!DOCTYPE html>

  <link href="http://gmpg.org/xfn/11" rel="profile">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

  <title>

      404: Page not found · Discretos

  </title>

  <link rel="stylesheet" href="/public/css/poole.css">
  <link rel="stylesheet" href="/public/css/syntax.css">
  <link rel="stylesheet" href="/public/css/hyde.css">
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface">

  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/public/apple-touch-icon-144-precomposed.png">
                                 <link rel="shortcut icon" href="/public/favicon.ico">

  <link rel="alternate" type="application/rss+xml" title="RSS" href="/atom.xml">

          Discretos

Discretamente...

      Início

            Sobre

            Downloads

            Membros

            Projectos

© 2015. Todos os direitos reservados.

404: Page not found

Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. Head back home to try finding it again.


text:
use std::marker::PhantomData;
use gl;
use gl::types::*;
use types::GLObject;

/// An OpenGL buffer object.
///
/// In OpenGL, a buffer is essentially untyped, and what data it can contain
/// only depends on how it is used. A buffer can be used to store vertices,
/// indices, or essentially any other data that the graphics device needs
/// to process.
///
/// A buffer will automatically be deleted after going out of scope.
///
/// # See also
/// [`gl.gen_buffer`](../context/buffer_context/trait.ContextBufferExt.html#method.gen_buffer) -
/// Create a new, empty buffer.
///
/// [`VertexBuffer`](../vertex_buffer/struct.VertexBuffer.html) and [`IndexBuffer`]
/// (vertex_buffer/struct.IndexBuffer.html): Wrapper types over raw buffers
/// that are more suitable for buffering vertex and index data, respectively.
///
/// [`gl.bind_array_buffer`](../context/buffer_context/trait.ArrayBufferContext.html#method.bind_array_buffer):
/// and [`gl.bind_element_array_buffer`](../context/buffer_context/trait.ElementArrayBufferContext.html#tymethod.split_element_array_buffer):
/// Bind a buffer to a target, returning a buffer binding type.
pub struct Buffer {
    gl_id: GLuint,
    _phantom: PhantomData<*mut ()>
}

impl Drop for Buffer {
    fn drop(&mut self) {
        unsafe {
            gl::DeleteBuffers(1, &self.gl_id as *const GLuint);
        }
    }
}

impl GLObject for Buffer {
    type Id = GLuint;

    unsafe fn from_raw(id: Self::Id) -> Self {
        Buffer {
            gl_id: id,
            _phantom: PhantomData
        }
    }

    fn id(&self) -> Self::Id {
        self.gl_id
    }
}

gl_enum! {
    /// Provides a hint to the OpenGL driver for how a buffer will be used.
    pub gl_enum BufferDataUsage {
        /// Indicates that a buffer will be set once and drawn
        /// only a few times.
        pub const StreamDraw as STREAM_DRAW = gl::STREAM_DRAW,

        /// Indicates that a buffer will be set once and drawn many times
        pub const StaticDraw as STATIC_DRAW = gl::STATIC_DRAW,

        /// Indicates that a buffer will be set and modified repeatedly
        /// and drawn many times.
        pub const DynamicDraw as DYNAMIC_DRAW = gl::DYNAMIC_DRAW
    }
}

gl_enum! {
    /// All of the possible OpenGL targets for binding a buffer object.
    pub gl_enum BufferBindingTarget {
        /// The array buffer object binding.
        pub const ArrayBuffer as ARRAY_BUFFER =
            gl::ARRAY_BUFFER,

        /// The element array buffer object binding.
        pub const ElementArrayBuffer as ELEMENT_ARRAY_BUFFER =
            gl::ELEMENT_ARRAY_BUFFER
    }
}


text:
package net.venaglia.nondairy.soylang.parser;

import net.venaglia.nondairy.SoyTestUtil;
import org.junit.Assert;

/**
 * Created by IntelliJ IDEA.
 * User: ed
 * Date: Aug 15, 2010
 * Time: 8:05:31 PM
 */
@SuppressWarnings({ "HardCodedStringLiteral" })
public class MockParseMetaToken {

    public static final EventDelegate ASSERT_NO_ERRORS = new EventDelegate() {
        public void event(Object value, MockTokenSource mockTokenSource) {
            if (value instanceof MockParseMetaToken && "error".equals(((MockParseMetaToken)value).name)) {
                Assert.fail("A parse error was recorded: " + value + " at " + mockTokenSource);
            }
        }
    };

    private final String name;
    private final String value;
    private final String where;

    public MockParseMetaToken(String name, MockTokenSource source) {
        this(name, null, source);
    }

    public MockParseMetaToken(String name, String value, MockTokenSource source) {
        this.name = name;
        this.value = value;
        this.where = source == null ? null : source.toString();
    }

    public String getName() {
        return name;
    }

    public String getValue() {
        return value;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MockParseMetaToken that = (MockParseMetaToken)o;

        if (value != null ? !value.equals(that.value) : that.value != null) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (value != null ? value.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        StringBuilder buffer = new StringBuilder();
        buffer.append('[');
        buffer.append(name);
        if (value != null) {
            buffer.append(':');
            buffer.append(SoyTestUtil.toSource(value));
        }
        if (where != null) {
            buffer.append(':');
            buffer.append(where);
        }
        buffer.append(']');
        return buffer.toString();
    }
}


text:
import React from 'react';
import { shallow } from 'enzyme';
import sinon from 'sinon';

import { createReduxStore } from 'test/store';
import { shallowUntilTarget } from 'test/utils';

import { actions } from '..';

import PluralSelector, { PluralSelectorBase } from './PluralSelector';

function createShallowPluralSelector(plural, locale) {
    return shallow(<PluralSelectorBase pluralForm={plural} locale={locale} />);
}

describe('<PluralSelectorBase>', () => {
    it('returns null when the locale is missing', () => {
        const wrapper = createShallowPluralSelector(0, null);
        expect(wrapper.type()).toBeNull();
    });

    it('returns null when the locale has only one plural form', () => {
        const wrapper = createShallowPluralSelector(0, { cldrPlurals: [5] });
        expect(wrapper.type()).toBeNull();
    });

    it('returns null when the selected plural form is -1', () => {
        // If pluralForm is -1, it means the entity has no plural string.
        const wrapper = createShallowPluralSelector(-1, {
            cldrPlurals: [1, 5],
        });
        expect(wrapper.type()).toBeNull();
    });

    it('shows the correct list of plural choices for locale with 2 forms', () => {
        const wrapper = createShallowPluralSelector(0, { cldrPlurals: [1, 5] });

        expect(wrapper.find('li')).toHaveLength(2);
        expect(wrapper.find('ul').text()).toEqual('one1other2');
    });

    it('shows the correct list of plural choices for locale with all 6 forms', () => {
        const wrapper = createShallowPluralSelector(0, {
            cldrPlurals: [0, 1, 2, 3, 4, 5],
            // This is the pluralRule for Arabic.
            pluralRule:
                '(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5)',
        });

        expect(wrapper.find('li')).toHaveLength(6);
        expect(wrapper.find('ul').text()).toEqual(
            'zero0one1two2few3many11other100',
        );
    });

    it('marks the right choice as active', () => {
        const wrapper = createShallowPluralSelector(1, { cldrPlurals: [1, 5] });

        expect(wrapper.find('li.active').text()).toEqual('other2');
    });
});

describe('<PluralSelector>', () => {
    it('selects the correct form when clicking a choice', () => {
        const initialState = {
            plural: {
                pluralForm: 1,
            },
            locale: {
                code: 'kg',
                cldrPlurals: [1, 5],
            },
            router: {
                location: {
                    pathname: '/kg/pro/all/',
                    search: '?string=42',
                },
            },
        };
        const store = createReduxStore(initialState);
        const dispatchSpy = sinon.spy(store, 'dispatch');

        const wrapper = shallowUntilTarget(
            <PluralSelector store={store} />,
            PluralSelectorBase,
        );

        wrapper.find('button').first().simulate('click');

        const expectedAction = actions.select(0);
        expect(dispatchSpy.calledWith(expectedAction)).toBeTruthy();
    });
});


text:
package com.amazonaws.services.dynamodbv2.datamodeling;

import java.util.Map;

import org.junit.Test;

import com.amazonaws.services.dynamodbv2.model.AttributeValue;

/**
 * Verify that we fail fast in case of incompatible subclasses that try to
 * override the (now-removed) transformAttributes method.
 */
public class IncompatibleSubclassTest {

    @Test
    public void testCompatibleSubclass() {
        // Doesn't try to override one of the deprecated/removed
        // transformAttributes methods; should be fine.
        new CompatibleDynamoDBMapper();
    }

    @Test(expected = IllegalStateException.class)
    public void testIncompatibleSubclass1() {
        // "Overrides" transformAttributes(Class, Map); should fail fast.
        new IncompatibleDynamoDBMapper1();
    }

    @Test(expected = IllegalStateException.class)
    public void testIncompatibleSubclass2() {
        // "Overrides" transformAttributes(String, String, Map); should fail
        // fast.
        new IncompatibleDynamoDBMapper2();
    }

    private static class CompatibleDynamoDBMapper extends DynamoDBMapper {

        public CompatibleDynamoDBMapper() {
            super(null);
        }

        protected void transformAttributes(boolean innocuous) {
        }
    }

    private static class IncompatibleDynamoDBMapper1 extends DynamoDBMapper {

        public IncompatibleDynamoDBMapper1() {
            super(null);
        }

        protected Map<String, AttributeValue> transformAttributes(
                Class<?> clazz,
                Map<String, AttributeValue> attributeValues) {

            return null;
        }
    }

    private static class IncompatibleDynamoDBMapper2 extends DynamoDBMapper {

        public IncompatibleDynamoDBMapper2() {
            super(null);
        }

        protected Map<String, AttributeValue> transformAttributes(
                String hashKey,
                String rangeKey,
                Map<String, AttributeValue> attributeValues) {

            return null;
        }
    }
}


text:
import logging

import pytest

from virtool.mongo.connect import check_mongo_version

@pytest.mark.parametrize("version", ["3.5.9", "3.6.0", "3.6.1"])
async def test_check_mongo_version(mongo, caplog, mocker, version):
    mocker.patch("virtool.mongo.connect.get_mongo_version", return_value=version)

    caplog.set_level(logging.INFO)

    try:
        await check_mongo_version(mongo)

        assert caplog.messages[0] == f"Found MongoDB {version}"
    except SystemExit as e:
        assert e.code == 1


text:
package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao;

import com.google.common.base.Strings;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.alarm.AlarmRecord;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.config.ConfigService;
import org.apache.skywalking.oap.server.core.query.enumeration.Scope;
import org.apache.skywalking.oap.server.core.query.type.AlarmMessage;
import org.apache.skywalking.oap.server.core.query.type.Alarms;
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;

public class H2AlarmQueryDAO implements IAlarmQueryDAO {

    private JDBCHikariCPClient client;

    private final ModuleManager manager;
    private final int maxSizeOfArrayColumn;
    private final int numOfSearchValuesPerTag;
    private List<String> searchableTagKeys;

    public H2AlarmQueryDAO(JDBCHikariCPClient client,
                           final ModuleManager manager,
                           final int maxSizeOfArrayColumn,
                           final int numOfSearchValuesPerTag) {
        this.client = client;
        this.manager = manager;
        this.maxSizeOfArrayColumn = maxSizeOfArrayColumn;
        this.numOfSearchValuesPerTag = numOfSearchValuesPerTag;
    }

    @Override
    public Alarms getAlarm(Integer scopeId, String keyword, int limit, int from, long startTB,
        long endTB, final List<Tag> tags) throws IOException {
        if (searchableTagKeys == null) {
            final ConfigService configService = manager.find(CoreModule.NAME)
                    .provider()
                    .getService(ConfigService.class);
            searchableTagKeys = Arrays.asList(configService.getSearchableAlarmTags().split(Const.COMMA));
            if (searchableTagKeys.size() > maxSizeOfArrayColumn) {
                searchableTagKeys = searchableTagKeys.subList(0, maxSizeOfArrayColumn);
            }
        }
        StringBuilder sql = new StringBuilder();
        List<Object> parameters = new ArrayList<>(10);
        sql.append("from ").append(AlarmRecord.INDEX_NAME).append(" where ");
        sql.append(" 1=1 ");
        if (Objects.nonNull(scopeId)) {
            sql.append(" and ").append(AlarmRecord.SCOPE).append(" = ?");
            parameters.add(scopeId.intValue());
        }
        if (startTB != 0 && endTB != 0) {
            sql.append(" and ").append(AlarmRecord.TIME_BUCKET).append(" >= ?");
            parameters.add(startTB);
            sql.append(" and ").append(AlarmRecord.TIME_BUCKET).append(" <= ?");
            parameters.add(endTB);
        }

        if (!Strings.isNullOrEmpty(keyword)) {
            sql.append(" and ").append(AlarmRecord.ALARM_MESSAGE).append(" like concat('%',?,'%') ");
            parameters.add(keyword);
        }
        if (CollectionUtils.isNotEmpty(tags)) {
            for (final Tag tag : tags) {
                final int foundIdx = searchableTagKeys.indexOf(tag.getKey());
                if (foundIdx > -1) {
                    sql.append(" and (");
                    for (int i = 0; i < numOfSearchValuesPerTag; i++) {
                        final String physicalColumn = AlarmRecord.TAGS + "_" + (foundIdx * numOfSearchValuesPerTag + i);
                        sql.append(physicalColumn).append(" = ? ");
                        parameters.add(tag.toString());
                        if (i != numOfSearchValuesPerTag - 1) {
                            sql.append(" or ");
                        }
                    }
                    sql.append(")");
                } else {
                    return new Alarms();
                }
            }
        }
        sql.append(" order by ").append(AlarmRecord.START_TIME).append(" desc ");

        Alarms alarms = new Alarms();
        try (Connection connection = client.getConnection()) {

            try (ResultSet resultSet = client.executeQuery(connection, buildCountStatement(sql.toString()), parameters
                .toArray(new Object[0]))) {
                while (resultSet.next()) {
                    alarms.setTotal(resultSet.getInt("total"));
                }
            }

            this.buildLimit(sql, from, limit);

            try (ResultSet resultSet = client.executeQuery(connection, "select * " + sql.toString(), parameters.toArray(new Object[0]))) {
                while (resultSet.next()) {
                    AlarmMessage message = new AlarmMessage();
                    message.setId(resultSet.getString(AlarmRecord.ID0));
                    message.setId1(resultSet.getString(AlarmRecord.ID1));
                    message.setMessage(resultSet.getString(AlarmRecord.ALARM_MESSAGE));
                    message.setStartTime(resultSet.getLong(AlarmRecord.START_TIME));
                    message.setScope(Scope.Finder.valueOf(resultSet.getInt(AlarmRecord.SCOPE)));
                    message.setScopeId(resultSet.getInt(AlarmRecord.SCOPE));
                    String dataBinaryBase64 = resultSet.getString(AlarmRecord.TAGS_RAW_DATA);
                    if (!com.google.common.base.Strings.isNullOrEmpty(dataBinaryBase64)) {
                        parserDataBinaryBase64(dataBinaryBase64, message.getTags());
                    }
                    alarms.getMsgs().add(message);
                }
            }
        } catch (SQLException e) {
            throw new IOException(e);
        }

        return alarms;
    }

    protected String buildCountStatement(String sql) {
        return "select count(1) total from (select 1 " + sql + " )";
    }

    protected void buildLimit(StringBuilder sql, int from, int limit) {
        sql.append(" LIMIT ").append(limit);
        sql.append(" OFFSET ").append(from);
    }
}


text:
using Cake.Common.Tools.GitReleaseManager.Label;

namespace Cake.Common.Tests.Fixtures.Tools.GitReleaseManager
{
    internal sealed class GitReleaseManagerLabellerFixture : GitReleaseManagerFixture<GitReleaseManagerLabelSettings>
    {
        private bool _useToken = false;

        public string UserName { get; set; }
        public string Password { get; set; }
        public string Token { get; set; }
        public string Owner { get; set; }
        public string Repository { get; set; }

        public GitReleaseManagerLabellerFixture()
        {
            UserName = "bob";
            Password = "password";
            Token = "token";
            Owner = "repoOwner";
            Repository = "repo";
        }

        public void UseToken()
        {
            _useToken = true;
        }

        protected override void RunTool()
        {
            var tool = new GitReleaseManagerLabeller(FileSystem, Environment, ProcessRunner, Tools);

            if (_useToken)
            {
                tool.Label(Token, Owner, Repository, Settings);
            }
            else
            {
                tool.Label(UserName, Password, Owner, Repository, Settings);
            }
        }
    }
}


text:
package com.riteshakya.subs.views.screens.login;

import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.common.api.GoogleApiClient;
import com.riteshakya.subs.mvp.FlowListener;
import com.riteshakya.subs.mvp.IPresenter;
import com.riteshakya.subs.mvp.IView;

import com.riteshakya.subs.mvp.FlowListener;
import com.riteshakya.subs.mvp.IPresenter;
import com.riteshakya.subs.mvp.IView;

/**
 * @author Ritesh Shakya
 */

public interface LoginPresenter extends IPresenter {

    void setView(LoginView loginView);

    void initialize();

    void validateResult(Intent data);

    GoogleApiClient getGoogleApiClient();

    interface LoginFlowListener extends FlowListener {

        void openMainActivity();
    }

    interface LoginView extends IView {
        FragmentActivity getActivity();
    }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>OR-Tools: operations_research::packing Namespace Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="navtree.css" rel="stylesheet" type="text/css"/>

<link href="search/search.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="styleSheet.tmp.css" rel="stylesheet" type="text/css"/>

OR-Tools
    9.4

Namespaces |
Classes |
Functions

operations_research::packing Namespace Reference

Namespaces

namespace  	vbp

Classes

struct  	ArcFlowGraph

class  	BinPacking2dParser

Functions

ArcFlowGraph 	BuildArcFlowGraph (const std::vector< int > &bin_dimensions, const std::vector< std::vector< int > > &item_dimensions_by_type, const std::vector< int > &demand_by_type)

vbp::VectorBinPackingSolution 	SolveVectorBinPackingWithArcFlow (const vbp::VectorBinPackingProblem &problem, MPSolver::OptimizationProblemType solver_type, const std::string &mip_params, double time_limit, int num_threads, int max_bins)

Function Documentation

◆ BuildArcFlowGraph()

          ArcFlowGraph BuildArcFlowGraph
          (
          const std::vector< int > &
          bin_dimensions,

          const std::vector< std::vector< int > > &
          item_dimensions_by_type,

          const std::vector< int > &
          demand_by_type

          )

Definition at line 402 of file arc_flow_builder.cc.

◆ SolveVectorBinPackingWithArcFlow()

          vbp::VectorBinPackingSolution SolveVectorBinPackingWithArcFlow
          (
          const vbp::VectorBinPackingProblem &
          problem,

          MPSolver::OptimizationProblemType
          solver_type,

          const std::string &
          mip_params,

          double
          time_limit,

          int
          num_threads,

          int
          max_bins

          )

Definition at line 77 of file arc_flow_solver.cc.

operations_research

packing

Generated by

     1.9.4


text:
import logging
import os.path
import tornado.ioloop
import tornado.web
from tornado.options import options, parse_config_file
from pymongo import MongoClient
from libs import vote, config

# Parse the config file
parse_config_file('settings.conf')

# Database
client = MongoClient(options.db_host, options.db_port)
db = client[options.db_name]

class MainHandler(tornado.web.RequestHandler):
  def get(self):
    contestants = db.contestants.find().sort('tickets', -1)
    counter = contestants.count()
    lastUpdate = db.info.find_one({ 'name': 'lastUpdate' })['value']
    self.render('home.html', contestants = contestants, counter = counter, lastUpdate = lastUpdate)

class VoteHandler(tornado.web.RequestHandler):
  def get(self):
    try:
      cid = self.get_argument('cid', True)
      tickets = int(self.get_argument('tickets', True))
    except:
      return

    # Between 1 ~ ???
    if tickets > 0:
      if tickets == 1:
        result = vote.vote(cid)
        self.write(result)
      else: # Maybe a big number
        vote.voteHelper(cid, tickets)
    else:
      return

config = dict(
  debug = options.debug,
  template_path = os.path.join(os.path.dirname(__file__), 'templates'),
  static_path = os.path.join(os.path.dirname(__file__), 'static'),
  gzip = options.gzip
)

application = tornado.web.Application([
  (r'/', MainHandler),
  (r'/vote', VoteHandler)
], **config)

if __name__ == '__main__':
  application.listen(options.port)
  logging.info('Starting tornado server on port %i' % options.port)
  tornado.ioloop.IOLoop.instance().start()


text:
export const SAVE_LP_DATA = 'longPollConstants/SAVE_LP_DATA';
export const UPDATE_LP_TS = 'longPollConstants/UPDATE_LP_TS';


text:
<?php

namespace Adrotec\BreezeJs\Serializer;

use JMS\Serializer\Metadata\ClassMetadata as JMSClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadata;
use JMS\Serializer\Metadata\PropertyMetadata;
use Doctrine\Common\Persistence\Proxy;
use Doctrine\ORM\Proxy\Proxy as ORMProxy;
use JMS\Serializer\Context;
use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
use Doctrine\ORM\EntityManager;
use Adrotec\BreezeJs\Serializer\Context\SaveChangesContextInterface;

class JsonSerializationVisitor extends \JMS\Serializer\JsonSerializationVisitor {

    private $entityManager;

    public function __construct(PropertyNamingStrategyInterface $namingStrategy, EntityManager $entityManager) {
        parent::__construct($namingStrategy);
        $this->entityManager = $entityManager;
    }

    public function visitProperty(PropertyMetadata $propertyMetadata, $data, Context $context) {
        $v = $propertyMetadata->getValue($data);
        $isSaveChanges = $context instanceof SaveChangesContextInterface;
        if ($this->isProxyObject($v) && ($isSaveChanges || !$v->__isInitialized())) {
            return;
        }
        if (!$propertyMetadata->reflection) {
            return;
        }
        return parent::visitProperty($propertyMetadata, $data, $context);
    }

    private function isProxyObject($object)
    {
        if ($object instanceof Proxy || $object instanceof ORMProxy) {
            return true;
        }
        return false;
    }

    public function endVisitingObject(JMSClassMetadata $metadata, $data, array $type, Context $context) {
        $rs = parent::endVisitingObject($metadata, $data, $type, $context);
        if (empty($rs)) {
            return null;
        }

        $isSaveChanges = $context instanceof SaveChangesContextInterface;
        if ($this->isProxyObject($data) && ($isSaveChanges || !$data->__isInitialized())) {
            return null;
        }

        try {
            $doctrineMeta = $this->entityManager->getClassMetadata($metadata->name);
            if ($doctrineMeta) {
                $rs['$type'] = strtr($type['name'], '\\', '.');
                foreach ($doctrineMeta->associationMappings as $associationMapping) {
                    $foreignKey = $associationMapping['fieldName'] . 'Id';
                    if(isset($rs[$foreignKey])){
                        continue;
                    }

                    $isScalar = in_array((int) $associationMapping['type'], array(ClassMetadata::ONE_TO_ONE, ClassMetadata::MANY_TO_ONE));
                    $isOwningSide = isset($associationMapping['isOwningSide']) ? $associationMapping['isOwningSide'] : false;
                    if (!($isScalar && $isOwningSide)) {
                        continue;
                    }
                    try {
                        $getter = 'get' . $associationMapping['fieldName'];
                        if (method_exists($data, $getter)) {
                            $association = $data->$getter();
                        } else {
                            $refl = new \ReflectionClass($data);
                            if ($this->isProxyObject($data)) {
                                $refl = $refl->getParentClass();
                            }
                            try {
                                $prop = $refl->getProperty($associationMapping['fieldName']);
                                $prop->setAccessible(true);
                                $association = $prop->getValue($data);
                            } catch (\ReflectionException $e) {
                            }
                        }
                        if ($association) {
                            try {
                                $id = $association->getId();
                                $rs[$foreignKey] = $id;
                            } catch (\Exception $e) {

                            }
                        }
                    } catch (\ReflectionException $e) {
//                    continue;
                    }
                }
            }
        } catch (\Exception $e) {
            return $rs;
        }

        return $rs;
    }

}


text:
---
uid: SolidEdgePart.Jog.NeutralFactor
summary:
remarks: If the UseGlobalNeutralFactor property is True, the global neutral factor is associatively applied, and this local value is ignored.
---


text:
package net.println.kt10;

/**
 * Created by luliju on 2017/7/8.
 */
public class LazyThreadSafeSynchronized {
    private static LazyThreadSafeSynchronized INSTANCE;

    private LazyThreadSafeSynchronized(){}

    public static synchronized LazyThreadSafeSynchronized getInstance(){
        if(INSTANCE == null){
            INSTANCE = new LazyThreadSafeSynchronized();
        }
        return INSTANCE;
    }
}


text:
package openperipheral.addons.glasses.utils;

public interface IRenderCommand {
	public void execute(RenderState renderState);
}


text:
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>404 | AreWePlayingYet? — A pragmatic HTML5 Audio test suite</title>
</head>
<body>
  <audio src="http://areweplayingyet.herokuapp.com/sounds/long.mp3" autoplay controls></audio>
</body>
</html>


text:
<?xml version="1.0" ?>
<!DOCTYPE FTCS SYSTEM "futuretense_cs.dtd">
<FTCS Version="1.1">
<!-- OpenMarket/Xcelerate/AssetType/HistoryVals/PostUpdate
--
-- INPUT
--
-- OUTPUT
--
-->

<callelement NAME="OpenMarket/Gator/FlexibleAssets/Common/PostUpdate"/>

</FTCS>


text:
package com.alibaba.jstorm.blobstore;

import backtype.storm.generated.SettableBlobMeta;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.regex.Matcher;

public class LocalFsBlobStoreFile extends BlobStoreFile {

    private final String _key;
    private final boolean _isTmp;
    private final File _path;
    private Long _modTime = null;
    private final boolean _mustBeNew;
    private SettableBlobMeta meta;

    public LocalFsBlobStoreFile(File base, String name) {
        if (BlobStoreFile.BLOBSTORE_DATA_FILE.equals(name)) {
            _isTmp = false;
        } else {
            Matcher m = TMP_NAME_PATTERN.matcher(name);
            if (!m.matches()) {
                throw new IllegalArgumentException("File name does not match '"+name+"' !~ "+TMP_NAME_PATTERN);
            }
            _isTmp = true;
        }
        _key = base.getName();
        _path = new File(base, name);
        _mustBeNew = false;
    }

    public LocalFsBlobStoreFile(File base, boolean isTmp, boolean mustBeNew) {
        _key = base.getName();
        _isTmp = isTmp;
        _mustBeNew = mustBeNew;
        if (_isTmp) {
            _path = new File(base, System.currentTimeMillis()+TMP_EXT);
        } else {
            _path = new File(base, BlobStoreFile.BLOBSTORE_DATA_FILE);
        }
    }

    @Override
    public void delete() throws IOException {
        _path.delete();
    }

    @Override
    public boolean isTmp() {
        return _isTmp;
    }

    @Override
    public String getKey() {
        return _key;
    }

    @Override
    public long getModTime() throws IOException {
        if (_modTime == null) {
            _modTime = _path.lastModified();
        }
        return _modTime;
    }

    @Override
    public InputStream getInputStream() throws IOException {
        if (isTmp()) {
            throw new IllegalStateException("Cannot read from a temporary part file.");
        }
        return new FileInputStream(_path);
    }

    @Override
    public OutputStream getOutputStream() throws IOException {
        if (!isTmp()) {
            throw new IllegalStateException("Can only write to a temporary part file.");
        }
        boolean success;
        try {
            success = _path.createNewFile();
        } catch (IOException e) {
            //Try to create the parent directory, may not work
            _path.getParentFile().mkdirs();
            success = _path.createNewFile();
        }
        if (!success) {
            throw new IOException(_path+" already exists");
        }
        return new FileOutputStream(_path);
    }

    @Override
    public void commit() throws IOException {
        if (!isTmp()) {
            throw new IllegalStateException("Can only write to a temporary part file.");
        }

        File dest = new File(_path.getParentFile(), BlobStoreFile.BLOBSTORE_DATA_FILE);
        if (_mustBeNew) {
            Files.move(_path.toPath(), dest.toPath(), StandardCopyOption.ATOMIC_MOVE);
        } else {
            Files.move(_path.toPath(), dest.toPath(), StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
        }
    }

    @Override
    public void cancel() throws IOException {
        if (!isTmp()) {
            throw new IllegalStateException("Can only write to a temporary part file.");
        }
        delete();
    }

    @Override
    public SettableBlobMeta getMetadata () {
        return meta;
    }

    @Override
    public void setMetadata (SettableBlobMeta meta) {
        this.meta = meta;
    }

    @Override
    public String toString() {
        return _path+":"+(_isTmp ? "tmp": BlobStoreFile.BLOBSTORE_DATA_FILE)+":"+_key;
    }

    @Override
    public long getFileLength() {
        return _path.length();
    }
}


text:
#ifndef __ASM_ARM_LOCALTIMER_H
#define __ASM_ARM_LOCALTIMER_H

#include <linux/errno.h>

struct clock_event_device;

struct local_timer_ops {
	int  (*setup)(struct clock_event_device *);
	void (*stop)(struct clock_event_device *);
};

#ifdef CONFIG_LOCAL_TIMERS
/*
 * Register a local timer driver
 */
int local_timer_register(struct local_timer_ops *);
#else
static inline int local_timer_register(struct local_timer_ops *ops)
{
	return -ENXIO;
}
#endif

#endif