text:
#ifndef TENSORFLOW_JAVA_OPERATION_BUILDER_JNI_H_
#define TENSORFLOW_JAVA_OPERATION_BUILDER_JNI_H_

#include <jni.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    allocate
 * Signature: (JLjava/lang/String;Ljava/lang/String;)J
 */
JNIEXPORT jlong JNICALL Java_org_tensorflow_OperationBuilder_allocate(
    JNIEnv *, jclass, jlong, jstring, jstring);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    finish
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL Java_org_tensorflow_OperationBuilder_finish(JNIEnv *,
                                                                    jclass,
                                                                    jlong);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    addInput
 * Signature: (JJI)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_addInput(
    JNIEnv *, jclass, jlong, jlong, jint);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    addInputList
 * Signature: (J[J[I)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_addInputList(
    JNIEnv *, jclass, jlong, jlongArray, jintArray);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    addControlInput
 * Signature: (JJ)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_addControlInput(
    JNIEnv *, jclass, jlong, jlong);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setDevice
 * Signature: (JLjava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setDevice(JNIEnv *,
                                                                      jclass,
                                                                      jlong,
                                                                      jstring);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrString
 * Signature: (JLjava/lang/String;[B)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrString(
    JNIEnv *, jclass, jlong, jstring, jbyteArray);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrInt
 * Signature: (JLjava/lang/String;J)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrInt(
    JNIEnv *, jclass, jlong, jstring, jlong);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrIntList
 * Signature: (JLjava/lang/String;[J)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrIntList(
    JNIEnv *, jclass, jlong, jstring, jlongArray);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrFloat
 * Signature: (JLjava/lang/String;F)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrFloat(
    JNIEnv *, jclass, jlong, jstring, jfloat);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrFloatList
 * Signature: (JLjava/lang/String;[F)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrFloatList(
    JNIEnv *, jclass, jlong, jstring, jfloatArray);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrBool
 * Signature: (JLjava/lang/String;Z)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrBool(
    JNIEnv *, jclass, jlong, jstring, jboolean);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrBoolList
 * Signature: (JLjava/lang/String;[Z)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrBoolList(
    JNIEnv *, jclass, jlong, jstring, jbooleanArray);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrType
 * Signature: (JLjava/lang/String;I)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrType(
    JNIEnv *, jclass, jlong, jstring, jint);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrTypeList
 * Signature: (JLjava/lang/String;[I)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrTypeList(
    JNIEnv *, jclass, jlong, jstring, jintArray);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrTensor
 * Signature: (JLjava/lang/String;J)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrTensor(
    JNIEnv *, jclass, jlong, jstring, jlong);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrTensorList
 * Signature: (JLjava/lang/String;[J)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrTensorList(
    JNIEnv *, jclass, jlong, jstring, jlongArray);

/*
 * Class:     org_tensorflow_OperationBuilder
 * Method:    setAttrShape
 * Signature: (JLjava/lang/String;[JI)V
 */
JNIEXPORT void JNICALL Java_org_tensorflow_OperationBuilder_setAttrShape(
    JNIEnv *, jclass, jlong, jstring, jlongArray, jint);

#ifdef __cplusplus
}  // extern "C"
#endif  // __cplusplus
#endif  // TENSORFLOW_JAVA_OPERATION_BUILDER_JNI_H_


text:
var StatsdClient = require('statsd-client');

var factory = function(config) {
  var prefix = config.tenant + "." + config.feature + "." + config.instance + ".app";
  var statsdConfig = {
    host: config.statsd.host,
    port: config.statsd.port,
    prefix: prefix
  };

  var statsdClient = new StatsdClient(statsdConfig);
  return statsdClient;
};

module.exports = factory;

redpajama_set_name: RedPajamaGithub


text:
<!doctype html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <title>Material Theme Date Picker</title>

  <link rel="import" href="common.html">

  <link rel="import" href="../../vaadin-date-picker/theme/material/vaadin-date-picker.html">

    <demo-navigation>
      Material
    </demo-navigation>

Date pickers

Light Theme

    <nice-demo-snippet>
      <template slot="source">
        <vaadin-date-picker label="Label" placeholder="Placeholder" min="2017-06-01"></vaadin-date-picker>
      </template>
    </nice-demo-snippet>

States

    <nice-demo-snippet>
      <template slot="source">
        <vaadin-date-picker label="Enabled" value="2017-01-31"></vaadin-date-picker>
        <vaadin-date-picker label="Disabled" value="2017-01-31" disabled></vaadin-date-picker>
        <vaadin-date-picker label="Read only" value="2017-01-31" readonly></vaadin-date-picker>
      </template>
    </nice-demo-snippet>

Week numbers

    <nice-demo-snippet>
      <template slot="source">
        <vaadin-date-picker show-week-numbers></vaadin-date-picker>
      </template>
    </nice-demo-snippet>


text:
<?xml version="1.0" encoding="UTF-8"?>

<recipeml version="0.5">
  <recipe>
    <head>
      <title>Australian Sticky Date Pudding</title>
      <categories>
        <cat>Bakery</cat>
        <cat>Sheet cake</cat>
        <cat>Typed</cat></categories>
      <yield>1</yield></head>
    <ingredients>
      <ing-div>
        <title/>
        <ing>
          <amt>
            <qty>1/2</qty>
            <unit>cups</unit></amt>
          <item>Butter, room temperature cut into eight pieces</item></ing>
        <ing>
          <amt>
            <qty/>
            <unit/></amt>
          <item>Plus extra to butter pan</item></ing>
        <ing>
          <amt>
            <qty>1 1/4</qty>
            <unit>cups</unit></amt>
          <item>Chopped pitted dates</item></ing>
        <ing>
          <amt>
            <qty>1</qty>
            <unit>teaspoon</unit></amt>
          <item>Baking soda</item></ing>
        <ing>
          <amt>
            <qty>1/4</qty>
            <unit>cups</unit></amt>
          <item>Granulated sugar</item></ing>
        <ing>
          <amt>
            <qty>2</qty>
            <unit/></amt>
          <item>Eggs</item></ing>
        <ing>
          <amt>
            <qty>1 1/4</qty>
            <unit>cups</unit></amt>
          <item>All purpose flour</item></ing>
        <ing>
          <amt>
            <qty>1/2</qty>
            <unit>teaspoons</unit></amt>
          <item>Salt</item></ing>
        <ing>
          <amt>
            <qty>1/2</qty>
            <unit>teaspoons</unit></amt>
          <item>Vanilla</item></ing>
        <ing>
          <amt>
            <qty>1 3/4</qty>
            <unit>teaspoons</unit></amt>
          <item>Baking powder</item></ing></ing-div>
      <ing-div>
        <title>CARAMEL SAUCE</title>
        <ing>
          <amt>
            <qty>1/2</qty>
            <unit>cups</unit></amt>
          <item>Butter</item></ing>
        <ing>
          <amt>
            <qty>1/4</qty>
            <unit>cups</unit></amt>
          <item>Whipping cream</item></ing>
        <ing>
          <amt>
            <qty>1/2</qty>
            <unit>cups</unit></amt>
          <item>Firm packed brown sugar PLUS</item></ing>
        <ing>
          <amt>
            <qty>1</qty>
            <unit>tablespoon</unit></amt>
          <item>Firm packed brown sugar</item></ing>
        <ing>
          <amt>
            <qty>1/2</qty>
            <unit>teaspoons</unit></amt>
          <item>Vanilla</item></ing></ing-div></ingredients>
    <directions>
      <step>  This Australian recipe, a very moist cake, not what we'd call a pudding,
  has taken Down Under by storm. you'll find it on restaurant and dinner
  party menus across that country. This version was printed recently by the
  New York times.

  TO PREPARE CAKE: Preheat oven to 350 degrees F. Butter a 9-inch round
  baking pan withsides at least 2 inches high, such as a springform pan.

  Place the dates in a saucepan and cover with water (about 1-1/2 cups).
  Bring to a boil, reduce to simmer and cook for 3 minutes. Add the baking
  soda (the mixture will foam) and set aside.

  In a bowl, cream the cut up butter, sugar and eggs, adding the eggs one at
  a time. Gently mix in the flour, salt and vanilla. Stowly stir in the
  baking powder and 1/4 cup of the liquid from cooking the dates, until the
  cake mixture resembles thick pancake batter. Drain off remainder of date
  cooking liquid and discard. Stir in the dates.

  Bake for 30 to 40 minutes, or until cooked in the center.

  TO PREPARE CARAMEL SAUCE: Combine the butter, whipping cream, brown sugar
  and vanilla. Bring to a boil; reduce to simmer, and cook for 3 minutes.

  TO SERVE: Drizzle some of the sauce over the cake as it is cooling. Serve
  the rest of the sauce separately.

  Makes 10 servings

  Per Serving:
    Calories: 384 (4% protein, 47% carbohydrate, 50% fat)
    Protein: 4 grams
    Fat: 22 grams
    Cholesterol: 100 mg
    Carbohydrate: 46 grams
    Sodium: 441 mg
    Exchanges: 1 fruit, 1-1/2 starch, 4-1/2 fat

  Source: Oregonian FoodDay 1995
    Typos by Dorothy Flatman
    Posted to MM-Recipes Digest V3 #266

    Date: Sat, 28 Sep 1996 07:00:52 -0500

    From: netdir@cyberspc.mb.ca (S.Pickell)

</step></directions></recipe></recipeml>


text:
package org.apache.hadoop.hive.ql.metadata;

import com.google.common.collect.Lists;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest;
import org.apache.hadoop.hive.metastore.api.Partition;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
import org.apache.hadoop.hive.metastore.api.SerDeInfo;
import org.apache.hadoop.hive.metastore.api.SkewedInfo;
import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
import org.apache.hadoop.hive.metastore.client.CustomIgnoreRule;
import org.apache.hadoop.hive.metastore.client.TestAddPartitions;
import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder;
import org.apache.hadoop.hive.metastore.client.builder.TableBuilder;
import org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService;
import org.apache.hadoop.hive.ql.session.SessionState;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
 * Test class for adding partitions related methods on temporary tables.
 */
@RunWith(Parameterized.class)
@Category(MetastoreCheckinTest.class)
public class TestSessionHiveMetastoreClientAddPartitionsTempTable
    extends TestAddPartitions {

  private HiveConf conf;

  public TestSessionHiveMetastoreClientAddPartitionsTempTable(String name, AbstractMetaStoreService metaStore) {
    super(name, metaStore);
    ignoreRule = new CustomIgnoreRule();
  }

  @Before
  public void setUp() throws Exception {
    initHiveConf();
    SessionState.start(conf);
    setClient(Hive.get(conf).getMSC());
    getClient().dropDatabase(DB_NAME, true, true, true);
    getMetaStore().cleanWarehouseDirs();
    new DatabaseBuilder().
        setName(DB_NAME).
        create(getClient(), conf);
  }

  private void initHiveConf() throws HiveException {
    conf = Hive.get().getConf();
    conf.setBoolVar(HiveConf.ConfVars.METASTORE_FASTPATH, true);
  }

  @Override
  protected Table createTable(String dbName, String tableName, List<FieldSchema> partCols, String location)
      throws Exception {
    new TableBuilder().setDbName(dbName).setTableName(tableName).addCol("test_id", "int", "test col id")
        .addCol("test_value", "string", "test col value")
        .addTableParam("partTestTableParamKey", "partTestTableParamValue").setPartCols(partCols)
        .addStorageDescriptorParam("partTestSDParamKey", "partTestSDParamValue").setSerdeName(tableName)
        .setStoredAsSubDirectories(false).addSerdeParam("partTestSerdeParamKey", "partTestSerdeParamValue")
        .setLocation(location).setTemporary(true).create(getClient(), conf);
    return getClient().getTable(dbName, tableName);
  }

  protected void createExternalTable(String tableName, String location) throws Exception {
    new TableBuilder().setDbName(DB_NAME).setTableName(tableName).addCol("test_id", "int", "test col id")
        .addCol("test_value", DEFAULT_COL_TYPE, "test col value").addPartCol(YEAR_COL_NAME, DEFAULT_COL_TYPE)
        .addTableParam("EXTERNAL", "TRUE").setLocation(location).setTemporary(true).create(getClient(), conf);
  }

  @Override
  protected void verifyPartition(Table table, String name, List<String> values, int index) throws Exception {

    Partition part = getClient().getPartition(table.getDbName(), table.getTableName(), name);
    Assert.assertNotNull("The partition should not be null.", part);
    assertEquals("The table name in the partition is not correct.", table.getTableName(), part.getTableName());
    List<String> partValues = part.getValues();
    assertEquals(values.size(), partValues.size());
    Assert.assertTrue("The partition has wrong values.", partValues.containsAll(values));
    assertEquals("The DB name in the partition is not correct.", table.getDbName(), part.getDbName());
    assertEquals("The last access time is not correct.", 123456, part.getLastAccessTime());
    assertEquals("The partition's parameter map should contain the partparamkey - partparamvalue pair.",
        DEFAULT_PARAM_VALUE + index, part.getParameters().get(DEFAULT_PARAM_KEY + index));
    StorageDescriptor sd = part.getSd();
    Assert.assertNotNull("The partition's storage descriptor must not be null.", sd);
    assertEquals("The input format is not correct.", "TestInputFormat" + index, sd.getInputFormat());
    assertEquals("The output format is not correct.", "TestOutputFormat" + index, sd.getOutputFormat());
    assertEquals("The serdeInfo name is not correct.", "partserde" + index, sd.getSerdeInfo().getName());
    assertEquals(
        "The parameter map of the partition's storage descriptor should contain the partsdkey - partsdvalue pair.",
        "partsdvalue" + index, sd.getParameters().get("partsdkey" + index));
    assertEquals("The parameter's location is not correct.",
        getMetaStore().getWarehouseRoot() + "/" + TABLE_NAME + "/" + name, sd.getLocation());
    Assert.assertTrue("The parameter's location should exist on the file system.",
        getMetaStore().isPathExists(new Path(sd.getLocation())));
    Assert.assertFalse("The partition should not inherit the table parameters.",
        part.getParameters().keySet().contains(table.getParameters().keySet()));
  }

  @Override
  protected void verifyPartitionAttributesDefaultValues(Partition partition, String tableLocation) {
    Assert.assertNotEquals("The partition's last access time should be set.", 0, partition.getLastAccessTime());
    Assert.assertNotEquals("The partition's create time should be set.", 0, partition.getCreateTime());
    StorageDescriptor sd = partition.getSd();
    Assert.assertNotNull("The storage descriptor of the partition must not be null.", sd);
    assertEquals("The partition location is not correct.", tableLocation + "/year=2017", sd.getLocation());
    assertEquals("The input format doesn't have the default value.", "org.apache.hadoop.hive.ql.io.HiveInputFormat",
        sd.getInputFormat());
    assertEquals("The output format doesn't have the default value.", "org.apache.hadoop.hive.ql.io.HiveOutputFormat",
        sd.getOutputFormat());
    Assert.assertFalse("The compressed attribute doesn't have the default value.", sd.isCompressed());
    Assert.assertFalse("The storedAsSubDirectories attribute doesn't have the default value.",
        sd.isStoredAsSubDirectories());
    assertEquals("The numBuckets attribute doesn't have the default value.", 0, sd.getNumBuckets());
    Assert.assertTrue("The default value of the attribute 'bucketCols' should be an empty list.",
        sd.getBucketCols().isEmpty());
    Assert.assertTrue("The default value of the attribute 'sortCols' should be an empty list.",
        sd.getSortCols().isEmpty());
    Assert.assertTrue("Per default the storage descriptor parameters should be empty.", sd.getParameters().isEmpty());
    SerDeInfo serdeInfo = sd.getSerdeInfo();
    Assert.assertNotNull("The serdeInfo attribute should not be null.", serdeInfo);
    Assert.assertNull("The default value of the serde's name attribute should be null.", serdeInfo.getName());
    assertEquals("The serde's 'serializationLib' attribute doesn't have the default value.",
        "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe", serdeInfo.getSerializationLib());
    Assert.assertTrue("Per default the serde info parameters should be empty.", serdeInfo.getParameters().isEmpty());
    SkewedInfo skewedInfo = sd.getSkewedInfo();
    Assert.assertTrue("Per default the skewedInfo column names list should be empty.",
        skewedInfo.getSkewedColNames().isEmpty());
    Assert.assertTrue("Per default the skewedInfo column value list should be empty.",
        skewedInfo.getSkewedColValues().isEmpty());
    Assert.assertTrue("Per default the skewedInfo column value location map should be empty.",
        skewedInfo.getSkewedColValueLocationMaps().isEmpty());
  }

  @Test
  @Override
  public void testAddPartitionNullLocationInTableToo() throws Exception {
    createTable(DB_NAME, TABLE_NAME, null);
    Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, null);
    getClient().add_partition(partition);
    Partition part = getClient().getPartition(DB_NAME, TABLE_NAME, "year=2017");
    Assert.assertTrue(getMetaStore().isPathExists(new Path(part.getSd().getLocation())));
    assertEquals(SessionState.get().getTempTables().get(DB_NAME).get(TABLE_NAME).getSd().getLocation() + "/year=2017",
        part.getSd().getLocation());
  }

  @Test
  @Override
  public void testAddPartitionForExternalTableNullLocation() throws Exception {
    String tableName = "part_add_ext_table";
    createExternalTable(tableName, null);
    Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE, null);
    getClient().add_partition(partition);
    Partition resultPart = getClient().getPartition(DB_NAME, tableName, Lists.newArrayList(DEFAULT_YEAR_VALUE));
    Assert.assertNotNull(resultPart);
    Assert.assertNotNull(resultPart.getSd());
    assertEquals(SessionState.get().getTempTables().get(DB_NAME).get(tableName).getSd().getLocation() + "/year=2017",
        resultPart.getSd().getLocation());
  }

  @Test
  @Override
  public void testAddPartitionsNullLocationInTableToo() throws Exception {
    createTable(DB_NAME, TABLE_NAME, null);
    List<Partition> partitions = new ArrayList<>();
    Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, null);
    partitions.add(partition);
    getClient().add_partitions(partitions);

    Partition part = getClient().getPartition(DB_NAME, TABLE_NAME, "year=2017");
    assertEquals(SessionState.get().getTempTables().get(DB_NAME).get(TABLE_NAME).getSd().getLocation() + "/year=2017",
        part.getSd().getLocation());
    Assert.assertTrue(getMetaStore().isPathExists(new Path(part.getSd().getLocation())));
  }

  @Test
  @Override
  public void testAddPartitionsForExternalTableNullLocation() throws Exception {
    String tableName = "part_add_ext_table";
    createExternalTable(tableName, null);
    Partition partition1 = buildPartition(DB_NAME, tableName, "2017", null);
    Partition partition2 = buildPartition(DB_NAME, tableName, "2018", null);
    List<Partition> partitions = Lists.newArrayList(partition1, partition2);
    getClient().add_partitions(partitions);

    List<Partition> resultParts =
        getClient().getPartitionsByNames(DB_NAME, tableName, Lists.newArrayList("year=2017", "year=2018"));
    Assert.assertNotNull(resultParts);
    Assert.assertEquals(2, resultParts.size());
    String defaultTableLocation = SessionState.get().getTempTables().get(DB_NAME).get(tableName).getSd().getLocation();
    String defaultPartLocation1 = defaultTableLocation + "/year=2017";
    String defaultPartLocation2 = defaultTableLocation + "/year=2018";
    if (resultParts.get(0).getValues().get(0).equals("2017")) {
      Assert.assertEquals(defaultPartLocation1, resultParts.get(0).getSd().getLocation());
      Assert.assertEquals(defaultPartLocation2, resultParts.get(1).getSd().getLocation());
    } else {
      Assert.assertEquals(defaultPartLocation2, resultParts.get(0).getSd().getLocation());
      Assert.assertEquals(defaultPartLocation1, resultParts.get(1).getSd().getLocation());
    }
  }
}


text:
"use strict";

var d              = require("d")
  , validateSymbol = require("../../../validate-symbol");

var registry = Object.create(null);

module.exports = function (SymbolPolyfill) {
	return Object.defineProperties(SymbolPolyfill, {
		for: d(function (key) {
			if (registry[key]) return registry[key];
			return (registry[key] = SymbolPolyfill(String(key)));
		}),
		keyFor: d(function (symbol) {
			var key;
			validateSymbol(symbol);
			for (key in registry) {
				if (registry[key] === symbol) return key;
			}
			return undefined;
		})
	});
};


text:
title: 'About'
layout: 'page'
---

A place on the interenet for the ramblings of [Ruairi O'Brien](https://github.com/ruairitobrien) and [George Boyle](https://github.com/Dockheas23).


text:
package com.mistraltech.bogen.bench.basic_extensible_if;

import com.mistraltech.bogen.bench.model.WidgetA;
import org.junit.Test;

import static com.mistraltech.bogen.bench.basic_extensible.WidgetABuilder.aWidgetAFrom;
import static com.mistraltech.bogen.bench.basic_extensible_if.WidgetABuilder.aWidgetA;
import static com.mistraltech.bogen.bench.model.matchers.WidgetAMatcher.aWidgetAThat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class TestBasicExtensible {
    @Test
    public void test() {
        WidgetABuilder<?, WidgetA> widgetABuilder = aWidgetA().withProp1("prop1").withProp2("prop2");
        WidgetA widgetA1 = widgetABuilder.build();
        WidgetA widgetA2 = aWidgetAFrom(widgetA1).build();

        assertThat(widgetA1, is(aWidgetAThat().hasProp1("prop1").hasProp2("prop2")));
        assertThat(widgetA2, is(aWidgetAThat().hasProp1("prop1").hasProp2("prop2")));
    }
}


text:
<?php
namespace com\japha\native;

use japha\lang\Object;

/**
 * $Id$
 *
 * Includes Japha io package:
 * Reader, Writer, IoReaderWrapper, IoWriterWrapper -- { true === ($we == need($this)) }
 *
 * @author Ryan Gantt
 * @version $Revision$ $Date$
 */
class LinkedFiles extends Object
{
	static $count;
	private $object;

	function __construct()
	{
		$this->count++;
	}

	public function setObject( &$object )
	{
		$this->object = $object;
	}

	public function &getObject()
	{
		return $this->object;
	}

	public function _previous()
	{
		return $this->count - 1;
	}

	public function _next()
	{
		return $this->count + 1;
	}
}

class GlueFile
{
	private $name = "";
	private $size = 0;
	private $checksum = "";
	private $data = array();
	static $count = 0;

	function __construct()
	{
		$this->count++;
	}

	public function __get( $key, &$value )
	{
		if(isset($this->$key))
		{
			$value = $this->$key;
			return true;
		}
		return false;
	}

	public function __set( $key, $value )
	{
		$this->$key = $value;
		return true;
	}

	public function compareSum( $newSum )
	{
		if(!strlen($newSum) == 32)
		{
			$newSum = md5($newSum);
		}
		return $this->checksum === $newSum ? true : false;
	}

	public function compareSize( $size )
	{
		if(!is_integer($size))
		{
			$size = (int)$size;
		}
		return $this->size === $size ? true : false;
	}

	public function appendLine( $data )
	{
		$this->data[] = $data;
	}

	private function returnFile()
	{
		foreach($this->data as $key => $value)
		{
			$total .= $value."\n";
		}
		return $total;
	}
}
overload("GlueFile");

/**
 * Class UnMelder
 * -=-=-=-=-=-=-=
 * Unpacks and unglues a melded data file
 * --
 *
 * Since this will probably get used by people other than me --
 * It has been engineered to acheieve black-box functionality
 *
 * I.E. -- Put a file in, get a file out. No questions asked.
 * All functions are private. All members are private.
 *
 * @author Ryan Gantt
 */
class UnMelder
{
	private $count = 0;
	private $filename;
	private $delimeter = "~";
	private $isCode = false;

	// Data is a Linked List.
	private $data = array();

	function __construct( $filename, $destination, $delimeter = "~" )
	{
		if(file_exists($filename))
		{
			$this->reader = new IoReaderWrapper( $filename );
		}
		else
		{
			throw new Exception($filename." does not exist!");
		}
		$this->delimeter = $delimeter;
		$this->destination = $destination;
	}

	private function parseFile()
	{
		while(false !== ($line = $this->readLine()))
		{
			$this->parseLine( $line );
		}
	}

	private function parseLine( $line )
	{
		if($this->isCode)
		{
			$this->{data[$this->count]}->appendLine( $line );
		{
		else
		{
			$this->differentiate( $line );
		}
	}

	private function differentiate( $data )
	{
		switch( substr( $data, 0, 1 ) )
		{
			case '#':
				if(in_array(substr($data, 1, 4)))
					$this->{data[$this->count]}->substr($data, 1, 4) = substr($data, 5);
				break;
			case $this->delimeter:
				++$this->count;
				$this->data[$this->count] = new GlueFile();
				break;
			case '!':
				if(eregi( "!#start#!", $data ))
					$this->isCode = true;
				else if(eregi( "!#stop#!", $data ))
					$this->isCode = false;
				break;
		}
	}

	private function readLine()
	{
		return $this->reader->readLine( 4096 );
	}
}

$u = new UnMelder( "newShizzy.shizzle", "." );
?>


text:
package advanced;

import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.coders.Coder;
import org.apache.beam.sdk.io.gcp.pubsub.PubsubIO;
import org.apache.beam.sdk.options.Default;
import org.apache.beam.sdk.options.Description;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.PipelineOptionsFactory;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.transforms.Sample;
import org.apache.beam.sdk.transforms.windowing.*;
import org.apache.beam.sdk.values.KV;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.joda.time.Duration;
import org.joda.time.Instant;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.Collection;

public class CustomWindows {

    private static final Logger LOG = LoggerFactory.getLogger(CustomWindows.class);

    public interface CustomWindowsOptions extends PipelineOptions {
        @Description("Topic to read from")
        @Default.String("projects/pubsub-public-data/topics/taxirides-realtime")
        String getTopic();

        void setTopic(String value);
    }

    // Fixed window with size dependent on the element value
    public static class WindowByValueElement extends WindowFn<KV<String, Integer>, IntervalWindow> {

        @Override
        public Collection<IntervalWindow> assignWindows(AssignContext c) {
            Instant timestamp = c.timestamp();
            Integer passengers = c.element().getValue();

            // Assign window size depending on number passengers
            Duration size = Duration.standardMinutes(passengers * 10);

            // Define lower/upper bound
            Instant start = new Instant(
                    timestamp.getMillis() - timestamp.plus(size).getMillis() % size.getMillis());
            Instant end = start.plus(size);
            return Arrays.asList(new IntervalWindow(start, end));
        }

        // Mandatory methods
        @Override
        public void mergeWindows(MergeContext c) {
            // This defines what to do in case the windows need to be merged (not the case here)
            // Example: https://github.com/apache/beam/blob/master/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/MergeOverlappingIntervalWindows.java
        }

        @Override
        public boolean isCompatible(WindowFn<?, ?> other) {
            return this.equals(other); // equals defined bellow
        }

        @Override
        public void verifyCompatibility(WindowFn<?, ?> other) throws IncompatibleWindowException {
            if (!this.isCompatible(other)) {
                throw new IncompatibleWindowException(
                        other,
                        String.format(
                                "Only %s objects with the same sizes and key to check are compatible.",
                                WindowByValueElement.class.getSimpleName()));
            }
        }

        @Override
        public boolean equals(@Nullable Object object) {
            return object instanceof WindowByValueElement;
        }

        @Override
        public Coder<IntervalWindow> windowCoder() {
            return IntervalWindow.getCoder();
        }

        @Override
        public WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn() {
            return null;
        }
    }

    public static void main(String[] args) {
        CustomWindowsOptions options = PipelineOptionsFactory.fromArgs(args).withValidation().as(CustomWindowsOptions.class);

        Pipeline p = Pipeline.create(options);

        p
                .apply("ReadFromPubSub", PubsubIO.readStrings().fromTopic(options.getTopic()))
                .apply("to KV", ParDo.of(new DoFn<String, KV<String, Integer>>() {
                            @ProcessElement
                            public void processElement(ProcessContext c) {
                                JSONObject json = new JSONObject(c.element());

                                String rideId = json.getString("ride_id");
                                Integer passengerCount = json.getInt("passenger_count");

                                // Discard elements without passengers
                                if (passengerCount > 0) {
                                    c.output(KV.of(rideId, passengerCount));
                                }
                            }
                        })
                )
                .apply(Window.into(new WindowByValueElement()))
                .apply(Sample.fixedSizePerKey(1))
                .apply("log window size", ParDo.of(new DoFn<KV<String, Iterable<Integer>>, String>() {
                    @ProcessElement
                    public void processElement(ProcessContext c, BoundedWindow w) {
                        LOG.info("Element " + c.element().toString() +
                                " in window " + w.toString());
                        c.output(c.element().toString());
                    }
                }));

        p.run();
    }
}


text:
import {KernelConfig, KernelFunc, ZerosLike, ZerosLikeInputs} from '@tensorflow/tfjs-core';

import {BackendWasm} from '../backend_wasm';

function zerosLike(args: {inputs: ZerosLikeInputs, backend: BackendWasm}) {
  const {inputs: {x}, backend} = args;
  const out = backend.makeOutput(x.shape, x.dtype);
  const outVals = backend.typedArrayFromHeap(out);
  outVals.fill(0);
  return out;
}

export const zerosLikeConfig: KernelConfig = {
  kernelName: ZerosLike,
  backendName: 'wasm',
  kernelFunc: zerosLike as {} as KernelFunc,
};


text:
cd L:\git\vskeddemolist\vskeddemos\htmljavascriptcss\vue2lesson
vue create lesson2
按下选择
Default (Vue 2 babel,eslint)

cd lesson2

npm install axios
npm i mockjs

npm run serve


text:
This is a list of available drivers for the SQL input plugin. The data-source-name (DSN) is driver specific and
might change between versions. Please check the driver documentation for available options and the format.

| database             | driver                                                    | aliases         | example DSN                                                                            | comment                                                                                |
| -------------------- | --------------------------------------------------------- | --------------- | -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| CockroachDB          | [cockroach](https://github.com/jackc/pgx)                 | postgres or pgx | see _postgres_ driver                                                                  | uses PostgresQL driver                                                                                |
| MariaDB              | [maria](https://github.com/go-sql-driver/mysql)           | mysql           | see _mysql_ driver                                                                     | uses MySQL driver                                                                                |
| Microsoft SQL Server | [sqlserver](https://github.com/denisenkom/go-mssqldb)     | mssql           | `username:password@host/instance?param1=value&param2=value`                            | uses newer _sqlserver_ driver                                                                                |
| MySQL                | [mysql](https://github.com/go-sql-driver/mysql)           |                 | `[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]` | see [driver docs](https://github.com/go-sql-driver/mysql) for more information                                        |
| PostgreSQL           | [postgres](https://github.com/jackc/pgx)                  | pgx             | `[user[:password]@][netloc][:port][,...][/dbname][?param1=value1&...]`                 | see [postgres docs](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) for more information |
| SQLite               | [sqlite](https://gitlab.com/cznic/sqlite)                 |                 | `filename`                                                                             | see [driver docu](https://pkg.go.dev/modernc.org/sqlite) for more information                                         |
| TiDB                 | [tidb](https://github.com/go-sql-driver/mysql)            | mysql           | see _mysql_ driver                                                                     | uses MySQL driver                                                                                |
| ClickHouse           | [clickhouse](https://github.com/ClickHouse/clickhouse-go) |                 | `tcp://host:port[?param1=value&...&paramN=value]"`                                     | see [clickhouse-go docs](https://github.com/ClickHouse/clickhouse-go#dsn) for more information                        |

## Comments

### Driver aliases

Some database drivers are supported though another driver (e.g. CockroachDB). For other databases we provide a more
obvious name (e.g. postgres) compared to the driver name. For all of those drivers you might use an _alias_ name
during configuration.

### Example data-source-name DSN

The given examples are just that, so please check the driver documentation for the exact format
and available options and parameters. Please note that the format of a DSN might also change
between driver version.

### Type conversions

Telegraf relies on type conversion of the database driver and/or the golang sql framework. In case you find
any problem, please open an issue!

## Help

If nothing seems to work, you might find help in the telegraf forum or in the chat.

### The documentation is wrong

Please open an issue or even better send a pull-request!

### I found a bug

Please open an issue or even better send a pull-request!

### My database is not supported

We currently cannot support CGO drivers in telegraf! Please check if a **pure Go** driver for the [golang sql framework](https://golang.org/pkg/database/sql/) exists.
If you found such a driver, please let us know by opening an issue or even better by sending a pull-request!


text:
package org.openxava.annotations;

import java.lang.annotation.*;

/**
 * A group of @{@link Action} associated to the same member.

 *
 * Applies to properties and references.

 *
 * It allows to define a value different for @{@link Action} in each view.

 * Example:
 *

 *  @Actions({
 *    @Action(forViews="DEFAULT", value= ... ),
 *    @Action(forViews="Simple, VerySimple", value= ... ),
 *    @Action(forViews="Complete", value= ... )
 *  })
 *

 *
 * @author Javier Paniza
 */

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.METHOD })
public @interface Actions {

	Action [] value();

}


text:
set -ex
source $(dirname $0)/provision-config.sh

OPENSHIFT_SDN=$4

NETWORK_CONF_PATH=/etc/sysconfig/network-scripts/
sed -i 's/^NM_CONTROLLED=no/#NM_CONTROLLED=no/' ${NETWORK_CONF_PATH}ifcfg-eth1

systemctl restart network

# Setup hosts file to support ping by hostname to each minion in the cluster from apiserver
node_list=""
minion_ip_array=(${MINION_IPS//,/ })
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
  minion=${MINION_NAMES[$i]}
  node_list="${node_list},${minion}"
  ip=${minion_ip_array[$i]}
  if [ ! "$(cat /etc/hosts | grep $minion)" ]; then
    echo "Adding $minion to hosts file"
    echo "$ip $minion" >> /etc/hosts
  fi
done
if ! grep ${MASTER_IP} /etc/hosts; then
  echo "${MASTER_IP} ${MASTER_NAME}" >> /etc/hosts
fi
node_list=${node_list:1}

# Install the required packages
yum install -y docker-io git golang e2fsprogs hg net-tools bridge-utils which

# Build openshift
echo "Building openshift"
pushd /vagrant
  ./hack/build-go.sh
  cp _output/local/go/bin/openshift /usr/bin
  ./hack/install-etcd.sh
popd

# Initialize certificates
echo "Generating certs"
pushd /vagrant
  SERVER_CONFIG_DIR="`pwd`/openshift.local.config"
  VOLUMES_DIR="`pwd`/openshift.local.volumes"
  MASTER_CONFIG_DIR="${SERVER_CONFIG_DIR}/master"
  CERT_DIR="${MASTER_CONFIG_DIR}"

  # Master certs
  /usr/bin/openshift admin ca create-master-certs \
    --overwrite=false \
    --cert-dir=${CERT_DIR} \
    --master=https://${MASTER_IP}:8443 \
    --hostnames=${MASTER_IP},${MASTER_NAME}

  # Certs for nodes
  for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
    minion=${MINION_NAMES[$i]}
    ip=${minion_ip_array[$i]}

    /usr/bin/openshift admin create-node-config \
      --node-dir="${SERVER_CONFIG_DIR}/node-${minion}" \
      --node="${minion}" \
      --hostnames="${minion},${ip}" \
      --master="https://${MASTER_IP}:8443" \
      --network-plugin="redhat/openshift-ovs-subnet" \
      --node-client-certificate-authority="${CERT_DIR}/ca.crt" \
      --certificate-authority="${CERT_DIR}/ca.crt" \
      --signer-cert="${CERT_DIR}/ca.crt" \
      --signer-key="${CERT_DIR}/ca.key" \
      --signer-serial="${CERT_DIR}/ca.serial.txt" \
      --volume-dir="${VOLUMES_DIR}_${minion}"
  done

popd

# Start docker
systemctl enable docker.service
systemctl start docker.service

# Create systemd service
cat <<EOF > /usr/lib/systemd/system/openshift-master.service
[Unit]
Description=OpenShift Master
Requires=docker.service network.service
After=network.service

[Service]
ExecStart=/usr/bin/openshift start master --master=https://${MASTER_IP}:8443 --nodes=${node_list} --network-plugin=redhat/openshift-ovs-subnet
WorkingDirectory=/vagrant/

[Install]
WantedBy=multi-user.target
EOF

# Start the service
systemctl daemon-reload
systemctl start openshift-master.service

# if SDN requires service on master, then set it up
if [ "${OPENSHIFT_SDN}" != "ovs-gre" ]; then
  export ETCD_CAFILE=/vagrant/openshift.local.config/master/ca.crt
  export ETCD_CERTFILE=/vagrant/openshift.local.config/master/master.etcd-client.crt
  export ETCD_KEYFILE=/vagrant/openshift.local.config/master/master.etcd-client.key
  $(dirname $0)/provision-master-sdn.sh $@
fi

# Set up the KUBECONFIG environment variable for use by oc
echo 'export KUBECONFIG=/vagrant/openshift.local.config/master/admin.kubeconfig' >> /root/.bash_profile
echo 'export KUBECONFIG=/vagrant/openshift.local.config/master/admin.kubeconfig' >> /home/vagrant/.bash_profile


text:
layout: post
title: "Avoiding DateTime Headaches"
excerpt: "Sometimes PowerShell just throws the system culture out the window and assumes that you meant to supply the date in the American style."
modified: 2017-11-06 21:15:00 +1300
date: 2017-11-06 21:15:00 +1300
tags: [powershell, nugget]
comments: true
image:
 thumb: /datetime-headache/thumb.jpg
 credit: Max Pixel (http://maxpixel.freegreatpicture.com/)
 creditlink: http://maxpixel.freegreatpicture.com/Agenda-Pressure-Time-Plans-819288
---

There's a number of things that - as a non-American - can cause confusion when
dealing with America:

-   Imperial rather than Metric units of measurement,
-   Words missing the letter 'U,'
-   Tipping,
-   Backwards dates.

A number of these applies to systems or software developed in America. The last
one specifically, dates, is the subject of this short post.

### When dates don't go as planned

Before getting into things, I wanted to thanks [Dan
Blank](https://twitter.com/danblank000) for inspiring this post during a
conversation we had on Twitter.

...with the culture now changed, why is this still converting to US format? pic.twitter.com/eeGb6eY4pi
— Dan Blank (@danblank000) October 9, 2017

As a primer for any American readers, how would you say the date: 12/10/2017?

Chances are you're saying "December 10, 2017", but to a lot of the world this is
actually "12 October, 2017."

That's just a human reading the date out loud. You can imagine how this might
cause some level of confusion, and even frustration, when you're providing dates
in this format to PowerShell (as an example) and it helpfully interprets it
incorrectly.

### You'd better get cultured!

Windows allows us to set the culture on our workstations. This changes the
currency, date and other number formats. With my culture set to "en-NZ" (New
Zealand English), the system displays the date in the correct format:

![Windows System Date](/images/datetime-headache/SystemDate.png)

*Note for clarity that this is the 6th of November.*

PowerShell will even output the date in this format when I ask for it in the
"short date" format:

![Get-Date -Format d](/images/datetime-headache/PowerShell1.png)

The trouble is that it isn't consistent. Sometimes it just throws the system
culture out the window and assumes that you meant to supply the date in the
American style, such as when converting a string to a datetime:

![DateTime from String - Wrong](/images/datetime-headache/PowerShell2.png)

### My "solution"

I use the term solution loosely, but my advice is to never assume that the
system (PowerShell or otherwise) knows which date format is appropriate.

If I'm supplying a date as a string, I always go with the unambiguous [ISO
8601](https://www.iso.org/iso-8601-date-and-time-format.html) date format,
YYYY-MM-DD. To revisit the previous example, that would be:

![DateTime from String - Right, because ISO](/images/datetime-headache/PowerShell3.png)

### But that's not what I have to work with!

Then make it so!

I'm being serious, leverage PowerShell to change the date format coming from
your (properly localized) log files:

```powershell
$InputDate = '6/11/2017'
$SplitDate = $InputDate.Split('/')
$OutputDate = '{0}-{1:D2}-{2:D2}' -f $SplitDate[2], [int] $SplitDate[1], [int] $SplitDate[0]
$OutputDate
# 2017-11-06
```

Obviously, if you're doing this a lot, you might consider making a function to
do this over a number of different scripts.

### We live in an international world

I have volunteered my time to a number of American websites in the past to the
point where I'm used to just spelling things according to the American
dictionary. I tend to lean towards that as the safer option when there is a
binary choice between American or British/New Zealand styles.

However, we can all help each other by picking an unambiguous middle ground
where they exist, such as the ISO 8601 dates.

This helps to ensure readers (from anywhere in the world) can parse what we're
writing with ease and avoids confusion or misunderstandings.


text:
import path from 'path';
import yargs from 'yargs';
import chalk from 'chalk';
import check from 'check-es3-syntax';

const { argv } = yargs
  .usage('Usage: $0 [options] file_or_directory_name(s)')
  .demand(1, 'Must be called with at least one file')
  .option('patch', {
    describe: 'print patch-file to disk',
    default: false,
    type: 'boolean',
  })
  .option('d', {
    alias: 'directory',
    describe:
      'if `file` is used, this sets a directory to write the files to. defaults to `process.cwd()`',
    type: 'string',
  })
  .option('k', {
    alias: 'kill',
    describe: 'exit the process with -1 if differences are found',
    default: false,
    type: 'boolean',
  })
  .option('p', {
    alias: 'print',
    describe: 'print a colorized diff to the console',
    default: false,
    type: 'boolean',
  })
  .implies('directory', 'patch')
  .alias('h', 'help');

const colorize = part => {
  if (part.added) return chalk.green(part.value);
  if (part.removed) return chalk.red(part.value);

  return chalk.grey(part.value);
};

check(argv._, {
  directory: argv.directory || process.cwd(),
  savePatchToDisk: argv.patch,
})
  .tap(arr => {
    if (arr.length === 0) return;

    console.log(
      'There are differences between input version and the ES3 version'
    );

    if (!argv.print) {
      if (argv.patch) {
        console.log('Patch file written to disk');
      } else {
        console.log(
          'Pass `-p` to the cli to print the difference, or `--patch` to create a patch file'
        );
      }

      return;
    }

    const output = arr
      .map(({ textDiff, ...rest }) => {
        const text = textDiff.reduce(
          (memo, part) => `${memo}${colorize(part)}`,
          ''
        );

        return {
          ...rest,
          text,
        };
      })
      .reduce(
        (memo, { filename, text }) =>
          `${memo}${path.resolve(filename)}\n${text}\n\n`,
        ''
      )
      .trim();

    console.log(output);
  })
  .tap(arr => {
    if (argv.kill && arr.length > 0) process.exit(-1);
  })
  .catch(e => {
    console.error(e);
    process.exit(-1);
  });


text:
using System;
using System.ComponentModel;
using System.Data;
using ingresos;
using System.Windows.Forms;
using dbFactory;
using DevExpress.XtraEditors;

namespace Consulta
{
    public partial class frmConsultaNueva : Form
    {

        private DataTable medRecetados = new DataTable();

        public frmConsultaNueva()
        {
            InitializeComponent();
            this.medRecetados.Columns.Add("Medicamento");
            this.medRecetados.Columns.Add("Cantidad");
            this.medRecetados.Columns.Add("Dosis");
            this.medRecetados.Columns.Add("id_medicamento");
            this.gridControlConsulta.DataSource = this.medRecetados;
            this.gridViewConsulta.Columns[3].Visible = false;
        }

        private void sbAgregar_Click(object sender, EventArgs e)
        {
            this.agregarProducto();
        }

        private void txtMedicamento_Validating(object sender, CancelEventArgs e)
        {
            if(txtMedicamento.Text == "")
            {
                txtMedicamento.Tag = null;
                return;
            }

            if(txtMedicamento.Tag == null && txtMedicamento.Text != "")
            {
                frmListadoDeProductos productoSeleccionado = new frmListadoDeProductos(txtMedicamento.Text);
                if(productoSeleccionado.ShowDialog() == DialogResult.OK)
                {
                    txtMedicamento.Tag = productoSeleccionado.datosProducto[1];
                    txtMedicamento.Text = productoSeleccionado.datosProducto[0];
                }
                else
                {
                    txtMedicamento.Tag = null;
                    txtMedicamento.Text = "";
                }
            }
        }

        private void agregarProducto()
        {
            if (this.txtMedicamento.Tag != null)
            {
                this.medRecetados.Rows.Add(this.txtMedicamento.Text, this.txtCantidad.Text, this.txtDosis.Text, this.txtMedicamento.Tag.ToString());
                this.txtMedicamento.Text = this.txtCantidad.Text = this.txtDosis.Text = "";
                this.txtMedicamento.Tag = null;
            }
        }

        private void txtPaciente_Validating(object sender, CancelEventArgs e)
        {
            if (txtPaciente.Text == "")
            {
                txtPaciente.Tag = null;
                return;
            }

            if (txtPaciente.Tag == null && txtPaciente.Text != "")
            {
                frmListadoPacientes pacienteSeleccionado = new frmListadoPacientes(txtPaciente.Text);
                if (pacienteSeleccionado.ShowDialog() == DialogResult.OK)
                {
                    txtPaciente.Tag = pacienteSeleccionado.data[0];
                    txtPaciente.Text = pacienteSeleccionado.data[1];
                }
                else
                {
                    txtPaciente.Tag = null;
                    txtPaciente.Text = "";
                }
            }
        }

        private void sbAceptar_Click(object sender, EventArgs e)
        {
            if(txtPaciente.Text == "" && this.medRecetados.Rows.Count < 1){
                XtraMessageBox.Show("Agregue datos antes de guardar la consulta!","Error!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return;
            }
            if(this.agregarConsulta())
                XtraMessageBox.Show("Consulta guardada exitosamente!");
            this.Dispose();
        }

        private Boolean agregarConsulta()
        {
            if (db.connect())
            {
                if(db.executeNonQuery("insert into consultas (descripcion,id_paciente,id_usuario) VALUES (@desc,@id_paciente,@id_usuario)", new String[] { "@desc","@id_paciente","@id_usuario" }, new object[] { txtDescripcion.Text,txtPaciente.Tag.ToString(), usuario.idUsuario }) != -1)
                {
                    DataTable datos = (DataTable)db.executeQuery("select id_consulta from consultas order by fecha_consulta desc") ?? new DataTable();
                    int idConsulta = int.Parse(datos.Rows[0].ItemArray[0].ToString());
                    for(int i = 0;i<this.medRecetados.Rows.Count; i++)
                    {
                        DataRow tmp = this.medRecetados.Rows[i];
                        if(db.executeNonQuery("insert into consulta_detalle (id_consulta,id_producto,cantidad,dosis) VALUES (@id_consulta,@id_producto,@cantidad,@dosis)", new String[] { "@id_consulta","@id_producto","@cantidad","@dosis" }, new object[] { idConsulta, tmp.ItemArray[3].ToString(), tmp.ItemArray[1].ToString(), tmp.ItemArray[2].ToString() }) == -1)
                        {
                            db.executeNonQuery("delete from consultas where id_consulta = @1", new String[] { "@1" }, new object[] { idConsulta });
                            db.executeNonQuery("delete from consulta_detalle where id_consulta = @1", new String[] { "@1" }, new object[] { idConsulta });
                            XtraMessageBox.Show("No se realizaron cambios!", "Error al intentar guardar los datos!",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            return false;
                        }
                    }
                }
                return true;
            }
            return false;
        }

    }
}


text:
layout: default
modal-id: 1
date: 2017-01-11
img: github-pages-sized.png
alt: Github Pages
project-date: November 2016
client: #
clientsite: #
category: Web Development, Jekyll, HTML, CSS, Javascript
description: This website was created as I needed a place to easily list and showcase my projects and so the goal was that it should be as simple as possible. For those reasons, I used Github Pages to host the site as it was free and the process was quite easy using Jekyll to build the website. I used HTML and CSS to write the markup together with the Freelancer Jekyll theme. Jekyll is quite a useful tool as it gives you the ability to set layouts for your pages, it also uses the Liquid Syntax which is easy to write and understand and plus it is fast, simple and secure. Jekyll provides all with the performance benefits of static content with no backend.
---


text:
<?php
namespace app\models;
use yii\db\ActiveRecord;
class config extends ActiveRecord{

}


text:
-   "Whats Tonights Move" is a google maps api based project, written in javascript, Knockout JS, NodeJS, MongoDB, Mongoose and PassportJs.

-	This applications login system is written in NodeJS and validated with PassportJS. Users and user favorite locations saved in a Mongo database.

-	This application gives the user the ability to mark their current location, search for locations within a user specified distance of the marked location, and also save & delete thoes locations in their favorite locations list.

# Installation

- Install NodeJS @ https://nodejs.org/en/
    - https://www.youtube.com/watch?v=1US-P13yKVs

- Install MongoDB @ https://www.mongodb.com/download-center#community
    - https://www.youtube.com/watch?v=_RQ4lET5ejw

- git clone https://github.com/TonyKelly12/Map-API-Project.git

- Type **_npm install_** in the command line to install the package.json file

- Once MongoDB is installed and configured, open command shell and enter **_mongod_** to start mongo server

- Once MongoDB server is running **DO NOT CLOSE SHELL**. Open another shell and enter **_mongo_** to connect your mongo database to the mongo server.

- Once both mongo server and mongo databse are running **DO NOT CLOSE EITHER SHELL** open another shell and enter **_npm start_** to start your development server listening on _port 8000_

# Usage
- On first startup you will be promted to create a login user name and password.

- Once account is created you can log in to the site and visit 3 pages
    - Dashboard
    - Maps
    - Favorite Places

- On the map page start by marking your current location _(Within Louisville, KY)_ at the top of the maps options bar.

- Once current location is set you may search for locations such as banks, restaurants, and hotels.

- Narrow that search down to a certian distance calculated by time and mode of transportation.

- Get routes to thoes locations.

- Save Locations in your favorite locations list.

# Known Issues/Bugs

- _7/24/2017_ Favorite Locations picture on the Dashboard/index page will not populate due to bug in favorite locations array
    - (**_working on a fix_**)

- _7/24/2017_ Initial Place search does not stay confined to initial city.
    - (**_working on a fix_**)

- _7/24/2017_ Hide and show listings buttons in the map options bar bring up hardcoded data from test array.
    - (**_working on a fix_**)


text:
package fr.intech.s5.candiesforall.android.layout;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.text.NumberFormat;
import java.util.Locale;

import fr.intech.s5.candiesforall.android.R;
import fr.intech.s5.candiesforall.android.model.Article;
import fr.intech.s5.candiesforall.android.util.BackendUrl;
import fr.intech.s5.candiesforall.android.util.Cart;
import it.sephiroth.android.library.picasso.Picasso;

/**
 * Created by hugoz on 02/10/2017.
 */

public class DetailActivity extends AppCompatActivity {

    Article article;

    @Override
    protected void onCreate( Bundle savedInstanceState ) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_detail );

        article = getIntent().getExtras().getParcelable( ArticlesAdapter.ITEM_KEY );
        if( article == null ) throw new AssertionError( "Null data article received!" );

        TextView tvName = (TextView) findViewById( R.id.tvItemName );
        TextView tvPrice = (TextView) findViewById( R.id.tvPrice );
        TextView tvDescription = (TextView) findViewById( R.id.tvDescription );
        ImageView ivImage = (ImageView) findViewById( R.id.ivImage );

        tvName.setText( article.getName() );
        tvDescription.setText( article.getDescription() );

        NumberFormat nf = NumberFormat.getCurrencyInstance( Locale.getDefault() );
        tvPrice.setText( nf.format( article.getPrix() ) );

        try {
            Picasso.with( this )
                .load( BackendUrl.IMAGE_ENDPOINT + "/" + article.getArticleId() + ".png" )
                .resizeByMaxSide()
                .into( ivImage );
        } catch( Exception e ) {
            e.printStackTrace();
        }
    }

    public void addClickHandler(View view) {
        if (article == null) throw new AssertionError("Article can't be null!");

        EditText etNbArticle = (EditText) findViewById(R.id.etNumberOfArticle);
        Cart.cart.add( new Cart.CartEntity( article, Integer.parseInt( etNbArticle.getText().toString() ) ) );

        Toast.makeText( this, "Articles added to cart", Toast.LENGTH_SHORT ).show();
        etNbArticle.setText( "" );

        Intent activityIntent = new Intent( this, MainActivity.class );
        this.startActivity( activityIntent );
    }
}


text:
/**
 * @overview W2C datasets of ccm components
 * @author Tea Kless <tea.kless@web.de> 2017
 * @author André Kless <andre.kless@web.de> 2017
 * @license The MIT License (MIT)
 */

ccm.files[ "w2c_datasets.js" ] = {
  "pdf_viewer": {
    "title": "PDF Viewer",
    "abstract": "For rendering a PDF",
    "name": "pdf-viewer",
    "versions": [
      {
        "version": "2.0.0",
        "source": "https://tkless.github.io/ccm-components/pdf-viewer/versions/ccm.pdf_viewer-2.0.0.js",
        "minified": "https://tkless.github.io/ccm-components/pdf-viewer/versions/ccm.pdf_viewer-2.0.0.min.js"
      },
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/pdf-viewer/versions/ccm.pdf_viewer-1.0.0.js",
        "minified": "https://tkless.github.io/ccm-components/pdf-viewer/versions/ccm.pdf_viewer-1.0.0.min.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [
      [ {} ]
    ],
    "factories": [
      {
        "url": "https://tkless.github.io/ccm-components/pdf_viewer_builder/versions/ccm.pdf_viewer_builder-1.0.0.min.js",
        "config": {}
      }
    ]
  },
  "content": {
    "title": "Content",
    "abstract": "For rendering a predefined content.",
    "name": "content",
    "versions": [
      {
        "version": "2.0.0",
        "source": "https://akless.github.io/ccm-components/content/versions/ccm.content-2.0.0.js",
        "minified": "https://akless.github.io/ccm-components/content/versions/ccm.content-2.0.0.min.js"
      },
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/content/versions/ccm.content-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/content/versions/ccm.content-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/content/resources/configs.min.js", "demo" ]
    ]
  },
  "comment": {
    "title": "Comment",
    "abstract": "For rendering a comment to any component.",
    "name": "comment",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/comment/versions/ccm.comment-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos":[ {} ]
  },
  "eval": {
    "title": "Eval",
    "abstract": "For interpreting a given JavaScript expression.",
    "screenshots": [
      "https://akless.github.io/ccm-components/eval/resources/screenshot_1.jpg"
    ],
    "name": "eval",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/eval/versions/ccm.eval-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/eval/versions/ccm.eval-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/eval/resources/configs.min.js", "demo" ]
    ]
  },
  "cloze": {
    "title": "Fill-in-the-Blank Text",
    "abstract": "For rendering a fill-in-the-blank text.",
    "screenshots": [
      "https://akless.github.io/ccm-components/cloze/resources/screenshot_1.jpg",
      "https://akless.github.io/ccm-components/cloze/resources/screenshot_2.jpg",
      "https://akless.github.io/ccm-components/cloze/resources/screenshot_3.jpg"
    ],
    "description": "The component supports solution hints, visual feedback, point allocation, time limitation, different layouts, authentication procedures, customization of buttons and learning analysis.",
    "name": "cloze",
    "versions": [
      {
        "version": "3.9.0",
        "source": "https://akless.github.io/ccm-components/cloze/versions/beta/ccm.cloze-3.9.0.js",
        "minified": "https://akless.github.io/ccm-components/cloze/versions/beta/ccm.cloze-3.9.0.min.js"
      },
      {
        "version": "2.2.0",
        "source": "https://akless.github.io/ccm-components/cloze/versions/ccm.cloze-2.2.0.js",
        "minified": "https://akless.github.io/ccm-components/cloze/versions/ccm.cloze-2.2.0.min.js"
      },
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/cloze/versions/ccm.cloze-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/cloze/versions/ccm.cloze-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/cloze/resources/configs.min.js", "demo" ]
    ],
    "factories": [
      {
        "url": "https://akless.github.io/ccm-components/cloze_builder/versions/ccm.cloze_builder-1.6.0.min.js",
        "config": {}
      }
    ]
  },
  "editor": {
    "title": "Quill Texteditor",
    "abstract": "For rendering a quill text editor.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/editor_preview_1.jpg"
    ],
    "name": "editor",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/editor/versions/ccm.editor-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "fine_upload": {
    "title": "Fine Uploader Connector",
    "abstract": "Upload a file to a server via Fine Uploader",
    "screenshots": [
      "https://mkaul.github.io/ccm-components/fine_upload/resources/screenshot_1.jpg"
    ],
    "description": "In order to embed the famous Fine Uploader software anywhere, use this connector. see https://fineuploader.com/: 'Fine Uploader aims to make file-uploading on the web possible in every browser and mobile device. It is cross-browser, dependency-free, and 100% JavaScript. The product is highly customizable, and allows integrators to fine-tune every aspect of their users' upload experience. Implementation requires only a single CSS file, a JavaScript file, and a server to upload to. Fine Uploader users enjoy widespread browser support and a suite of features, resulting in a smooth experience when uploading files to a website.'",
    "name": "fine_upload",
    "versions": [
      {
        "version": "latest",
        "source": "https://mkaul.github.io/ccm-components/fine_upload/ccm.fine_upload.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/",
    "demos": [ {} ]
  },
  "forum": {
    "title": "Forum",
    "abstract": "For rendering a forum.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/forum_preview_1.png"
    ],
    "name": "forum",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/forum/versions/ccm.forum-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "feedback": {
    "title": "Feedback",
    "abstract": "For rendering a feedback.",
    "name": "feedback",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/feedback/versions/ccm.feedback-1.0.0.min.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [  [ "ccm.get", "https://tkless.github.io/ccm-components/feedback/resources/configs.min.js", "demo" ] ]
  },
  "game_chooser": {
    "title": "Game Chooser",
    "abstract": "Game for quickly choosing one of two answers.",
    "screenshots": [
      "https://mkaul.github.io/ccm-components/game_chooser/resources/screenshot_1.jpg",
      "https://mkaul.github.io/ccm-components/game_chooser/resources/screenshot_2.jpg",
      "https://mkaul.github.io/ccm-components/game_chooser/resources/screenshot_3.jpg"
    ],
    "description": "Game Chooser is a little game implemented in ccm. Game Rules: A number is given and the user has to decide, whether the sum of digits is even or odd as fast as possible. There are two buttons, which the user can press accordingly. The time for choosing is recorded. The range of the numbers can be adjusted via a slider.",
    "name": "game_chooser",
    "versions": [
      {
        "version": "latest",
        "source": "https://mkaul.github.io/ccm-components/game_chooser/versions/ccm.game_chooser-1.0.0.min.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/",
    "demos": [ {} ]
  },
  "geogebra": {
    "title": "GeoGebra Connector",
    "abstract": "ccm connector for GeoGebra",
    "screenshots": [
      "https://mkaul.github.io/ccm-components/geogebra/resources/screenshot_1.jpg"
    ],
    "description": "In order to embed the famous GeoGebra software anywhere, use this connector. For GeoGebra see https://www.geogebra.org: 'GeoGebra is dynamic mathematics software for all levels of education that brings together geometry, algebra, spreadsheets, graphing, statistics and calculus in one easy-to-use package. GeoGebra is a rapidly expanding community of millions of users located in just about every country. GeoGebra has become the leading provider of dynamic mathematics software, supporting science, technology, engineering and mathematics (STEM) education and innovations in teaching and learning worldwide.'",
    "name": "geogebra",
    "versions": [
      {
        "version": "latest",
        "source": "https://mkaul.github.io/ccm-components/geogebra/ccm.geogebra.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/",
    "demos": [ {} ]
  },
  "highlight": {
    "title": "Code Highlighting",
    "abstract": "For Code Highlighting",
    "name": "highlight",
    "versions": [
      {
        "version": "latest",
        "source": "https://mkaul.github.io/ccm-components/highlight/ccm.highlight.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/"
  },
  "input": {
    "title": "Input",
    "abstract": "For user inputs.",
    "name": "input",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/input/versions/ccm.input-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/input/versions/ccm.input-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/input/resources/configs.min.js", "demo" ]
    ]
  },
  "kanban_board": {
    "title": "Kanban Board",
    "abstract": "For rendering a kanban board.",
    "screenshots": [
      "https://akless.github.io/ccm-components/kanban_board/resources/preview_1.png"
    ],
    "name": "kanban_board",
    "versions": [
      {
        "version": "1.1.0",
        "source": "https://akless.github.io/ccm-components/kanban_board/versions/ccm.kanban_board-1.1.0.js",
        "minified": "https://akless.github.io/ccm-components/kanban_board/versions/ccm.kanban_board-1.1.0.min.js"
      },
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/kanban_board/versions/ccm.kanban_board-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/kanban_board/versions/ccm.kanban_board-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/kanban_board/resources/configs.min.js", "demo" ]
    ]
  },
  "kanban_card": {
    "title": "Kanban Card",
    "abstract": "For rendering a kanban card.",
    "screenshots": [
      "https://akless.github.io/ccm-components/kanban_card/resources/preview_1.jpg",
      "https://akless.github.io/ccm-components/kanban_card/resources/preview_2.png",
      "https://akless.github.io/ccm-components/kanban_card/resources/preview_3.png"
    ],
    "name": "kanban_card",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/kanban_card/versions/ccm.kanban_card-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/kanban_card/versions/ccm.kanban_card-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/kanban_card/resources/configs.min.js", "homework" ],
      [ "ccm.get", "https://akless.github.io/ccm-components/kanban_card/resources/configs.min.js", "presentation" ],
      [ "ccm.get", "https://akless.github.io/ccm-components/kanban_card/resources/configs.min.js", "realtime" ]
    ]
  },
  "le": {
    "title": "Learning Unit",
    "abstract": "For rendering a learning unit.",
    "name": "le",
    "versions": [
      {
        "version": "2.0.0",
        "source": "https://akless.github.io/ccm-components/le/versions/ccm.le-2.0.0.js",
        "minified": "https://akless.github.io/ccm-components/le/versions/ccm.le-2.0.0.min.js"
      },
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/le/versions/ccm.le-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/le/versions/ccm.le-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/akless/ccm/ccm-overview/configs.min.js", "le" ]
    ]
  },
  "learning_app": {
    "title": "LearningApp Connector",
    "abstract": "ccm connector for learning apps",
    "screenshots": [
      "https://mkaul.github.io/ccm-components/learning_app/resources/screenshot_1.jpg"
    ],
    "description": "In order to embed the famous LearningApps software anywhere, use this connector. 'LearningApps.org is a Web 2.0 application, to support learning and teaching processes with small interactive modules. Those modules can be used directly in learning materials, but also for self studying. The aim is to collect reusable building blocks and make them available to everyone. Blocks (called Apps) include no specific framework or a specific learning scenario. The blocks are therefore not suitable as complete lessons or tasks, instead they must be embedded in an appropriate teaching scenario', see http://learningapps.org.",
    "name": "learning_app",
    "versions": [
      {
        "version": "latest",
        "source": "https://mkaul.github.io/ccm-components/learning_app/ccm.learning_app.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/",
    "demos": [ {} ]
  },
  "log": {
    "title": "Logger",
    "abstract": "For data logging.",
    "name": "log",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/log/versions/ccm.log-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/log/versions/ccm.log-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/"
  },
  "posts": {
    "title": "News",
    "abstract": "For rendering a news.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/posts_preview_1.png"
    ],
    "name": "posts",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/news/versions/ccm.posts-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "question": {
    "title": "Question",
    "abstract": "For rendering a question and given answers.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/question_preview_1.png"
    ],
    "name": "question",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/question/versions/ccm.question-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "quiz": {
    "title": "Quiz",
    "abstract": "For rendering a quiz.",
    "screenshots": [
      "https://akless.github.io/ccm-components/quiz/resources/preview_1.png",
      "https://akless.github.io/ccm-components/quiz/resources/preview_2.png"
    ],
    "name": "quiz",
    "versions": [
      {
        "version": "2.0.0",
        "source": "https://akless.github.io/ccm-components/quiz/versions/ccm.quiz-2.0.0.js",
        "minified": "https://akless.github.io/ccm-components/quiz/versions/ccm.quiz-2.0.0.min.js"
      },
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/quiz/versions/ccm.quiz-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/quiz/versions/ccm.quiz-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/quiz/resources/configs.min.js", "demo" ]
    ]
  },
  "star_rating": {
    "title": "Star Rating",
    "abstract": "For rendering a star rating.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/star_rating_preview_1.png"
    ],
    "name": "star_rating",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/star_rating/versions/ccm.star_rating-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "star_rating_result": {
    "title": "Star Rating Result",
    "abstract": "For rendering a star rating result.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/star_rating_result_preview_1.png"
    ],
    "name": "star_rating_result",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/star_rating_result/versions/ccm.star_rating_result-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "slidecast": {
    "title": "Slidecast",
    "abstract": "For rendering a slidecast.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/slidecast_preview_1.png",
      "https://akless.github.io/ccm-components/libs/screenshots/slidecast_preview_2.png"
    ],
    "name": "slidecast",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/slidecast/versions/ccm.slidecast-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "teambuild": {
    "title": "Team Building",
    "abstract": "For realtime team building.",
    "name": "teambuild",
    "versions": [
      {
        "version": "1.0.1",
        "source": "https://akless.github.io/ccm-components/teambuild/versions/ccm.teambuild-1.0.1.js",
        "minified": "https://akless.github.io/ccm-components/teambuild/versions/ccm.teambuild-1.0.1.min.js"
      },
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/teambuild/versions/ccm.teambuild-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/teambuild/versions/ccm.teambuild-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/teambuild/resources/configs.min.js", "demo" ]
    ],
    "factories": [
      {
        "url": "https://akless.github.io/ccm-components/teambuild_builder/versions/ccm.teambuild_builder-2.3.0.min.js",
        "config": {}
      },
      {
        "url": "https://akless.github.io/ccm-components/teambuild_builder/versions/ccm.teambuild_builder-2.2.0.min.js",
        "config": {}
      }
    ]
  },
  "testsuite": {
    "title": "Test Suite",
    "abstract": "For running unit tests.",
    "name": "testsuite",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/testsuite/versions/ccm.testsuite-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/testsuite/versions/ccm.testsuite-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/"
  },
  "thumb_rating": {
    "title": "Thumb Rating",
    "abstract": "For rendering a thumb rating.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/thumb_rating_preview_1.png"
    ],
    "name": "thumb_rating",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/thumb_rating/versions/ccm.thumb_rating-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "user": {
    "title": "User",
    "abstract": "For user authentication.",
    "name": "user",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://akless.github.io/ccm-components/user/versions/ccm.user-1.0.0.js",
        "minified": "https://akless.github.io/ccm-components/user/versions/ccm.user-1.0.0.min.js"
      }
    ],
    "developer": "André Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/akless/ccm-components/",
    "demos": [
      [ "ccm.get", "https://akless.github.io/ccm-components/user/resources/configs.min.js", "demo" ]
    ]
  },
  "uml": {
    "title": "UML Connector",
    "abstract": "ccm connector for PlantUML",
    "screenshots": [
      "https://mkaul.github.io/ccm-components/uml/resources/screenshot_1.jpg"
    ],
    "description": "In order to embed the famous PlantUML software anywhere, use this connector. PlantUML.com is a web server that generates diagrams in the cloud. There are also various extensions or add-ons that incorporate PlantUML, see http://plantuml.com/",
    "name": "uml",
    "versions": [
      {
        "version": "latest",
        "source": "https://mkaul.github.io/ccm-components/uml/ccm.uml.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/",
    "demos": [ {} ]
  },
  "upload": {
    "title": "Upload",
    "abstract": "Upload a file to a server",
    "screenshots": [
      "https://mkaul.github.io/ccm-components/upload/resources/screenshot_1.jpg"
    ],
    "description": "With a file chooser you can choose any file from your computer. Upload lets you upload the file to a server.",
    "name": "upload",
    "versions": [
      {
        "version": "latest",
        "source": "https://mkaul.github.io/ccm-components/upload/ccm.upload.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/",
    "demos": [ {} ]
  },
  "voting": {
    "title": "Voting",
    "abstract": "For rendering a voting.",
    "screenshots": [
      "https://akless.github.io/ccm-components/libs/screenshots/voting_preview_1.png"
    ],
    "name": "voting",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://tkless.github.io/ccm-components/voting/versions/ccm.voting-1.0.0.js"
      }
    ],
    "developer": "Tea Kless",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/tkless/ccm-components/",
    "demos": [ {} ]
  },
  "difference_chart": {
    "title": "Difference Chart",
    "abstract": "To show the results of a questionaire for different groups",
    "name": "difference_chart",
    "versions": [
      {
        "version": "1.0.0",
        "source": "https://kaul.inf.h-brs.de/data/ccm/difference_chart/versions/ccm.difference_chart-1.0.0.js"
      }
    ],
    "developer": "Manfred Kaul",
    "license": "The MIT License (MIT)",
    "website": "https://github.com/mkaul/ccm-components/",
    "demos":[
      [ "ccm.get", "https://kaul.inf.h-brs.de/data/ccm/difference_chart/resources/configs.js", "demo" ],
      [ "ccm.get", "https://kaul.inf.h-brs.de/data/ccm/difference_chart/resources/configs.js", "research" ],
    ]
  }
};


text:
package net.goldolphin.cate.partitioned;

import net.goldolphin.cate.IScheduler;

/**
 * A scheduler pool which is used to schedule tasks using a partitioning algorithm.
 * @param <K> the key type used to select scheduler.
 * @author goldolphin
 *         2014-09-30 19:26
 */
public class PartitionedSchedulerPool<K> {
    private final IScheduler[] schedulers;
    private final IPartitioner<K> partitioner;

    /**
     * Constructor.
     * @param schedulers
     * @param partitioner
     */
    public PartitionedSchedulerPool(IScheduler[] schedulers, IPartitioner<K> partitioner) {
        this.schedulers = schedulers;
        this.partitioner = partitioner;
    }

    /**
     * Returns a scheduler for a specified key.
     * @param key
     * @return
     */
    public IScheduler getScheduler(K key) {
        return schedulers[partitioner.partition(key, schedulers.length)];
    }

    /**
     * Get partition number.
     * @return
     */
    public int getPartitionNum() {
        return schedulers.length;
    }

    /**
     * Get the partitioner
     * @return
     */
    public IPartitioner getPartitioner() {
        return partitioner;
    }
}