text:
/*
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package dk.statsbiblioteket.summa.control.bundle;

import dk.statsbiblioteket.summa.common.configuration.Configuration;
import dk.statsbiblioteket.summa.common.rpc.RemoteHelper;
import dk.statsbiblioteket.summa.control.api.bundle.WritableBundleRepository;
import dk.statsbiblioteket.summa.control.api.bundle.rmi.RemoteRepository;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.File;
import java.io.IOException;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.List;

/**
 * A {@link dk.statsbiblioteket.summa.control.api.bundle.BundleRepository}
 * exposing an RMI interface. It wraps a child {@link URLRepository} storing
 * the bundles.
 */
public class RemoteURLRepositoryServer extends UnicastRemoteObject
                                       implements RemoteRepository,
                                                  WritableBundleRepository {
    private static final long serialVersionUID = 1683681887L;
    private static final Log log =
                             LogFactory.getLog(RemoteURLRepositoryServer.class);
    private WritableBundleRepository localRepo;

    /**
     * Configuraion property defining the port on which RMI communications
     * with this repo should proceed. The default is 27045.
     */
    public static final String CONF_SERVICE_PORT =
                                        "summa.control.repository.service.port";

    public static final int DEFAULT_SERVICE_PORT = 27045;

    /**
     * Configuraion property defining the name which the repository should
     * register itself on the RMI registry with. The default is
     * {@code remoteURLRepository}
     */
    public static final String CONF_SERVICE_NAME =
                                        "summa.control.repository.service.name";

    public static final String DEFAULT_SERVICE_NAME = "remoteURLRepository";

    /**
     * Configuraion property defining the port on which RMI registry should run
     * or can be found. The default is 27000.
     */
    public static final String CONF_REGISTRY_PORT =
                                          "summa.control.repository.registry.port";

    public static final int DEFAULT_REGISTRY_PORT = 27000;

    /**
     * Create a new {@code RemoteURLRepository}. The passed in configuration
     * will be passed unmodified to an underlying {@link LocalURLRepository}.
     *

     * The {@link #CONF_REPO_ADDRESS} will be passed down to an embedded
     *
     *
     * @param conf configuration from which to read properties. This
     *             configuration will also be passed directly to the underlying
     *             {@link URLRepository}
     * @throws IOException if there is an error exporting the remote interface
     */
    public RemoteURLRepositoryServer (Configuration conf) throws IOException {
        super (getServicePort(conf));

        log.debug ("Creating RemoteURLRepositoryServer");

        localRepo = new LocalURLRepository(conf);

        log.debug ("Exporting remote interfaces");

        BundleUtils.prepareCodeBase(conf, this,
                                    "summa-common", "summa-control-api");
        RemoteHelper.exportRemoteInterface(this,
                                           conf.getInt(CONF_REGISTRY_PORT,
                                                       DEFAULT_REGISTRY_PORT),
                                           conf.getString(CONF_SERVICE_NAME,
                                                          DEFAULT_SERVICE_NAME));
    }

    private static int getServicePort(Configuration conf) {
        return conf.getInt (CONF_SERVICE_PORT, 27045);
    }

    /**
     * Warning: This method returns the File object for the 'local' file
     * on the server side. This works if you are the Control server.
     * However the  {@link RemoteURLRepositoryClient} does not invoke
     * this method, but bypasses it with a {@link URLRepository#get}
     */
    @Override
    public File get(String bundleId) throws RemoteException {
        try {
            return localRepo.get(bundleId);
        } catch (IOException e) {
            throw new RemoteException("Error getting bundle file for '"
                                       + bundleId + "'", e);
        }
    }

    @Override
    public List<String> list(String regex) throws RemoteException {
        log.trace ("Got list() request: '" + regex + "'");
        try {
            return localRepo.list (regex);
        } catch (IOException e) {
            throw new RemoteException("Failed to list local repository: "
                                      + e.getMessage(), e);
        }
    }

     @Override
     public String expandApiUrl (String jarFileName) throws RemoteException {
        try {
            return localRepo.expandApiUrl(jarFileName);
        } catch (IOException e) {
            throw new RemoteException("Failed to expand API URL for '"
                                      + jarFileName + "'", e);
        }
    }

    // Note that this method is intentionally not exported over rmi
    // since the RemoteRepository interface does not declare it
    @Override
    public boolean installBundle(File bundle) throws IOException {
        return localRepo.installBundle(bundle);
    }

    // Note that this method is intentionally not exported over rmi
    // since the RemoteRepository interface does not declare it
    @Override
    public boolean installApi(File apiFile) throws IOException {
        return localRepo.installApi(apiFile);
    }
}


text:
.. _sockets-net-mgmt-sample:

Network Management Socket
#########################

Overview
********

The net-mgmt-socket sample application for Zephyr implements a listener
for network management events that the networking subsystem is sending.

The source code for this sample application can be found at:
:zephyr_file:`samples/net/sockets/net_mgmt`.

Requirements
************

- :ref:`networking_with_host`

Building and Running
********************

There are multiple ways to use this application. One of the most common
usage scenario is to run echo-server application inside QEMU. This is
described in :ref:`networking_with_qemu`.

Build net-mgmt socket sample application like this:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/net_mgmt
   :board: <board to use>
   :conf: <config file to use>
   :goals: build
   :compact:

Example building for the native_posix board:

.. zephyr-app-commands::
   :zephyr-app: samples/net/sockets/net_mgmt
   :host-os: unix
   :board: native_posix
   :conf: prj.conf
   :goals: run
   :compact:

redpajama_set_name: RedPajamaGithub


text:
module Imp10 where
import {-# SOURCE #-} Imp10Aux


text:
* Ideas for effective template partial specialization

## multi_vector	multi_vector
* Ideas for multi-dimensional vector
```
MultiVector4<int, 2> l24;
  l24.resize( 2 );
  l24[0] << 1 <<  2 <<  3 ;
  l24[1] << 10 <<  20 <<  30 ;
  l24[0].push_back(4);
  for( unsigned int i=0; i<l24.size(); i++ ){
    for( unsigned int j=0; j<l24[i].size(); j++ )
      cout<< l24[i][j] <<", ";
    cout<<endl;
  }
```

## safe_formater_template
* safe formater with variadic template ( replace of printf, sprintf )
```
std::string str = SafeFormatter::format(%10d",12);
```

## check_template_parameter_in_compile.cxx
* How to check values of template parameters in compile time

## pythonic_range.cxx	pythonic_range.cxx
* range function/method like python
* ```for( auto i : range( 1,3 )    ) cout<< i <<", ";cout<<endl;```

## vector_minus_index.cxx
* An index -1 for a last element of a vector like python
* ```vec[-1]```


text:
var casper = require('casper').create();

casper.start('http://casperjs.org/', function() {
    this.echo(this.getTitle());
});

casper.thenOpen('http://phantomjs.org', function() {
    this.echo(this.getTitle());
});

casper.run();


text:
#include "php.h"
#include "SAPI.h"
#include "php_main.h"

#ifdef HAVE_PHTTPD

#include "ext/standard/info.h"

#ifndef ZTS
#error PHTTPD module is only useable in thread-safe mode
#endif

#include "php_phttpd.h"

typedef struct {
    struct connectioninfo *cip;
	struct stat sb;
} phttpd_globals_struct;

static int ph_globals_id;

#define PHG(v) TSRMG(ph_globals_id, phttpd_globals_struct *, v)

static int
php_phttpd_startup(sapi_module_struct *sapi_module)
{
	fprintf(stderr,"***php_phttpd_startup\n");

    if (php_module_startup(sapi_module, NULL, 0)) {
        return FAILURE;
    } else {
        return SUCCESS;
    }
}

static int
php_phttpd_sapi_ub_write(const char *str, uint str_length TSRMLS_DC)
{
    int sent_bytes;

	sent_bytes = fd_write(PHG(cip)->fd, str, str_length);

	if (sent_bytes == -1) {
		php_handle_aborted_connection();
	}

    return sent_bytes;
}

static int
php_phttpd_sapi_header_handler(sapi_header_struct *sapi_header, sapi_headers_struct *sapi_headers TSRMLS_DC)
{
    char *header_name, *header_content;
    char *p;

	http_sendheaders(PHG(cip)->fd, PHG(cip), SG(sapi_headers).http_response_code, NULL);

    header_name = sapi_header->header;
    header_content = p = strchr(header_name, ':');

    if (p) {
        *p = '\0';
        do {
            header_content++;
        } while (*header_content == ' ');

		fd_printf(PHG(cip)->fd,"%s: %s\n", header_name, header_content);

        *p = ':';
    }

    sapi_free_header(sapi_header);

    return 0;
}

static int
php_phttpd_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
{
    if (SG(sapi_headers).send_default_content_type) {
		fd_printf(PHG(cip)->fd,"Content-Type: text/html\n");
    }

	fd_putc('\n', PHG(cip)->fd);

    return SAPI_HEADER_SENT_SUCCESSFULLY;
}

static char *
php_phttpd_sapi_read_cookies(TSRMLS_D)
{

/*
    int i;
    char *http_cookie = NULL;

    i = Ns_SetIFind(NSG(conn->headers), "cookie");
    if(i != -1) {
        http_cookie = Ns_SetValue(NSG(conn->headers), i);
    }

    return http_cookie;
*/
	fprintf(stderr,"***php_phttpd_sapi_read_cookies\n");

	return 0;
}

static int
php_phttpd_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC)
{
/*
    uint max_read;
    uint total_read = 0;

    max_read = MIN(NSG(data_avail), count_bytes);

    total_read = Ns_ConnRead(NSG(conn), buf, max_read);

    if(total_read == NS_ERROR) {
        total_read = -1;
    } else {
        NSG(data_avail) -= total_read;
    }

    return total_read;
*/
	fprintf(stderr,"***php_phttpd_sapi_read_post\n");
	return 0;
}

static sapi_module_struct phttpd_sapi_module = {
    "phttpd",
    "PHTTPD",

    php_phttpd_startup,                     /* startup */
    php_module_shutdown_wrapper,            /* shutdown */

	NULL,									/* activate */
	NULL,									/* deactivate */

    php_phttpd_sapi_ub_write,               /* unbuffered write */
	NULL,									/* flush */
	NULL,									/* get uid */
 	NULL,									/* getenv */

    php_error,                              /* error handler */

    php_phttpd_sapi_header_handler,         /* header handler */
    php_phttpd_sapi_send_headers,           /* send headers handler */
    NULL,                                   /* send header handler */

    php_phttpd_sapi_read_post,              /* read POST data */
    php_phttpd_sapi_read_cookies,           /* read Cookies */

	NULL,									/* register server variables */
	NULL,									/* Log message */
	NULL,									/* Get request time */
	NULL,									/* Child terminate */

    STANDARD_SAPI_MODULE_PROPERTIES
};

static void
php_phttpd_request_ctor(TSRMLS_D TSRMLS_DC)
{
	memset(&SG(request_info), 0, sizeof(sapi_globals_struct)); /* pfusch! */

    SG(request_info).query_string = PHG(cip)->hip->request;
    SG(request_info).request_method = PHG(cip)->hip->method;
	SG(request_info).path_translated = malloc(MAXPATHLEN);
    SG(sapi_headers).http_response_code = 200;
	if (url_expand(PHG(cip)->hip->url, SG(request_info).path_translated, MAXPATHLEN, &PHG(sb), NULL, NULL) == NULL) {
		/* handle error */
	}

#if 0
    char *server;
    Ns_DString ds;
    char *root;
    int index;
    char *tmp;

    server = Ns_ConnServer(NSG(conn));

    Ns_DStringInit(&ds);
    Ns_UrlToFile(&ds, server, NSG(conn->request->url));

    /* path_translated is the absolute path to the file */
    SG(request_info).path_translated = strdup(Ns_DStringValue(&ds));
    Ns_DStringFree(&ds);
    root = Ns_PageRoot(server);
    SG(request_info).request_uri = SG(request_info).path_translated + strlen(root);
    SG(request_info).content_length = Ns_ConnContentLength(NSG(conn));
    index = Ns_SetIFind(NSG(conn)->headers, "content-type");
    SG(request_info).content_type = index == -1 ? NULL :
        Ns_SetValue(NSG(conn)->headers, index);

    tmp = Ns_ConnAuthUser(NSG(conn));
    if(tmp) {
        tmp = estrdup(tmp);
    }
    SG(request_info).auth_user = tmp;

    tmp = Ns_ConnAuthPasswd(NSG(conn));
    if(tmp) {
        tmp = estrdup(tmp);
    }
    SG(request_info).auth_password = tmp;

    NSG(data_avail) = SG(request_info).content_length;
#endif
}

static void
php_phttpd_request_dtor(TSRMLS_D TSRMLS_DC)
{
    free(SG(request_info).path_translated);
}

int php_doit(TSRMLS_D)
{
	struct stat sb;
	zend_file_handle file_handle;
	struct httpinfo *hip = PHG(cip)->hip;

	if (php_request_startup(TSRMLS_C) == FAILURE) {
        return -1;
    }

    file_handle.type = ZEND_HANDLE_FILENAME;
    file_handle.filename = SG(request_info).path_translated;
    file_handle.free_filename = 0;

/*
	php_phttpd_hash_environment(TSRMLS_C);
*/
	php_execute_script(&file_handle TSRMLS_CC);
	php_request_shutdown(NULL);

	return SG(sapi_headers).http_response_code;
}

int pm_init(const char **argv)
{
	tsrm_startup(1, 1, 0, NULL);
	sapi_startup(&phttpd_sapi_module);
    phttpd_sapi_module.startup(&phttpd_sapi_module);

	ts_allocate_id(&ph_globals_id, sizeof(phttpd_globals_struct), NULL, NULL);

	return 0;
}

void pm_exit(void)
{
	fprintf(stderr,"***pm_exit\n");
}

int pm_request(struct connectioninfo *cip)
{
	struct httpinfo *hip = cip->hip;
	int status;
	TSRMLS_FETCH();

	if (strcasecmp(hip->method, "GET") == 0 ||
	    strcasecmp(hip->method, "HEAD") == 0 ||
	    strcasecmp(hip->method, "POST") == 0) {
		PHG(cip) = cip;

		php_phttpd_request_ctor(TSRMLS_C);
		status = php_doit(TSRMLS_C);
		php_phttpd_request_dtor(TSRMLS_C);

		return status;
	} else {
		return -2;
	}
}

#endif


text:
module.exports = function (config) {
  var webpackConfig = require('./webpack.config');
  webpackConfig.devtool = 'inline-source-map';

  config.set({
    browsers: ['PhantomJS'],
    files: [
      'node_modules/babel-polyfill/dist/polyfill.js',
      'tests.bundle.js'
    ],
    frameworks: ['chai', 'mocha', 'es5-shim'],
    plugins: [
      'karma-chrome-launcher',
      'karma-phantomjs-launcher',
      'karma-chai',
      'karma-mocha',
      'karma-es5-shim',
      'karma-sourcemap-loader',
      'karma-webpack',
    ],
    // run the bundle through the webpack and sourcemap plugins
    preprocessors: {
      'tests.bundle.js': [ 'webpack', 'sourcemap' ]
    },
    reporters: ['dots'],
    autoWatch: true,
    // webpack config object
    webpack: webpackConfig,
    webpackMiddleware: {
      noInfo: true,
    },
    phantomjsLauncher: {
      // Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
      exitOnResourceError: true
    }
  });
};


text:
<template name="MasterLayout">

        {{#linkTo route="articles" class="mdl-layout-title"}}Meteor Blog{{/linkTo}}

          {{> loginButtons align="right"}}

        {{> yield}}

Github

</template>


text:
title: "contactos"
bg: purple
color: white
fa-icon: users
---

# Contactos

<br>

### Garita de Vigilancia: 0291-3153778

### Junta de Condominio: [seguridadmc6@gmail.com](mailto:seguridadmc6@gmail.com)

### Administradora: Lic. Adriana Velázquez 0412-6070861


text:
using System;
using ReMi.Commands.Acknowledge;
using ReMi.Contracts.Cqrs.Commands;
using ReMi.Contracts.Cqrs.Events;
using ReMi.DataAccess.BusinessEntityGateways.ReleasePlan;
using ReMi.Events.ReleasePlan;

namespace ReMi.CommandHandlers.Acknowledge
{
    public class AcknowledgeHandler : IHandleCommand<ApproveReleaseParticipationCommand>, IHandleCommand<ClearReleaseAcknowledgesCommand>
    {
        public Func<IReleaseParticipantGateway> ReleaseParticipantGatewayFactory { get; set; }
        public IPublishEvent EventPublisher { get; set; }

        public void Handle(ApproveReleaseParticipationCommand command)
        {
            Guid releaseWindowGuid;
            using (var gateway = ReleaseParticipantGatewayFactory())
            {
                gateway.ApproveReleaseParticipation(command.ReleaseParticipantId);
                releaseWindowGuid = gateway.GetReleaseWindow(command.ReleaseParticipantId).ExternalId;
            }

            EventPublisher.Publish(new ReleaseParticipationConfirmedEvent
            {
                ReleaseParticipantId = command.ReleaseParticipantId,
                ReleaseWindowGuid = releaseWindowGuid
            });
        }

        public void Handle(ClearReleaseAcknowledgesCommand command)
        {
            using (var gateway = ReleaseParticipantGatewayFactory())
            {
                gateway.ClearParticipationApprovements(command.ReleaseWindowId,
                    command.CommandContext.UserId);
            }
        }
    }
}


text:
package conicio;

import conicio.shapes.*;
import conicio.util.*;
import java.util.*;
import java.io.*;
import javax.imageio.*;
import java.awt.image.*;

public class Conicio {

	public static void main(String[] args) {
		if(args.length == 0) {
			System.err.println("ERROR: No scene specified");
			return;
		}

		boolean visual = false;
		boolean render = true;
		for(String arg : args) {
			if(arg.equals(  "-visual")) { visual = true;  }
			if(arg.equals("-norender")) { render = false; }
		}

		try {
			Class<?> sceneClass = Class.forName(args[args.length - 1]);
			Scene<?> scene      = (Scene<?>)sceneClass.newInstance();

			Renderer<?> renderer = Renderer.create(scene);

			if(visual) {
				Visualizer visualizer = new Visualizer(renderer);
				new Thread(visualizer).start();
			}

			long start = System.nanoTime();
			renderer.run();
			long elapsed = System.nanoTime() - start;
			System.out.format("Render Time: %f(s)%n", elapsed / 1000000000.);

			if(render) {
				String filename = String.format(
					"img/render-%s.png",
					(new Date()).toString().replace(" ", "-")
				);
				BufferedImage image = new BufferedImage(
					scene.xSize(), scene.ySize(),
					BufferedImage.TYPE_INT_RGB
				);
				image.getGraphics().drawImage(
					renderer.result(),
					0, 0, scene.xSize(), scene.ySize(), null
				);
				ImageIO.write(image, "png", new File(filename));
			}
		}
		catch(Exception e) {
			e.printStackTrace();
		}
	}
}


text:
/**
 */
package exploitation.impl;

import exploitation.Environment;
import exploitation.Exploitation;
import exploitation.ExploitationPackage;
import java.util.Collection;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 *
 * An implementation of the model object 'Environment'.
 *
 *

 * The following features are implemented:
 *

 *
{@link exploitation.impl.EnvironmentImpl#getExploitation Exploitation}

 *

 *

 *
 * @generated
 */
public class EnvironmentImpl extends MinimalEObjectImpl.Container implements Environment {
	/**
	 * The cached value of the '{@link #getExploitation() Exploitation}' containment reference list.
	 *
	 *
	 * @see #getExploitation()
	 * @generated
	 * @ordered
	 */
	protected EList<Exploitation> exploitation;

	/**
	 *
	 *
	 * @generated
	 */
	protected EnvironmentImpl() {
		super();
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ExploitationPackage.Literals.ENVIRONMENT;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EList<Exploitation> getExploitation() {
		if (exploitation == null) {
			exploitation = new EObjectContainmentEList<Exploitation>(Exploitation.class, this, ExploitationPackage.ENVIRONMENT__EXPLOITATION);
		}
		return exploitation;
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ExploitationPackage.ENVIRONMENT__EXPLOITATION:
				return ((InternalEList<?>)getExploitation()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ExploitationPackage.ENVIRONMENT__EXPLOITATION:
				return getExploitation();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ExploitationPackage.ENVIRONMENT__EXPLOITATION:
				getExploitation().clear();
				getExploitation().addAll((Collection<? extends Exploitation>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ExploitationPackage.ENVIRONMENT__EXPLOITATION:
				getExploitation().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ExploitationPackage.ENVIRONMENT__EXPLOITATION:
				return exploitation != null && !exploitation.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //EnvironmentImpl


text:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>WebUploader演示</title>
    <link rel="stylesheet" type="text/css" href="ex_src/css/webuploader.css" />
    <link rel="stylesheet" type="text/css" href="ex_src/css/style.css" />

或将照片拖到这里,单次最多可选300张

                        0%

开始上传


text:
<?xml version='1.0' encoding='UTF-8'?>
<Document>
  <Header>
    <SchemaName>Location</SchemaName>
    <Identifier>location_geonames_6929984</Identifier>
    <DocumentState>public</DocumentState>
    <TimeStamp>1390753462395</TimeStamp>
    <SummaryFields>
      <Title>NL > North Brabant > Villapark</Title>
    </SummaryFields>
  </Header>
  <Body>
    <Location>
      <GeopoliticalHierarchy>NL,North Brabant,Villapark</GeopoliticalHierarchy>
      <LocationName>
        <Appelation>Villapark</Appelation>
        <LocationNameType>section of populated place</LocationNameType>
        <Comments></Comments>
      </LocationName>
      <Coordinates>
        <Longitude>5.49385</Longitude>
        <Latitude>51.44144</Latitude>
      </Coordinates>
      <GeonamesURI>http://www.geonames.org/6929984</GeonamesURI>
      <WikipediaLink/>
      <DbpediaLink/>
    </Location>
  </Body>
</Document>


text:
#include <assert.h>
#include <stdlib.h>

#include <dom/html/html_text_area_element.h>

#include "html/html_document.h"
#include "html/html_text_area_element.h"

#include "core/node.h"
#include "core/attr.h"
#include "utils/utils.h"

static struct dom_element_protected_vtable _protect_vtable = {
	{
		DOM_NODE_PROTECT_VTABLE_HTML_TEXT_AREA_ELEMENT
	},
	DOM_HTML_TEXT_AREA_ELEMENT_PROTECT_VTABLE
};

/**
 * Create a dom_html_text_area_element object
 *
 * \param doc  The document object
 * \param ele  The returned element object
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception _dom_html_text_area_element_create(struct dom_html_document *doc,
		dom_string *namespace, dom_string *prefix,
		struct dom_html_text_area_element **ele)
{
	struct dom_node_internal *node;

	*ele = malloc(sizeof(dom_html_text_area_element));
	if (*ele == NULL)
		return DOM_NO_MEM_ERR;

	/* Set up vtables */
	node = (struct dom_node_internal *) *ele;
	node->base.vtable = &_dom_html_element_vtable;
	node->vtable = &_protect_vtable;

	return _dom_html_text_area_element_initialise(doc, namespace, prefix, *ele);
}

/**
 * Initialise a dom_html_text_area_element object
 *
 * \param doc  The document object
 * \param ele  The dom_html_text_area_element object
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception _dom_html_text_area_element_initialise(struct dom_html_document *doc,
		dom_string *namespace, dom_string *prefix,
		struct dom_html_text_area_element *ele)
{
	ele->form = NULL;
	ele->default_value = NULL;
	ele->default_value_set = false;
	ele->value = NULL;
	ele->value_set = false;

	return _dom_html_element_initialise(doc, &ele->base,
					    doc->memoised[hds_TEXTAREA],
					    namespace, prefix);
}

/**
 * Finalise a dom_html_text_area_element object
 *
 * \param ele  The dom_html_text_area_element object
 */
void _dom_html_text_area_element_finalise(struct dom_html_text_area_element *ele)
{
	if (ele->default_value != NULL) {
		dom_string_unref(ele->default_value);
		ele->default_value = NULL;
		ele->default_value_set = false;
	}

	if (ele->value != NULL) {
		dom_string_unref(ele->value);
		ele->value = NULL;
		ele->value_set = false;
	}

	_dom_html_element_finalise(&ele->base);
}

/**
 * Destroy a dom_html_text_area_element object
 *
 * \param ele  The dom_html_text_area_element object
 */
void _dom_html_text_area_element_destroy(struct dom_html_text_area_element *ele)
{
	_dom_html_text_area_element_finalise(ele);
	free(ele);
}

/*-----------------------------------------------------------------------*/
/* Public APIs */

/**
 * Get the disabled property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The returned status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_get_disabled(dom_html_text_area_element *ele,
		bool *disabled)
{
	return dom_html_element_get_bool_property(&ele->base, "disabled",
			SLEN("disabled"), disabled);
}

/**
 * Set the disabled property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_set_disabled(dom_html_text_area_element *ele,
		bool disabled)
{
	return dom_html_element_set_bool_property(&ele->base, "disabled",
			SLEN("disabled"), disabled);
}

/**
 * Get the readOnly property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The returned status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_get_read_only(dom_html_text_area_element *ele,
		bool *read_only)
{
	return dom_html_element_get_bool_property(&ele->base, "readonly",
			SLEN("readonly"), read_only);
}

/**
 * Set the readOnly property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_set_read_only(dom_html_text_area_element *ele,
		bool read_only)
{
	return dom_html_element_set_bool_property(&ele->base, "readonly",
			SLEN("readonly"), read_only);
}

/**
 * Get the defaultValue property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The returned status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_get_default_value(
	dom_html_text_area_element *ele, dom_string **default_value)
{
	dom_exception err;

	if (ele->default_value_set == false) {
		err = dom_node_get_text_content((dom_node *)ele,
						&ele->default_value);
		if (err == DOM_NO_ERR) {
			ele->default_value_set = true;
		}
	}

	*default_value = ele->default_value;

	if (*default_value != NULL)
		dom_string_ref(*default_value);

	return DOM_NO_ERR;
}

/**
 * Set the defaultValue property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_set_default_value(
	dom_html_text_area_element *ele, dom_string *default_value)
{
	if (ele->default_value != NULL)
		dom_string_unref(ele->default_value);

	ele->default_value = default_value;
	ele->default_value_set = true;

	if (ele->default_value != NULL)
		dom_string_ref(ele->default_value);

	return DOM_NO_ERR;
}

/**
 * Get the value property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The returned status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_get_value(
	dom_html_text_area_element *ele, dom_string **value)
{
	dom_exception err;

	if (ele->value_set == false) {
		err = dom_node_get_text_content((dom_node *)ele,
						&ele->value);
		if (err == DOM_NO_ERR) {
			ele->default_value_set = true;
			if (ele->default_value_set == false) {
				ele->default_value_set = true;
				ele->default_value = ele->value;
				dom_string_ref(ele->default_value);
			}
		}
	}

	*value = ele->value;

	if (*value != NULL)
		dom_string_ref(*value);

	return DOM_NO_ERR;
}

/**
 * Set the value property
 *
 * \param ele       The dom_html_text_area_element object
 * \param disabled  The status
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_set_value(
	dom_html_text_area_element *ele, dom_string *value)
{
	dom_exception err;

	if (ele->default_value_set == false) {
		err = dom_node_get_text_content((dom_node *)ele,
						&ele->default_value);
		if (err == DOM_NO_ERR) {
			ele->default_value_set = true;
		}
	}

	if (ele->value != NULL)
		dom_string_unref(ele->value);

	ele->value = value;
	ele->value_set = true;

	if (ele->value != NULL)
		dom_string_ref(ele->value);

	return DOM_NO_ERR;
}

/*------------------------------------------------------------------------*/
/* The protected virtual functions */

/* The virtual function used to parse attribute value, see src/core/element.c
 * for detail */
dom_exception _dom_html_text_area_element_parse_attribute(dom_element *ele,
		dom_string *name, dom_string *value,
		dom_string **parsed)
{
	UNUSED(ele);
	UNUSED(name);

	dom_string_ref(value);
	*parsed = value;

	return DOM_NO_ERR;
}

/* The virtual destroy function, see src/core/node.c for detail */
void _dom_virtual_html_text_area_element_destroy(dom_node_internal *node)
{
	_dom_html_text_area_element_destroy((struct dom_html_text_area_element *) node);
}

/* The virtual copy function, see src/core/node.c for detail */
dom_exception _dom_html_text_area_element_copy(dom_node_internal *old,
		dom_node_internal **copy)
{
	return _dom_html_element_copy(old, copy);
}

/*-----------------------------------------------------------------------*/
/* API functions */

#define SIMPLE_GET(attr)						\
	dom_exception dom_html_text_area_element_get_##attr(		\
		dom_html_text_area_element *element,			\
		dom_string **attr)					\
	{								\
		dom_exception ret;					\
		dom_string *_memo_##attr;				\
									\
		_memo_##attr =						\
			((struct dom_html_document *)			\
			 ((struct dom_node_internal *)element)->owner)->\
			memoised[hds_##attr];				\
									\
		ret = dom_element_get_attribute(element, _memo_##attr, attr); \
									\
		return ret;						\
	}
#define SIMPLE_SET(attr)						\
dom_exception dom_html_text_area_element_set_##attr(			\
		dom_html_text_area_element *element,			\
		dom_string *attr)					\
	{								\
		dom_exception ret;					\
		dom_string *_memo_##attr;				\
									\
		_memo_##attr =						\
			((struct dom_html_document *)			\
			 ((struct dom_node_internal *)element)->owner)->\
			memoised[hds_##attr];				\
									\
		ret = dom_element_set_attribute(element, _memo_##attr, attr); \
									\
		return ret;						\
	}

#define SIMPLE_GET_SET(attr) SIMPLE_GET(attr) SIMPLE_SET(attr)

SIMPLE_GET_SET(access_key);
SIMPLE_GET_SET(name);

dom_exception dom_html_text_area_element_get_type(
	dom_html_text_area_element *text_area, dom_string **type)
{
	dom_html_document *html = (dom_html_document *)
		((dom_node_internal *)text_area)->owner;

	*type = html->memoised[hds_textarea];
	dom_string_ref(*type);

	return DOM_NO_ERR;
}

dom_exception dom_html_text_area_element_get_tab_index(
	dom_html_text_area_element *text_area, int32_t *tab_index)
{
	return dom_html_element_get_int32_t_property(&text_area->base, "tabindex",
			SLEN("tabindex"), tab_index);
}

dom_exception dom_html_text_area_element_set_tab_index(
	dom_html_text_area_element *text_area, uint32_t tab_index)
{
	return dom_html_element_set_int32_t_property(&text_area->base, "tabindex",
			SLEN("tabindex"), tab_index);
}

dom_exception dom_html_text_area_element_get_cols(
	dom_html_text_area_element *text_area, int32_t *cols)
{
	return dom_html_element_get_int32_t_property(&text_area->base, "cols",
			SLEN("cols"), cols);
}

dom_exception dom_html_text_area_element_set_cols(
	dom_html_text_area_element *text_area, uint32_t cols)
{
	return dom_html_element_set_int32_t_property(&text_area->base, "cols",
			SLEN("cols"), cols);
}

dom_exception dom_html_text_area_element_get_rows(
	dom_html_text_area_element *text_area, int32_t *rows)
{
	return dom_html_element_get_int32_t_property(&text_area->base, "rows",
			SLEN("rows"), rows);
}

dom_exception dom_html_text_area_element_set_rows(
	dom_html_text_area_element *text_area, uint32_t rows)
{
	return dom_html_element_set_int32_t_property(&text_area->base, "rows",
			SLEN("rows"), rows);
}

dom_exception dom_html_text_area_element_get_form(
	dom_html_text_area_element *text_area, dom_html_form_element **form)
{
	*form = text_area->form;

	if (*form != NULL)
		dom_node_ref(*form);

	return DOM_NO_ERR;
}

dom_exception _dom_html_text_area_element_set_form(
	dom_html_text_area_element *text_area, dom_html_form_element *form)
{
	text_area->form = form;

	return DOM_NO_ERR;
}

/**
 * Blur this control
 *
 * \param ele  The form object
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_blur(dom_html_text_area_element *ele)
{
	struct dom_html_document *doc =
		(dom_html_document *) dom_node_get_owner(ele);
	bool success = false;
	assert(doc != NULL);

	/** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
	return _dom_dispatch_generic_event((dom_document *) doc,
					   (dom_event_target *) ele,
					   doc->memoised[hds_blur], true,
					   true, &success);
}

/**
 * Focus this control
 *
 * \param ele  The form object
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_focus(dom_html_text_area_element *ele)
{
	struct dom_html_document *doc =
		(dom_html_document *) dom_node_get_owner(ele);
	bool success = false;
	assert(doc != NULL);

	/** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
	return _dom_dispatch_generic_event((dom_document *)doc,
					   (dom_event_target *) ele,
					   doc->memoised[hds_focus], true,
					   true, &success);
}

/**
 * Select this control
 *
 * \param ele  The form object
 * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
 */
dom_exception dom_html_text_area_element_select(dom_html_text_area_element *ele)
{
	struct dom_html_document *doc =
		(dom_html_document *) dom_node_get_owner(ele);
	bool success = false;
	assert(doc != NULL);

	/** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
	return _dom_dispatch_generic_event((dom_document *)doc,
					   (dom_event_target *) ele,
					   doc->memoised[hds_select], true,
					   true, &success);
}


text:
<!DOCTYPE html>

		<meta charset="utf-8">
		<title>TodoApp</title>
		<link rel=stylesheet href="css/main.css" type="text/css" />


text:
import hoomd
import pytest
from hoomd.conftest import pickling_check

def test_attributes():
    active = hoomd.md.force.Active(filter=hoomd.filter.All())

    assert active.active_force['A'] == (1.0, 0.0, 0.0)
    assert active.active_torque['A'] == (0.0, 0.0, 0.0)

    active.active_force['A'] = (0.5, 0.0, 0.0)
    assert active.active_force['A'] == (0.5, 0.0, 0.0)
    active.active_force['A'] = (0.0, 0.0, 1.0)
    assert active.active_force['A'] == (0.0, 0.0, 1.0)

def test_attributes_constraints():
    plane = hoomd.md.manifold.Plane()
    active = hoomd.md.force.ActiveOnManifold(filter=hoomd.filter.All(),
                                             manifold_constraint=plane)

    assert active.active_force['A'] == (1.0, 0.0, 0.0)
    assert active.active_torque['A'] == (0.0, 0.0, 0.0)
    assert active.manifold_constraint == plane

    active.active_force['A'] = (0.5, 0.0, 0.0)
    assert active.active_force['A'] == (0.5, 0.0, 0.0)
    active.active_force['A'] = (0.0, 0.0, 1.0)
    assert active.active_force['A'] == (0.0, 0.0, 1.0)

    sphere = hoomd.md.manifold.Sphere(r=5)
    with pytest.raises(AttributeError):
        active.manifold_constraint = sphere
    assert active.manifold_constraint == plane

def test_attach(simulation_factory, two_particle_snapshot_factory):
    active = hoomd.md.force.Active(filter=hoomd.filter.All())

    sim = simulation_factory(two_particle_snapshot_factory(dimensions=3, d=8))
    integrator = hoomd.md.Integrator(.05)
    integrator.methods.append(
        hoomd.md.methods.Langevin(hoomd.filter.All(), kT=0))
    integrator.forces.append(active)
    sim.operations.integrator = integrator
    sim.run(0)

    assert active.active_force['A'] == (1.0, 0.0, 0.0)
    assert active.active_torque['A'] == (0.0, 0.0, 0.0)

    active.active_force['A'] = (0.5, 0.0, 0.0)
    assert active.active_force['A'] == (0.5, 0.0, 0.0)
    active.active_force['A'] = (0.0, 0.0, 1.0)
    assert active.active_force['A'] == (0.0, 0.0, 1.0)

def test_attach_manifold(simulation_factory, two_particle_snapshot_factory):
    plane = hoomd.md.manifold.Plane()
    active = hoomd.md.force.ActiveOnManifold(filter=hoomd.filter.All(),
                                             manifold_constraint=plane)

    sim = simulation_factory(two_particle_snapshot_factory(dimensions=3, d=8))
    integrator = hoomd.md.Integrator(.05)
    integrator.methods.append(
        hoomd.md.methods.Langevin(hoomd.filter.All(), kT=0))
    integrator.forces.append(active)
    sim.operations.integrator = integrator
    sim.run(0)

    assert active.active_force['A'] == (1.0, 0.0, 0.0)
    assert active.active_torque['A'] == (0.0, 0.0, 0.0)
    assert active.manifold_constraint == plane

    active.active_force['A'] = (0.5, 0.0, 0.0)
    assert active.active_force['A'] == (0.5, 0.0, 0.0)
    active.active_force['A'] = (0.0, 0.0, 1.0)
    assert active.active_force['A'] == (0.0, 0.0, 1.0)
    sphere = hoomd.md.manifold.Sphere(r=2)
    with pytest.raises(AttributeError):
        active.manifold_constraint = sphere
    assert active.manifold_constraint == plane

def test_pickling(simulation_factory, two_particle_snapshot_factory):
    sim = simulation_factory(two_particle_snapshot_factory())
    active = hoomd.md.force.Active(filter=hoomd.filter.All())
    pickling_check(active)
    integrator = hoomd.md.Integrator(
        .05,
        methods=[hoomd.md.methods.Langevin(hoomd.filter.All(), kT=0)],
        forces=[active])
    sim.operations.integrator = integrator
    sim.run(0)
    pickling_check(active)

def test_pickling_constraint(simulation_factory, two_particle_snapshot_factory):
    sim = simulation_factory(two_particle_snapshot_factory())
    active = hoomd.md.force.ActiveOnManifold(
        filter=hoomd.filter.All(),
        manifold_constraint=hoomd.md.manifold.Plane())
    pickling_check(active)
    integrator = hoomd.md.Integrator(
        .05,
        methods=[hoomd.md.methods.Langevin(hoomd.filter.All(), kT=0)],
        forces=[active])
    sim.operations.integrator = integrator
    sim.run(0)
    pickling_check(active)


text:
/*****************************************
svidget.eventdesc.js

Represents a user-defined object for the widget.

Dependencies:
svidget.core.js
svidget.eventprototype.js
svidget.objectprototype.js

******************************************/

/**
 * Represents an user-defined event for a widget, defined by <svidget:event>
 * @constructor
 * @mixes ObjectPrototype
 * @augments EventPrototype
 * @memberof Svidget
 * @param {string} name - The name of the event.
 * @param {object} options - The options for the event. Example: { enabled: true, description: "An event" }
 * @param {Svidget.Widget} parent - The widget instance that is the parent for this action.
 */
Svidget.EventDesc = function (name, options, parent) {
	this.__type = "Svidget.EventDesc";
	// validate:
	// name is not null
	options = options || {};
	parent = parent instanceof Svidget.Widget ? parent : null; // parent can only be a Widget

	var that = this;
	var c = Svidget.Conversion;
	// private fields
	var privates = new (function () {
		this.writable = ["description", "enabled", "external"];
		this.name = c.toString(name);
		this.description = c.toString(options.description);
		this.external = options.external != null ? c.toBool(options.external) : true;
		this.enabled = options.enabled != null ? c.toBool(options.enabled) : true;
		this.eventName = "trigger"; // this is the internal name we use for the event
		this.eventContainer = new Svidget.EventContainer([this.eventName], that);
		this.parent = parent;
	})();
	// private accessors
	this.setup(privates);

	// wire up event bubble parent
	privates.eventContainer.registerBubbleCallback(Svidget.EventDesc.eventTypes, parent, parent.eventBubble);
}

Svidget.EventDesc.prototype = {

	/**
	 * Gets the event name.
	 * @method
	 * @returns {string}
	*/
	/*
	// Note: name is immutable after creation
	*/
	name: function (val) {
		if (val !== undefined) return false; // they are trying to set, it should fail
		var res = this.getPrivate("name");
		return res;
	},

	/**
	 * Gets whether the event is attached to the widget.
	 * @method
	 * @returns {boolean}
	*/
	attached: function () {
		var parent = this.parent();
		return this.parent != null && this.parent instanceof Svidget.Widget;
	},

	/**
	 * Gets the parent widget.
	 * @method
	 * @returns {Svidget.Widget}
	*/
	parent: function () {
		var res = this.getPrivate("parent");
		return res;
	},

	/**
	 * Gets or sets whether the event is enabled.
	 * @method
	 * @param {boolean} [val] - Sets the enabled state when specified.
	 * @returns {boolean} - The enabled state when nothing is passed, or true/false if succeeded or failed when setting.
	*/
	enabled: function (val) {
		if (val === null) val = true;
		var res = this.getset("enabled", val, "bool");
		// if undefined its a get so return value, if res is false then set failed
		if (val === undefined || !!!res) return res;
		// fire "changed" event
		val = this.getset("enabled"); // get converted value
		this.trigger("change", { property: "enabled", value: val });
		// set was successful
		return true;
	},

	/**
	 * Gets or sets the description.
	 * @method
	 * @param {string} [val] - Sets the value when specified.
	 * @returns {string} - The value for a get, or true/false if succeeded or failed for a set.
	*/
	description: function (val) {
		var res = this.getset("description", val, "string");
		// if undefined its a get so return value, if res is false then set failed
		if (val === undefined || !!!res) return res;
		// fire "changed" event
		val = this.getPrivate("description"); // get converted value
		this.trigger("change", { property: "description", value: val });
		// set was successful
		return true;
	},

	/**
	 * Gets or sets whether the event is external and can be triggered from the page.
	 * @method
	 * @param {boolean} [val] - Sets the value when specified.
	 * @returns {boolean} - The value for a get, or true/false if succeeded or failed for a set.
	*/
	external: function (val) {
		if (val === null) val = true;
		var res = this.getset("external", val, "bool");
		// if undefined its a get so return value, if res is false then set failed
		if (val === undefined || !!!res) return res;
		// fire "changed" event
		val = this.getPrivate("external"); // get converted value
		this.trigger("change", { property: "external", value: val });
		// set was successful
		return true;
	},

	/* REGION Events */

	// private: used internally for a default event name for the container
	eventName: function() {
		return this.getPrivate("eventName");
	},

	eventContainer: function() {
		return this.getset("eventContainer");
	},

	/**
	 * Registers an event handler for the EventDesc object.
	 * @method
	 * @param {string} [type] - The event type i.e. "change". If not specified it is assumed it is for the event itself.
	 * @param {object} [data] - Arbirary data to initialize Event object with when event is triggered.
	 * @param {string} [name] - The name of the handler. Useful when removing the handler for the event.
	 * @param {Function} handler - The event handler.
	 * @returns {boolean} - True if the event handler was successfully added.
	*/
	/*
	// type, data, name, handler
	// type, data, handler
	// type, handler
	*/
	on: function (type, data, name, handler) {
		// if type is function, then assume type not passes so use default event name
		if (Svidget.isFunction(type)) {
			handler = type;
			type = this.eventName();
		}
		this.eventContainer().on(type, data, name, handler);
	},

	/**
	* Adds an event handler for the "trigger" event.
	 * @method
	 * @param {object} [data] - Arbirary data to initialize Event object with when event is triggered.
	 * @param {string} [name] - The name of the handler. Useful when removing the handler for the event.
	 * @param {Function} handler - The event handler.
	 * @returns {boolean} - True if the event handler was successfully added.
	*/
	ontrigger: function (data, name, handler) {
		this.eventContainer().on(this.eventName(), data, name, handler);
	},

	ondeclaredtrigger: function (handler) {
		return this.ontrigger(null, Svidget.declaredHandlerName, handler);
	},

	/**
	 * Unregisters an event handler for the EventDesc object.
	 * @method
	 * @param {string} [type] - The event type i.e. "change", "paramremove". If not specified it is assumed it is for the event itself.
	 * @param {(Function|string)} handlerOrName - The handler function and/or the handler name used when calling on().
	 * @returns {boolean} - True if the event handler was successfully removed.
	*/
	off: function (type, handlerOrName) {
		// if type is function, then assume type not passes so use default event name
		if (Svidget.isFunction(type)) {
			handlerOrName = type;
			type = this.eventName();
		}
		this.eventContainer().off(type, handlerOrName);
	},

	/**
	* Removes an event handler for the "trigger" event.
	* @method
	* @param {(Function|string)} handlerOrName - The handler function and/or the handler name used when calling on().
	* @returns {boolean} - True if the event handler was successfully removed.
	*/
	offtrigger: function (handlerOrName) {
		this.eventContainer().off(this.eventName(), handlerOrName);
	},

	offdeclaredtrigger: function () {
		return this.offtrigger(Svidget.declaredHandlerName);
	},

	/**
	* Adds an event handler for the "change" event.
	* @method
	* @param {object} [data] - Arbirary data to initialize Event object with when event is triggered.
	* @param {string} [name] - The name of the handler. Useful when removing the handler for the event.
	* @param {Function} handler - The event handler.
	* @returns {boolean} - True if the event handler was successfully added.
	*/
	onchange: function (data, name, handler) {
		return this.on("change", data, name, handler);
	},

	ondeclaredchange: function (handler) {
		return this.onchange(null, Svidget.declaredHandlerName, handler);
	},

	/**
	* Removes an event handler for the "change" event.
	* @method
	* @param {(Function|string)} handlerOrName - The handler function and/or the handler name used when calling on().
	* @returns {boolean} - True if the event handler was successfully removed.
	*/
	offchange: function (handlerOrName) {
		this.off("change", handlerOrName);
	},

	offdeclaredchange: function () {
		return this.offchange(Svidget.declaredHandlerName);
	},

	/**
	* Triggers the event for the EventDesc object.
	* @method
	* @param {object} value - The value to set to the Event.value property.
	*/
	// Note: The use of type as a param is undocumented here. For public use we only want them passing value as a param.
	trigger: function (type, value) {
		if (!this.enabled()) return;
		if (value === undefined) {
			value = type;
			type = this.eventName();
		}
		this.eventContainer().trigger(type, value);
	},

	triggerEvent: function (value) {
		this.trigger(this.eventName(), value);
	},

	// helpers

	/**
	* Serializes the EventDesc object for transport across a window boundary.
	* @method
	* @returns {boolean} - A generic serialized object representing the EventDesc object.
	*/
	toTransport: function () {
		var transport = {
			name: this.name(),
			description: this.description(),
			external: this.external(),
			enabled: this.enabled(),
		};
		return transport;
	},

	// overrides

	/**
	* Gets a string representation of this object.
	* @method
	* @returns {string}
	*/
	toString: function () {
		return "[Svidget.EventDesc { name: \"" + this.name() + "\" }]";
	}

}

Svidget.EventDesc.eventTypes = ["trigger", "change"];
Svidget.EventDesc.optionProperties = ["external", "enabled", "description"];
Svidget.EventDesc.allProxyProperties = ["name", "external", "enabled", "description", "eventContainer"];
Svidget.EventDesc.writableProxyProperties = [];

Svidget.extend(Svidget.EventDesc, Svidget.ObjectPrototype);


text:
package it.gmariotti.cardslib.library.view.component;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.support.v7.widget.PopupMenu;

import it.gmariotti.cardslib.library.R;
import it.gmariotti.cardslib.library.internal.CardHeader;
import it.gmariotti.cardslib.library.view.base.CardViewInterface;

/**
 * Compound View for Header Component.
 * It is built with base_header_layout xml file.
 *

 * The base layout has two elements:
 *

 *
card_header_inner_frame: frame which contains custom content.

 *
card_header_button_frame: frame which contains button.

 *

 *

 * You can populate and customize this layout using your CardHeader class.
 * See {@link CardHeader} for more info.
 *

 * You can use a custom layout for Header Component in your xml layout.
 *

 *  <it.gmariotti.cardslib.library.view.component.CardHeaderView
 *       android:id="@+id/card_header_layout"
 *       android:layout_width="match_parent"
 *       android:layout_height="wrap_content"
 *       card:card_header_layout_resourceID="@layout/my_header_layout" />
 *

 *

 *
 * @author Gabriele Mariotti (gabri.mariotti@gmail.com)
 */
public class CardHeaderView extends FrameLayout implements CardViewInterface {

    //--------------------------------------------------------------------------
    // Custom Layout
    //--------------------------------------------------------------------------
    /**
     * Header Layout
     */
    protected int card_header_layout_resourceID = R.layout.base_header_layout;

    //--------------------------------------------------------------------------
    // View
    //--------------------------------------------------------------------------
    /**
     * Compound View for this Component
     */
    protected View mInternalOuterView;

    /**
     * Inner View.
     */
    protected View mInternalInnerView;

    //--------------------------------------------------------------------------
    // Frame
    //--------------------------------------------------------------------------
    /**
     * InnerContent Frame
     */
    protected ViewGroup mFrameInner;

    /**
     * Button Frame
     */
    protected ViewGroup mFrameButton;

    //--------------------------------------------------------------------------
    // Button
    //--------------------------------------------------------------------------
    /**
     * Overflow
     */
    protected ImageButton mImageButtonOverflow;

    /**
     * Expand/Collapse button
     */
    protected ImageButton mImageButtonExpand;

    /**
     * Other Button
     */
    protected ImageButton mImageButtonOther;

    /**
     * Card Model *
     */
    protected CardHeader mCardHeader;

    /**
     * Listener invoked when expand/collapse button is clicked
     */
    protected OnClickListener mOnClickExpandCollapseActionListener;

    /**
     * Used to recycle ui elements.
     */
    protected boolean mIsRecycle=false;

    /**
     * Used to replace inner layout elements.
     */
    protected boolean mForceReplaceInnerLayout = false;

    //--------------------------------------------------------------------------
    // Constructors
    //--------------------------------------------------------------------------

    public CardHeaderView(Context context) {
        super(context);
        init(null, 0);
    }

    public CardHeaderView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(attrs, 0);
    }

    public CardHeaderView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(attrs, defStyle);
    }

    //--------------------------------------------------------------------------
    // Init
    //--------------------------------------------------------------------------

    /**
     * Initializes component
     *
     * @param attrs
     * @param defStyle
     */
    protected void init(AttributeSet attrs, int defStyle) {
        //Init attrs
        initAttrs(attrs, defStyle);

        //Init View
        if (!isInEditMode())
            initView();
    }

    /**
     * Init custom attrs.
     *
     * @param attrs
     * @param defStyle
     */
    protected void initAttrs(AttributeSet attrs, int defStyle) {

        TypedArray a = getContext().getTheme().obtainStyledAttributes(
                attrs, R.styleable.card_options, defStyle, defStyle);

        try {
            card_header_layout_resourceID = a.getResourceId(R.styleable.card_options_card_header_layout_resourceID, card_header_layout_resourceID);
        } finally {
            a.recycle();
        }
    }

    /**
     * Inits view
     */
    protected void initView() {

        //Inflate the root view (outerView)
        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mInternalOuterView = inflater.inflate(card_header_layout_resourceID, this, true);

        //Get buttons from layout
        mImageButtonExpand = (ImageButton) findViewById(R.id.card_header_button_expand);
        mImageButtonOverflow = (ImageButton) findViewById(R.id.card_header_button_overflow);
        mImageButtonOther = (ImageButton) findViewById(R.id.card_header_button_other);

        //Get frames
        mFrameInner = (FrameLayout) findViewById(R.id.card_header_inner_frame);
        mFrameButton = (FrameLayout) findViewById(R.id.card_header_button_frame);

    }

    @Override
    public View getInternalOuterView() {
        return mInternalOuterView;
    }

    /**
     * Adds a {@link CardHeader}.
     * It is important to set all header values before launch this method
     *
     * @param cardHeader CardHeader model
     */
    public void addCardHeader(CardHeader cardHeader) {
        //Set header
        mCardHeader = cardHeader;
        //build ui
        buildUI();
    }

    /**
     * This method builds UI.
     * If you are using standard base layout it sets up buttons and innerView.
     * If you are using your custom layout it sets your elements.
     */
    protected void buildUI() {
        if (mCardHeader == null) return;

        //Set button visibility
        setupButtons();

        //Setup InnerView
        setupInnerView();
    }

    /**
     * Sets Buttons visibility
     */
    @SuppressWarnings("deprecation")
    @SuppressLint("NewApi")
    protected void setupButtons() {

        if (mCardHeader.isButtonOverflowVisible()) {
            visibilityButtonHelper(VISIBLE, GONE, GONE);

            if (mCardHeader.getPopupMenu()!=CardHeader.NO_POPUP_MENU){
                //Add popup
                addPopup();
            }else if (mCardHeader.getCustomOverflowAnimation()!=null){
                addCustomOverflowAnimation();
            }
        } else {

            if (mCardHeader.isButtonExpandVisible()) {
                visibilityButtonHelper(GONE, VISIBLE, GONE);
            } else {

                if (mCardHeader.isOtherButtonVisible() && mImageButtonOther != null) {
                    visibilityButtonHelper(GONE, GONE, VISIBLE);
                    //Check if button is not null
                    if (mImageButtonOther != null) {
                        if (mCardHeader.getOtherButtonDrawable() > 0) {
                            if (Build.VERSION.SDK_INT >= 16) {
                                mImageButtonOther.setBackground(getResources().getDrawable(mCardHeader.getOtherButtonDrawable()));
                            } else {
                                mImageButtonOther.setBackgroundDrawable(getResources().getDrawable(mCardHeader.getOtherButtonDrawable()));
                            }
                        }
                        addOtherListener();
                    }
                } else {
                    visibilityButtonHelper(GONE, GONE, GONE);
                }
            }
        }
    }

    /**
     * Add Custom Overflow Animation
     */
    private void addCustomOverflowAnimation() {

        final CardHeader.CustomOverflowAnimation animation= mCardHeader.getCustomOverflowAnimation();
        if (animation!=null && mImageButtonOverflow != null) {

            //Add a PopupMenu and its listener
            mImageButtonOverflow.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                   animation.doAnimation(mCardHeader.getParentCard(),v);
                }
            });

        }else{
            if (mImageButtonOverflow != null)
                mImageButtonOverflow.setVisibility(GONE);
        }

    }

    /**
     * Sets listener for OtherButtonAction
     */
    protected void addOtherListener() {

        if (mCardHeader.getOtherButtonClickListener() != null) {
            if (mImageButtonOther != null) {
                mImageButtonOther.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (mCardHeader.getOtherButtonClickListener()!=null)
                            mCardHeader.getOtherButtonClickListener().onButtonItemClick(mCardHeader.getParentCard(), v);
                    }
                });
            }
        }else{
            if (mImageButtonOther != null) {
                mImageButtonOther.setClickable(false);
            }
        }
    }

    /**
     * Sets the inner view.
     */
    protected void setupInnerView() {
        if (mFrameInner != null) {
            //Check if view can be recycled
            //It can happen in a listView to improve performances or while refreshing a card
            if (!isRecycle() || isForceReplaceInnerLayout()){

                if (isForceReplaceInnerLayout() && mFrameInner != null && mInternalInnerView!=null)
                    mFrameInner.removeView(mInternalInnerView);

                //Inflate inner view
                mInternalInnerView = mCardHeader.getInnerView(getContext(), mFrameInner);
            }else{
                //View can be recycled.
                //Only setup Inner Elements
                if (mCardHeader.getInnerLayout()>-1)
                    mCardHeader.setupInnerViewElements(mFrameInner,mInternalInnerView);
            }
        }
    }

    /**
     * Helper method to setup buttons visibility
     *
     * @param overflowButtonVisibility VISIBLE to make visibile this button , otherwise GONE
     * @param expandButtonVisibility   VISIBLE to make visibile this button , otherwise GONE
     * @param otherButtonVisibility    VISIBLE to make visibile this button , otherwise GONE
     */
    protected void visibilityButtonHelper(int overflowButtonVisibility, int expandButtonVisibility, int otherButtonVisibility) {

        if (overflowButtonVisibility == VISIBLE || overflowButtonVisibility == GONE) {
            if (mImageButtonOverflow != null)
                mImageButtonOverflow.setVisibility(overflowButtonVisibility);
        }
        if (expandButtonVisibility == VISIBLE || expandButtonVisibility == GONE) {
            if (mImageButtonExpand != null)
                mImageButtonExpand.setVisibility(expandButtonVisibility);
        }
        if (otherButtonVisibility == VISIBLE || otherButtonVisibility == GONE) {
            if (mImageButtonOther != null)
                mImageButtonOther.setVisibility(otherButtonVisibility);
        }
    }

    /**
     * Adds Popup menu
     */
    protected void addPopup() {

        if (mCardHeader.getPopupMenu() > -1 && mImageButtonOverflow != null) {

            //Add a PopupMenu and its listener
            mImageButtonOverflow.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PopupMenu popup = new PopupMenu(getContext(), mImageButtonOverflow);
                    MenuInflater inflater = popup.getMenuInflater();
                    inflater.inflate(mCardHeader.getPopupMenu(), popup.getMenu());
                    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                        @Override
                        public boolean onMenuItemClick(MenuItem item) {
                            if (mCardHeader.getPopupMenu() > 0 && mCardHeader.getPopupMenuListener() != null) {
                                // This individual card has it unique menu
                                mCardHeader.getPopupMenuListener().onMenuItemClick(mCardHeader.getParentCard(), item);
                            }
                            return false;
                        }
                    });
                    popup.show();
                }
            });

        } else {
            if (mImageButtonOverflow != null)
                mImageButtonOverflow.setVisibility(GONE);
        }
    }

    //--------------------------------------------------------------------------
    // Getters and Setters
    //--------------------------------------------------------------------------

    /**
     * Returns Listener invoked when expand/collpse button is clicked
     *
     * @return listener
     */
    public OnClickListener getOnClickExpandCollapseActionListener() {
        return mOnClickExpandCollapseActionListener;
    }

    /**
     * Attaches Listener to expand/collapse button
     *
     * @param onClickExpandCollapseActionListener listener
     */
    public void setOnClickExpandCollapseActionListener(OnClickListener onClickExpandCollapseActionListener) {
        this.mOnClickExpandCollapseActionListener = onClickExpandCollapseActionListener;
        /*if (mImageButtonExpand != null)
            mImageButtonExpand.setOnClickListener(onClickExpandCollapseActionListener);
            */
    }

    /**
     * Indicates if view can recycle ui elements.
     *
     * @return true if views can recycle ui elements
     */
    public boolean isRecycle() {
        return mIsRecycle;
    }

    /**
     * Sets if view can recycle ui elements
     *
     * @param isRecycle  true to recycle
     */
    public void setRecycle(boolean isRecycle) {
        this.mIsRecycle = isRecycle;
    }

    /**
     * Indicates if inner layout have to be replaced
     *
     * @return true if inner layout can be recycled
     */
    public boolean isForceReplaceInnerLayout() {
        return mForceReplaceInnerLayout;
    }

    /**
     * Sets if inner layout have to be replaced
     *
     * @param forceReplaceInnerLayout  true to recycle
     */
    public void setForceReplaceInnerLayout(boolean forceReplaceInnerLayout) {
        this.mForceReplaceInnerLayout = forceReplaceInnerLayout;
    }

    /**
     * Returns the {@link ImageButton} used for overflow menu
     *
     * @return {@link ImageButton}
     */
    public ImageButton getImageButtonOverflow() {
        return mImageButtonOverflow;
    }

    /**
     * Returns the {@link ImageButton} used for expand/collapse
     *
     * @return {@link ImageButton}
     */
    public ImageButton getImageButtonExpand() {
        return mImageButtonExpand;
    }

    /*
     *Returns the {@link ImageButton} used for other Button
     *
     * @return {@link ImageButton}
     */
    public ImageButton getImageButtonOther() {
        return mImageButtonOther;
    }

    /**
     * Returns the Frame which contains the buttons
     * @return
     */
    public ViewGroup getFrameButton() {
        return mFrameButton;
    }

}


text:
/*
 * PropositionalFormula.java
 *
 * Created on April 3, 2008, 6:49 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package kobdig.logic;

import kobdig.agent.AplTokenizer;

import java.io.IOException;

/**
 * A well-formed formula in the language of propositional logic
 *
 * @author Andrea G. B. Tettamanzi
 */
public class PropositionalFormula extends Formula
{
    /**
     * Creates a stub propositional formula with the given operator.
     * This constructor is declared as protected
     * because it can be called only from within this class.
     */
    protected PropositionalFormula(Operator o)
    {
        int arity = o.arity();
        op = o;
        atom = null;
        child = new Formula[arity];
    }

    /** Creates a new atomic propositional formula */
    public PropositionalFormula(PropositionalAtom a)
    {
        super(a);
    }

    /**
     * Creates a new compound formula, with the given logical
     * operator and arguments.
     *
     * @param o the operator
     * @param args the formulas that constitute the arguments of the operator.
     *        If there are more arguments than the arity of the operator,
     *        the extra arguments are ignored. The number of arguments is variable
     *        but cannot be less than the arity of the operator.
     *        The maximum number of arguments is limited by the maximum dimension
     *        of a Java array as defined by the
     *        Java Virtual Machine
     *        Specification.
     */
    public PropositionalFormula(Operator o, Formula... args)
    {
        int arity = o.arity();
        if(args.length < arity)
            throw new IllegalArgumentException("Not enough arguments for an operator of arity " + arity);
        op = o;
        atom = null;
        child = new Formula[arity];
        for(int i = 0; i<arity; i++)
            child[i] = new PropositionalFormula(args[i]);
    }

    /**
     * Copy constructor: creates a new formula identical to the one provided
     * as parameter, without sharing any of its objects.
     * In other words, the copy operation is "deep".
     *
     * @param that a formula
     */
    public PropositionalFormula(Formula that)
    {
        op = that.op;
        atom = that.atom;
        if(op!=null)
        {
            int arity = op.arity();
            child = new Formula[arity];
            for(int i = 0; i<arity; i++)
                child[i] = new PropositionalFormula(that.child[i]);
        }
    }

    /**
     * Parses a propositional formula from a source file.
     */
    public PropositionalFormula(AplTokenizer source) throws IOException
    {
        PropositionalFormula that = parseDisjunction(source);
        op = that.op;
        atom = that.atom;
        child = that.child;
    }

    /**
     * Parses a disjunction of one or more subformulas.
     *
     * @param source a tokenizer of the source file from which the disjunction
     *   is being parsed
     * @return the parsed formula
     * @throws IOException
     */
    protected static PropositionalFormula parseDisjunction(AplTokenizer source) throws IOException
    {
        PropositionalFormula phi = null;
        do
        {
            if(phi==null)
                phi = parseConjunction(source);
            else
            {
                source.nextToken();
                phi = new PropositionalFormula(Operator.OR, parseConjunction(source), phi);
            }
        }
        while(source.has("or"));
        return phi;
    }

    /**
     * Parses a conjunction of one or more subformulas (whose top-level
     * logical connective is guaranteed not to be a disjunction).
     *
     * @param source a tokenizer of the source file from which the conjunction
     *   is being parsed
     * @return the parsed formula
     * @throws IOException
     */
    protected static PropositionalFormula parseConjunction(AplTokenizer source) throws IOException
    {
        PropositionalFormula phi = null;
        do
        {
            if(phi==null)
                phi = parseSubFormula(source);
            else
            {
                source.nextToken();
                phi = new PropositionalFormula(Operator.AND, parseSubFormula(source), phi);
            }
        }
        while(source.has("and"));
        return phi;
    }

    /**
     * Parses a subformula, which can consist either of a literal or
     * of a positive or negated subformula surrounded by parentheses.
     *
     * @param source a tokenizer of the source file from which the subformula
     *   is being parsed
     * @return the parsed formula
     * @throws IOException
     */
    protected static PropositionalFormula parseSubFormula(AplTokenizer source) throws IOException
    {
        if(source.ttype==AplTokenizer.TT_WORD)
        {
            if(source.has("not"))
            {
                source.nextToken();
                return new PropositionalFormula(Operator.NOT, parseSubFormula(source));
            }
            else
            {
                PropositionalAtom a = new PropositionalAtom(source.sval);
                source.nextToken();
                return new PropositionalFormula(a);
            }
        }
        else
        {
            source.require('(');
            source.nextToken();
            PropositionalFormula phi = parseDisjunction(source);
            source.require(')');
            source.nextToken();
            return phi;
        }
    }

    /**
     * Returns the degree of truth of this formula under the given interpretation.
     */
    @Override
    public TruthDegree truth(Interpretation itp)
    {
        if(!(itp instanceof PropositionalInterpretation))
            throw new IllegalArgumentException("Propositional interpretation required");

        PropositionalInterpretation interpretation = (PropositionalInterpretation) itp;
        if(op==null)
            // Base of recursion:
            return interpretation.truth(atom);
        else
        {
            // Recursion Step:
            // calculate the truth for each of the arguments
            int arity = op.arity();
            TruthDegree[] t = new TruthDegree[arity];
            for(int i = 0; i<arity; i++)
                t[i] = child[i].truth(itp);
            return op.truth(t);
        }
    }

    /**
     * Returns the negation of this formula.
     */
    @Override
    public Formula negated()
    {
        if(op!=Operator.NOT)
            return new PropositionalFormula(Operator.NOT, this);
        else
            return child[0];
    }

    /**
     * Generates a random propositional formulas using atoms from the
     * provided atom set.
     *
     * @param p a parameter controlling the expected depth of the formula,
     *   0 < p < 1.
     * @param atoms a set of propositional atoms that can be used to construct
     *   the random formula
     * @return a random propositional formula
     */
    public static PropositionalFormula random(double p, PropositionalAtom[] atoms)
    {
        if(Math.random()<p)
        {
            switch((int) Math.floor(Math.random()*3.0))
            {
                case 0:
                    return new PropositionalFormula(Operator.NOT, random(p, atoms));
                case 1:
                    return new PropositionalFormula(Operator.AND,
                            random(p, atoms), random(p, atoms));
                case 2:
                    return new PropositionalFormula(Operator.OR,
                            random(p, atoms), random(p, atoms));
            }
        }
        return new PropositionalFormula(atoms[(int) Math.floor(Math.random()*atoms.length)]);
    }
}


text:
<?php
require_once "config.php";
$pageController = new PageController();

if(isset($_GET["p"]))
{
    $page = $_GET["p"];

    switch($page)
    {
        case "writeIssue":
            $pageController->htmlPage->printWriteIssuePage();
            break;
        case "statistics":
            $pageController->htmlPage->printStatisticsPage();
            break;
        case "close":
            $id = $_GET["id"];
            $pageController->htmlPage->printCloseIssuePage($id);
            break;
        case "closeIssue":
            $id = $_GET["id"];
            $pageController->closeIssue($id);
            break;
        case "deleteIssue":
            $id = $_GET["id"];
            $pageController->deleteIssue($id);
            break;
        case "reopenIssue":
            $id = $_GET["id"];
            $pageController->reopenIssue($id);
            break;
        case "createIssue":
            $pageController->createIssue();
            break;
        default:
            $pageController->htmlPage->printHomePage();
            break;
    }
}
else
{
    $pageController->htmlPage->printHomePage();
}


text:
package tk.mybatis.mapper.common.example;

import org.apache.ibatis.annotations.DeleteProvider;
import tk.mybatis.mapper.provider.MapperProvider;

/**
 * 通用Mapper接口,Example查询
 *
 * @param <T> 不能为空
 * @author liuzh
 */
public interface DeleteByExampleMapper<T> {

    /**
     * 根据Example条件删除数据
     *
     * @param example
     * @return
     */
    @DeleteProvider(type = MapperProvider.class, method = "dynamicSQL")
    int deleteByExample(Object example);

}


text:
layout: landing
title: "6 simple tips to save 166 hours in one year"
permalink: /courses/productivity-tips/
category: courses
tags: [productivity]
---

"6 simple tips to save 166 hours in one year" is a short book that shows you how to spend your time more efficient. It is both for beginners and experienced PC users, for those who develop programs as well as for simple users. You will find out how your precious time can be saved at work so you can dedicate it to your family and friends.

The monotonous everyday operations will be as easy and fast as never before. I've used the described techniques for last 8 years in my work and can assure you that they really work on practice. Now I've written a guide to share what I learned.

Contents

            This book provides tips worth knowing about your daily computer work. By utilizing my practical advices you'll be able to become truly "armed" and productive. You'll find a wealth of valuable information in this book, including:

Guide to spend your time efficiently

Methods to fix committed errors quicker

Fasten your business email communication

Improve your skills in writing everyday texts/programs

Make your computer much faster

Software that can help you significantly reduce number of your mistakes

Shortcuts to your efficiency

            <link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">

                <form action="//heroesofprogramming.us14.list-manage.com/subscribe/post?u=66810098b68f8d99a0327fc1f&id=9b174ea904" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>

Get the book on your email!

* indicates required

                            Email Address  *

                            <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">

                            First Name  *

                            <input type="text" value="" name="FNAME" class="required" id="mce-FNAME">

<input type="text" name="b_66810098b68f8d99a0327fc1f_9b174ea904" tabindex="-1" value="">

<input type="submit" value="Get the book" name="subscribe" id="mc-embedded-subscribe" class="button">

                </form>

"6 simple tips to save 166 hours in one year" is a profession-neutral informational resource that doesn't waste your time. The reading will be easy and enjoyable and in the same time very useful.


text:
package main

import (
	"encoding/base64"
	"fmt"
	"log"
	"net/http"

	"golang.org/x/net/context"

	"gopkg.in/macaroon-bakery.v2/bakery"
	"gopkg.in/macaroon-bakery.v2/bakery/checkers"
	"gopkg.in/macaroon-bakery.v2/httpbakery"
	"gopkg.in/macaroon-bakery.v2/httpbakery/form"

	"github.com/juju/httprequest"
	"github.com/rogpeppe/fastuuid"
)

const formURL string = "/form"

type loginResponse struct {
	Token *httpbakery.DischargeToken `json:"token"`
}

// AuthService is an HTTP service for authentication using macaroons.
type authService struct {
	httpService

	KeyPair *bakery.KeyPair
	Checker credentialsChecker

	userTokens    map[string]string // map user token to username
	uuidGenerator *fastuuid.Generator
}

// NewAuthService returns an AuthService
func newAuthService(listenAddr string, logger *log.Logger) *authService {
	key := bakery.MustGenerateKey()
	mux := http.NewServeMux()
	s := authService{
		httpService: httpService{
			Name:       "auth",
			ListenAddr: listenAddr,
			Logger:     logger,
			Mux:        mux,
		},
		KeyPair:       key,
		Checker:       newCredentialsChecker(),
		uuidGenerator: fastuuid.MustNewGenerator(),
		userTokens:    map[string]string{},
	}
	mux.Handle(formURL, http.HandlerFunc(s.formHandler))

	discharger := httpbakery.NewDischarger(
		httpbakery.DischargerParams{
			Key:     key,
			Checker: httpbakery.ThirdPartyCaveatCheckerFunc(s.thirdPartyChecker),
		})
	discharger.AddMuxHandlers(mux, "/")
	return &s
}

func (s *authService) thirdPartyChecker(ctx context.Context, req *http.Request, info *bakery.ThirdPartyCaveatInfo, token *httpbakery.DischargeToken) ([]checkers.Caveat, error) {
	if token == nil {
		err := httpbakery.NewInteractionRequiredError(nil, req)
		err.SetInteraction("form", form.InteractionInfo{URL: formURL})
		return nil, err
	}

	tokenString := string(token.Value)
	username, ok := s.userTokens[tokenString]
	if token.Kind != "form" || !ok {
		return nil, fmt.Errorf("invalid token %#v", token)
	}

	_, _, err := checkers.ParseCaveat(string(info.Condition))
	if err != nil {
		return nil, fmt.Errorf("cannot parse caveat %q: %s", info.Condition, err)
	}

	return []checkers.Caveat{
		checkers.DeclaredCaveat("username", username),
	}, nil
}

func (s *authService) formHandler(w http.ResponseWriter, req *http.Request) {
	s.LogRequest(req)
	switch req.Method {
	case "GET":
		httprequest.WriteJSON(w, http.StatusOK, schemaResponse)
	case "POST":
		params := httprequest.Params{
			Response: w,
			Request:  req,
			Context:  context.TODO(),
		}
		loginRequest := form.LoginRequest{}
		if err := httprequest.Unmarshal(params, &loginRequest); err != nil {
			s.bakeryFail(w, "can't unmarshal login request")
			return
		}

		form, err := fieldsChecker.Coerce(loginRequest.Body.Form, nil)
		if err != nil {
			s.bakeryFail(w, "invalid login form data: %v", err)
			return
		}

		if !s.Checker.Check(form) {
			s.bakeryFail(w, "invalid credentials")
			return
		}

		username := form.(map[string]interface{})["username"].(string)
		token := s.getRandomToken()
		s.userTokens[token] = username

		loginResponse := loginResponse{
			Token: &httpbakery.DischargeToken{
				Kind:  "form",
				Value: []byte(token),
			},
		}
		httprequest.WriteJSON(w, http.StatusOK, loginResponse)

	default:
		s.Fail(w, http.StatusMethodNotAllowed, "%s method not allowed", req.Method)
		return
	}
}

func (s *authService) getRandomToken() string {
	uuid := make([]byte, 24)
	for i, b := range s.uuidGenerator.Next() {
		uuid[i] = b
	}
	return base64.StdEncoding.EncodeToString(uuid)
}

func (s *authService) bakeryFail(w http.ResponseWriter, msg string, args ...interface{}) {
	httpbakery.WriteError(context.TODO(), w, fmt.Errorf(msg, args...))
}


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.displayvideo.v2.model;

/**
 * Specifies how many days into the past to look when determining whether to record a conversion.
 *
 *
 This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the Display & Video 360 API. For a detailed explanation
 * see:
 * https://developers.google.com/api-client-library/java/google-http-java-client/json
 *

 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class LookbackWindow extends com.google.api.client.json.GenericJson {

  /**
   * Lookback window, in days, from the last time a given user clicked on one of your ads.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Integer clickDays;

  /**
   * Lookback window, in days, from the last time a given user viewed one of your ads.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Integer impressionDays;

  /**
   * Lookback window, in days, from the last time a given user clicked on one of your ads.
   * @return value or {@code null} for none
   */
  public java.lang.Integer getClickDays() {
    return clickDays;
  }

  /**
   * Lookback window, in days, from the last time a given user clicked on one of your ads.
   * @param clickDays clickDays or {@code null} for none
   */
  public LookbackWindow setClickDays(java.lang.Integer clickDays) {
    this.clickDays = clickDays;
    return this;
  }

  /**
   * Lookback window, in days, from the last time a given user viewed one of your ads.
   * @return value or {@code null} for none
   */
  public java.lang.Integer getImpressionDays() {
    return impressionDays;
  }

  /**
   * Lookback window, in days, from the last time a given user viewed one of your ads.
   * @param impressionDays impressionDays or {@code null} for none
   */
  public LookbackWindow setImpressionDays(java.lang.Integer impressionDays) {
    this.impressionDays = impressionDays;
    return this;
  }

  @Override
  public LookbackWindow set(String fieldName, Object value) {
    return (LookbackWindow) super.set(fieldName, value);
  }

  @Override
  public LookbackWindow clone() {
    return (LookbackWindow) super.clone();
  }

}


text:
package com.sequenceiq.redbeams.domain;

import com.sequenceiq.cloudbreak.auth.crn.Crn;

public interface RedbeamsResourceCrnAndNameView {

    String getName();

    Crn getResourceCrn();
}


text:
#import "CCRenderTexture.h"
#import "CCDirector.h"
#import "ccMacros.h"
#import "CCGLProgram.h"
#import "ccGLStateCache.h"
#import "CCConfiguration.h"
#import "Support/ccUtils.h"
#import "Support/CCFileUtils.h"

#if __CC_PLATFORM_MAC
#import <ApplicationServices/ApplicationServices.h>
#endif

// extern
#import "matrix.h"

@implementation CCRenderTexture

@synthesize sprite=sprite_;

+(id)renderTextureWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat) format depthStencilFormat:(GLuint)depthStencilFormat
{
  return [[[self alloc] initWithWidth:w height:h pixelFormat:format depthStencilFormat:depthStencilFormat] autorelease];
}

// issue #994
+(id)renderTextureWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat) format
{
	return [[[self alloc] initWithWidth:w height:h pixelFormat:format] autorelease];
}

+(id)renderTextureWithWidth:(int)w height:(int)h
{
	return [[[self alloc] initWithWidth:w height:h pixelFormat:kCCTexture2DPixelFormat_RGBA8888 depthStencilFormat:0] autorelease];
}

-(id)initWithWidth:(int)w height:(int)h
{
	return [self initWithWidth:w height:h pixelFormat:kCCTexture2DPixelFormat_RGBA8888];
}

- (id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat)format
{
  return [self initWithWidth:w height:h pixelFormat:format depthStencilFormat:0];
}

-(id)initWithWidth:(int)w height:(int)h pixelFormat:(CCTexture2DPixelFormat) format depthStencilFormat:(GLuint)depthStencilFormat
{
	if ((self = [super init]))
	{
		NSAssert(format != kCCTexture2DPixelFormat_A8,@"only RGB and RGBA formats are valid for a render texture");

		CCDirector *director = [CCDirector sharedDirector];

		// XXX multithread
		if( [director runningThread] != [NSThread currentThread] )
			CCLOGWARN(@"cocos2d: WARNING. CCRenderTexture is running on its own thread. Make sure that an OpenGL context is being used on this thread!");

		w *= CC_CONTENT_SCALE_FACTOR();
		h *= CC_CONTENT_SCALE_FACTOR();

		glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO_);

		// textures must be power of two
		NSUInteger powW;
		NSUInteger powH;

		if( [[CCConfiguration sharedConfiguration] supportsNPOT] ) {
			powW = w;
			powH = h;
		} else {
			powW = ccNextPOT(w);
			powH = ccNextPOT(h);
		}

		void *data = malloc((int)(powW * powH * 4));
		memset(data, 0, (int)(powW * powH * 4));
		pixelFormat_=format;

		texture_ = [[CCTexture2D alloc] initWithData:data pixelFormat:pixelFormat_ pixelsWide:powW pixelsHigh:powH contentSize:CGSizeMake(w, h)];
		free( data );

		GLint oldRBO;
		glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO);

		// generate FBO
		glGenFramebuffers(1, &fbo_);
		glBindFramebuffer(GL_FRAMEBUFFER, fbo_);

		// associate texture with FBO
		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_.name, 0);

		if (depthStencilFormat != 0) {
			//create and attach depth buffer
			glGenRenderbuffers(1, &depthRenderBufffer_);
			glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBufffer_);
			glRenderbufferStorage(GL_RENDERBUFFER, depthStencilFormat, (GLsizei)powW, (GLsizei)powH);
			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBufffer_);

			// if depth format is the one with stencil part, bind same render buffer as stencil attachment
			if (depthStencilFormat == CC_GL_DEPTH24_STENCIL8)
				glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthRenderBufffer_);
		}

		// check if it worked (probably worth doing :) )
		NSAssert( glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, @"Could not attach texture to framebuffer");

		[texture_ setAliasTexParameters];

		sprite_ = [CCSprite spriteWithTexture:texture_];

		[texture_ release];
		[sprite_ setScaleY:-1];
		[self addChild:sprite_];

		// issue #937
		[sprite_ setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];

		glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
		glBindFramebuffer(GL_FRAMEBUFFER, oldFBO_);
	}
	return self;
}

-(void)dealloc
{
	glDeleteFramebuffers(1, &fbo_);
	if (depthRenderBufffer_)
		glDeleteRenderbuffers(1, &depthRenderBufffer_);

	[super dealloc];
}

-(void)begin
{
	CCDirector *director = [CCDirector sharedDirector];

	// Save the current matrix
	kmGLPushMatrix();

	CGSize texSize = [texture_ contentSizeInPixels];

	// Calculate the adjustment ratios based on the old and new projections
	CGSize size = [director winSizeInPixels];
	float widthRatio = size.width / texSize.width;
	float heightRatio = size.height / texSize.height;

	// Adjust the orthographic projection and viewport
	glViewport(0, 0, texSize.width, texSize.height );

	kmMat4 orthoMatrix;
	kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio,  (float)1.0 / widthRatio,
								 (float)-1.0 / heightRatio, (float)1.0 / heightRatio, -1,1 );
	kmGLMultMatrix(&orthoMatrix);

	glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO_);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
}

-(void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)a
{
	[self begin];

	// save clear color
	GLfloat	clearColor[4];
	glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor);

	glClearColor(r, g, b, a);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// restore clear color
	glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
}

-(void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)a depth:(float)depthValue
{
  [self begin];

  // save clear color
  GLfloat	clearColor[4];
  GLfloat depthClearValue;
  glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor);
  glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue);

  glClearColor(r, g, b, a);
  glClearDepth(depthValue);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  // restore clear color
  glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
  glClearDepth(depthClearValue);
}

-(void)beginWithClear:(float)r g:(float)g b:(float)b a:(float)a depth:(float)depthValue stencil:(int)stencilValue
{
  [self begin];

  // save clear color
  GLfloat	clearColor[4];
  GLfloat depthClearValue;
  int stencilClearValue;
  glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor);
  glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue);
  glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue);

  glClearColor(r, g, b, a);
  glClearDepth(depthValue);
  glClearStencil(stencilValue);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

  // restore clear color
  glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
  glClearDepth(depthClearValue);
  glClearStencil(stencilClearValue);
}

-(void)end
{
	CCDirector *director = [CCDirector sharedDirector];

	glBindFramebuffer(GL_FRAMEBUFFER, oldFBO_);

	kmGLPopMatrix();

	CGSize size = [director winSizeInPixels];

	// restore viewport
	glViewport(0, 0, size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() );

	// special viewport for 3d projection + retina display
	if ( director.projection == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1 )
		glViewport(-size.width/2, -size.height/2, size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() );

	[director setProjection:director.projection];
}

-(void)clear:(float)r g:(float)g b:(float)b a:(float)a
{
	[self beginWithClear:r g:g b:b a:a];
	[self end];
}

- (void)clearDepth:(float)depthValue
{
  [self begin];
  //! save old depth value
  GLfloat depthClearValue;
  glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue);

  glClearDepth(depthValue);
  glClear(GL_DEPTH_BUFFER_BIT);

  // restore clear color
  glClearDepth(depthClearValue);
  [self end];
}

- (void)clearStencil:(int)stencilValue
{
  // save old stencil value
  int stencilClearValue;
  glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue);

  glClearStencil(stencilValue);
  glClear(GL_STENCIL_BUFFER_BIT);

  // restore clear color
  glClearStencil(stencilClearValue);
}

#pragma mark RenderTexture - Save Image

-(CGImageRef) newCGImage
{
    NSAssert(pixelFormat_ == kCCTexture2DPixelFormat_RGBA8888,@"only RGBA8888 can be saved as image");

	CGSize s = [texture_ contentSizeInPixels];
	int tx = s.width;
	int ty = s.height;

	int bitsPerComponent			= 8;
    int bitsPerPixel                = 4 * 8;
    int bytesPerPixel               = bitsPerPixel / 8;
	int bytesPerRow					= bytesPerPixel * tx;
	NSInteger myDataLength			= bytesPerRow * ty;

	GLubyte *buffer	= calloc(myDataLength,1);
	GLubyte *pixels	= calloc(myDataLength,1);

	if( ! (buffer && pixels) ) {
		CCLOG(@"cocos2d: CCRenderTexture#getCGImageFromBuffer: not enough memory");
		free(buffer);
		free(pixels);
		return nil;
	}

	[self begin];

	glReadPixels(0,0,tx,ty,GL_RGBA,GL_UNSIGNED_BYTE, buffer);

	[self end];

	// make data provider with data.

	CGBitmapInfo bitmapInfo	= kCGImageAlphaPremultipliedLast | kCGBitmapByteOrderDefault;
	CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer, myDataLength, NULL);
	CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
	CGImageRef iref	= CGImageCreate(tx, ty,
									bitsPerComponent, bitsPerPixel, bytesPerRow,
									colorSpaceRef, bitmapInfo, provider,
									NULL, false,
									kCGRenderingIntentDefault);

	CGContextRef context = CGBitmapContextCreate(pixels, tx,
												 ty, CGImageGetBitsPerComponent(iref),
												 CGImageGetBytesPerRow(iref), CGImageGetColorSpace(iref),
												 bitmapInfo);

	// vertically flipped
	if( YES ) {
		CGContextTranslateCTM(context, 0.0f, ty);
		CGContextScaleCTM(context, 1.0f, -1.0f);
	}
	CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, tx, ty), iref);
	CGImageRef image = CGBitmapContextCreateImage(context);

	CGImageRelease(iref);
	CGContextRelease(context);
	CGColorSpaceRelease(colorSpaceRef);
	CGDataProviderRelease(provider);

	free(pixels);
	free(buffer);

	return image;
}

-(BOOL) saveToFile:(NSString*)name
{
	return [self saveToFile:name format:kCCImageFormatJPEG];
}

-(BOOL)saveToFile:(NSString*)fileName format:(tCCImageFormat)format
{
	BOOL success;

	NSString *fullPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:fileName];

	CGImageRef imageRef = [self newCGImage];

	if( ! imageRef ) {
		CCLOG(@"cocos2d: Error: Cannot create CGImage ref from texture");
		return NO;
	}

#if __CC_PLATFORM_IOS

	UIImage* image	= [[UIImage alloc] initWithCGImage:imageRef scale:CC_CONTENT_SCALE_FACTOR() orientation:UIImageOrientationUp];
	NSData *imageData;

	if( format == kCCImageFormatPNG )
		imageData = UIImagePNGRepresentation( image );

	else if( format == kCCImageFormatJPEG )
		imageData = UIImageJPEGRepresentation(image, 0.9f);

	else
		NSAssert(NO, @"Unsupported format");

	[image release];

	success = [imageData writeToFile:fullPath atomically:YES];

#elif __CC_PLATFORM_MAC

	CFURLRef url = (CFURLRef)[NSURL fileURLWithPath:fullPath];

	CGImageDestinationRef dest;

	if( format == kCCImageFormatPNG )
		dest = 	CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL);

	else if( format == kCCImageFormatJPEG )
		dest = 	CGImageDestinationCreateWithURL(url, kUTTypeJPEG, 1, NULL);

	else
		NSAssert(NO, @"Unsupported format");

	CGImageDestinationAddImage(dest, imageRef, nil);

	success = CGImageDestinationFinalize(dest);

	CFRelease(dest);
#endif

	CGImageRelease(imageRef);

	if( ! success )
		CCLOG(@"cocos2d: ERROR: Failed to save file:%@ to disk",fullPath);

	return success;
}

#if __CC_PLATFORM_IOS

-(UIImage *) getUIImage
{
	CGImageRef imageRef = [self newCGImage];

	UIImage* image	= [[UIImage alloc] initWithCGImage:imageRef scale:CC_CONTENT_SCALE_FACTOR() orientation:UIImageOrientationUp];

	CGImageRelease( imageRef );

	return [image autorelease];
}
#endif // __CC_PLATFORM_IOS
@end


text:
import { IViewModelCreatorService, ViewModelCreatorService } from './../../logofx/view-model';
import { DocumentsList } from './documentslist';
import { DataService } from './../../model/implementation';
import { inject } from 'aurelia-framework';

@inject(ViewModelCreatorService)
export class DocumentsApprovalScreen {

    _myList: DocumentsList;
    scale: number = 0.8;

    constructor(private _viewModelCreatorService: IViewModelCreatorService) {
        //console.log('DocumentsApprovalScreen.ctor. _vmcs = ' + _vmcs);
    }

    bind() {
        this._myList = this._viewModelCreatorService.create<DocumentsList>(DocumentsList);
        //console.log('ViewModel is ' + this._myList.list.length.toString());
        //setTimeout(() => {this.scale = 0.8}, 2000);
    }

    attached() {
        //this.scale = 0.8;
    //    setTimeout(() => {this.scale = 0.2}, 200);
    //    setTimeout(() => {this.scale = 0.3}, 400);
    //    setTimeout(() => {this.scale = 0.4}, 600);
    //    setTimeout(() => {this.scale = 0.5}, 800);
    //    setTimeout(() => {this.scale = 0.6}, 1000);
    //    setTimeout(() => {this.scale = 0.7}, 1200);
       //setTimeout(() => {this.scale = 0.8}, 1400);

    }

    get list(): DocumentsList {
        return this._myList;
    }
}


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.machinelearning.models;

import com.azure.core.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Target lags rolling window determined automatically. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "mode")
@JsonTypeName("Auto")
@Immutable
public final class AutoTargetRollingWindowSize extends TargetRollingWindowSize {
    /** Creates an instance of AutoTargetRollingWindowSize class. */
    public AutoTargetRollingWindowSize() {
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
    }
}