text:
Sounds
======

Terminology
-----------

| Term | Description |
|----------------|----------------|
|  Sound Events  | Something that triggers a sound effect. Examples include `"minecraft:block.anvil.hit"` or `"botania:spreaderFire"`. |
| Sound Category | The category of the sound, for example `"player"`, `"block"` or simply `"master"`. The sliders in the sound settings GUI represent these categories. |
|   Sound File   | The literal file on disk that is played, usually an .ogg file. |

`sounds.json`
-------------

This JSON defines sound events, and defines which sound files they play, the subtitle, etc. Sound events are identified with [`ResourceLocation`][ResourceLocation]s. `sounds.json` should be located at the root of a resource namespace (`assets/<namespace>/sounds.json`), and it defines sound events in that namespace (`assets/<namespace>/sounds.json` defines sound events in the namespace `namespace`.).

A full specification is available on the vanilla [wiki][], but this example highlights the important parts:

```json
{
  "open_chest": {
    "category": "block",
    "subtitle": "mymod.subtitle.openChest",
    "sounds": [ "mymod:open_chest_sound_file" ]
  },
  "epic_music": {
    "category": "record",
    "sounds": [
      {
        "name": "mymod:music/epic_music",
        "stream": true
      }
    ]
  }
}
```

Underneath the top-level object, each key corresponds to a sound event. Note that the namespace is not given, as it is taken from the namespace of the JSON itself. Each event specifies its category, and a localization key to be shown when subtitles are enabled. Finally, the actual sound files to be played are specified. Note that the value is an array; if multiple sound files are specified then the game will randomly choose one to play whenever the sound event is triggered.

The two examples represent two different ways to specify a sound file. The [wiki][] has precise details, but generally, long sound files such as BGM or music discs should use the second form, because the "stream" argument tells Minecraft to not load the entire sound file into memory but to stream it from disk. The second form can also specify the volume, pitch, and random weight of a sound file.

In all cases, the path to a sound file for namespace `namespace` and path `path` is `assets/<namespace>/sounds/<path>.ogg`. Therefore `mymod:open_chest_sound_file` points to `assets/mymod/sounds/open_chest_sound_file.ogg`, and `mymod:music/epic_music` points to `assets/mymod/sounds/music/epic_music.ogg`.

Creating Sound Events
---------------------

In order to actually be able to play sounds, a `SoundEvent` corresponding to an entry in `sounds.json` must be created. This `SoundEvent` must then be [registered][registration]. Normally, the location used to create a sound event should be set as it's registry name.

Creating a `SoundEvent`:

```java
ResourceLocation location = new ResourceLocation("mymod", "open_chest");
SoundEvent event = new SoundEvent(location);
```

The `SoundEvent` acts as a reference to the sound, and is passed around to actually play sounds. Therefore, the `SoundEvent` should be stored somewhere. If a mod has an API, it should expose its `SoundEvent`s in the API.

Playing Sounds
--------------

Vanilla has lots of methods for playing sounds, and it's unclear which to use at times.

!!! Note
    This information was gathered by looking at these various methods, analyzing their usage and categorizing them accordingly. It is up-to-date as of Forge 1907, please let someone know if it is out of date!

Note that each takes a `SoundEvent`, the ones registered above. Additionally, the terms *"Server Behavior"* and *"Client Behavior"* refer to the respective [**logical** side][sides].

### `World`

1.  `playSound(EntityPlayer, BlockPos, SoundEvent, SoundCategory, volume, pitch)`
    - Simply forwards to [overload (2)](#world-playsound-pxyzecvp), adding 0.5 to each coordinate of the `BlockPos` given.

2.  `playSound(EntityPlayer, double x, double y, double z, SoundEvent, SoundCategory, volume, pitch)`
    - **Client Behavior**: If the passed in player is *the* client player, plays the sound event to the client player.
    - **Server Behavior**: Plays the sound event to everyone nearby **except** the passed in player. Player can be `null`.
    - **Usage**: The correspondence between the behaviors implies that these two methods are to be called from some player-initiated code that will be run on both logical sides at the same time - the logical client handles playing it to the user and the logical server handles everyone else hearing it without re-playing it to the original user.
       They can also be used to play any sound in general at any position server-side by calling it on the logical server and passing in a `null` player, thus letting everyone hear it.

3.  `playSound(double x, double y, double z, SoundEvent, SoundCategory, volume, pitch, distanceDelay)`
    - **Client Behavior**: Just plays the sound event in the client world. If `distanceDelay` is `true`, then delays the sound based on how far it is from the player.
    - **Server Behavior**: Does nothing.
    - **Usage**: This method only works client-side, and thus is useful for sounds sent in custom packets, or other client-only effect-type sounds. Used for thunder.

### `WorldClient`

1.  `playSound(BlockPos, SoundEvent, SoundCategory, volume, pitch, distanceDelay)`
    - Simply forwards to `World`'s [overload (3)](#world-playsound-xyzecvpd), adding 0.5 to each coordinate of the `BlockPos` given.

### `Entity`

1.  `playSound(SoundEvent, volume, pitch)`
    - Forwards to `World`'s [overload (2)](#world-playsound-pxyzecvp), passing in `null` as the player.
    - **Client Behavior**: Does nothing.
    - **Server Behavior**: Plays the sound event to everyone at this entity's position.
    - **Usage**: Emitting any sound from any non-player entity server-side.

### `EntityPlayer`

1.  `playSound(SoundEvent, volume, pitch)` (overriding the one in [`Entity`](#entity-playsound-evp))
    - Forwards to `World`'s [overload (2)](#world-playsound-pxyzecvp), passing in `this` as the player.
    - **Client Behavior**: Does nothing, see override in [`EntityPlayerSP`](#entityplayersp-playsound-evp).
    - **Server Behavior**: Plays the sound to everyone nearby *except* this player.
    - **Usage**: See [`EntityPlayerSP`](#entityplayersp-playsound-evp).

### `EntityPlayerSP`

1.  `playSound(SoundEvent, volume, pitch)` (overriding the one in [`EntityPlayer`](#entityplayer-playsound-evp))
    - Forwards to `World`'s [overload (2)](#world-playsound-pxyzecvp), passing in `this` as the player.
    - **Client Behavior**: Just plays the Sound Event.
    - **Server Behavior**: Method is client-only.
    - **Usage**: Just like the ones in `World`, these two overrides in the player classes seem to be for code that runs together on both sides. The client handles playing the sound to the user, while the server handles everyone else hearing it without re-playing to the original user.

[wiki]: https://minecraft.gamepedia.com/Sounds.json
[registration]: ../concepts/registries.md#registering-things
[ResourceLocation]: ../concepts/resources.md#resourcelocation
[sides]: ../concepts/sides.md


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>http-client</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>io.airlift</groupId>
        <artifactId>airlift</artifactId>
        <version>0.94-SNAPSHOT</version>
    </parent>

    <properties>
        <air.main.basedir>${project.parent.basedir}</air.main.basedir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-client</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-io</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-util</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-http</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>concurrent</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>json</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>log</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>units</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>stats</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>configuration</artifactId>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>trace-token</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
        </dependency>

        <dependency>
            <groupId>org.weakref</groupId>
            <artifactId>jmxutils</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-multibindings</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>annotations</artifactId>
        </dependency>

        <!-- for testing -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>testing</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>bootstrap</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.airlift</groupId>
            <artifactId>log-manager</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

redpajama_set_name: RedPajamaGithub


text:
---
id: 587d7fb8367417b2b2512c11
title: Видалення багатьох елементів за допомогою model.remove()
challengeType: 2
forumTopicId: 301538
dashedName: delete-many-documents-with-model-remove
---

# --description--

`Model.remove()` корисний для видалення всіх документів, що відповідають заданим критеріям.

# --instructions--

Змініть функцію `removeManyPeople`, щоб видалити всіх людей, ім'я яких знаходиться в змінній `nameToRemove`, за допомогою `Model.remove()`. Передайте його до документа запиту з набором полів `name`, і зворотнім викликом.

**Примітка:** `Model.remove()` не повертає видалений документ, а об'єкт JSON, що містить результат операції та кількість елементів, що постраждали. Не забудьте передати його до зворотного виклику `done()`, оскільки він буде використовуватися у тестах.

# --hints--

Видалення одразу декількох елементів має пройти успішно

```js
(getUserInput) =>
  $.ajax({
    url: getUserInput('url') + '/_api/remove-many-people',
    type: 'POST',
    contentType: 'application/json',
    data: JSON.stringify([
      { name: 'Mary', age: 16, favoriteFoods: ['lollipop'] },
      { name: 'Mary', age: 21, favoriteFoods: ['steak'] }
    ])
  }).then(
    (data) => {
      assert.isTrue(!!data.ok, 'The mongo stats are not what expected');
      assert.equal(
        data.n,
        2,
        'The number of items affected is not what expected'
      );
      assert.equal(data.count, 0, 'the db items count is not what expected');
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );
```

# --solutions--

```js
/**
  Backend challenges don't need solutions,
  because they would need to be tested against a full working project.
  Please check our contributing guidelines to learn more.
*/
```


text:
struct camera_t {
private:
  glm::mat4 proj, matrix;
  glm::vec3 pos, dir, right,
      // the look-at, as well as pivot-around position
      target;
  float horizontal_ang, // horizontal angle : toward -Z
      // vertical angle : 0, look at the horizon
      vertical_ang, speed, rotational_speed;
  enum INPUT {
    FORWARD = 0,
    BACK,
    LEFT,
    RIGHT,
    SHOWREEL,
    ROTATE,
    TOTAL
  };
  bool user[TOTAL];
  bool showreel, moving_back_or_forth, // forward or backward...
      strafing, rotating;              // left or right ...

  void calc_velocity(float dt);
  void orient(float dt);

public:
  camera_t();
  ~camera_t(void);

  void setup(glm::vec3 pos, float fov, float aspect, float near_plane,
             float far_plane);
  void teardown(void);

  void apply(float dt);

  // return projection matrix
  inline const glm::mat4 &get_proj(void) const { return proj; }

  inline virtual const glm::mat4 &get_matrix(void) const { return matrix; }

  // where I'm I looking?
  inline void set_target(glm::vec3 const &t) { target = t; }

  const glm::vec3 &get_pos(void) const { return this->pos; }

  void rotate(float angle, glm::vec3 const &axes) {
    matrix = glm::translate(glm::mat4(1.0), this->pos);
    matrix *= glm::rotate(matrix, glm::radians(angle), axes);
  }

  void process_input(int key, int scancode, int action, int mods);
};

// initial definition in main.cpp i.e. camera_t cam;
extern camera_t cam;

#endif


text:
package loon.action.map.heuristics;

import loon.action.map.AStarFindHeuristic;
import loon.utils.MathUtils;

public class Closest implements AStarFindHeuristic {

	public float getScore(float sx, float sy, float tx, float ty) {
		float dx = tx - sx;
		float dy = ty - sy;
		float result = MathUtils.sqrt((dx * dx) + (dy * dy));
		return result;
	}

	public int getType() {
		return CLOSEST;
	}

}


text:
package org.apache.geronimo.kernel.config;

import org.apache.geronimo.kernel.repository.Artifact;

/**
 * Interface for receiving deployment notifications
 *
 * @version $Rev$ $Date$
 */
public interface DeploymentWatcher {
    void deployed(Artifact id);
    void undeployed(Artifact id);
}


text:
/**************************************************
map.cpp contains stuff for the map class.
***************************************************/
#include "all_header.h"
#include "map_header.h"

//class map
//{
//    boost::mutex entityMap_mtx;
//    boost::mutex boolMap_mtx;

//    public:
//        map(int, int, std::string); //constructer, load the map.
//        base_entity* entityMap[16][9]; //array of entity pointers.
//        bool boolMap[16][9]; //array of bools
//        int return_number_of_entities(); //returns all the entities currently initialised.
//    private:
//        std::string lines[512]; //string array to hold the contents of our map file.
//        std::string mapName; //string for the name of our current map to go into.
//        bool read_map_file(int, int, std::string); //read the map file.
//        void entity_init(int); //func to initialise all the members.
//        void object_factory(int, int, std::string, std::string); //function which creates all the entities.
//        int pixPerElement_w; //stores the pixels per grid element width.
//        int pixPerElement_h; //stores the pixels per grid element height.
//        int currentEntities; //int storing the amount of initialised entities. (includes entities that re invisible etc)
//};

int map::return_number_of_entities()
{

    return map::currentEntities;

}

void map::destroy_map() //destroy all humans (by that i mean entity objects;-)
{

            for (int i = 0; i>map::return_number_of_entities(); ++i) //loop for however many
            {
                //delete entityStack[i]; //delete entities entities.
            }

return;

}

void map::entity_init(int i)
{
    unsigned strPos;
    std::string cmpEndDec("%");
    std::string cmpEndSet("#");
    std::string objectName;
    GLfloat Xf;
    GLfloat Yf;

    int colourR; //colours.
    int colourG;
    int colourB;
    int colourA;
//
//    if (i >= 400)
//    {
//        std::cout <<"i = > 400 >.< \n I= " << i <<" \n";
//        std::terminate();
//    }

    //std::cout <<  "lines = " << lines[i] << " on line 41\n\n";
    //std::cout << "i = "<< i <<" on line 42 of map.cpp\n\n";

    strPos = map::lines[i].find("#"); //try and find a # to show end of file.
    //std::cout << "strPos == " << strPos << " on line 45\n\n";
    if (strPos == std::string::npos || strPos == 0 || strPos < 0)
    {
        std::cout << "Found end of file.\n\n";
        return;
    }

        //i=i+1;
    //std::cout << "At line 42, map::lines["<<i<<"]" << "\n\n";

    //std::cout <<  "at line 44, i = " << i << "\n\n";

    objectName = map::lines[i]; //assign objectName the next line in the map file.
    i= i+1;
    //std::cout << "objectName = " << objectName << "\n\n";
    //std::cout << "i = " << i << "\n\n";
    Xf = atof(map::lines[i].c_str()); //get the GL coords of the entity
    i = i+1;
    Yf = atof(map::lines[i].c_str());
    i = i+1;
    //std::cout << "i = " << i << "\n\n\n";

    std::cout << "Initialising entity with the following params:" << " at X= " << Xf << " Y= " << Yf <<"\n"; //initialise enities.

    std::cout << "Current entity number " << map::currentEntities << "\n\n";
    int entitys = map::currentEntities;
    map::entityStack[entitys] = new base_entity (Xf, Yf); //initialise a new entity on the entity stack at element
    std::cout << "Object created\n\n";

    map::currentEntities = map::currentEntities + 1; //increment the amount of entities

    std::cout << "Current entities incremented. \nNow current entity count is: " << map::currentEntities << "\n\n";

    strPos = map::lines[i].find("%"); //try and find % to show end of params
    if (strPos != std::string::npos)
    {
        i = i+1;
        std::cout << "Returning and reading next area\n\n";
        //return;
        map::entity_init(i);
    }

        strPos = map::lines[i].find("#"); //try and find a # to show end of file.
    if (strPos == std::string::npos || strPos == 0 || strPos < 0)
    {
        std::cout << "Found end of file.\n\n";
        return;
    }

    if (strPos >= std::string::npos)
    {
    std::cout << "Map file missing closing % on line " << i << " \nIgnoring that for now, but that might change in the future.\n\n";
    i = i+1;
    std::cout << "returning and reading next area\n\n";
    map::entity_init(i);
    }

    if (i >= 25) //if looped more than 25 times there probable an error, so return.
    {
        std::cout <<"i = > 20 >.< \n I= " << i <<" \n";
        return;
    }

    return;

}

bool map::read_map_file (int width, int height, std::string filename)
{
    unsigned strPos; //temp for the result of tring operations like .find().
    int i = 0;

    std::ifstream map_file (filename.c_str());// open file.

        if (!map_file)
        {
        // Check the stream is in a good state,
        // which here pretty much just means open
        std::cout<< "Cant open map file. Common cause is not having admin privilages.\n";
        return false;
        }

        std::cout << "Opening map file....\n\n";
        std::cout << "Map file contents: \n";

        std::string line;

        while (std::getline(map_file, line))
        // read and immediately check it worked.
        {
            //std::cout << line << '\n';
            map::lines[i] = line;
            std::cout << "lines["<<i<<"] = " << map::lines[i] << "\n";
            i= i+1;
        }

    if (map::lines[0].empty() == true) //if the string is empty then either the map file is corrupt or something went wrong.
    {
        std::cout << "Empty\n";
        return false;
    }

    std::string cmp ("Name"); //var with comparason strings in.

    std::size_t found = map::lines[0].find(cmp);

    if (found != std::string::npos)
    {
        cmp.assign ("=");
        strPos = map::lines[0].rfind(cmp); // find the last instance of = in the string.
        std::string tmp = map::lines[0].substr(5); //create a new string starting at = to end of string.
        std::cout << "\n" << tmp << " <--Tempory string\n";
        //tmp.erase (0,1); //erase the = symbol

        map::mapName.assign(tmp);

        std::cout << "\n\nEventual map name = " << mapName << "\n";
    }
    std::cout <<"\n Now to read the next declaration\n\n";
    //std::cout << lines[2];

    if (map::lines[1].empty() == true) //check if the line[1] is empty.
    {
        std::cout << "Empty\n";
        return 0; //return if its empty
    }

    cmp.assign ("%");
    strPos = map::lines[1].find(cmp);

    if (strPos != std::string::npos)
    {
        std::cout << "Found entity declarations start\n\n";
        std::cout << map::lines[2]<< "\n";
        map::entity_init(2); //go to init entities.
        return true;
    }
    else
    {
    return false;
    }

    std::cout << map::lines[1];

return true;

}

map::map (int width, int height, std::string fileName)
{

//        for (int i=0; i<200; i++) //for loop 16 times.
//        {
//                    map::entityStack[i] = NULL ; //and make sure that the entity map's pointers are all null.
//        }
    map::currentEntities = 0;
    map::read_map_file(width, height, fileName);
    return;
}


text:
<?php
/**
 * Created by atorian.
 * Date: 05.12.13 21:03
 */

namespace Rock\Mvc;

use Rock\Di\CompiledAdapter;
use Rock\Di\Compiler;
use Rock\Di\Cache;
use Rock\Di\Config\DiConfig;
use Rock\Di\Config\ServiceManagerConfig;
use Rock\Di\Config\ConfigAggregate;
use Rock\Di\ServiceManagerAdapter;
use Rock\Di\ServiceManagerBuilder;
use Zend\ModuleManager\ModuleEvent;

class Application extends \Zend\Mvc\Application
{
    public static function init($configuration = array())
    {
        $cache = new Cache('data/ApplicationContext.php');

        if ($cache->isExpired()) {

            $smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
            $diConfig = isset($configuration['di']) ? $configuration['di'] : array();

            $containerBuilder = new ServiceManagerAdapter(
                new ServiceManagerBuilder(
                    new ConfigAggregate(array(
                        new ServiceManagerConfig($smConfig),
                        new DiConfig($diConfig),
                    ))
                )
            );

        } else {
            // use cached static service manager
            require_once $cache;
            $containerBuilder = new CompiledAdapter(new \ApplicationContext());
        }

        $containerBuilder->set('ApplicationConfig', $configuration);

        /** @var $moduleManager \Zend\ModuleManager\ModuleManager */
        $moduleManager = $containerBuilder->get('ModuleManager');

        if ($containerBuilder instanceof ServiceManagerAdapter) {
            // compile, cache and reuse static SM
            $moduleManager->getEventManager()
                ->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, function(ModuleEvent $e) use ($containerBuilder, $cache) {

                    $config = $containerBuilder->get('Config');
                    $diConfig = new DiConfig($config['di']);
                    $diConfig->configure($containerBuilder->getContainer());

                    $cache->write(new Compiler($containerBuilder->getContainer())); // compile DI

                    require_once $cache;

                    $sm = new \ApplicationContext();
                    // move already instantiated services to static manager
                    $sm->merge($containerBuilder->getContainer());

                    $containerBuilder->set('service_manager', new CompiledAdapter($sm));
                });
        }

        $moduleManager->loadModules();

        return $containerBuilder
            ->get('Application')
            ->bootstrap();
    }
}


text:
VpnPacket::VpnPacket(uint8_t msg_type, uint16_t msg_size) : msg_type{ msg_type }, msg_size{ msg_size } {
}

VpnPacket::VpnPacket(uint8_t msg_type) : VpnPacket(msg_type, 0) {
}

int VpnPacket::header_len() const
{
	return sizeof(VpnPacket);
}

int VpnPacket::total_len() const
{
	return header_len() + msg_size;
}

void VpnPacket::print_raw() const {
	Util::print_raw(reinterpret_cast<const uint8_t*>(this), total_len());
}

// --- HELLO ---

VpnPacketHello::VpnPacketHello(const std::string& message) : VpnPacket(MsgType::HELLO) {
	strncpy(this->message, message.c_str(), sizeof(this->message));
	msg_size = strnlen(this->message, sizeof(this->message));
}


text:
package io.astro.lib.style.csslayout;

public enum CSSAlign {
  AUTO,
  FLEX_START,
  CENTER,
  FLEX_END,
  STRETCH,
}


text:
* no changes. published to update npm docs

### Version 1.0.4
* bug fix only

### Version 1.0.3
* Pool modifies the Tedious connection object rather than the Connection prototype.

### Version 1.0.2
* Added additional log message when acquiring a connection.

### Version 1.0.0
* No changes from v0.3.9.

### Version 0.3.9
* bug fix only

### Version 0.3.7
* bug fix only

### Version 0.3.6
* bug fix only

### Version 0.3.5
* `poolConfig` option `min` is limited to less than `max`

### Version 0.3.4
* `poolConfig` option `min` supports being set to 0

### Version 0.3.3
* Ignore calls to connection.release() on a connection that has been closed or not part of the connection pool.

### Version 0.3.2
 * Calls connection.reset() when the connection is released to the pool. This is very unlikely to cause anyone trouble.
 * Added a callback argument to connectionPool.drain()

### Version 0.3.0
 * Removed dependency on the `generic-pool` node module.
 * Added `poolConfig` options `retryDelay`
 * Added `poolConfig` options `aquireTimeout` **(Possibly Breaking)**
 * Added `poolConfig` options `log`
 * `idleTimeoutMillis` renamed to `idleTimeout` **(Possibly Breaking)**
 * The `ConnectionPool` `'error'` event added
 * The behavior of the err parameter of the callback passed to `acquire()` has changed. It only returns errors related to acquiring a connection not Tedious Connection errors. Connection errors can happen anytime the pool is being filled and could go unnoticed if only passed the the callback. Subscribe to the `'error'` event on the pool to be notified of all connection errors. **(Possibly Breaking)**
 * `PooledConnection` object removed.

### Version 0.2.x
* To acquire a connection, call on `acquire()` on a `ConnectionPool` rather than `requestConnection()`. **(Breaking)**
* After acquiring a `PooledConnection`, do not wait for the `'connected'` event. The connection is received connected. **(Breaking)**
* Call `release()` on a `PooledConnection` to release the it back to the pool. `close()` permanently closes the connection (as `close()` behaves in in tedious). **(Breaking)**


text:
//var discover = require('rssdiscovery');
//var parser = require('blindparser');

var RssBraider = require('rss-braider'),
    feeds = {};

exports.run = function (params, cb) {

var url = params.url;
var item = {};
var sources = [];
//var sources = new Array();

for (var i = 0; i < url.length; i++) {
    sources.push({
        "name": url[i],
        "count": 1000,
        "feed_url": url[i]
    });
}

feeds.simple_test_feed = {
    "feed_name"             : "feed",
    "default_count"         : 1,
    "no_cdata_fields"       : [], // Don't wrap these fields in CDATA tags
    "meta" : {
        "title": "NPR Braided Feed",
        "description": "This is a test of two NPR"
    },
    "sources" : sources
};
var braider_options = {
    feeds           : feeds,
    indent          : "",
    date_sort_order : "desc", // Newest first
    log_level       : "debug"
};
var rss_braider = RssBraider.createClient(braider_options);

// Override logging level (debug, info, warn, err, off)
rss_braider.logger.level('off');

// Output braided feed as rss. use 'json' for JSON output.
rss_braider.processFeed('simple_test_feed', 'json', function(err, data){
    if (err) {
        return console.log(err);
    }
    //console.log(data);
    var array = JSON.parse("[" + data + "]");
    cb({"out": array[0]['items']});
});

/*
if( typeof options === 'object' ) {
    console.log('array');
}

discover(url, function (err, results) {
    //cb({"out": results['links'][0]});
        //show_results(results['links'][0]);
        //cb({"out": show_results(results['links'][0])});
        console.log(results);
    });

//console.log(feed_url);

//console.log(feed_url.getOwnPropertyNames());
    */
/*
parser.parseURL(url, function (err, out) {
        cb({"out": out});
    })
*/
    //console.log(params.in['']);
};

exports.definition = {
    "name": "rssfind",
    "category": "Operators",
    "container": {
        "icon": "/images/icons/rss_add.png",
        "xtype": "WireIt.FormContainer",
        "title": "Discover RSS",
        fields: [
        {
            type: 'list',
            label: "Feed URL",
            minItems: 1,
            elementType: {type: 'string'},
            value: [''],
            name: 'url',
            sortable: true,
            useButtons: true

        }],
        "terminals": [
            {"name": "out", "direction": [0, 1], "offsetPosition": {"left": 75, "bottom": -15}, "ddConfig": {
                    "type": "output",
                    "allowedTypes": ["input"]
                }
            }
        ]
    }
};

function show_results(results) {
 // We want this to show the "results" from the callback function.
 feed_url = results;
}

function discover_feeds(url) {
    discover(url, function (err, results) {

        return results;
    });
}

function parse_url(url){
    parser.parseURL(url, function (err, out) {
        return out;
    });
}


text:
CIDU 2012: Introduction to astroML
----------------------------------
These figures are from the introduction to the astroML package presented at
the Conference for Intelligent Data Understanding (CIDU) 2012.


text:
<?xml version="1.0" encoding="UTF-8"?>
<ldswebml type="image" uri="/media-library/images/church-history/pioneer#handcart-wheel-355211" xml:lang="eng" locale="eng" status="publish" xmlns:its="http://www.w3.org/2005/11/its">
  <search-meta>
      <uri-title its:translate="no">handcart-wheel-355211</uri-title>
      <source>handcart-wheel-355211</source>
      <publication-type its:translate="no">image</publication-type>
      <media-type its:translate="no">image</media-type>
      <publication value="ldsorg">LDS.org</publication>
      <publication-date value="2012-07-06">2012-07-06</publication-date>
      <title/>
      <description/>
      <collections>
          <collection its:translate="no">global-search</collection>
          <collection its:translate="no">media</collection>
          <collection its:translate="no">images</collection>
      </collections>
      <subjects>
          <subject>wagon</subject>
          <subject>wheel</subject>
          <subject>path</subject>
          <subject>field</subject>
          <subject>mountain</subject>
          <subject>antique</subject>
          <subject>old</subject>
          <subject>handcart</subject>
          <subject>spokes</subject>
      </subjects>
  </search-meta>
  <no-search>
      <path>http://media.ldscdn.org/images/media-library/church-history/pioneer/handcart-wheel-355211-gallery.jpg</path>
      <images>
          http://media.ldscdn.org/images/media-library/church-history/pioneer/handcart-wheel-355211-thumbnail.jpg
      </images>
          <download-urls>
              <download-url>
                  Mobile
                  <size>286 KB</size>
                  <path>http://media.ldscdn.org/images/media-library/church-history/pioneer/handcart-wheel-355211-mobile.jpg</path>
              </download-url>
              <download-url>
                  Tablet
                  <size>1.0 MB</size>
                  <path>http://media.ldscdn.org/images/media-library/church-history/pioneer/handcart-wheel-355211-tablet.jpg</path>
              </download-url>
              <download-url>
                  Print
                  <size>779 KB</size>
                  <path>http://media.ldscdn.org/images/media-library/church-history/pioneer/handcart-wheel-355211-print.jpg</path>
              </download-url>
              <download-url>
                  Wallpaper
                  <size>463 KB</size>
                  <path>http://media.ldscdn.org/images/media-library/church-history/pioneer/handcart-wheel-355211-wallpaper.jpg</path>
              </download-url>
          </download-urls>
  </no-search>
</ldswebml>


text:
<?php

namespace Teampass\Api\Controller;

use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Exception\InvalidParameterException;

final class KeyController extends AbstractController
{
    protected function addRoutes(ControllerCollection $controllers)
    {
        $controllers->post('/key', [$this, 'create']);
        $controllers->get('/key/{id}', [$this, 'show']);
        $controllers->put('/key/{id}', [$this, 'update']);
        $controllers->delete('/key/{id}', [$this, 'delete']);
    }

    public function show($id)
    {
        $key = $this->container['repository.key']->findById($id, $this->container['user']);
        if (!$key) {
            throw new NotFoundHttpException($this->container['translator']->trans('key.not_found', [], 'messages', $this->container['locale']));
        }

        $node = $this->container['repository.node']->findById($key['folder'], $this->container['user']);
        if (!in_array('W', explode(', ', $node['access'])) && !in_array('R', explode(', ', $node['access']))) {
            throw new AccessDeniedHttpException($this->container['translator']->trans('node.not_read', [], 'messages', $this->container['locale']));
        }

        return new JsonResponse($key, 200);
    }

    public function create(Request $request)
    {
        $data = $this->handleRequest($request);
        $key = $this->container['repository.key']->findByLabel($data['label'], $this->container['user']);
        if ($key) {
            throw new ConflictHttpException($this->container['translator']->trans('key.already_exists', [], 'messages', $this->container['locale']));
        }

        $node = $this->container['repository.node']->findById($data['id_tree'], $this->container['user']);
        if (!$node) {
            throw new NotFoundHttpException($this->container['translator']->trans('node.not_found', [], 'messages', $this->container['locale']));
        }

        if (!in_array('W', explode(', ', $node['access']))) {
            throw new AccessDeniedHttpException($this->container['translator']->trans('node.not_writable', [], 'messages', $this->container['locale']));
        }

        return new JsonResponse($this->container['repository.key']->create($data, $this->container['user']), 201);
    }

    public function update(Request $request, $id)
    {
        $data = $this->handleRequest($request);
        $key = $this->container['repository.key']->findById($id, $this->container['user']);

        if (!$key) {
            throw new NotFoundHttpException($this->container['translator']->trans('key.not_found', [], 'messages', $this->container['locale']));
        }

        $node = $this->container['repository.node']->findById($key['folder'], $this->container['user']);
        if (!in_array('W', explode(', ', $node['access']))) {
            throw new AccessDeniedHttpException($this->container['translator']->trans('node.not_writable', [], 'messages', $this->container['locale']));
        }

        return new JsonResponse($this->container['repository.key']->update($id, $data, $this->container['user']));
    }

    public function delete($id)
    {
        $key = $this->container['repository.key']->findById($id, $this->container['user']);
        if (!$key) {
            throw new NotFoundHttpException($this->container['translator']->trans('key.not_found', [], 'messages', $this->container['locale']));
        }

        $node = $this->container['repository.node']->findById($key['folder'], $this->container['user']);
        if (!in_array('W', explode(', ', $node['access']))) {
            throw new AccessDeniedHttpException($this->container['translator']->trans('node.not_writable', [], 'messages', $this->container['locale']));
        }

        $this->container['repository.key']->delete($id);

        return new JsonResponse(null, 204);
    }

    public function handleRequest(Request $request)
    {
        $data = json_decode($request->getContent(), true);
        if (null === $data) {
            throw new InvalidParameterException($this->container['translator']->trans('invalid_body', [], 'messages', $this->container['locale']));
        }

        if (array_key_exists('id', $data)) {
            unset($data['id']);
        }

        if (array_key_exists('title', $data)) {
            $data['label'] = $data['title'];
            unset($data['title']);
        }

        if (array_key_exists('folder', $data)) {
            $data['id_tree'] = $data['folder'];
            unset($data['folder']);
        }

        if (array_key_exists('username', $data)) {
            $data['login'] = $data['username'];
	    unset($data['username']);
        }

        if (array_key_exists('password', $data)) {
            $data['pw'] = $this->container['api.encoder']->decrypt($data['password']);
            unset($data['password']);
        }

        if (array_key_exists('type', $data)) {
            unset($data['type']);
        }

        return $data;
    }
}


text:
using System.Collections.Generic;
using Aurora.EffectsEngine;
using Aurora.Profiles.Aurora_Wrapper;

namespace Aurora.Profiles.Evolve
{
    public class GameEvent_Evolve : GameEvent_Aurora_Wrapper
    {
        public GameEvent_Evolve()
        {
            profilename = "Evolve";
        }

        public override bool IsEnabled()
        {
            return (Global.Configuration.ApplicationProfiles[profilename].Settings as EvolveSettings).isEnabled;
        }

        public override void UpdateLights(EffectFrame frame)
        {
            //Update wrapper lighting
            UpdateWrapperLights(frame);

            Queue<EffectLayer> layers = new Queue<EffectLayer>();

            //ColorZones
            EffectLayer cz_layer = new EffectLayer("Evolve - Color Zones");
            cz_layer.DrawColorZones((Global.Configuration.ApplicationProfiles[profilename].Settings as EvolveSettings).lighting_areas.ToArray());
            layers.Enqueue(cz_layer);

            //Scripts
            Global.Configuration.ApplicationProfiles[profilename].UpdateEffectScripts(layers, _game_state);

            frame.AddLayers(layers.ToArray());
        }
    }
}


text:
.. embedding_compiling_a_script:

==================
Compiling a script
==================

You can compile a Squirrel script with the function *sq_compile*.::

    typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer userdata);

    SQRESULT sq_compile(HSQUIRRELVM v,SQREADFUNC read,SQUserPointer p,
                const SQChar *sourcename,SQBool raiseerror);

In order to compile a script is necessary for the host application to implement a reader
function (SQLEXREADFUNC); this function is used to feed the compiler with the script
data.
The function is called every time the compiler needs a character; It has to return a
character code if succeed or 0 if the source is finished.

If sq_compile succeeds, the compiled script will be pushed as Squirrel function in the
stack.

.. :note::
    In order to execute the script, the function generated by *sq_compile()* has
    to be called through *sq_call()*

Here an example of a 'read' function that read from a file: ::

    SQInteger file_lexfeedASCII(SQUserPointer file)
    {
        int ret;
        char c;
        if( ( ret=fread(&c,sizeof(c),1,(FILE *)file )>0) )
            return c;
        return 0;
    }

    int compile_file(HSQUIRRELVM v,const char *filename)
    {
        FILE *f=fopen(filename,"rb");
        if(f)
        {
             sq_compile(v,file_lexfeedASCII,f,filename,1);
             fclose(f);
             return 1;
        }
        return 0;
    }

When the compiler fails for a syntax error it will try to call the 'compiler error handler';
this function must be declared as follow: ::

    typedef void (*SQCOMPILERERROR)(HSQUIRRELVM /*v*/,const SQChar * /*desc*/,const SQChar * /*source*/,
                            SQInteger /*line*/,SQInteger /*column*/);

and can be set with the following API call::

    void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);


text:
import { EventEmitter, Injectable } from '@angular/core';
import { HttpHeaders, HttpClient} from '@angular/common/http';
import { Observable } from 'rxjs/Observable';

import { EntryTime } from './entry-time.model';
import { PositionTime, convertJsonToPositionTime } from './postion-time.model';
import { Race } from '../races/race.model';
import { Entry } from '../entries/entry.model';

import { CachedHttpService } from '../http/cached-http.service';
import { Data } from '../model/data.model';

@Injectable()
export class TimesHttpService extends CachedHttpService {

  protected timeEndPoint: string = '/rest/time/race/';

  constructor(protected http: HttpClient) {
    super(http);
  }

  public getTimesForRace(race: Race): Observable<Data> {
    if (race) {
      const url: string = this.timeEndPoint + race.id;
      return this.getData(url);
    }
  }
}


text:
// Copyright (c) 2013-2022 Cemalettin Dervis, MIT License.
// https://github.com/cemdervis/SharpConfig

using System;
using System.Diagnostics;
using System.IO;
using System.Text;

namespace SharpConfig
{
  internal static class ConfigurationWriter
  {
    // We need this, as we never want to close the stream the user has given us.
    // But we also want to call the specified writer's Dispose() method.
    // We wouldn't need this if we were targeting .NET 4+, because BinaryWriter
    // gives us the option to leave the stream open after Dispose(), but not
    // on .NET lower than 4.0.
    // To circumvent this, we just define our own writer that does not close
    // the underlying stream in Dispose().
    private class NonClosingBinaryWriter : BinaryWriter
    {
      public NonClosingBinaryWriter(Stream stream)
          : base(stream)
      { }

      protected override void Dispose(bool disposing)
      { }
    }

    internal static void WriteToStreamTextual(Configuration cfg, Stream stream, Encoding encoding)
    {
      Debug.Assert(cfg != null);

      if (stream == null)
      {
        throw new ArgumentNullException(nameof(stream));
      }

      if (encoding == null)
      {
        encoding = Encoding.UTF8;
      }

      var str = cfg.StringRepresentation;

      // Encode & write the string.
      var byteBuffer = new byte[encoding.GetByteCount(str)];
      int byteCount = encoding.GetBytes(str, 0, str.Length, byteBuffer, 0);

      stream.Write(byteBuffer, 0, byteCount);
      stream.Flush();
    }

    internal static void WriteToStreamBinary(Configuration cfg, Stream stream, BinaryWriter writer)
    {
      Debug.Assert(cfg != null);

      if (stream == null)
      {
        throw new ArgumentNullException(nameof(stream));
      }

      if (writer == null)
      {
        writer = new NonClosingBinaryWriter(stream);
      }

      writer.Write(cfg.SectionCount);

      foreach (var section in cfg)
      {
        writer.Write(section.Name);
        writer.Write(section.SettingCount);

        WriteCommentsBinary(writer, section);

        // Write the section's settings.
        foreach (var setting in section)
        {
          writer.Write(setting.Name);
          writer.Write(setting.RawValue);

          WriteCommentsBinary(writer, setting);
        }
      }

      writer.Close();
    }

    private static void WriteCommentsBinary(BinaryWriter writer, ConfigurationElement element)
    {
      writer.Write(element.Comment != null);
      if (element.Comment != null)
      {
        // SharpConfig <3.0 wrote the comment char here.
        // We'll just write a single char for backwards-compatibility.
        writer.Write(' ');
        writer.Write(element.Comment);
      }

      writer.Write(element.PreComment != null);
      if (element.PreComment != null)
      {
        // Same as with inline comments above.
        writer.Write(' ');
        writer.Write(element.PreComment);
      }
    }

  }
}