text:
package alluxio.exception.runtime;

import alluxio.grpc.ErrorType;

import io.grpc.Status;

/**
 * Exception indicating that an operation is not implemented or not supported/enabled in this
 * service.
 */
public class UnimplementedRuntimeException extends AlluxioRuntimeException {
  private static final ErrorType ERROR_TYPE = ErrorType.Internal;
  private static final Status STATUS = Status.UNIMPLEMENTED;
  private static final boolean RETRYABLE = false;

  /**
   * Constructor.
   *
   * @param t         cause
   * @param errorType error type
   */
  public UnimplementedRuntimeException(Throwable t, ErrorType errorType) {
    super(STATUS, t.getMessage(), t, errorType, RETRYABLE);
  }

  /**
   * Constructor.
   * @param message error message
   */
  public UnimplementedRuntimeException(String message) {
    super(STATUS, message, null, ERROR_TYPE, RETRYABLE);
  }
}

redpajama_set_name: RedPajamaGithub


text:
/* IPOLICE_FLAGS: DONT_REMOVE */

#ifndef _RTPP_DEBUG_H_
#define _RTPP_DEBUG_H_

#define RTPP_DBG_YES	1
#define RTPP_DBG_NO	0

#if defined(RTPP_DEBUG)
# if defined(RTPP_DEBUG_MAX)
/* Supported levels 0, 1, 2. 1 - basic debug & debug when I/O fails, */
/*  2 - debug on every packet                                        */
#  define RTPP_DEBUG_netio      2
/* Supported levels 0, 1. */
#  define RTPP_DEBUG_timers     1
/* Catch fatal signals and try to pring backtrace */
/* Supported levels 0, 1. */
#  define RTPP_DEBUG_catchtrace 1
/* Supported levels 0, 1. */
#  define RTPP_DEBUG_refcnt     1
/* Supported levels 0, 1. */
#  define RTPP_DEBUG_analyze    1
# else /* !RTPP_DEBUG_MAX */
#  define RTPP_DEBUG_netio      RTPP_DBG_YES
#  define RTPP_DEBUG_timers     RTPP_DBG_NO
#  define RTPP_DEBUG_catchtrace RTPP_DBG_NO
#  define RTPP_DEBUG_refcnt     RTPP_DBG_NO
#  define RTPP_DEBUG_analyze    RTPP_DBG_NO
# endif /* RTPP_DEBUG_MAX */
#else /* !RTPP_DEBUG */
# define RTPP_DEBUG_netio       RTPP_DBG_NO
# define RTPP_DEBUG_timers      RTPP_DBG_NO
# define RTPP_DEBUG_catchtrace  RTPP_DBG_NO
# define RTPP_DEBUG_refcnt      RTPP_DBG_NO
# define RTPP_DEBUG_analyze     RTPP_DBG_NO
#endif

#if defined(RTPP_DEBUG)
#include <assert.h>

#define RTPP_DBG_ASSERT(...)  assert(__VA_ARGS__)
#else
#define RTPP_DBG_ASSERT(...)
#endif

#endif


text:
package com.eagle.programmar.HTML.Terminals;

import com.eagle.tokens.TerminalPunctuationToken;

public class HTML_Punctuation extends TerminalPunctuationToken
{
	// Need default constructor for reading from the XML file
	public HTML_Punctuation()
	{
		this('\0');
	}

	public HTML_Punctuation(char punct)
	{
		super(punct);
	}

	public HTML_Punctuation(String punct)
	{
		super(punct);
	}
}


text:
@import 'https://cdn.checkout.com/v2/css/cko-fonts-jsicons.css?v=1.1.9';

/**
 * Card payment
 */
.frames-container {
    margin-bottom: 15px;
    max-width: 650px;
    position: relative;
    z-index: 1;
}

.save-card-option {
    margin-bottom: 10px;
}

.clr {
    clear: both;
    visibility: hidden;
    height: 0px;
    width: 0px;
}

/**
 * Agreement
 */

.checkout-agreement label {
    background-image: url(../images/icon-link.png);
    background-repeat: no-repeat;
    background-position: top right;
    padding-right: 20px;
    background-size: 13px 13px;
}

.message.notice {
    overflow-wrap: break-word;
}


text:
namespace AsterNET.Manager.Action
{
    /// <summary>
    ///     The HangupAction causes the pbx to hang up a given channel.
    /// </summary>
    public class HangupAction : ManagerAction
    {
        /// <summary>
        ///     Creates a new empty HangupAction.
        /// </summary>
        public HangupAction()
        {
        }

        /// <summary>
        ///     Creates a new HangupAction that hangs up the given channel.
        /// </summary>
        /// <param name="channel">the name of the channel to hangup.</param>
        public HangupAction(string channel)
        {
            Channel = channel;
        }

        /// <summary>
        ///     Get the name of this action, i.e. "Hangup".
        /// </summary>
        public override string Action
        {
            get { return "Hangup"; }
        }

        /// <summary>
        ///     Get/Set the name of the channel to hangup.
        /// </summary>
        public string Channel { get; set; }
    }
}


text:
var fs = require("fs");
var js2xmlparser = require("js2xmlparser");
console.log("Started reading a file");

fs.exists('./'+'source.json', function (exists)
            {
                if (exists)
                {
                    //read the json file
                    fs.readFile("source.json", function(error, data) {
                        console.log("Content of file: " + data);
                      //parse the received data into json object

                      try
                      {
                        var studentObject = JSON.parse(data);

                        //converting the object into xml
                      var xmlData = js2xmlparser("students", studentObject);

                        console.log("xmlData: "+xmlData);

                        //writting xml date to a xml file
                        fs.writeFile("destination.xml", xmlData, function(error, data) {
                            console.log("Wrote to the file");
                        });

                        console.log("finished executing");

                    }
                    catch(e)
                    {
                      console.log("Not a valid json source");
                    }

                  });

                }
                else
                {
                  console.log('source.json file does not exist');
                }
        });


text:
package hu.mentlerd.hybrid.compiler;

/*
** structure to chain all variables in the left-hand side of an
** assignment
*/
/**
 * @exclude
 */
public class LHS_assign {
	LHS_assign prev;
	/* variable (global, local, upvalue, or indexed) */
	ExpDesc v = new ExpDesc();
}


text:
import { Fragment, ReactNode } from 'react';
import { connect } from 'react-redux';

import { ENV } from '@waldur/configs/default';
import { RootState } from '@waldur/store/reducers';

import { DOMAIN_MESSAGES } from './constants';
import { LanguageUtilsService } from './LanguageUtilsService';
import { Translate, TranslateProps } from './types';

export const formatJsxTemplate = (template, context) => {
  if (!context) {
    return template;
  }
  return (
    <Fragment>
      {template.split(/\{|\}/g).map((part, index) => (
        <Fragment key={index}>
          {index % 2 === 0 ? part : context[part]}
        </Fragment>
      ))}
    </Fragment>
  );
};

export const formatJsx = (
  template: string,
  context: Record<string, (s: string) => ReactNode>,
) => {
  const pattern = /<([^>]+)>([^<]*)<\/([^>]+)>/g;
  const parts = [];
  let matches,
    prevIndex = 0;
  while ((matches = pattern.exec(template)) !== null) {
    parts.push(template.substring(prevIndex, matches.index));
    parts.push(context[matches[1]](matches[2]));
    prevIndex = matches[0].length + matches.index;
  }
  if (prevIndex !== template.length) {
    parts.push(template.substring(prevIndex));
  }
  return (
    <Fragment>
      {parts.map((part, index) => (
        <Fragment key={index}>{part}</Fragment>
      ))}
    </Fragment>
  );
};

export const formatTemplate: Translate = (template, context) =>
  context ? template.replace(/{(.+?)}/g, (_, key) => context[key]) : template;

export const translateTemplate = (template) =>
  LanguageUtilsService.dictionary[template] || template;

const getDomainMessage = (message) => {
  const domain = ENV.plugins?.WALDUR_CORE?.TRANSLATION_DOMAIN;
  if (!domain) {
    return message;
  }
  if (!DOMAIN_MESSAGES[domain]) {
    return message;
  }
  return DOMAIN_MESSAGES[domain][message] || message;
};

export const translate: Translate = (
  template,
  context,
  interpolator = formatTemplate,
) => interpolator(translateTemplate(getDomainMessage(template)), context);

export const getLocale = (state: RootState) => ({
  locale: state.locale,
  translate,
});

export const withTranslation = connect<TranslateProps>(getLocale);


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Empresa extends CI_Controller {

	public function __construct() {
		parent::__construct();
		$this->load->helper('url');
		$this->load->model("empresa_model");
	}
	public function index(){
		if (!$this->ion_auth->logged_in()){
			$this->session->set_flashdata('message', 'Necessário está logado para ter acesso a essa página');
			redirect('auth/login');
		}else{
			if (!$this->ion_auth->is_admin()){
				$this->session->set_flashdata('message', 'Você deve ser um administrador para visualizar esta página');
				redirect('welcome/index');
			}else{
				//$this->template->load('orion/template', 'orion/index.html');
				$data['empresas']=$this->empresa_model->listar();
				$this->load->view('empresa/index',$data);
			}
		}
	}

	public function cadastrar() {
		if (!$this->ion_auth->logged_in()){
			$this->session->set_flashdata('message', 'Necessário está logado para ter acesso a essa página');
			redirect('auth/login');
		}else{
			if (!$this->ion_auth->is_admin()){
				$this->session->set_flashdata('message', 'Você deve ser um administrador para visualizar esta página');
				redirect('welcome/index');
			}else{
				$this->_validate();
		        $empresa = array(
						'emp_rz_social' => $this->input->post('emp_rz_social'),
						'emp_nm_fantasia' => $this->input->post('emp_nm_fantasia'),
						'emp_cnpj' => $this->input->post('emp_cnpj')
						);
				$insert = $this->empresa_model->cadastrar($empresa);
				echo json_encode(array("status" => TRUE));
			}
		}
    }
    public function ajax_edit($id){
    	if (!$this->ion_auth->logged_in()){
			$this->session->set_flashdata('message', 'Necessário está logado para ter acesso a essa página');
			redirect('auth/login');
		}else{
			if (!$this->ion_auth->is_admin()){
				$this->session->set_flashdata('message', 'Você deve ser um administrador para visualizar esta página');
				redirect('welcome/index');
			}else{
				$data = $this->empresa_model->getEmpresa($id);
				echo json_encode($data);
			}
		}
	}
	public function empresa_update(){
		if (!$this->ion_auth->logged_in()){
			$this->session->set_flashdata('message', 'Necessário está logado para ter acesso a essa página');
			redirect('auth/login');
		}else{
			if (!$this->ion_auth->is_admin()){
				$this->session->set_flashdata('message', 'Você deve ser um administrador para visualizar esta página');
				redirect('welcome/index');
			}else{
				$this->_validate();
				$empresa = array(
						'emp_rz_social' => $this->input->post('emp_rz_social'),
						'emp_nm_fantasia' => $this->input->post('emp_nm_fantasia'),
						'emp_cnpj' => $this->input->post('emp_cnpj')
						);
				$this->empresa_model->empresa_update(array('emp_id' => $this->input->post('emp_id')), $empresa);
				echo json_encode(array("status" => TRUE));
			}
		}
	}

	public function empresa_delete($id){
		if (!$this->ion_auth->logged_in()){
			$this->session->set_flashdata('message', 'Necessário está logado para ter acesso a essa página');
			redirect('auth/login');
		}else{
			if (!$this->ion_auth->is_admin()){
				$this->session->set_flashdata('message', 'Você deve ser um administrador para visualizar esta página');
				redirect('welcome/index');
			}else{
				$this->empresa_model->delete_by_id($id);
				echo json_encode(array("status" => TRUE));
			}
		}
	}
	public function lista_empresa_json(){
		if (!$this->ion_auth->logged_in()){
			$this->session->set_flashdata('message', 'Necessário está logado para ter acesso a essa página');
			redirect('auth/login');
		}else{
			if (!$this->ion_auth->is_admin()){
				$this->session->set_flashdata('message', 'Você deve ser um administrador para visualizar esta página');
				redirect('welcome/index');
			}else{
		        $data = $this->empresa_model->listar();
		        echo json_encode($data);
		    }
		}
    }
    private function _validate(){
        $data = array();
        $data['error_string'] = array();
        $data['inputerror'] = array();
        $data['status'] = TRUE;

        if($this->input->post('emp_rz_social') == ''){
            $data['inputerror'][] = 'emp_rz_social';
            $data['error_string'][] = 'Razão Social é obrigatoria';
            $data['status'] = FALSE;
        }

        if($data['status'] === FALSE){
            echo json_encode($data);
            exit();
        }
    }

}


text:
<?php
 /* CAT:Labels */

 /* pChart library inclusions */
 include("../class/pData.class.php");
 include("../class/pDraw.class.php");
 include("../class/pImage.class.php");
 include("../class/pBubble.class.php");

 /* Create and populate the pData object */
 $MyData = new pData();
 $MyData->loadPalette("../palettes/blind.color",TRUE);
 $MyData->addPoints(array(34,55,15,62,38,42),"Probe1");
 $MyData->addPoints(array(5,10,8,9,15,10),"Probe1Weight");
 $MyData->addPoints(array(5,10,-5,-1,0,-10),"Probe2");
 $MyData->addPoints(array(6,10,14,10,14,6),"Probe2Weight");
 $MyData->setSerieDescription("Probe1","This year");
 $MyData->setSerieDescription("Probe2","Last year");
 $MyData->setAxisName(0,"Current stock");
 $MyData->addPoints(array("Apple","Banana","Orange","Lemon","Peach","Strawberry"),"Product");
 $MyData->setAbscissa("Product");

 /* Create the pChart object */
 $myPicture = new pImage(700,230,$MyData);

 /* Draw the background */
 $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
 $myPicture->drawFilledRectangle(0,0,700,230,$Settings);

 /* Overlay with a gradient */
 $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
 $myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings);
 $myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));

 /* Add a border to the picture */
 $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));

 /* Write the picture title */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6));
 $myPicture->drawText(10,13,"drawBubbleChart() - draw a linear bubble chart",array("R"=>255,"G"=>255,"B"=>255));

 /* Write the title */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));
 $myPicture->drawText(40,55,"Current Stock / Needs chart",array("FontSize"=>14,"Align"=>TEXT_ALIGN_BOTTOMLEFT));

 /* Change the default font */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));

 /* Create the Bubble chart object and scale up */
 $myBubbleChart = new pBubble($myPicture,$MyData);

 /* Scale up for the bubble chart */
 $bubbleDataSeries   = array("Probe1","Probe2");
 $bubbleWeightSeries = array("Probe1Weight","Probe2Weight");
 $myBubbleChart->bubbleScale($bubbleDataSeries,$bubbleWeightSeries);

 /* Draw the 1st chart */
 $myPicture->setGraphArea(40,60,430,190);
 $myPicture->drawFilledRectangle(40,60,430,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-50,"Alpha"=>10));
 $myPicture->drawScale(array("DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE));
 $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
 $myBubbleChart->drawBubbleChart($bubbleDataSeries,$bubbleWeightSeries);

 /* Write a label over the chart */
 $LabelSettings = array("TitleMode"=>LABEL_TITLE_BACKGROUND,"VerticalMargin"=>4,"HorizontalMargin"=>6,"DrawSerieColor"=>FALSE,"TitleR"=>255,"TitleG"=>255,"TitleB"=>255);
 $myBubbleChart->writeBubbleLabel("Probe1","Probe1Weight",3,$LabelSettings);
 $myBubbleChart->writeBubbleLabel("Probe2","Probe2Weight",4,$LabelSettings);

 /* Draw the 2nd scale */
 $myPicture->setShadow(FALSE);
 $myPicture->setGraphArea(500,60,670,190);
 $myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
 $myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE));

 /* Draw the 2nd bubble chart */
 $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
 $myBubbleChart->drawbubbleChart($bubbleDataSeries,$bubbleWeightSeries,array("DrawBorder"=>TRUE,"Surrounding"=>60,"BorderAlpha"=>100));

 /* Write a label over the chart */
 $myBubbleChart->writeBubbleLabel("Probe1","Probe1Weight",4,$LabelSettings);

 /* Write the chart legend */
 $myPicture->drawLegend(550,215,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

 /* Render the picture (choose the best way) */
 $myPicture->autoOutput("pictures/example.drawLabel.bubble.png");
?>


text:
using System.Collections.Generic;

namespace RememBeer.Models.Contracts
{
    public interface IBrewery : IIdentifiable
    {
        string Name { get; set; }

        string Description { get; set; }

        string Country { get; set; }

        ICollection<Beer> Beers { get; set; }
    }
}


text:
#ifndef _MAXIM_GATT_SERVER_H_
#define _MAXIM_GATT_SERVER_H_

#include <stddef.h>

#include "ble/blecommon.h"
#include "ble/GattServer.h"
#include "wsf_types.h"
#include "att_api.h"

class MaximGattServer : public GattServer
{
public:
    static MaximGattServer &getInstance();

    /* Functions that must be implemented from GattServer */
    virtual ble_error_t addService(GattService &);

    virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
    virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
    virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
    virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);

    virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP);
    virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP);

    virtual bool isOnDataReadAvailable() const { return true; }

private:
    static void cccCback(attsCccEvt_t *pEvt);
    static void attCback(attEvt_t *pEvt);
    static uint8_t attsReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr);
    static uint8_t attsWriteCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr);

    /*! client characteristic configuration descriptors settings */
    #define MAX_CCC_CNT 20
    attsCccSet_t cccSet[MAX_CCC_CNT];
    uint16_t cccValues[MAX_CCC_CNT];
    uint16_t cccHandles[MAX_CCC_CNT];
    uint8_t cccCnt;

private:
    MaximGattServer() : GattServer(), cccSet(), cccValues(), cccHandles(), cccCnt(0) {
        /* empty */
    }

    MaximGattServer(const MaximGattServer &);
    const MaximGattServer& operator=(const MaximGattServer &);
};

#endif /* _MAXIM_GATT_SERVER_H_ */


text:
use std::ffi::CString;
use std::io::{Error, ErrorKind};
use std::io::prelude::*;
use std::net::TcpStream;

use super::Packet;
use super::PacketType::{SERVERDATA_AUTH, SERVERDATA_EXECCOMMAND};
use super::PacketDirection::INCOMING;

const INVALID_RCON_ID: i32 = -1;

#[derive(Debug)]
pub struct Connection {
    packet_id: i32,
    connection: TcpStream
}

impl Connection {
    pub fn new(hostname: &str, rcon_password: &str) -> Result<Connection, Error> {
        let mut stream = TcpStream::connect(hostname)?;

        let auth_packet = Packet {
            id: 0,
            net_type: SERVERDATA_AUTH,
            body: CString::new(rcon_password).unwrap(),
        };
        stream.write(&auth_packet.serialize())?;

        // Somehow srcds returns us SERVERDATA_RESPONSE_VALUE first
        // we probably can safely ignore it
        let _ = Packet::read_from(&mut stream, INCOMING)?;

        let auth_packet_response = Packet::read_from(&mut stream, INCOMING)?;
        if auth_packet_response.id == INVALID_RCON_ID {
            Err(Error::new(
                ErrorKind::PermissionDenied,
                "invalid rcon password",
            ))
        } else {
            Ok(Connection {
                packet_id: 1,
                connection: stream
            })
        }
    }

    pub fn send_command(&mut self, command: &str) -> Result<CString, Error> {
        let cmd = CString::new(command)?;
        let command_packet = Packet {
            id: 1,
            net_type: SERVERDATA_EXECCOMMAND,
            body: cmd
        };

        self.connection.write(&command_packet.serialize())?;
        let response_body = Packet::read_from(&mut self.connection, INCOMING)?.body;
        Ok(response_body)
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use std::thread;
    use std::net::TcpListener;
    use std::error::Error;

    use super::super::PacketType::SERVERDATA_AUTH_RESPONSE;
    use super::super::PacketDirection::OUTCOMING;

    const VALID_RCON_PASSWORD: &str = "somespecialrconpassword";
    const INVALID_RCON_PASSWORD: &str = "somenonspecialrconpassword";

    fn local_tcp_server() -> (TcpListener, String) {
        loop {
            let bind_result = TcpListener::bind("127.0.0.1:0");

            if let Err(_) = bind_result {
                continue;
            }

            let listener = bind_result.unwrap();
            let listen_port = listener.local_addr().unwrap().port();
            let hostname = format!("127.0.0.1:{}", listen_port);
            break (listener, hostname)
        }
    }

    #[test]
    fn test_new_success() {
        let (listener, hostname) = local_tcp_server();

        let _t = thread::spawn(move || {
            let _ = Connection::new(&hostname, VALID_RCON_PASSWORD);
        });

        let (mut stream, _) = listener.accept().unwrap();
        let connection_packet = Packet::read_from(&mut stream, INCOMING).unwrap();

        assert_eq!(connection_packet.id, 0);
        assert_eq!(connection_packet.net_type, SERVERDATA_AUTH);
        assert_eq!(
            connection_packet.body.to_str().unwrap(),
            VALID_RCON_PASSWORD
        );
    }

    #[test]
    fn test_new_fail_rcon() {
        let (listener, hostname) = local_tcp_server();

        let _t = thread::spawn(move || {
            let (mut stream, _) = listener.accept().unwrap();

            // empty auth packet
            let empty_response_packet = Packet {
                id: INVALID_RCON_ID,
                net_type: SERVERDATA_AUTH_RESPONSE,
                body: CString::new("").unwrap(),
            };

            let failed_rcon_packet = Packet {
                id: INVALID_RCON_ID,
                net_type: SERVERDATA_AUTH_RESPONSE,
                body: CString::new("").unwrap(),
            };

            let mut combined_packets = empty_response_packet.serialize();
            combined_packets.extend(failed_rcon_packet.serialize());
            stream.write(&combined_packets).unwrap();
        });

        match Connection::new(&hostname, INVALID_RCON_PASSWORD) {
            Ok(_) => panic!(),
            Err(e) => {
                assert_eq!(e.description(), "invalid rcon password");
                assert_eq!(e.kind(), ErrorKind::PermissionDenied);
            }
        }
    }

    #[test]
    fn test_send_command_success() {
        const RCON_COMMAND: &str = "echo 123";
        let (listener, hostname) = local_tcp_server();

        let t = thread::spawn(move || {
            let mut connection = Connection::new(&hostname, VALID_RCON_PASSWORD).unwrap();
            match connection.send_command(RCON_COMMAND) {
                Err(_) => panic!(),
                Ok(s) => assert_eq!("123", s.to_str().unwrap())
            }
        });

        let (mut stream, _) = listener.accept().unwrap();

        // empty auth packet
        let empty_response_packet = Packet {
            id: INVALID_RCON_ID,
            net_type: SERVERDATA_AUTH_RESPONSE,
            body: CString::new("").unwrap(),
        };

        // Send success to connection
        let success_auth_packet = Packet {
            id: 0,
            net_type: SERVERDATA_AUTH_RESPONSE,
            body: CString::new("").unwrap(),
        };

        let mut combined_packets = empty_response_packet.serialize();
        combined_packets.extend(success_auth_packet.serialize());
        stream.write(&combined_packets).unwrap();

        // Drop auth packet
        Packet::read_from(&mut stream, OUTCOMING).unwrap();

        // Check if incoming command packet is correct
        let command_packet = Packet::read_from(&mut stream, OUTCOMING).unwrap();

        assert_eq!(command_packet.id, 1);
        assert_eq!(command_packet.net_type, SERVERDATA_EXECCOMMAND);
        assert_eq!(
            command_packet.body.to_str().unwrap(),
            RCON_COMMAND
        );

        // and send command execution response
        let success_auth_packet = Packet {
            id: 3,
            net_type: SERVERDATA_AUTH_RESPONSE,
            body: CString::new("123").unwrap(),
        };
        stream.write(&success_auth_packet.serialize()).unwrap();

        t.join().unwrap();
    }

    #[test]
    fn test_send_command_fail_server_closed_connection() {
        const RCON_COMMAND: &str = "echo 123";
        let (listener, hostname) = local_tcp_server();

        let _t = thread::spawn(move || {
            let (mut stream, _) = listener.accept().unwrap();

            // empty auth packet
            let empty_response_packet = Packet {
                id: INVALID_RCON_ID,
                net_type: SERVERDATA_AUTH_RESPONSE,
                body: CString::new("").unwrap(),
            };

            // Send success to connection
            let success_auth_packet = Packet {
                id: 0,
                net_type: SERVERDATA_AUTH_RESPONSE,
                body: CString::new("").unwrap(),
            };

            let mut combined_packets = empty_response_packet.serialize();
            combined_packets.extend(success_auth_packet.serialize());
            stream.write(&combined_packets).unwrap();
        });

        let mut connection = Connection::new(&hostname, VALID_RCON_PASSWORD).unwrap();
        if let Ok(_) = connection.send_command(RCON_COMMAND) {
            panic!()
        }
    }
}


text:
package team111;

import battlecode.common.Clock;
import battlecode.common.Direction;
import battlecode.common.MapLocation;
import battlecode.common.RobotController;
import battlecode.common.RobotInfo;
import battlecode.common.RobotType;

public class Launcher extends Mobile {

	static int last_fired = Clock.getRoundNum();

	public Launcher(RobotController rc) {
		super(rc);
	}

	public MapLocation get_default_location(){
		aggressive = 0;
		MapLocation[] the_towers = robot_controller.senseTowerLocations();
		if(the_towers.length < 1)
			the_towers = new MapLocation[] {HQ_location};
		return Utilities.find_closest(enemy_HQ_Location,the_towers).add(HQ_location.directionTo(enemy_HQ_Location),1);
	}

	public boolean attack_deadest_enemy_in_range(){
		if(Clock.getRoundNum()%2 ==0)
			return false;
		int attack_pos = 0;
		int attack_radius = 63;
		RobotInfo[] close_enemies = robot_controller.senseNearbyRobots(attack_radius, enemy_team);
		if(close_enemies.length < 1)
			return false;
		if(close_enemies.length > 0){
			int num_of_loops = close_enemies.length;
			double enemy_health = 9999;

			for(int i=0; i< num_of_loops;i++){
			//	if(close_enemies[i].health <= enemy_health || close_enemies[i].type == RobotType.MISSILE){
				if(close_enemies[i].health <= enemy_health && close_enemies[i].type != RobotType.MISSILE){
					if(robot_controller.getLocation().distanceSquaredTo(close_enemies[i].location) > 4){
						enemy_health = close_enemies[i].health;
						attack_pos = i;
					}
				}
			}
		}
		MapLocation target_location = location;
		if(close_enemies.length > 0){
			target_location = close_enemies[attack_pos].location;
		}
		if(robot_controller.getLocation().distanceSquaredTo(target_location) > 63)
			return false;
		try{
			Direction initial_direction = robot_controller.getLocation().directionTo(target_location);
			if(robot_controller.canLaunch(initial_direction)){
				robot_controller.launchMissile(initial_direction);
				last_fired = Clock.getRoundNum();
				//turn 1
				MapLocation missile_location = robot_controller.getLocation().add(initial_direction);
				Direction direction_to_head = missile_location.directionTo(target_location);
		//		System.out.println("Turn1: " + direction_to_head);
				send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
				//turn 2
				missile_location = missile_location.add(direction_to_head);
				direction_to_head = missile_location.directionTo(target_location);
				if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
					direction_to_head = initial_direction;
		//		System.out.println("Turn2: " + direction_to_head);
				send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
				//turn 3
				missile_location = missile_location.add(direction_to_head);
				direction_to_head = missile_location.directionTo(target_location);
				if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
					direction_to_head = initial_direction;
			//	System.out.println("Turn3: " + direction_to_head);
				send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
				//turn 4
				missile_location = missile_location.add(direction_to_head);
				direction_to_head = missile_location.directionTo(target_location);
				if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
					direction_to_head = initial_direction;
			//	System.out.println("Turn4: " + direction_to_head);
				send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
				//turn 5
				missile_location = missile_location.add(direction_to_head);
				direction_to_head = missile_location.directionTo(target_location);
				if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
					direction_to_head = initial_direction;
			//	System.out.println("Turn5: " + direction_to_head);
				send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
			}
				initial_direction = initial_direction.rotateLeft();
				if(robot_controller.canLaunch(initial_direction)){
					robot_controller.launchMissile(initial_direction);
					last_fired = Clock.getRoundNum();
					//turn 1
					MapLocation  missile_location = robot_controller.getLocation().add(initial_direction);
					Direction direction_to_head = missile_location.directionTo(target_location);
			//		System.out.println("Turn1: " + direction_to_head);
					send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
					//turn 2
					missile_location = missile_location.add(direction_to_head);
					direction_to_head = missile_location.directionTo(target_location);
					if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
						direction_to_head = initial_direction;
			//		System.out.println("Turn2: " + direction_to_head);
					send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
					//turn 3
					missile_location = missile_location.add(direction_to_head);
					direction_to_head = missile_location.directionTo(target_location);
					if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
						direction_to_head = initial_direction;
				//	System.out.println("Turn3: " + direction_to_head);
					send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
					//turn 4
					missile_location = missile_location.add(direction_to_head);
					direction_to_head = missile_location.directionTo(target_location);
					if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
						direction_to_head = initial_direction;
				//	System.out.println("Turn4: " + direction_to_head);
					send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
					//turn 5
					missile_location = missile_location.add(direction_to_head);
					direction_to_head = missile_location.directionTo(target_location);
					if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
						direction_to_head = initial_direction;
				//	System.out.println("Turn5: " + direction_to_head);
					send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
				}
					initial_direction= initial_direction.rotateRight().rotateRight();
					if(robot_controller.canLaunch(initial_direction)){
						robot_controller.launchMissile(initial_direction);
						last_fired = Clock.getRoundNum();
						//turn 1
						MapLocation missile_location = robot_controller.getLocation().add(initial_direction);
						Direction direction_to_head = missile_location.directionTo(target_location);
				//		System.out.println("Turn1: " + direction_to_head);
						send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
						//turn 2
						missile_location = missile_location.add(direction_to_head);
						direction_to_head = missile_location.directionTo(target_location);
						if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
							direction_to_head = initial_direction;
				//		System.out.println("Turn2: " + direction_to_head);
						send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
						//turn 3
						missile_location = missile_location.add(direction_to_head);
						direction_to_head = missile_location.directionTo(target_location);
						if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
							direction_to_head = initial_direction;
					//	System.out.println("Turn3: " + direction_to_head);
						send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
						//turn 4
						missile_location = missile_location.add(direction_to_head);
						direction_to_head = missile_location.directionTo(target_location);
						if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
							direction_to_head = initial_direction;
					//	System.out.println("Turn4: " + direction_to_head);
						send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
						//turn 5
						missile_location = missile_location.add(direction_to_head);
						direction_to_head = missile_location.directionTo(target_location);
						if(direction_to_head.equals(Direction.OMNI) || direction_to_head.equals(Direction.NONE))
							direction_to_head = initial_direction;
					//	System.out.println("Turn5: " + direction_to_head);
						send_broadcast(orders_broadcast_offset + location_channel(missile_location), direction_to_head.ordinal());
					}
			} catch (Exception e){
				Utilities.print_exception(e);
			}
		return false;
	}
}


text:
<?php

namespace Wlm\EquipmentBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class MasterType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
       $builder
        ->add('name','text'  )
        ->add('description','textarea'  )
        ->add('manufacturer','text'  )
        ->add('price','text'  )
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Wlm\EquipmentBundle\Entity\Master'
        ));
    }

    public function getName()
    {
        return 'wlm_equipmentbundle_equipmentmastertype';
    }
}


text:
package moviesuggestion.databank.model.grouplens;

import moviesuggestion.databank.model.MovieContent;

import java.util.Date;
import java.util.List;

/**
 * Created by Sburroughs on 9/18/2016.
 */
public class GroupLensMovie implements MovieContent {

    private String title;
    private Date releaseDate;
    private List<String> genres;

    @Override
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public Date getReleaseDate() {
        return releaseDate;
    }

    public void setReleaseDate(Date releaseDate) {
        this.releaseDate = releaseDate;
    }

    public List<String> getGenres() {
        return genres;
    }

    public void setGenres(List<String> genres) {
        this.genres = genres;
    }
}


text:
import * as React from "react";
import { Spell } from "../../../common/Spell";
import { linkComponentToObservables } from "../../Combatant/linkComponentToObservables";
import { LibrariesCommander } from "../../Commands/LibrariesCommander";
import { TextEnricher } from "../../TextEnricher/TextEnricher";
import { GetAlphaSortableLevelString } from "../../Utility/GetAlphaSortableLevelString";
import { Listing } from "../Listing";
import { ListingGroupFn } from "../Components/BuildListingTree";
import { LibraryReferencePane } from "./LibraryReferencePane";
import { ListingRow } from "../Components/ListingRow";
import { SpellDetails } from "../Components/SpellDetails";
import { Library } from "../useLibrary";

export type SpellLibraryReferencePaneProps = {
  librariesCommander: LibrariesCommander;
  library: Library<Spell>;
};

type SpellListing = Listing<Spell>;

export class SpellLibraryReferencePane extends React.Component<
  SpellLibraryReferencePaneProps
> {
  constructor(props: SpellLibraryReferencePaneProps) {
    super(props);
    linkComponentToObservables(this);
  }

  public render() {
    return (
      <LibraryReferencePane
        listings={this.props.library.GetAllListings()}
        renderListingRow={this.renderListingRow}
        defaultItem={Spell.Default()}
        addNewItem={this.props.librariesCommander.CreateAndEditSpell}
        renderPreview={this.renderPreview}
        groupByFunctions={this.groupByFunctions}
        showPreloadInfo
      />
    );
  }

  private groupByFunctions: ListingGroupFn[] = [
    l => ({ key: l.Meta().Path }),
    l => ({
      label: LevelOrCantrip(l.Meta().FilterDimensions.Level),
      key: GetAlphaSortableLevelString(l.Meta().FilterDimensions.Level)
    }),
    l => ({ key: l.Meta().FilterDimensions.Type })
  ];

  private renderListingRow = (l: Listing<Spell>, onPreview, onPreviewOut) => {
    const listingMeta = l.Meta();
    return (
      <ListingRow
        key={listingMeta.Id + listingMeta.Path + listingMeta.Name}
        name={listingMeta.Name}
        onAdd={this.loadSavedSpell}
        onEdit={this.editSpell}
        onPreview={onPreview}
        onPreviewOut={onPreviewOut}
        listing={l}
      />
    );
  };

  private renderPreview = (spell: Spell) => (
    <div className="spell-preview">
      <SpellDetails Spell={spell} />
    </div>
  );

  private loadSavedSpell = (listing: SpellListing) => {
    return this.props.librariesCommander.ReferenceSpell(listing);
  };

  private editSpell = (l: Listing<Spell>) => {
    l.Meta.subscribe(_ => this.forceUpdate());
    this.props.librariesCommander.EditSpell(l);
  };
}

function LevelOrCantrip(levelString: string) {
  if (levelString == "0") {
    return "Cantrip";
  }
  return "Level " + levelString;
}


text:
class AddPracticeToPetitions < ActiveRecord::Migration
  def change
    add_column :petitions, :practice, :text
  end
end