text:
package com.amazonaws.metrics.internal.cloudwatch;

import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.DaemonThreadCount;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.DeadLockThreadCount;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.FreeMemory;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.OpenFileDescriptorCount;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.PeakThreadCount;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.SpareFileDescriptorCount;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.SpareMemory;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.ThreadCount;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.TotalMemory;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.TotalStartedThreadCount;
import static com.amazonaws.metrics.internal.cloudwatch.MachineMetric.UsedMemory;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.logging.LogFactory;

import com.amazonaws.jmx.spi.JmxInfoProvider;
import com.amazonaws.metrics.AwsSdkMetrics;
import com.amazonaws.metrics.MetricType;
import com.amazonaws.services.cloudwatch.model.Dimension;
import com.amazonaws.services.cloudwatch.model.MetricDatum;
import com.amazonaws.services.cloudwatch.model.StandardUnit;

class MachineMetricFactory {
    private static final List<MachineMetric> memoryMetrics = Arrays.asList(
            TotalMemory, FreeMemory, UsedMemory, SpareMemory);
    private static final List<MachineMetric> threadMetrics = Arrays.asList(
            ThreadCount, DeadLockThreadCount, DaemonThreadCount,
            PeakThreadCount, TotalStartedThreadCount);
    private static final List<MachineMetric> fdMetrics = Arrays.asList(
            OpenFileDescriptorCount, SpareFileDescriptorCount);
    private final JmxInfoProvider jmxInfoProvider = JmxInfoProvider.Factory.getJmxInfoProvider();

    /**
     * Add the given list of metrics and corresponding values specified in
     * "metricValues" to the given list of metric datum.
     *
     * @param list
     *            list of metric data
     * @param metricValues
     *            list of metrics and their corresponding values
     */
    private void addMetrics(List<MetricDatum> list,
            MetricValues metricValues,
            StandardUnit unit) {
        List<MachineMetric> machineMetrics = metricValues.getMetrics();
        List<Long> values = metricValues.getValues();
        for (int i=0; i < machineMetrics.size(); i++) {
            MachineMetric metric = machineMetrics.get(i);
            long val = values.get(i).longValue();
            // skip zero values in some cases
            if (val != 0 || metric.includeZeroValue()) {
                MetricDatum datum = new MetricDatum()
                    .withMetricName(metric.getMetricName())
                    .withDimensions(
                        new Dimension()
                        .withName(metric.getDimensionName())
                        .withValue(metric.name()))
                    .withUnit(unit)
                    .withValue((double) val)
                    ;
                list.add(datum);
            }
        }
    }

    /**
     * Returns the set of custom machine metrics specified in the SDK metrics
     * registry; or an empty set if there is none. Note any machine metrics
     * found in the registry must have been custom specified, as the default
     * behavior is to include all machine metrics when enabled.
     *
     * @return a non-null set of machine metrics. An empty set means no custom
     *         machine metrics have been specified.
     */
    private Set<MachineMetric> customMachineMetrics() {
        Set<MachineMetric> customized = new HashSet<MachineMetric>();
        for (MetricType m: AwsSdkMetrics.getPredefinedMetrics()) {
            if (m instanceof MachineMetric)
                customized.add((MachineMetric)m);
        }
        return customized;
    }

    /**
     * Returns a subset of the given list of metrics in "defaults" and the
     * corresponding value of each returned metric in the subset. Note if the
     * custom set is empty, the full set of default machine metrics and values
     * will be returned. (In particular, as in set theory, a set is a subset of
     * itself.)
     *
     * @param customSet
     *            custom machine metrics specified in the SDK metrics registry
     * @param defaults
     *            the given default list of metrics
     * @param values
     *            corresponding values of each metric in "defaults"
     */
    private MetricValues metricValues(Set<MachineMetric> customSet,
            List<MachineMetric> defaults, List<Long> values) {
        List<MachineMetric> actualMetrics = defaults;
        List<Long> actualValues = values;
        if (customSet.size() > 0) {
            // custom set of machine metrics specified
            actualMetrics = new ArrayList<MachineMetric>();
            actualValues = new ArrayList<Long>();
            for (int i=0; i < defaults.size(); i++) {
                MachineMetric mm = defaults.get(i);
                if (customSet.contains(mm)) {
                    actualMetrics.add(mm);
                    actualValues.add(values.get(i));
                }
            }
        }
        return new MetricValues(actualMetrics, actualValues);
    }

    List<MetricDatum> generateMetrics() {
        if (AwsSdkMetrics.isMachineMetricExcluded())
            return Collections.emptyList();
        Set<MachineMetric> customSet = customMachineMetrics();
        List<MetricDatum> targetList = new ArrayList<MetricDatum>(
                MachineMetric.values().length);
        // Memory usage
        addMemoryMetrics(targetList, customSet);
        // Thread related counts
        try {
            addThreadMetrics(targetList, customSet);
        } catch (Throwable t) {
            LogFactory.getLog(getClass()).debug("Ignoring thread metrics", t);
        }
        // File descriptor usage
        try {
            addFileDescriptorMetrics(targetList, customSet);
        } catch (Throwable t) {
            LogFactory.getLog(getClass()).debug("Ignoring file descriptor metrics", t);
        }
        return targetList;
    }

    private void addMemoryMetrics(List<MetricDatum> targetList,
            Set<MachineMetric> customSet) {
        Runtime rt = Runtime.getRuntime();
        long totalMem = rt.totalMemory();
        long freeMem = rt.freeMemory();
        long usedMem = totalMem - freeMem;
        long spareMem = rt.maxMemory() - usedMem;
        List<Long> values = Arrays.asList(totalMem, freeMem, usedMem, spareMem);
        MetricValues metricValues = memoryMetricValues(customSet, values);
        addMetrics(targetList, metricValues, StandardUnit.Bytes);
    }

    private void addFileDescriptorMetrics(List<MetricDatum> targetList,
            Set<MachineMetric> customSet) {
        JmxInfoProvider provider = JmxInfoProvider.Factory.getJmxInfoProvider();
        long[] fdInfo = provider.getFileDecriptorInfo();

        if (fdInfo != null) {
            long openFdCount = fdInfo[0];
            long maxFdCount = fdInfo[1];
            List<Long> values = Arrays.asList(openFdCount, maxFdCount - openFdCount);
            MetricValues metricValues = fdMetricValues(customSet, values);
            addMetrics(targetList, metricValues, StandardUnit.Count);
        }
    }

    private void addThreadMetrics(List<MetricDatum> targetList,
            Set<MachineMetric> customSet) {
        long threadCount = jmxInfoProvider.getThreadCount();
        long[] ids = jmxInfoProvider.findDeadlockedThreads();
        long deadLockThreadCount = ids == null ? 0 : ids.length;
        long daemonThreadCount = jmxInfoProvider.getDaemonThreadCount();
        long peakThreadCount = jmxInfoProvider.getPeakThreadCount();
        long totalStartedThreadCount = jmxInfoProvider.getTotalStartedThreadCount();
        List<Long> values = Arrays.asList(threadCount,
            deadLockThreadCount,
            daemonThreadCount,
            peakThreadCount,
            totalStartedThreadCount);
        MetricValues metricValues = threadMetricValues(customSet, values);
        addMetrics(targetList, metricValues, StandardUnit.Count);
    }

    /**
     * Returns the set of memory metrics and the corresponding values based on
     * the default and the customized set of metrics, if any.
     *
     * @param customSet
     *            a non-null customized set of metrics
     * @param values
     *            a non-null list of values corresponding to the list of default
     *            memory metrics
     */
    private MetricValues memoryMetricValues(Set<MachineMetric> customSet,
            List<Long> values) {
        return metricValues(customSet, MachineMetricFactory.memoryMetrics,
                values);
    }

    /**
     * Returns the set of file-descriptor metrics and the corresponding values based on
     * the default and the customized set of metrics, if any.
     *
     * @param customSet
     *            a non-null customized set of metrics
     * @param values
     *            a non-null list of values corresponding to the list of default
     *            file-descriptor metrics
     */
    private MetricValues fdMetricValues(Set<MachineMetric> customSet,
            List<Long> values) {
        return metricValues(customSet, MachineMetricFactory.fdMetrics, values);
    }

    /**
     * Returns the set of thread metrics and the corresponding values based on
     * the default and the customized set of metrics, if any.
     *
     * @param customSet
     *            a non-null customized set of metrics
     * @param values
     *            a non-null list of values corresponding to the list of default
     *            thread metrics
     */
    private MetricValues threadMetricValues(Set<MachineMetric> customSet,
            List<Long> values) {
        return metricValues(customSet, MachineMetricFactory.threadMetrics,
                values);
    }

    // Used to get around the limitation of Java returning at most a single value
    private static class MetricValues {
        private final List<MachineMetric> metrics;
        private final List<Long> values;
        MetricValues(List<MachineMetric> metrics, List<Long> values) {
            this.metrics = metrics;
            this.values = values;
        }
        List<MachineMetric> getMetrics() { return metrics; }
        List<Long> getValues() { return values; }
    }
}


text:
import glob
import os.path
import re
import sys

# delays are advances from the last one instead of delays since the first?
inverted_delays = True
# fps maps the delay times to frame numbers
fps = 25
# one delay value in seconds per line, in increasing order
syncfile = "sync.txt"
# matching order as in syncfile
camnames = ["A", "B", "C", "D", "E", "F", "G", "H", "I"]

def files(camname):
    return sorted(glob.glob(camname + "/out_*.jpg"))

fileframere = re.compile("out_(\d+).jpg")

def fileframe(path):
    base = os.path.basename(path)
    match = fileframere.match(base)
    return int(match.group(1))

def mkdirf(path):
    try:
        os.mkdir(path)
    except OSError:
        # maybe exists already
        pass

def symlinkforce(src, dest):
    try:
        os.symlink(src, dest)
    except OSError:
        os.remove(dest)
        os.symlink(src, dest)

def writelinks(outdir, camframes):
    back = "../../../"
    for name, frames in zip(camnames, camframes):
        i = 0
        for frame in frames:
            symlinkforce(back + frame, "%s/by-cam/%s/out_%05d.jpg" % (outdir, name, i))
            mkdirf("%s/by-frame/%05d" % (outdir, i))
            symlinkforce(back + frame, "%s/by-frame/%05d/%s.jpg" % (outdir, i, name))
            i += 1

def main():
    offsets = map(float, open(syncfile).readlines())

    # delays must be increasing
    if inverted_delays:
        offsets = [offsets[0] - x for x in offsets]

    frame_offsets = [int(round(x * fps)) for x in offsets]
    # must start only when the slowest one has started
    first_frame = frame_offsets[-1]
    camframes = [fs[first_frame + offset:]
            for fs, offset
            in zip(map(files, camnames), frame_offsets)]

    outdir = sys.argv[1]
    mkdirf(outdir)
    mkdirf(outdir + "/by-cam")
    mkdirf(outdir + "/by-frame")

    for cam in camnames:
        mkdirf(outdir + "/by-cam/" + cam)

    writelinks(outdir, camframes)

if __name__ == "__main__":
    main()

redpajama_set_name: RedPajamaGithub


text:
Apollo Universal Starter Kit comes with a root `package.json` file that contains commands you can run for all the
packages – web, server, and mobile.

You can run the scripts from the root of your Apollo Universal Starter Kit project:

```bash
# project root, typically apollo-universal-starter-kit
yarn build
```

Alternatively, you can run all the scripts using NPM:

```bash
npm run build
```

## Global Scripts in `root/package.json`

**NOTE**: Most scripts in `apollo-universal-starter-kit/package.json` run with [Lerna], a tool that enables us to
simultaneously run the same scripts for all the packages – client, server, and mobile.

### `yarn build`

Compiles the production application to the `packages/server/build`, `packages/client/build`, and `packages/mobile/build`
directories for the server, client, and mobile applications respectively.

### `yarn clean`

Removes the compiled production application files from the `packages/server/build`, `packages/client/build`, and
`packages/mobile/build` folders.

### `yarn start`

Runs the Apollo Universal Starter Kit application in production mode. The application will be open in your default
browser. The application code is minified and optimized to ensure the best performance.

### `yarn watch`

Runs the app in development mode and watches the changes made to the code with the help of hot code reload.

The `yarn watch` command has a few specific implementations.

#### `yarn watch-client`

Runs the client-side React application in development mode and watches the changes using hot code reload.

This command is especially useful if you're developing a Scala back-end application or your custom back-end app and you
don't need the Express application to run. Also note that the server-side rendering is _turned off_ if you run
`yarn watch-client`.

#### `yarn watch:angular`

Runs only the Angular frontend application in development mode.

#### `yarn watch:vue`

Runs only the Vue frontend application in development mode.

#### `yarn watch:android`

Runs only the Android app in development mode.

#### `yarn watch:ios`

Runs only the iOS app in development mode.

### `yarn android`

Runs the Expo Android project _and_ the Express back-end application in development mode. The command disables
building the project for the web (the React application) and iOS platforms.

### `yarn ios`

Runs the Expo iOS project _and_ the Express back-end application in development mode. The command disables building the
project for the web (the React application) and Android platforms.

### `yarn cli`

Runs the Apollo Universal Starter Kit built-in command line interface (CLI). The CLI is currently used for scaffolding
and deleting Apollo Starter Kit modules. Consult the [CLI guide] for more information about `yarn cli`.

### `yarn stripe:setup`

Generates the Stripe plan for the payment module in Apollo Starter Kit. The default Stripe configuration used for
generation of the plan is located in `config/stripe/subscription.js`.

### `yarn seed`

Seeds the sample data to the SQLite database. You can use the `yarn seed --prod` command for production mode.

### `yarn migrate`

Migrates the sample database. The command updates the database according to the latest migrations.

### `yarn rollback`

Rolls back the sample database to the previous state. The command simply cancels the last migration created with
`yarn migrate`.

### `yarn jest`

Runs the tests for the mobile app using Jest, a Facebook utility for running unit tests for React Native apps. You can
view a demo unit test for mobile in the `packages/mobile/src/__tests__` directory.

### `yarn test`

Runs the unit tests with Mocha and the static code checking with TSLint and ESLint.

### `yarn tests`

Runs the unit tests with Mocha and waits until all the tests are executed. The test results will be shown in the
console.

### `yarn tests:watch`

Runs the unit tests with Mocha, waits until they're executed, and automatically watches the changes to the tests or
application code. Once the changes are made, the tests will re-run (one or more tests will be executed again depending
on how many changes you've made).

### `yarn lint`

Runs the [ESLint] to perform checks for errors in `.js`, `.jsx`, `.ts`, and `.tsx` files.

### `yarn heroku-postbuild`

Runs various commands specific for Heroku for Apollo Starter Kit client, server, and mobile packages.
Once you publish your application on Heroku, this command will run `yarn build` for the client, server, and mobile
packages. For example, after you build the project for Heroku, this command will publish the mobile app: It'll run
`exp publish`, then log in to Expo, compile the mobile builds and publish them on Expo.

### `yarn precommit`

Runs additional checks before the code is committed to Git.

`yarn precommit` is a utility command that runs each time you commit your changes to Git. You don't need to run this
command separately, although doing so won't create any issues.

`yarn precommit` runs the [lint-staged] utility to find any changes in `.js`, `.jsx`, and `.json` files and fix errors
if any. If changes were made in TypeScript files, then TSLint will run to check the code updates. If linting issues in
the files are fixed, the file is committed to Git. During the checks, the code is also forcibly formatted.

When formatting the code isn't possible, however, the changes won't be committed, and the issues (the files and the
lines where issues were found) will be shown in the console.

[lerna]: https://lernajs.io/
[cli guide]: /docs/tools/CLI.md
[`expo`]: https://docs.expo.io/versions/latest/workflow/expo-cli
[webpack]: https://webpack.js.org/
[haul cli]: https://github.com/callstack/haul
[metro bundler]: https://facebook.github.io/metro/
[expo cli documentation]: https://docs.expo.io/versions/latest/workflow/expo-cli
[esLint]: https://eslint.org/
[lint-staged]: https://www.npmjs.com/package/lint-staged


text:
require 'faker'

kelly = User.create(username: "Kelly Malone", email: "kelly@gmail.com", password: Faker::Internet.password)
ziggy = User.create(username: "Ziggy Marley", email: "jahrastafari@themosthigh.com", password: Faker::Internet.password)
selasie = User.create(username: "Haile Selasie", email: "hisimperialmajesty@gmail.com", password: Faker::Internet.password)
lil_jon = User.create(username: "Lil' Jon", email: "liljon@gmail.com", password: Faker::Internet.password)

##cities(name, state)
# golden = City.new(name: "Golden", state: "Colorado")
# steamboat = City.new(name: "Steamboat Springs", state: "Colorado")
# buena_vista = City.new(name: "Buena Vista", state: "Colorado")
# denver = City.new(name: "Denver", state: "Colorado")
# boulder = City.new(name: "Boulder", state: "Colorado")
# aurora = City.new(name: "Aurora", state: "Colorado")
# manitou_springs = City.new(name: "Manitou Springs", state: "Colorado")
# erie = City.new(name: "Erie", state: "Colorado")
# lakewood = City.new(name: "Lakewood", state: "Colorado")

##golden
terrapin = Dispensary.create(name: "Terrapin Care Clinic", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
terrapin_location = Location.create(address: "11091 E Mississippi Ave,Aurora,CO", dispensary_id: terrapin.id)
native_roots = Dispensary.create(name: "Native Roots", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
native_roots_location = Location.create(address: "1555 Champa St,Denver,CO", dispensary_id: native_roots.id)
fox_street_clinic = Dispensary.create(name: "Fox Street Clinic", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
fox_street_location = Location.create(address: "11975 E 40th Ave,Denver,CO", dispensary_id: fox_street_clinic.id)
# ##steamboat
# natural_remedies = Dispensary.create(name: "Natural Remedies",  phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# mindful_recreation = Dispensary.create(name: "Mindful Recreation", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# new_age_medical = Dispensary.create(name: "New Age Medical", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# ##buena_vista
# northern_lights_cannabis = Dispensary.create(name: "Northern Lights Cannabis", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# green_man_cannabis = Dispensary.create(name: "Green Man Cannabis", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# ## denver
# lightshade = Dispensary.create(name: "Lightshade", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# timberline = Dispensary.create(name: "Timberline Herbal Clinic", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# firehouse = Dispensary.create(name: "Firehouse Organics", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# standing_akimbo = Dispensary.create(name: "Standing Akimbo", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# livegreen_cannabis = Dispensary.create(name: "Livegreen Cannabis", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# medicine_man = Dispensary.create(name: "Medicine Man", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# tru_cannabis_mile_high = Dispensary.create(name: "Tru Cannabis Mile High", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# metro_cannabis_inc = Dispensary.create(name: "Metro Cannabis Inc.", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# natural_remedies_denver = Dispensary.create(name: "Natural Remedies",  phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# botanico = Dispensary.create(name: "Botanico", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# caregivers_for_life = Dispensary.create(name: "Caregivers for Life Recreational Center", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# herbs4you = Dispensary.create(name: "Herbs4you", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# sweet_leaf = Dispensary.create(name: "Sweet Leaf", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# the_herbal_cure = Dispensary.create(name: "The Herbal Cure", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# trenchtown_medical_marijuana_center = Dispensary.create(name: "Trenchtown Medical Marijuana Center", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# green_man_cannabis_sf_street = Dispensary.create(name: "Green Man Cannabis", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# infinite_wellness_center = Dispensary.create(name: "Infinite Wellness Center", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# denver_relief = Dispensary.create(name: "Denver Releif", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# verde_wellness_center = Dispensary.create(name: "Verde Wellness Center", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# dank_colorado = Dispensary.create(name: "DANK Colorado", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# the_giving_tree_of_denver = Dispensary.create(name: "The Giving Tree of Denver", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# colorado_harvest_center = Dispensary.create(name: "Colorado Harvest Center", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# herbs4you_9th_ave = Dispensary.create(name: "Herbs4you", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# holistic_life = Dispensary.create(name: "Holistic Life", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)

# ##boulder
# cannabis_center = Dispensary.create(name: "3D Cannabis Center", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# native_roots_boulder = Dispensary.create(name: "Native Roots", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# sweet_leaf_38th_ave = Dispensary.create(name: "Sweet Leaf", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# ballpark_holistic_dispensary = Dispensary.create(name: "Ballpark Holistic Dispensary", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# chronic_therapy_recreational = Dispensary.create(name: "Chronic Therapy Recreational", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)

# ## aurora
# good_chemistry = Dispensary.create(name: "Good Chemistry", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# herbs4you_aurora = Dispensary.create(name: "Herbs4you", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# tru_cannabis_aurora = Dispensary.create(name: "Tru Cannabis", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# allgreens = Dispensary.create(name: "Allgreens", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# river_rock_store = Dispensary.create(name: "River Rock Store", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)

# ## manitou springs
# maggies_farm = Dispensary.create(name: "Maggie's Farm", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# the_clone_store = Dispensary.create(name: "The Clone Store", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# lyons_finest = Dispensary.create(name: "Lyon's Finest", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)

# ## erie
# at_home_remedies = Dispensary.create(name: "At Home Remedies", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# lucy_sky = Dispensary.create(name: "Lucy Sky",phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# ivita_wellness = Dispensary.create(name: "iVita Wellness", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# tru_cannabis = Dispensary.create(name: "Tru Cannabis", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)

# ##lakewood
# natures_best_alternative_medicine = Dispensary.create(name: "Nature's Best Alternative Medicine", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)
# herban_medicinals = Dispensary.create(name: "Herban Medicinals", phone_number: Faker::PhoneNumber.phone_number, website: Faker::Internet.domain_name)

##strains(name, photo.id)
white_widow = Strain.create(name: "White Widow", photo_url: "whiteWidow.jpg")
trainwreck = Strain.create(name: "Trainwreck", photo_url: "trainwreck.jpg")
blue_cheese = Strain.create(name: "Blue Cheese", photo_url: "blueCheese.jpg")
wchemdawg = Strain.create(name: "Chemdawg", photo_url: "chemDawg.jpg")
grape_ape = Strain.create(name: "Grape Ape", photo_url: "cherryPie.jpg")
bubba_kush = Strain.create(name: "Bubba Kush", photo_url:"bubbaKush.jpg")
northern_lights = Strain.create(name: "Northern Lights", photo_url: "northernLights.jpg")
lemon_haze = Strain.create(name: "Lemon Haze", photo_url: "lemonHaze.jpg")
blackberry_kush = Strain.create(name: "Blackberry Kush", photo_url: "blackberryKush.jpg")
green_crack = Strain.create(name: "Green Crack", photo_url: "greenCrack.jpg")
girl_scount_cookies = Strain.create(name: "Girl Scout Cookies", photo_url: "girlScoutCookies.jpg")
grandaddy_purple = Strain.create(name: "Grandaddy Purple", photo_url: "grandaddyPurple.jpg")
jack_herer = Strain.create(name: "Jack Herer", photo_url: "jackHerer.jpg")
pineapple_express = Strain.create(name: "Pineapple Express", photo_url: "pineappleExpress.jpg")
lemon_kush = Strain.create(name: "Lemon Kush", photo_url: "lemonKush.jpg")
death_star = Strain.create(name: "Death Star", photo_url: "greenCrack.jpg")
gods_gift = Strain.create(name: "God's Gift", photo_url: "godsGift.jpg")
purple_urkle = Strain.create(name: "Purple Urkle", photo_url: "purpleUrkle.jpg")
amnesia_haze = Strain.create(name: "Amnesia Haze", photo_url: "amnesiaHaze.jpg")
chocalope= Strain.create(name: "Chocalope", photo_url: "chocalope.jpg")
hindu_kush = Strain.create(name: "Hindu Kush", photo_url: "hinduKush.jpg")
g13 = Strain.create(name: "G13", photo_url: "g13.jpg")
cherry_pie = Strain.create(name: "Cherry Pie", photo_url: "cherryPie.jpg")
tahoe_og_kush = Strain.create(name: "Tahoe OG Kush", photo_url: "tahoe.jpg")
bubble_gum = Strain.create(name: "Bubble Gum", photo_url: "bubbleGum.jpg")
white_rhino = Strain.create(name: "White Rhino", photo_url: "whiteRhino.jpg")
la_confidential = Strain.create(name: "LA Confidential", photo_url: "laConfidential.jpg")
skywalker = Strain.create(name: "Skywalker", photo_url: "skywalker.jpg")
nyc_diesel = Strain.create(name: "NYC Diesel", photo_url: "nycDiesel.jpg")
afghan_kush = Strain.create(name: "Afghan Kush", photo_url: "afghanKush.jpg")
cheese = Strain.create(name: "Cheese", photo_url: "cheese.jpg")
super_silver_haze = Strain.create(name: "Super Silver Haze", photo_url: "superSilverHaze.jpg")
strawberry_cough = Strain.create(name: "Strawberry Cough", photo_url: "strawberryCough.jpg")
durban_poison = Strain.create(name: "Durban Poison", photo_url: "durbanPoison.jpg")

##dispensary_strains(dispensary_id, strain_id, stocked?)
##only dispensaries in boulder ---- all w/ white_widow, trainwreck, cheese, skywalker

# <<<<<<< HEAD
# one = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: white_widow.id)
# two = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: trainwreck.id)
# three = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: cheese.id)
# four = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: skywalker.id)
# five = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: afghan_kush.id)
# six = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: white_widow.id)
# seven = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: trainwreck.id)
# eight = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: cheese.id)
# nine = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: skywalker.id)
# ten = DispensaryStrain.create(dispensary_id: sweet_leaf_38th_ave.id, strain_id: white_widow.id)
# eleven = DispensaryStrain.create(dispensary_id: sweet_leaf_38th_ave.id, strain_id: trainwreck.id)
# twelve = DispensaryStrain.create(dispensary_id: sweet_leaf_38th_ave.id, strain_id: cheese.id)
# thirteen = DispensaryStrain.create(dispensary_id: sweet_leaf_38th_ave.id, strain_id: skywalker.id)
# fourteen = DispensaryStrain.create(dispensary_id: sweet_leaf_38th_ave.id, strain_id: afghan_kush.id)
# fifteen = DispensaryStrain.create(dispensary_id: sweet_leaf_38th_ave.id, strain_id: bubble_gum.id)
# sixteen = DispensaryStrain.create(dispensary_id: sweet_leaf_38th_ave.id, strain_id: cherry_pie.id)
# seventeen = DispensaryStrain.create(dispensary_id: ballpark_holistic_dispensary.id, strain_id: white_widow.id)
# eighteen = DispensaryStrain.create(dispensary_id: ballpark_holistic_dispensary.id, strain_id: trainwreck.id)
# nineteen = DispensaryStrain.create(dispensary_id: ballpark_holistic_dispensary.id, strain_id: cheese.id)
# twenty = DispensaryStrain.create(dispensary_id: ballpark_holistic_dispensary.id, strain_id: skywalker.id)
# twenty_one = DispensaryStrain.create(dispensary_id: ballpark_holistic_dispensary.id, strain_id: afghan_kush.id)
# twenty_two = DispensaryStrain.create(dispensary_id: ballpark_holistic_dispensary.id, strain_id: bubble_gum.id)
# twenty_three = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: white_widow.id)
# twenty_four = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: trainwreck.id)
# twenty_five = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: cheese.id)
# twenty_six = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: skywalker.id)
# twenty_seven = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: afghan_kush.id)
# twenty_eight = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: bubble_gum.id)
# twenty_nine = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: cherry_pie.id)
# thirty = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: g13.id)
# thirty_one = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: white_rhino.id)
# thirty_two = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: super_silver_haze.id)
# thirty_three = DispensaryStrain.create(dispensary_id: chronic_therapy_recreational.id, strain_id: tahoe_og_kush.id)
# =======
dispensaries = [terrapin,
                native_roots,
                fox_street_clinic]
                # natural_remedies,
                # mindful_recreation,
                # new_age_medical,
                # northern_lights_cannabis,
                # green_man_cannabis,
                # lightshade,
                # firehouse,
                # standing_akimbo,
                # livegreen_cannabis,
                # medicine_man,
                # tru_cannabis_mile_high,
                # metro_cannabis_inc,
                # natural_remedies_denver,
                # botanico,
                # caregivers_for_life,
                # herbs4you,
                # sweet_leaf,
                # the_herbal_cure,
                # trenchtown_medical_marijuana_center,
                # green_man_cannabis_sf_street,
                # infinite_wellness_center,
                # denver_relief,
                # verde_wellness_center,
                # dank_colorado,
                # the_giving_tree_of_denver,
                # colorado_harvest_center,
                # herbs4you_9th_ave,
                # holistic_life,
                # cannabis_center,
                # native_roots_boulder,
                # sweet_leaf_38th_ave,
                # ballpark_holistic_dispensary,
                # chronic_therapy_recreational,
                # good_chemistry,
                # herbs4you_aurora,
                # tru_cannabis_aurora,
                # allgreens,
                # river_rock_store,
                # maggies_farm,
                # the_clone_store,
                # lyons_finest,
                # at_home_remedies,
                # lucy_sky,
                # tru_cannabis,
                # natures_best_alternative_medicine,
                # herban_medicinals]

# dispensaries.each do |dispensary|
#   num = 1
#   until num == 30
#     dispensary.dispensary_strains.create(strain_id: num)
#     num += 1
#   end
# end

dispensaries.each do |dispensary|
   Strain.all.each do |strain|
        dispensary.dispensary_strains.create(strain_id: strain.id)
   end
end
# one = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: white_widow.id)
# two = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: trainwreck.id)
# three = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: cheese.id)
# four = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: skywalker.id)
# five = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: afghan_kush.id)
# five = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: lemon_kush.id)
# five = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: blackberry_kush.id)
# five = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: grandaddy_purple.id)
# five = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: super_silver_haze.id)
# five = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: durban_poison.id)
# five = DispensaryStrain.create(dispensary_id: terrapin.id, strain_id: strawberry_cough.id)
# six = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: white_widow.id)
# seven = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: trainwreck.id)
# eight = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: cheese.id)
# nine = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: strawberry_cough.id)
# nine = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: lemon_kush.id)
# nine = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: afghan_kush.id)
# nine = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: blackberry_kush.id)
# nine = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: cherry_pie.id)
# nine = DispensaryStrain.create(dispensary_id: native_roots_boulder.id, strain_id: durban_poison.id)
# ten = DispensaryStrain.create(dispensary_id: fox_street_clinic.id, strain_id: white_widow.id)
# eleven = DispensaryStrain.create(dispensary_id: fox_street_clinic.id, strain_id: trainwreck.id)
# twelve = DispensaryStrain.create(dispensary_id: fox_street_clinic.id, strain_id: cheese.id)
# thirteen = DispensaryStrain.create(dispensary_id: fox_street_clinic.id, strain_id: skywalker.id)
# fourteen = DispensaryStrain.create(dispensary_id: fox_street_clinic.id, strain_id: afghan_kush.id)
# fifteen = DispensaryStrain.create(dispensary_id: fox_street_clinic.id, strain_id: bubble_gum.id)
# sixteen = DispensaryStrain.create(dispensary_id: fox_street_clinic.id, strain_id: cherry_pie.id)
# seventeen = DispensaryStrain.create(dispensary_id: natural_remedies.id, strain_id: white_widow.id)
# eighteen = DispensaryStrain.create(dispensary_id: natural_remedies.id, strain_id: trainwreck.id)
# nineteen = DispensaryStrain.create(dispensary_id: natural_remedies.id, strain_id: cheese.id)
# twenty = DispensaryStrain.create(dispensary_id: natural_remedies.id, strain_id: skywalker.id)
# twenty_one = DispensaryStrain.create(dispensary_id: natural_remedies.id, strain_id: afghan_kush.id)
# twenty_two = DispensaryStrain.create(dispensary_id: natural_remedies.id, strain_id: bubble_gum.id)
# twenty_three = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: white_widow.id)
# twenty_four = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: trainwreck.id)
# twenty_five = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: cheese.id)
# twenty_six = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: skywalker.id)
# twenty_seven = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: afghan_kush.id)
# twenty_eight = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: bubble_gum.id)
# twenty_nine = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: cherry_pie.id)
# thirty = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: g13.id)
# thirty_one = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: white_rhino.id)
# thirty_one = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: lemon_kush.id)
# thirty_two = DispensaryStrain.create(dispensary_id: mindful_recreation.id, strain_id: super_silver_haze.id)
# thirty_three = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: tahoe_og_kush.id)
# thirty_four = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: white_rhino.id)
# thirty_five = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: grandaddy_purple.id)
# thirty_six = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: skywalker.id)
# thirty_seven = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: afghan_kush.id)
# thirty_eight = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: lemon_kush.id)
# thirty_nine = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: cheese.id)
# forty = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: white_widow.id)
# forty_one = DispensaryStrain.create(dispensary_id: standing_akimbo.id, strain_id: durban_poison.id)
# forty_two = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: tahoe_og_kush.id)
# forty_three = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: afghan_kush.id)
# forty_four = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: lemon_kush.id)
# forty_five = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: skywalker.id)
# forty_six = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: tahoe_og_kush.id)
# forty_seven = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: super_silver_haze.id)
# forty_eight = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: grandaddy_purple.id)
# forty_nine = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: strawberry_cough.id)
# fifty = DispensaryStrain.create(dispensary_id: lightshade.id, strain_id: cherry_pie.id)
# fifty_one = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: skywalker.id)
# fifty_two = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: grandaddy_purple.id)
# fifty_three = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: strawberry_cough.id)
# fifty_four = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: white_widow.id)
# fifty_five = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: white_rhino.id)
# fifty_six = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: super_silver_haze.id)
# fifty_seven = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: afghan_kush.id)
# fifty_eight = DispensaryStrain.create(dispensary_id: timberline.id, strain_id: blackberry_kush.id)
# fifty_nine = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: lemon_kush.id)
# sixty = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: white_rhino.id)
# sixty_one = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: blackberry_kush.id)
# sixty_two = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: afghan_kush.id)
# sixty_three = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: super_silver_haze.id)
# sixty_four = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: white_widow.id)
# sixty_five = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: skywalker.id)
# sixty_six = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: bubble_gum.id)
# sixty_seven = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: bubba_kush.id)
# sixty_eight = DispensaryStrain.create(dispensary_id: green_man_cannabis.id, strain_id: strawberry_cough.id)
# sixty_nine = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: lemon_kush.id)
# seventy = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: trainwreck.id)
# seventy_one = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: grandaddy_purple.id)
# seventy_two = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: white_widow.id)
# seventy_three = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: skywalker.id)
# seventy_four = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: afghan_kush.id)
# seventy_five = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: lemon_kush.id)
# seventy_six = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: cherry_pie.id)
# seventy_seven = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: blackberry_kush.id)
# seventy_eight = DispensaryStrain.create(dispensary_id: native_roots.id, strain_id: super_silver_haze.id)
# seventy_nine = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: strawberry_cough.id)
# eighty = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: afghan_kush.id)
# eighty_one = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: super_silver_haze.id)
# eighty_two = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: blackberry_kush.id)
# eithy_three = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: lemon_kush.id)
# eighty_four = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: white_widow.id)
# eighty_five = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: skywalker.id)
# eighty_six = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: amnesia_haze.id)
# eighty_seven = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: lemon_haze.id)
# eighty_eight = DispensaryStrain.create(dispensary_id: cannabis_center.id, strain_id: cheese.id)

# <<<<<<< HEAD
# a = [one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve,
#      thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen,
#      twenty, twenty_one, twenty_two, twenty_three, twenty_four, twenty_five,
#      thirty,thirty_one, thirty_two, thirty_three]
# =======

# a = [one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve,
#  thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen,
#  twenty, twenty_one, twenty_two, twenty_three, twenty_four, twenty_five,
#  thirty,thirty_one, thirty_two, thirty_three, thirty_four, thirty_five, thirty_six,
#  thirty_seven, thirty_eight, thirty_nine, forty, forty_one, forty_two, forty_three,
#  forty_four, forty_five, forty_six, forty_seven, forty_eight, forty_nine, fifty,
#  fifty_one, fifty_two, fifty_three, fifty_four, fifty_five, fifty_six, fifty_seven,
#  fifty_eight, fifty_nine, sixty, sixty_one, sixty_two]

## choices (name, category)

#effects
overall_rating = Choice.create(name: "Overall Average")

euphoric = Choice.create(name: "Euphoric", category: "Effects")
lazy = Choice.create(name: "Lazy", category: "Effects")
happy = Choice.create(name: "Happy", category: "Effects")
uplifted = Choice.create(name: "Uplifted", category: "Effects")
sleepy = Choice.create(name: "Sleepy", category: "Effects")
relaxed = Choice.create(name: "Relaxed", category: "Effects")
giggly = Choice.create(name: "Giggly", category: "Effects")
energetic = Choice.create(name: "Energetic", category: "Effects")
focused = Choice.create(name: "Focused", category: "Effects")
creative = Choice.create(name: "Creative", category: "Effects")
talkative = Choice.create(name: "Talkative", category: "Effects")
#medical
stress = Choice.create(name: "Stress", category: "Medical")
pain = Choice.create(name: "Pain", category: "Medical")
anxiety = Choice.create(name: "Anxiety", category: "Medical")
insomnia = Choice.create(name: "Insomnia", category: "Medical")
nausea = Choice.create(name: "Nausea", category: "Medical")
depression = Choice.create(name: "Depression", category: "Medical")
glaucoma = Choice.create(name: "Glaucoma", category: "Medical")
muscle_spasms = Choice.create(name: "Muscle Spasms", category: "Medical")
fatigue = Choice.create(name: "Fatigue", category: "Medical")
#negative
headache = Choice.create(name: "Headache", category: "Negatives")
dry_mouth = Choice.create(name: "Dry Mouth", category: "Negatives")
dry_eyes = Choice.create(name: "Dry Eyes", category: "Negatives")
shakes = Choice.create(name: "Shakes", category: "Negatives")
paranoia = Choice.create(name: "Paranoia", category: "Negatives")
dizzy = Choice.create(name: "Dizzy", category: "Negatives")

## user_choices (strain_rating_id, choice_id, rating)

effects_array = [lazy, focused, sleepy, giggly, happy, creative, sleepy, talkative, energetic, euphoric, uplifted]

medical_array = [insomnia, fatigue, pain, glaucoma, muscle_spasms, anxiety, depression, stress, nausea]

negative_array = [shakes, dry_mouth, paranoia, dry_eyes, dizzy, headache]

DispensaryStrain.all.each do |x|
  30.times do
    # x.user_choices.create(choice_id: overall_rating.id, rating: (1..10).to_a.sample)
    x.user_choices.create(choice_id: effects_array.sample.id, rating: (1..10).to_a.sample)
    x.user_choices.create(choice_id: medical_array.sample.id, rating: (1..10).to_a.sample)
    x.user_choices.create(choice_id: negative_array.sample.id, rating: (1..10).to_a.sample)
  end
end


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

namespace LionFire.ObjectBus
{
    //[SlotName ("KeyProvider")] // FUTURE
    public interface IVobKeyProvider
    {
        void ReturnKey(object key);
        string GetNextKeyAsString();
        object GetNextKey();
    }
}


text:
namespace OpenApoc
{

#define CITY_TILE_X (64)
#define CITY_TILE_Y (32)
#define CITY_TILE_Z (16)

#define CITY_STRAT_TILE_X 8
#define CITY_STRAT_TILE_Y 8

class Vehicle;
class GameState;
class Building;
class Projectile;
class Scenery;
class Doodad;
class DoodadDef;

class City
{
  private:
	Framework &fw;

  public:
	City(Framework &fw, GameState &state);
	~City();
	std::vector<sp<Vehicle>> vehicles;
	std::set<sp<Projectile>> projectiles;
	std::vector<sp<Building>> buildings;
	std::vector<sp<Building>> baseBuildings;
	std::set<sp<Scenery>> scenery;
	std::set<sp<Scenery>> fallingScenery;
	std::set<sp<Doodad>> doodads;

	TileMap map;

	void update(GameState &state, unsigned int ticks);

	sp<Doodad> placeDoodad(DoodadDef &def, Vec3<float> position);
};

}; // namespace OpenApoc


text:
package org.beetl.core;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Stack;
import java.util.TreeMap;

import org.beetl.core.exception.HTMLTagParserException;
import org.beetl.core.statement.GrammarToken;

/**
 * 将模版转化为beetl script的代码,此为核心代码之一.似乎有一1.x有个小bug,换行导致输出乱了
 *
 * @author jeolli
 * @create 2011-6-19
 */
public class Transformator
{

	String htmlTagStart = "<#";
	String htmlTagEnd = "</#";
	String htmlTagBindingAttribute = "var";

	Stack htmlTagStack = new Stack();
	boolean isSupportHtmlTag = false;

	String placeholderStart = "$";
	String placeholderEnd = "$";
	String startStatement = "#:";
	String endStatement = null;
	boolean appendCR = false;
	String vname = "";
	int vnamesuffix = 0;
	Map<Integer, String> textMap = new TreeMap<Integer, String>();

	// 1 解析在文本处,2 解析在控制语句处,3 解析在占位符号里 4文件结束 5,html tag begin 6 html tag end
	int status = 1;
	// 最后转化的结果
	StringBuilder sb = new StringBuilder();
	// 输入
	char[] cs = null;
	int index = 0;
	// int currentLine = 0;
	LineStatus lineStatus = new LineStatus();
	// 合并行的行数
	int lineCount = 0;
	// 总共有多少行
	int totalLineCount = 0;

	String VCR = "<$__VCR>>";
	String lineSeparator = System.getProperty("line.separator");
	//回车换行
	char[] lineSeparatorCharArray = null;
	// 设置最多max-line行合并输出,现在不支持
	static int MAX_LINE = 78;
	// 转义符号
	static char ESCAPE = '\\';

	public Transformator()
	{

	}

	public Map<Integer, String> getTextMap()
	{
		return this.textMap;
	}

	public Transformator(String placeholderStart, String placeholderEnd, String startStatement, String endStatement)
	{
		this.placeholderStart = placeholderStart;
		this.placeholderEnd = placeholderEnd;
		this.startStatement = startStatement;
		this.endStatement = endStatement;

	}

	public String getPlaceholderStart()
	{
		return placeholderStart;
	}

	public void setPlaceholderStart(String placeholderStart)
	{
		this.placeholderStart = placeholderStart;
	}

	public String getPlaceholderEnd()
	{
		return placeholderEnd;
	}

	public void setPlaceholderEnd(String placeholderEnd)
	{
		this.placeholderEnd = placeholderEnd;
	}

	public String getStartStatement()
	{
		return startStatement;
	}

	public void setStartStatement(String startStatement)
	{
		this.startStatement = startStatement;
	}

	public String getEndStatement()
	{
		return endStatement;
	}

	public void setEndStatement(String endStatement)
	{
		this.endStatement = endStatement;

	}

	public void enableHtmlTagSupport(String tagStart, String tagEnd, String htmlTagBindingAttribute)
	{
		this.htmlTagStart = tagStart;
		this.htmlTagEnd = tagEnd;
		this.htmlTagBindingAttribute = htmlTagBindingAttribute;
		this.isSupportHtmlTag = true;
	}

	public Reader transform(Reader orginal) throws IOException, HTMLTagParserException
	{

		StringBuilder temp = new StringBuilder();
		int bufSzie = 1024;
		cs = new char[bufSzie];
		int len = -1;

		while ((len = orginal.read(cs)) != -1)
		{
			temp.append(cs, 0, len);

		}

		cs = temp.toString().toCharArray();
		// 找到回车换行符号
		findCR();
		if (this.endStatement == null)
		{
			this.endStatement = lineSeparator;
		}
		checkAppendCR();
		parser();
		if (this.isSupportHtmlTag && this.htmlTagStack.size() != 0)
		{

			String tagName = (String) htmlTagStack.peek();
			GrammarToken token = GrammarToken.createToken(tagName, this.totalLineCount + 1);

			HTMLTagParserException ex = new HTMLTagParserException("解析html tag 标签出错,未找到匹配结束标签 " + tagName);

			ex.pushToken(token);
			ex.line = totalLineCount + 1;
			this.clear();
			throw ex;

		}

		orginal.close();
		return new StringReader(sb.toString());
	}

	public Reader transform(String str) throws IOException, HTMLTagParserException
	{
		cs = str.toCharArray();
		// 找到回车换行符号
		findCR();
		if (this.endStatement == null)
		{
			this.endStatement = this.lineSeparator;
		}
		checkAppendCR();
		parser();
		if (this.isSupportHtmlTag && this.htmlTagStack.size() != 0)
		{
			String tagName = (String) htmlTagStack.peek();
			GrammarToken token = GrammarToken.createToken(tagName, this.totalLineCount + 1);

			HTMLTagParserException ex = new HTMLTagParserException("解析html tag 标签出错,未找到匹配结束标签 " + tagName);
			ex.pushToken(token);
			ex.line = totalLineCount + 1;
			this.clear();
			throw ex;
		}
		return new StringReader(sb.toString());
	}

	private void findCR()
	{

		// 是回车换行,
		StringBuilder cr = new StringBuilder(2);
		for (int i = 0; i < cs.length; i++)
		{
			if (cs[i] == '\n' || cs[i] == '\r')
			{
				cr.append(cs[i]);
				if (cs.length != (i + 1))
				{
					char next = cs[i] == '\r' ? '\n' : '\r';
					if (cs[i + 1] == next)
					{
						cr.append(next);
					}
				}
				lineSeparator = cr.toString();
				this.lineSeparatorCharArray = lineSeparator.toCharArray();
				// this.textMap.put("__VCR", lineSeparator);
				return;
			}
		}
		//

		this.lineSeparatorCharArray = lineSeparator.toCharArray();
	}

	public void parser() throws HTMLTagParserException
	{

		while (true)
		{
			switch (status)
			{
				case 1:
				{
					readCommonString();
					break;
				}
				case 2:
				{
					readStatement();
					break;
				}
				case 3:
				{
					readPlaceHolder();
					break;
				}
				case 5:
					readHTMLTagBegin();
					break;
				case 6:
					readHTMLTagEnd();
					break;
				case 4:
				{

					return;
				}

			}
		}

	}

	public void readHTMLTagBegin() throws HTMLTagParserException
	{
		String tagName = null;
		try
		{
			StringBuilder script = new StringBuilder();
			HTMLTagParser html = new HTMLTagParser(cs, index, htmlTagBindingAttribute, true);
			html.cr = this.lineSeparatorCharArray;
			html.parser();
			if (html.hasVarBinding)
			{
				script.append("htmltagvar");

			}
			else
			{
				script.append("htmltag");

			}
			tagName = html.getTagName();
			script.append("('").append(tagName).append("',");

			Map<String, String> map = html.getExpMap();
			Map<String, Character> quat = html.getQuatMap();
			if (map.size() != 0)
			{
				script.append("{");
			}
			for (Entry<String, String> entry : map.entrySet())
			{

				String key = entry.getKey();
				String value = entry.getValue();
				if (html.crKey.contains(key))
				{
					script.append(this.lineSeparator);
				}
				script.append(key).append(":");
				String attrValue = this.parseAttr(quat.get(key), value);
				script.append(attrValue);

				script.append(",");
			}

			script.setLength(script.length() - 1);
			if (map.size() != 0)
			{
				script.append("}");
			}

			if (html.hasVarBinding)
			{
				if (map.size() == 0)
				{
					//保持三个参数,第一个为标签函数名,第二个为属性,第三个为申明的变量
					script.append(",{}");
				}
				if (html.varBidingStr.trim().length() == 0)
				{
					String defaultVarName = null;
					int index = tagName.lastIndexOf(":");
					if (index == -1)
					{
						defaultVarName = tagName;
					}
					else
					{
						defaultVarName = tagName.substring(index + 1);
					}
					script.append(",").append("'").append(defaultVarName).append("'");
				}
				else
				{
					script.append(",").append("'").append(html.varBidingStr).append("'");
				}

			}

			script.append("){");
			if (html.isEmptyTag())
			{
				script.append("}");
			}
			else
			{
				htmlTagStack.push(tagName);
			}

			sb.append(script);
			this.index = html.getIndex();
			status = 1;
			this.lineStatus.setStatment();
		}
		catch (RuntimeException re)
		{

			if (tagName == null)
			{
				tagName = "未知标签";
			}
			GrammarToken token = GrammarToken.createToken(tagName, this.totalLineCount + 1);
			HTMLTagParserException ex = new HTMLTagParserException(re.getMessage());
			ex.pushToken(token);
			//todo
			//			ex.token = token;
			ex.line = totalLineCount + 1;
			throw ex;

		}

	}

	public void readHTMLTagEnd() throws HTMLTagParserException
	{
		String tagName = null;
		try
		{
			HTMLTagParser html = new HTMLTagParser(cs, index, htmlTagBindingAttribute, false);

			html.parser();
			tagName = html.getTagName();
			if (htmlTagStack.empty())
			{
				throw new RuntimeException("解析html tag出错");
			}
			String lastTag = (String) this.htmlTagStack.peek();
			if (tagName.equals(lastTag))
			{
				this.htmlTagStack.pop();
				sb.append("}");
			}
			else
			{
				throw new RuntimeException("解析html tag出错,期望匹配标签" + lastTag);
			}
			this.index = html.getIndex();
			status = 1;
			this.lineStatus.setStatment();
		}
		catch (RuntimeException re)
		{

			if (tagName == null)
			{
				tagName = "未知标签";
			}
			GrammarToken token = GrammarToken.createToken(tagName, this.totalLineCount + 1);
			HTMLTagParserException ex = new HTMLTagParserException(re.getMessage());
			ex.pushToken(token);
			//ex.token = token;
			ex.line = totalLineCount + 1;
			throw ex;
		}

	}

	public void readPlaceHolder()
	{
		index = index + this.placeholderStart.length();
		lineStatus.addHolderCount();
		sb.append("<<");

		while (index <= cs.length)
		{
			if (match(this.placeholderEnd))
			{
				// 如果前面一个是转义符
				if (this.isEscape(sb, index))
				{
					sb.append(cs[index++]);
					continue;
				}

				index = index + this.placeholderEnd.length();
				sb.append(">>");
				status = 1;
				return;
			}
			else if (status != 4)
			{
				sb.append(cs[index]);
				index++;

			}
			else
			{
				break;
			}
		}
		status = 4;
	}

	public void readStatement()
	{
		index = index + this.startStatement.length();
		lineStatus.setStatment();
		while (index <= cs.length)
		{
			if (match(this.endStatement))
			{

				// 如果前面一个是转义符
				if (this.isEscape(sb, index))
				{
					sb.append(cs[index++]);
					continue;
				}
				index = index + this.endStatement.length();
				status = 1;
				// 如果是以回车符作为控制语句结束符号
				if (appendCR)
				{

					lineStatus.setStatment();
					if (this.lineStatus.onlyStatment())
					{
						// 只有控制语句,则如果文本变量都是空格,这些文本变量则认为是格式化的,非输出语句
						// 需要更改输出
						reforamtStatmentLine();
						lineStatus.reset();
						sb.append(endStatement);
					}

				}
				else
				{
					lineStatus.setStatment();
				}
				return;
			}
			else if (status != 4)
			{
				char ch = cs[index++];
				if (ch == '\r' || ch == '\n')
				{

					totalLineCount++;
					sb.append(this.lineSeparator);
					if (this.lineSeparator.length() == 2)
					{
						index++;
					}
					if (this.lineStatus.onlyStatment())
					{
						// 只有控制语句,则如果文本变量都是空格,这些文本变量则认为是格式化的,非输出语句
						// 需要更改输出
						reforamtStatmentLine();
						lineStatus.reset();
					}

				}
				else
				{
					// 正常路径
					sb.append(ch);
				}

			}
			else
			{
				break;
			}
		}
		status = 4;
	}

	public void readCommonString()
	{
		StringBuilder temp = new StringBuilder();
		boolean hasLetter = false;
		boolean hasCheck = false;
		while (index <= cs.length)
		{
			if (match(this.placeholderStart))
			{
				if (this.isEscape(temp, index))
				{

					temp.append(cs[index++]);
					continue;
				}
				if (temp.length() != 0)
				{
					if (lineCount >= 1)
					{
						createMutipleLineTextNode(temp);
						lineCount = 0;
					}
					else
					{
						createTextNode(temp);
					}
				}

				status = 3;
				return;
			}
			else if (match(this.startStatement))
			{
				if (this.isEscape(temp, index))
				{
					temp.append(cs[index++]);
					continue;
				}
				if (temp.length() != 0)
				{
					if (lineCount >= 1)
					{
						createMutipleLineTextNode(temp);
						lineCount = 0;
					}
					else
					{
						createTextNode(temp);
					}
				}

				status = 2;
				return;
			}
			else if (isSupportHtmlTag && match(htmlTagEnd))
			{

				if (temp.length() != 0)
				{
					if (lineCount >= 1)
					{
						createMutipleLineTextNode(temp);
						lineCount = 0;
					}
					else
					{
						createTextNode(temp);
					}
				}
				index = index + this.htmlTagEnd.length();
				status = 6;
				return;

			}
			else if (isSupportHtmlTag && match(htmlTagStart))
			{

				if (temp.length() != 0)
				{
					if (lineCount >= 1)
					{
						createMutipleLineTextNode(temp);
						lineCount = 0;
					}
					else
					{
						createTextNode(temp);
					}
				}
				status = 5;
				index = index + this.htmlTagStart.length();
				return;

			}
			else if (status != 4)
			{
				char ch = cs[index++];
				if (ch == '\r' || ch == '\n')
				{
					totalLineCount++;
					if (this.lineSeparator.length() == 2)
					{
						index++;
					}

					if (!hasLetter && this.lineStatus.onlyText())
					{
						// 多行,直到碰到占位符号才停止
						temp.append(this.lineSeparator);
						lineCount++;
						lineStatus.reset();
						continue;

					}
					if (this.lineStatus.onlyStatment())
					{
						// 只有控制语句,则如果文本变量都是空格,这些文本变量则认为是格式化的,非输出语句
						// 需要更改输出
						if (temp.length() != 0)
							createTextNode(temp);
						reforamtStatmentLine();
						lineStatus.reset();
						sb.append(lineSeparator);
						continue;
					}
					else
					{

						// createTextNode(temp.append(lineSeparator));
						// // 总是需要回车换行
						// sb.append(this.lineSeparator);
						// lineStatus.reset();

						lineCount++;
						lineStatus.reset();
						temp.append(this.lineSeparator);
						continue;
					}

				}
				else
				{

					if (!hasCheck && ch != ' ' && ch != '\t')
					{
						hasLetter = true;
						hasCheck = true;
					}
					// 正常调用路径
					temp.append(ch);
				}

			}
			else
			{
				break;
			}
		}
		if (temp.length() != 0)
			createTextNode(temp);
		status = 4;
		return;

	}

	private void reforamtStatmentLine()
	{

		/*
		 * 是否需要删除控制语句俩边的空格,约定,如果一行只有控制语句以及空格或者tab,那么空格或者tab 将不是输出内容,而是格式化字符串,比如:
		 * 空格... <%for (item in userList!){ 空格+回车 %>
		 */
		int count = lineStatus.getSpaceCount();
		for (int i = count - 1; i >= 0; i--)
		{
			int start = lineStatus.getSpaceTextStart(i);
			int end = lineStatus.getSpaceTextEnd(i);
			String varName = sb.substring(start + 2, end - 2);
			String orgText = this.textMap.get(Integer.parseInt(varName));
			sb.replace(start, end, orgText);
		}
		lineStatus.reset();
	}

	private void createTextNode(StringBuilder str)
	{
		if (str.length() == 0)
		{
			return;
		}
		String name = this.getNewVarName();
		this.textMap.put(Integer.parseInt(name), new String(str));
		String textVarName = "<$" + name + ">>";

		if (isSpace(str))
		{
			lineStatus.addSpaceText(this.sb.length(), this.sb.length() + textVarName.length());
		}
		else
		{
			lineStatus.addTextCount();
		}

		this.sb.append(textVarName);
		str.setLength(0);

	}

	private void createMutipleLineTextNode(StringBuilder str)
	{
		int index = str.lastIndexOf(lineSeparator);
		String firstPart = str.substring(0, index);
		String secondPart = str.substring(index + lineSeparator.length());
		if (isSpace(new StringBuilder(secondPart)))
		{
			// 有可能是格式化字符串,单独计算
			createTextNode(new StringBuilder(firstPart + lineSeparator));
			// 压缩多行,但补充回车
			for (int i = 0; i < lineCount; i++)
			{
				sb.append(lineSeparator);
			}
			// 最后一行是文本和占位符混合,因此,单独算一个文本变量
			createTextNode(new StringBuilder(secondPart));
		}
		else
		{

			createTextNode(str);
			for (int i = 0; i < lineCount; i++)
			{
				sb.append(lineSeparator);
			}

		}
		str.setLength(0);
	}

	private boolean isSpace(StringBuilder str)
	{
		for (char c : str.toString().toCharArray())
		{
			if (c != ' ' && c != '\t')
			{
				return false;
			}
		}
		return true;
	}

	public boolean match(String expectedStr)
	{

		int i = 0;
		while (i < expectedStr.length())
		{
			if (cs.length == (index + i))
			{
				// 行尾
				status = 4;
				return false;
			}
			if (cs[index + i] != expectedStr.charAt(i))
			{
				return false;
			}
			i++;
		}
		return true;

		// 如果匹配,但往前看有转义符,则还是算不匹配
		/*
		 * if (isEscape(sb, index) && (this.status == 2 || this.status == 3))
		 * return false; else return true;
		 */
	}

	/**
	 * 在match情况下,判断前面一符号是否是转义符号,如果是,则删除转义符号 2012-2-5 李bear
	 */
	public boolean isEscape(StringBuilder temp, int index)
	{
		if (index != 0 && cs[index - 1] == this.ESCAPE)
		{
			if (index >= 2 && cs[index - 2] == this.ESCAPE)
			{
				// 俩个转义符号,删除一个
				if (temp.length() != 0)
					temp.setLength(temp.length() - 1);
				return false;
			}
			else
			{
				// 将已经添加的转义符号删除
				if (temp.length() != 0)
					temp.setLength(temp.length() - 1);
				return true;
			}
		}
		else
		{
			return false;
		}

		// //将已经添加的转义符号删除
		// if(temp.length()!=0)temp.setLength(temp.length()-1);
		// return true ;
	}

	public String getNewVarName()
	{
		return this.vname + this.vnamesuffix++;
	}

	private void checkAppendCR()
	{

		if (this.endStatement.indexOf("\n") != -1)
		{
			this.appendCR = true;
		}
		else if (this.endStatement.indexOf("\r") != -1)
		{
			this.appendCR = true;
		}
		else
		{
			this.appendCR = false;
		}
	}

	public String parseAttr(char q, String attr)
	{
		//attr="aa{bb}cc" => ("aa"+(bb)+"cc") todo: 太难看了,会有很多潜在问题,需要一个专门的解析器,类似字符串模版,或者正则表达式
		StringBuilder sb = new StringBuilder(attr.length() + 10);
		int start = 0;
		int end = 0;
		int index = -1;
		while ((index = attr.indexOf(placeholderStart, start)) != -1)
		{

			int holdStart = index;

			while( (end = attr.indexOf(placeholderEnd, holdStart))!=-1){
				if(attr.charAt(end-1)=='\\'){
					//非占位结束符号
					holdStart = end+1;
					continue;
				}else{
					break;
				}
			}

			if (end == -1)
				throw new RuntimeException(attr + "标签属性错误,有站位符号,但找不到到结束符号");
			if (index != 0)
			{
				// 字符串
				sb.append(q).append(attr.substring(start, index)).append(q).append("+");
			}
			// 占位符号
			String value = attr.substring(index + this.placeholderStart.length(), end);
			value = value.replace("\\}", "}");
			sb.append("(").append(value).append(")").append("+");
			start = end + 1;
		}
		//attr = "aaaa";
		if (start == 0)
		{
			//全字符串
			return sb.append(q).append(attr).append(q).toString();
		}

		if (start != attr.length())
		{
			// 最后一个是字符串
			sb.append(q).append(attr.substring(start, attr.length())).append(q);
		}
		else
		{
			//删除"+"
			sb.setLength(sb.length() - 1);
		}
		return sb.toString();

	}

	public static void main(String[] args)
	{
		char c = '\\';
		Transformator p = new Transformator("${", "}", "<%", "%>");
		p.enableHtmlTagSupport("<ns:", "</ns:", "var");
		try
		{

			// String str = "   #:var u='hello';:#  \n  $u$";
			String str = "<ns:a tt='a${bc}' cc='bb${{tt:12,key:1232\\}}/a/b' var='c,b'></ns:a>";

			BufferedReader reader = new BufferedReader(p.transform(str));
			String line = null;
			System.out.println(p.getTextMap());
			String v = p.getTextMap().get(0);
			System.out.println("==============================");
			while ((line = reader.readLine()) != null)
			{
				System.out.println(line);
			}
		}
		catch (Exception ex)
		{
			System.out.println(ex.getMessage());
			ex.printStackTrace();
		}

	}

	public void clear()
	{
		this.cs = null;

		this.sb = null;
	}

}

// 记录一行出现的控制语句,占位符号,以及用于格式化的空格,tab符号
class LineStatus
{
	// 当前行非空格(包括tab)符号 个数
	private int textCount = 0;
	// 当前行控制语句个数
	private int statementCount = 0;
	// 当前行占位符号个数
	private int holderCount = 0;
	// 当前行用于格式化的空格(包括tab)所在sb的索引位置
	private List<Integer> startTextIndexList = new ArrayList<Integer>();
	private List<Integer> endTextIndexList = new ArrayList<Integer>();
	private int lineCount;

	public boolean onlyStatment()
	{
		// //如果包含普通文本,占位符
		// if ((textCount > 0 && startTextIndexList.size() != textCount) ||
		// holderCount > 0)
		// {
		// return false;
		// }
		// else
		// {
		// //如果有空格,没有控制语句
		// if (this.getSpaceCount() > 0 && this.statementCount == 0)
		// {
		// return false;
		// }
		//
		// return true;
		// }

		return this.statementCount != 0 && holderCount == 0;

	}

	/* 本行是否只有文本 */
	public boolean onlyText()
	{
		if (holderCount == 0 && this.statementCount == 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public void addTextCount()
	{

		this.textCount++;
	}

	public void addHolderCount()
	{

		this.holderCount++;

	}

	// 表示改行有statment
	public void setStatment()
	{
		this.statementCount = 1;
	}

	public void addSpaceText(int start, int end)
	{
		startTextIndexList.add(start);
		endTextIndexList.add(end);
	}

	public int getSpaceTextStart(int i)
	{
		return startTextIndexList.get(i);
	}

	public int getSpaceTextEnd(int i)
	{
		return this.endTextIndexList.get(i);
	}

	public int getSpaceCount()
	{
		return this.startTextIndexList.size();
	}

	public int getTextCount()
	{
		return textCount;
	}

	public void reset()
	{

		textCount = 0;
		statementCount = 0;
		holderCount = 0;
		startTextIndexList.clear();
		endTextIndexList.clear();

	}

}


text:
package org.apache.isis.core.metamodel.facets.value.money;

import org.apache.isis.applib.value.Money;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;

public class MoneyValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Money> {

    public MoneyValueFacetUsingSemanticsProviderFactory() {
        super();
    }

    @Override
    public void process(final ProcessClassContext processClassContext) {
        final Class<?> type = processClassContext.getCls();
        final FacetHolder holder = processClassContext.getFacetHolder();

        if (type != org.apache.isis.applib.value.Money.class) {
            return;
        }
        addFacets(new MoneyValueSemanticsProvider(holder, getContext()));
    }

}


text:
title: Second-Level Retries
summary: With SLR, the message causing the exception is instantly retried via a retries queue instead of an error queue.
tags:
- Second Level Retry
- Error Handling
- Exceptions
- Automatic retries
---

When an exception occurs, you should [let the NServiceBus infrastructure handle it](how-do-i-handle-exceptions.md) . It retries the message a configurable number of times, and if still doesn't work, sends it to the error queue.

Second Level Retries (SLR) introduces another level. When using SLR, the message that causes the exception is, as before, instantly retried, but instead of being sent to the error queue, it is sent to a retries queue.

SLR then picks up the message and defers it, by default first for 10 seconds, then 20, and lastly for 30 seconds, then returns it to the original worker queue.

For example, if there is a call to an web service in your handler, but the service goes down for five seconds just at that time. Without SLR, the message is retried instantly and sent to the error queue. With SLR, the message is instantly retried, deferred for 10 seconds, and then retried again. This way, the Web Service could be up and running, and the message is processed just fine.

## Configuration

### App.config

To configure SLR, enable its configuration section:

<!-- import SecondLevelRetiesAppConfig -->

 *  `Enabled`: Turns the feature on and off. Default: true.
 *  `TimeIncrease`: A time span after which the time between retries increases. Default: 10 seconds (`00:00:10`).
 *  `NumberOfRetries`: Number of times SLR kicks in. Default: 3.

## Fluent configuration API

To disable the SLR feature, add this to your configuration

<!-- import SecondLevelRetriesDisable -->

## Custom Retry Policy

You can change the time between retries or the number of retries in code.

Here is a sample method for handling this behavior.

<!-- import SecondLevelRetriesCustomPolicyHandler -->

To plug this into NServiceBus use the following APIs.

<!-- import SecondLevelRetriesCustomPolicy -->

## Working sample

In the [ErrorHandling sample](https://github.com/Particular/NServiceBus.Msmq.Samples/tree/master/ErrorHandling) are two endpoints, one with SLR enabled and the other with it disabled.

When you run the sample, you should start them using Ctrl+F5 (start without debugging), press the letter "S" in both windows at the same time and watch the different outputs.

Both endpoints execute the same code.

![](slr1.png)

![](slr2.png)


text:
title: App Lab Docs
embedded_layout: simple_embedded
---

[name]

## setStrokeWidth(width)

[/name]

[category]

Category: Canvas

[/category]

[description]

[short_description]

Set line width for the active canvas.

[/short_description]

The stroke width controls the thickness of lines drawn with [line](/applab/docs/line), [rect](/applab/docs/rect), and [circle](/applab/docs/circle). The width is measured in pixels. As the stroke width increases, the lines drawn get thicker equally on both sides.

Setting the stroke width affects all subsequent [`line()`](/applab/docs/line), [`circle()`](/applab/docs/circle), and [`rect()`](/applab/docs/rect) calls. Any lines or shapes that have already been drawn are not affected.

**Note**: A canvas element must be created before the stroke width can be changed. Create a canvas element in Design mode first, or call [`createCanvas()`](/applab/docs/createCanvas) before calling `setStrokeWidth()`.

[/description]

### Examples
____________________________________________________

[example]

This example draws two parallel lines that start and end at the same x coordinates, but have different stroke widths. Because the lines have rounded ends, the thicker line is in fact longer than the thinner line.

createCanvas(); //Create a canvas on which to draw
line(120, 50, 200, 50); //Draw a horizontal line with the default stroke width
setStrokeWidth(20);
line(120, 75, 200, 75); //Draw a horizontal line with width 20

[/example]

____________________________________________________

[example]

This example draws two lines with the same start and end point, but with different stroke widths. Thicker strokes expand the line equally on both sides.

createCanvas(); //Create a canvas on which to draw
setStrokeColor("lightblue");
setStrokeWidth(20);
line(0, 50, 320, 50); //Draw a thick blue horizontal line
setStrokeColor("black");
setStrokeWidth(1);
line(0, 50, 320, 50); //Draw a thin black line on top of the blue line

[/example]

____________________________________________________

[example]

This example draws two circles at the same location and with the same radius. The first circle has a thick stroke width and the second has a thin stroke width. The resulting image shows how a thicker stroke increases the outer radius of the circle.

createCanvas(); //Create a canvas on which to draw
setStrokeWidth(40); //Change the thickness of lines to be drawn
setStrokeColor("lightblue");
circle(160, 240, 100); //Draw a circle with a thick border
setStrokeWidth(1); //Change the thickness of lines to be drawn
setStrokeColor("black");
circle(160, 240, 100); //Draw the same circle with narrow border

[/example]

____________________________________________________

[syntax]

### Syntax

setStrokeWidth(width)

[/syntax]

[parameters]

### Parameters

| Name  | Type | Required? | Description |
|-----------------|------|-----------|-------------|
| width | number | Yes | The width in pixels with which to draw lines, circles, and rectangles.  |

[/parameters]

[returns]

### Returns
No return value. Outputs to the display only.

[/returns]

[tips]

### Tips
- `setStrokeWidth` only affects the active canvas. If there is more than one canvas, each one can have a different stroke width.
- When a new canvas is created, its stroke width will be the default value of 1 pixel.

[/tips]

[bug]

Found a bug in the documentation? Let us know at documentation@code.org

[/bug]

<%= view :applab_docs_common %>


text:
using System;
using MatrixAPI.Interfaces;
using MatrixAPI.Data;
using System.Collections.Generic;

namespace MatrixAPI.Interfaces
{
	/// <summary>
	/// Expanded version of MatrixPortal with methods to launch or shutdown nodes.
	/// </summary>
	public interface IControllerPortal : IMatrixPortal
	{
		/// <summary>
		/// Request a node launch in the cluster.
		/// </summary>
		/// <returns>
		/// Node info for launched node.
		/// </returns>
		/// <param name='nodeType'>
		/// Node type to launch in the cluster.
		/// </param>
		NodeInfo LaunchNode<T>();

        /// <summary>
        /// Launch a new node in the cluster.
        /// </summary>
        /// <typeparam name="T">RMI type of node to launch.</typeparam>
        /// <param name="host">Host to launch the node on.</param>
        /// <returns></returns>
	    NodeInfo LaunchNode<T>(HostInfo host);

		/// <summary>
		/// Shuts down a node identified by NodeInfo
		/// </summary>
		/// <returns>
		/// Successful shutdown command?
		/// </returns>
		/// <param name='node'>
		/// Identifier for the node.
		/// </param>
		void ShutdownNode(NodeInfo node);

		/// <summary>
		/// Gets the nodes running on a host.
		/// </summary>
		/// <returns>
		/// Nodes running on specified host.
		/// </returns>
		/// <param name='host'>
		/// Identifier for host
		/// </param>
		NodeInfo[] GetHostNodes(HostInfo host);
	}
}


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

    <title>The Find Tax Authorities screen.</title>
    <para>The default screen displays a list of Tax Authorities that have been setup.</para>
    <para>IMPORTANT: You will need to create a party in Party Manager for the tax authority before
        you can add a new tax authority in the accounting / tax authorities screen.</para>
    <para>Steps to create the party to be used for the tax authority are as follows:</para>
    <para>
        <orderedlist>
            <listitem>
                <para>Create New Party Group</para>
            </listitem>
            <listitem>
                <para>Fill in basic details (eg name, address etc)</para>
            </listitem>
            <listitem>
                <para>Once the party record is created then add the role of 'Tax Authority' to the
                    party</para>
            </listitem>
        </orderedlist>
    </para>
    <para>Only when the tax authority party record is created can you continue.</para>

        <title>How do I create a new tax authority?</title>
        <para>Press the 'New Tax Authority' button</para>
        <para>
            <orderedlist>
                <listitem>
                    <para>Select or enter the code for the country, state or region that is
                        applicable for the 'Geo' field</para>
                </listitem>
                <listitem>
                    <para>Select or enter the party id of the Tax Authority party that has been
                        created in Party Manager</para>
                </listitem>
                <listitem>
                    <para>Leave the 'Require Tax Id for Exemption' field at its default of 'Y'(NOTE:
                        This triggers tax not to be charged if a valid Tax Id is found!)</para>
                </listitem>
                <listitem>
                    <para>Leave 'Tax Id Format Pattern' blank (NOTE: This specifies the format of
                        the Tax Id so that it can be validated)</para>
                </listitem>
                <listitem>
                    <para>Fill in the 'Include Tax in the price' - the default is 'N'. (NOTE: If
                        prices need to include tax such as GST or VAT in the price then change this
                        to 'Y')</para>
                </listitem>
                <listitem>
                    <para>Press the 'Update' button</para>
                </listitem>
            </orderedlist>
        </para>
        <para>NOTE: The above process creates the basic tax authority detail but there are further
            details that can be added via the other tax authority sub menus</para>

        <title>How do I update a tax authority?</title>
        <para>
            <orderedlist>
                <listitem>
                    <para>Select the 'Edit' button next to the tax authority that you wish to
                        update</para>
                </listitem>
                <listitem>
                    <para>The 'Edit Tax Authority' screen is displayed</para>
                </listitem>
                <listitem>
                    <para>Update the details of the tax authority as required including any
                        submenus</para>
                </listitem>
                <listitem>
                    <para>Press the 'Update' button</para>
                </listitem>
            </orderedlist>
        </para>

        <title>How do I delete / remove a tax authority?</title>
        <para>Tax authorities cannot be deleted via the Tax Authority screens. If they need to be
            removed then it can be done via the Webtools and Entity Data maintenance.</para>
        <para>NOTE: Be very careful removing tax authorities records unless you are completely
            certain that they have not been already used for transaction calculations. </para>


text:
package com.sksamuel.scrimage.angles;

public class Radians {
   public final double value;

   public Radians(double value) {
      this.value = value;
   }

   public Degrees toDegrees() {
      return new Degrees((int) (value * 180.0 / Math.PI));
   }
}


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

    <string name="app_name">Ejercicio302</string>
    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="title_activity_bienvenida">Ejercicio302</string>
    <string name="txtClave">Ingrese clave:</string>
    <string name="btnClave">Verificar</string>
    <string name="txtBienvenida">Bienvenid@, has ingresado la clave correcta.</string>

</resources>


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

namespace Cake.Fastlane
{
    internal interface IFastlaneSupplyProvider
    {
        void Supply(FastlaneSupplyConfiguration configuration);
    }
}


text:
#include "ThreadInfo.h"
#include <cutils/threads.h>

static thread_store_t s_tls = THREAD_STORE_INITIALIZER;

RenderThreadInfo::RenderThreadInfo() {
    thread_store_set(&s_tls, this, NULL);
}

RenderThreadInfo::~RenderThreadInfo() {
}

RenderThreadInfo* RenderThreadInfo::get() {
    return (RenderThreadInfo*)thread_store_get(&s_tls);
}