text:
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../leaflet-photo-marker/leaflet-photo-marker.html">
<link rel="import" href="../leaflet-marker-cluster-group/leaflet-marker-cluster-group.html">
<link rel="import" href="../leaflet-album-geojson/leaflet-album-geojson.html">

<dom-module id="leaflet-album-map">
    <template>
        <leaflet-album-geojson geojson="[[album.featureCollection]]"
                container="[[container]]"
                on-latlng-bounds-changed="onGeojsonBoundsChanged"></leaflet-album-geojson>
    </template>
</dom-module>
<script>
    (function () {
        var L = window.L || {};

        Polymer({
            is: 'leaflet-album-map',

            properties: {
                album: {
                    type: Object,
                    observer: '_albumChanged'
                },
                container: {
                    type: Object,
                    observer: '_containerChanged'
                }
            },

            _albumChanged: function(/*oldVal, newVal*/) {
                // TODO simple to clear
                this._clusterGroup.clearLayers();
//                if(!newVal || !newVal.photos || !newVal.photos.length) {
//                    this._clusterGroup.clearLayers();
//                }else {
//                }
                if(this.album.photos) {
                    for(var i in this.album.photos ) {
                        var photo = this.album.photos[i];
                        if(photo.location && photo.location.position) {
                            this.addMarker(this._createMarker(photo));
                        }
                    }
                }
            },

            _containerChanged: function() {
                if (this.container) {
                    this.container.addLayer(this._clusterGroup);
                }
            },

            addMarker: function(marker) {
                this._clusterGroup.addLayer(marker);
            },

            _createMarker: function(photo) {
                var newElement = document.createElement('div');
                newElement.className = 'icon-marker';
                var img = document.createElement('img');
                img.setAttribute('src', photo.ossKey);
                img.setAttribute('class', 'leaflet-photo-marker-icon');
                newElement.appendChild(img);
                newElement.addEventListener('click', this.onMarkerClick.bind(this));
                newElement.photo = photo;

                var marker = L.photoMarker(photo, newElement);
                return marker;
            },

            onMarkerClick: function(e) {
                if(e.target && e.target.parentElement && e.target.parentElement.photo) {
                    this.fire('click', e.target.parentElement.photo);
                }
            },

            ready: function() {
                this._clusterGroup = L.markerClusterGroup();
//                this._clusterGroup.on('click', function (a) {
//                    that.fire('click', a.layer.photo);
//                });
            },

            onGeojsonBoundsChanged: function(e) {
                console.log(e.detail.value);
                if(e.detail.value) {
                    this._fitBounds(e.detail.value);
                }
            },

            _fitBounds: function(bounds) {
                this.container.fitBounds(bounds);
            }
        });
    })();
</script>


text:
package crate.elasticsearch.rest.action.admin.reindex;

import static org.elasticsearch.rest.RestRequest.Method.POST;

import org.elasticsearch.action.Action;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestController;

import crate.elasticsearch.action.reindex.ReindexAction;
import crate.elasticsearch.action.searchinto.SearchIntoRequest;
import crate.elasticsearch.action.searchinto.SearchIntoResponse;
import crate.elasticsearch.client.action.searchinto.SearchIntoRequestBuilder;
import crate.elasticsearch.rest.action.admin.searchinto.RestSearchIntoAction;

/**
 * Rest action for the _reindex end points. Does the _search_into action to
 * the own index with the defined fields _id and _source.
 *
 * Does a re-index to either all indexes, a specified index or a specific type of
 * a specified index.
 */
public class RestReindexAction extends RestSearchIntoAction {

    @Inject
    public RestReindexAction(Settings settings, Client client, RestController controller) {
        super(settings, client, controller);
    }

    @Override
    protected void registerHandlers(RestController controller) {
        controller.registerHandler(POST, "/_reindex", this);
        controller.registerHandler(POST, "/{index}/_reindex", this);
        controller.registerHandler(POST, "/{index}/{type}/_reindex", this);
    }

    @Override
    protected Action<SearchIntoRequest, SearchIntoResponse, SearchIntoRequestBuilder> action() {
        return ReindexAction.INSTANCE;
    }
}

redpajama_set_name: RedPajamaGithub


text:
package release_v3_6

import (
	"github.com/golang/glog"
	v1authorization "github.com/openshift/origin/pkg/authorization/clientset/release_v3_6/typed/authorization/v1"
	restclient "k8s.io/kubernetes/pkg/client/restclient"
	discovery "k8s.io/kubernetes/pkg/client/typed/discovery"
	"k8s.io/kubernetes/pkg/util/flowcontrol"
	_ "k8s.io/kubernetes/plugin/pkg/client/auth"
)

type Interface interface {
	Discovery() discovery.DiscoveryInterface
	AuthorizationV1() v1authorization.AuthorizationV1Interface
	// Deprecated: please explicitly pick a version if possible.
	Authorization() v1authorization.AuthorizationV1Interface
}

// Clientset contains the clients for groups. Each group has exactly one
// version included in a Clientset.
type Clientset struct {
	*discovery.DiscoveryClient
	*v1authorization.AuthorizationV1Client
}

// AuthorizationV1 retrieves the AuthorizationV1Client
func (c *Clientset) AuthorizationV1() v1authorization.AuthorizationV1Interface {
	if c == nil {
		return nil
	}
	return c.AuthorizationV1Client
}

// Deprecated: Authorization retrieves the default version of AuthorizationClient.
// Please explicitly pick a version.
func (c *Clientset) Authorization() v1authorization.AuthorizationV1Interface {
	if c == nil {
		return nil
	}
	return c.AuthorizationV1Client
}

// Discovery retrieves the DiscoveryClient
func (c *Clientset) Discovery() discovery.DiscoveryInterface {
	return c.DiscoveryClient
}

// NewForConfig creates a new Clientset for the given config.
func NewForConfig(c *restclient.Config) (*Clientset, error) {
	configShallowCopy := *c
	if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 {
		configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst)
	}
	var clientset Clientset
	var err error
	clientset.AuthorizationV1Client, err = v1authorization.NewForConfig(&configShallowCopy)
	if err != nil {
		return nil, err
	}

	clientset.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy)
	if err != nil {
		glog.Errorf("failed to create the DiscoveryClient: %v", err)
		return nil, err
	}
	return &clientset, nil
}

// NewForConfigOrDie creates a new Clientset for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *restclient.Config) *Clientset {
	var clientset Clientset
	clientset.AuthorizationV1Client = v1authorization.NewForConfigOrDie(c)

	clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c)
	return &clientset
}

// New creates a new Clientset for the given RESTClient.
func New(c restclient.Interface) *Clientset {
	var clientset Clientset
	clientset.AuthorizationV1Client = v1authorization.New(c)

	clientset.DiscoveryClient = discovery.NewDiscoveryClient(c)
	return &clientset
}


text:
spec = {
  contexts = {}, passed = 0, failed = 0, pending = 0, current = nil
}

Report = {}
Report.__index = Report

function Report:new(spec)
  local report = {
    num_passed = spec.passed,
    num_failed = spec.failed,
    num_pending = spec.pending,
    total = spec.passed + spec.failed + spec.pending,
    results = {}
  }

  report.percent = report.num_passed/report.total*100

  local contexts = spec.contexts

  for index = 1, #contexts do
    report.results[index] = {
      name = contexts[index],
      spec_results = contexts[contexts[index]]
    }
  end

  return report
end

function spec:report(verbose)
  local report = Report:new(self)

  if report.num_failed ~= 0 or verbose then
    for i, result in pairs(report.results) do
      print(("\n%s\n================================"):format(result.name))

      for description, r in pairs(result.spec_results) do
        local outcome = r.passed and 'pass' or "FAILED"

        if verbose or not (verbose and r.passed) then
          print(("%-70s [ %s ]"):format(" - " .. description, outcome))

          table.foreach(r.errors, function(index, error)
            print("   " .. index ..". Failed expectation : " .. error.message .. "\n   "..error.trace)
          end)
        end
      end
    end
  end

  local summary = [[

========== %s =============
%s Failed
%s Passed
--------------------------------
%s Run, %.2f%% Success rate
]]

  print(summary:format(report.num_failed == 0 and "Success" or "Failure", report.num_failed, report.num_passed, report.total, report.percent))
end

function spec:add_results(success, message, trace)
  if self.current.passed then
    self.current.passed = success
  end

  if success then
    self.passed = self.passed + 1
  else
    table.insert(self.current.errors, { message = message, trace = trace })
    self.failed = self.failed + 1
  end
end

function spec:add_context(name)
  self.contexts[#self.contexts+1] = name
  self.contexts[name] = {}
end

function spec:add_spec(context_name, spec_name)
  local context = self.contexts[context_name]
  context[spec_name] = { passed = true, errors = {} }
  self.current = context[spec_name]
end

function spec:add_pending_spec(context_name, spec_name, pending_description)
end

-- create tables to support pending specifications
local pending = {}

function pending.__newindex() error("You can't set properties on pending") end

function pending.__index(_, key)
  if key == "description" then
    return nil
  else
    error("You can't get properties on pending")
  end
end

function pending.__call(_, description)
  local o = { description = description}
  setmetatable(o, pending)
  return o
end

setmetatable(pending, pending)

--

-- define matchers

matchers = {
  should_be = function(value, expected)
    if value ~= expected then
      return false, "expecting "..tostring(expected)..", not ".. tostring(value)
    end
    return true
  end;

  should_not_be = function(value, expected)
    if value == expected then
      return false, "should not be "..tostring(value)
    end
    return true
  end;

  should_be_greater_than = function(value, expected)
    if expected >= value then
      return false, "got " .. tostring(value) .. " expecting value > " .. tostring(expected)
    end
    return true
  end;

  should_be_less_than = function(value, expected)
    if expected <= value then
      return false, "got " .. tostring(value) .. " expecting value < " .. tostring(expected)
    end
    return true
  end;

  should_error = function(f)
    if pcall(f) then
      return false, "expecting an error but received none"
    end
    return true
  end;

  should_match = function(value, pattern)
    if type(value) ~= 'string' then
      return false, "type error, should_match expecting target as string"
    end

    if not string.match(value, pattern) then
      return false, value .. "doesn't match pattern ".. pattern
    end
    return true
  end;

  should_be_kind_of = function(value, class)
    if type(value) == "userdata" then

      if not value:isKindOfClass(class) then
        return false, tostring(value) .. " is not a " .. tostring(class)
      end
    elseif type(value) ~= class then
      return false, type(value) .. " is not a " .. tostring(class)
    end

    return true
  end;

  should_exist = function(value)
    if not value then
      return false, tostring(value) .. " evaluates to false."
    else
      return true
    end
  end;

  should_not_exist = function(value)
    if value then
      return false, value .. " evaluates to true."
    else
      return true
    end
  end;
}

matchers.should_equal = matchers.should_be

--

-- expect returns an empty table with a 'method missing' metatable
-- which looks up the matcher.  The 'method missing' function
-- runs the matcher and records the result in the current spec
local function expect(target)
  return setmetatable({}, {
    __index = function(_, matcher)
      return function(...)
        local success, message = matchers[matcher](target, ...)
        spec:add_results(success, message, debug.traceback())
      end
    end
  })
end

--

Context = {}
Context.__index = Context

function Context:new(context)
  for i, child in ipairs(context.children) do
    child.parent = context
  end
  return setmetatable(context, self)
end

function Context:run_befores(env)
  if self.parent then
    self.parent:run_befores(env)
  end
  if self.before then
    setfenv(self.before, env)
    self.before()
  end
end

function Context:run_afters(env)
  if self.after then
    setfenv(self.after, env)
    self.after()
  end
  if self.parent then
    self.parent:run_afters(env)
  end
end

function Context:run()
  -- run all specs
  for spec_name, spec_func in pairs(self.specs) do
    if getmetatable(spec_func) == pending then
    else
      spec:add_spec(self.name, spec_name)

      local mocks = {}

      -- setup the environment that the spec is run in, each spec is run in a new environment
      local env = {
        track_error = function(f)
          local status, err = pcall(f)
          return err
        end,

        expect = expect,

        mock = function(table, key, mock_value)
          mocks[{ table = table, key = key }] = table[key]  -- store the old value
          table[key] = mock_value or Mock:new()
          return table[key]
        end
      }
      setmetatable(env, { __index = _G })

      -- run each spec with proper befores and afters
      self:run_befores(env)

      setfenv(spec_func, env)
      local message
      local traceback
      local success = xpcall(spec_func, function(err)
        message = err
        traceback = debug.traceback("", 2)
      end)

      self:run_afters(env)

      if not success then
        io.write("x")
        spec:add_results(false, message, traceback)
      else
        io.write(".")
      end
      io.flush()

      -- restore stored values for mocks
      for key, old_value in pairs(mocks) do
        key.table[key.key] = old_value
      end
    end
  end

  for i, child in pairs(self.children) do
    child:run()
  end
end

-- dsl for creating contexts

local function make_it_table()
  -- create and set metatables for 'it'
  local specs = {}
  local it = {}
  setmetatable(it, {
    -- this is called when it is assigned a function (e.g. it["spec name"] = function() ...)
    __newindex = function(_, spec_name, spec_function)
      specs[spec_name] = spec_function
    end
  })

  return it, specs
end

local make_describe_table

-- create an environment to run a context function in as well as the tables to collect
-- the subcontexts and specs
local function create_context_env()
  local it, specs = make_it_table()
  local describe, sub_contexts = make_describe_table()

  -- create an environment to run the function in
  local context_env = {
    it = it,
    describe = describe,
    pending = pending
  }

  return context_env, sub_contexts, specs
end

-- Note: this is declared locally earlier so it is still local
function make_describe_table(auto_run)
  local describe = {}
  local contexts = {}
  local describe_mt = {

    -- This function is called when a function is assigned to a describe table
    -- (e.g. describe["context name"] = function() ...)
    __newindex = function(_, context_name, context_function)

      spec:add_context(context_name)

      local context_env, sub_contexts, specs = create_context_env()

      -- set the environment
      setfenv(context_function, context_env)

      -- run the context function which collects the data into context_env and sub_contexts
      context_function()

      -- store the describe function in contexts
      contexts[#contexts+1] = Context:new {
        name = context_name,
        before = context_env.before,
        after = context_env.after,
        specs = specs,
        children = sub_contexts
      }

      if auto_run then
        contexts[#contexts]:run()
      end
    end
  }

  setmetatable(describe, describe_mt)

  return describe, contexts
end

describe = make_describe_table(true)


text:
DEVELSPACE = True
INSTALLSPACE = False

CATKIN_DEVEL_PREFIX = '/home/meka/mekabot/m3meka/ros/shm_pwr_state_omnibase/devel'

CATKIN_GLOBAL_BIN_DESTINATION = 'bin'
CATKIN_GLOBAL_ETC_DESTINATION = 'etc'
CATKIN_GLOBAL_INCLUDE_DESTINATION = 'include'
CATKIN_GLOBAL_LIB_DESTINATION = 'lib'
CATKIN_GLOBAL_LIBEXEC_DESTINATION = 'lib'
CATKIN_GLOBAL_PYTHON_DESTINATION = 'lib/python2.7/dist-packages'
CATKIN_GLOBAL_SHARE_DESTINATION = 'share'

CATKIN_PACKAGE_BIN_DESTINATION = ''
CATKIN_PACKAGE_ETC_DESTINATION = ''
CATKIN_PACKAGE_INCLUDE_DESTINATION = ''
CATKIN_PACKAGE_LIB_DESTINATION = ''
CATKIN_PACKAGE_LIBEXEC_DESTINATION = ''
CATKIN_PACKAGE_PYTHON_DESTINATION = ''
CATKIN_PACKAGE_SHARE_DESTINATION = ''

CMAKE_BINARY_DIR = '/home/meka/mekabot/m3meka/ros/shm_pwr_state_omnibase'
CMAKE_CURRENT_BINARY_DIR = '/home/meka/mekabot/m3meka/ros/shm_pwr_state_omnibase'
CMAKE_CURRENT_SOURCE_DIR = '/home/meka/mekabot/m3meka/ros/shm_pwr_state_omnibase'
CMAKE_INSTALL_PREFIX = '/usr/local'
CMAKE_SOURCE_DIR = '/home/meka/mekabot/m3meka/ros/shm_pwr_state_omnibase'

PROJECT_NAME = 'shm_pwr_state_omnibase'
PROJECT_BINARY_DIR = '/home/meka/mekabot/m3meka/ros/shm_pwr_state_omnibase'
PROJECT_SOURCE_DIR = '/home/meka/mekabot/m3meka/ros/shm_pwr_state_omnibase'


text:
// Author: David Skrenta CS1300 Fall 2017
// Recitation: 210 - Arcadia
// Assignment 7
// SpellChecker.cpp

#include "SpellChecker.h"

/*
    Empty constructor for SpellCheck class
*/

SpellChecker::SpellChecker() {

}

/*
    Constructor for SpellCheck class with input language specification
    Parameters: inputLanguage
*/

SpellChecker::SpellChecker(string inputLanguage) {
    language = inputLanguage;
}

/*
    Constructor for SpellCheck class with input language, correct spelling filename, and incorrect spelling filename specification
    Parameters: inputLanguage, correctSpellingFilename, incorrectSpellingFilename
*/

SpellChecker::SpellChecker(string inputLanguage, string correctSpellingFilename, string incorrectSpellingFilename) {
    language = inputLanguage;
    readValidWords(correctSpellingFilename);
    readCorrectedWords(incorrectSpellingFilename);
}

/*
    Destructor for SpellCheck class
*/

SpellChecker::~SpellChecker() {
    // letting compiler handle deconstruction of the class
}

/*
    Reads valid words into valid words array
    Parameters: filename
    Returns: boolean value based on successful file read
*/

bool SpellChecker::readValidWords(string filename) {
    ifstream file (filename);
    string line;
    int index = 0;
    if (file.is_open()) {
        while (getline(file, line)) {
            validWords[index] = line;
            index++;
        }
        file.close();
        return true;
    }
    else {
        return false;
    }
}

/*
    Reads corrected words into a map
    Parameters: filename
    Returns: boolean value based on successful file read
*/

bool SpellChecker::readCorrectedWords(string filename) {
    ifstream file (filename);
    string line;
    if (file.is_open()) {
        while (getline(file, line)) {
            string parsed[2];
            split(line, '\t', parsed, 2);
            corrections.insert(pair <string, string>(parsed[0], parsed[1]));
        }
        file.close();
        return true;
    }
    else {
        return false;
    }
}

/*
    Sets start marker for SpellCheck class
    Parameters: begin
    Returns: true
*/

bool SpellChecker::setStartMarker(char begin) {
    startMarker = begin;
    return true;
}

/*
    Sets end marker for SpellCheck class
    Parameters: end
    Returns: true
*/

bool SpellChecker::setEndMarker(char end) {
    endMarker = end;
    return true;
}

/*
    Gets start marker for SpellCheck class
    Returns: start marker
*/

char SpellChecker::getStartMarker() {
    return startMarker;
}

/*
    Gets end marker for SpellCheck class
    Returns: end marker
*/

char SpellChecker::getEndMarker() {
    return endMarker;
}

/*
    Repairs a normalized string given the valid words array, and corrected words map
    Parameters: sentence
    Returns: repaired sentence
*/

string SpellChecker::repair(string sentence) {
    string repaired = "";
    string normalized = lowerNoPunctuation(sentence, ".?-/,!(){}[]_:;<>");
    string token;
    stringstream ss(normalized);
    map <string, string>::iterator it;
    while (ss >> token) {
        if (search(token, validWords, 10000) != -1) {
            repaired += token;
        }
        else if ((it = corrections.find(token)) != corrections.end()) {
            repaired += it->second;
        }
        else {
            repaired += startMarker + token + endMarker;
        }
        repaired += " ";
    }
    return repaired;
}

/*
    Searches for a target value in array
    Parameters: target, array, size
    Returns: -1 if not found, positive index if found
*/

int SpellChecker::search(string target, string array[], int size) {
    for (int i = 0; i < size; i++) {
        if (array[i] == target) {
            return i;
        }
    }
    return -1;
}

/*
    Removes punctation from a string
    Note: Does not remove punctation inside a word
    Parameters: str, punch
    Returns: normalized string
*/

string SpellChecker::lowerNoPunctuation(string str, string punch) {
    string normalized = "";

    for (int i = 0; i < str.length(); i++) {
        if (isupper(str[i])) {
            normalized += tolower(str[i]);
        }
        else {
            bool isPunch = false;
            for (int j = 0; j < punch.length(); j++) {
                if (str[i] == punch[j] && (i == 0 || i + 1 == str.length() || str[i + 1] == ' ' || str[i - 1] == ' ')) {
                    isPunch = true;
                    break;
                }
            }
            if (!isPunch) {
                normalized += str[i];
            }
        }
    }

    return normalized;
}

/*
    Splits string into array based on delimiter
    Parameters: str, delimiter, words array, size
*/

void SpellChecker::split(string str, char delimiter, string words[], int size) {
    size_t pos = 0;
    int index = 0;
    while ((pos = str.find(delimiter)) != string::npos) {
        words[index] = str.substr(0, pos);
        str.erase(0, pos + 1);
        index++;
    }
    words[index] = str;
}


text:
shared_examples_for "oauth_controller" do
  describe "using 'create_from'" do
    before(:each) do
      stub_all_oauth_requests!
      User.delete_all
      Authentication.delete_all
    end

    it "should create a new user" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
      lambda do
        get :test_create_from_provider, :provider => "twitter"
      end.should change(User, :count).by(1)
      User.first.username.should == "nbenari"
    end

    it "should support nested attributes" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
      lambda do
        get :test_create_from_provider, :provider => "twitter"
      end.should change(User, :count).by(1)
      User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
    end

    it "should not crash on missing nested attributes" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text", :created_at => "does/not/exist"})
      lambda do
        get :test_create_from_provider, :provider => "twitter"
      end.should change(User, :count).by(1)
      User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
      User.first.created_at.should_not be_nil
    end
  end
end


text:
require 'kontena_cli'

puts Kontena::Client.new('https://example.com').host


text:
<template bindable="router"
    class="demo-navigation mdl-navigation mdl-color--blue-grey-800">
    ${route.settings.icon}${route.title}
</template>


text:
package com.github.nisrulz.sensey;

import static android.hardware.Sensor.TYPE_LIGHT;

import android.hardware.SensorEvent;

public class LightDetector extends SensorDetector {

    public interface LightListener {

        void onDark();

        void onLight();
    }

    private final LightListener lightListener;

    private final float threshold;

    public LightDetector(LightListener lightListener) {
        this(3f, lightListener);
    }

    public LightDetector(float threshold, LightListener lightListener) {
        super(TYPE_LIGHT);
        this.threshold = threshold;
        this.lightListener = lightListener;
    }

    @Override
    protected void onSensorEvent(SensorEvent sensorEvent) {
        float lux = sensorEvent.values[0];
        if (lux < threshold) {
            // Dark
            lightListener.onDark();
        } else {
            // Not Dark
            lightListener.onLight();
        }
    }
}


text:
<?php

namespace Bread\ContentBundle\Controller;

use Bread\ContentBundle\Controller\Base\BaseController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;

class HomePageController extends BaseController
{
    /**
     * @Route("/", name="homepage")
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction(Request $request)
    {
        return $this->render('@BreadContent/HomePage/home_page.html.twig', [
            'page'  =>  $this->getPage()
        ]);
    }
}


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

namespace Kiss.Core.DataAdapter
{
    public class KeyValueAdapter : IDataObjectAdapter
    {
        private IDictionary<string, string> data;

        public IDictionary<string, string> Data
        {
            get { return this.data; }
        }

        public KeyValueAdapter(IDictionary<string, string> data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            this.data = data;
        }

        public void Set(string field, object value)
        {
            if (value == null)
            {
                data[field] = null;
            }
            else
            {
                data[field] = value.ToString();
            }
        }

        public object Get(string field)
        {
            return data[field];
        }

        public IEnumerable<string> Fields()
        {
            return data.Keys;
        }

        public bool Contains(string field)
        {
            return data.ContainsKey(field);
        }
    }
}


text:
package org.jbpm.workbench.wi.client.workitem;

import org.gwtbootstrap3.client.ui.base.form.AbstractForm;
import org.jbpm.workbench.wi.client.workitem.ServiceTaskUploadFormView.Presenter;
import org.uberfire.client.mvp.UberView;

import com.google.gwt.user.client.Command;

public interface ServiceTaskUploadFormView extends UberView<Presenter> {

    interface Presenter {

        void handleSubmitComplete(AbstractForm.SubmitCompleteEvent event);

        boolean isFileNameValid();

        Command onCloseCommand();
    }

    String getFileName();

    void showSelectFileUploadWarning();

    void showUnsupportedFileTypeWarning();

    void showInvalidJarNoPomWarning();

    void showInvalidPomWarning();

    void showUploadFailedError();

    void showUploadingBusy();

    void hideUploadingBusy();

    String getSuccessInstallMessage();

    void show();

    void hide();

}


text:
module Ansible
  # Ansible configuration
  module Config
    PATH = 'lib/ansible/'
    # IP_OR_HOSTNAME = /((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})$|^((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))\n/
    SKIP_HOSTVARS = %w(ansible_version inventory_dir inventory_file inventory_hostname inventory_hostname_short group_names groups omit playbook_dir)
    VERSION = `ansible --version`.split("\n").first.split.last rescue nil # nil when Ansible not installed

    # Default configuration options
    DefaultConfig = Struct.new(:env, :extra_vars, :params) do
      # @!attribute env
      #   @return [Hash] environment variables
      # @!attribute params
      #   @return [Hash] parameters
      # @!attribute extra_vars
      #   @return [Hash] extra variables to pass to Ansible

      def initialize
        self.env = {
          'ANSIBLE_FORCE_COLOR' => 'True',
          'ANSIBLE_HOST_KEY_CHECKING' => 'False'
        }

        self.extra_vars = {
          # skip creation of .retry files
          'retry_files_enabled' => 'False'
        }
        # TODO support --ssh-common-args, --ssh-extra-args
        # e.g. ansible-playbook --ssh-common-args="-o ServerAliveInterval=60" -i inventory install.yml

        self.params = {
          debug: false
        }
      end

      # Pass additional options to Ansible
      # NB: --extra-vars can also accept JSON string, see http://stackoverflow.com/questions/25617273/pass-array-in-extra-vars-ansible
      # @return [String] command-line options
      def options
        x = extra_vars.each_with_object('--extra-vars=\'') { |kv, a| a << "#{kv.first}=\"#{kv.last}\" " }.strip+'\'' if extra_vars unless extra_vars.empty?
        # can test with configure { |config| config.extra_vars.clear }

        [x, '--ssh-extra-args=\'-o UserKnownHostsFile=/dev/null\'']*' '
      end

      # Output configuration as a string for the command-line
      # @param cmd [String] command to be appended to the command-line produced
      # @return [Config, DefaultConfig] the configuration
      def to_s(cmd)
        entire_cmd = [env.each_with_object([]) { |kv, a| a << kv*'=' } * ' ', cmd, options]*' '
        puts entire_cmd if params[:debug]
        entire_cmd
      end
    end

    # Create and yield configuration
    # @return [Config, DefaultConfig] the configuration
    def configure
      @config ||= DefaultConfig.new
      yield(@config) if block_given?

      # allow chaining if block given
      block_given? ? self : @config
    end

    # accessor for config
    # @return [DefaultConfig] the configuration
    def config
      @config || configure
    end
  end
end


text:
package core

import "github.com/sacloud/libsacloud/v2/pkg/mapconv"

var mapconvDecoder = mapconv.Decoder{Config: &mapconv.DecoderConfig{TagName: "temp"}}

func cloneParameter(src, dest interface{}) error {
	return mapconvDecoder.ConvertTo(src, dest)
}


text:
import { IgxDateTimeEditorDirective, IgxDateTimeEditorModule } from './date-time-editor.directive';
import { DatePart } from './date-time-editor.common';
import { DOCUMENT } from '@angular/common';
import { Component, ViewChild, DebugElement, EventEmitter, Output, SimpleChange, SimpleChanges } from '@angular/core';
import { fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { FormsModule, FormGroup, FormBuilder, ReactiveFormsModule, Validators, NgControl } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { IgxInputGroupModule, IgxInputGroupComponent, IgxInputDirective } from '../../input-group/public_api';
import { configureTestSuite } from '../../test-utils/configure-suite';
import { ControlsFunction } from '../../test-utils/controls-functions.spec';
import { UIInteractions } from '../../test-utils/ui-interactions.spec';

describe('IgxDateTimeEditor', () => {
    let dateTimeEditor: IgxDateTimeEditorDirective;
    describe('Unit tests', () => {
        const maskParsingService = jasmine.createSpyObj('MaskParsingService',
            ['parseMask', 'restoreValueFromMask', 'parseMaskValue', 'applyMask']);
        const renderer2 = jasmine.createSpyObj('Renderer2', ['setAttribute']);
        const locale = 'en';
        const _ngModel = {
            control: { touched: false, dirty: false, validator: null, setValue: (value: any) => { } },
            valid: false,
            statusChanges: new EventEmitter(),
        };
        let elementRef = { nativeElement: null };
        let inputFormat: string;
        let inputDate: string;
        const initializeDateTimeEditor = (_control?: NgControl) => {
            // const injector = { get: () => control };
            dateTimeEditor = new IgxDateTimeEditorDirective(renderer2, elementRef, maskParsingService, null, DOCUMENT, locale);
            dateTimeEditor.inputFormat = inputFormat;
            dateTimeEditor.ngOnInit();

            const change: SimpleChange = new SimpleChange(undefined, inputFormat, true);
            const changes: SimpleChanges = { inputFormat: change };
            dateTimeEditor.ngOnChanges(changes);
        };
        describe('Properties & Events', () => {
            it('should emit valueChange event on clear()', () => {
                inputFormat = 'dd/M/yy';
                inputDate = '6/6/2000';
                elementRef = { nativeElement: { value: inputDate, setSelectionRange: () => { } } };
                initializeDateTimeEditor();

                const date = new Date(2000, 5, 6);
                dateTimeEditor.value = date;
                spyOn(dateTimeEditor.valueChange, 'emit');
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.clear();
                expect(dateTimeEditor.value).toBeNull();
                expect(dateTimeEditor.valueChange.emit).toHaveBeenCalledTimes(1);
                expect(dateTimeEditor.valueChange.emit).toHaveBeenCalledWith(null);
            });

            it('should update mask according to the input format', () => {
                inputFormat = 'd/M/yy';
                inputDate = '';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.inputFormat = inputFormat;
                expect(dateTimeEditor.mask).toEqual('00/00/00');

                dateTimeEditor.inputFormat = 'dd-MM-yyyy HH:mm:ss';
                expect(dateTimeEditor.mask).toEqual('00-00-0000 00:00:00');

                dateTimeEditor.inputFormat = 'H:m:s';
                expect(dateTimeEditor.mask).toEqual('00:00:00');
            });
        });

        describe('Date portions spinning', () => {
            it('should correctly increment / decrement date portions with passed in DatePart', () => {
                inputFormat = 'dd/M/yy';
                inputDate = '12/10/2015';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2015, 11, 12);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);
                const date = dateTimeEditor.value.getDate();
                const month = dateTimeEditor.value.getMonth();

                dateTimeEditor.increment(DatePart.Date);
                expect(dateTimeEditor.value.getDate()).toBeGreaterThan(date);

                dateTimeEditor.decrement(DatePart.Month);
                expect(dateTimeEditor.value.getMonth()).toBeLessThan(month);
            });

            it('should correctly increment / decrement date portions without passed in DatePart', () => {
                inputFormat = 'dd/MM/yyyy';
                inputDate = '12/10/2015';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2015, 11, 12);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);
                const date = dateTimeEditor.value.getDate();

                dateTimeEditor.increment();
                expect(dateTimeEditor.value.getDate()).toBeGreaterThan(date);

                dateTimeEditor.decrement();
                expect(dateTimeEditor.value.getDate()).toEqual(date);
            });

            it('should correctly increment / decrement date portions with passed in spinDelta', () => {
                inputFormat = 'dd/MM/yyyy';
                inputDate = '12/10/2015';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                const date = new Date(2015, 11, 12, 14, 35, 12);
                dateTimeEditor.value = date;
                dateTimeEditor.spinDelta = { date: 2, month: 2, year: 2, hours: 2, minutes: 2, seconds: 2 };
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment();
                expect(dateTimeEditor.value.getDate()).toEqual(14);

                dateTimeEditor.decrement();
                expect(dateTimeEditor.value.getDate()).toEqual(12);

                dateTimeEditor.increment(DatePart.Minutes);
                expect(dateTimeEditor.value.getMinutes()).toEqual(date.getMinutes() + 2);

                dateTimeEditor.decrement(DatePart.Hours);
                expect(dateTimeEditor.value.getHours()).toEqual(date.getHours() - 2);
            });

            it('should not loop over to next month when incrementing date', () => {
                inputFormat = 'dd/MM/yyyy';
                inputDate = '29/02/2020';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2020, 1, 29);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment();
                expect(dateTimeEditor.value.getDate()).toEqual(1);
                expect(dateTimeEditor.value.getMonth()).toEqual(1);
            });

            it('should not loop over to next year when incrementing month', () => {
                inputFormat = 'dd/MM/yyyy';
                inputDate = '29/12/2020';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2020, 11, 29);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Month);
                expect(dateTimeEditor.value.getMonth()).toEqual(0);
                expect(dateTimeEditor.value.getFullYear()).toEqual(2020);
            });

            it('should update date part if next/previous month\'s max date is less than the current one\'s', () => {
                inputFormat = 'dd/MM/yyyy';
                inputDate = '31/01/2020';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2020, 0, 31);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Month);
                expect(dateTimeEditor.value.getDate()).toEqual(29);
                expect(dateTimeEditor.value.getMonth()).toEqual(1);
            });

            it('should prioritize Date for spinning, if it is set in format', () => {
                inputFormat = 'dd/M/yy HH:mm:ss tt';
                inputDate = '11/03/2020 00:00:00 AM';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2020, 2, 11);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment();
                expect(dateTimeEditor.value.getDate()).toEqual(12);

                dateTimeEditor.decrement();
                expect(dateTimeEditor.value.getDate()).toEqual(11);
            });

            it('should not loop over when isSpinLoop is false', () => {
                inputFormat = 'dd/MM/yyyy';
                inputDate = '31/03/2020';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();
                dateTimeEditor.spinLoop = false;

                dateTimeEditor.value = new Date(2020, 2, 31);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Date);
                expect(dateTimeEditor.value.getDate()).toEqual(31);

                dateTimeEditor.value = new Date(2020, 1, 31);
                dateTimeEditor.decrement(DatePart.Month);
                expect(dateTimeEditor.value.getMonth()).toEqual(1);
            });

            it('should loop over when isSpinLoop is true (default)', () => {
                inputFormat = 'dd/MM/yyyy';
                inputDate = '31/03/2020';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2020, 2, 31);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);
                dateTimeEditor.increment(DatePart.Date);
                expect(dateTimeEditor.value.getDate()).toEqual(1);

                dateTimeEditor.value = new Date(2020, 0, 31);
                dateTimeEditor.decrement(DatePart.Month);
                expect(dateTimeEditor.value.getMonth()).toEqual(11);
            });
        });

        describe('Time portions spinning', () => {
            it('should correctly increment / decrement time portions with passed in DatePart', () => {
                inputFormat = 'dd/MM/yyyy HH:mm:ss';
                inputDate = '10/10/2010 12:10:34';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2010, 11, 10, 12, 10, 34);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);
                const minutes = dateTimeEditor.value.getMinutes();
                const seconds = dateTimeEditor.value.getSeconds();

                dateTimeEditor.increment(DatePart.Minutes);
                expect(dateTimeEditor.value.getMinutes()).toBeGreaterThan(minutes);

                dateTimeEditor.decrement(DatePart.Seconds);
                expect(dateTimeEditor.value.getSeconds()).toBeLessThan(seconds);
            });

            it('should correctly increment / decrement time portions without passed in DatePart', () => {
                inputFormat = 'HH:mm:ss tt';
                inputDate = '';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();
                /*
                 * format must be set because the editor will prioritize Date if Hours is not set
                 * and no DatePart is provided to increment / decrement
                 */
                dateTimeEditor.value = new Date();
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);
                const hours = dateTimeEditor.value.getHours();

                dateTimeEditor.increment();
                expect(dateTimeEditor.value.getHours()).toBeGreaterThan(hours);

                dateTimeEditor.decrement();
                expect(dateTimeEditor.value.getHours()).toEqual(hours);
            });

            it('should not loop over to next minute when incrementing seconds', () => {
                inputFormat = 'dd/MM/yyyy HH:mm:ss';
                inputDate = '20/01/2019 20:05:59';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2019, 1, 20, 20, 5, 59);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Seconds);
                expect(dateTimeEditor.value.getMinutes()).toEqual(5);
                expect(dateTimeEditor.value.getSeconds()).toEqual(0);
            });

            it('should not loop over to next hour when incrementing minutes', () => {
                inputFormat = 'dd/MM/yyyy HH:mm:ss';
                inputDate = '20/01/2019 20:59:12';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2019, 1, 20, 20, 59, 12);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Minutes);
                expect(dateTimeEditor.value.getHours()).toEqual(20);
                expect(dateTimeEditor.value.getMinutes()).toEqual(0);
            });

            it('should not loop over to next day when incrementing hours', () => {
                inputFormat = 'dd/MM/yyyy HH:mm:ss';
                inputDate = '20/01/2019 23:13:12';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2019, 1, 20, 23, 13, 12);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Hours);
                expect(dateTimeEditor.value.getDate()).toEqual(20);
                expect(dateTimeEditor.value.getHours()).toEqual(0);
            });

            it('should not loop over when isSpinLoop is false', () => {
                inputFormat = 'dd/MM/yyyy HH:mm:ss';
                inputDate = '20/01/2019 23:13:12';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();
                dateTimeEditor.spinLoop = false;
                dateTimeEditor.value = new Date(2019, 1, 20, 23, 0, 12);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Hours);
                expect(dateTimeEditor.value.getHours()).toEqual(23);

                dateTimeEditor.decrement(DatePart.Minutes);
                expect(dateTimeEditor.value.getMinutes()).toEqual(0);
            });

            it('should loop over when isSpinLoop is true (default)', () => {
                inputFormat = 'dd/MM/yyyy HH:mm:ss';
                inputDate = '20/02/2019 23:15:12';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.value = new Date(2019, 1, 20, 23, 15, 0);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.Hours);
                expect(dateTimeEditor.value.getHours()).toEqual(0);

                dateTimeEditor.decrement(DatePart.Seconds);
                expect(dateTimeEditor.value.getSeconds()).toEqual(59);
            });

            it('should properly parse AM/PM no matter where it is in the format', () => {
                inputFormat = 'dd tt yyyy-MM mm-ss-hh';
                inputDate = '12 AM 2020-06 14-15-11';
                elementRef = { nativeElement: { value: inputDate } };
                initializeDateTimeEditor();

                dateTimeEditor.inputFormat = inputFormat;
                expect(dateTimeEditor.mask).toEqual('00 LL 0000-00 00-00-00');

                dateTimeEditor.value = new Date(2020, 5, 12, 11, 15, 14);
                spyOnProperty((dateTimeEditor as any), 'inputValue', 'get').and.returnValue(inputDate);

                dateTimeEditor.increment(DatePart.AmPm);
                expect(dateTimeEditor.value).toEqual(new Date(2020, 5, 12, 23, 15, 14));
            });
        });
    });

    describe('Integration tests', () => {
        const dateTimeOptions = {
            day: '2-digit', month: '2-digit', year: 'numeric',
            hour: 'numeric', minute: 'numeric', second: 'numeric'
        };
        let fixture;
        let inputElement: DebugElement;
        let dateTimeEditorDirective: IgxDateTimeEditorDirective;
        describe('Key interaction tests', () => {
            configureTestSuite();
            beforeAll(waitForAsync(() => {
                TestBed.configureTestingModule({
                    declarations: [
                        IgxDateTimeEditorSampleComponent,
                        IgxDateTimeEditorBaseTestComponent
                    ],
                    imports: [IgxInputGroupModule, IgxDateTimeEditorModule, FormsModule, NoopAnimationsModule]
                })
                    .compileComponents();
            }));
            beforeEach(async () => {
                fixture = TestBed.createComponent(IgxDateTimeEditorSampleComponent);
                fixture.detectChanges();
                inputElement = fixture.debugElement.query(By.css('input'));
                dateTimeEditorDirective = inputElement.injector.get(IgxDateTimeEditorDirective);
            });
            it('should properly update mask with inputFormat onInit', () => {
                fixture = TestBed.createComponent(IgxDateTimeEditorBaseTestComponent);
                fixture.detectChanges();
                expect(fixture.componentInstance.dateEditor.elementRef.nativeElement.value).toEqual('09/11/2009');
            });
            it('should correctly display input format during user input', () => {
                fixture.componentInstance.dateTimeFormat = 'dd/MM/yy';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('1', inputElement);
                expect(inputElement.nativeElement.value).toEqual('1_/__/__');
                UIInteractions.simulateTyping('9', inputElement, 1, 1);
                expect(inputElement.nativeElement.value).toEqual('19/__/__');
                UIInteractions.simulateTyping('1', inputElement, 2, 2);
                expect(inputElement.nativeElement.value).toEqual('19/1_/__');
                UIInteractions.simulateTyping('2', inputElement, 4, 4);
                expect(inputElement.nativeElement.value).toEqual('19/12/__');
                UIInteractions.simulateTyping('0', inputElement, 5, 5);
                expect(inputElement.nativeElement.value).toEqual('19/12/0_');
                UIInteractions.simulateTyping('8', inputElement, 7, 7);
                expect(inputElement.nativeElement.value).toEqual('19/12/08');
            });
            it('should not accept invalid date.', () => {
                fixture.componentInstance.dateTimeFormat = 'dd/MM/yy';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('333333', inputElement);
                expect(inputElement.nativeElement.value).toEqual('33/33/33');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');
            });
            it('should autofill missing date/time segments on blur.', () => {
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('8', inputElement);
                expect(inputElement.nativeElement.value).toEqual('8_/__/____ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                const date = new Date(2000, 0, 8, 0, 0, 0);
                let result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('5', inputElement, 7, 7);
                expect(inputElement.nativeElement.value).toEqual('__/__/_5__ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date.setFullYear(2005);
                date.setDate(1);
                result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('3', inputElement, 11, 11);
                expect(inputElement.nativeElement.value).toEqual('__/__/____ 3_:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date.setFullYear(2000);
                date.setHours(3);
                result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);
            });
            it('should not accept invalid date and time parts.', () => {
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('63', inputElement);
                expect(inputElement.nativeElement.value).toEqual('63/__/____ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('63', inputElement, 3, 3);
                expect(inputElement.nativeElement.value).toEqual('__/63/____ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('25', inputElement, 11, 11);
                expect(inputElement.nativeElement.value).toEqual('__/__/____ 25:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('78', inputElement, 14, 14);
                expect(inputElement.nativeElement.value).toEqual('__/__/____ __:78:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('78', inputElement, 17, 17);
                expect(inputElement.nativeElement.value).toEqual('__/__/____ __:__:78');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');
            });
            it('should correctly show year based on century threshold.', () => {
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('0000', inputElement, 6, 6);
                expect(inputElement.nativeElement.value).toEqual('__/__/0000 __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                const date = new Date(2000, 0, 1, 0, 0, 0);
                let result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('5', inputElement, 6, 6);
                expect(inputElement.nativeElement.value).toEqual('__/__/5___ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date.setFullYear(2005);
                result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('16', inputElement, 6, 6);
                expect(inputElement.nativeElement.value).toEqual('__/__/16__ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date.setFullYear(2016);
                result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('169', inputElement, 6, 6);
                expect(inputElement.nativeElement.value).toEqual('__/__/169_ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date.setFullYear(169);
                result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/169,/g, '0169');
                expect(inputElement.nativeElement.value).toEqual(result);
            });
            it('should support different display and input formats.', () => {
                fixture.componentInstance.displayFormat = 'longDate';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('9', inputElement);
                expect(inputElement.nativeElement.value).toEqual('9_/__/____ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                let date = new Date(2000, 0, 9, 0, 0, 0);
                const options = { month: 'long', day: 'numeric' };
                let result = `${ControlsFunction.formatDate(date, options)}, ${date.getFullYear()}`;
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                fixture.componentInstance.displayFormat = 'dd/MM/yyy';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('169', inputElement, 6, 6);
                expect(inputElement.nativeElement.value).toEqual('__/__/169_ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date = new Date(169, 0, 1, 0, 0, 0);
                const customOptions = { day: '2-digit', month: '2-digit', year: 'numeric' };
                result = ControlsFunction.formatDate(date, customOptions);
                expect(inputElement.nativeElement.value).toEqual(result);
            });
            it('should support long and short date formats', () => {
                fixture.componentInstance.displayFormat = 'longDate';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('9', inputElement);
                expect(inputElement.nativeElement.value).toEqual('9_/__/____ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                let date = new Date(2000, 0, 9, 0, 0, 0);
                const longDateOptions = { month: 'long', day: 'numeric' };
                let result = `${ControlsFunction.formatDate(date, longDateOptions)}, ${date.getFullYear()}`;
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                fixture.componentInstance.displayFormat = 'shortDate';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('9', inputElement);
                expect(inputElement.nativeElement.value).toEqual('9_/__/____ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                const shortDateOptions = { day: 'numeric', month: 'numeric', year: '2-digit' };
                result = ControlsFunction.formatDate(date, shortDateOptions);
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                fixture.componentInstance.displayFormat = 'fullDate';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('9', inputElement);
                expect(inputElement.nativeElement.value).toEqual('9_/__/____ __:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                const fullDateOptions = { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' };
                result = ControlsFunction.formatDate(date, fullDateOptions);
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                fixture.componentInstance.displayFormat = 'shortTime';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('1', inputElement, 11, 11);
                expect(inputElement.nativeElement.value).toEqual('__/__/____ 1_:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date = new Date(0, 0, 0, 1, 0, 0);
                const shortTimeOptions = { hour: 'numeric', minute: 'numeric', hour12: true };
                result = ControlsFunction.formatDate(date, shortTimeOptions);
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                fixture.componentInstance.displayFormat = 'longTime';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('2', inputElement, 11, 11);
                expect(inputElement.nativeElement.value).toEqual('__/__/____ 2_:__:__');
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date = new Date(2010, 10, 10, 2, 0, 0);
                const longTimeOptions = { hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true };
                result = ControlsFunction.formatDate(date, longTimeOptions);
                const offset = date.getTimezoneOffset();
                const tz = (offset > 0 ? '-' : '+') + (Math.abs(offset) / 60);
                result = `${result} GMT${tz}`;
                expect(inputElement.nativeElement.value).toEqual(result);
            });
            it('should be able to apply custom display format.', fakeAsync(() => {
                // default format
                const date = new Date(2003, 3, 5, 0, 0, 0);
                fixture.componentInstance.date = new Date(2003, 3, 5, 0, 0, 0);
                fixture.detectChanges();
                tick();
                let result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                // custom format
                fixture.componentInstance.displayFormat = 'EEEE d MMMM y h:mm a';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('1', inputElement);
                date.setDate(15);
                result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date.setMonth(3);
                const shortTimeOptions = { hour: 'numeric', minute: 'numeric', hour12: true };
                const dateOptions = { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' };
                const resultDate = ControlsFunction.formatDate(date, dateOptions, 'en-GB').replace(/,/g, '');
                result = `${resultDate} ${ControlsFunction.formatDate(date, shortTimeOptions)}`;
                expect(inputElement.nativeElement.value).toEqual(result);
            }));
            it('should convert dates correctly on paste when different display and input formats are set.', () => {
                // display format = input format
                let date = new Date(2020, 10, 10, 10, 10, 10);
                let inputDate = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);

                // display format != input format
                fixture.componentInstance.displayFormat = 'd/M/yy';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                const shortDateOptions = { day: 'numeric', month: 'numeric', year: '2-digit' };
                const result = ControlsFunction.formatDate(date, shortDateOptions, 'en-GB');
                expect(inputElement.nativeElement.value).toEqual(result);

                inputDate = '6/7/28';
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');

                fixture.componentInstance.dateTimeFormat = 'd/M/yy';
                fixture.detectChanges();
                fixture.componentInstance.displayFormat = 'dd/MM/yyyy';
                fixture.detectChanges();

                // inputElement.triggerEventHandler('focus', {});
                // fixture.detectChanges();
                // UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                // fixture.detectChanges();
                // inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                // fixture.detectChanges();
                // expect(inputElement.nativeElement.value).toEqual('__/__/__');

                date = new Date(2028, 7, 16, 0, 0, 0);
                inputDate = '16/07/28';
                const longDateOptions = { day: '2-digit', month: '2-digit', year: '2-digit' };
                inputDate = ControlsFunction.formatDate(date, longDateOptions, 'en-GB');
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                longDateOptions.year = 'numeric';
                inputDate = ControlsFunction.formatDate(date, longDateOptions, 'en-GB');
                expect(inputElement.nativeElement.value).toEqual(inputDate);
            });
            it('should clear input date on clear()', fakeAsync(() => {
                const date = new Date(2003, 3, 5);
                fixture.componentInstance.date = date;
                fixture.detectChanges();
                tick();
                const result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                dateTimeEditorDirective.clear();
                expect(inputElement.nativeElement.value).toEqual('');
            }));
            it('should move the caret to the start/end of the portion with CTRL + arrow left/right keys.', fakeAsync(() => {
                const date = new Date(2003, 4, 5);
                fixture.componentInstance.date = date;
                fixture.detectChanges();
                tick();
                const result = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(result);

                const inputHTMLElement = inputElement.nativeElement as HTMLInputElement;
                inputHTMLElement.setSelectionRange(0, 0);
                fixture.detectChanges();

                UIInteractions.triggerEventHandlerKeyDown('ArrowRight', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(2);
                expect(inputHTMLElement.selectionEnd).toEqual(2);

                UIInteractions.triggerEventHandlerKeyDown('ArrowLeft', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(0);
                expect(inputHTMLElement.selectionEnd).toEqual(0);

                inputHTMLElement.setSelectionRange(8, 8);
                fixture.detectChanges();

                UIInteractions.triggerEventHandlerKeyDown('ArrowLeft', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(6);
                expect(inputHTMLElement.selectionEnd).toEqual(6);

                UIInteractions.triggerEventHandlerKeyDown('ArrowRight', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(10);
                expect(inputHTMLElement.selectionEnd).toEqual(10);

                UIInteractions.triggerEventHandlerKeyDown('ArrowRight', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(13);
                expect(inputHTMLElement.selectionEnd).toEqual(13);

                inputHTMLElement.setSelectionRange(15, 15);
                fixture.detectChanges();

                UIInteractions.triggerEventHandlerKeyDown('ArrowRight', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(16);
                expect(inputHTMLElement.selectionEnd).toEqual(16);

                UIInteractions.triggerEventHandlerKeyDown('ArrowLeft', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(14);
                expect(inputHTMLElement.selectionEnd).toEqual(14);

                UIInteractions.triggerEventHandlerKeyDown('ArrowRight', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(16);
                expect(inputHTMLElement.selectionEnd).toEqual(16);

                UIInteractions.triggerEventHandlerKeyDown('ArrowRight', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(19);
                expect(inputHTMLElement.selectionEnd).toEqual(19);

                UIInteractions.triggerEventHandlerKeyDown('ArrowLeft', inputElement, false, false, true);
                fixture.detectChanges();
                expect(inputHTMLElement.selectionStart).toEqual(17);
                expect(inputHTMLElement.selectionEnd).toEqual(17);
            }));
            it('should not block the user from typing/pasting dates outside of min/max range', () => {
                fixture.componentInstance.minDate = '01/01/2000';
                fixture.componentInstance.maxDate = '31/12/2000';
                fixture.detectChanges();

                let date = new Date(2009, 10, 10, 10, 10, 10);
                let inputDate = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);

                dateTimeEditorDirective.clear();
                fixture.detectChanges();

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('27', inputElement, 8, 8);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                date = new Date(2027, 0, 1, 0, 0, 0);
                inputDate = ControlsFunction.formatDate(date, dateTimeOptions, 'en-GB').replace(/,/g, '');
                expect(inputElement.nativeElement.value).toEqual(inputDate);
            });
            it('should be able to customize prompt char.', () => {
                fixture.componentInstance.promptChar = '.';
                fixture.detectChanges();
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('../../.... ..:..:..');
            });
            it('should be en/disabled when the input is en/disabled.', fakeAsync(() => {
                spyOn(dateTimeEditorDirective, 'setDisabledState');
                fixture.componentInstance.disabled = true;
                fixture.detectChanges();
                tick();
                expect(dateTimeEditorDirective.setDisabledState).toHaveBeenCalledTimes(1);
                expect(dateTimeEditorDirective.setDisabledState).toHaveBeenCalledWith(true);

                fixture.componentInstance.disabled = false;
                fixture.detectChanges();
                tick();
                expect(dateTimeEditorDirective.setDisabledState).toHaveBeenCalledTimes(2);
                expect(dateTimeEditorDirective.setDisabledState).toHaveBeenCalledWith(false);
            }));
            it('should emit valueChange event on blur', () => {
                const newDate = new Date(2004, 11, 18);
                fixture.componentInstance.dateTimeFormat = 'dd/MM/yy';
                fixture.detectChanges();
                spyOn(dateTimeEditorDirective.valueChange, 'emit');

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('18124', inputElement);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();

                const options = { day: '2-digit', month: '2-digit', year: '2-digit' };
                const result = ControlsFunction.formatDate(newDate, options, 'en-GB');
                expect(inputElement.nativeElement.value).toEqual(result);
                expect(dateTimeEditorDirective.valueChange.emit).toHaveBeenCalledTimes(1);
                expect(dateTimeEditorDirective.valueChange.emit).toHaveBeenCalledWith(newDate);
            });
            it('should emit valueChange event after input is complete', () => {
                const newDate = new Date(2012, 11, 12);
                fixture.componentInstance.dateTimeFormat = 'dd/MM/yy';
                fixture.detectChanges();
                spyOn(dateTimeEditorDirective.valueChange, 'emit');
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulateTyping('121212', inputElement);
                fixture.detectChanges();
                expect(dateTimeEditorDirective.valueChange.emit).toHaveBeenCalledTimes(1);
                expect(dateTimeEditorDirective.valueChange.emit).toHaveBeenCalledWith(newDate);
            });
            it('should fire validationFailed when input date is outside date range.', () => {
                fixture.componentInstance.dateTimeFormat = 'dd-MM-yyyy';
                fixture.componentInstance.minDate = new Date(2020, 1, 20);
                fixture.componentInstance.maxDate = new Date(2020, 1, 25);
                fixture.detectChanges();
                spyOn(dateTimeEditorDirective.validationFailed, 'emit');

                // date within the range
                let inputDate = '22-02-2020';
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 10);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);
                expect(dateTimeEditorDirective.validationFailed.emit).not.toHaveBeenCalled();

                // date > maxValue
                let oldDate = new Date(2020, 1, 22);
                let newDate = new Date(2020, 1, 26);
                inputDate = '26-02-2020';
                let args = { oldValue: oldDate, newValue: newDate, userInput: inputDate };
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledTimes(1);
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledWith(args);

                // date < minValue
                oldDate = newDate;
                newDate = new Date(2020, 1, 12);
                inputDate = '12-02-2020';
                args = { oldValue: oldDate, newValue: newDate, userInput: inputDate };
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 19);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledTimes(2);
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledWith(args);
            });
            it('should fire validationFailed when input date is invalid.', () => {
                fixture.componentInstance.dateTimeFormat = 'dd-MM-yyyy';
                fixture.componentInstance.minDate = new Date(2000, 1, 1);
                fixture.componentInstance.maxDate = new Date(2050, 1, 25);
                fixture.detectChanges();
                spyOn(dateTimeEditorDirective.validationFailed, 'emit').and.callThrough();

                // valid date
                let inputDate = '22-02-2020';
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 10);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);
                expect(dateTimeEditorDirective.validationFailed.emit).not.toHaveBeenCalled();

                // invalid date
                const oldDate = new Date(2020, 1, 22);
                inputDate = '99-99-2020';
                const args = { oldValue: oldDate, newValue: null, userInput: inputDate };
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 10);
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual('');
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledTimes(1);
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledWith(args);
            });
            it('should properly increment/decrement date-time portions on wheel', fakeAsync(() => {
                fixture.componentInstance.dateTimeFormat = 'dd-MM-yyyy';
                fixture.detectChanges();
                const today = new Date(2021, 12, 12);
                dateTimeEditorDirective.value = today;

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                dateTimeEditorDirective.nativeElement.setSelectionRange(1, 1);
                inputElement.triggerEventHandler('wheel', new WheelEvent('wheel', { deltaY: 1 }));
                fixture.detectChanges();
                expect(dateTimeEditorDirective.value.getDate()).toEqual(today.getDate() - 1);
            }));
            it('should properly set placeholder with inputFormat applied', () => {
                fixture.componentInstance.placeholder = 'Date:';
                fixture.detectChanges();
                expect(dateTimeEditorDirective.nativeElement.placeholder).toEqual('Date:');
            });
            it('should be able to switch placeholders at runtime', () => {
                let placeholder = 'Placeholder';
                fixture.componentInstance.placeholder = placeholder;
                fixture.detectChanges();
                expect(dateTimeEditorDirective.nativeElement.placeholder).toEqual(placeholder);

                placeholder = 'Placeholder1';
                fixture.componentInstance.placeholder = placeholder;
                fixture.detectChanges();
                expect(dateTimeEditorDirective.nativeElement.placeholder).toEqual(placeholder);

                // when an empty placeholder (incl. null, undefined) is provided, at run-time, we do not default to the inputFormat
                placeholder = '';
                fixture.componentInstance.placeholder = placeholder;
                fixture.detectChanges();
                expect(dateTimeEditorDirective.nativeElement.placeholder).toEqual(placeholder);
            });
        });

        describe('Form control tests: ', () => {
            let form: FormGroup;
            configureTestSuite();
            beforeAll(waitForAsync(() => {
                TestBed.configureTestingModule({
                    declarations: [
                        IgxDateTimeEditorFormComponent
                    ],
                    imports: [
                        IgxInputGroupModule,
                        IgxDateTimeEditorModule,
                        NoopAnimationsModule,
                        ReactiveFormsModule,
                        FormsModule
                    ]
                }).compileComponents();
            }));
            beforeEach(() => {
                fixture = TestBed.createComponent(IgxDateTimeEditorFormComponent);
                fixture.detectChanges();
                form = fixture.componentInstance.reactiveForm;
                inputElement = fixture.debugElement.query(By.css('input'));
                dateTimeEditorDirective = inputElement.injector.get(IgxDateTimeEditorDirective);
            });
            it('should validate properly when used as form control.', () => {
                spyOn(dateTimeEditorDirective.validationFailed, 'emit').and.callThrough();
                const dateEditor = form.controls['dateEditor'];
                const args = { oldValue: '', newValue: null };
                const inputDate = '99-99-9999';

                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 10);
                fixture.detectChanges();
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();

                expect(inputElement.nativeElement.value).toEqual('');
                expect(form.valid).toBeFalsy();
                expect(dateEditor.valid).toBeFalsy();
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledTimes(1);
                // expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledWith(args);
            });
            it('should validate properly min/max value when used as form control.', () => {
                fixture.componentInstance.minDate = new Date(2020, 2, 20);
                fixture.componentInstance.maxDate = new Date(2020, 2, 25);
                spyOn(dateTimeEditorDirective.validationFailed, 'emit');
                const dateEditor = form.controls['dateEditor'];

                let inputDate = '21-03-2020';
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 10);
                fixture.detectChanges();
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);
                expect(form.valid).toBeTruthy();
                expect(dateEditor.valid).toBeTruthy();
                expect(dateTimeEditorDirective.validationFailed.emit).not.toHaveBeenCalled();

                inputDate = '21-02-2020';
                const args = { oldValue: new Date(2020, 2, 21), newValue: new Date(2020, 1, 21), userInput: inputDate };
                inputElement.triggerEventHandler('focus', {});
                fixture.detectChanges();
                UIInteractions.simulatePaste(inputDate, inputElement, 0, 10);
                fixture.detectChanges();
                inputElement.triggerEventHandler('blur', { target: inputElement.nativeElement });
                fixture.detectChanges();
                expect(inputElement.nativeElement.value).toEqual(inputDate);
                expect(form.valid).toBeFalsy();
                expect(dateEditor.valid).toBeFalsy();
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledTimes(1);
                expect(dateTimeEditorDirective.validationFailed.emit).toHaveBeenCalledWith(args);
            });
            it('should properly submit values when used as a form control', () => {
                const inputDate = '09-04-2020';
                expect(form.valid).toBeFalsy();
                form.controls['dateEditor'].setValue(inputDate);
                expect(form.valid).toBeTruthy();

                let result: string;
                fixture.componentInstance.submitted.subscribe((value) => result = value);
                fixture.componentInstance.submit();
                expect(result).toBe(inputDate);
            });
            it('should default to inputFormat as placeholder if none is provided', () => {
                fixture.componentInstance.dateTimeFormat = 'dd/MM/yyyy';
                fixture.detectChanges();
                expect(dateTimeEditorDirective.nativeElement.placeholder).toEqual('dd/MM/yyyy');
            });
        });
    });
});

@Component({
    template: `
    <igx-input-group>
        <input igxInput [igxDateTimeEditor]="'dd/MM/yyyy'" [value]="date"/>
    </igx-input-group>
    `
})
export class IgxDateTimeEditorBaseTestComponent {
    @ViewChild(IgxDateTimeEditorDirective)
    public dateEditor: IgxDateTimeEditorDirective;
    public date = new Date(2009, 10, 9);
}

@Component({
    template: `
<igx-input-group #igxInputGroup>
        <input type="text" igxInput [disabled]="disabled" [readonly]="readonly"
            [igxDateTimeEditor]="dateTimeFormat" [displayFormat]="displayFormat" [placeholder]="placeholder"
            [(ngModel)]="date" [minValue]="minDate" [maxValue]="maxDate" [promptChar]="promptChar"/>
    </igx-input-group>

    <input [(ngModel)]="placeholder" />
`
})
export class IgxDateTimeEditorSampleComponent {
    @ViewChild('igxInputGroup', { static: true }) public igxInputGroup: IgxInputGroupComponent;
    public date: Date;
    public dateTimeFormat = 'dd/MM/yyyy HH:mm:ss';
    public displayFormat: string;
    public minDate: string | Date;
    public maxDate: string | Date;
    public promptChar = '_';
    public disabled = false;
    public readonly = false;
    public placeholder = null;
}

@Component({
    template: `
<form (ngSubmit)="submit()" [formGroup]="reactiveForm">
    <igx-input-group>
        <input formControlName="dateEditor" type="text"
        igxInput [igxDateTimeEditor]="dateTimeFormat" [minValue]="minDate" [maxValue]="maxDate"/>
    </igx-input-group>
</form>
`
})
class IgxDateTimeEditorFormComponent {
    @ViewChild('dateEditor', { read: IgxInputDirective, static: true })
    public formInput: IgxInputDirective;
    @Output()
    public submitted = new EventEmitter<any>();
    public reactiveForm: FormGroup;
    public dateTimeFormat = 'dd-MM-yyyy';
    public minDate: Date;
    public maxDate: Date;

    constructor(fb: FormBuilder) {
        this.reactiveForm = fb.group({
            dateEditor: ['', Validators.required]
        });
    }

    public submit() {
        if (this.reactiveForm.valid) {
            this.submitted.emit(this.reactiveForm.value.dateEditor);
        }
    }
}


text:
/*
 * This script is to split a huge json file into pieces of json files of
 * around 200 M.
 * User can set the file size that they prefer by setting the size parameter
 * in bytes.
 * The subFiles will be created in the current folder from which the script
 * is running.
 */

/*******************************************************************************
 *  PAY ATTENTION
 *
 *  This script only handles JSON files that fit for Solr, which means that
 *  each JSON file is an array of objects, for each object, the values of
 *  it's attributes can be number, string, boolean value, array of string,
 *  array of number, but not array of objects. (array of stringified object
 *  string is OK).
 *
 ****************************************************************************/

'use strict';

const fs = require('fs');
const path = require('path');

/**
 * @param srcPath: path to the JSON file
 * @param size in bytes
 * @param enc: encoding, e.g. "binary" (default), "utf8"
 */
function splitLargeJSON(srcPath, size, enc) {
  enc = enc || 'binary';
  var src = fs.createReadStream(srcPath, enc);
  src.count = 0;
  src.part = 1;
  src.size = size || 1024 * 1024 * 200;

  var filePath = path.parse(srcPath);
  var subFilePath = filePath.name + '_part_' + src.part + '.json';

  var subFile = fs.createWriteStream(subFilePath, {flags: 'w+', defaultEncoding: enc});

  console.log('work in progress ...');
  src.on('data', function (chunk) {
    var s = chunk.replace(/\s+/g, '');
    // s = s.replace(/,,+/g, ',');

    src.count += s.length;

    if (src.count >= src.size) {
      var idx = s.lastIndexOf('},{');
      if (idx !== -1) {
        var left = s.slice(0, idx + 1) + ']';
        subFile.end(left, enc);
        src.part += 1;
        subFilePath = filePath.name + '_part_' + src.part + '.json';
        subFile = fs.createWriteStream(subFilePath, {flags: 'w+', defaultEncoding: enc});
        subFile.write('[' + s.slice(idx + 2));
        src.count = 0;
      } else {
        subFile.write(s, enc);
      }
    } else {
      subFile.write(s, enc);
    }
  }).on('end', function () {
    console.log('Done!');
    console.log('' + src.part + ' files were created in the current' +
      ' directory!');
    process.exit(0);
  });
}

if (typeof module !== 'undefined' && module.parent) {
  module.exports = splitLargeJSON;
} else {
  let file = process.argv[2];
  let size = +(process.argv[3]);
  let enc = process.argv[4];
  splitLargeJSON(file, size, enc);
}


text:
#ifndef D__PERSISTENTDATALISTENER_H
#define D__PERSISTENTDATALISTENER_H

#include "d__types.h"
#include "d__listener.h"
#include "u_groupQueue.h"

#if defined (__cplusplus)
extern "C" {
#endif

d_persistentDataListener d_persistentDataListenerNew (d_subscriber subscriber);

void                     d_persistentDataListenerFree (d_persistentDataListener listener);

c_bool                   d_persistentDataListenerStart (d_persistentDataListener listener);

c_bool                   d_persistentDataListenerStop (d_persistentDataListener listener);

#if defined (__cplusplus)
}
#endif

#endif /* D__PERSISTENTDATALISTENER_H */


text:
CREATE TABLE fcp_proposal (
    id SERIAL PRIMARY KEY,
    fk_issue INTEGER UNIQUE NOT NULL REFERENCES issue (id),
    fk_initiator INTEGER NOT NULL REFERENCES githubuser (id),
    fk_initiating_comment INTEGER NOT NULL REFERENCES issuecomment (id),
    disposition VARCHAR NOT NULL
);

CREATE TABLE fcp_review_request (
    id SERIAL PRIMARY KEY,
    fk_proposal INTEGER NOT NULL REFERENCES fcp_proposal (id) ON DELETE CASCADE,
    fk_reviewer INTEGER NOT NULL REFERENCES githubuser (id),
    fk_reviewed_comment INTEGER REFERENCES issuecomment (id),
    UNIQUE (fk_proposal, fk_reviewer)
);

CREATE TABLE fcp_concern (
    id SERIAL PRIMARY KEY,
    fk_proposal INTEGER NOT NULL REFERENCES fcp_proposal (id) ON DELETE CASCADE,
    fk_initiator INTEGER NOT NULL REFERENCES githubuser (id),
    fk_resolved_comment INTEGER REFERENCES issuecomment (id),
    name VARCHAR NOT NULL
);

CREATE TABLE rfc_feedback_request (
    id SERIAL PRIMARY KEY,
    fk_initiator INTEGER NOT NULL REFERENCES githubuser (id),
    fk_requested INTEGER NOT NULL REFERENCES githubuser (id),
    fk_issue INTEGER NOT NULL REFERENCES issue (id),
    fk_feedback_comment INTEGER REFERENCES issuecomment (id)
);