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

using Google.Api.Gax;
using Google.Apis.Bigquery.v2.Data;
using Google.Apis.Requests;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace Google.Cloud.BigQuery.V2
{
    public partial class BigQueryClientImpl
    {
        // TODO: Allow JSON and CSV to be loaded from a TextReader? Tricky, but useful.

        /// <inheritdoc />
        public override BigQueryJob UploadCsv(TableReference tableReference, TableSchema schema, Stream input, UploadCsvOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));
            schema = schema ?? GetSchema(tableReference);

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat = "CSV",
                Schema = schema,
            };
            options?.ModifyConfiguration(configuration);

            return UploadData(configuration, input, "text/csv");
        }

        /// <inheritdoc />
        public override BigQueryJob UploadAvro(TableReference tableReference, TableSchema schema, Stream input, UploadAvroOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));
            schema = schema ?? GetSchema(tableReference);

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat = "AVRO",
                Schema = schema,
            };
            options?.ModifyConfiguration(configuration);

            return UploadData(configuration, input, "application/vnd.apache.avro+binary");
        }

        /// <inheritdoc />
        public override BigQueryJob UploadJson(TableReference tableReference, TableSchema schema, IEnumerable<string> rows, UploadJsonOptions options = null)
            => UploadJson(tableReference, schema, CreateJsonStream(rows), options);

        /// <inheritdoc />
        public override BigQueryJob UploadJson(TableReference tableReference, TableSchema schema, Stream input, UploadJsonOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));
            schema = schema ?? GetSchema(tableReference);

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat = "NEWLINE_DELIMITED_JSON",
                Schema = schema
            };
            options?.ModifyConfiguration(configuration);

            return UploadData(configuration, input, "text/json");
        }

        private TableSchema GetSchema(TableReference tableReference)
        {
            // TODO: Handle "table doesn't exist" more reasonably.
            var table = GetTable(tableReference);
            return table.Schema;
        }

        private BigQueryJob UploadData(JobConfigurationLoad loadConfiguration, Stream input, string contentType)
        {
            var job = new Job { Configuration = new JobConfiguration { Load = loadConfiguration } };
            var mediaUpload = new CustomMediaUpload(Service, job, ProjectId, input, contentType);
            mediaUpload.Options.ModifySessionInitiationRequest += _versionHeaderAction;
            var finalProgress = mediaUpload.Upload();
            if (finalProgress.Exception != null)
            {
                throw finalProgress.Exception;
            }
            return new BigQueryJob(this, mediaUpload.ResponseBody);
        }

        /// <inheritdoc />
        public override void InsertRows(TableReference tableReference, IEnumerable<BigQueryInsertRow> rows, InsertOptions options = null)
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(rows, nameof(rows));

            var body = new TableDataInsertAllRequest
            {
                Rows = rows.Select(row =>
                {
                    GaxPreconditions.CheckArgument(row != null, nameof(rows), "Entries must not be null");
                    return row.ToRowsData();
                }).ToList()
            };
            options?.ModifyRequest(body);
            var request = Service.Tabledata.InsertAll(body, tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);
            request.ModifyRequest += _versionHeaderAction;
            var response = request.Execute();
            HandleInsertAllResponse(response);
        }

        private void HandleInsertAllResponse(TableDataInsertAllResponse response)
        {
            var errors = response.InsertErrors;
            if (errors?.Count > 0)
            {
                var exception = new GoogleApiException(Service.Name, "Error inserting data")
                {
                    Error = new RequestError
                    {
                        Errors = response.InsertErrors
                            .SelectMany(rowErrors => (rowErrors.Errors ?? Enumerable.Empty<ErrorProto>()).Select(error => new SingleError
                            {
                                Location = error.Location,
                                Reason = error.Reason,
                                Message = $"Row {rowErrors.Index}: {error.Message}"
                            }))
                            .ToList()
                    }
                };
                throw exception;
            }
        }

        /// <inheritdoc />
        public override async Task<BigQueryJob> UploadCsvAsync(TableReference tableReference, TableSchema schema, Stream input, UploadCsvOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));
            schema = schema ?? await GetSchemaAsync(tableReference, cancellationToken).ConfigureAwait(false);

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat = "CSV",
                Schema = schema,
            };
            options?.ModifyConfiguration(configuration);

            return await UploadDataAsync(configuration, input, "text/csv", cancellationToken).ConfigureAwait(false);
        }

        /// <inheritdoc />
        public override async Task<BigQueryJob> UploadAvroAsync(TableReference tableReference, TableSchema schema, Stream input, UploadAvroOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));
            schema = schema ?? await GetSchemaAsync(tableReference, cancellationToken).ConfigureAwait(false);

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat = "AVRO",
                Schema = schema,
            };
            options?.ModifyConfiguration(configuration);

            return await UploadDataAsync(configuration, input, "application/vnd.apache.avro+binary", cancellationToken).ConfigureAwait(false);
        }

        /// <inheritdoc />
        public override Task<BigQueryJob> UploadJsonAsync(TableReference tableReference, TableSchema schema, IEnumerable<string> rows,
            UploadJsonOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
            => UploadJsonAsync(tableReference, schema, CreateJsonStream(rows), options, cancellationToken);

        /// <inheritdoc />
        public override async Task<BigQueryJob> UploadJsonAsync(TableReference tableReference, TableSchema schema, Stream input,
            UploadJsonOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(input, nameof(input));
            schema = schema ?? await GetSchemaAsync(tableReference, cancellationToken).ConfigureAwait(false);

            var configuration = new JobConfigurationLoad
            {
                DestinationTable = tableReference,
                SourceFormat = "NEWLINE_DELIMITED_JSON",
                Schema = schema
            };
            options?.ModifyConfiguration(configuration);

            return await UploadDataAsync(configuration, input, "text/json", cancellationToken).ConfigureAwait(false);
        }

        private async Task<TableSchema> GetSchemaAsync(TableReference tableReference, CancellationToken cancellationToken)
        {
            // TODO: Handle "table doesn't exist" more reasonably.
            var table = await GetTableAsync(tableReference, cancellationToken: cancellationToken).ConfigureAwait(false);
            return table.Schema;
        }

        private async Task<BigQueryJob> UploadDataAsync(JobConfigurationLoad loadConfiguration, Stream input, string contentType, CancellationToken cancellationToken)
        {
            var job = new Job { Configuration = new JobConfiguration { Load = loadConfiguration } };
            var mediaUpload = new CustomMediaUpload(Service, job, ProjectId, input, contentType);
            mediaUpload.Options.ModifySessionInitiationRequest += _versionHeaderAction;
            var finalProgress = await mediaUpload.UploadAsync(cancellationToken).ConfigureAwait(false);
            if (finalProgress.Exception != null)
            {
                throw finalProgress.Exception;
            }
            return new BigQueryJob(this, mediaUpload.ResponseBody);
        }

        /// <inheritdoc />
        public override async Task InsertRowsAsync(TableReference tableReference, IEnumerable<BigQueryInsertRow> rows,
            InsertOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            GaxPreconditions.CheckNotNull(tableReference, nameof(tableReference));
            GaxPreconditions.CheckNotNull(rows, nameof(rows));

            var body = new TableDataInsertAllRequest
            {
                Rows = rows.Select(row =>
                {
                    GaxPreconditions.CheckArgument(row != null, nameof(rows), "Entries must not be null");
                    return row.ToRowsData();
                }).ToList()
            };
            options?.ModifyRequest(body);
            var request = Service.Tabledata.InsertAll(body, tableReference.ProjectId, tableReference.DatasetId, tableReference.TableId);
            request.ModifyRequest += _versionHeaderAction;
            var response = await request.ExecuteAsync(cancellationToken).ConfigureAwait(false);
            HandleInsertAllResponse(response);
        }

        /// <summary>
        /// Creates a stream containing JSON data from the given rows. Each row is sanitized to a single
        /// line by replacing CR and LF with space. The stream contains UTF-8, LF-separated lines.
        /// </summary>
        private static Stream CreateJsonStream(IEnumerable<string> rows)
        {
            GaxPreconditions.CheckNotNull(rows, nameof(rows));
            var stream = new MemoryStream();
            // No using statement here, as we want the stream to stay open. StreamWriter.Dispose()
            // will dispose of the underlying stream in this case.
            var writer = new StreamWriter(stream);
            foreach (var row in rows)
            {
                GaxPreconditions.CheckArgument(row != null, nameof(rows), "JSON string sequence cannot contain null elements");
                var sanitized = row.Replace('\n', ' ').Replace('\r', ' ');
                writer.Write(sanitized);
                writer.Write('\n');
            }
            writer.Flush();
            stream.Position = 0;
            return stream;
        }
    }
}


text:
//
//  AKOLibrary_CoreText.h
//  AKOLibrary
//
//  Created by Adrian on 4/15/11.
//  Copyright (c) 2009, 2010, 2011, Adrian Kosmaczewski & akosma software
//  All rights reserved.
//
//  Use in source and/or binary forms without modification is permitted following the
//  instructions in the LICENSE file.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
//  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
//  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
//  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
//  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
//  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
//  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
//  OF THE POSSIBILITY OF SUCH DAMAGE.
//

/**
 @file AKOLibrary_CoreText.h
 Header file with extensions to Core Text.
 */

#import "UIFont+AKOLibrary.h"
#import "AKOMultiPageTextView.h"

redpajama_set_name: RedPajamaGithub


text:
package org.encog.ml.svm.training;

import org.encog.EncogError;
import org.encog.mathutil.libsvm.svm_node;
import org.encog.mathutil.libsvm.svm_problem;
import org.encog.ml.data.MLData;
import org.encog.ml.data.MLDataPair;
import org.encog.ml.data.MLDataSet;

/**
 * Encode an Encog dataset as a SVM problem.
 */
public final class EncodeSVMProblem {

	/**
	 * Encode the Encog dataset.
	 *
	 * @param training
	 *            The training data.
	 * @param outputIndex
	 *            The ideal element to use, this is necessary because SVM's have
	 *            only a single output. This value is typically zero.
	 * @return The SVM problem.
	 */
	public static svm_problem encode(final MLDataSet training,
			final int outputIndex) {
		try {
			final svm_problem result = new svm_problem();

			result.l = (int) training.getRecordCount();

			result.y = new double[result.l];
			result.x = new svm_node[result.l][training.getInputSize()];

			int elementIndex = 0;

			for (final MLDataPair pair : training) {
				final MLData input = pair.getInput();
				final MLData output = pair.getIdeal();
				result.x[elementIndex] = new svm_node[input.size()];

				for (int i = 0; i < input.size(); i++) {
					result.x[elementIndex][i] = new svm_node();
					result.x[elementIndex][i].index = i + 1;
					result.x[elementIndex][i].value = input.getData(i);
				}

				result.y[elementIndex] = output.getData(outputIndex);

				elementIndex++;
			}

			return result;
		} catch (final OutOfMemoryError e) {
			throw new EncogError("SVM Model - Out of Memory");
		}
	}

	/**
	 * Private constructor.
	 */
	private EncodeSVMProblem() {

	}

}


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

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>pynance.opt.spread.vert — PyNance 0.5.0 documentation</title>

    <link rel="stylesheet" href="../../../../_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />

    <link rel="top" title="PyNance 0.5.0 documentation" href="../../../../index.html" />
    <link rel="up" title="Module code" href="../../../index.html" />

Navigation

          index

          modules |

PyNance 0.5.0 documentation »

Module code »

Quick search

    <form class="search" action="../../../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>

Source code for pynance.opt.spread.vert

"""
.. Copyright (c) 2015 Marshall Farrier
   license http://opensource.org/licenses/MIT

Options - vertical spreads (:mod:`pynance.opt.spread.vert`)
===========================================================

.. currentmodule:: pynance.opt.spread.vert
"""

from __future__ import absolute_import

import numpy as np
import pandas as pd

from .._common import _relevant_rows
from .._common import _getprice
from .. import _constants

[docs]class Vert(object):
    """
    Wrapper class for :class:`pandas.DataFrame` for retrieving
    metrics on vertical options spreads

    Objects of this class are not intended for direct instantiation
    but are created as attributes of objects of type
    :class:`~pynance.opt.spread.core.Spread`.

    .. versionadded:: 0.3.0

    Parameters
    ----------
    df : :class:`pandas.DataFrame`
        Options data.

    Attributes
    ----------
    data : :class:`pandas.DataFrame`

    Methods
    -------
    .. automethod:: call

    .. automethod:: put

    .. automethod:: straddle
    """
    def __init__(self, df):
        self.data = df

[docs]    def call(self, lowstrike, highstrike, expiry):
        """
        Metrics for evaluating a bull call spread.

        The metrics returned can easily be translated into bear
        spread metrics. The difference is only whether one buys
        the call at the lower strike and sells at the higher
        (bull call spread) or sells at the lower while buying
        at the higher (bear call spread). The metrics
        dataframe shows values for a bull call spread, where
        the transaction is a debit. A bear call spread
        is created by *selling* a bull call spread, so the transaction
        amount is the same, but it
        is a credit rather than a debit.

        Parameters
        ------------
        lowstrike : numeric
            Lower strike price.
        highstrike : numeric
            Higher strike sprice.
        expiry : date or date str (e.g. '2015-01-01')
            Expiration date.

        Returns
        ------------
        metrics : DataFrame

        Notes
        -----
        Cf. Lawrence McMillan, Options as a Strategic Investment, 5th ed., pp. 157ff.

        See Also
        --------
        :meth:`put`
        """
        assert lowstrike < highstrike
        _rows = {}
        _prices = {}
        _opttype = 'call'
        for _strike in (lowstrike, highstrike):
            _rows[_strike] = _relevant_rows(self.data, (_strike, expiry, _opttype,),
                    "No key for {} strike {} {}".format(expiry, _strike, _opttype))
            _prices[_strike] = _getprice(_rows[_strike])
        _eq = _rows[lowstrike].loc[:, 'Underlying_Price'].values[0]
        _qt = _rows[lowstrike].loc[:, 'Quote_Time'].values[0]
        _debit = _prices[lowstrike] - _prices[highstrike]
        _breakeven = lowstrike + _debit
        if _breakeven > highstrike:
            _breakeven = np.nan
        _maxprof = highstrike - lowstrike -_debit
        _index = ['Low Strike Call', 'High Strike Call', 'Debit',  'Break_Even',
                'Max Profit', 'Underlying_Price', 'Quote_Time']
        _vals = np.array([_prices[lowstrike], _prices[highstrike], _debit,
                _breakeven, _maxprof, _eq, _qt])
        return pd.DataFrame(_vals, index=_index, columns=['Value'])

[docs]    def put(self, lowstrike, highstrike, expiry):
        """
        Metrics for evaluating a bear put spread.

        The metrics returned can easily be translated into bull
        spread metrics. The difference is only whether one buys
        the put at the lower strike and sells at the higher
        (bear put spread) or sells at the lower while buying
        at the higher (bull put spread). The metrics
        dataframe shows values for a bear put spread, where
        the transaction is a debit. A bull put spread
        is created by *selling* a bear put spread, so the transaction
        amount is the same, but it
        is a credit rather than a debit.

        Parameters
        ------------
        lowstrike : numeric
            Lower strike price.
        highstrike : numeric
            Higher strike sprice.
        expiry : date or date str (e.g. '2015-01-01')
            Expiration date.

        Returns
        ------------
        metrics : DataFrame

        Notes
        -----
        Cf. Lawrence McMillan, Options as a Strategic Investment, 5th ed., pp. 316ff.

        See Also
        --------
        :meth:`call`
        """
        assert lowstrike < highstrike
        _rows = {}
        _prices = {}
        _opttype = 'put'
        for _strike in (lowstrike, highstrike):
            _rows[_strike] = _relevant_rows(self.data, (_strike, expiry, _opttype,),
                    "No key for {} strike {} {}".format(expiry, _strike, _opttype))
            _prices[_strike] = _getprice(_rows[_strike])
        _eq = _rows[lowstrike].loc[:, 'Underlying_Price'].values[0]
        _qt = _rows[lowstrike].loc[:, 'Quote_Time'].values[0]
        _debit = _prices[highstrike] - _prices[lowstrike]
        _breakeven = highstrike - _debit
        _maxprof = highstrike - lowstrike -_debit
        if _breakeven < lowstrike:
            _breakeven = np.nan
        _index = ['Low Strike Put', 'High Strike Put', 'Debit',  'Break_Even',
                'Max Profit', 'Underlying_Price', 'Quote_Time']
        _vals = np.array([_prices[lowstrike], _prices[highstrike], _debit,
                _breakeven, _maxprof, _eq, _qt])
        return pd.DataFrame(_vals, index=_index, columns=['Value'])

[docs]    def straddle(self, strike, expiry):
        """
        Metrics for evaluating a straddle.

        Parameters
        ------------
        strike : numeric
            Strike price.
        expiry : date or date str (e.g. '2015-01-01')
            Expiration date.

        Returns
        ------------
        metrics : DataFrame
            Metrics for evaluating straddle.
        """
        _rows = {}
        _prices = {}
        for _opttype in _constants.OPTTYPES:
            _rows[_opttype] = _relevant_rows(self.data, (strike, expiry, _opttype,),
                    "No key for {} strike {} {}".format(expiry, strike, _opttype))
            _prices[_opttype] = _getprice(_rows[_opttype])
        _eq = _rows[_constants.OPTTYPES[0]].loc[:, 'Underlying_Price'].values[0]
        _qt = _rows[_constants.OPTTYPES[0]].loc[:, 'Quote_Time'].values[0]
        _index = ['Call', 'Put', 'Credit', 'Underlying_Price', 'Quote_Time']
        _vals = np.array([_prices['call'], _prices['put'], _prices['call'] + _prices['put'], _eq, _qt])
        return pd.DataFrame(_vals, index=_index, columns=['Value'])

Navigation

          index

          modules |

PyNance 0.5.0 documentation »

Module code »

        © Copyright 2015-2016, Marshall Farrier.
      Created using Sphinx 1.4.


text:
describe 'nginx::ohai_plugin' do
  let(:chef_run) do
    ChefSpec::Runner.new.converge(described_recipe)
  end

  xit 'defines ohai reload resource' do
    # submit PR on ohai cookbook and fix it
    pending('ohai cookbook does not provide a matcher or ohai resource')
  end

  it 'create nginx ohai configuration' do
    expect(chef_run).to render_file('/etc/chef/ohai_plugins/nginx.rb')
  end

  it 'reloads ohai' do
    expect(chef_run.template('/etc/chef/ohai_plugins/nginx.rb')).to notify('ohai[reload_nginx]').to(:reload).immediately
  end

  it 'includes the ohai default recipe' do
    expect(chef_run).to include_recipe('ohai::default')
  end
end


text:
import { module } from 'angular';

import { CHECK_PRECONDITIONS_STAGE } from './checkPreconditionsStage';
import { STAGE_COMMON_MODULE } from '../common/stage.common.module';
import { CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE } from '../stage.module';

export const CHECK_PRECONDITIONS_STAGE_MODULE = 'spinnaker.pipelines.stage.checkPreconditions';
module(CHECK_PRECONDITIONS_STAGE_MODULE, [
  CORE_PIPELINE_CONFIG_STAGES_STAGE_MODULE,
  STAGE_COMMON_MODULE,
  CHECK_PRECONDITIONS_STAGE,
]);


text: from .consolehive import consolehive, consoleapp


text:
package main

import (
	"encoding/json"
	"io"
	"io/ioutil"
	"log"
	"strconv"
	"strings"
)

func Convert(r io.Reader) []byte {
	tables := parse(r)
	return tables.ToJSON()
}

type DummyTable struct {
	Name    string
	Columns []string
	Rows    [][]interface{}
}

func (d *DummyTable) RowMap(r int) map[string]interface{} {
	row := d.Rows[r]

	m := make(map[string]interface{})
	for i := 0; i < len(row); i++ {
		m[d.Columns[i]] = row[i]
	}

	return m
}

type DummyTables []*DummyTable

func (d DummyTables) ToJSON() []byte {
	jsonTables := make(map[string][]map[string]interface{})

	for _, table := range d {
		for i := 0; i < len(table.Rows); i++ {
			jsonTables[table.Name] = append(jsonTables[table.Name], table.RowMap(i))
		}
	}

	data, err := json.MarshalIndent(jsonTables, "", "  ")
	if err != nil {
		log.Fatal(err)
	}

	return data
}

func parse(r io.Reader) DummyTables {

	data, err := ioutil.ReadAll(r)
	if err != nil {
		log.Fatal(err)
	}

	dummyTables := make(DummyTables, 0)

	str := string(data)

	// TODO: Lots of ugly string splitting that needs to be taken care of.
	tables := strings.Split(str, "-- Table structure for table `")[1:]
	for _, table := range tables {
		tableName := strings.SplitN(table, "`", 2)[0]

		dummyTable := DummyTable{tableName, make([]string, 0), make([][]interface{}, 0)}
		dummyTables = append(dummyTables, &dummyTable)

		columnsRaw := strings.Split(table, "  `")
		for _, columnRaw := range columnsRaw {
			column := strings.SplitN(columnRaw, "`", 2)[0]
			dummyTable.Columns = append(dummyTable.Columns, column)
		}
		dummyTable.Columns = dummyTable.Columns[1:]

		valuesData := strings.Split(table, "` VALUES (")
		if len(valuesData) < 2 {
			continue
		}
		values := valuesData[1]

		newRow := make([]interface{}, 0)

		open := false
		openString := false
		start := 0

		i := 0
		for {
			if i >= len(values) {
				break
			}

			if values[i] == ')' {
				// Special case if number and last element
				if open && !openString {
					// Close and add as usual
					newRow = append(newRow, typify(values[start:i]))
					open = false
					i++

					// Add row
					dummyTable.Rows = append(dummyTable.Rows, newRow)
					newRow = make([]interface{}, 0)
					continue
				} else if !open {
					// Means we're ending after a string, add row
					dummyTable.Rows = append(dummyTable.Rows, newRow)
					newRow = make([]interface{}, 0)
					i++
					continue
				}
			}

			// Null
			if !open && values[i:i+4] == "NULL" {
				newRow = append(newRow, typify(values[i:i+4]))
				i = i + 4
				continue
			}

			//// Numbers
			// Open number
			numbers := "0123456789-."
			if !open && strings.Contains(numbers, string(values[i])) {
				start = i
				open = true
				i++
				continue
			}

			// End number
			if open && !openString && values[i] == ',' {
				newRow = append(newRow, typify(values[start:i]))
				open = false
				i++
				continue
			}

			//// Strings
			// Open string
			if !openString && values[i] == '\'' {
				start = i + 1
				open = true
				openString = true
				i++
				continue
			}

			// End string
			if openString && values[i] == '\'' {
				newRow = append(newRow, typify(values[start:i]))
				open = false
				openString = false
				i++
				continue
			}
			i++
		}

	}

	return dummyTables
}

func typify(val string) interface{} {
	i, err := strconv.ParseFloat(val, 64)
	if err == nil {
		return i
	}

	f, err := strconv.ParseInt(val, 10, 64)
	if err == nil {
		return int(f)
	}

	return val
}


text:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../inc/atom.h"

#include "test.h"

void test_atom(void)
{
  char* s = "test_atom";
  char* v;
  fprintf(stdout, "call function : %s\n", __func__);

  fprintf(stdout, "test function atom_new ===>\n");
  v = (char*)atom_new(s, strlen(s));
  fprintf(stdout, "\tcall atom_new(s, strlen(s)) = %s\n", v);

  fprintf(stdout, "\ntest function atom_length ===>\n");
  fprintf(stdout, "\tcall atom_length(v) = %d\n", atom_length(v));

  fprintf(stdout, "\ntest function atom_int ===>\n");
  fprintf(stdout, "\tcall atom_int(100) = %s\n", atom_int(100));

  fprintf(stdout, "\ntest function atom_string ===>\n");
  fprintf(stdout, "\tcall atom_string(\"Hello, world!\") = %s\n", atom_string("Hello, world!"));
}


text:
import QuestionPage from '../../question.page'

class OtherAddressPage extends QuestionPage {

  constructor() {
    super('other-address')
  }

  setOtherAddressAnswerBuilding(value) {
    browser.setValue('[name="other-address-answer-building"]', value)
    return this
  }

  getOtherAddressAnswerBuilding(value) {
    return browser.element('[name="other-address-answer-building"]').getValue()
  }

  setOtherAddressAnswerStreet(value) {
    browser.setValue('[name="other-address-answer-street"]', value)
    return this
  }

  getOtherAddressAnswerStreet(value) {
    return browser.element('[name="other-address-answer-street"]').getValue()
  }

  setOtherAddressAnswerCity(value) {
    browser.setValue('[name="other-address-answer-city"]', value)
    return this
  }

  getOtherAddressAnswerCity(value) {
    return browser.element('[name="other-address-answer-city"]').getValue()
  }

  setOtherAddressAnswerCounty(value) {
    browser.setValue('[name="other-address-answer-county"]', value)
    return this
  }

  getOtherAddressAnswerCounty(value) {
    return browser.element('[name="other-address-answer-county"]').getValue()
  }

  setOtherAddressAnswerPostcode(value) {
    browser.setValue('[name="other-address-answer-postcode"]', value)
    return this
  }

  getOtherAddressAnswerPostcode(value) {
    return browser.element('[name="other-address-answer-postcode"]').getValue()
  }

}

export default new OtherAddressPage()


text:
RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'
BLUE='\033[0m;31m'

ARTIFACTORY_URL=https://eneco.github.io/helm-charts/

# We begin by testing if we can reach artifactory
echo -e ""
echo -e "==> ${GREEN}Testing if we can reach the helm repository at ${ARTIFACTORY_URL} ${NC}..."
code=`curl -o /dev/null -I -w "%{http_code}" $ARTIFACTORY_URL -sSL`
if [ $? -eq 0 ]; then
  if [ ! $code -eq 200 ]; then
    echo -e "==> ${RED}ERROR: Unable to read from repository. Received status code: ${BLUE}$code${NC}"
    exit $code
  fi
else
  echo -e "==> ${RED}ERROR: Unable to reach remote repository${NC}"
  exit 1
fi
echo -e "==> ${GREEN}Valid helm repository configured...${NC}"

echo -e ""
echo -e "==> ${GREEN}Testing if charts have been properly versioned...${NC}"
error=0

for path in `find packages -name "*.tgz"`; do
  # strip packages/ from the path name
  package=`echo -e $path | sed 's:packages/::'`
  echo -e $package

  # download existing artifact (if it exists)
  curl "$ARTIFACTORY_URL/$package" -o packages/$package.compare --fail -sL -m 5

  # if there is no current artifact, or there is no difference between them, we are good
  if [ -a packages/$package.compare ]; then
    echo -e "${GREEN}Comparing packages/$package and packages/$package.compare${NC}"
    if ! cmp -s packages/$package packages/$package.compare; then
      echo -e "==> ${RED}WARNING: You have updated chart $package without bumping the version...${NC}"
      error=1
    else
      echo -e "==> ${GREEN}Properly versioned: $package${NC}"
    fi
  else
    echo -e "==> ${GREEN}Properly versioned: $package${NC}"
  fi
done

if [ $error -eq 1 ]; then
  echo -e ""
  echo -e "==> ${RED}ERROR: There are charts updated without bumping the version!${NC}"
  echo -e ""
  exit 1
else
  echo -e ""
  echo -e "==> ${GREEN}Tests passed!${NC}"
  echo -e ""
fi


text:
package org.openqa.selenium;

import org.junit.Test;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.JavascriptEnabled;

import java.util.concurrent.Callable;

import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.openqa.selenium.TestWaiter.waitFor;
import static org.openqa.selenium.testing.Ignore.Driver.ANDROID;
import static org.openqa.selenium.testing.Ignore.Driver.CHROME;
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
import static org.openqa.selenium.testing.Ignore.Driver.IE;
import static org.openqa.selenium.testing.Ignore.Driver.IPHONE;
import static org.openqa.selenium.testing.Ignore.Driver.OPERA;
import static org.openqa.selenium.testing.Ignore.Driver.OPERA_MOBILE;
import static org.openqa.selenium.testing.Ignore.Driver.SELENESE;

public class VisibilityTest extends JUnit4TestBase {

  @JavascriptEnabled
  @Test
  public void testShouldAllowTheUserToTellIfAnElementIsDisplayedOrNot() {
    driver.get(pages.javascriptPage);

    assertThat(driver.findElement(By.id("displayed")).isDisplayed(),
               is(true));
    assertThat(driver.findElement(By.id("none")).isDisplayed(), is(false));
    assertThat(driver.findElement(By.id("suppressedParagraph")).isDisplayed(), is(false));
    assertThat(driver.findElement(By.id("hidden")).isDisplayed(), is(false));
  }

  @JavascriptEnabled
  @Test
  public void testVisibilityShouldTakeIntoAccountParentVisibility() {
    driver.get(pages.javascriptPage);

    WebElement childDiv = driver.findElement(By.id("hiddenchild"));
    WebElement hiddenLink = driver.findElement(By.id("hiddenlink"));

    assertFalse(childDiv.isDisplayed());
    assertFalse(hiddenLink.isDisplayed());
  }

  @JavascriptEnabled
  @Test
  public void testShouldCountElementsAsVisibleIfStylePropertyHasBeenSet() {
    driver.get(pages.javascriptPage);

    WebElement shown = driver.findElement(By.id("visibleSubElement"));

    assertTrue(shown.isDisplayed());
  }

  @JavascriptEnabled
  @Test
  public void testShouldModifyTheVisibilityOfAnElementDynamically() {
    driver.get(pages.javascriptPage);

    WebElement element = driver.findElement(By.id("hideMe"));

    assertTrue(element.isDisplayed());

    element.click();

    waitFor(elementNotToDisplayed(element));

    assertFalse(element.isDisplayed());
  }

  @JavascriptEnabled
  @Test
  public void testHiddenInputElementsAreNeverVisible() {
    driver.get(pages.javascriptPage);

    WebElement shown = driver.findElement(By.name("hidden"));

    assertFalse(shown.isDisplayed());
  }

  @JavascriptEnabled
  @Ignore(SELENESE)
  @Test
  public void testShouldNotBeAbleToClickOnAnElementThatIsNotDisplayed() {
    driver.get(pages.javascriptPage);
    WebElement element = driver.findElement(By.id("unclickable"));

    try {
      element.click();
      fail("You should not be able to click on an invisible element");
    } catch (ElementNotVisibleException e) {
      // This is expected
    }
  }

  @JavascriptEnabled
  @Ignore(SELENESE)
  @Test
  public void testShouldNotBeAbleToTypeAnElementThatIsNotDisplayed() {
    driver.get(pages.javascriptPage);
    WebElement element = driver.findElement(By.id("unclickable"));

    try {
      element.sendKeys("You don't see me");
      fail("You should not be able to send keyboard input to an invisible element");
    } catch (ElementNotVisibleException e) {
      // This is expected
    }

    assertThat(element.getAttribute("value"), is(not("You don't see me")));
  }

  @JavascriptEnabled
  @Ignore({IE, SELENESE})
  @Test
  public void testZeroSizedDivIsShownIfDescendantHasSize() {
    driver.get(pages.javascriptPage);

    WebElement element = driver.findElement(By.id("zero"));
    Dimension size = element.getSize();

    assertEquals("Should have 0 width", 0, size.width);
    assertEquals("Should have 0 height", 0, size.height);
    assertTrue(element.isDisplayed());
  }

  private Callable<Boolean> elementNotToDisplayed(final WebElement element) {
    return new Callable<Boolean>() {

      public Boolean call() throws Exception {
        return !element.isDisplayed();
      }
    };
  }

  @Test
  public void parentNodeVisibleWhenAllChildrenAreAbsolutelyPositionedAndOverflowIsHidden() {
    String url = appServer.whereIs("visibility-css.html");
    driver.get(url);

    WebElement element = driver.findElement(By.id("suggest"));
    assertTrue(element.isDisplayed());
  }

  @Test
  @Ignore({ANDROID, CHROME, HTMLUNIT, IE, IPHONE, SELENESE, OPERA, OPERA_MOBILE})
  public void tooSmallAWindowWithOverflowHiddenIsNotAProblem() {
    WebDriver.Window window = driver.manage().window();
    Dimension originalSize = window.getSize();

    try {
      // Short in the Y dimension
      window.setSize(new Dimension(1024, 500));

      String url = appServer.whereIs("overflow-body.html");
      driver.get(url);

      WebElement element = driver.findElement(By.name("resultsFrame"));
      assertTrue(element.isDisplayed());
    } finally {
      window.setSize(originalSize);
    }
  }

}


text:
'use strict';
define(["require", "exports", './objectpascal-forms-moduleDef', 'monaco'], function (require, exports, languageDef, monaco) {
    monaco.Modes.registerMonarchDefinition('objectpascal-forms-module', languageDef.language);
});


text:
iTrajComp
=====

The **iTrajComp** VMD plugin is a general analysis tool for trajectories.

It is under heavy development, but it can already do a few interesting things (no guarantees, though!). In hopes of helping our fellow VMD users, this webpage will host the preview releases of the tool. If you are interested in trying this tool, please contact the author. Once we are confident that the plugin is doing what it should and we get some time to write a little manual, it will be freely available from this webpage.

> Website: http://physiology.med.cornell.edu/faculty/hweinstein/vmdplugins/itrajcomp

## Installation

A small guide on how to install third party VMD plugins can be found [here](http://physiology.med.cornell.edu/faculty/hweinstein/vmdplugins/installation.html). In summary:

1. Create a VMD plugins' directory if you don't have one, ie */path/to/plugins/directory*.
2. Clone or download the project into a subdirectory of your *VMD plugins' directory* (ie. */path/to/plugins/directory/itrajcomp*):
```sh
cd /path/to/plugins/directory
git clone https://github.com/luisico/itrajcomp.git itrajcomp
```
3. Add the following to your *$HOME/.vmdrc* file (if you followed the instructions in the link above, you might already have the first line present):
```tcl
set auto_path [linsert $auto_path 0 {/path/to/plugins/directory}]
vmd_install_extension itrajcomp itrajcomp_tk_cb "WMC PhysBio/iTrajComp"
```
The iTrajComp plugin should be accessible from the Extensions menu.

### Speeding up rmsd calculations in VMD

Due to the repetition of the calculations, these can take a long time. I have created a patch for VMD's `measure rmsd` command that adds two options to speed up by residue and by atoms rmsd calculations, while maintaining compatibility with the standard command. New options are:
  - *byres*: will return an array with all the rmsd by residue in the selection after the global rmsd.
  - *byatom*: will return an array with all the rmsd by atom in the selection after the global rmsd.

A patch for VMD can be found in [RMSDTT](https://github.com/luisico/rmsdtt/tree/master/patches). You will need to recompile VMD. iTrajComp will use it if available.

Example use:
```tcl
lassign [measure rmsd $sel1 $sel2 byres] rmsd_global rmsd_byres

```
## Getting started

1. Load a small trajectory in vmd. Clculations on large trajectories might take a while, I recommend to use a small one while learning your way around the iTrajcomp

2. Click on tab `Selection` (upper right) and do your selection:
   - Atom selection: enter **all** in the text field
   - Molecules: **Top** (your current top molecule in the main window 'T')
   - Frames: **All**
   - Modifiers: **Trace** (behind the scenes this will transform the selection into "all and name CA")
   - Activate **Same selection**

3. Click on tab `Calculation` (upper right)
   a.  Select **rmsd**
   b.  Select **align** from the options. This will pre-align the pair of frames before calculating the rmsd

4. Click on **Calculate** (upper center) and you will get a new window. It might take some time if you trajectory is large

5. In the new window you see 3 tabs (Graph, Representations, Info). In the initial tab **Graph** you see a diagonal matrix, a color scale, a zoom interface, the calculation type options (*Set*) and some matrix manipulation options (*Keys*, *keep*,...):
   - Move your **mouse** around the matrix. You will see the correspoding key and value (rmsd in this case) in the lower left. Each key is (mol frame).
   - **Click** on a matrix cell. The color will change and the 2 structures (key1, key2) will be shown in VMD' graphic window. Their representation can be changed if you click in the tab **Representations** (this tab should be easy to understand)
     - Look in men *Help | Keybindings* for other options to select/deselect cells.
     - Option *keep* allows you to fix *Keys/Value*. They won't update while moving the mouse) but will change if you select/deselect a cell.
     - Options *Add/Del* help in adding/deleting cells when using batch selection (see *Help | Keybindings*)
   - Change the size of the cells with the **zoom** buttons
   - The color **scale**, well, gives an idea of the range of values. See *Help | Keybindings* for batch selection based on values
   - The menu **Transform** changes the values of each cell based on the selected function. You can always use the *Reset* option in that menu to get back to the original data. If the *Source is raw data* is active the source values for the transformation are the original data, otherwise the source values are the current ones displayed, ie. you could inverse and then normalize.
   - Data can be view and saved in different formats with the **File** menu. Use the matrix format to import it later in R.

## Reference

### Supported calculations

iTrajComp supports two calculation modes, *frames* and *segments*.

#### Frames mode

Each cell in the graph represents a pair of molecule/frame. For exapmle, cell `(0 1) (3 5)` in a rmsd graph contains the rmsd between `(molecule 0, frame 1)` and `(molecule 3, frame5)`.

In this mode the number of cells in the graph will depend on the number of molecules and frames, and is independent of the number of atoms. For example, a *rmsd* calculation with 2 molecules, each with 20 frames, 25 residues and 100 atoms will results in a graph of 40 by 40 cells.

Calculation types:
* **contacts**: number of contacts within a cutoff
* **hbonds**: number of hydrogen bonds within a cutoff, angle (as defined in VMD)
* **labels**: bonds, angles, dihedrals
* **rgyr**: radius of gyration
* **rmsd**: rmsd

#### Segments mode

In segments mode calculations are based on molecule segments, ie, residues or atoms. Each cell in the graph represents a pair of segments. For example, cell `(5 Glu) (7 Arg)` in a dist by residue graph contains the distance between residues `5 (Glu)` and `7 (Arg)`.

In this mode the number of cells in the graph will depend on the number of segments (atoms or residues) and is independent of the number of molecules or frames. For example, a *dist* calculation with 2 molecules, each with 20 frames, 25 residues and 100 atoms will results in a graph of 25 by 25 cells if the segments are residues and 100 by 100 if the segments are atoms.

Calculation types:
* **covar**: covariance among segments
* **dist**: distance among segments

#### Custom calculations

iTrajComp supports custom calculations created by users. Stay tunned for more information on how to created your own iTrajComp driven calculations.

### GUI

In the **main window** you find:

* **Menu**:
  * **File**: Load previously save results (*objects*).
  * **Options**: Activate/deactivate the progress bar.
  * **Combine**: Combine *objects*, ie `($1 + $2) / 2` will calculate the mean between to *object* results for each corresponding cell.

* 3 main **Tabs**:
  * **Selection**: make selections in this tab. It support 1 or 2 sets of atoms.
  * **Calculation**: select calculation type and options. Start a calculation with the *Calculate* button.
  * **Results**: index of calculation (*objects*) run so far.

**Each run** will create a new window (*object*) with a new GUI to show the results:
* **Menu**:
  * **File**: save results in different formats, view the raw data, hide the object (stil available from *Results* tab in the main plugin window) and destroy the object.
  * **Transform**: modify the data represented in the graph using different functions (inverse, normalize). Reset graph to the raw data. *source is raw data* selects the raw data as the source of the transformation. Otherwise the current data in the graph is used.
  * **Analysis**: calculate a few statistical descriptors on the current displayed data.

* **Tabs**:
  * **Graph**: 3D representation of the results. X/Y axis hold the *molecule/frame* or *residue/atom* pair depending on the type of calculation. Z is represented by the color of the cell. Click on the cells to see/hide representations in VMD's graphics window (see also *Help / Keybinding*).
    * **Scale**: clicking in the scale will select cells (see also *Help / Keybinding*).
    * **Zoom**: self explained.
    * **Set**: select the set to use: depending on the type of calculation you'll get different options here.
    * **Keys/Value**: *molecule/frame* or *residue/atom* corresponding to the cell were the mouse points in the graph. Value for that pair. The *keep* option allow to move in the graph without changing *keys* and *value*.
    * **Options add/del**: finner control in the selection of cells to represent in the vmd graphics window.
    * **Clear**: delete all selections from the graph.
  * **Info**: information on the run
  * **Representation**: change the representation to use in VMD's graphics window when selecting cells.

You can create as many of this *Objects* as you want, using different atom selections, calculation types/options,... And even combine them with the **Combine** menu.

### Keybindings

The following keybindings are available in the graph and scale (when noted):

Key | Selection | Scale
:----|:-----|:
 B1       | Select/Deselect one cell |
 B2       | Explore data for cell |
 Shift-B1 | Selects all cells in column/row of data
 Shift-B2 | Selects all cells in column/row with values <= than data clicked | [x]
 Shift-B3 | Selects all cells in column/row with values => than data clicked | [x]
 Ctrl-B1  | Selects all cells |
 Ctrl-B2  | Selects all cells with values <= than data clicked | [x]
 Ctrl-B3  | Selects all cells with values => than data clicked | [x]

## Author

Luis Gracia (https://github.com/luisico)

Developed at Weill Cornell Medical College

## Contributors

Please, use issues and pull requests for feedback and contributions to this project.

## License

See LICENSE.


text:
#pragma once
#include <aws/rds/RDS_EXPORTS.h>
#include <aws/rds/RDSRequest.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>

namespace Aws
{
namespace RDS
{
namespace Model
{

  /**
   */
  class AWS_RDS_API DeleteDBClusterEndpointRequest : public RDSRequest
  {
  public:
    DeleteDBClusterEndpointRequest();

    // Service request name is the Operation name which will send this request out,
    // each operation should has unique request name, so that we can get operation's name from this request.
    // Note: this is not true for response, multiple operations may have the same response name,
    // so we can not get operation's name from response.
    inline virtual const char* GetServiceRequestName() const override { return "DeleteDBClusterEndpoint"; }

    Aws::String SerializePayload() const override;

  protected:
    void DumpBodyToUrl(Aws::Http::URI& uri ) const override;

  public:

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline const Aws::String& GetDBClusterEndpointIdentifier() const{ return m_dBClusterEndpointIdentifier; }

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline bool DBClusterEndpointIdentifierHasBeenSet() const { return m_dBClusterEndpointIdentifierHasBeenSet; }

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline void SetDBClusterEndpointIdentifier(const Aws::String& value) { m_dBClusterEndpointIdentifierHasBeenSet = true; m_dBClusterEndpointIdentifier = value; }

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline void SetDBClusterEndpointIdentifier(Aws::String&& value) { m_dBClusterEndpointIdentifierHasBeenSet = true; m_dBClusterEndpointIdentifier = std::move(value); }

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline void SetDBClusterEndpointIdentifier(const char* value) { m_dBClusterEndpointIdentifierHasBeenSet = true; m_dBClusterEndpointIdentifier.assign(value); }

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline DeleteDBClusterEndpointRequest& WithDBClusterEndpointIdentifier(const Aws::String& value) { SetDBClusterEndpointIdentifier(value); return *this;}

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline DeleteDBClusterEndpointRequest& WithDBClusterEndpointIdentifier(Aws::String&& value) { SetDBClusterEndpointIdentifier(std::move(value)); return *this;}

    /**
     *
The identifier associated with the custom endpoint. This parameter is stored
     * as a lowercase string.

     */
    inline DeleteDBClusterEndpointRequest& WithDBClusterEndpointIdentifier(const char* value) { SetDBClusterEndpointIdentifier(value); return *this;}

  private:

    Aws::String m_dBClusterEndpointIdentifier;
    bool m_dBClusterEndpointIdentifierHasBeenSet = false;
  };

} // namespace Model
} // namespace RDS
} // namespace Aws


text:
<?php
/**
 * PqweServiceManagerException class
 */
namespace pqwe\Exception;

/**
 * exception for ServiceManager classes
 *
 * @exception
 */
class PqweServiceManagerException extends PqweException {
    /**
     * constructor
     *
     * @param string $str Exception message
     */
    public function __construct($str) {
        parent::__construct($str);
    }
}


text:
class GURL;

// HTTP server for receiving .
class PrivetHttpServer: public net::HttpServer::Delegate {
 public:
  // TODO(maksymb): Move this enum to some namespace instead of this class.
  enum RegistrationErrorStatus {
    REG_ERROR_OK,

    REG_ERROR_INVALID_PARAMS,
    REG_ERROR_DEVICE_BUSY,
    REG_ERROR_PENDING_USER_ACTION,
    REG_ERROR_USER_CANCEL,
    REG_ERROR_CONFIRMATION_TIMEOUT,
    REG_ERROR_INVALID_ACTION,
    REG_ERROR_OFFLINE,
    REG_ERROR_SERVER_ERROR
  };

  // TODO(maksymb): Move this struct to some namespace instead of this class.
  struct DeviceInfo {
    DeviceInfo();
    ~DeviceInfo();

    std::string version;
    std::string name;
    std::string description;
    std::string url;
    std::string id;
    std::string device_state;
    std::string connection_state;
    std::string manufacturer;
    std::string model;
    std::string serial_number;
    std::string firmware;
    int uptime;
    std::string x_privet_token;

    std::vector<std::string> api;
    std::vector<std::string> type;
  };

  class Delegate {
   public:
    virtual ~Delegate() {}

    // Invoked when registration is starting.
    virtual RegistrationErrorStatus RegistrationStart(
        const std::string& user) = 0;

    // Invoked when claimtoken is needed.
    virtual RegistrationErrorStatus RegistrationGetClaimToken(
        const std::string& user,
        std::string* token,
        std::string* claim_url) = 0;

    // Invoked when registration is going to be completed.
    virtual RegistrationErrorStatus RegistrationComplete(
        const std::string& user,
        std::string* device_id) = 0;

    // Invoked when client asked for cancelling the registration.
    virtual RegistrationErrorStatus RegistrationCancel(
        const std::string& user) = 0;

    // Invoked for receiving server error details.
    virtual void GetRegistrationServerError(std::string* description) = 0;

    // Invoked when /privet/info is called.
    virtual void CreateInfo(DeviceInfo* info) = 0;

    // Invoked for checking wether /privet/register should be exposed.
    virtual bool IsRegistered() const = 0;

    // Invoked for checking wether /privet/printer/* should be exposed.
    virtual bool IsLocalPrintingAllowed() const = 0;

    // Invoked when XPrivetToken has to be checked.
    virtual bool CheckXPrivetTokenHeader(const std::string& token) const = 0;

    // Invoked for getting capabilities.
    virtual const base::DictionaryValue& GetCapabilities() = 0;

    // Invoked for creating a job.
    virtual LocalPrintJob::CreateResult CreateJob(
        const std::string& ticket,
        std::string* job_id,
        int* expires_in,
        // TODO(maksymb): Use base::TimeDelta for timeouts
        int* error_timeout,
        std::string* error_description) = 0;

    // Invoked for simple local printing.
    virtual LocalPrintJob::SaveResult SubmitDoc(
        const LocalPrintJob& job,
        std::string* job_id,
        int* expires_in,
        std::string* error_description,
        int* timeout) = 0;

    // Invoked for advanced local printing.
    virtual LocalPrintJob::SaveResult SubmitDocWithId(
        const LocalPrintJob& job,
        const std::string& job_id,
        int* expires_in,
        std::string* error_description,
        int* timeout) = 0;

    // Invoked for getting job status.
    virtual bool GetJobState(const std::string& job_id,
                             LocalPrintJob::Info* info) = 0;
  };

  // Constructor doesn't start server.
  explicit PrivetHttpServer(Delegate* delegate);

  // Destroys the object.
  virtual ~PrivetHttpServer();

  // Starts HTTP server: start listening port |port| for HTTP requests.
  bool Start(uint16 port);

  // Stops HTTP server.
  void Shutdown();

 private:
  // net::HttpServer::Delegate methods:
  virtual void OnHttpRequest(
      int connection_id,
      const net::HttpServerRequestInfo& info) OVERRIDE;
  virtual void OnWebSocketRequest(
      int connection_id,
      const net::HttpServerRequestInfo& info) OVERRIDE;
  virtual void OnWebSocketMessage(int connection_id,
                                  const std::string& data) OVERRIDE;
  virtual void OnClose(int connection_id) OVERRIDE;

  // Sends error as response. Invoked when request method is invalid.
  void ReportInvalidMethod(int connection_id);

  // Returns |true| if |request| should be done with correct |method|.
  // Otherwise sends |Invalid method| error.
  // Also checks support of |request| by this server.
  bool ValidateRequestMethod(int connection_id,
                             const std::string& request,
                             const std::string& method);

  // Processes http request after all preparations (XPrivetHeader check,
  // data handling etc.)
  net::HttpStatusCode ProcessHttpRequest(
      const GURL& url,
      const net::HttpServerRequestInfo& info,
      std::string* response);

  // Pivet API methods. Return reference to NULL if output should be empty.
  scoped_ptr<base::DictionaryValue> ProcessInfo(
      net::HttpStatusCode* status_code) const;

  scoped_ptr<base::DictionaryValue> ProcessCapabilities(
      net::HttpStatusCode* status_code) const;

  scoped_ptr<base::DictionaryValue> ProcessCreateJob(
      const GURL& url,
      const std::string& body,
      net::HttpStatusCode* status_code) const;

  scoped_ptr<base::DictionaryValue> ProcessSubmitDoc(
      const GURL& url,
      const net::HttpServerRequestInfo& info,
      net::HttpStatusCode* status_code) const;

  scoped_ptr<base::DictionaryValue> ProcessJobState(
      const GURL& url,
      net::HttpStatusCode* status_code) const;

  scoped_ptr<base::DictionaryValue> ProcessRegister(
      const GURL& url,
      net::HttpStatusCode* status_code) const;

  // Processes current status and depending on it replaces (or not)
  // |current_response| with error or empty response.
  void ProcessRegistrationStatus(
      RegistrationErrorStatus status,
      scoped_ptr<base::DictionaryValue>* current_response) const;

  // Port for listening.

  uint16 port_;

  // Contains encapsulated object for listening for requests.
  scoped_refptr<net::HttpServer> server_;

  Delegate* delegate_;

  DISALLOW_COPY_AND_ASSIGN(PrivetHttpServer);
};

#endif  // CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_


text:
<?php

namespace PHPExcel\CachedObjectStorage;

class Wincache extends CacheBase implements ICache
{
    /**
     * Prefix used to uniquely identify cache data for this worksheet
     *
     * @var string
     */
    private $cachePrefix = null;

    /**
     * Cache timeout
     *
     * @var integer
     */
    private $cacheTime = 600;

    /**
     * Store cell data in cache for the current cell object if it's "dirty",
     *     and the 'nullify' the current cell object
     *
     * @return    void
     * @throws    \PHPExcel\Exception
     */
    protected function storeData()
    {
        if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
            $this->currentObject->detach();

            $obj = serialize($this->currentObject);
            if (wincache_ucache_exists($this->cachePrefix.$this->currentObjectID.'.cache')) {
                if (!wincache_ucache_set($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
                    $this->__destruct();
                    throw new \PHPExcel\Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
                }
            } else {
                if (!wincache_ucache_add($this->cachePrefix.$this->currentObjectID.'.cache', $obj, $this->cacheTime)) {
                    $this->__destruct();
                    throw new \PHPExcel\Exception('Failed to store cell '.$this->currentObjectID.' in WinCache');
                }
            }
            $this->currentCellIsDirty = false;
        }

        $this->currentObjectID = $this->currentObject = null;
    }

    /**
     * Add or Update a cell in cache identified by coordinate address
     *
     * @param   string            $pCoord        Coordinate address of the cell to update
     * @param   \PHPExcel\Cell    $cell        Cell to update
     * @return  \PHPExcel\Cell
     * @throws  \PHPExcel\Exception
     */
    public function addCacheData($pCoord, \PHPExcel\Cell $cell)
    {
        if (($pCoord !== $this->currentObjectID) && ($this->currentObjectID !== null)) {
            $this->storeData();
        }
        $this->cellCache[$pCoord] = true;

        $this->currentObjectID = $pCoord;
        $this->currentObject = $cell;
        $this->currentCellIsDirty = true;

        return $cell;
    }

    /**
     * Is a value set in the current \PHPExcel\CachedObjectStorage\ICache for an indexed cell?
     *
     * @param    string        $pCoord        Coordinate address of the cell to check
     * @return    boolean
     * @throws  \PHPExcel\Exception
     */
    public function isDataSet($pCoord)
    {
        //    Check if the requested entry is the current object, or exists in the cache
        if (parent::isDataSet($pCoord)) {
            if ($this->currentObjectID == $pCoord) {
                return true;
            }
            //    Check if the requested entry still exists in cache
            $success = wincache_ucache_exists($this->cachePrefix.$pCoord.'.cache');
            if ($success === false) {
                //    Entry no longer exists in Wincache, so clear it from the cache array
                parent::deleteCacheData($pCoord);
                throw new \PHPExcel\Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
            }
            return true;
        }
        return false;
    }

    /**
     * Get cell at a specific coordinate
     *
     * @param   string            $pCoord        Coordinate of the cell
     * @throws  \PHPExcel\Exception
     * @return  \PHPExcel\Cell    Cell that was found, or null if not found
     */
    public function getCacheData($pCoord)
    {
        if ($pCoord === $this->currentObjectID) {
            return $this->currentObject;
        }
        $this->storeData();

        //    Check if the entry that has been requested actually exists
        $obj = null;
        if (parent::isDataSet($pCoord)) {
            $success = false;
            $obj = wincache_ucache_get($this->cachePrefix.$pCoord.'.cache', $success);
            if ($success === false) {
                //    Entry no longer exists in WinCache, so clear it from the cache array
                parent::deleteCacheData($pCoord);
                throw new \PHPExcel\Exception('Cell entry '.$pCoord.' no longer exists in WinCache');
            }
        } else {
            //    Return null if requested entry doesn't exist in cache
            return null;
        }

        //    Set current entry to the requested entry
        $this->currentObjectID = $pCoord;
        $this->currentObject = unserialize($obj);
        //    Re-attach this as the cell's parent
        $this->currentObject->attach($this);

        //    Return requested entry
        return $this->currentObject;
    }

    /**
     * Get a list of all cell addresses currently held in cache
     *
     * @return  string[]
     */
    public function getCellList()
    {
        if ($this->currentObjectID !== null) {
            $this->storeData();
        }

        return parent::getCellList();
    }

    /**
     * Delete a cell in cache identified by coordinate address
     *
     * @param   string            $pCoord        Coordinate address of the cell to delete
     * @throws  \PHPExcel\Exception
     */
    public function deleteCacheData($pCoord)
    {
        //    Delete the entry from Wincache
        wincache_ucache_delete($this->cachePrefix.$pCoord.'.cache');

        //    Delete the entry from our cell address array
        parent::deleteCacheData($pCoord);
    }

    /**
     * Clone the cell collection
     *
     * @param  \PHPExcel\Worksheet    $parent        The new worksheet that we're copying to
     * @throws  \PHPExcel\Exception
     */
    public function copyCellCollection(\PHPExcel\Worksheet $parent)
    {
        parent::copyCellCollection($parent);
        //    Get a new id for the new file name
        $baseUnique = $this->getUniqueID();
        $newCachePrefix = substr(md5($baseUnique), 0, 8) . '.';
        $cacheList = $this->getCellList();
        foreach ($cacheList as $cellID) {
            if ($cellID != $this->currentObjectID) {
                $success = false;
                $obj = wincache_ucache_get($this->cachePrefix.$cellID.'.cache', $success);
                if ($success === false) {
                    //    Entry no longer exists in WinCache, so clear it from the cache array
                    parent::deleteCacheData($cellID);
                    throw new \PHPExcel\Exception('Cell entry '.$cellID.' no longer exists in Wincache');
                }
                if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->cacheTime)) {
                    $this->__destruct();
                    throw new \PHPExcel\Exception('Failed to store cell '.$cellID.' in Wincache');
                }
            }
        }
        $this->cachePrefix = $newCachePrefix;
    }

    /**
     * Clear the cell collection and disconnect from our parent
     *
     * @return    void
     */
    public function unsetWorksheetCells()
    {
        if (!is_null($this->currentObject)) {
            $this->currentObject->detach();
            $this->currentObject = $this->currentObjectID = null;
        }

        //    Flush the WinCache cache
        $this->__destruct();

        $this->cellCache = array();

        //    detach ourself from the worksheet, so that it can then delete this object successfully
        $this->parent = null;
    }

    /**
     * Initialise this new cell collection
     *
     * @param  \PHPExcel\Worksheet    $parent        The worksheet for this cell collection
     * @param  mixed[]        $arguments    Additional initialisation arguments
     */
    public function __construct(\PHPExcel\Worksheet $parent, $arguments)
    {
        $cacheTime    = (isset($arguments['cacheTime']))    ? $arguments['cacheTime']    : 600;

        if (is_null($this->cachePrefix)) {
            $baseUnique = $this->getUniqueID();
            $this->cachePrefix = substr(md5($baseUnique), 0, 8).'.';
            $this->cacheTime = $cacheTime;

            parent::__construct($parent);
        }
    }

    /**
     * Destroy this cell collection
     */
    public function __destruct()
    {
        $cacheList = $this->getCellList();
        foreach ($cacheList as $cellID) {
            wincache_ucache_delete($this->cachePrefix.$cellID.'.cache');
        }
    }

    /**
     * Identify whether the caching method is currently available
     * Some methods are dependent on the availability of certain extensions being enabled in the PHP build
     *
     * @return    boolean
     */
    public static function cacheMethodIsAvailable()
    {
        if (!function_exists('wincache_ucache_add')) {
            return false;
        }

        return true;
    }
}


text:
CrackingCodes
=============
You'll be seeing a lot of `Al Sweigart <https://twitter.com/AlSweigart>`_'s books because he provides them for free
online at `his website <http://inventwithpython.com/>`_. Please consider donating to show your support.

`Cracking Codes with Python <http://inventwithpython.com/cracking/>`_ is his latest release and largely covers how to
use and compromise various ciphers with Python.

Granted, most of the ciphers are old enough to be broken with a Raspberry Pi, but the general idea is how they are
implemented and what about them are easy to break.

For detailed answers to Practice Questions, check the `No Starch Press Website <https://nostarch.com/crackingcodes>`_.


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

namespace OpenCommon.DS
{

    public class UseNVLine
    {
        /// <summary>
        /// 用车检索	8227	用/p 车/n 检索/vn
        /// </summary>
        public string OriginParagraph;
        public int Count;
        public string CutParaGraph;

        public string[] CutParagraphDetail;

        public static char[] split = new char[] { ' ' };
        public UseNVLine()
        {

        }

        public UseNVLine(string v, int count)
        {
            this.OriginParagraph = v;
            this.Count = count;
        }
        public UseNVLine(string v, int count, string cutParagraph)
        {
            this.OriginParagraph = v;
            this.Count = count;
            this.CutParaGraph = cutParagraph;
            this.CutParagraphDetail = this.CutParaGraph.Split(split, StringSplitOptions.RemoveEmptyEntries);
        }
    }
}


text:
define(['lodash', "pipeline_configs/models/jobs", "string-plus"], function (_, Jobs, s) {
  var jobs, job;
  beforeEach(function () {
    jobs = new Jobs();
    job  = jobs.createJob({
      name:                 "UnitTest",
      runInstanceCount:     10,
      timeout:              10,
      environmentVariables: ["foo=bar", "boo=baz"],
      resources:            ['java', 'firefox'],
      tasks:                ['ant', 'mvn'],
      artifacts:            ['pkgs', 'logs'],
      tabs:                 ['twist', 'junit']
    });
  });

  describe("Job Model", function () {
    it("should initialize job model with name", function () {
      expect(job.name()).toBe("UnitTest");
    });

    it("should initialize job model with runInstanceCount", function () {
      expect(job.runInstanceCount()).toBe(10);
    });

    it("should initialize job model with timeout", function () {
      expect(job.timeout()).toBe(10);
    });

    it("should initialize job model with environmentVariables", function () {
      expect(job.environmentVariables()).toEqual(['foo=bar', 'boo=baz']);
    });

    it("should initialize job model with resources", function () {
      expect(job.resources()).toEqual(['java', 'firefox']);
    });

    it("should initialize job model with tasks", function () {
      expect(job.tasks()).toEqual(['ant', 'mvn']);
    });

    it("should initialize job model with artifacts", function () {
      expect(job.artifacts()).toEqual(['pkgs', 'logs']);
    });

    it("should initialize job model with tabs", function () {
      expect(job.tabs()).toEqual(['twist', 'junit']);
    });

    describe("validations", function () {
      it("should not allow blank job names", function () {
        var errors = job.validate();
        expect(errors._isEmpty()).toBe(true);

        job.name("");
        var duplicateJob = jobs.createJob({name: job.name()});

        errors                = job.validate();
        var errorsOnDuplicate = duplicateJob.validate();

        expect(errors.errors('name')).toEqual(['Name must be present']);
        expect(errorsOnDuplicate.errors('name')).toEqual(['Name must be present']);
      });

      it("should not allow jobs with duplicate names", function () {
        var errorsOnOriginal = job.validate();
        expect(errorsOnOriginal._isEmpty()).toBe(true);

        var duplicateVariable = jobs.createJob({
          name: "UnitTest"
        });

        var errorsOnOriginal = job.validate();
        expect(errorsOnOriginal.errors('name')).toEqual(['Name is a duplicate']);

        var errorsOnDuplicate = duplicateVariable.validate();
        expect(errorsOnDuplicate.errors('name')).toEqual(['Name is a duplicate']);
      });

    });

    describe("Serialization from/to JSON", function () {
      beforeEach(function () {
        job = Jobs.Job.fromJSON(sampleJobJSON());
      });

      it("should de-serialize from JSON", function () {
        expect(job.name()).toBe("UnitTest");
        expect(job.runInstanceCount()).toBe(10);
        expect(job.timeout()).toBe(20);
        expect(job.resources()).toEqual(['jdk5', 'tomcat']);

        var expectedEnvironmentVarNames = job.environmentVariables().collectVariableProperty('name');
        var expectedTasks               = job.tasks().collectTaskProperty('type');
        var expectedArtifacts           = job.artifacts().collectArtifactProperty('source');
        var expectedTabs                = job.tabs().collectTabProperty('name');
        var expectedProperties          = job.properties().collectPropertyProperty('name');

        expect(expectedEnvironmentVarNames).toEqual(['MULTIPLE_LINES', 'COMPLEX']);
        expect(expectedTasks).toEqual(['ant']);
        expect(expectedArtifacts).toEqual(['target/dist.jar']);
        expect(expectedTabs).toEqual(['coverage']);
        expect(expectedProperties).toEqual(['coverage.class']);
      });

      it("should serialize to JSON", function () {
        expect(JSON.parse(JSON.stringify(job, s.snakeCaser))).toEqual(sampleJobJSON());
      });

      it("should serialize a comma separated resource string to array", function () {
        job.resources('foo,bar,baz');
        expect(JSON.parse(JSON.stringify(job, s.snakeCaser))['resources']).toEqual(['foo', 'bar', 'baz']);
      });

      it("should validate timeout", function () {
        job.timeout('never');
        expect(job.validate().errors()).toBe(undefined);

        job.timeout(null);
        expect(job.validate().errors()).toBe(undefined);

        job.timeout(undefined);
        expect(job.validate().errors()).toBe(undefined);

        job.timeout('10');
        expect(job.validate().errors()).toBe(undefined);

        job.timeout(10);
        expect(job.validate().errors()).toBe(undefined);

        job.timeout('');
        expect(job.validate().errors('timeout')).toEqual(['Timeout must be a positive integer']);

        job.timeout('snafu');
        expect(job.validate().errors('timeout')).toEqual(['Timeout must be a positive integer']);

        job.timeout('123.xy');
        expect(job.validate().errors('timeout')).toEqual(['Timeout must be a positive integer']);

        job.timeout('xy.123');
        expect(job.validate().errors('timeout')).toEqual(['Timeout must be a positive integer']);

        job.timeout('-123');
        expect(job.validate().errors('timeout')).toEqual(['Timeout must be a positive integer']);
      });

      it("should validate runInstanceCount", function () {
        job.runInstanceCount('all');
        expect(job.validate().errors()).toBe(undefined);

        job.runInstanceCount(null);
        expect(job.validate().errors()).toBe(undefined);

        job.runInstanceCount(undefined);
        expect(job.validate().errors()).toBe(undefined);

        job.runInstanceCount('10');
        expect(job.validate().errors()).toBe(undefined);

        job.runInstanceCount(10);
        expect(job.validate().errors()).toBe(undefined);

        job.runInstanceCount('');
        expect(job.validate().errors('runInstanceCount')).toEqual(['Run instance count must be a positive integer']);

        job.runInstanceCount('snafu');
        expect(job.validate().errors('runInstanceCount')).toEqual(['Run instance count must be a positive integer']);

        job.runInstanceCount('-123');
        expect(job.validate().errors('runInstanceCount')).toEqual(['Run instance count must be a positive integer']);

        job.runInstanceCount('123.xy');
        expect(job.validate().errors('runInstanceCount')).toEqual(['Run instance count must be a positive integer']);

        job.runInstanceCount('xy.123');
        expect(job.validate().errors('runInstanceCount')).toEqual(['Run instance count must be a positive integer']);
      });

      function sampleJobJSON() {
        return {
          name:                  "UnitTest",
          run_instance_count:    10,
          timeout:               20,
          resources:             ["jdk5", "tomcat"],
          environment_variables: [
            {
              name:   "MULTIPLE_LINES",
              value:  "multiplelines",
              secure: true
            },
            {
              name:   "COMPLEX",
              value:  "This has very <complex> data",
              secure: false
            }
          ],
          tasks:                 [
            {
              type:       "ant",
              attributes: {
                target:            "clean",
                working_directory: "dir",
                build_file:        ""
              }
            }
          ],
          artifacts:             [
            {
              type:        "build",
              source:      "target/dist.jar",
              destination: "pkg"
            }
          ],
          tabs:                  [
            {
              name: "coverage",
              path: "Jcoverage/index.html"
            }
          ],
          properties:            [
            {
              name:   "coverage.class",
              source: "target/emma/coverage.xml",
              xpath:  "substring-before(//report/data/all/coverage[starts-with(@type,'class')]/@value, '%')"
            }
          ]
        };
      }
    });
  });

});


text:
import os, sys
#import sqlite3
import json
from json import JSONEncoder

class ParseToDB:
	'''
	This class loads the input files into a sqlite database
	'''
	def __init__(self,list_of_files):
		'''
		This function parses the 23andMe raw data file to a sqlite database
		'''
		dbName = 'AllData.db'
		try:
			self.createDB(dbName,list_of_files)
		except sqlite3.OperationalError:
			print "Database", dbName, "already exists. Moving on..."
			return None
		for i in list_of_files:
				self.readInFilesToDB(i,dbName)

	def createDB(self,name,list_of_files):
		'''
		This function creates a database
		'''
		DB = sqlite3.connect(name)
		cursor = DB.cursor()
		for i in list_of_files:
			TableName = str(i.split('.')[0])
			cursor.execute('create table '+TableName+' (rsid TEXT, chr TEXT, pos TEXT, geno TEXT)')
		DB.close()

	def readInFilesToDB(self,infile,dbName):
		'''
		This function reads in the 23andMe raw data file into a dictionary
		'''
		f = open(infile,'r')
		DB = sqlite3.connect(dbName)
		cursor = DB.cursor()
		for i in f.readlines():
			if '#' not in i:
				line = i.strip().split('\t')
				TableName = str(infile.split('.')[0])
				cursor.execute("insert into "+TableName+" values(?,?,?,?)", (line[0],line[1:][0],line[1:][1],line[1:][2]))
		DB.commit()
		DB.close()
		f.close()

class ParseToJSON:
	'''
	This function parses input data into json format
	'''
	def __init__(self,list_of_files):
		'''
		This function reads the input data into a dictionary, converts it to json, and prints it to an outfile
		'''
		outfile = open('23andMe.json', 'w')
		self.Data = {}
		for i in list_of_files:
				self.Data[i] = self.readInFile(i)
		self.Data = self.convertToJSON(self.Data)
		outfile.write(str(self.Data))
		outfile.close()

	def readInFile(self,infile):
		'''
		This function reads in the data from a file into a dictionary
		'''
		f = open(infile, 'r')
		rsid = {}
		for i in f.readlines():
			if '#' not in i:
				line = i.strip().split('\t')
				rsid[line[0]] = line[1:]
		f.close()
		return rsid

	def convertToJSON(self,data):
		'''
		This function converts the data structure (dictionary) into a json string
		'''
		out = JSONEncoder().encode(data)
		return out

class ConvertToBED:
	'''
	This function converts a 23andMe file into a BED file (for use with bedtools)
	I've found that 23andMe data is in hg18 (NCBI36) format
	'''
	def __init__(self,file,out):
		'''
		The default function calls the actual function that does the conversion
		'''
		self.convert(file,out)

	def convert(self,infile,outfile):
		'''
		This is the function that does to 23andMe to BED conversion
		'''
		out = open(outfile+".bed", 'w')
		for i in open(infile, 'r'):
			if "#" not in i:
				line = infile.strip('\n').split('\t')
				out.write(line[0]+'\t'+str(int(line[1])-1)+'\t'+line[1]+'\t'+line[2]+'\t+\n')
		out.close()
		return "Complete"

class ParseToDict:
        '''
	This class reads in the raw data files into a dictionary
	'''
        def __init__(self,list_of_files):
		'''
                This function initializes the data contained in the class
		'''
		# The main data dictionary
                self.files = list_of_files
		self.Data = {}
		for i in list_of_files:
			self.Data[i] = self.readInFile(i)

		# A data dictionary with a list of rsids encountered in each file
		self.RSids = self.getRSids()

		# Orders files by their number of RSids
		self.FileRSidsTuple = sorted([(i,len(self.RSids[i])) for i in self.RSids], key = lambda a: -a[1])

		# File with the maximum number of RSids
		self.MaxSize = self.FileRSidsTuple[0]

		# File with the minimum number of RSids
		self.MinSize = self.FileRSidsTuple[-1]

		# Find intersection between the input datasets
		self.Intersection = self.calcIntersectionAll()

		# A data dictionary which include only the snps in the intersection list
		self.intersectionData = self.commonDict()
                # A variable that contains the files provided as input

	def readInFile(self,infile):
		'''
		This function reads in the data from a file into a dictionary
		'''
		f = open(infile, 'r')
		rsid = {}
		for i in f.readlines():
			if '#' not in i:
				line = i.strip().split('\t')
				rsid[line[0]] = line[1:]
		f.close()
		return rsid

	def getRSids(self):
		'''
		This function returns a dictionary identical to self.Data, but each file (key) returns a list of corresponding RSids
		'''
		self.Sizes = {}
		for i in self.Data:
			self.Sizes[i] = self.Data[i].keys()
		return self.Sizes

	def getIntersection(self,A,B):
		'''
		This function returns the intersection of two lists
		'''
		self.inter = set(A).intersection( set(B) )
		return self.inter

	def searchSNP(self,rsid):
		'''
		This function looks for SNPS across the input files
		'''
		list = []
		for i in self.Data:
			try:
				tuple = (i, self.Data[i][rsid][-1])
				list.append(tuple)
			except:
				tuple = (i, 'N/A')
				list.append(tuple)
		return list

	def searchChromosomes(self,chrom):
		'''
		This function outputs all of the data across all of the files for a specified chromosome
		'''
		self.biglist = []
		for i in self.intersectionData:
			for k in self.intersectionData[i]:
				if str(chrom) == str(self.intersectionData[i][k][0]) and str(min) < str(self.intersectionData[i][k][1]) and str(max) > str(self.intersectionData[i][k][1]):
					li = []
					for j in self.intersectionData:
						tup = (j,self.intersectionData[i][k])
						li.append(tup)
					self.biglist.append(li)
		return self.biglist

	def calcIntersectionAll(self):
		'''
		This function calculates the intersection between all of the input files
		'''
		self.li = set(self.Data[self.MinSize[0]].keys())
		for i in range(len(self.files)):
			self.li = (set(self.li) & set(self.Data[self.files[i]].keys()))
		return self.li

	def commonDict(self):
		'''
		This function outputs a dictionary (identical to the Data dictionary) which only contains the snps from the intersection list
		'''
		self.newDict = {}
		for i in self.Data:
			self.rsiddict = {}
			for k in self.Data[i]:
				if k in self.Intersection:
					self.rsiddict[k] = self.Data[i][k]
				else:
					pass
			self.newDict[i] = self.rsiddict
		return self.newDict

	def identity(self, dict1, dict2):
		'''
		This function compares two dictionaries and returns a dictionary which contains only the identical elements between
		'''
                return dict( (key, dict1[key]) for key in (set(dict1) & set(dict2)) if dict1[key] == dict2[key] )

	def halfIdentity(self, dict1, dict2):
		'''
		This function compares two dictionaries and returns a dictionary which contains only the half identical elements between
		'''
                return dict( (key, dict1[key]) for key in (set(dict1) & set(dict2)) if dict1[key][-1][0] == dict2[key][-1][0] or dict1[key][-1][0] == dict2[key][-1][1] or dict1[key][-1][1] == dict2[key][-1][0] or dict1[key][-1][1] == dict2[key][-1][1])

	def phylogeny(self,rsid=None,metric='identity'):
		'''
		This function generates a phylogeny from the raw data files. If rsid is lookup is requested, each raw data file in the phylogeny can be coupled with its genotype
		'''
		def level(x):
                        '''
			This function essentially removes the tuples and sub-lists contained in a list and returns a single flattened list
			'''
                        result = []
                        for n in x:
                                if hasattr(n, "__iter__") and not isinstance(n, basestring):
                                        result.extend(level(n))
                                else:
                                        result.append(n)
                        return result

		def makeTree(li):
			'''
			This function creates a visual clustering effect on the final output list for the phylogeny function
			'''
			for i in range(len(li)):
				if i == 0 or i ==1:
					tup = [li[0],li[1]]
				else:
					tup = [tup,li[i]]
			return tup

		self.threshold = {}
		self.people = [i for i in self.files]
		self.combo = {}

		# Prepare the ModDict dictionary by removing the SNPS that are not in common
		self.ModDict = self.commonDict()

		# Generate a list of combinations and scores
		for i in range(len(self.people)):
			for k in range(len(self.people)):
				if self.people[i] == self.people[k]:
					pass
				else:
					# a different metric is used if specified, otherwise identity is the default
					if metric == 'identity':
						self.common = self.identity(self.ModDict[self.people[i]],self.ModDict[self.people[k]])
					elif metric == 'halfidentity':
						self.common = self.halfIdentity(self.ModDict[self.people[i]],self.ModDict[self.people[k]])
					else:
						self.common = self.identity(self.ModDict[self.people[i]],self.ModDict[self.people[k]])
					self.combo[(self.people[i], self.people[k])] = len(self.common)
					# record the highest score to identify which two files are first clustered

                                        if len(self.common) > len(self.threshold):
						self.threshold == self.common.copy()
						self.coords = (i,k)
					else:
						pass

		# Create the phylogeny
		self.phylo = []
		self.used = []
		for i in sorted(self.combo.items(), key=lambda x: x[1], reverse=True):
			if len(self.phylo) == 0:
				self.phylo.append(i[0])
				self.used.append(i[0][0])
				self.used.append(i[0][1])
			else:
				if i[0][0] in self.used:
					pass
				else:
					self.phylo.append(i[0][0])
					self.used.append(i[0][0])

		self.flatphy = level(self.phylo)
		# Return the genotype tupled with the raw file if rsid provided
		if rsid != None:
			tree = zip(self.flatphy,[Datasets.Data[i][rsid][-1] for i in self.flatphy if isinstance(i,str)])
			return makeTree(tree)
		else:
			return makeTree(self.flatphy)

if __name__ == "__main__":

	# Program takes 23andMe raw data files as input and they are stored in a list
	files_to_process = sys.argv[1:]

	# Program takes 23andMe raw data files as input and store them in a dictionary
	Datasets = ParseToDict(sys.argv[1:])


text:
/* Author: Ioan Sucan */

#include <moveit/pick_place/pick_place.h>
#include <moveit/pick_place/reachable_valid_pose_filter.h>
#include <moveit/pick_place/approach_and_translate_stage.h>
#include <moveit/pick_place/plan_stage.h>
#include <ros/console.h>

namespace pick_place
{
PickPlan::PickPlan(const PickPlaceConstPtr& pick_place) : PickPlacePlanBase(pick_place, "pick")
{
}

namespace
{
struct OrderGraspQuality
{
  OrderGraspQuality(const std::vector<moveit_msgs::Grasp>& grasps) : grasps_(grasps)
  {
  }

  bool operator()(const std::size_t a, const std::size_t b) const
  {
    return grasps_[a].grasp_quality > grasps_[b].grasp_quality;
  }

  const std::vector<moveit_msgs::Grasp>& grasps_;
};
}

bool PickPlan::plan(const planning_scene::PlanningSceneConstPtr& planning_scene, const moveit_msgs::PickupGoal& goal)
{
  double timeout = goal.allowed_planning_time;
  ros::WallTime endtime = ros::WallTime::now() + ros::WallDuration(timeout);

  std::string planning_group = goal.group_name;
  std::string end_effector = goal.end_effector;
  if (end_effector.empty() && !planning_group.empty())
  {
    const robot_model::JointModelGroup* jmg = planning_scene->getRobotModel()->getJointModelGroup(planning_group);
    if (!jmg)
    {
      error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
      return false;
    }
    const std::vector<std::string>& eefs = jmg->getAttachedEndEffectorNames();
    if (!eefs.empty())
    {
      end_effector = eefs.front();
      if (eefs.size() > 1)
        ROS_WARN_STREAM_NAMED("manipulation", "Choice of end-effector for group '"
                                                  << planning_group << "' is ambiguous. Assuming '" << end_effector
                                                  << "'");
    }
  }
  else if (!end_effector.empty() && planning_group.empty())
  {
    const robot_model::JointModelGroup* jmg = planning_scene->getRobotModel()->getEndEffector(end_effector);
    if (!jmg)
    {
      error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
      return false;
    }
    planning_group = jmg->getEndEffectorParentGroup().first;
    if (planning_group.empty())
    {
      ROS_ERROR_STREAM_NAMED("manipulation", "No parent group to plan in was identified based on end-effector '"
                                                 << end_effector << "'. Please define a parent group in the SRDF.");
      error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
      return false;
    }
    else
      ROS_INFO_STREAM_NAMED("manipulation", "Assuming the planning group for end effector '" << end_effector << "' is '"
                                                                                << planning_group << "'");
  }
  const robot_model::JointModelGroup* eef =
      end_effector.empty() ? NULL : planning_scene->getRobotModel()->getEndEffector(end_effector);
  if (!eef)
  {
    ROS_ERROR_NAMED("manipulation", "No end-effector specified for pick action");
    error_code_.val = moveit_msgs::MoveItErrorCodes::INVALID_GROUP_NAME;
    return false;
  }
  const std::string& ik_link = eef->getEndEffectorParentGroup().second;

  ros::WallTime start_time = ros::WallTime::now();

  // construct common data for possible manipulation plans
  ManipulationPlanSharedDataPtr plan_data(new ManipulationPlanSharedData());
  ManipulationPlanSharedDataConstPtr const_plan_data = plan_data;
  plan_data->planning_group_ = planning_scene->getRobotModel()->getJointModelGroup(planning_group);
  plan_data->end_effector_group_ = eef;
  plan_data->ik_link_ = planning_scene->getRobotModel()->getLinkModel(ik_link);
  plan_data->timeout_ = endtime;
  plan_data->path_constraints_ = goal.path_constraints;
  plan_data->planner_id_ = goal.planner_id;
  plan_data->minimize_object_distance_ = goal.minimize_object_distance;
  plan_data->max_goal_sampling_attempts_ = std::max(2u, plan_data->planning_group_->getDefaultIKAttempts());
  moveit_msgs::AttachedCollisionObject& attach_object_msg = plan_data->diff_attached_object_;

  // construct the attached object message that will change the world to what it would become after a pick
  attach_object_msg.link_name = ik_link;
  attach_object_msg.object.id = goal.target_name;
  attach_object_msg.object.operation = moveit_msgs::CollisionObject::ADD;
  attach_object_msg.touch_links =
      goal.attached_object_touch_links.empty() ? eef->getLinkModelNames() : goal.attached_object_touch_links;
  collision_detection::AllowedCollisionMatrixPtr approach_grasp_acm(
      new collision_detection::AllowedCollisionMatrix(planning_scene->getAllowedCollisionMatrix()));

  // we are allowed to touch the target object
  approach_grasp_acm->setEntry(goal.target_name, attach_object_msg.touch_links, true);
  // we are allowed to touch certain other objects with the gripper
  approach_grasp_acm->setEntry(eef->getLinkModelNames(), goal.allowed_touch_objects, true);
  if (!goal.support_surface_name.empty())
  {
    // we are allowed to have contact between the target object and the support surface before the grasp
    approach_grasp_acm->setEntry(goal.support_surface_name, goal.target_name, true);

    // optionally, it may be allowed to touch the support surface with the gripper
    if (goal.allow_gripper_support_collision)
      approach_grasp_acm->setEntry(goal.support_surface_name, eef->getLinkModelNames(), true);
  }

  // configure the manipulation pipeline
  pipeline_.reset();
  ManipulationStagePtr stage1(
      new ReachableAndValidPoseFilter(planning_scene, approach_grasp_acm, pick_place_->getConstraintsSamplerManager()));
  ManipulationStagePtr stage2(new ApproachAndTranslateStage(planning_scene, approach_grasp_acm));
  ManipulationStagePtr stage3(new PlanStage(planning_scene, pick_place_->getPlanningPipeline()));
  pipeline_.addStage(stage1).addStage(stage2).addStage(stage3);

  initialize();
  pipeline_.start();

  // order the grasps by quality
  std::vector<std::size_t> grasp_order(goal.possible_grasps.size());
  for (std::size_t i = 0; i < goal.possible_grasps.size(); ++i)
    grasp_order[i] = i;
  OrderGraspQuality oq(goal.possible_grasps);
  std::sort(grasp_order.begin(), grasp_order.end(), oq);

  // feed the available grasps to the stages we set up
  for (std::size_t i = 0; i < goal.possible_grasps.size(); ++i)
  {
    ManipulationPlanPtr p(new ManipulationPlan(const_plan_data));
    const moveit_msgs::Grasp& g = goal.possible_grasps[grasp_order[i]];
    p->approach_ = g.pre_grasp_approach;
    p->retreat_ = g.post_grasp_retreat;
    p->goal_pose_ = g.grasp_pose;
    p->id_ = grasp_order[i];
    // if no frame of reference was specified, assume the transform to be in the reference frame of the object
    if (p->goal_pose_.header.frame_id.empty())
      p->goal_pose_.header.frame_id = goal.target_name;
    p->approach_posture_ = g.pre_grasp_posture;
    p->retreat_posture_ = g.grasp_posture;
    pipeline_.push(p);
  }

  // wait till we're done
  waitForPipeline(endtime);
  pipeline_.stop();

  last_plan_time_ = (ros::WallTime::now() - start_time).toSec();

  if (!getSuccessfulManipulationPlans().empty())
    error_code_.val = moveit_msgs::MoveItErrorCodes::SUCCESS;
  else
  {
    if (last_plan_time_ > timeout)
      error_code_.val = moveit_msgs::MoveItErrorCodes::TIMED_OUT;
    else
    {
      error_code_.val = moveit_msgs::MoveItErrorCodes::PLANNING_FAILED;
      if (goal.possible_grasps.size() > 0)
      {
        ROS_WARN_NAMED("manipulation", "All supplied grasps failed. Retrying last grasp in verbose mode.");
        // everything failed. we now start the pipeline again in verbose mode for one grasp
        initialize();
        pipeline_.setVerbose(true);
        pipeline_.start();
        pipeline_.reprocessLastFailure();
        waitForPipeline(ros::WallTime::now() + ros::WallDuration(1.0));
        pipeline_.stop();
        pipeline_.setVerbose(false);
      }
    }
  }
  ROS_INFO_NAMED("manipulation", "Pickup planning completed after %lf seconds", last_plan_time_);

  return error_code_.val == moveit_msgs::MoveItErrorCodes::SUCCESS;
}

PickPlanPtr PickPlace::planPick(const planning_scene::PlanningSceneConstPtr& planning_scene,
                                const moveit_msgs::PickupGoal& goal) const
{
  PickPlanPtr p(new PickPlan(shared_from_this()));

  if (planning_scene::PlanningScene::isEmpty(goal.planning_options.planning_scene_diff))
    p->plan(planning_scene, goal);
  else
    p->plan(planning_scene->diff(goal.planning_options.planning_scene_diff), goal);

  if (display_computed_motion_plans_)
  {
    const std::vector<pick_place::ManipulationPlanPtr>& success = p->getSuccessfulManipulationPlans();
    if (!success.empty())
      visualizePlan(success.back());
  }

  if (display_grasps_)
  {
    const std::vector<pick_place::ManipulationPlanPtr>& success = p->getSuccessfulManipulationPlans();
    visualizeGrasps(success);
    const std::vector<pick_place::ManipulationPlanPtr>& failed = p->getFailedManipulationPlans();
    visualizeGrasps(failed);
  }

  return p;
}
}