text:
package com.github.haixing_hu.bean;

import java.util.List;
import java.util.Set;

import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * The interface for beans.
 *

 * This interface provides a uniform way to access the descriptors of a bean.
 * Although we could access the descriptors of a bean through reflections, there
 * are still some situations that we need a uniform way to access the
 * descriptors of beans.
 *

 * For example, suppose we have a {@code Article} class, which consists of a
 * list of {@code Field} objects. Each {@code Field} has a unique name. We want
 * to access a {@code Field} of a {@code Article} by the field's name, as if the
 * document has a property with that name. The {@link Bean} interface provides
 * getter and setter functions to access the internal property of a
 * {@code Article}, as well as the internal descriptors of the {@code Article}.
 *

 * A {@link Bean} object can also be used with the {@link PropertyExpression}.
 *

 * NOTE: the implementation of this interface does not have to be
 * thread-safe.
 *
 * @author Haixing Hu
 */
@NotThreadSafe
public interface Bean {

  /**
   * Gets the {@link BeanClass} instance that describes the set of descriptors
   * available for this {@link Bean}.
   *
   * @return the {@link BeanClass} instance that describes the set of
   *         descriptors available for this {@link Bean}.
   */
  BeanClass getBeanClass();

  /**
   * Gets a property.
   *
   * @param name
   *          the name of the property to be get.
   * @return the property with the specified name, or {@code null} if there is
   *         no such property.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  Property getProperty(String name);

  /**
   * Gets the value of a simple property.
   *
   * @param name
   *          the name of a simple property.
   * @return the value of the simple property with the specified name, which
   *         could be {@code null}, depending on the implementation.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not a simple property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  Object get(String name);

  /**
   * Sets the value of a simple property.
   *
   * @param name
   *          the name of a simple property.
   * @param value
   *          the value to be set to the simple property with the specified
   *          name, which could be {@code null}, depending on the
   *          implementation.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not a simple property.
   * @throws ClassCastException
   *           if the type of the provided value does not match the type of the
   *           specified property.
   * @throws NullPointerException
   *           if attempt to set a primitive property to {@code null}.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  void set(String name, @Nullable Object value);

  /**
   * Gets the size of an indexed property or a mapped property.
   *
   * @param name
   *          the name of an indexed or mapped property.
   * @return the size (number of values) of the indexed or mapped property.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not an indexed property nor a mapped
   *           property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  int getSize(String name);

  /**
   * Gets the value at the specified index of an indexed property.
   *
   * @param name
   *          the name of an indexed property.
   * @param index
   *          the index of the value to be retrieved.
   * @return the value at the specified index of the indexed property with the
   *         specified name, which could be {@code null}, depending on the
   *         implementation.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not an indexed property.
   * @throws IndexOutOfBoundsException
   *           if the {@code index} is outside the range of the indexed
   *           property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  Object get(String name, int index);

  /**
   * Sets the value at the specified index of an indexed property.
   *
   * @param name
   *          the name of an indexed property.
   * @param index
   *          the index of the value to set.
   * @param value
   *          the value to be set to specified index at the index property with
   *          the specified name, which could be {@code null}, depending on the
   *          implementation.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not an indexed property.
   * @throws IndexOutOfBoundsException
   *           if the {@code index} is outside the range of the indexed
   *           property.
   * @throws ClassCastException
   *           if the type of the provided value does not match the type of the
   *           specified property.
   * @throws NullPointerException
   *           if attempt to set a primitive property to {@code null}.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  void set(String name, int index, @Nullable Object value);

  /**
   * Inserts a value at the specified index of an indexed property.
   *
   * @param name
   *          the name of an indexed property.
   * @param index
   *          the index where the value to be inserted.
   * @param value
   *          the value to be inserted to specified index of the indexed
   *          property with the specified name, which could be {@code null},
   *          depending on the implementation.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not an indexed property.
   * @throws IndexOutOfBoundsException
   *           if the {@code index} is outside the range of the indexed
   *           property.
   * @throws ClassCastException
   *           if the type of the provided value does not match the type of this
   *           property.
   * @throws NullPointerException
   *           if attempt to set a primitive property to {@code null}.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  void add(String name, int index, @Nullable Object value);

  /**
   * Adds a value at the end of an indexed property.
   *
   * @param name
   *          the name of an indexed property.
   * @param value
   *          the value to be added to the end of the indexed property with the
   *          specified name, which could be {@code null}, depending on the
   *          implementation.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not an indexed property.
   * @throws ClassCastException
   *           if the type of the provided value does not match the type of this
   *           property.
   * @throws NullPointerException
   *           if attempt to set a primitive property to {@code null}.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  void add(String name, @Nullable Object value);

  /**
   * Removes a value at the specified position from an indexed property.
   *

   * Note that the removing operation will shift the subsequent values to the
   * left, as described by {@link List#remove(int)}.
   *
   * @param name
   *          the name of an indexed property.
   * @param index
   *          the index of the value to be removed.
   * @return the value at the specified index that was removed from the indexed
   *         property with the specified name, which may be {@code null} ,
   *         depending on the implementation.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not an indexed property.
   * @throws IndexOutOfBoundsException
   *           if the {@code index} is outside the range of the indexed
   *           property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  Object remove(String name, int index);

  /**
   * Gets the key set of a mapped property.
   *
   * @param name
   *          the name of a mapped property.
   * @return the key set of the mapped property.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not a mapped property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  Set<String> getKeySet(String name);

  /**
   * Tests whether a mapped property contains the specified key.
   *
   * @param name
   *          the name of a mapped property.
   * @param key
   *          the key to check.
   * @return {@code true} if the mapped property with the specified name
   *         contains the specified key; {@code false} otherwise.
   * @throws NullPointerException
   *           if {@code name} or {@code key} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not a mapped property.
   * @throws ReflectionException
   *           if any error occurs during the reflection operation.
   */
  boolean containsKey(String name, String key);

  /**
   * Gets the value corresponds to a specified key of a mapped property.
   *
   * @param name
   *          the name of a mapped property.
   * @param key
   *          the key of the value to be retrieved.
   * @return the value corresponds to the specified key of the mapped property
   *         with the specified name, which could be {@code null}, depending on
   *         the implementation.
   * @throws NullPointerException
   *           if {@code name} or {@code key} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not a mapped property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  Object get(String name, String key);

  /**
   * Sets the value corresponds to the specified key of a mapped property.
   *
   * @param name
   *          the name of a mapped property.
   * @param key
   *          the key corresponds to the value to set.
   * @param value
   *          the value to be set corresponds to the specified key in the mapped
   *          property with the specified name, which could be {@code null},
   *          depending on the implementation.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not a mapped property.
   * @throws ClassCastException
   *           if the type of the provided value does not match the type of the
   *           specified property.
   * @throws NullPointerException
   *           if {@code name} or {@code key} is {@code null}.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  void set(String name, String key, @Nullable Object value);

  /**
   * Removes a value corresponds to a specified key from a mapped property.
   *
   * @param name
   *          the name of a mapped property.
   * @param key
   *          the key corresponds to the value to be removed.
   * @return the value corresponds to the specified key that was removed from
   *         the mapped property with the specified name; or {@code null} if
   *         there is no value corresponds to the specified key in the mapped
   *         property.
   * @throws NullPointerException
   *           if {@code name} or {@code key} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not a mapped property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  Object remove(String name, String key);

  /**
   * Clears all values of an indexed or mapped property.
   *
   * @param name
   *          the name of a indexed or mapped property.
   * @throws NullPointerException
   *           if {@code name} is {@code null}.
   * @throws PropertyNotExistException
   *           if the specified property does not exist.
   * @throws InvalidPropertyKindException
   *           if the specified property is not an indexed property nor a mapped
   *           property.
   * @throws ReflectionException
   *           if any other error occurs during the reflection operation.
   */
  void clear(String name);
}


text:
package liquibase.database.core;

import liquibase.database.AbstractDatabase;
import liquibase.database.DatabaseConnection;
import liquibase.exception.DatabaseException;
import liquibase.exception.DateParseException;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class DB2Database extends AbstractDatabase {

    public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException {
        return conn.getDatabaseProductName().startsWith("DB2");
    }

    public String getDefaultDriver(String url) {
        if (url.startsWith("jdbc:db2")) {
            return "com.ibm.db2.jcc.DB2Driver";
        }
        return null;
    }

    public int getPriority() {
        return PRIORITY_DEFAULT;
    }

    public String getTypeName() {
        return "db2";
    }

    @Override
    protected String getDefaultDatabaseSchemaName() throws DatabaseException {//NOPMD
        return super.getDefaultDatabaseSchemaName().toUpperCase();
    }

    public boolean supportsInitiallyDeferrableColumns() {
        return false;
    }

    public String getCurrentDateTimeFunction() {
        if (currentDateTimeFunction != null) {
            return currentDateTimeFunction;
        }

        return "CURRENT TIMESTAMP";
    }

    /**
     * Return an DB2 date literal with the same value as a string formatted using ISO 8601.
     *

     * Convert an ISO8601 date string to one of the following results:
     * to_date('1995-05-23', 'YYYY-MM-DD')
     * to_date('1995-05-23 09:23:59', 'YYYY-MM-DD HH24:MI:SS')
     *

     * Implementation restriction:
     * Currently, only the following subsets of ISO8601 are supported:
     * YYYY-MM-DD
     * hh:mm:ss
     * YYYY-MM-DDThh:mm:ss
     */
    @Override
    public String getDateLiteral(String isoDate) {
        String normalLiteral = super.getDateLiteral(isoDate);

        if (isDateOnly(isoDate)) {
            StringBuffer val = new StringBuffer();
            val.append("DATE(");
            val.append(normalLiteral);
            val.append(')');
            return val.toString();
        } else if (isTimeOnly(isoDate)) {
            StringBuffer val = new StringBuffer();
            val.append("TIME(");
            val.append(normalLiteral);
            val.append(')');
            return val.toString();
        } else if (isDateTime(isoDate)) {
            StringBuffer val = new StringBuffer();
            val.append("TIMESTAMP(");
            val.append(normalLiteral);
            val.append(')');
            return val.toString();
        } else {
            return "UNSUPPORTED:" + isoDate;
        }
    }

    @Override
    public boolean shouldQuoteValue(String value) {
        return super.shouldQuoteValue(value)
                && !value.startsWith("\"SYSIBM\"");
    }

    public boolean supportsTablespaces() {
        return true;
    }

    @Override
    public String getViewDefinition(String schemaName, String name) throws DatabaseException {
        return super.getViewDefinition(schemaName, name).replaceFirst("CREATE VIEW \\w+ AS ", ""); //db2 returns "create view....as select
    }

    @Override
    public java.util.Date parseDate(String dateAsString) throws DateParseException {
        try {
            if (dateAsString.indexOf(' ') > 0) {
                return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateAsString);
            } else if (dateAsString.indexOf('.') > 0 && dateAsString.indexOf('-') > 0) {
                return new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSSSSS").parse(dateAsString);

            } else {
                if (dateAsString.indexOf(':') > 0) {
                    return new SimpleDateFormat("HH:mm:ss").parse(dateAsString);
                } else if (dateAsString.indexOf('.') > 0) {
                    return new SimpleDateFormat("HH.mm.ss").parse(dateAsString);
                } else {
                    return new SimpleDateFormat("yyyy-MM-dd").parse(dateAsString);
                }
            }
        } catch (ParseException e) {
            throw new DateParseException(dateAsString);
        }
    }

    @Override
    public String convertRequestedSchemaToSchema(String requestedSchema) throws DatabaseException {
        if (requestedSchema == null) {
            return getDefaultDatabaseSchemaName();
        } else {
            return requestedSchema.toUpperCase();
        }
    }

    @Override
    public String convertRequestedSchemaToCatalog(String requestedSchema) throws DatabaseException {
        return null;
    }

    @Override
    public String generatePrimaryKeyName(String tableName) {
        if (tableName.equals(getDatabaseChangeLogTableName())) {
            tableName = "DbChgLog".toUpperCase();
        } else if (tableName.equals(getDatabaseChangeLogLockTableName())) {
            tableName = "DbChgLogLock".toUpperCase();
        }

        String pkName = super.generatePrimaryKeyName(tableName);
        if (pkName.length() > 18) {
            pkName = pkName.substring(0, 17);
        }
        return pkName;
    }

    @Override
    public String escapeIndexName(String schemaName, String indexName) {
        // does not support the schema name for the index -
        return super.escapeIndexName(null, indexName);
    }

}

redpajama_set_name: RedPajamaGithub


text:
layout: post
id: the-art-of-hiring-good-engineers
title: "The Art of Hiring Good Engineers"
date: 2017-10-04 07:30:00
authors: [rachel-lee]
categories: [Engineering]
tags: [Hiring]
comments: true
cover_photo: /img/the-art-of-hiring-good-engineers/cover.jpg
excerpt: "Hiring the first five good engineers in your team requires a different approach to hiring the first twenty good engineers. The approach to designing this process will be even more different, when you want to hire to scale up to a 100 Engineers... or even to 300."
---

![cover](/img/the-art-of-hiring-good-engineers/cover.jpg)

Hiring the first five good engineers in your team requires a different approach to hiring the first twenty good engineers. The approach to designing this process will be even more different, when you want to hire to scale up to a 100 engineers... or even to 300.

Should you start from the top hires?

Or should you start from hiring a few really good engineers and then help them to scale?

This post covers some concepts on designing efficient, useful processes to help Tech Leads who are actively involved in building fast-growing Engineering teams from scratch. This post may also be useful for people working in super niche fields who want to build and scale Engineering teams for continued growth.

### Start Small

There is never only one way to start building a team of good engineers. Many of the mobile apps we use daily today, are known for having small teams of good engineers who built great products:

* WhatsApp finished building their initial product with 32 engineers

* Skype's product was built by 5 engineers

* Instagram's first team only had 13 employees in total

> Your small team of good engineers should be ready to fight every day for the right to be a player in the market where you are.

They will need to be more eager, more hungry, and more consumer minded than others. They will need to always fight for the right to be a player in that market. To fight off the big guys, sometimes the good engineer needs to be battle-worn, battle-tried.

The battle-tried good engineer has faced many of the situations you too will face:

* How do you handle outages that cause the entire product to be down?

* How do you release a lot of features simultaneously without disrupting users?

![quote](/img/the-art-of-hiring-good-engineers/quote.jpg)

### Follow Existing Wisdom

Many of the top technology companies today have had great success in hiring good engineers. They do put in plenty of effort and research to design processes that work for bringing in hundreds of good engineers each year.

My recommendation to you would be to follow the wisdom of these best practices that have been adopted by the top companies.  Many of these processes are well documented and shared about on sites like Quora and Glassdoor. However, be mindful that there are weak points in these processes due to how top companies deal with volume.

> (Too many interviews + tests and coding assignment rounds) * too little human touch = bad design for hiring a team of good engineers

### Shatter Illusions

The illusion that there is always more good engineers out there.

When you have found a truly good engineer, he/she is simply irreplaceable. I believe this good engineer can help drive successful processes to help you hire 100 good engineers as I've personally witnessed this effort happen - and as they also carry great value in product knowledge, systems design, and design thinking, they will be able to exert an influence over their colleagues which, when lost, has an immeasurable impact on the internal culture.

![quote 2](/img/the-art-of-hiring-good-engineers/quote_2.jpg)

**The illusion that small teams can afford to not think about diversity.**

Don't forget about diversity, equality and inclusion. Even in small teams, diversity - this means hiring a good engineer coming from a completely different background from you and the other members - bring distinct advantages.

Remember to give everyone an equal chance to join your team by eliminating as many obvious biases as possible - and to understand inclusion, simply: when you invite someone 'different' to the party, make them feel like they are not only invited, but make them feel like they are really one of you! There's something to be said for teams that champion all three.

**Do a fast game, but not too fast though!**

If you bring in good engineers too fast and furious without a proper approach, some parts of the moving equation will prove to be detrimental to their success - if you are not setting them up for success, the good engineer will find it hard to match the fit prerogatives, and fail, fast. Being fast at hiring good engineers should not be the only success metric you hold yourself to.

### The Recipe so far

Start Small + Follow Existing Wisdom + Shatter Illusions + ... how about designing a process that works ?

Now, if you are ready to design your process, consider these 4 steps for designing a robust process.

#### Step 1: Make a REALLY Good List

If you do decide to only hire the top 2 - 5% good engineers with a relevant tech stack / industry expertise, understand that you are making your process 100 times harder. Sometimes this means that you have to process 500 profiles in order to hire 5 - 10 good engineers. This will take months at least, unless you have super resources.

Add to your list those good engineers who are open-source committers, top engineers from the leading technology companies who are in your location. Even if they do not join your team now, they will be able to recommend others - good engineers attract good engineers and these activities of yours will be discussed in engineering communities.

Once you have already recognised all profiles from LinkedIn, GitHub is the next battleground to look up.

#### Step 2: Determine Technical Fit

While I don't recommend the technical phone screen for every single engineering role (as cybersecurity and niche data engineering processes can be designed differently, frontend, full-stack and product or mobile engineering hiring can benefit from a process to review their portfolio and design thinking), most top companies assign tests as the pre-screening round that can be a timed coding test with relevancy, a technical phone screen, a recruiter screen for the role, scope, and culture fit or, a take-home assignment involving designing elements crucial for success in the role.

Most top companies design this first part to take 1-2 hours of the candidates' time initially, the phone screen can range from 20 minutes to 1.5 hours.

#### Step 3: Determine Culture and Team Fit Based off Group Interviews

The outcome you should look for is ideally for every one of your warriors to feel comfortable with fighting alongside this battle-ready good engineer. Misgivings and possible gaps can always be improved on while working on the product together.

Also, check if the good engineer can work well with others in Design, Product and Data functions as well as communicate reasonably well to someone outside your engineering organisation. Any HR or Recruitment professional can help check if the engineer possesses a few of these soft skills you need, such as communicating to stakeholders, business acumen or excitement in helping solve consumer issues. Don't skip this step!

#### Step 4: Optimise Your Process to 'Always Be Closing'

Most talent acquisition professionals abide by the 'always be closing' mantra - they are selective in the people they talk to and eventually feel proud to represent to top companies, they also choose the roles they want to focus on, usually these are the easier roles to fulfil, according to their expertise.

It could be a good idea to identify the members in your team who are really 'strict' interviewers, we call them 'bar-raisers' and only send the super strong profiles across to them. The normal profiles can be sent to other good engineers for interviewing, so as not to burn out the strict bar-raiser.

By following this method we can effectively predict the pipeline of candidates and expedite those who have passed well in the bar-raiser round. Always know your reasons for declining a candidate and always be involved in the interview rounds no matter how big your team gets. Your efforts will definitely be discussed by others, so it's also a good idea to frequently check in with peers, board members and technical advisors, especially if you find a senior candidate who had overlapping tenures with them. Your board and peers could provide useful information about this candidate or other interesting details that enable you to enhance your decision making process and improve your future hiring process as well.

If you did not manage to optimise your approach, a possible outcome is that you will be wasting valuable time of your existing Engineers. One hour spent in a bad interview is one hour less that could be spent on coding for your product.

I think it is a good idea to personally spend more time with all good engineer candidates on an informal basis, if you feel that the 1 hour or 1.5 hour session did not suffice to determine if he/she is a suitable hire.

Many good engineers will seem to possess all the right credentials but in the mid to long-term, there will always be some who are much better for your team.

### Final Thoughts

Aim for a flat structure, even if you get big one day. Companies like Facebook and Grab still try to keep their Engineering structure as flat as possible.

Company after company who rose to greatness often struggle with scale.

The first point to the last point of interaction is always important for the candidate experience. If you want to build a strong team from the first hire to the last, your branding is important.

Hire the really talented good engineer, and the rest will follow.

Ensure your small team still stands for diversity, equality and inclusion

Always be closing but don't forget to have fun: Your current challenge will always be to hire the people who really want to see you succeed!

[So You Need to Hire a Good Engineer](/so-you-need-to-hire-good-engineers)

Thank you for reading and please share some ideas for future inspiration, I love challenges!


text:
#pragma once

typedef struct {
  float  *vertices;
  size_t  bufferSize;
  size_t  vertexCount;
} math_BezierCurve;

void math_BezierCurve_new(math_BezierCurve* curve, float const* vertices, int vertexCount);
void math_BezierCurve_free(math_BezierCurve* curve);
void math_BezierCurve_evaluate(math_BezierCurve const* curve, float t, float *outX, float *outY);
float const* math_BezierCurve_getControlPoint(math_BezierCurve const* curve, int i);
int math_BezierCurve_getControlPointCount(math_BezierCurve const* curve);
int math_BezierCurve_getDegree(math_BezierCurve const* curve);
void math_BezierCurve_getDerivative(math_BezierCurve const* curve, math_BezierCurve *derivative);
void math_BezierCurve_insertControlPoint(math_BezierCurve *curve, int i, float x, float y);
float const* math_BezierCurve_render(math_BezierCurve const* curve, int depth, size_t *count);
void math_BezierCurve_rotate(math_BezierCurve *curve, float angle, float ox, float oy);
void math_BezierCurve_scale(math_BezierCurve *curve, float sx, float sy, float ox, float oy);
void math_BezierCurve_setControlPoint(math_BezierCurve *curve, int i, float x, float y);
void math_BezierCurve_translate(math_BezierCurve *curve, float x, float y);


text:
Fetches and caches counterparty asset information.

[![Build Status](https://travis-ci.org/tokenly/counterparty-asset-info-cache.svg?branch=master)](https://travis-ci.org/tokenly/counterparty-asset-info-cache)


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 org.flowable.task.service.impl;

import java.util.List;
import java.util.Objects;

import org.flowable.common.engine.impl.service.CommonServiceImpl;
import org.flowable.identitylink.service.HistoricIdentityLinkService;
import org.flowable.identitylink.api.IdentityLinkType;
import org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.HistoricTaskService;
import org.flowable.task.service.TaskServiceConfiguration;
import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntityManager;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.task.service.impl.util.CommandContextUtil;

/**
 * @author Tom Baeyens
 * @author Joram Barrez
 */
public class HistoricTaskServiceImpl extends CommonServiceImpl<TaskServiceConfiguration> implements HistoricTaskService {

    public HistoricTaskServiceImpl(TaskServiceConfiguration taskServiceConfiguration) {
        super(taskServiceConfiguration);
    }

    @Override
    public HistoricTaskInstanceEntity getHistoricTask(String id) {
        return getHistoricTaskInstanceEntityManager().findById(id);
    }

    @Override
    public List<HistoricTaskInstanceEntity> findHistoricTasksByParentTaskId(String parentTaskId) {
        return getHistoricTaskInstanceEntityManager().findHistoricTasksByParentTaskId(parentTaskId);
    }

    @Override
    public List<HistoricTaskInstanceEntity> findHistoricTasksByProcessInstanceId(String processInstanceId) {
        return getHistoricTaskInstanceEntityManager().findHistoricTasksByProcessInstanceId(processInstanceId);
    }

    @Override
    public List<HistoricTaskInstance> findHistoricTaskInstancesByQueryCriteria(HistoricTaskInstanceQueryImpl historicTaskInstanceQuery) {
        return getHistoricTaskInstanceEntityManager().findHistoricTaskInstancesByQueryCriteria(historicTaskInstanceQuery);
    }

    @Override
    public HistoricTaskInstanceEntity createHistoricTask() {
        return getHistoricTaskInstanceEntityManager().create();
    }

    @Override
    public HistoricTaskInstanceEntity createHistoricTask(TaskEntity taskEntity) {
        return getHistoricTaskInstanceEntityManager().create(taskEntity);
    }

    @Override
    public void updateHistoricTask(HistoricTaskInstanceEntity historicTaskInstanceEntity, boolean fireUpdateEvent) {
        getHistoricTaskInstanceEntityManager().update(historicTaskInstanceEntity, fireUpdateEvent);
    }

    @Override
    public void insertHistoricTask(HistoricTaskInstanceEntity historicTaskInstanceEntity, boolean fireCreateEvent) {
        getHistoricTaskInstanceEntityManager().insert(historicTaskInstanceEntity, fireCreateEvent);
    }

    @Override
    public void deleteHistoricTask(HistoricTaskInstanceEntity HistoricTaskInstance) {
        getHistoricTaskInstanceEntityManager().delete(HistoricTaskInstance);
    }

    @Override
    public HistoricTaskInstanceEntity recordTaskCreated(TaskEntity task) {
        HistoricTaskInstanceEntityManager historicTaskInstanceEntityManager = getHistoricTaskInstanceEntityManager();
        HistoricTaskInstanceEntity historicTaskInstanceEntity = historicTaskInstanceEntityManager.create(task);
        historicTaskInstanceEntityManager.insert(historicTaskInstanceEntity, true);
        return historicTaskInstanceEntity;
    }

    @Override
    public HistoricTaskInstanceEntity recordTaskEnd(TaskEntity task, String deleteReason) {
        HistoricTaskInstanceEntity historicTaskInstanceEntity = getHistoricTaskInstanceEntityManager().findById(task.getId());
        if (historicTaskInstanceEntity != null) {
            historicTaskInstanceEntity.markEnded(deleteReason);
        }
        return historicTaskInstanceEntity;
    }

    @Override
    public HistoricTaskInstanceEntity recordTaskInfoChange(TaskEntity taskEntity) {
        HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskInstanceEntityManager().findById(taskEntity.getId());
        if (historicTaskInstance != null) {
            historicTaskInstance.setName(taskEntity.getName());
            historicTaskInstance.setDescription(taskEntity.getDescription());
            historicTaskInstance.setDueDate(taskEntity.getDueDate());
            historicTaskInstance.setPriority(taskEntity.getPriority());
            historicTaskInstance.setCategory(taskEntity.getCategory());
            historicTaskInstance.setFormKey(taskEntity.getFormKey());
            historicTaskInstance.setParentTaskId(taskEntity.getParentTaskId());
            historicTaskInstance.setTaskDefinitionKey(taskEntity.getTaskDefinitionKey());
            historicTaskInstance.setProcessDefinitionId(taskEntity.getProcessDefinitionId());
            historicTaskInstance.setClaimTime(taskEntity.getClaimTime());
            historicTaskInstance.setLastUpdateTime(configuration.getClock().getCurrentTime());

            if (!Objects.equals(historicTaskInstance.getAssignee(), taskEntity.getAssignee())) {
                historicTaskInstance.setAssignee(taskEntity.getAssignee());
                createHistoricIdentityLink(historicTaskInstance.getId(), IdentityLinkType.ASSIGNEE, historicTaskInstance.getAssignee());
            }

            if (!Objects.equals(historicTaskInstance.getOwner(), taskEntity.getOwner())) {
                historicTaskInstance.setOwner(taskEntity.getOwner());
                createHistoricIdentityLink(historicTaskInstance.getId(), IdentityLinkType.OWNER, historicTaskInstance.getOwner());
            }
        }
        return historicTaskInstance;
    }

    protected void createHistoricIdentityLink(String taskId, String type, String userId) {
        HistoricIdentityLinkService historicIdentityLinkService =  CommandContextUtil.getHistoricIdentityLinkService();
        HistoricIdentityLinkEntity historicIdentityLinkEntity = historicIdentityLinkService.createHistoricIdentityLink();
        historicIdentityLinkEntity.setTaskId(taskId);
        historicIdentityLinkEntity.setType(type);
        historicIdentityLinkEntity.setUserId(userId);
        historicIdentityLinkEntity.setCreateTime(configuration.getClock().getCurrentTime());
        historicIdentityLinkService.insertHistoricIdentityLink(historicIdentityLinkEntity, false);
    }

    public HistoricTaskInstanceEntityManager getHistoricTaskInstanceEntityManager() {
        return configuration.getHistoricTaskInstanceEntityManager();
    }

}


text:
/*******************************************************************************
	parameterDialog.c

       Associated Header file: parameterDialog.h
*******************************************************************************/

#include <stdio.h>

#ifdef MOTIF
#include <Xm/Xm.h>
#include <Xm/MwmUtil.h>
#include <Xm/DialogS.h>
#include <Xm/MenuShell.h>
#endif /* MOTIF */

#include "UxXt.h"
#include <Xm/TextF.h>
#include <Xm/Label.h>
#include <Xm/Form.h>
#include <Xm/MessageB.h>

/*******************************************************************************
       Includes, Defines, and Global variables from the Declarations Editor:
*******************************************************************************/

#include <stdlib.h>

#ifndef DESIGN_TIME
#include "mainWS.h"
#endif

#include "mprintf.h"

extern swidget mainWS;

static	int _UxIfClassId;
int	UxparameterDialog_setRotation_Id = -1;
char*	UxparameterDialog_setRotation_Name = "setRotation";
int	UxparameterDialog_setWave_Id = -1;
char*	UxparameterDialog_setWave_Name = "setWave";
int	UxparameterDialog_setCentre_Id = -1;
char*	UxparameterDialog_setCentre_Name = "setCentre";
int	UxparameterDialog_setDistance_Id = -1;
char*	UxparameterDialog_setDistance_Name = "setDistance";
int	UxparameterDialog_setTilt_Id = -1;
char*	UxparameterDialog_setTilt_Name = "setTilt";

/*******************************************************************************
       The following header file defines the context structure.
*******************************************************************************/

#ifndef XKLOADDS
#define XKLOADDS
#endif /* XKLOADDS */

#define CONTEXT_MACRO_ACCESS 1
#include "parameterDialog.h"
#undef CONTEXT_MACRO_ACCESS

/*******************************************************************************
Declarations of methods
*******************************************************************************/

static void	_parameterDialog_setRotation( swidget UxThis, Environment * pEnv, double valueX, double valueY, double valueZ );
static void	_parameterDialog_setWave( swidget UxThis, Environment * pEnv, double value );
static void	_parameterDialog_setCentre( swidget UxThis, Environment * pEnv, double valX, double valY );
static void	_parameterDialog_setDistance( swidget UxThis, Environment * pEnv, double value );
static void	_parameterDialog_setTilt( swidget UxThis, Environment * pEnv, double value );

/*******************************************************************************
       The following are method functions.
*******************************************************************************/

static void	Ux_setRotation( swidget UxThis, Environment * pEnv, double valueX, double valueY, double valueZ )
{
	sprintf (textBuf, "%8.2f", valueX);
	XmTextFieldSetString (UxGetWidget (detectorRotText), textBuf);
	sprintf (textBuf, "%8.2f", valueY);
	XmTextFieldSetString (UxGetWidget (detectorTwistText), textBuf);
	sprintf (textBuf, "%8.2f", valueZ);
	XmTextFieldSetString (UxGetWidget (detectorTiltText), textBuf);
}

static void	_parameterDialog_setRotation( swidget UxThis, Environment * pEnv, double valueX, double valueY, double valueZ )
{
	_UxCparameterDialog     *UxSaveCtx = UxParameterDialogContext;

	UxParameterDialogContext = (_UxCparameterDialog *) UxGetContext( UxThis );
	if (pEnv)
		pEnv->_major = NO_EXCEPTION;
	Ux_setRotation( UxThis, pEnv, valueX, valueY, valueZ );
	UxParameterDialogContext = UxSaveCtx;
}

static void	Ux_setWave( swidget UxThis, Environment * pEnv, double value )
{
	sprintf (textBuf, "%6.4f", value);
	XmTextFieldSetString (UxGetWidget (waveText), textBuf);
}

static void	_parameterDialog_setWave( swidget UxThis, Environment * pEnv, double value )
{
	_UxCparameterDialog     *UxSaveCtx = UxParameterDialogContext;

	UxParameterDialogContext = (_UxCparameterDialog *) UxGetContext( UxThis );
	if (pEnv)
		pEnv->_major = NO_EXCEPTION;
	Ux_setWave( UxThis, pEnv, value );
	UxParameterDialogContext = UxSaveCtx;
}

static void	Ux_setCentre( swidget UxThis, Environment * pEnv, double valX, double valY )
{
	sprintf (textBuf, "%6.1f", valX);
	XmTextFieldSetString (UxGetWidget (centreXText), textBuf);
	sprintf (textBuf, "%6.1f", valY);
	XmTextFieldSetString (UxGetWidget (centreYText), textBuf);
}

static void	_parameterDialog_setCentre( swidget UxThis, Environment * pEnv, double valX, double valY )
{
	_UxCparameterDialog     *UxSaveCtx = UxParameterDialogContext;

	UxParameterDialogContext = (_UxCparameterDialog *) UxGetContext( UxThis );
	if (pEnv)
		pEnv->_major = NO_EXCEPTION;
	Ux_setCentre( UxThis, pEnv, valX, valY );
	UxParameterDialogContext = UxSaveCtx;
}

static void	Ux_setDistance( swidget UxThis, Environment * pEnv, double value )
{
	sprintf (textBuf, "%8.1f", value);
	XmTextFieldSetString (UxGetWidget (distanceText), textBuf);
}

static void	_parameterDialog_setDistance( swidget UxThis, Environment * pEnv, double value )
{
	_UxCparameterDialog     *UxSaveCtx = UxParameterDialogContext;

	UxParameterDialogContext = (_UxCparameterDialog *) UxGetContext( UxThis );
	if (pEnv)
		pEnv->_major = NO_EXCEPTION;
	Ux_setDistance( UxThis, pEnv, value );
	UxParameterDialogContext = UxSaveCtx;
}

static void	Ux_setTilt( swidget UxThis, Environment * pEnv, double value )
{
	sprintf (textBuf, "%8.2f", value);
	XmTextFieldSetString (UxGetWidget (specimenTiltText), textBuf);
}

static void	_parameterDialog_setTilt( swidget UxThis, Environment * pEnv, double value )
{
	_UxCparameterDialog     *UxSaveCtx = UxParameterDialogContext;

	UxParameterDialogContext = (_UxCparameterDialog *) UxGetContext( UxThis );
	if (pEnv)
		pEnv->_major = NO_EXCEPTION;
	Ux_setTilt( UxThis, pEnv, value );
	UxParameterDialogContext = UxSaveCtx;
}

/*******************************************************************************
       The following are callback functions.
*******************************************************************************/

static void  cancelCB_parameterDialog(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	{
#include "parameterDialog_applyCB.c"
	}
	UxParameterDialogContext = UxSaveCtx;
}

static void  helpCB_parameterDialog(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	{
	waveChanged = distanceChanged = centreChanged = rotationChanged = tiltChanged = False;
	UxPopdownInterface (UxThisWidget);
	}
	UxParameterDialogContext = UxSaveCtx;
}

static void  okCallback_parameterDialog(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	{
#include "parameterDialog_applyCB.c"
	UxPopdownInterface (UxThisWidget);
	}
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_waveText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	{
	waveChanged = True;
	}
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_distanceText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	distanceChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_centreXText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	centreChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_centreYText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	centreChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_detectorRotText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	rotationChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_detectorTwistText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	rotationChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_detectorTiltText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	rotationChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_specimenTiltText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	tiltChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

static void  valueChangedCB_calibrationText(
			Widget wgt,
			XtPointer cd,
			XtPointer cb)
{
	_UxCparameterDialog     *UxSaveCtx, *UxContext;
	Widget                  UxWidget = wgt;
	XtPointer               UxClientData = cd;
	XtPointer               UxCallbackArg = cb;

	UxSaveCtx = UxParameterDialogContext;
	UxParameterDialogContext = UxContext =
			(_UxCparameterDialog *) UxGetContext( UxWidget );
	calibrationChanged = True;
	UxParameterDialogContext = UxSaveCtx;
}

/*******************************************************************************
       The 'build_' function creates all the widgets
       using the resource values specified in the Property Editor.
*******************************************************************************/

static Widget	_Uxbuild_parameterDialog()
{
	Widget		_UxParent;

	/* Creation of parameterDialog */
	_UxParent = UxParent;
	if ( _UxParent == NULL )
	{
		_UxParent = UxTopLevel;
	}

	_UxParent = XtVaCreatePopupShell( "parameterDialog_shell",
			xmDialogShellWidgetClass, _UxParent,
			XmNheight, 400,
			XmNshellUnitType, XmPIXELS,
			XmNtitle, "parameterDialog",
			NULL );

	parameterDialog = XtVaCreateWidget( "parameterDialog",
			xmMessageBoxWidgetClass,
			_UxParent,
			XmNheight, 400,
			XmNdialogType, XmDIALOG_TEMPLATE,
			XmNunitType, XmPIXELS,
			RES_CONVERT( XmNcancelLabelString, "Apply" ),
			RES_CONVERT( XmNokLabelString, "OK" ),
			RES_CONVERT( XmNdialogTitle, "Parameter Editor" ),
			RES_CONVERT( XmNhelpLabelString, "Cancel" ),
			XmNautoUnmanage, FALSE,
			XmNmarginHeight, 5,
			XmNmarginWidth, 5,
			NULL );
	XtAddCallback( parameterDialog, XmNcancelCallback,
		(XtCallbackProc) cancelCB_parameterDialog,
		(XtPointer) UxParameterDialogContext );
	XtAddCallback( parameterDialog, XmNhelpCallback,
		(XtCallbackProc) helpCB_parameterDialog,
		(XtPointer) UxParameterDialogContext );
	XtAddCallback( parameterDialog, XmNokCallback,
		(XtCallbackProc) okCallback_parameterDialog,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( parameterDialog, (char *) UxParameterDialogContext );
	UxPutClassCode( parameterDialog, _UxIfClassId );

	/* Creation of form2 */
	form2 = XtVaCreateManagedWidget( "form2",
			xmFormWidgetClass,
			parameterDialog,
			XmNheight, 339,
			NULL );
	UxPutContext( form2, (char *) UxParameterDialogContext );

	/* Creation of waveLabel */
	waveLabel = XtVaCreateManagedWidget( "waveLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 10,
			XmNy, 20,
			XmNwidth, 100,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Wavelength:" ),
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 10,
			XmNleftOffset, 0,
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( waveLabel, (char *) UxParameterDialogContext );

	/* Creation of waveText */
	waveText = XtVaCreateManagedWidget( "waveText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 190,
			XmNy, 20,
			XmNheight, 30,
			XmNleftAttachment, XmATTACH_FORM,
			XmNleftOffset, 100,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 10,
			XmNvalue, "1.5418",
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( waveText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_waveText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( waveText, (char *) UxParameterDialogContext );

	/* Creation of distanceLabel */
	distanceLabel = XtVaCreateManagedWidget( "distanceLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 100,
			XmNy, 50,
			XmNwidth, 100,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Distance:" ),
			XmNleftAttachment, XmATTACH_FORM,
			XmNleftOffset, 0,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 50,
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( distanceLabel, (char *) UxParameterDialogContext );

	/* Creation of distanceText */
	distanceText = XtVaCreateManagedWidget( "distanceText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 100,
			XmNy, 50,
			XmNheight, 30,
			XmNvalue, "",
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNleftOffset, 100,
			XmNtopOffset, 50,
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( distanceText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_distanceText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( distanceText, (char *) UxParameterDialogContext );

	/* Creation of centreXLabel */
	centreXLabel = XtVaCreateManagedWidget( "centreXLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 10,
			XmNy, 60,
			XmNwidth, 170,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Detector centre:   X" ),
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 90,
			XmNleftAttachment, XmATTACH_FORM,
			XmNleftOffset, 0,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( centreXLabel, (char *) UxParameterDialogContext );

	/* Creation of centreXText */
	centreXText = XtVaCreateManagedWidget( "centreXText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 150,
			XmNy, 90,
			XmNheight, 30,
			XmNvalue, "600",
			XmNleftOffset, 170,
			XmNleftAttachment, XmATTACH_FORM,
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( centreXText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_centreXText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( centreXText, (char *) UxParameterDialogContext );

	/* Creation of centreYLabel */
	centreYLabel = XtVaCreateManagedWidget( "centreYLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 250,
			XmNy, 90,
			XmNwidth, 15,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Y" ),
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNleftAttachment, XmATTACH_FORM,
			XmNleftOffset, 258,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 90,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( centreYLabel, (char *) UxParameterDialogContext );

	/* Creation of centreYText */
	centreYText = XtVaCreateManagedWidget( "centreYText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 270,
			XmNy, 90,
			XmNheight, 30,
			XmNvalue, "600",
			XmNleftAttachment, XmATTACH_FORM,
			XmNleftOffset, 275,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 90,
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( centreYText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_centreYText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( centreYText, (char *) UxParameterDialogContext );

	/* Creation of detectorRotLabel */
	detectorRotLabel = XtVaCreateManagedWidget( "detectorRotLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 0,
			XmNy, 130,
			XmNwidth, 170,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Detector rotation:  " ),
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 130,
			XmNleftOffset, 0,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( detectorRotLabel, (char *) UxParameterDialogContext );

	/* Creation of detectorRotText */
	detectorRotText = XtVaCreateManagedWidget( "detectorRotText",
			xmTextFieldWidgetClass,
			form2,
			XmNx, 150,
			XmNy, 130,
			XmNheight, 30,
			XmNvalue, "600",
			XmNvalueWcs, UxConvertValueWcs("0.0" ),
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNleftOffset, 170,
			XmNtopOffset, 130,
			XmNfontList, UxConvertFontList("8x13" ),
			XmNwidth, 90,
			NULL );
	XtAddCallback( detectorRotText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_detectorRotText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( detectorRotText, (char *) UxParameterDialogContext );

	/* Creation of detectorTwistText */
	detectorTwistText = XtVaCreateManagedWidget( "detectorTwistText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 150,
			XmNy, 160,
			XmNheight, 30,
			XmNvalue, "0.0",
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNleftOffset, 170,
			XmNtopOffset, 160,
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( detectorTwistText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_detectorTwistText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( detectorTwistText, (char *) UxParameterDialogContext );

	/* Creation of detectorTwistLabel */
	detectorTwistLabel = XtVaCreateManagedWidget( "detectorTwistLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, -220,
			XmNy, 160,
			XmNwidth, 170,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Detector twist:  " ),
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 160,
			XmNleftOffset, 0,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( detectorTwistLabel, (char *) UxParameterDialogContext );

	/* Creation of detectorTiltText */
	detectorTiltText = XtVaCreateManagedWidget( "detectorTiltText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 150,
			XmNy, 190,
			XmNheight, 30,
			XmNvalue, "0.0",
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNleftOffset, 170,
			XmNtopOffset, 190,
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( detectorTiltText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_detectorTiltText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( detectorTiltText, (char *) UxParameterDialogContext );

	/* Creation of detectorTiltLabel */
	detectorTiltLabel = XtVaCreateManagedWidget( "detectorTiltLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 0,
			XmNy, 190,
			XmNwidth, 127,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Detector tilt:  " ),
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNleftOffset, 0,
			XmNtopOffset, 190,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( detectorTiltLabel, (char *) UxParameterDialogContext );

	/* Creation of specimenTiltText */
	specimenTiltText = XtVaCreateManagedWidget( "specimenTiltText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 150,
			XmNy, 230,
			XmNheight, 30,
			XmNvalue, "0.0",
			XmNleftOffset, 170,
			XmNleftAttachment, XmATTACH_FORM,
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( specimenTiltText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_specimenTiltText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( specimenTiltText, (char *) UxParameterDialogContext );

	/* Creation of specimenTiltLabel */
	specimenTiltLabel = XtVaCreateManagedWidget( "specimenTiltLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 0,
			XmNy, 230,
			XmNwidth, 170,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Specimen tilt:  " ),
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNleftAttachment, XmATTACH_FORM,
			XmNtopAttachment, XmATTACH_FORM,
			XmNtopOffset, 230,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( specimenTiltLabel, (char *) UxParameterDialogContext );

	/* Creation of calibrationLabel */
	calibrationLabel = XtVaCreateManagedWidget( "calibrationLabel",
			xmLabelWidgetClass,
			form2,
			XmNx, 0,
			XmNy, 270,
			XmNwidth, 170,
			XmNheight, 30,
			RES_CONVERT( XmNlabelString, "Calibrant d-spacing:  " ),
			XmNalignment, XmALIGNMENT_BEGINNING,
			XmNfontList, UxConvertFontList("8x13bold" ),
			NULL );
	UxPutContext( calibrationLabel, (char *) UxParameterDialogContext );

	/* Creation of calibrationText */
	calibrationText = XtVaCreateManagedWidget( "calibrationText",
			xmTextFieldWidgetClass,
			form2,
			XmNwidth, 90,
			XmNx, 150,
			XmNy, 270,
			XmNheight, 30,
			XmNvalue, "3.137",
			XmNleftOffset, 170,
			XmNleftAttachment, XmATTACH_FORM,
			XmNfontList, UxConvertFontList("8x13" ),
			NULL );
	XtAddCallback( calibrationText, XmNvalueChangedCallback,
		(XtCallbackProc) valueChangedCB_calibrationText,
		(XtPointer) UxParameterDialogContext );

	UxPutContext( calibrationText, (char *) UxParameterDialogContext );

	XtAddCallback( parameterDialog, XmNdestroyCallback,
		(XtCallbackProc) UxDestroyContextCB,
		(XtPointer) UxParameterDialogContext);

	return ( parameterDialog );
}

/*******************************************************************************
       The following is the 'Interface function' which is the
       external entry point for creating this interface.
       This function should be called from your application or from
       a callback function.
*******************************************************************************/

Widget	create_parameterDialog( swidget _UxUxParent )
{
	Widget                  rtrn;
	_UxCparameterDialog     *UxContext;
	static int		_Uxinit = 0;

	UxParameterDialogContext = UxContext =
		(_UxCparameterDialog *) UxNewContext( sizeof(_UxCparameterDialog), False );

	UxParent = _UxUxParent;

	if ( ! _Uxinit )
	{
		_UxIfClassId = UxNewInterfaceClassId();
		UxparameterDialog_setRotation_Id = UxMethodRegister( _UxIfClassId,
				UxparameterDialog_setRotation_Name,
				(void (*)()) _parameterDialog_setRotation );
		UxparameterDialog_setWave_Id = UxMethodRegister( _UxIfClassId,
				UxparameterDialog_setWave_Name,
				(void (*)()) _parameterDialog_setWave );
		UxparameterDialog_setCentre_Id = UxMethodRegister( _UxIfClassId,
				UxparameterDialog_setCentre_Name,
				(void (*)()) _parameterDialog_setCentre );
		UxparameterDialog_setDistance_Id = UxMethodRegister( _UxIfClassId,
				UxparameterDialog_setDistance_Name,
				(void (*)()) _parameterDialog_setDistance );
		UxparameterDialog_setTilt_Id = UxMethodRegister( _UxIfClassId,
				UxparameterDialog_setTilt_Name,
				(void (*)()) _parameterDialog_setTilt );
		_Uxinit = 1;
	}

	rtrn = _Uxbuild_parameterDialog();

	waveChanged = distanceChanged = centreChanged = rotationChanged = tiltChanged = calibrationChanged = False;
	firstLook = True;
	return(rtrn);
}

/*******************************************************************************
       END OF FILE
*******************************************************************************/


text:
Why and how to profile a website, while comparing changes effectively.
See it online :


text:
'use strict';

const co = require('co');
const program = require('commander');
const update = require('npm-update');

const pkg = require('../package.json');
const _ = require('../lib/common/helper');
const logger = require('../lib/common/logger');

const {
  chalk,
  sudoUserPermissionDenied
} = _;

sudoUserPermissionDenied();

const NoSmoke = require('..');

const options = {
  port: 5678,
  verbose: true
};
const EOL = require('os').EOL;

program
  .option('-p, --port <d>',   'port to use (5678 default)')
  .option('-u, --udid <s>',   'udid of device')
  .option('-a, --app <s>',    'path of app, will override the one specified in crawler.config.yml')
  .option('-h, --hooks <s>',  'location of the hook.js file')
  .option('-c, --config <s>', 'location of the configuration.yml file')
  .option('-s, --silent',     'start without opening browser')
  .option('-v, --versions',   'output version infomation')
  .option('--verbose',        'show more debugging information')
  .option('--server <s>',     'adddress for server: `http://127.0.01:3456`')
  .option('--duration <d>',       'timeout interval')
  .option('--deviceName <s>',     'name of device')
  .option('--deviceType <s>',     'type of device')
  .usage('');

program.parse(process.argv);

var printInfo = function(lines) {
  var maxLength = 0;
  lines.forEach(line => {
    maxLength = line.length > maxLength ? line.length : maxLength;
  });

  var res = [new Array(maxLength + 7).join('*')];

  lines.forEach(line => {
    res.push(`*  ${line + new Array(maxLength - line.length + 1).join(' ')}  *`);
  });

  res.push(new Array(maxLength + 7).join('*'));
  console.log(chalk.white(`${EOL}${res.join(EOL)}${EOL}`));
};

function init(error, data) {
  if (program.versions) {
    console.info(`${EOL} ${chalk.grey(pkg.version)} ${EOL}`);
    process.exit(0);
  }

  _.merge(options, _.getConfig(program));

  co(NoSmoke, options).catch(e => {
    console.log(e);
  });
}

co(update, {
  pkg: pkg,
  callback: init
});


text:
<?php

use Terbium\Keeper\Facades\Keeper;

// Basic example
// Set rule, that grants ability to comment something
Keeper::register('comment', null, 'Ability to comment');
// Use:
Keeper::check('comment');

// Custom rule example
// Rule, that determine, that user can edit a post, if he is the post's author
Keeper::register(
	'edit_my_post',
	// The $user var is appended to arguments list by Keeper
	// In this case check would be like this:
	// Keeper::check('edit_my_post', array($post));
	// And current auth user will be passed in closure
	// To check other user, write:
	// Keeper::check('edit_my_post', array($post), $otherUser);
	function ($check, $user) {
		if ( empty($check['post']) || !is_object($check['post']) ) {
			throw new InvalidArgumentException('Expecting post object to check');
		}
		return $check['post']->author_id == $user->id;
	},
	'Ability to edit my post'
);
// Use:
Keeper::check('edit_my_post', array('post' => $postToCheck));
Keeper::check('edit_my_post', array('post' => $postToCheck), $otherUser);

// Nested rules
Keeper::group(
	'admin_panel', // This also will be a rule "admin_panel"
	function () {
		// Grant access to admin's dashboard
		// The same as to write Keeper::register('admin_panel.dashboard')
		Keeper::register('dashboard', null, 'Access to admin dashboard');

		// Custom rule
		Keeper::register(
			'edit_post',
			function ($check, $user) {
				if ( empty($check['post']) || !is_object($check['post']) ) {
					throw new InvalidArgumentException('Expecting post object to check');
				}
				return $check['post']->created_by == $user->id;
			},
			'Ability to edit post'
		);

		// We need to deeper
		Keeper::group(
			'shops', // The same as to write Keeper::register('admin_panel.shops')
			function () {
				// The same as to write Keeper::register('admin_panel.shops.add')
				Keeper::register('add', null, 'Adding shops');

				// Let's make dynamic rules
				// Assume, that we have many shops
				// And we want to manually set,
				// what groups will have access to specific shops
				foreach ( Shop::all() as $shop ) {
					// This will add rules for each shop
					// And then you can set something like that:
					// | Group: autoshop_moderators
					// | Rule: edit_autoshop
					Keeper::register("edit_{$shop->alias}", null, "Edit shop {$shop->title}");
				}
			},
			null,
			'Access to shops management'
		);
	},
	null, // Here might be a custom rule for group
	'Access to admin panel'
);
// Use:
// Check only access to admin_panel
Keeper::check('admin_panel');
// Check access to admin_panel AND dashboard
Keeper::check('admin_panel.dashboard');
// Check access to admin_panel AND dashboard
Keeper::check('admin_panel.edit_post', array('post' => $postToCheck));
// Check access to admin_panel AND shops
Keeper::check('admin_panel.shops');
// Check access to admin_panel AND shops AND add
Keeper::check('admin_panel.shops.add');
// Check access to admin_panel AND shops AND edit_autoshop
Keeper::check('admin_panel.shops.edit_autoshop');


text:
package com.roundup.kafka.actors

import java.util.Properties

import kafka.utils.Logging
import org.apache.kafka.clients.producer.{RecordMetadata, Callback, KafkaProducer, ProducerRecord}
import org.apache.kafka.common.serialization.{ByteArraySerializer, StringSerializer}

/**
 * Created by Lior Gonnen on 3/16/15.
 */

/**
 * Wraps a Java Kafka Producer
 * @param brokers
 *        A list of host/port pairs to use for establishing the initial connection to the Kafka cluster. Data will be
 *        load balanced over all servers irrespective of which servers are specified here for bootstrapping—this list
 *        only impacts the initial hosts used to discover the full set of servers. This list should be in the form
 *        host1:port1,host2:port2,.... Since these servers are just used for the initial connection to discover the full
 *        cluster membership (which may change dynamically), this list need not contain the full set of servers (you may
 *        want more than one, though, in case a server is down). If no server in this list is available sending data will
 *        fail until on becomes available.
 *
 * @param clientId
 *        The id string to pass to the server when making requests. The purpose of this is to be able to track the source
 *        of requests beyond just ip/port by allowing a logical application name to be included with the request.
 *        The application can set any string it wants as this has no functional purpose other than in logging and metrics.
 *
 * @param compress
 *        If true, use GZip compression
 *        The compression type for all data generated by the producer. The default is none (i.e. no compression).
 *        Compression is of full batches of data, so the efficacy of batching will also impact the compression ratio
 *        (more batching means better compression).
 *
 * @param batchSize
 *        The producer will attempt to batch records together into fewer requests whenever multiple records are being sent
 *        to the same partition. This helps performance on both the client and the server. This configuration controls the
 *        default batch size in bytes. No attempt will be made to batch records larger than this size.
 *        Requests sent to brokers will contain multiple batches, one for each partition with data available to be sent.
 *        A small batch size will make batching less common and may reduce throughput (a batch size of zero will disable
 *        batching entirely). A very large batch size may use memory a bit more wastefully as we will always allocate a
 *        buffer of the specified batch size in anticipation of additional records.
 *
 * @param maxSendRetries
 *        Setting a value greater than zero will cause the client to resend any record whose send fails with a potentially
 *        transient error. Note that this retry is no different than if the client resent the record upon receiving the error.
 *        Allowing retries will potentially change the ordering of records because if two records are sent to a single partition,
 *        and the first fails and is retried but the second succeeds, then the second record may appear first.
 *
 * @param acks
 *        0 = The producer never waits for an acknowledgement from the broker (the same behavior as 0.7).
 *        This option provides the lowest latency but the weakest durability guarantees (some data will be lost when a server fails).
 *        1 = The producer gets an acknowledgement after the leader replica has received the data. This option provides
 *        better durability as the client waits until the server acknowledges the request as successful (only messages that were
 *        written to the now-dead leader but not yet replicated will be lost).
 *        -1 = The producer gets an acknowledgement after all in-sync replicas have received the data. This option
 *        provides the best durability, we guarantee that no messages will be lost as long as at least one in sync replica remains.
 *
 * @param bufferMemoryBytes
 *        The total bytes of memory the producer can use to buffer records waiting to be sent to the server.
 *         If records are sent faster than they can be delivered to the server the producer will either block or throw an exception based on
 *         the preference specified by block.on.buffer.full.
 *
 * @param metadataFetchTimeoutMillis
 *        he first time data is sent to a topic we must fetch metadata about that topic to know which servers host the topic's partitions.
 *        This configuration controls the maximum amount of time we will block waiting for the metadata fetch to succeed before throwing an
 *        exception back to the client.
 */

case class ProducerConfig(
    brokers: String = null,
    clientId: String = null,
    compress: Boolean = true,
    batchSize: Int = 16384,
    maxSendRetries: Int = 2,
    acks: Integer = 1,
    bufferMemoryBytes: Long = 10*1024*1024,
    metadataFetchTimeoutMillis: Long = 1000) {

    def validate = {
        require(brokers != null, "null brokers")
    }

    def toProperties = new Properties() {
        put("bootstrap.servers", brokers)
        put("buffer.memory", bufferMemoryBytes.toString)                // default=33554432
        put("retries", maxSendRetries.toString)                         // default=0
        put("acks", acks.toString)                                      // default=1
        put("compression.type", "gzip")                                 // default=none (none / gzip / snappy)
        put("batch.size", batchSize.toString)                           // default=16384
        put("key.serializer", classOf[StringSerializer].getName)
        put("value.serializer", classOf[ByteArraySerializer].getName)
        put("metadata.fetch.timeout.ms", metadataFetchTimeoutMillis.toString)
        put("block.on.buffer.full", "false")
        put("request.timeout.ms", 10000.toString)
        if (clientId != null) put("client.id", clientId)
    }
}

case class ScalaKafkaProducer(config: ProducerConfig) extends Logging with Callback {

    require(config != null, "null config")

    config.validate

    val producer = new KafkaProducer[String, Array[Byte]](config.toProperties)

    def send(topic: String, message: String): Unit = send(topic, message.getBytes("UTF8"))

    def send(topic: String, message: Array[Byte]): Unit = {
        logger.debug(s"ScalaKafkaProducer.send($topic)")
        producer.send(new ProducerRecord(topic, message), this)
    }

    override def onCompletion(recordMetadata: RecordMetadata, e: Exception): Unit = {
        if (e != null) logger.error(e.getMessage)
    }

    def close: Unit = {
        try {
            producer.close()
        }
        catch {
            case e: Exception => error(e)
        }
    }
}


text:
#ifndef __EM_VV_STORE_H__
#define __EM_VV_STORE_H__

#include "vv_store.h"
#include "EM_object.h"
#include "EM_vector.h"
#include "local_vv_store.h"

namespace fm
{

namespace detail
{

class EM_vv_store: public vv_store, public EM_object
{
	EM_vv_store(const scalar_type &type): vv_store(type, false) {
	}
	EM_vv_store(const std::vector<off_t> &offs,
			EM_vec_store::ptr store): vv_store(offs, store) {
	}

	const EM_vec_store &get_EM_data() const {
		return static_cast<const EM_vec_store &>(get_data());
	}
public:
	typedef std::shared_ptr<EM_vv_store> ptr;
	typedef std::shared_ptr<const EM_vv_store> const_ptr;

	static ptr create(const scalar_type &type) {
		return ptr(new EM_vv_store(type));
	}
	static ptr create(const std::vector<off_t> &offs, EM_vec_store::ptr store) {
		return ptr(new EM_vv_store(offs, store));
	}
	virtual local_vec_store::ptr get_portion_async(off_t start,
			size_t len, portion_compute::ptr compute) const;

	virtual std::vector<safs::io_interface::ptr> create_ios() const {
		return dynamic_cast<const EM_object &>(get_data()).create_ios();
	}

	virtual vec_store::ptr shallow_copy() {
		return ptr(new EM_vv_store(*this));
	}
	virtual vec_store::const_ptr shallow_copy() const {
		return const_ptr(new EM_vv_store(*this));
	}
};

}

}

#endif


text:
package cn.wizzer.modules.sys.bean;

import org.nutz.dao.entity.annotation.*;

/**
 * @author Wizzer
 * @time 2014-02-27 10:01:23
 */
@Table("SYS_TASK")
public class Sys_task {
    @Column
    @Id
    private int task_id;
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String task_code;
    @Column
    private int task_type;
    @Column
    private String task_name;
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String job_class;
    @Column
    private int execycle;
    @Column
    private int day_of_month;
    @Column
    private int day_of_week;
    @Column
    private int hour;
    @Column
    private int minute;
    @Column
    private int interval_hour;
    @Column
    private int interval_minute;
    @Column
    private int task_interval_unit;
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 20)
    private String cron_expression;
    @Column
    private int is_enable;
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 255)
    private String task_remark;
    @Column
    private long user_id;
    @Column
    private String create_time;
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 100)
    private String param_value;
    @Column
    private int task_interval;
    @Column
    private int task_threadnum;
    public int getTask_id() {
        return task_id;
    }

    public void setTask_id(int task_id) {
        this.task_id = task_id;
    }

    public String getTask_code() {
        return task_code;
    }

    public void setTask_code(String task_code) {
        this.task_code = task_code;
    }

    public int getTask_type() {
        return task_type;
    }

    public void setTask_type(int task_type) {
        this.task_type = task_type;
    }

    public String getTask_name() {
        return task_name;
    }

    public void setTask_name(String task_name) {
        this.task_name = task_name;
    }

    public String getJob_class() {
        return job_class;
    }

    public void setJob_class(String job_class) {
        this.job_class = job_class;
    }

    public int getExecycle() {
        return execycle;
    }

    public void setExecycle(int execycle) {
        this.execycle = execycle;
    }

    public int getDay_of_month() {
        return day_of_month;
    }

    public void setDay_of_month(int day_of_month) {
        this.day_of_month = day_of_month;
    }

    public int getDay_of_week() {
        return day_of_week;
    }

    public void setDay_of_week(int day_of_week) {
        this.day_of_week = day_of_week;
    }

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }

    public int getMinute() {
        return minute;
    }

    public void setMinute(int minute) {
        this.minute = minute;
    }

    public int getInterval_hour() {
        return interval_hour;
    }

    public void setInterval_hour(int interval_hour) {
        this.interval_hour = interval_hour;
    }

    public int getInterval_minute() {
        return interval_minute;
    }

    public void setInterval_minute(int interval_minute) {
        this.interval_minute = interval_minute;
    }

    public int getTask_interval_unit() {
        return task_interval_unit;
    }

    public void setTask_interval_unit(int task_interval_unit) {
        this.task_interval_unit = task_interval_unit;
    }

    public String getCron_expression() {
        return cron_expression;
    }

    public void setCron_expression(String cron_expression) {
        this.cron_expression = cron_expression;
    }

    public int getIs_enable() {
        return is_enable;
    }

    public void setIs_enable(int is_enable) {
        this.is_enable = is_enable;
    }

    public String getTask_remark() {
        return task_remark;
    }

    public void setTask_remark(String task_remark) {
        this.task_remark = task_remark;
    }

    public long getUser_id() {
        return user_id;
    }

    public void setUser_id(long user_id) {
        this.user_id = user_id;
    }

    public String getCreate_time() {
        return create_time;
    }

    public void setCreate_time(String create_time) {
        this.create_time = create_time;
    }

    public String getParam_value() {
        return param_value;
    }

    public void setParam_value(String param_value) {
        this.param_value = param_value;
    }

    public int getTask_interval() {
        return task_interval;
    }

    public void setTask_interval(int task_interval) {
        this.task_interval = task_interval;
    }

    public int getTask_threadnum() {
        return task_threadnum;
    }

    public void setTask_threadnum(int task_threadnum) {
        this.task_threadnum = task_threadnum;
    }
}


text:
package com.helger.commons.io.stream;

import java.io.IOException;
import java.io.Reader;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.helger.commons.annotation.OverrideOnDemand;
import com.helger.commons.string.ToStringGenerator;

/**
 * A wrapper around an {@link Reader} that logs read and skip actions.
 *
 * @author Philip Helger
 * @since 9.3.8
 */
public class LoggingReader extends WrappedReader
{
  private static final Logger LOGGER = LoggerFactory.getLogger (LoggingReader.class);

  private long m_nPosition = 0;

  /**
   * @param aSourceReader
   *        The reader that should be logged. May not be null.
   */
  public LoggingReader (@Nonnull final Reader aSourceReader)
  {
    super (aSourceReader);
  }

  /**
   * @return The current read position. Always ≥ 0.
   */
  public final long getPosition ()
  {
    return m_nPosition;
  }

  @OverrideOnDemand
  protected void onRead (final int nBytesRead, final long nNewPosition)
  {
    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Read " + nBytesRead + " char(s); now at " + nNewPosition);
  }

  @OverrideOnDemand
  protected void onSkip (final long nBytesSkipped, final long nNewPosition)
  {
    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Skipped " + nBytesSkipped + " char(s); now at " + nNewPosition);
  }

  @OverrideOnDemand
  protected void onMark (final int nReadLimit, final long nCurrentPosition)
  {
    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Marked at " + nCurrentPosition + " with read-limit of " + nReadLimit);
  }

  @OverrideOnDemand
  protected void onReset (final long nCurrentPosition)
  {
    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Reset at " + nCurrentPosition);
  }

  @OverrideOnDemand
  protected void onClose (final long nCurrentPosition)
  {
    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Close at " + nCurrentPosition);
  }

  @Override
  public final int read () throws IOException
  {
    final int ret = super.read ();
    if (ret != -1)
    {
      m_nPosition++;
      onRead (1, m_nPosition);
    }
    return ret;
  }

  @Override
  public final int read (final char [] aBuf, final int nOffset, final int nLength) throws IOException
  {
    final int ret = super.read (aBuf, nOffset, nLength);
    if (ret != -1)
    {
      m_nPosition += ret;
      onRead (ret, m_nPosition);
    }
    return ret;
  }

  @Override
  public final long skip (@Nonnegative final long n) throws IOException
  {
    final long nSkipped = super.skip (n);
    if (nSkipped > 0)
    {
      m_nPosition += nSkipped;
      onSkip (nSkipped, m_nPosition);
    }
    return nSkipped;
  }

  @Override
  public final void mark (@Nonnegative final int nReadlimit) throws IOException
  {
    super.mark (nReadlimit);
    onMark (nReadlimit, m_nPosition);
  }

  @Override
  public final void reset () throws IOException
  {
    super.reset ();
    onReset (m_nPosition);
  }

  @Override
  public final void close () throws IOException
  {
    super.close ();
    onClose (m_nPosition);
  }

  @Override
  public String toString ()
  {
    return ToStringGenerator.getDerived (super.toString ()).append ("position", m_nPosition).getToString ();
  }
}


text:
package com.planet_ink.coffee_mud.Items.ClanItems;
import com.planet_ink.coffee_mud.core.interfaces.*;
import com.planet_ink.coffee_mud.core.*;
import com.planet_ink.coffee_mud.core.collections.*;
import com.planet_ink.coffee_mud.Abilities.interfaces.*;
import com.planet_ink.coffee_mud.Areas.interfaces.*;
import com.planet_ink.coffee_mud.Behaviors.interfaces.*;
import com.planet_ink.coffee_mud.CharClasses.interfaces.*;
import com.planet_ink.coffee_mud.Commands.interfaces.*;
import com.planet_ink.coffee_mud.Common.interfaces.*;
import com.planet_ink.coffee_mud.Exits.interfaces.*;
import com.planet_ink.coffee_mud.Items.interfaces.*;
import com.planet_ink.coffee_mud.Libraries.interfaces.*;
import com.planet_ink.coffee_mud.Locales.interfaces.*;
import com.planet_ink.coffee_mud.MOBS.interfaces.*;
import com.planet_ink.coffee_mud.Races.interfaces.*;

import java.util.*;

@SuppressWarnings({"unchecked","rawtypes"})
public class StdClanCommonItem extends StdClanItem
{
	@Override
	public String ID()
	{
		return "StdClanCommonItem";
	}

	private static final Map<Area,DVector> needChart = new Hashtable<Area,DVector>();

	protected int 		workDown=0;
	protected boolean 	glows=false;

	public StdClanCommonItem()
	{
		super();

		setName("a clan workers item");
		basePhyStats.setWeight(1);
		setDisplayText("an workers item belonging to a clan is here.");
		setDescription("");
		secretIdentity="";
		baseGoldValue=1;
		setClanItemType(ClanItem.ClanItemType.GATHERITEM);
		material=RawMaterial.RESOURCE_OAK;
		recoverPhyStats();
	}

	public boolean fireHere(Room R)
	{
		for(int i=0;i<R.numItems();i++)
		{
			final Item I2=R.getItem(i);
			if((I2!=null)
			&&(I2.container()==null)
			&&(CMLib.flags().isOnFire(I2)))
				return true;
		}
		return false;
	}

	public Vector<Item> resourceHere(Room R, int material)
	{
		final Vector<Item> here=new Vector<Item>();
		for(int i=0;i<R.numItems();i++)
		{
			final Item I2=R.getItem(i);
			if((I2!=null)
			&&(I2.container()==null)
			&&(I2 instanceof RawMaterial)
			&&(((I2.material()&RawMaterial.RESOURCE_MASK)==material)
				||(((I2.material())&RawMaterial.MATERIAL_MASK)==material))
			&&(!CMLib.flags().isEnchanted(I2)))
				here.addElement(I2);
		}
		return here;
	}

	public Vector<Item> resourceHere(MOB M, int material)
	{
		final Vector<Item> here=new Vector<Item>();
		for(int i=0;i<M.numItems();i++)
		{
			final Item I2=M.getItem(i);
			if((I2!=null)
			&&(I2.container()==null)
			&&(I2 instanceof RawMaterial)
			&&(((I2.material()&RawMaterial.RESOURCE_MASK)==material)
				||(((I2.material())&RawMaterial.MATERIAL_MASK)==material))
			&&(!CMLib.flags().isEnchanted(I2)))
				here.addElement(I2);
		}
		return here;
	}

	public List<Item> resourceHere(Room R, List<Integer> materials)
	{
		final List<Item> allMat=new Vector<Item>();
		List<Item> V=null;
		for(int m=0;m<materials.size();m++)
		{
			V=resourceHere(R,materials.get(m).intValue());
			for(int v=0;v<V.size();v++)
				allMat.add(V.get(v));
			V.clear();
		}
		return allMat;
	}

	public List<Item> resourceHere(MOB M, List<Integer> materials)
	{
		final List<Item> allMat=new Vector<Item>();
		List<Item> V=null;
		for(int m=0;m<materials.size();m++)
		{
			V=resourceHere(M,materials.get(m).intValue());
			for(int v=0;v<V.size();v++)
				allMat.add(V.get(v));
			V.clear();
		}
		return allMat;
	}

	public List<Integer> enCode(MOB M, String req)
	{
		req=req.toUpperCase();
		final List<Integer> V=new Vector<Integer>();
		for(final RawMaterial.Material m : RawMaterial.Material.values())
		{
			final int x=req.indexOf(m.desc());
			if(x<0)
				continue;
			if((x>0)&&Character.isLetter(req.charAt(x-1)))
				continue;
			if(((x+m.desc().length())<req.length())
			&&Character.isLetter(req.charAt((x+m.desc().length()))))
				continue;
			V.add(Integer.valueOf(m.mask()));
		}
		final RawMaterial.CODES codes = RawMaterial.CODES.instance();
		for(int s=0;s<codes.total();s++)
		{
			final String S=codes.name(s);
			final int x=req.indexOf(S);
			if(x<0)
				continue;
			if((x>0)&&Character.isLetter(req.charAt(x-1)))
				continue;
			if(((x+S.length())<req.length())
			&&Character.isLetter(req.charAt((x+S.length()))))
				continue;
			V.add(Integer.valueOf(codes.get(s)));
		}
		if((M.location()!=null)
		&&(V.contains(Integer.valueOf(RawMaterial.MATERIAL_METAL)))
		&&(resourceHere(M.location(),RawMaterial.MATERIAL_WOODEN).size()==0))
			V.add(Integer.valueOf(RawMaterial.MATERIAL_WOODEN));
		return V;
	}

	@Override
	public void affectPhyStats(Physical affected, PhyStats stats)
	{
		super.affectPhyStats(affected,stats);
		if((glows)
		&&(affected instanceof MOB)
		&&(!super.amWearingAt(Wearable.IN_INVENTORY))
		&&(((MOB)affected).location()!=null)
		&&(((MOB)affected).location().domainType()==Room.DOMAIN_INDOORS_CAVE)
		&&(((MOB)affected).getStartRoom()!=null)
		&&(((MOB)affected).getStartRoom().getArea()==((MOB)affected).location().getArea()))
			stats.setSensesMask(stats.sensesMask()|PhyStats.CAN_SEE_DARK);
	}

	@Override
	public void setReadableText(String newText)
	{
		super.setReadableText(newText);
		glows=(newText.equalsIgnoreCase("Mining"));
	}

	public boolean trackTo(MOB M, MOB M2)
	{
		final Ability A=CMClass.getAbility("Skill_Track");
		if(A!=null)
		{
			final Room R=M2.location();
			if((R!=null)&&(CMLib.flags().isInTheGame(M2,true)))
			{
				A.invoke(M,CMParms.parse("\""+CMLib.map().getExtendedRoomID(R)+"\""),R,true,0);
				return true;
			}
		}
		return false;
	}
	public boolean trackTo(MOB M, Room R)
	{
		final Ability A=CMClass.getAbility("Skill_Track");
		if((A!=null)&&(R!=null))
		{
			A.invoke(M,CMParms.parse("\""+CMLib.map().getExtendedRoomID(R)+"\""),R,true,0);
			return true;
		}
		return false;
	}

	@Override
	public boolean tick(Tickable ticking, int tickID)
	{
		if(!super.tick(ticking,tickID))
			return false;
		if((tickID==Tickable.TICKID_CLANITEM)
		&&(owner() instanceof MOB)
		&&(((MOB)owner()).isMonster())
		&&(readableText().length()>0)
		&&(((MOB)owner()).getClanRole(clanID())!=null)
		&&((--workDown)<=0)
		&&(!CMLib.flags().isATrackingMonster((MOB)owner()))
		&&(CMLib.flags().isInTheGame((MOB)owner,true))
		&&(!CMLib.flags().isAnimalIntelligence((MOB)owner())))
		{
			workDown=CMLib.dice().roll(1,7,0);
			final MOB M=(MOB)owner();
			if(M.fetchEffect(readableText())==null)
			{
				final Ability A=CMClass.getAbility(readableText());
				if((A!=null)&&((A.classificationCode()&Ability.ALL_ACODES)==Ability.ACODE_COMMON_SKILL))
				{
					A.setProficiency(100);
					boolean success=false;
					if(((A.classificationCode()&Ability.ALL_DOMAINS)!=Ability.DOMAIN_CRAFTINGSKILL)
					&&((A.classificationCode()&Ability.ALL_DOMAINS)!=Ability.DOMAIN_BUILDINGSKILL)
					&&(CMLib.flags().isMobile(M)))
					{
						final DVector DV=needChart.get(M.location().getArea());
						if(DV!=null)
						{
							List needs=null;
							MOB M2=null;
							boolean getToWork=false;
							if(A.ID().equalsIgnoreCase("FireBuilding"))
							{
								MOB possibleMOBToGoTo=null;
								for(int i=0;i<DV.size();i++)
								{
									try
									{
										final int rand=i;
										needs=(List)DV.elementAt(rand,2);
										M2=(MOB)DV.elementAt(rand,1);
									}
									catch (final Exception e)
									{
										continue;
									}
									if((needs!=null)
									&&(M2!=null)
									&&(needs.contains(Integer.valueOf(RawMaterial.MATERIAL_METAL)))
									&&(!fireHere(M2.location()))
									&&(resourceHere(M2.location(),RawMaterial.MATERIAL_WOODEN).size()>0))
									{
										if(M.location()==M2.location())
										{
											getToWork=true;
											break;
										}
										else
										if((possibleMOBToGoTo==null)||(CMLib.dice().roll(1,2,0)==1))
											possibleMOBToGoTo=M2;
									}
								}
								if((!getToWork)
								&&(possibleMOBToGoTo!=null)
								&&(trackTo(M,possibleMOBToGoTo)))
								{
									return true;
								}
							}
							List rsc=null;
							// if I have the stuff on hand.
							if(!getToWork)
							for(int i=DV.size()-1;i>=0;i--)
							{
								try
								{
									final int rand=i;
									needs=(List)DV.elementAt(rand,2);
									M2=(MOB)DV.elementAt(rand,1);
									if(!CMLib.flags().isInTheGame(M2,true))
									{
										DV.removeElementAt(i);
										continue;
									}
								}
								catch(final Exception e)
								{
									continue;
								}
								if((needs!=null)
								&&(M2!=null)
								&&(M.location()==M2.location()))
								{
									rsc=resourceHere(M,needs);
									if(rsc.size()>0)
									{
										for(int r=0;r<rsc.size();r++)
											CMLib.commands().postDrop(M,(Environmental)rsc.get(r),false,true,false);
										return true;
									}
								}
							}
							if(!getToWork)
							for(int i=0;i<DV.size();i++)
							{
								try
								{
									final int rand=CMLib.dice().roll(1,DV.size(),-1);
									needs=(List)DV.elementAt(rand,2);
									M2=(MOB)DV.elementAt(rand,1);
								}
								catch(final Exception e)
								{
									continue;
								}
								if((needs!=null)
								&&(M2!=null)
								&&(M.location()!=M2.location()))
								{
									rsc=resourceHere(M,needs);
									if((rsc.size()>0)
									&&(trackTo(M,M2)))
										return true;
								}
							}
							if(!getToWork)
							{
								for(int i=0;i<DV.size();i++)
								{
									try
									{
										final int rand=CMLib.dice().roll(1,DV.size(),-1);
										needs=(List)DV.elementAt(rand,2);
										M2=(MOB)DV.elementAt(rand,1);
									}
									catch(final Exception e)
									{
										continue;
									}
									if((needs!=null)
									&&(M2!=null)
									&&(M.location()!=M2.location()))
									{
										rsc=resourceHere(M.location(),needs);
										if(rsc.size()>0)
										{
											for(int r=0;r<rsc.size();r++)
												CMLib.commands().postGet(M,null,(Item)rsc.get(r),false);
											if(trackTo(M,M2))
												return true;
										}
									}
								}
							}
						}
					}

					if((M.location()!=null)
					&&(CMLib.flags().isAliveAwakeMobileUnbound(M,true))
					&&(!CMLib.flags().canBeSeenBy(M.location(),M)))
					{
						switch(CMLib.dice().roll(1,7,0))
						{
						case 1:
							CMLib.commands().postSay(M, null, L("I can't see a thing."));
							break;
						case 2:
							CMLib.commands().postSay(M, null, L("It's too dark to work."));
							break;
						case 3:
							CMLib.commands().postSay(M, null, L("How am I supposed to work in these conditions?"));
							break;
						case 4:
							CMLib.commands().postSay(M, null, L("Too dadgum dark."));
							break;
						case 5:
							CMLib.commands().postSay(M, null, L("Is anyone there?  I can't see!"));
							break;
						case 6:
							CMLib.commands().postSay(M, null, L("Someone turn on the lights to I can work!"));
							break;
						case 7:
							CMLib.commands().postSay(M, null, L("I could use some light, if you expect me to work."));
							break;
						}
					}

					if((M.numItems()>1)&&((A.classificationCode()&Ability.ALL_DOMAINS)==Ability.DOMAIN_CRAFTINGSKILL))
					{
						Item I=null;
						int tries=0;
						while((I==null)&&((++tries)<20))
						{
							I=M.getRandomItem();
							if((I==null)
							||(I==this)
							||(I instanceof RawMaterial)
							||(!I.amWearingAt(Wearable.IN_INVENTORY)))
								I=null;
						}
						final Vector<String> V=new Vector<String>();
						if(I!=null)
							V.addElement(I.name());
						success=A.invoke(M,V,null,false,phyStats().level());
					}
					else
						success=A.invoke(M,new Vector<String>(),null,false,phyStats().level());
					if((A.classificationCode()&Ability.ALL_DOMAINS)==Ability.DOMAIN_CRAFTINGSKILL)
					{
						DVector DV=needChart.get(M.location().getArea());
						if(!success)
						{
							if(DV==null)
							{
								DV=new DVector(2);
								needChart.put(M.location().getArea(),DV);
							}
							DV.removeElement(M);
							final String req=A.accountForYourself();
							final int reqIndex=req.indexOf(':');
							if(reqIndex>0)
								DV.addElement(M,enCode(M,req.substring(reqIndex+1)));
							else
								DV.addElement(M,enCode(M,req));
						}
						else
						if(DV!=null)
							DV.removeElement(M);
					}
				}
			}
		}
		return true;
	}
}


text:
import pytest

from kolibri.plugins import DEFAULT_PLUGINS
from kolibri.plugins.utils import enable_plugin

@pytest.mark.parametrize("plugin", DEFAULT_PLUGINS)
def test_can_enable_all_default_plugins(plugin):
    assert enable_plugin(plugin)


text:
.. _timeaveraging:

Time Averaging
==============

The ``mc3.stats.time_avg()`` routine computes the binned RMS array (as
function of bin size) used in the the time-averaging procedure for a
given model--data residuals array.  The routine returns the RMS of the
binned data (:math:`{\rm rms}_N`), the lower and upper RMS
uncertainties, the extrapolated RMS for Gaussian (white) noise
(:math:`\sigma_N`), and the bin-size array (:math:`N`).

This function uses an asymptotic approximation to compute the RMS
uncertainties (:math:`\sigma_{\rm rms} = \sqrt{{\rm rms}_N / 2M}`) for
number of bins :math:`M> 35`.  For smaller values of :math:`M`
(equivalently, large bin size) this routine computes the errors from
the posterior PDF of the RMS (an inverse-gamma distribution).  For
more details, see [Cubillos2017]_.

Example
^^^^^^^

For the sake of illustration, this example uses mock data.  In the
real world, your 'data' should be the residuals between the observed
values and some model fit:

.. literalinclude:: ../examples/timeavg.py

For a time-correlated signal, the RMS-vs-binsize curve deviates above
the white-noise Gaussian prediction, as in the left panel below.  For
a white-noise signal, both curves should match within uncertainties,
as in the right panel below:

.. image:: ./figures/rms-vs-binsize.png
   :width: 100%