text:
package com.linkedin.pinot.tools.data.generator;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.math.IntRange;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.JSONException;

import com.linkedin.pinot.common.data.DimensionFieldSpec;
import com.linkedin.pinot.common.data.FieldSpec;
import com.linkedin.pinot.common.data.FieldSpec.DataType;
import com.linkedin.pinot.common.data.FieldSpec.FieldType;
import com.linkedin.pinot.common.data.MetricFieldSpec;
import com.linkedin.pinot.common.data.Schema;
import com.linkedin.pinot.common.data.TimeFieldSpec;
import com.linkedin.pinot.core.data.readers.FileFormat;

/**
 * Sep 12, 2014
 */

public class DataGenerator {
  private static final Logger LOGGER = LoggerFactory.getLogger(DataGenerator.class);
  private File outDir;

  DataGeneratorSpec genSpec;

  private final Map<String, Generator> generators;

  public DataGenerator() {
    generators = new HashMap<String, Generator>();
  }

  public void init(DataGeneratorSpec spec) throws IOException {
    genSpec = spec;
    outDir = new File(genSpec.getOutputDir());
    if (outDir.exists() && !genSpec.isOverrideOutDir()) {
      LOGGER.error("output directory already exists, and override is set to false");
      throw new RuntimeException("output directory exists");
    }

    if (outDir.exists()) {
      FileUtils.deleteDirectory(outDir);
    }

    outDir.mkdir();

    for (final String column : genSpec.getColumns()) {
      DataType dataType = genSpec.getDataTypesMap().get(column);

      if (genSpec.getCardinalityMap().containsKey(column)) {
        generators.put(column,
            GeneratorFactory.getGeneratorFor(dataType, genSpec.getCardinalityMap().get(column)));

      } else if (genSpec.getRangeMap().containsKey(column)) {
        IntRange range = genSpec.getRangeMap().get(column);

        generators.put(column,
            GeneratorFactory.getGeneratorFor(dataType, range.getMinimumInteger(), range.getMaximumInteger()));
      } else {
        LOGGER.error("cardinality for this column does not exist : " + column);
        throw new RuntimeException("cardinality for this column does not exist");
      }

      generators.get(column).init();
    }
  }

  public void generate(long totalDocs, int numFiles) throws IOException, JSONException {
    final int numPerFiles = (int) (totalDocs / numFiles);
    for (int i = 0; i < numFiles; i++) {
      final AvroWriter writer = new AvroWriter(outDir, i, generators, fetchSchema());

      for (int j = 0; j < numPerFiles; j++) {
        writer.writeNext();
      }
      writer.seal();
    }
  }

  public Schema fetchSchema() {
    final Schema schema = new Schema();
    for (final String column : genSpec.getColumns()) {
      final FieldSpec spec = buildSpec(genSpec, column);
      schema.addField(spec);
    }
    return schema;
  }

  private FieldSpec buildSpec(DataGeneratorSpec genSpec, String column) {
    DataType dataType = genSpec.getDataTypesMap().get(column);
    FieldType fieldType = genSpec.getFieldTypesMap().get(column);

    FieldSpec spec;
    switch (fieldType) {
      case DIMENSION:
        spec = new DimensionFieldSpec();
        break;

      case METRIC:
        spec = new MetricFieldSpec();
        break;

      case TIME:
        spec = new TimeFieldSpec(column, dataType, genSpec.getTimeUnitMap().get(column));
        break;

        default:
          throw new RuntimeException("Invalid Field type.");
    }

    spec.setName(column);
    spec.setDataType(dataType);
    spec.setSingleValueField(true);

    return spec;
  }

  public static void main(String[] args) throws IOException, JSONException {
    final String[] columns = { "column1", "column2", "column3", "column4", "column5" };
    final Map<String, DataType> dataTypes = new HashMap<String, DataType>();
    final Map<String, FieldType> fieldTypes = new HashMap<String, FieldType>();
    final Map<String, TimeUnit> timeUnits = new HashMap<String, TimeUnit>();

    final Map<String, Integer> cardinality = new HashMap<String, Integer>();
    final Map<String, IntRange> range = new HashMap<String, IntRange>();

    for (final String col : columns) {
      dataTypes.put(col, DataType.INT);
      fieldTypes.put(col, FieldType.DIMENSION);
      cardinality.put(col, 1000);
    }
    final DataGeneratorSpec spec = new DataGeneratorSpec(Arrays.asList(columns), cardinality,
        range, dataTypes, fieldTypes, timeUnits, FileFormat.AVRO, "/tmp/out", true);

    final DataGenerator gen = new DataGenerator();
    gen.init(spec);
    gen.generate(1000000L, 2);
  }
}


text:
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSocial extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('social', function(Blueprint $table)
		{
			$table->bigIncrements('id')->unsigned();
			$table->string('service', 25);
			$table->string('service_user_identifier', 255)->default('movie');
			$table->bigInteger('user_id')->unsigned();
			$table->timestamp('created_at')->default( DB::raw('CURRENT_TIMESTAMP') );
			$table->timestamp('updated_at')->default('0000-00-00 00:00:00');

			$table->engine = 'InnoDB';
			$table->unique(array('user_id'), 'user_id');
			$table->unique(array('service_user_identifier'), 'service_user_identifier');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('social');
	}

}

redpajama_set_name: RedPajamaGithub


text:
We present a free, user-friendly tool implementing an efficient [moment expansion approximation with parametric closures](http://scitation.aip.org/content/aip/journal/jcp/138/17/10.1063/1.4802475) that integrates well with the IPython interactive environment. Our package enables the analysis of complex stochastic systems without any constraints on the number of species and moments studied and the type of rate laws in the system. In addition to the approximation method our package provides numerous tools to help non-expert users in stochastic analysis.

## Documentation

### Tutorial
A tutorial on getting started with MEANS can be found in the [directory tutorial](tutorial/README.md) in this repository.

### API Reference

API reference can be found on [Read the Docs](https://means.readthedocs.org/en/latest/).

## Installation

### Dependancy: Sundials

Prior to installation of this package ensure [`sundials`](https://computation.llnl.gov/casc/sundials/main.html)
libraries are installed on your system.

The exact steps to install them will depend on your system and configuration.

Generally, the easiest way to install these packages is via the system's package manager.
For instance, on Mac OS X these libraries can be installed via [HomeBrew](http://brew.sh/):

    brew install sundials

If you are using ubuntu, you can use `apt-get` to install the packages:

    apt-get install libsundials-cvode1 libsundials-cvodes2 libsundials-ida2 libsundials-idas0 libsundials-kinsol1 libsundials-nvecserial0 libsundials-serial libsundials-serial-dev

Users of `anaconda` python distribution, could use the [recipe provided by `chemreac`](https://anaconda.org/chemreac/sundials) to install it:

    conda install -c https://conda.anaconda.org/chemreac sundials

At this point, make sure to note the path where the package manager installs the libraries to.
For instance, `apt-get` is likely to put the libraries to `/usr/lib` whereas anaconda is likely to put it in `/home/username/anaconda/lib`. Ensure this lib directory is in `LD_LIBRARY_PATH` variable.

    export LD_LIBRARY_PATH="/your/sundials/home/lib:$LD_LIBRARY_PATH"

Also note the directory prefix without the `lib` as you might need to specify this path as `--sundials-home`` when istalling `assimulo` (see the [troubleshooting section below](#symptom-tests-fail-with-no-module-named-sundials)).

On other linux systems one might need to compile the sundials libraries from source.
Visit [`sundials` homepage](https://computation.llnl.gov/casc/sundials/download/download.php) for
instructions on how to obtain the latest release of the library.

For the newest release of `sundials`, follow instructions in the pdf distributed with the `sundials` source.
Ensure that `-DCMAKE_C_FLAGS=-fPIC` is set when installing.

If you are installing an older version of the library, then make sure that

`--enable-shared`, `--enable-static`, `--with-gnu-ld`
and `--with-cflags=-fPIC` flags are set.

Similarly, ensure that the `--prefix` is set to `/usr/local`, or alternatively see [troubleshooting section below](#symptom-tests-fail-with-no-module-named-sundials).

### MEANS: Stable Release
Once `sundials `libraries are installed correctly, MEANS can be installed through `pip`, just like any other python package:

```
pip install means
```

Note that due to the way ``pip`` handles dependencies, you might need to install ``cython``, ``numpy`` prior to `means`:

```
    pip install cython
    pip install numpy
```

### Verifying Installation

Since a lot of things can go wrong during the installation, it is important to verify the installation before proceeding
with the package.

Particularly, please run the tests and ensure they pass.
To run the tests, install `nose` package first:

```
pip install nose
```

Then run the following command:
```
nosetests means.tests
```
If no tests failed, [proceed straight to the tutorial](tutorial/README.md).
Otherwise, consult the [troubleshooting section](#troubleshooting).

### MEANS: Development Version

The development version of this package can be installed by downloading the code, navigating to `src`
directory and typing
```
pip install -e .
```

You may similarly need to install `numpy` and `cython` for this command to work, as in the section above.

## Troubleshooting

### Symptom: Tests fail with `No module named sundials`

This error indicates that `assimulo` installation failed to find the sundials in the system path.
Please ensure that you set appropriate flags in `sundials` installation, as described in previous section and attempt
to reinstall assimulo as follows:

```
pip uninstall assimulo
pip install assimulo
```

If you installed the `sundials` libraries to prefix other than `/usr/local` (for instance,
ArchLinux installs the library to `/usr` by default), install assimulo as follows:

```
pip install assimulo --install-option="--sundials-home=/your/sundials/installation/prefix"
```
Replacing the `/your/sundials/installation/prefix` with the appropriate prefix.

Once this is done try running tests again.

### Symptom: Tests fail with `ImportError: /usr/lib/libsundials_idas.so.0: undefined symbol: dscal_`

The symptom above indicates incorrect linkage between `libsundials_idas.so` and BLAS/LAPACK libraries.
A workaround for this issue is to add `libblas.so liblapack.so` to `LD_PRELOAD` environment variable.
To do this, make sure to set this environment variable first:

```
export LD_PRELOAD='libblas.so liblapack.so'
```

And then run everything else as usual.


text:
/* ================================================================================================
   JTQuad

   Author: Jerry Tostao
   ================================================================================================ */

#ifndef __HEADINGHOLDPROCESSOR_H__
#define __HEADINGHOLDPROCESSOR_H__

/* ================================================================================================
   Includes
   ================================================================================================ */

	#include "common.h"

/* ================================================================================================
   Function prototypes
   ================================================================================================ */

	// Enable C linkage for C++ Compilers
	#if defined(__cplusplus)
	extern "C" {
	#endif

	// Public functions
	void process_heading(void);

	// Private functions

	// Disable C linkage for C++ Compilers
	#if defined(__cplusplus)
	}
	#endif

#endif


text:
namespace net {

WebSocketThrottle::WebSocketThrottle() {
}

WebSocketThrottle::~WebSocketThrottle() {
  DCHECK(queue_.empty());
  DCHECK(addr_map_.empty());
}

// static
WebSocketThrottle* WebSocketThrottle::GetInstance() {
  return Singleton<WebSocketThrottle>::get();
}

void WebSocketThrottle::PutInQueue(WebSocketJob* job) {
  queue_.push_back(job);
  const AddressList& address_list = job->address_list();
  std::set<IPEndPoint> address_set;
  for (AddressList::const_iterator addr_iter = address_list.begin();
       addr_iter != address_list.end();
       ++addr_iter) {
    const IPEndPoint& address = *addr_iter;
    // If |address| is already processed, don't do it again.
    if (!address_set.insert(address).second)
      continue;

    ConnectingAddressMap::iterator iter = addr_map_.find(address);
    if (iter == addr_map_.end()) {
      ConnectingQueue* queue = new ConnectingQueue();
      queue->push_back(job);
      addr_map_[address] = queue;
    } else {
      iter->second->push_back(job);
      job->SetWaiting();
      DVLOG(1) << "Waiting on " << address.ToString();
    }
  }
}

void WebSocketThrottle::RemoveFromQueue(WebSocketJob* job) {
  ConnectingQueue::iterator queue_iter =
      std::find(queue_.begin(), queue_.end(), job);
  if (queue_iter == queue_.end())
    return;
  queue_.erase(queue_iter);
  const AddressList& address_list = job->address_list();
  std::set<IPEndPoint> address_set;
  for (AddressList::const_iterator addr_iter = address_list.begin();
       addr_iter != address_list.end();
       ++addr_iter) {
    const IPEndPoint& address = *addr_iter;
    // If |address| is already processed, don't do it again.
    if (!address_set.insert(address).second)
      continue;

    ConnectingAddressMap::iterator map_iter = addr_map_.find(address);
    DCHECK(map_iter != addr_map_.end());

    ConnectingQueue* queue = map_iter->second;
    // Job may not be front of queue if the socket is closed while waiting.
    ConnectingQueue::iterator address_queue_iter =
        std::find(queue->begin(), queue->end(), job);
    if (address_queue_iter != queue->end())
      queue->erase(address_queue_iter);
    if (queue->empty()) {
      delete queue;
      addr_map_.erase(map_iter);
    }
  }
}

void WebSocketThrottle::WakeupSocketIfNecessary() {
  for (ConnectingQueue::iterator iter = queue_.begin();
       iter != queue_.end();
       ++iter) {
    WebSocketJob* job = *iter;
    if (!job->IsWaiting())
      continue;

    bool should_wakeup = true;
    const AddressList& address_list = job->address_list();
    for (AddressList::const_iterator addr_iter = address_list.begin();
         addr_iter != address_list.end();
         ++addr_iter) {
      const IPEndPoint& address = *addr_iter;
      ConnectingAddressMap::iterator map_iter = addr_map_.find(address);
      DCHECK(map_iter != addr_map_.end());
      ConnectingQueue* queue = map_iter->second;
      if (job != queue->front()) {
        should_wakeup = false;
        break;
      }
    }
    if (should_wakeup)
      job->Wakeup();
  }
}

}  // namespace net