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

namespace System.Collections.ObjectModel
{
#if PSLegacy
    /// <summary>
    /// A read-only dictionary intended to be forward-compatible with later .NET versions.
    /// </summary>
    /// <typeparam name="TKey">Type of key used by the wrapped dictionary.</typeparam>
    /// <typeparam name="TValue">Type of value associated with the keys in the wrapped dictionary.</typeparam>
    public class ReadOnlyDictionary<TKey, TValue> : IDictionary<TKey, TValue>
	{
		private const string ReadOnlyErrorMessage = "Dictionary is read-only";

		private IDictionary<TKey, TValue> _innerDictionary;

		/// <summary>
		/// Gets the dictionary that is wrapped by this <see cref="ReadOnlyDictionary<TKey,TValue>" /> object.
		/// </summary>
		protected IDictionary<TKey, TValue> InnerDictionary { get { return _innerDictionary; } }

		/// <summary>
		/// Initializes a new instance of the <see cref="ReadOnlyDictionary<TKey,TValue>" /> class that is a wrapper around the specified dictionary.
		/// </summary>
        /// <param name="dictionary">The dictionary to wrap.</param>
		public ReadOnlyDictionary(IDictionary<TKey, TValue> dictionary)
		{
			if (dictionary == null)
				throw new ArgumentNullException("dictionary");
			_innerDictionary = dictionary;
		}

#region IDictionary<TKey, TValue> members

		/// <summary>
		/// Gets the element that has the specified key.
		/// </summary>
        /// <param name="key">The key of the element to get.</param>
		public TValue this[TKey key] { get { return _innerDictionary[key]; } }

		TValue IDictionary<TKey, TValue>.this[TKey key]
		{
			get { return _innerDictionary[key]; }
			set { throw new NotSupportedException(ReadOnlyErrorMessage); }
		}

		/// <summary>
		/// Gets a key collection that contains the keys of the dictionary.
		/// </summary>
		public ICollection<TKey> Keys { get { return _innerDictionary.Keys; } }

		/// <summary>
		/// Gets a collection that contains the values in the dictionary.
		/// </summary>
		public ICollection<TValue> Values { get { return _innerDictionary.Values; } }

		void IDictionary<TKey, TValue>.Add(TKey key, TValue value) { throw new NotSupportedException(ReadOnlyErrorMessage); }

		/// <summary>
		/// Determines whether the dictionary contains an element that has the specified key.
		/// </summary>
        /// <param name="key">The key to locate in the dictionary.</param>
		public bool ContainsKey(TKey key) { return _innerDictionary.ContainsKey(key); }

		bool IDictionary<TKey, TValue>.Remove(TKey key) { throw new NotSupportedException(ReadOnlyErrorMessage); }

		/// <summary>
		/// Retrieves the value that is associated with the specified key.
		/// </summary>
        /// <param name="key">The key whose value will be retrieved.</param>
        /// <param name="value">When this method returns, the value associated with the specified key, if the key is found;
		/// otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.</param>
		public bool TryGetValue(TKey key, out TValue value) { return _innerDictionary.TryGetValue(key, out value); }

#endregion

#region ICollection<KeyValuePair<TKey, TValue>> members

		/// <summary>
		/// Gets the number of items in the dictionary.
		/// </summary>
		public int Count { get { return _innerDictionary.Count; } }

		bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly { get { return true; } }

		void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item) { throw new NotSupportedException(ReadOnlyErrorMessage); }

		void ICollection<KeyValuePair<TKey, TValue>>.Clear() { throw new NotSupportedException(ReadOnlyErrorMessage); }

		bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item) { return _innerDictionary.Contains(item); }

		/// <summary>
		/// Copies the elements of the dictionary to an array, starting at the specified array index.
		/// </summary>
        /// <param name="array">The one-dimensional array that is the destination of the elements copied from the dictionary. The array must have zero-based indexing.</param>
        /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
		public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) { _innerDictionary.CopyTo(array, arrayIndex); }

		bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item) { throw new NotSupportedException(ReadOnlyErrorMessage); }

#endregion

#region IEnumerable members

		/// <summary>
		/// Returns an enumerator that iterates through the <see cref="ReadOnlyDictionary<TKey,TValue>" />.
		/// </summary>
		public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() { return _innerDictionary.GetEnumerator(); }

		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (_innerDictionary as System.Collections.IEnumerable).GetEnumerator(); }

#endregion
	}

 #endif
}


text:
<?php

namespace Flying\Bundle\DebugBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Reference;

/**
 * Container compiler pass to register services
 * that want to receive "request is running under debugger" status
 * as soon as it will be determined
 */
class RegisterDebuggerStatusSubscribersPass implements CompilerPassInterface
{
    /**
     * {@inheritdoc}
     * @throws InvalidArgumentException
     */
    public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition('debug.debugger_detector')) {
            return;
        }
        $definition = $container->getDefinition('debug.debugger_detector');
        $subscribers = $container->findTaggedServiceIds('debug.debugger_status.subscriber');
        foreach ($subscribers as $id => $tags) {
            $definition->addMethodCall('addSubscriber', array(new Reference($id)));
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
/* Defining blocks (when asked for block list)
 * we follow (x, y, z)
 *
 * Defining faces
 * (BlockPos, facenum)
 */

/* BlockPos
 * (x, y, z)
 */

//2x the minimum frame rate before lag?
var OBJECT_FRAME_RATE = 24;

function RubeJect(objectPropertyID, position, rotation){

	//objects are stored with object property ID
	this.position = position;
	this.rotation = rotation;

	var allBlockLists, allIOMaps;

	//populate the object variables with stuff from database
	var self = this;
	$.ajax({
		url: '/home/get_object',
		dataType: 'json',
		data: { objID : objectPropertyID },
		async: false,
		success: function( obj ){
			self.objectPropertyID		= objectPropertyID;
			self.name 					= obj.name;
			self.category 				= obj.category;
			self.blockNum				= obj.block_num;
			self.mass					= obj.mass;
			self.elasticity 			= obj.elasticity;
			self.changeInHeight			= obj.change_in_height;
			self.compatibleRoamers 		= obj.compatible_roamers;
			self.ioMap 					= obj.io_map[rotation];

			// Retrieve the right rotation.
			if (obj.blocks.length != 1)
				self.blockList 			= obj.blocks[rotation];
			else self.blockList 		= obj.blocks;

			allBlockLists 				= obj.blocks;
			allIOMaps	 				= obj.io_map;
		}
	});

	//------stuff that is just cached and not in table------
	this.velocityToFrameRateRatio;
	this.sceneObjectHandler;

	// Search for face in format "x,y,z,face"
	this.hasInFace = function(inFace){
		for (var i = 0; i < this.ioMap.length; i++) {
			if (this.ioMap[i][0][0] === inFace[0] && this.ioMap[i][0][1] === inFace[1]
				&& this.ioMap[i][0][2] === inFace[2] && this.ioMap[i][0][3] === inFace[3]) {
				return true;
			}
		}
		return false;
	};

	// Returns outface with corresponding inface.
	// Returns null otherwise.
	this.getOutFace = function(inFace){
		for (var i = 0; i < this.ioMap.length; i++) {
			if (this.ioMap[i][0][0] === inFace[0] && this.ioMap[i][0][1] === inFace[1]
				&& this.ioMap[i][0][2] === inFace[2] && this.ioMap[i][0][3] === inFace[3])
				return this.ioMap[i][1];
		}
		return null;
	};

	// Returns outface by index of ioMap.
	this.getOutFaceByIndex = function(index) {
		if (index < this.ioMap.length)
			return this.ioMap[index][1];
		return null;
	}

	this.getInNode = function(inFace) {
		for (var i = 0; i < this.ioMap.length; i++) {
			if (this.ioMap[i][0][0] === inFace[0] && this.ioMap[i][0][1] === inFace[1]
				&& this.ioMap[i][0][2] === inFace[2] && this.ioMap[i][0][3] === inFace[3])
				return this.ioMap[i][3];
		}
		return null;
	}

	this.getAbsoluteInNode = function(absInface) {
		var relInface = absInface.slice(0);
		relInface[0] -= this.position[0];
		relInface[1] -= this.position[1];
		relInface[2] -= this.position[2];
		var relInNode = this.getInNode(relInface);
		var absInNode = relInNode.slice(0);
		absInNode[0] -= this.position[0];
		absInNode[1] -= this.position[1];
		absInNode[2] -= this.position[2];
		return absInNode;
	}

	this.getAbsoluteOutNode = function(absInface) {
		var relInface = absInface.slice(0);
		relInface[0] -= this.position[0];
		relInface[1] -= this.position[1];
		relInface[2] -= this.position[2];
		var relOutNode = this.getOutNode(relInface);
		var absOutNode = relOutNode.slice(0);
		absOutNode[0] -= this.position[0];
		absOutNode[1] -= this.position[1];
		absOutNode[2] -= this.position[2];
		return absOutNode;
	}

	this.getOutNode = function(inFace) {
		for (var i = 0; i < this.ioMap.length; i++) {
			if (this.ioMap[i][0][0] === inFace[0] && this.ioMap[i][0][1] === inFace[1]
				&& this.ioMap[i][0][2] === inFace[2] && this.ioMap[i][0][3] === inFace[3])
				return this.ioMap[i][4];
		}
		return null;
	}

	// Rotates RubeJect
	this.rotate = function(){
		this.rotation = (this.rotation + 1) % 4;
		if (allBlockLists.length > 1)
			this.blockList = allBlockLists[this.rotation];
		this.ioMap = allIOMaps[this.rotation];
	};
}

/*----------Inert Object Class-----------------*/
function InertRubeJect(objectPropertyID){
	RubeJect.apply(this, arguments);
}

//InertRubeJect can make function calls to any RubeJect functions
//http://stackoverflow.com/questions/2107556/how-to-inherit-from-a-class-in-javascript
//dat be what we used
/*---------------------------------------------*/

/*----------Gadget Object Class----------------*/
function GadgetRubeJect(objectPropertyID){
	RubeJect.apply(this, arguments);
	/* Key Frames for gadget */
	this.keyFrames = new Array();
}

/*---------------------------------------------*/

/*------------Roamer Object Class--------------*/
function RoamerRubeJect(objectPropertyID){
	RubeJect.apply(this, arguments);
	//For now, empty, since Roamer has no unique properties...
}

/*---------------------------------------------*/

/*-------------Carrier Object Class------------*/
function CarrierRubeJect(objectPropertyID){
	/* Should each instance get its own array?
	 * Maybe we can have a singleton access to the array?
	 */
	RubeJect.apply(this, arguments);
	this.compatibleRoamers = new Array();
	this.roamerPositionNodes = new Array();

	/* Returns the position of where the roamer object should be.
	*/
	this.AnimateCarrierPosition = function(positionNodeIndex, interpolation){
		/*
		 * To do: Fill in this function.
		 */
	}
}

/*---------------------------------------------*/

/*
var pyramid = new InertRubeJect(0);
pyramid.blockList.push([0, 0, 0]);
 pyramid.blockList.push([1, 0, 0]);
 pyramid.blockList.push([2, 0, 0]);
 pyramid.blockList.push([3, 0, 0]);
 pyramid.blockList.push([4, 0, 0]);
 pyramid.blockList.push([5, 0, 0]);
 pyramid.blockList.push([6, 0, 0]);
 pyramid.blockList.push([7, 0, 0]);
 pyramid.blockList.push([8, 0, 0]);

pyramid.blockList.push([0, 1, 0]);
 pyramid.blockList.push([1, 1, 0]);
 pyramid.blockList.push([2, 1, 0]);
 pyramid.blockList.push([3, 1, 0]);
 pyramid.blockList.push([4, 1, 0]);
 pyramid.blockList.push([5, 1, 0]);
 pyramid.blockList.push([6, 1, 0]);
 pyramid.blockList.push([7, 1, 0]);
 pyramid.blockList.push([8, 1, 0]);

pyramid.blockList.push([0, 2, 0]);
 pyramid.blockList.push([1, 2, 0]);
 pyramid.blockList.push([2, 2, 0]);
 pyramid.blockList.push([3, 2, 0]);
 pyramid.blockList.push([4, 2, 0]);
 pyramid.blockList.push([5, 2, 0]);
 pyramid.blockList.push([6, 2, 0]);
 pyramid.blockList.push([7, 2, 0]);
 pyramid.blockList.push([8, 2, 0]);

pyramid.blockList.push([0, 3, 0]);
 pyramid.blockList.push([1, 3, 0]);
 pyramid.blockList.push([2, 3, 0]);
 pyramid.blockList.push([3, 3, 0]);
 pyramid.blockList.push([4, 3, 0]);
 pyramid.blockList.push([5, 3, 0]);
 pyramid.blockList.push([6, 3, 0]);
 pyramid.blockList.push([7, 3, 0]);
 pyramid.blockList.push([8, 3, 0]);

pyramid.blockList.push([0, 4, 0]);
 pyramid.blockList.push([1, 4, 0]);
 pyramid.blockList.push([2, 4, 0]);
 pyramid.blockList.push([3, 4, 0]);
 pyramid.blockList.push([4, 4, 0]);
 pyramid.blockList.push([5, 4, 0]);
 pyramid.blockList.push([6, 4, 0]);
 pyramid.blockList.push([7, 4, 0]);
 pyramid.blockList.push([8, 4, 0]);

pyramid.blockList.push([0, 5, 0]);
 pyramid.blockList.push([1, 5, 0]);
 pyramid.blockList.push([2, 5, 0]);
 pyramid.blockList.push([3, 5, 0]);
 pyramid.blockList.push([4, 5, 0]);
 pyramid.blockList.push([5, 5, 0]);
 pyramid.blockList.push([6, 5, 0]);
 pyramid.blockList.push([7, 5, 0]);
 pyramid.blockList.push([8, 5, 0]);

pyramid.blockList.push([0, 6, 0]);
 pyramid.blockList.push([1, 6, 0]);
 pyramid.blockList.push([2, 6, 0]);
 pyramid.blockList.push([3, 6, 0]);
 pyramid.blockList.push([4, 6, 0]);
 pyramid.blockList.push([5, 6, 0]);
 pyramid.blockList.push([6, 6, 0]);
 pyramid.blockList.push([7, 6, 0]);
 pyramid.blockList.push([8, 6, 0]);

pyramid.blockList.push([0, 7, 0]);
 pyramid.blockList.push([1, 7, 0]);
 pyramid.blockList.push([2, 7, 0]);
 pyramid.blockList.push([3, 7, 0]);
 pyramid.blockList.push([4, 7, 0]);
 pyramid.blockList.push([5, 7, 0]);
 pyramid.blockList.push([6, 7, 0]);
 pyramid.blockList.push([7, 7, 0]);
 pyramid.blockList.push([8, 7, 0]);

pyramid.blockList.push([0, 8, 0]);
 pyramid.blockList.push([1, 8, 0]);
 pyramid.blockList.push([2, 8, 0]);
 pyramid.blockList.push([3, 8, 0]);
 pyramid.blockList.push([4, 8, 0]);
 pyramid.blockList.push([5, 8, 0]);
 pyramid.blockList.push([6, 8, 0]);
 pyramid.blockList.push([7, 8, 0]);
 pyramid.blockList.push([8, 8, 0]);

pyramid.blockList.push([1, 1, 1]);
 pyramid.blockList.push([2, 1, 1]);
 pyramid.blockList.push([3, 1, 1]);
 pyramid.blockList.push([4, 1, 1]);
 pyramid.blockList.push([5, 1, 1]);
 pyramid.blockList.push([6, 1, 1]);
 pyramid.blockList.push([7, 1, 1]);

pyramid.blockList.push([1, 2, 1]);
 pyramid.blockList.push([2, 2, 1]);
 pyramid.blockList.push([3, 2, 1]);
 pyramid.blockList.push([4, 2, 1]);
 pyramid.blockList.push([5, 2, 1]);
 pyramid.blockList.push([6, 2, 1]);
 pyramid.blockList.push([7, 2, 1]);

pyramid.blockList.push([1, 3, 1]);
 pyramid.blockList.push([2, 3, 1]);
 pyramid.blockList.push([3, 3, 1]);
 pyramid.blockList.push([4, 3, 1]);
 pyramid.blockList.push([5, 3, 1]);
 pyramid.blockList.push([6, 3, 1]);
 pyramid.blockList.push([7, 3, 1]);

pyramid.blockList.push([1, 4, 1]);
 pyramid.blockList.push([2, 4, 1]);
 pyramid.blockList.push([3, 4, 1]);
 pyramid.blockList.push([4, 4, 1]);
 pyramid.blockList.push([5, 4, 1]);
 pyramid.blockList.push([6, 4, 1]);
 pyramid.blockList.push([7, 4, 1]);

pyramid.blockList.push([1, 5, 1]);
 pyramid.blockList.push([2, 5, 1]);
 pyramid.blockList.push([3, 5, 1]);
 pyramid.blockList.push([4, 5, 1]);
 pyramid.blockList.push([5, 5, 1]);
 pyramid.blockList.push([6, 5, 1]);
 pyramid.blockList.push([7, 5, 1]);

pyramid.blockList.push([1, 6, 1]);
 pyramid.blockList.push([2, 6, 1]);
 pyramid.blockList.push([3, 6, 1]);
 pyramid.blockList.push([4, 6, 1]);
 pyramid.blockList.push([5, 6, 1]);
 pyramid.blockList.push([6, 6, 1]);
 pyramid.blockList.push([7, 6, 1]);

pyramid.blockList.push([1, 7, 1]);
 pyramid.blockList.push([2, 7, 1]);
 pyramid.blockList.push([3, 7, 1]);
 pyramid.blockList.push([4, 7, 1]);
 pyramid.blockList.push([5, 7, 1]);
 pyramid.blockList.push([6, 7, 1]);
 pyramid.blockList.push([7, 7, 1]);

pyramid.blockList.push([2, 2, 2]);
 pyramid.blockList.push([3, 2, 2]);
 pyramid.blockList.push([4, 2, 2]);
 pyramid.blockList.push([5, 2, 2]);
 pyramid.blockList.push([6, 2, 2]);

pyramid.blockList.push([2, 3, 2]);
 pyramid.blockList.push([3, 3, 2]);
 pyramid.blockList.push([4, 3, 2]);
 pyramid.blockList.push([5, 3, 2]);
 pyramid.blockList.push([6, 3, 2]);

pyramid.blockList.push([2, 4, 2]);
 pyramid.blockList.push([3, 4, 2]);
 pyramid.blockList.push([4, 4, 2]);
 pyramid.blockList.push([5, 4, 2]);
 pyramid.blockList.push([6, 4, 2]);

pyramid.blockList.push([2, 5, 2]);
 pyramid.blockList.push([3, 5, 2]);
 pyramid.blockList.push([4, 5, 2]);
 pyramid.blockList.push([5, 5, 2]);
 pyramid.blockList.push([6, 5, 2]);

pyramid.blockList.push([2, 6, 2]);
 pyramid.blockList.push([3, 6, 2]);
 pyramid.blockList.push([4, 6, 2]);
 pyramid.blockList.push([5, 6, 2]);
 pyramid.blockList.push([6, 6, 2]);

pyramid.blockList.push([3, 3, 3]);
 pyramid.blockList.push([4, 3, 3]);
 pyramid.blockList.push([5, 3, 3]);

pyramid.blockList.push([3, 4, 3]);
 pyramid.blockList.push([4, 4, 3]);
 pyramid.blockList.push([5, 4, 3]);

pyramid.blockList.push([3, 5, 3]);
 pyramid.blockList.push([4, 5, 3]);
 pyramid.blockList.push([5, 5, 3]);

pyramid.blockList.push([4, 4, 4]);
*/


text:
Super lightweight twitter client for Python used for personal projects. No need for long Twitter APIs. Use Twitter in Python.

[![BCH compliance](https://bettercodehub.com/edge/badge/andresitodeguzman/twtpy?branch=master)](https://bettercodehub.com/)

## Requirements
- Python3
- Twitter-Python Module

## Setup
Download the repo. Install python-twitter through pip. Generate keys and tokens. Once you have the necessary keys and tokens, open auth.py and insert them.

## How to use
Start Python
```
$ python
```
Import TwtPy via tweet
```python
>>> import tweet
```
Start Using it

## Basic Usage
Check your Name
```python
>>> tweet.whoami()
```
Check your username/screen name
```python
>>> tweet.username()
```
Tweet Something
```python
>>> status = "Hello World"
>>> tweet.tweet(status)
```
Tweet Something (without printing any response)
```python
>>> status = "Hello World"
>>> tweet.update(status)
```
Search for Tweets
```python
>>> query = "Your Query Here"
>>> tweet.tweet(query)
```
See your Followers
```python
>>> tweet.followers()
```
Follow Someone
```python
>>> username = "username_here"
>>> tweet.follow(username)
```
Unfollow Someone
```python
>>> username = "username_here"
>>> tweet.unfollow(username)
```
Send a DM
```python
>>> to = "username"
>>> message = "Hi!"
>>> tweet.sendDM(to, message)
```

Get DMs (last 20 DMs Recieved)
```python
>>> tweet.getDM()
```

## Note
- Please do not rename tweet.py as twitter.py
- Get token and keys from https://dev.twitter.com and replace the values in the file.
- This will not work without token and keys.
- This is made for personal projects. Use with caution.

## Development
This is a personal project and was intended for personal use. You may fork and improve this. Report bugs if you find one.


text:
@implementation Prediction

- (instancetype)
init {
    self = [super init];
    if (self) {
        self.confidence = 0.0;
        self.label = @"Unknown";
    }
    return self;
}

@end

// CogMachines, LLC. Confidential Information.
// TM and (c) 2017-present Semitone Inc.  All Rights Reserved.
// Reproduction in whole or in part without prior written permission of a
// duly authorized representative is prohibited.


text:
export * from './fromTo'
export * from './repeatedly'
export * from './scanStr'
export * from './toggler'


text:
//
//  UAAudioPlayerDelegate.h
//  Part of UAAudioPlayerController (license: New BSD)
//  -> https://github.com/BeamApp/MusicPlayerViewController
//
//  Created by Moritz Haarmann on 30.05.12.
//  Copyright (c) 2012 BeamApp UG. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>
@class UAAudioPlayerController;

/**
 * The Delegate of the UAAudioPlayerController must adopt the UAAudioPlayerDelegate protocol to track changes
 * in the state of the music player.
 */
@protocol UAAudioPlayerDelegate <NSObject>

@optional

/**
 * Called by the player after the player started playing a song.
 * @param player the UAAudioPlayerController sending the message
 */
-(void)musicPlayerDidStartPlaying:(UAAudioPlayerController*)player;

/**
 * Called after a user presses the "play"-button but before the player actually starts playing.
 * @param player the UAAudioPlayerController sending the message
 * @return  If the value returned is NO, the player won't start playing. YES, tells the player to starts. Default is YES.
 */
-(BOOL)musicPlayerShouldStartPlaying:(UAAudioPlayerController*)player;

/**
 * Called after the player stopped playing. This method is called both when the current song ends
 * and if the user stops the playback.
 * @param player the UAAudioPlayerController sending the message
 */
-(void)musicPlayerDidStopPlaying:(UAAudioPlayerController*)player;

/**
 * Called after the player stopped playing the last track.
 * @param player the UAAudioPlayerController sending the message
 */
-(void)musicPlayerDidStopPlayingLastTrack:(UAAudioPlayerController*)player;

/**
 * Called before the player stops playing but after the user initiated the stop action.
 * @param player the UAAudioPlayerController sending the message
 * @return By returning NO here, the delegate may prevent the player from stopping the playback. Default YES.
 */
-(BOOL)musicPlayerShouldStopPlaying:(UAAudioPlayerController*)player;

/**
 * Called after the player seeked or scrubbed to a new position. This is mostly the result of a user interaction.
 * @param player the UAAudioPlayerController sending the message
 * @param position new position in seconds
 */
-(void)musicPlayer:(UAAudioPlayerController*)player didSeekToPosition:(CGFloat)position;

/**
 * Called before the player actually skips to the next song, but after the user initiated that action.
 *
 * If an implementation returns NO, the track will not be changed, if it returns YES the track will be changed. If you do not implement this method, YES is assumed.
 * @param player the UAAudioPlayerController sending the message
 * @param track a NSUInteger containing the number of the new track
 * @return YES if the track can be changed, NO if not. Default YES.
 */
-(BOOL)musicPlayer:(UAAudioPlayerController*)player shouldChangeTrack:(NSUInteger)track;

/**
 * Called after the music player changed to a new track
 *
 * You can implement this method if you need to react to the player changing tracks.
 * @param player the UAAudioPlayerController changing the track
 * @param track a NSUInteger containing the number of the new track
 * @return the actual track the delegate has changed to
 */
-(NSInteger)musicPlayer:(UAAudioPlayerController*)player didChangeTrack:(NSUInteger)track;

/**
 * Called when the player changes it's shuffle state.
 *
 * YES indicates the player is shuffling now, i.e. randomly selecting a next track from the valid range of tracks, NO
 * means there is no shuffling.
 * @param player The UAAudioPlayerController that changes the shuffle state
 * @param shuffling YES if shuffling, NO if not
 */
-(void)musicPlayer:(UAAudioPlayerController*)player didChangeShuffleState:(BOOL)shuffling;

/**
 * Called when the player changes it's repeat mode.
 *
 * The repeat modes are taken from MediaPlayer framework and indicate whether the player is in No Repeat, Repeat Once or Repeat All mode.
 * @param player The UAAudioPlayerController that changes the repeat mode.
 * @param repeatMode a MPMusicRepeatMode indicating the currently active mode.
 */
-(void)musicPlayer:(UAAudioPlayerController*)player didChangeRepeatMode:(MPMusicRepeatMode)repeatMode;

@end


text:
{-# LANGUAGE ApplicativeDo #-}

-- | Command line options for Importify

module Options
       ( ImportifyCliArgs  (..)
       , CommonOptions     (..)
       , Command (..)
       , CabalCacheOptions (..)
       , SingleFileOptions (..)

       , parseOptions
       ) where

import Universum

import Options.Applicative (Parser, ParserInfo, auto, command, execParser, flag', fullDesc, help,
                            helper, info, long, metavar, option, progDesc, short, showDefault,
                            strArgument, strOption, subparser, switch, value)
import System.Wlog (Severity (Info))

import Importify.Main (OutputOptions (..))

data ImportifyCliArgs = ImportifyCliArgs
    { icaCommon  :: !CommonOptions
    , icaCommand :: !Command
    } deriving (Show)

newtype CommonOptions = CommonOptions
    { coLoggingSeverity :: Severity -- ^ Severity for logger
    } deriving (Show)

data Command
    = SingleFile SingleFileOptions
    | CabalCache CabalCacheOptions
    deriving (Show)

data SingleFileOptions = SingleFileOptions
    { sfoFileName :: !FilePath      -- ^ File where all redundant imports should be removed
    , sfoOutput   :: !OutputOptions -- ^ Options for @importify file@ output
    } deriving (Show)

data CabalCacheOptions = CabalCacheOptions
    { ccoSaveSources  :: !Bool    -- ^ Don't delete downloaded package cache
    , ccoDependencies :: ![Text]  -- ^ Use specified dependencies overriding .cabal ones
    } deriving (Show)

cliArgumentsParser :: Parser ImportifyCliArgs
cliArgumentsParser = do
    icaCommon  <- commonArgsParser
    icaCommand <- commandParser
    pure ImportifyCliArgs{..}

commonArgsParser :: Parser CommonOptions
commonArgsParser = do
    coLoggingSeverity <- option auto $
        metavar "SEVERITY"
     <> long "logging-severity"
     <> short 'l'
     <> value Info
     <> showDefault
     <> help "Severity for logger"
    pure CommonOptions{..}

commandParser :: Parser Command
commandParser = subparser $
    command "file"
            (info (helper <*> fileParser)
                  (fullDesc <> progDesc "Importify a single file."))
 <> command "cache"
            (info (helper <*> cacheParser)
                  (fullDesc <> progDesc
                   "Search for .cabal file in current directory. If it's found then cache \
                   \all dependencies for every target and store them inside ./.importify folder."))

fileParser :: Parser Command
fileParser = do
    sfoFileName <- strArgument
      $ metavar "FILE"
     <> help "File to importify"
    sfoOutput <- outputOptionsParser
    pure (SingleFile SingleFileOptions{..})
  where
    outputOptionsParser :: Parser OutputOptions
    outputOptionsParser =
         flag' InPlace (  long "in-place"
                       <> short 'i'
                       <> help "Write changes directly to file")
     <|> ToFile <$> strOption (  long "to"
                              <> short 't'
                              <> help "Write to specified file")
     <|> pure ToConsole

cacheParser :: Parser Command
cacheParser = do
    ccoSaveSources <- switch
      $ long "preserve"
     <> short 'p'
     <> help "Don't remove downloaded package cache"
    ccoDependencies <- many $ strOption
      $ metavar "[STRING]"
     <> long "dependency"
     <> short 'd'
     <> help "List of manually specified dependencies that should be used \
             \for caching instead of libraries from .cabal file. This option \
             \overrides default behavior."
    pure (CabalCache CabalCacheOptions{..})

optsInfo :: ParserInfo ImportifyCliArgs
optsInfo = info
    (helper <*> cliArgumentsParser)
    (fullDesc <> progDesc "Importify - manage Haskell imports easily")

parseOptions :: IO ImportifyCliArgs
parseOptions = execParser optsInfo


text:
package ballad;

import java.util.Arrays;
import org.hamcrest.Description;

class PostconditionError extends AssertionError {
  private static final long serialVersionUID = -3383182470908582913L;

  static final PostconditionError eager() {
    final PostconditionError e = new PostconditionError();
    final StackTraceElement[] a = e.getStackTrace();
    e.setStackTrace(Arrays.copyOfRange(a, 2, a.length, a.getClass()));
    return e;
  }

  private PostconditionError() {
    this("postcondition not met");
  }

  private PostconditionError(String message, AssertionError cause) {
    super(message, cause);
  }

  PostconditionError(PostconditionError eager, AssertionError cause) {
    this(eager.getMessage(), cause);
    setStackTrace(eager.getStackTrace());
  }

  PostconditionError(String message) {
    super(message);
  }

  PostconditionError(PostconditionError eager, Description description) {
    this(String.format("postcondition not met%s", description.toString()));
    setStackTrace(eager.getStackTrace());
  }
}


text:
package schema

import (
	"context"
	"database/sql"
	"fmt"
	"sort"
	"strings"

	"github.com/lxc/lxd/lxd/db/query"
	"github.com/lxc/lxd/shared"
)

// Schema captures the schema of a database in terms of a series of ordered
// updates.
type Schema struct {
	updates []Update // Ordered series of updates making up the schema
	hook    Hook     // Optional hook to execute whenever a update gets applied
	fresh   string   // Optional SQL statement used to create schema from scratch
	check   Check    // Optional callback invoked before doing any update
	path    string   // Optional path to a file containing extra queries to run
}

// Update applies a specific schema change to a database, and returns an error
// if anything goes wrong.
type Update func(*sql.Tx) error

// Hook is a callback that gets fired when a update gets applied.
type Hook func(int, *sql.Tx) error

// Check is a callback that gets fired all the times Schema.Ensure is invoked,
// before applying any update. It gets passed the version that the schema is
// currently at and a handle to the transaction. If it returns nil, the update
// proceeds normally, otherwise it's aborted. If ErrGracefulAbort is returned,
// the transaction will still be committed, giving chance to this function to
// perform state changes.
type Check func(int, *sql.Tx) error

// New creates a new schema Schema with the given updates.
func New(updates []Update) *Schema {
	return &Schema{
		updates: updates,
	}
}

// NewFromMap creates a new schema Schema with the updates specified in the
// given map. The keys of the map are schema versions that when upgraded will
// trigger the associated Update value. It's required that the minimum key in
// the map is 1, and if key N is present then N-1 is present too, with N>1
// (i.e. there are no missing versions).
//
// NOTE: the regular New() constructor would be formally enough, but for extra
//       clarity we also support a map that indicates the version explicitly,
//       see also PR #3704.
func NewFromMap(versionsToUpdates map[int]Update) *Schema {
	// Collect all version keys.
	versions := []int{}
	for version := range versionsToUpdates {
		versions = append(versions, version)
	}

	// Sort the versions,
	sort.Ints(versions)

	// Build the updates slice.
	updates := []Update{}
	for i, version := range versions {
		// Assert that we start from 1 and there are no gaps.
		if version != i+1 {
			panic(fmt.Sprintf("updates map misses version %d", i+1))
		}

		updates = append(updates, versionsToUpdates[version])
	}

	return &Schema{
		updates: updates,
	}
}

// Empty creates a new schema with no updates.
func Empty() *Schema {
	return New([]Update{})
}

// Add a new update to the schema. It will be appended at the end of the
// existing series.
func (s *Schema) Add(update Update) {
	s.updates = append(s.updates, update)
}

// Hook instructs the schema to invoke the given function whenever a update is
// about to be applied. The function gets passed the update version number and
// the running transaction, and if it returns an error it will cause the schema
// transaction to be rolled back. Any previously installed hook will be
// replaced.
func (s *Schema) Hook(hook Hook) {
	s.hook = hook
}

// Check instructs the schema to invoke the given function whenever Ensure is
// invoked, before applying any due update. It can be used for aborting the
// operation.
func (s *Schema) Check(check Check) {
	s.check = check
}

// Fresh sets a statement that will be used to create the schema from scratch
// when bootstraping an empty database. It should be a "flattening" of the
// available updates, generated using the Dump() method. If not given, all
// patches will be applied in order.
func (s *Schema) Fresh(statement string) {
	s.fresh = statement
}

// File extra queries from a file. If the file is exists, all SQL queries in it
// will be executed transactionally at the very start of Ensure(), before
// anything else is done.
//
//If a schema hook was set with Hook(), it will be run before running the
//queries in the file and it will be passed a patch version equals to -1.
func (s *Schema) File(path string) {
	s.path = path
}

// Ensure makes sure that the actual schema in the given database matches the
// one defined by our updates.
//
// All updates are applied transactionally. In case any error occurs the
// transaction will be rolled back and the database will remain unchanged.
//
// A update will be applied only if it hasn't been before (currently applied
// updates are tracked in the a 'shema' table, which gets automatically
// created).
//
// If no error occurs, the integer returned by this method is the
// initial version that the schema has been upgraded from.
func (s *Schema) Ensure(db *sql.DB) (int, error) {
	var current int
	aborted := false
	err := query.Transaction(context.TODO(), db, func(ctx context.Context, tx *sql.Tx) error {
		err := execFromFile(tx, s.path, s.hook)
		if err != nil {
			return fmt.Errorf("failed to execute queries from %s: %w", s.path, err)
		}

		err = ensureSchemaTableExists(tx)
		if err != nil {
			return err
		}

		current, err = queryCurrentVersion(tx)
		if err != nil {
			return err
		}

		if s.check != nil {
			err := s.check(current, tx)
			if err == ErrGracefulAbort {
				// Abort the update gracefully, committing what
				// we've done so far.
				aborted = true
				return nil
			}

			if err != nil {
				return err
			}
		}

		// When creating the schema from scratch, use the fresh dump if
		// available. Otherwise just apply all relevant updates.
		if current == 0 && s.fresh != "" {
			_, err = tx.Exec(s.fresh)
			if err != nil {
				return fmt.Errorf("cannot apply fresh schema: %w", err)
			}
		} else {
			err = ensureUpdatesAreApplied(tx, current, s.updates, s.hook)
			if err != nil {
				return err
			}
		}

		return nil
	})
	if err != nil {
		return -1, err
	}

	if aborted {
		return current, ErrGracefulAbort
	}

	return current, nil
}

// Dump returns a text of SQL commands that can be used to create this schema
// from scratch in one go, without going thorugh individual patches
// (essentially flattening them).
//
// It requires that all patches in this schema have been applied, otherwise an
// error will be returned.
func (s *Schema) Dump(db *sql.DB) (string, error) {
	var statements []string
	err := query.Transaction(context.TODO(), db, func(ctx context.Context, tx *sql.Tx) error {
		err := checkAllUpdatesAreApplied(tx, s.updates)
		if err != nil {
			return err
		}

		statements, err = selectTablesSQL(tx)
		return err
	})
	if err != nil {
		return "", err
	}

	for i, statement := range statements {
		statements[i] = formatSQL(statement)
	}

	// Add a statement for inserting the current schema version row.
	statements = append(
		statements,
		fmt.Sprintf(`
INSERT INTO schema (version, updated_at) VALUES (%d, strftime("%%s"))
`, len(s.updates)))
	return strings.Join(statements, ";\n"), nil
}

// Trim the schema updates to the given version (included). Updates with higher
// versions will be discarded. Any fresh schema dump previously set will be
// unset, since it's assumed to no longer be applicable. Return all updates
// that have been trimmed.
func (s *Schema) Trim(version int) []Update {
	trimmed := s.updates[version:]
	s.updates = s.updates[:version]
	s.fresh = ""
	return trimmed
}

// ExerciseUpdate is a convenience for exercising a particular update of a
// schema.
//
// It first creates an in-memory SQLite database, then it applies all updates
// up to the one with given version (excluded) and optionally executes the
// given hook for populating the database with test data. Finally it applies
// the update with the given version, returning the database handle for further
// inspection of the resulting state.
func (s *Schema) ExerciseUpdate(version int, hook func(*sql.DB)) (*sql.DB, error) {
	// Create an in-memory database.
	db, err := sql.Open("sqlite3", ":memory:?_foreign_keys=1")
	if err != nil {
		return nil, fmt.Errorf("failed to open memory database: %w", err)
	}

	// Apply all updates to the given version, excluded.
	trimmed := s.Trim(version - 1)
	_, err = s.Ensure(db)
	if err != nil {
		return nil, fmt.Errorf("failed to apply previous updates: %w", err)
	}

	// Execute the optional hook.
	if hook != nil {
		hook(db)
	}

	// Apply the update with the given version
	s.Add(trimmed[0])
	_, err = s.Ensure(db)
	if err != nil {
		return nil, fmt.Errorf("failed to apply given update: %w", err)
	}

	return db, nil
}

// Ensure that the schema exists.
func ensureSchemaTableExists(tx *sql.Tx) error {
	exists, err := DoesSchemaTableExist(tx)
	if err != nil {
		return fmt.Errorf("failed to check if schema table is there: %w", err)
	}

	if !exists {
		err := createSchemaTable(tx)
		if err != nil {
			return fmt.Errorf("failed to create schema table: %w", err)
		}
	}
	return nil
}

// Return the highest update version currently applied. Zero means that no
// updates have been applied yet.
func queryCurrentVersion(tx *sql.Tx) (int, error) {
	versions, err := selectSchemaVersions(tx)
	if err != nil {
		return -1, fmt.Errorf("failed to fetch update versions: %w", err)
	}

	// Fix bad upgrade code between 30 and 32
	hasVersion := func(v int) bool { return shared.IntInSlice(v, versions) }
	if hasVersion(30) && hasVersion(32) && !hasVersion(31) {
		err = insertSchemaVersion(tx, 31)
		if err != nil {
			return -1, fmt.Errorf("failed to insert missing schema version 31")
		}

		versions, err = selectSchemaVersions(tx)
		if err != nil {
			return -1, fmt.Errorf("failed to fetch update versions: %w", err)
		}
	}

	// Fix broken schema version between 37 and 38
	if hasVersion(37) && !hasVersion(38) {
		count, err := query.Count(tx, "config", "key = 'cluster.https_address'")
		if err != nil {
			return -1, fmt.Errorf("Failed to check if cluster.https_address is set: %w", err)
		}

		if count == 1 {
			// Insert the missing version.
			err := insertSchemaVersion(tx, 38)
			if err != nil {
				return -1, fmt.Errorf("Failed to insert missing schema version 38")
			}

			versions = append(versions, 38)
		}
	}

	current := 0
	if len(versions) > 0 {
		err = checkSchemaVersionsHaveNoHoles(versions)
		if err != nil {
			return -1, err
		}

		current = versions[len(versions)-1] // Highest recorded version
	}

	return current, nil
}

// Apply any pending update that was not yet applied.
func ensureUpdatesAreApplied(tx *sql.Tx, current int, updates []Update, hook Hook) error {
	if current > len(updates) {
		return fmt.Errorf(
			"schema version '%d' is more recent than expected '%d'",
			current, len(updates))
	}

	// If there are no updates, there's nothing to do.
	if len(updates) == 0 {
		return nil
	}

	// Apply missing updates.
	for _, update := range updates[current:] {
		if hook != nil {
			err := hook(current, tx)
			if err != nil {
				return fmt.Errorf(
					"failed to execute hook (version %d): %v", current, err)
			}
		}
		err := update(tx)
		if err != nil {
			return fmt.Errorf("failed to apply update %d: %w", current, err)
		}

		current++

		err = insertSchemaVersion(tx, current)
		if err != nil {
			return fmt.Errorf("failed to insert version %d", current)
		}
	}

	return nil
}

// Check that the given list of update version numbers doesn't have "holes",
// that is each version equal the preceding version plus 1.
func checkSchemaVersionsHaveNoHoles(versions []int) error {
	// Ensure that there are no "holes" in the recorded versions.
	for i := range versions[:len(versions)-1] {
		if versions[i+1] != versions[i]+1 {
			return fmt.Errorf("Missing updates: %d to %d", versions[i], versions[i+1])
		}
	}
	return nil
}

// Check that all the given updates are applied.
func checkAllUpdatesAreApplied(tx *sql.Tx, updates []Update) error {
	versions, err := selectSchemaVersions(tx)
	if err != nil {
		return fmt.Errorf("failed to fetch update versions: %w", err)
	}

	if len(versions) == 0 {
		return fmt.Errorf("expected schema table to contain at least one row")
	}

	err = checkSchemaVersionsHaveNoHoles(versions)
	if err != nil {
		return err
	}

	current := versions[len(versions)-1]
	if current != len(updates) {
		return fmt.Errorf("update level is %d, expected %d", current, len(updates))
	}

	return nil
}

// Format the given SQL statement in a human-readable way.
//
// In particular make sure that each column definition in a CREATE TABLE clause
// is in its own row, since SQLite dumps occasionally stuff more than one
// column in the same line.
func formatSQL(statement string) string {
	lines := strings.Split(statement, "\n")
	for i, line := range lines {
		if strings.Contains(line, "UNIQUE") {
			// Let UNIQUE(x, y) constraints alone.
			continue
		}

		lines[i] = strings.Replace(line, ", ", ",\n    ", -1)
	}

	return strings.Join(lines, "\n")
}


text:
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Castle.DynamicProxy;
using log4net;
using ServiceStack.Text;

namespace FloydPink.Flickr.Downloadr.Bootstrap
{
  public class LogInterceptor : IInterceptor
  {
    public LogInterceptor(ILog log)
    {
      Log = log;
    }

    private ILog Log { get; }

    public void Intercept(IInvocation invocation)
    {
      if (Log.IsDebugEnabled)
      {
        Log.Debug(CreateInvocationLogString("Called", invocation));
      }
      try
      {
        invocation.Proceed();

        if (Log.IsDebugEnabled)
        {
          var returnType = invocation.Method.ReturnType;
          if (returnType != typeof(void))
          {
            var returnValue = invocation.ReturnValue;
            if (returnType == typeof(Task))
            {
              Log.Debug("Returning with a task.");
            }
            else if (returnType.IsGenericType && (returnType.GetGenericTypeDefinition() == typeof(Task<>)))
            {
              Log.Debug("Returning with a generic task.");
              var task = (Task) returnValue;
              task.ContinueWith(antecedent =>
              {
                var taskDescriptor = CreateInvocationLogString("Task from",
                  invocation);
                var result =
                  antecedent.GetType()
                    .GetProperty("Result")
                    .GetValue(antecedent, null);
                Log.Debug(taskDescriptor + " returning with: " +
                          DumpObject(result));
              });
            }
            else
            {
              Log.Debug("Returning with: " + DumpObject(returnValue));
            }
          }
        }
      } catch (Exception ex)
      {
        if (Log.IsErrorEnabled)
        {
          Log.Error(CreateInvocationLogString("ERROR", invocation), ex);
        }
        throw;
      }
    }

    private static string CreateInvocationLogString(string operation, IInvocation invocation)
    {
      var sb = new StringBuilder(100);
      sb.AppendFormat("{0}: {1}.{2}(", operation, invocation.TargetType.Name, invocation.Method.Name);
      foreach (var argument in invocation.Arguments)
      {
        var argumentDescription = argument == null ? "null" : DumpObject(argument);
        sb.Append(argumentDescription).Append(",");
      }
      if (invocation.Arguments.Any())
      {
        sb.Length--;
      }
      sb.Append(")");
      return sb.ToString();
    }

    private static string DumpObject(object argument)
    {
      if (argument == null)
      {
        return "<null>";
      }
      var objtype = argument.GetType();
      if ((objtype == typeof(string)) || objtype.IsPrimitive || !objtype.IsClass)
      {
        return argument.ToString();
      }

      return ToJson(argument);
    }

    private static string ToJson(object value)
    {
      try
      {
        return value.Dump();
      } catch (Exception)
      {
        return value.ToString();
      }
    }
  }
}


text:
package uk.nhs.ciao.fhir;
import java.io.File;

import org.apache.camel.Body;
import org.apache.camel.Exchange;
import org.apache.camel.Header;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.hl7.fhir.instance.client.ResourceFormat;

import static org.hl7.fhir.instance.client.ResourceFormat.RESOURCE_XML;
import static org.hl7.fhir.instance.client.ResourceFormat.RESOURCE_JSON;
import uk.nhs.ciao.fhir.resources.ConformanceResource;
import uk.nhs.ciao.fhir.resources.MimeTypes;
import uk.nhs.ciao.fhir.resources.PatientResource;
import uk.nhs.ciao.model.Patient;
import uk.nhs.ciao.spine.pds.hl7.HL7PayloadBuilder;
import uk.nhs.ciao.spine.pds.hl7.HL7ResponseParser;
import uk.nhs.interoperability.payloads.util.FileLoader;

/**
 * There are two methods to query for FHIR conformance:
 *
 * GET [base]/metadata {?_format=[mime-type]}
 * OPTIONS [base] {?_format=[mime-type]}
 *
 * @author Adam Hatherly
 */
public class ConformanceProcessor implements Processor {
	public void process(Exchange exchange) throws Exception {

		Message in = exchange.getIn();

		// Check requested response format
		ResourceFormat responseFormat = RESOURCE_JSON;
		if (in.getHeader("_format") != null) {
			ResourceFormat requestedFormat = MimeTypes.getFormatFromMimeType(in.getHeader("_format").toString());
			if (requestedFormat != null) {
				responseFormat = requestedFormat;
			}
		}

		// Build resource
		String conformanceResource = ConformanceResource.getConformanceResource(responseFormat);
		Message out = exchange.getOut();
		out.setBody(conformanceResource);
	}
}


text:
using System;
using System.Runtime.InteropServices;

internal partial class Interop
{
    internal partial class User32
    {
        [DllImport(Libraries.User32)]
        public static extern int PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
    }
}


text:
Web Server Benchmarks of Real Business Value
===============================================

*Surprise! CNBC just mentioned you as an up-and-coming company that everyone needs to know about. How well do your webservers handle
that surge in traffic, and how much is that going to cost you? Did you pick the right web development framework to handle your company's
hockey stick moment?*

The goal of these benchmarks is to get away from the hyper-tuned microbenchmarks that so fascinate certain geeks, and instead measure
a real-world usage scenario. Specifically, the questions we are pursuing are:

> For various web development platforms, how financially expensive is it to run a production-like REST API web server
> which wraps a database with production levels of data and load?

and

> For various web development platforms, how well does this server perform under significant numbers of concurrent users?

The way that we break this down is as follows:

* The key financial metric that we are tracking is dollars per concurrent user. We are going to use the MythBusters approach to
  gathering these metrics: first, we are going to test the load level under an extreme case; then, we will see what it would take
  to accomplish the load level we have set out.
  * The extreme case that we will test is using a single `t2.nano` as the server:
  this is 0.5GiB of RAM, a variable amount of compute capability, and (as of this writing) USD$0.0059 per hour. We will test
  each implementation utilizing just one of these servers at 10, 100, 1000, and 10000 concurrent users.
  * The other extreme test will be using the compute-optimized `c4.xlarge` as the underlying image:
  4 CPUs, 16 [ECU](https://aws.amazon.com/ec2/faqs/#What_is_an_EC2_Compute_Unit_and_why_did_you_introduce_it), and 7.5GiB of RAM.
  They run USD$0.10 per hour (that's 17 `t2.nano` instances per hour). We will test each implementation utilizing just one of
  these virtual machines. Each virtual machine will run 4 primary instances of the server implementation and 2 instances
  as hot backup. This reflects a beefy single-server production environment and gives implementations which could barely
  run under `t2.nano` have their chance to shine, too. We will test each implementation at 100000 concurrent users.
  * We will then set up an Auto-Scaling Group of the `t2.nano` servers, and see how many servers the Auto-Scaling Group spins
  up while under this load, along with the performance characteristics of that Auto-Scaling Group from the client's perspective,
  along with the cost of those Auto-Scaling Groups from a business perspective.
  (If you would like to see this test repeated
  with the `c4.xlarge` instances, please contact [Sapiens Development](http://sapiensdev.com) with your sponshorship offer.)

Constraints and Contexts for Servers
======================================

* What we are curious in measuring is the REST API web server, not the database. Although we want the database to have performance
  characteristics in line with production usage, we do not need to be exercising different kinds of operations against the database,
  so testing only database reads is fine. Along these same lines, we need to ensure that the database is identical across all the
  different tests, and that it has a chance to warm its caches before we take measurements.
* We are also curious in measuring code such as what you would find in the real world. All the code should resemble something that
  would end up in production.
* We are not going to do significant tuning to the infrastructure underlying the codebase, but instead run on the default
  settings for the various platforms/frameworks. Servers must not programatically adjust these defaults, with the exception of the
  database connection pool configuration noted below. This reflects a standard deployment in a small to midsized project without
  significant operations support.
* Servers will run behind [Nginx](https://www.nginx.com/resources/wiki/), which both reflects production environments more closely
  and offloads the HTTP connection work. Nginx will run with the exact same configuration on all servers.
* Servers will run under [daemontools](https://cr.yp.to/daemontools.html), which means that servers that die through the
  course of the benchmark will be automatically restarted.
* Servers must not do any caching of the database data or other "stateful" work -- we are assuming that the servers are
  running in a serverless architecture.
* JSON serialization and deserialization on the servers must be performed using an open source, commercially accessible library.
* Database communication and pooling on the servers must be done using an open source, commercially accessible library. The
  database pool should use the default configuration, with the following exceptions:
  * The database pool should be configured to have a maximum of 25000 connections in the pool.
  * If the pool requires you to specify the number of stripes, then the number of stripes should be 5, and the maximum number of
    connections per stripe should be 5000.
  * If it is possible to configure an idle timeout in the pool, that timeout should be set to 1 minute.
* Servers must implement protections against SQL injection attacks.
* Servers must implement the swagger spec found at the sibling file to this document, `webbench.swagger.json`.

Server Configuration
=====================

All of these benchmark servers run the same way -- you provide environment variables to configure the database
connection, and then run the servers, and they provide the endpoints necessary for the benchmarking on all interfaces.

Environment Variables
-------------------------

* `PGHOST` -- The hostname where the database lives.
* `PGPORT` -- The port where the database is listening.
* `PGDATABASE` -- The database name to connect to.
* `PGUSER` -- The username to use to connect to the database.
* `PGPASSWORD` -- The password to use for the username.
* `WEBBENCH_PORT` -- The port that the server should attach to.

Deploying the Servers
----------------------

Each implementation must contain an `dependencies.sh` script that performs the necessary installation
of dependencies on an Ubuntu server.  It should also provide an `run.sh` script which actually runs the server, assuming
`dependencies.sh` has been previously executed as the same user.

Help Wanted
=================

We are looking for the following implementations:

* Python 3
  * Wheezy
  * Bottle
  * (We don't want Flask, because the other two seem to reliably outperform it.)
* Go
  * ??? (What do Go folks use for REST API webservers?)

We are also looking to implement the following extensions:

* Improved scripting of executing tests, including building up and tearing down test environments.
* SQL injection attacks launched by the client code before the tests are executed.

Inspiration
==============

We are digging at the same spot as [the TechEmpower benchmarks](https://www.techempower.com/benchmarks/), with three key differences:

1. We are not concerned about how fast a single server can return results, but how well the server handles under load.
2. We are looking into the case with highly constrained resources, as well as the scalability of servers with constrained resources.
3. Our analysis is based on the financial cost and client experience during these benchmarks, not the raw performance characteristics.


text:
This is an experimental clang provider for Atom's autocomplete-plus. This has a few assumptions for objective c.

## Clang notes

`clang` supports a command line arg named `-code-completion-at` where you can pass a row and column, and get contextual completions back.

```bash
clang -fsyntax-only -xobjective-c -Xclang -code-completion-at=MyFile.m:20:2 -include-pch test.pch -I. MyFile.m
```

And it will return a bunch of lines of potential completions:

```
COMPLETION: abortEditing : [#BOOL#]abortEditing
COMPLETION: acceptsFirstMouse: : [#BOOL#]acceptsFirstMouse:<#(NSEvent *)#>
COMPLETION: acceptsFirstResponder : [#BOOL#]acceptsFirstResponder
COMPLETION: acceptsTouchEvents : [#BOOL#]acceptsTouchEvents
COMPLETION: accessibilityActionDescription: : [#NSString *#]accessibilityActionDescription:<#(NSString *)#>
COMPLETION: accessibilityActionNames : [#NSArray *#]accessibilityActionNames
COMPLETION: accessibilityArrayAttributeCount: : [#NSUInteger#]accessibilityArrayAttributeCount:<#(NSString *)#>
COMPLETION: accessibilityArrayAttributeValues:index:maxCount: : [#NSArray *#]accessibilityArrayAttributeValues:<#(NSString *)#> index:<#(NSUInteger)#> maxCount:<#(NSUInteger)#>
```

Clang returns _all_ potential completions for a symbol. Consider the following code:

```objc
@implementation SomeButton

- (NSString*)myFunc:(NSPoint)aPoint {
  [self some|]; // << pretend our cursor is at the pipe; position [4, 13]
}

@end
```

Clang doesnt do context or filtering. So, while the cursor is at `[4, 13]`, to get all the completions for `self` we will need to pass clang position `[4, 8]`, then filter the entire list by the prefix: `some` in this case.

If it does not have a valid symbol to provide context, it will return _all_ available global symbols.

### Pre compiled headers

For this provider to work reasonably well, you currently need to make your own pre compiled header and put it at `test.pch`. For an objective c app, save a file with the following:

```objc
#import <Cocoa/Cocoa.h>
#import <SystemConfiguration/SystemConfiguration.h>
```

And run

```
clang -xobjective-c-header -Xclang -emit-pch -o test.pch -I. myfile.h
```


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TypeMock.ArrangeActAssert;

namespace Nucleo.Web.ButtonControls
{
	[TestClass]
	public class ButtonListTest
	{
		#region " Tests "

		[TestMethod]
		public void ChangingButtonGroupVisibilityWorksOK()
		{
			//Arrange
			var list = Isolate.Fake.Instance<ButtonList>();

			//Act

			//Assert

		}

		#endregion
	}
}


text:
Rails.application.routes.draw do

  mount ReusableContainers::Engine => "/reusable_containers"
end


text:
<?php

// autoload.php @generated by Composer

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInit267ce2067ad105f19515331a51d22b82::getLoader();


text:
import django_filters
from msz.market.models import Category, Product, HomePic

class CategoryFilter(django_filters.FilterSet):
    code = django_filters.CharFilter(name="code", lookup_type="icontains")
    name = django_filters.CharFilter(name="name", lookup_type="icontains")

    class Meta:
        model = Category
        fields = ('code', 'name')

class ProductFilter(django_filters.FilterSet):
    code = django_filters.CharFilter(name="code", lookup_type="icontains")
    name = django_filters.CharFilter(name="name", lookup_type="icontains")

    class Meta:
        model = Product
        fields = ('name', 'code')

class HomePicFilter(django_filters.FilterSet):

    class Meta:
        model = HomePic
        fields = ('name', )


text:
import mustSatisfy from '../checks/mustSatisfy';
import isInteger from '../checks/isInteger';

/**
 * @hidden
 */
function beAnInteger() {
    return "be an integer";
}

/**
 * @hidden
 */
export default function mustBeInteger(name: string, value: number, contextBuilder?: () => string): number {
    mustSatisfy(name, isInteger(value), beAnInteger, contextBuilder);
    return value;
}


text:
PretrainedModel::PretrainedModel()
    : CaffeData(), d(new PretrainedModelObject())
{
    CaffeData::setDataType(className<PretrainedModel>());  // data type name
}

PretrainedModel::PretrainedModel(const PretrainedModel &other)
    : CaffeData(other), d(new PretrainedModelObject(*other.d))
{ }

// PretrainedModel::PretrainedModel(const PretrainedModelObject &object)
//     : CaffeData(), d(new PretrainedModelObject(object))
// { }

PretrainedModel::~PretrainedModel()
{
    // If the reference count becomes 0,
    // the shared data object 'PretrainedModelObject' is deleted.
}

// QString PretrainedModel::id() const
// {
//     return d->id;
// }

// void PretrainedModel::setId(const QString &id)
// {
//     d->id = id;
// }

QString PretrainedModel::caffeModelId() const
{
    return d->caffe_model_id;
}

void PretrainedModel::setCaffeModelId(const QString &caffeModelId)
{
    d->caffe_model_id = caffeModelId;
}

QString PretrainedModel::pretrainedModelFile() const
{
    return d->pretrained_model_file;
}

void PretrainedModel::setPretrainedModelFile(const QString &pretrainedModelFile)
{
    d->pretrained_model_file = pretrainedModelFile;
}

PretrainedModel &PretrainedModel::operator=(const PretrainedModel &other)
{
    CaffeData::operator=(other);
    d = other.d;  // increments the reference count of the data
    return *this;
}

// PretrainedModel PretrainedModel::create(const QString &id, const QString &caffeModelId, const QString &pretrainedModelFile)
// {
//     PretrainedModelObject obj;
//     obj.id = id;
//     obj.caffe_model_id = caffeModelId;
//     obj.pretrained_model_file = pretrainedModelFile;
//     if (!obj.create()) {
//         return PretrainedModel();
//     }
//     return PretrainedModel(obj);
// }

bool PretrainedModel::create()
{
    for (;;) {
        setId(QString::number(QDateTime::currentDateTime().toMSecsSinceEpoch()));
        QDir dir(dirPath());
        if (! dir.exists()) {
            dir.mkpath(".");
            break;
        }
        Tf::msleep(5);
    }
    return update();
}

PretrainedModel PretrainedModel::create(const QVariantMap &values)
{
    PretrainedModel model;
    model.setProperties(values);
    if (! model.create()) {
        model.d->clear();
    }
    return model;
}

bool PretrainedModel::update()
{
    if (id().isEmpty()) {
        return false;
    }

    // json
    auto values = toVariantMap();
    values.unite(CaffeData::toVariantMap());
    CaffeData::setDataType(className<PretrainedModel>());  // data type name
    writeJson(jsonFilePath(), values);
    return true;
}

bool PretrainedModel::save()
{
    return (id().isEmpty()) ? create() : update();
}

void PretrainedModel::clear()
{
    CaffeData::clear();
    d->clear();
}

PretrainedModel PretrainedModel::get(const QString &id)
{
    return CaffeData::get<PretrainedModel>(id);
}

QList<PretrainedModel> PretrainedModel::getAll()
{
    return CaffeData::getAll<PretrainedModel>();
}

// QJsonArray PretrainedModel::getAllJson()
// {
//     QJsonArray array;
//     TSqlORMapper<PretrainedModelObject> mapper;

//     if (mapper.find() > 0) {
//         for (TSqlORMapperIterator<PretrainedModelObject> i(mapper); i.hasNext(); ) {
//             array.append(QJsonValue(QJsonObject::fromVariantMap(PretrainedModel(i.next()).toVariantMap())));
//         }
//     }
//     return array;
// }

void PretrainedModel::setProperties(const QVariantMap &properties)
{
    CaffeData::setProperties(properties);
    TAbstractModel::setProperties(properties);
}

QVariantMap PretrainedModel::toVariantMap() const
{
    auto ret = CaffeData::toVariantMap().unite(TAbstractModel::toVariantMap());
    return ret;
}

TModelObject *PretrainedModel::modelData()
{
    return d.data();
}

const TModelObject *PretrainedModel::modelData() const
{
    return d.data();
}

QDataStream &operator<<(QDataStream &ds, const PretrainedModel &model)
{
    auto varmap = model.toVariantMap();
    ds << varmap;
    return ds;
}

QDataStream &operator>>(QDataStream &ds, PretrainedModel &model)
{
    QVariantMap varmap;
    ds >> varmap;
    model.setProperties(varmap);
    return ds;
}

// Don't remove below this line
T_REGISTER_STREAM_OPERATORS(PretrainedModel)