text:
import React from 'react';

import Paper from 'material-ui/Paper';
import AppBar from 'material-ui/AppBar';
import { red700, blue700, green700, yellow700 } from 'material-ui/styles/colors';

import IconButton from 'material-ui/IconButton';
import IconEmpty from 'material-ui/svg-icons/toggle/star-border';
import IconHalf from 'material-ui/svg-icons/toggle/star-half';
import IconFull from 'material-ui/svg-icons/toggle/star';

import Player from './Player';

const colors = [red700, blue700, green700, yellow700];

export default class PlayerAll extends React.Component {
    state = {
        view: 1
    }

    _toggle = () => {
        this.setState({view: (this.state.view + 1) % 3});
    }

    render() {
        var players = this.props.players;
        var len = players.length;
        for (var i = 0; i < len; i++) {
            if (players[i].slot === -1) {
                players[i].slot = i;
            }
        }

        var index = players.findIndex(function(player) {
            return player.isPlayer;
        });
        if (index !== -1) {
            players = this.props.players.slice(index).concat(
                this.props.players.slice(0, index));
        }

        players.sort(function(playerA, playerB) {
            return playerA.rank - playerB.rank;
        });

        var view = this.state.view;
        return (
            <Paper id='players' zDepth={2}>
                <AppBar title='players'
                        showMenuIconButton={false}
                        iconElementRight={
                            (view === 0 &&
                            <IconButton tooltip='min'><IconEmpty/></IconButton>) ||
                            (view === 1 &&
                            <IconButton tooltip='default'><IconHalf/></IconButton>) ||
                            (view === 2 &&
                            <IconButton tooltip='full'><IconFull/></IconButton>)}
                        onRightIconButtonTouchTap={this._toggle}
                        style={{zIndex:998}}/>

                <div className='content'>
                    {players.map(function(player, index) {
                        return <Player key={index}
                                       player={player}
                                       tooltip={player.isTurn && this.tooltip}
                                       color={colors[player.slot]}
                                       hideContent={view === 0 && !player.isPlayer}
                                       allCards={view === 2}
                                       _recon={this._recon.bind(null, player.slot)}
                                       _complete={this._complete}
                                       _tap={this._tap}/>;
                    }, this.props)}
                </div>
            </Paper>
        );
    }
}


text:
#

option(BUILD_OpenCV "Build OpenCV." OFF)

if(BUILD_VTK AND APPLE AND BUILD_OpenCV AND "${VTK_VERSION}" STREQUAL "${DEFAULT_VTK_VERSION}")
  set(VTK_VERSION "${FALLBACK_VTK_VERSION}")
  message(STATUS "Forcing VTK_VERSION to ${VTK_VERSION} as you are on Mac OSX and BUILD_OpenCV is on.")
endif()

redpajama_set_name: RedPajamaGithub


text:
package weixin.guanjia.message.dao;

import org.jeecgframework.minidao.annotation.Arguments;
import org.jeecgframework.minidao.annotation.MiniDao;
import org.jeecgframework.minidao.annotation.Sql;

import weixin.guanjia.message.entity.TextTemplate;

@MiniDao
public interface TextTemplateDao {

	/**
	 * 根据[accountid][templateName]获取对应的文本消息
	 * @param accountid
	 * @return
	 */
	@Sql("select * from weixin_texttemplate where accountid=:accountid and templateName=:templateName")
	@Arguments( { "accountid", "templateName"})
	public TextTemplate getTextTemplate(String accountid,String templateName);
}


text:
var app = angular.module('quizApp', []);

app.directive('quiz', function(quizFactory) {
	return {
		restrict: 'AE',
		scope: {},
		templateUrl: 'mc-template.html',
		link: function(scope, elem, attrs) {

			scope.lesson = "Lesson 22";

			scope.start = function() {
				scope.id = 0;
				scope.items = 0;
				scope.quizOver = false;
				scope.inProgress = true;
				scope.getQuestion();
			};

			scope.reset = function() {
				scope.inProgress = false;
				scope.score = 0;
			}

			scope.getQuestion = function() {
				var q = quizFactory.getQuestion(scope.id);
				if(q) {
					scope.question = q.question;
					scope.options = q.options;
					scope.answer = q.answer;
					scope.answerMode = true;
					scope.items++;
				} else {
					scope.quizOver = true;
				}
			};

			scope.checkAnswer = function() {
				if(!$('input[name=answer]:checked').length) return;

				var ans = $('input[name=answer]:checked').val();

				if(ans == scope.options[scope.answer]) {
					scope.score++;
					scope.correctAns = true;
				} else {
					scope.correctAns = false;
				}

				scope.answerMode = false;
			};

			scope.nextQuestion = function() {
				scope.id++;
				scope.getQuestion();
			}

			scope.reset();
		}
	}
});

app.factory('quizFactory', function() {
	var questions = [
		{
			question : "What is the remainder when 6567 is divided by 27?",
			options: ["264 r. 13", "243 r. 6", "251", "263"],
			answer: 0
		},
		{
			question : "A farmer planted 1680 pineapples equally in 24 rows. How many pineapples were planted in each row?",
			options: ["180", "240", "160", "210"],
			answer: 2
		},
		{
			question : "Hazel, Cha, and Marimar shared the amount of Php480 to buy a birthday gift for their teacher. How much did each of them share?",
			options: ["120", "160", "180", "140"],
			answer: 1
		},
		{
			question : "A farmer gathered 760 mangoes from his farm. He placed 60 mangoes in each basket and sold them. How many mangoes were not in a full basket?",
			options: ["20", "30", "40", "50"],
			answer: 3
		}
	];

	questions =  shuffleArray(questions);

	return {
		getQuestion: function(id) {
			if(id < questions.length) {
				return questions[id];
			} else {
				return false;
			}
		}
	};
});

function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
    return array;
}


text:
<?php

namespace Pugmi\Bundle\PageBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class PugmiPageBundle extends Bundle
{
}


text:
namespace RAT {

// Convenience class for ROOT scripts
class DSReader : public TObject {
public:
  DSReader(const char *filename);
  virtual ~DSReader();

  void Add(const char* filename);
  void SetBranchStatus(const char *bname, bool status=1) {
    T.SetBranchStatus(bname, status);
  };

  TTree* GetT() { return &T; };
  DS::Root* GetDS() { return ds; };
  Long64_t GetTotal() { return total; };

  // Load event.  Returns ds (which will now point to specified event)
  DS::Root* GetEvent(Long64_t num) { next = num+1; T.GetEntry(num); return ds; };
  DS::Root* NextEvent();

  ClassDef(DSReader,0)

protected:
  TChain T;
  DS::Root *ds;
  Long64_t next;
  Long64_t total;
};

} // namespace RAT

#endif


text:
The default format for room aliases (which are automatically resolved, whether the room exists on Matrix or not) is:

``#_discord_guildid_channelid``

You can find these on discord in the browser where:

``https://discordapp.com/channels/282616294245662720/282616372591329281``

is formatted as https://discordapp.com/channels/``guildid``/``channelid``

### Set privileges on bridge managed rooms

* The ``adminme`` script is provided to set Admin/Moderator or any other custom power level to a specific user.
* e.g. To set Alice to Admin on her ``example.com`` HS on default config. (``config.yaml``)
  * ``npm run adminme -- -m '!AbcdefghijklmnopqR:example.com' -u '@Alice:example.com' -p '100'``
  * Run ``npm run adminme -- -h`` for usage.

Please note that `!AbcdefghijklmnopqR:example.com` is the internal room id and will always begin with `!`.
You can find this internal id in the room settings in Riot.

### Migrate to postgres from sqlite
* Stop the bridge.
* Create a new database on postgres and create a user for it with a password.
    * We will call the database `discord_bridge` and the the user `discord`.
* Install `pgloader` if you do not have it.
* Run `pgloader ./discord.db postgresql://discord:password@localhost/discord_bridge`
* Change the config so that the config contains:

```yaml
database:
    connString: "postgresql://discord:password@localhost/discord_bridge"
```
* All done!


text:
<?php
	/**
	 * Class Merger
	 *
	 * class_definition
	 *
	 * @author   Popov
	 * @access   public
	 * @package  Merger.class.php
	 * @created  Tue Apr 13 16:22:05 EEST 2010
	 */
	class Merger extends Controller
	{
		private $DB2 = null;
		/**
		 * Constructor of Merger
		 *
		 * @access  public
		 */
		function __construct() {
			parent::Controller();
		}

		function index(){
			/*$regions = $this->get_geo_regions();
			if(!empty($regions)) {
				foreach ($regions as $region) {

				}
			}
			echo "Regions completed";*/

			/*$query = "select
				count(city.city_name) as count
			FROM
				geo_cities city
			inner join geo_regions region on region.region_id=city.rid
			inner join geo_countries country on country.country_id=region.cid";
			$result = $this->db->query($query);
			if ( ! $result) return FALSE;
			$cities_count = $result->row();

			if($cities_count->count > 0) {
				for($i = 1889; $i < $cities_count->count; $i++) {
					log_message('debug', "iteration: ".$i);
					$city = $this->get_geo_cities(null, null, null, $i);
					if(!empty($city)){
						$_city = $this->get_cities($city->city_name);
						$city_id = null;
						if(empty($_city)) {
							$_region = $this->get_regions($city->region_name);
							$_country = $this->get_countries($city->country_name);
							if($_region && $_country) {
								$_region = $_region[0];
								$_country = $_country[0];

								$city_id = $this->insert_city($city->city_name, $_region->id, $_country->id);
							}
						}
					}
				}
			}*/

			$cities = $this->get_geo_cities();

			$i = 0;
			if(!empty($cities)){
				foreach ($cities as $city) {
					log_message('debug', "iteration: ".$i);
					$_city = $this->get_cities($city->city_name);
					$city_id = null;
					if(empty($_city)) {
						$_region = $this->get_regions($city->region_name);
						$_country = $this->get_countries($city->country_name);
						if($_region && $_country) {
							$_region = $_region[0];
							$_country = $_country[0];

							$city_id = $this->insert_city($city->city_name, $_region->id, $_country->id);
						}
					}
					$i++;
				}
			}
			echo "All cities, regions and countries have been added";
		}

		function get_geo_countries($country=null){
			$query = "select * from geo_countries ";
			if(!empty($country)) $query .= " where geo_countries.country_name='".$country->country_name."'";

			$result = $this->db->query($query);
			if ( ! $result) return FALSE;
			return $result->result();
		}

		function get_geo_regions($region=null, $country_id=null){
			$query = "select gr.*
			from geo_regions gr
			inner join geo_countries gc on gr.cid = gc.country_id where 1";
			if(!empty($region)) $query .= " and gr.region_name='".$region->region_name."'";
			if(!empty($country_id)) $query .= " and gr.cid='".$country_id."'";

			$result = $this->db->query($query);
			if ( ! $result) return FALSE;
			return $result->result();
		}

		function get_geo_cities($city=null, $region_id=null, $country_id=null){
			$query = "select
				city.city_name,region.region_id, region.region_name,country.country_id, country.country_name
			FROM
				geo_cities city
			inner join geo_regions region on region.region_id=city.rid
			inner join geo_countries country on country.country_id=region.cid where 1 ";

			if(!empty($city)) $query .= " and city.city_name='".$city->city_name."'";
			if(!empty($region_id)) $query .= " and city.rid='".$region_id."'";
			if(!empty($country_id)) $query .= " and city.cid='".$country_id."'";

//			$query .= " group by city.city_id";
			$query .= " limit 100000, 200000";
			$result = $this->db->query($query);
			if ( ! $result) return FALSE;
			return $result->result();
		}

		function get_countries($country_name=null){
			$query = "select * from country";

			if(!empty($country_name)) $query .= " where country.country='".$country_name."'";

			$result = $this->db->query($query);
			if ( ! $result) return FALSE;
			return $result->result();
		}

		function get_regions($region_name, $country_id=null){
			$query = "select r.*
			from region r
			inner join country_region cr on cr.id_region=r.id
			inner join country c on c.id=cr.id_country where 1 ";

			if(!empty($region_name)) $query .= " and r.region='".$region_name."'";
			if(!empty($country_id)) $query .= " and cr.id_country='".$country_id."'";

			$query .= " group by r.id";

			$result = $this->db->query($query);
			if ( ! $result) return FALSE;
			return $result->result();
		}

		function get_cities($city_name=null, $region_id=null, $country_id=null){
			$query = "select
				city.city,
				region.id as region_id,
				region.region,
				country.id as country_id,
				country.country
			FROM
				city
			inner join region_city on region_city.id_city=city.id
			inner join region on region.id=region_city.id_region
			inner join country_region on country_region.id_region=region.id
			inner join country on country.id=country_region.id_country where 1 ";

			if(!empty($city_name)) $query .= " and city.city='".$city_name."'";
			if(!empty($region_id)) $query .= " and region.id='".$region_id."'";
			if(!empty($country_id)) $query .= " and country.id='".$country_id;

//			$query .= " group by city.id";

			$result = $this->db->query($query);
			if ( ! $result) return FALSE;
			return $result->result();
		}

		function insert_country($country){
			$region_data = array(
				'country' => $country->country_name,
				'countrycode' => 0
			);
			$this->db->insert('country', $region_data);
			log_message('debug', "country $country->country_name has been added");

			return $this->db->insert_id();
		}

		function insert_country_diff($country, $country_id){
			$country_new = $this->get_countries($country_id);
			if($country_new) {
				$country_new = $country_new[0];

				$country_data = array(
					'country_id_old' => $country->country_id,
					'country_id_new' => $country_new->id,
					'country_name_old' => $country->country_name,
					'country_name_new' => $country_new->country
				);
				$this->db->insert('country_diff', $country_data);
			}
		}

		function insert_region($region, $country_id){
			$region_data = array(
				'region' => $region->region_name
			);
			$this->db->insert('region', $region_data);
			log_message('debug', "region $region->region_name has been added");

			$region_id = $this->db->insert_id();

			$region_data = array(
				'id_region' => $region_id,
				'id_country' => $country_id
			);
			$this->db->insert('country_region', $region_data);
			log_message('debug', "region $region->region_name in country_region has been added");

			return $region_id;
		}

		function insert_region_diff($region, $region_id){
			$region_new = $this->get_regions($region_id);
			if($region_new) {
				$region_new = $region_new[0];
				$region_data = array(
					'region_id_old' => $region->region_id,
					'region_id_new' => $region_new->id,
					'region_name_old' => $region->region_name,
					'region_name_new' => $region_new->region
				);
				$this->db->insert('region_diff', $region_data);
			}
		}

		function insert_city($city_name, $region_id){
			$city_data = array(
				'city' => $city_name,
				'telcode' => 0,
				'timezone' => 0
			);
			$this->db->insert('city', $city_data);
			log_message('debug', "city $city_name has been added");

			$city_id = $this->db->insert_id();

			$city_data = array(
				'id_city' => $city_id,
				'id_region' => $region_id
			);
			$this->db->insert('region_city', $city_data);
			log_message('debug', "city $city_name in region_city has been added");

			return $city_id;
		}

		function insert_city_diff($city, $city_id){
			$city_new = $this->get_cities($city_id);
			if($city_new) {
				$city_new = $city_new[0];
				$city_data = array(
					'city_id_old' => $country->city_id,
					'city_id_new' => $city_new->id,
					'city_name_old' => $country->city_name,
					'city_name_new' => $city_new->city
				);
				$this->db->insert('city_diff', $city_data);
			}
		}

		// MERGER'S USERS
		function index2(){
			$this->DB2 = $this->load->database('temp', TRUE, TRUE);

			$res = $this->db->query("SHOW columns FROM photos LIKE 'photo_id_old'");
			if ($res) {
				$res = $res->result();
				if(empty($res)) $this->db->query('ALTER TABLE photos ADD photo_id_old int(11) AFTER photo_id');
			}
			$res = $this->db->query("SHOW columns FROM photos LIKE 'score'");
			if ($res) {
				$res = $res->result();
				if(empty($res)) $this->db->query('ALTER TABLE photos ADD score int(11)');
			}
			$result1 = $this->get_users(null, $this->DB2);

			if(!empty($result1)) {
				foreach ($result1 as $user) {
					$db2_user = $this->get_users($user);

					// add user
					$user_id = null;
					if(empty($db2_user)) {
						$user_id = $this->insert_user($user);
					}
					else {
						$user_id = $user->user_id;
					}
					// add user's photos
					$user_photos = $this->get_user_photos($user->user_id);
					if(!empty($user_photos)) {
						$this->insert_photo($user_photos, $user_id);
					}
				}
				echo "All users have been added with their photos";
			}
		}

		function check_photos(){
			$photo_path = dirname(BASEPATH)."/uploads/photos/temp/";

			$query = "SELECT SQL_CALC_FOUND_ROWS DISTINCT p.*, count(commented_object_id) as comcnt, login, rating_totals.see_cnt, rating_totals.balls,if( p.md_width >p.md_height,true,false) as land
						FROM photos p LEFT JOIN rating_totals ON (p.photo_id = rating_totals.on_what_id
						AND rating_totals.on_what='foto')
						LEFT JOIN comments_tree ct ON (ct.commented_object_id = p.photo_id AND ct.commented_object_type = 'photo'),
						competition_photos cp, competitions c, users u
						WHERE p.moderation_state >= 0
                        AND c.competition_id = cp.competition_id
                        AND u.user_id = p.user_id
						AND cp.photo_id = p.photo_id
						AND c.competition_id = 1 GROUP BY p.photo_id ORDER BY p.title";

			$qresult = $this->db->query($query);
			if ( ! $qresult) return FALSE;
			$result = $qresult->result();
			foreach ($result as $photo) {
				$file_head = photo_location().date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-head'.$photo->extension;
				$file_lg = photo_location().date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-lg'.$photo->extension;
				$file_md = photo_location().date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-md'.$photo->extension;
				$file_sm = photo_location().date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-sm'.$photo->extension;

				$image_head = file_get_contents($file_head);
				if(!empty($image_head)) {
                	$path = $photo_path.$photo->photo_id.'-head'.$photo->extension;
               		file_put_contents($path, $image_head);
				}

               	$image_lg = file_get_contents($file_lg);
               	if(!empty($image_lg)) {
               		$path = $photo_path.$photo->photo_id.'-lg'.$photo->extension;
					file_put_contents($path, $image_lg);
               	}

				$image_md = file_get_contents($file_md);
				if(!empty($image_md)) {
               		$path = $photo_path.$photo->photo_id.'-md'.$photo->extension;
					file_put_contents($path, $image_md);
				}

				$image_sm = file_get_contents($file_sm);
				if(!empty($image_sm)) {
               		$path = $photo_path.$photo->photo_id.'-sm'.$photo->extension;
					file_put_contents($path, $image_sm);
				}
			}
		}

		function get_photos(){
			$this->load->helper('file');

			$result1 = $this->get_users();
			$photo_path = dirname(BASEPATH)."/uploads/photos/from_kz/".date("m")."/";

			$user_photos = "";//$this->get_user_photos();

			$competition = modules::run('competition_mod/competition_ctr/get_competition');
			if($competition) {
				if(is_array($competition)) $competition = $competition[0];
				$competition->photos = modules::run('competition_mod/competition_ctr/get_competition_photos', $competition->competition_id, 0, 1, 1);
				$user_photos = $competition->photos;
			}

			if(!empty($user_photos)) {
				foreach ($user_photos as $photo) {
					$file_head = "http://pinpix.prototypeboom.com/uploads/photos/".date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-head'.$photo->extension;
					$file_lg = "http://pinpix.prototypeboom.com/uploads/photos/".date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-lg'.$photo->extension;
					$file_md = "http://pinpix.prototypeboom.com/uploads/photos/".date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-md'.$photo->extension;
					$file_sm = "http://pinpix.prototypeboom.com/uploads/photos/".date('m', strtotime($photo->date_added)).'/'.$photo->photo_id.'-sm'.$photo->extension;

					$image_head = file_get_contents($file_head);
					if(!empty($image_head)) {
                    	$path = $photo_path.$photo->photo_id.'-head'.$photo->extension;
                   		file_put_contents($path, $image_head);
					}

                   	$image_lg = file_get_contents($file_lg);
                   	if(!empty($image_lg)) {
                   		$path = $photo_path.$photo->photo_id.'-lg'.$photo->extension;
						file_put_contents($path, $image_head);
                   	}

					$image_md = file_get_contents($file_md);
					if(!empty($image_md)) {
                   		$path = $photo_path.$photo->photo_id.'-md'.$photo->extension;
						file_put_contents($path, $image_md);
					}

					$image_sm = file_get_contents($file_sm);
					if(!empty($image_sm)) {
                   		$path = $photo_path.$photo->photo_id.'-sm'.$photo->extension;
						file_put_contents($path, $image_sm);
					}
				}
			}
		}

		function insert_user($user){
			$user_data = array(
				'login' => $user->login,
				'password' => $user->password,
				'email' => $user->email,
				'email_for_change' => $user->email_for_change,
				'secret_question_id' => $user->secret_question_id,
				'secret_question_answer' => $user->secret_question_answer,
				'activation_code' => $user->activation_code,
				'first_name' => $user->first_name,
				'last_name' => $user->last_name,
				'birthdate' => $user->birthdate,
				'country_iso' => $user->country_iso,
				'country_id' => $user->country_id,
				'city_id'  => $user->city_id,
				'region_id'  => $user->region_id,
				'google_map_point'  => $user->google_map_point,
				'gender'  => $user->gender,
				'registration_date' => $user->registration_date,
				'registration_ip' => $user->registration_ip,
				'last_login_date' => $user->last_login_date,
				'last_login_ip' => $user->last_login_ip,
				'about' => $user->about,
				'group_id' => $user->group_id,
				'interests' => $user->interests,
				'avatar' => $user->avatar,
				'predefined_avatar' => $user->predefined_avatar,
				'moderation_state' => $user->moderation_state,
				'group_id' => $user->group_id,
				'language' => $user->language
			);

			$this->db->insert('users', $user_data);

			log_message('debug', "user $user->login has been added");

			return $this->db->insert_id();
		}

		function insert_photo($photo_array, $user_id){
			try {
				if(empty($photo_array) || empty($user_id))
					throw new Exception("data are empty");

				foreach ($photo_array as $photo) {
					$photo_data = array(
						'photo_id_old' => $photo->photo_id,
						'title' => $photo->title,
						'user_id' => $user_id,
						'date_added' => date("Y-m-d H:i:s"),
						'date_modified' => date("Y-m-d H:i:s"),
						'added_from_ip' => $photo->added_from_ip,
						'lg_width' => $photo->lg_width,
						'lg_width' => $photo->lg_width,
						'lg_height' => $photo->lg_height,
						'md_width' => $photo->md_width,
						'sm_width' => $photo->sm_width,
						'sm_height' => $photo->sm_height,
						'size' => $photo->size,
						'extension' => $photo->extension,
						'exif_camera' => $photo->exif_camera,
						'exif_shooting_date' => $photo->exif_shooting_date,
						'exif_focal_length' => $photo->exif_focal_length,
						'exif_exposure_time' => $photo->exif_exposure_time,
						'exif_aperture' => $photo->exif_aperture,
						'exif_focus_dist' => $photo->exif_focus_dist,
						'google_map_point' => $photo->google_map_point,
						'view_allowed' => $photo->view_allowed,
						'erotic_p' => $photo->erotic_p,
						'extension' => $photo->extension,
						'moderation_state' => $photo->moderation_state,
						'description' => $photo->description,
						'score' => $photo->score
					);
					if(!$this->db->insert('photos', $photo_data))
						throw new Exception($this->db->_error_message());

					$photo_id = $this->db->insert_id();

					$photo->photo_id_old = $photo->photo_id;
					$photo->photo_id = $photo_id;

					$photo_category_map = array(
						'photo_id' => $photo_id,
						'category_id' => '96'
					);
					if(!$this->db->insert('photo_category_map', $photo_category_map))
						throw new Exception($this->db->_error_message());

					$this->change_photos($photo);
				}
				return true;

			} catch(Exception $e){
				log_message('error', $e->getMessage().'\n'.
									$e->getFile().'\n'.
									$e->getCode());
			}
			return false;
		}

		function get_users($user=null, $prefix_db=null){
			$query = "select * from users ";
			if(!empty($user)) $query .= " where login=".clean($user->login)." and email=".clean($user->email);

			if($prefix_db) $qresult = $prefix_db->query($query);
			else $qresult = $this->db->query($query);
			if ( ! $qresult) return FALSE;
			if($user) return $qresult->row();
			else return $qresult->result();
		}

		function get_user_photos($user_id=null, $photo_id=null){
			$query = "SELECT p.*, count(commented_object_id) as comcnt, login, rating_totals.see_cnt, rating_totals.balls,if( p.md_width >p.md_height,true,false) as land
						FROM photos p LEFT JOIN rating_totals ON (p.photo_id = rating_totals.on_what_id
						AND rating_totals.on_what='foto')
						LEFT JOIN comments_tree ct ON (ct.commented_object_id = p.photo_id AND ct.commented_object_type = 'photo'),
						competition_photos cp, competitions c, users u
						WHERE p.moderation_state >= 0
		                AND c.competition_id = cp.competition_id
		                AND u.user_id = p.user_id
						AND cp.photo_id = p.photo_id
						AND c.competition_id = 1 ";
			if($photo_id) $query .= " and p.photo_id=".clean($photo_id);
			if($user_id) $query .= " and p.user_id=".clean($user_id);
			$query .= " GROUP BY p.photo_id";

			$qresult = $this->DB2->query($query);
			if ( ! $qresult) return FALSE;
			if($photo_id) return $qresult->row();
			else return $qresult->result();
		}

		function change_photos($photo){
			$photo_path = dirname(BASEPATH)."/uploads/photos/kz/";
			$photo_path_new = dirname(BASEPATH)."/uploads/photos/04/";

			$file_head = $photo_path.$photo->photo_id_old.'-head'.$photo->extension;
			$file_lg = $photo_path.$photo->photo_id_old.'-lg'.$photo->extension;
			$file_md = $photo_path.$photo->photo_id_old.'-md'.$photo->extension;
			$file_sm = $photo_path.$photo->photo_id_old.'-sm'.$photo->extension;

			$photos_arr = array();
			if(is_file($photo_path_new.$photo->photo_id.'-head'.$photo->extension)) unlink($photo_path_new.$photo->photo_id.'-head'.$photo->extension);
			if(is_file($file_head)) {
				rename($file_head, $photo_path_new.$photo->photo_id.'-head'.$photo->extension);
				$photos_arr[] = $photo_path_new.$photo->photo_id.'-head'.$photo->extension;
			}

			if(is_file($photo_path_new.$photo->photo_id.'-lg'.$photo->extension)) unlink($photo_path_new.$photo->photo_id.'-lg'.$photo->extension);
			if(is_file($file_lg)) {
				rename($file_lg, $photo_path_new.$photo->photo_id.'-lg'.$photo->extension);
				$photos_arr[] = $photo_path_new.$photo->photo_id.'-lg'.$photo->extension;
			}

			if(is_file($photo_path_new.$photo->photo_id.'-md'.$photo->extension)) unlink($photo_path_new.$photo->photo_id.'-md'.$photo->extension);
			if(is_file($file_md)) {
				rename($file_md, $photo_path_new.$photo->photo_id.'-md'.$photo->extension);
				$photos_arr[] = $photo_path_new.$photo->photo_id.'-md'.$photo->extension;
			}

			if(is_file($photo_path_new.$photo->photo_id.'-sm'.$photo->extension)) unlink($photo_path_new.$photo->photo_id.'-sm'.$photo->extension);
			if(is_file($file_sm)) {
				rename($file_sm, $photo_path_new.$photo->photo_id.'-sm'.$photo->extension);
				$photos_arr[] = $photo_path_new.$photo->photo_id.'-sm'.$photo->extension;
			}

			log_message('debug', "fotos has been copied sucsessfully: ".var_export($photos_arr, true));
		}

		/**
		 * Destructor of Merger
		 *
		 * @access  public
		 */
		function __destruct() {}

	}


text:
package com.puppetlabs.http.client.metrics;

import com.puppetlabs.http.client.impl.metrics.TimerMetricData;

public class UrlClientMetricData extends ClientMetricData {
    private final String url;

    public UrlClientMetricData(TimerMetricData timerMetricData,
                               String url) {
        super(timerMetricData);
        this.url = url;
    }

    public String getUrl() {
        return url;
    }
}


text:
/*global Vue, todoStorage */

(function (exports) {

	'use strict';

	exports.app = new Vue({

		// the root element that will be compiled
		el: '#todoapp',

		// app state data
		data: {
			todos: todoStorage.fetch(),
			newTodo: '',
			editedTodo: null,
			activeFilter: 'all',
			filters: {
				all: function () {
					return true;
				},
				active: function (todo) {
					return !todo.completed;
				},
				completed: function (todo) {
					return todo.completed;
				}
			}
		},

		// ready hook, watch todos change for data persistence
		ready: function () {
			this.$watch('todos', function (todos) {
				todoStorage.save(todos);
			}, true);
		},

		// a custom directive to wait for the DOM to be updated
		// before focusing on the input field.
		// http://vuejs.org/guide/directives.html#Writing_a_Custom_Directive
		directives: {
			'todo-focus': function (value) {
				if (!value) {
					return;
				}
				var el = this.el;
				setTimeout(function () {
					el.focus();
				}, 0);
			}
		},

		// a custom filter that filters the displayed todos array
		filters: {
			filterTodos: function (todos) {
				return todos.filter(this.filters[this.activeFilter]);
			}
		},

		// computed properties
		// http://vuejs.org/guide/computed.html
		computed: {
			remaining: function () {
				return this.todos.filter(this.filters.active).length;
			},
			allDone: {
				get: function () {
					return this.remaining === 0;
				},
				set: function (value) {
					this.todos.forEach(function (todo) {
						todo.completed = value;
					});
				}
			}
		},

		// methods that implement data logic.
		// note there's no DOM manipulation here at all.
		methods: {

			addTodo: function () {
				var value = this.newTodo && this.newTodo.trim();
				if (!value) {
					return;
				}
				this.todos.push({ title: value, completed: false });
				this.newTodo = '';
			},

			removeTodo: function (todo) {
				this.todos.$remove(todo.$data);
			},

			editTodo: function (todo) {
				this.beforeEditCache = todo.title;
				this.editedTodo = todo;
			},

			doneEdit: function (todo) {
				if (!this.editedTodo) {
					return;
				}
				this.editedTodo = null;
				todo.title = todo.title.trim();
				if (!todo.title) {
					this.removeTodo(todo);
				}
			},

			cancelEdit: function (todo) {
				this.editedTodo = null;
				todo.title = this.beforeEditCache;
			},

			removeCompleted: function () {
				this.todos = this.todos.filter(this.filters.active);
			}
		}
	});

})(window);


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

namespace Zhua.Domain
{
    public class Tag
    {
        public Tag()
        {
            Id = Guid.NewGuid();
            CreatedOn = DateTime.Now;
        }

        public Tag(Guid id, DateTime createdOn)
        {
            Id = id;
            CreatedOn = createdOn;
        }

        public Guid Id { get; }
        public DateTime CreatedOn { get; }

        public string Name { get; set; }
        public string Description { get; set; }
        public string Type { get; set; }
    }
}


text:
	cargBags: An inventory framework addon for World of Warcraft

	Copyright (C) 2010  Constantin "Cargor" Schomburg <xconstruct@gmail.com>

	cargBags is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	cargBags is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with cargBags; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

DESCRIPTION
	This file holds a list of default layouts

DEPENDENCIES
	mixins/api-common.lua
]]
local addon, ns = ...
local layouts = ns.cargBags.classes.Container.layouts

function layouts.grid(self, columns, spacing, xOffset, yOffset)
	columns, spacing = columns or 8, spacing or 5
	xOffset, yOffset = xOffset or 0, yOffset or 0

	local width, height = 0, 0
	local col, row = 0, 0
	for i, button in ipairs(self.buttons) do

		if(i == 1) then -- Hackish, I know
			width, height = button:GetSize()
		end

		col = i % columns
		if(col == 0) then col = columns end
		row = math.ceil(i/columns)

		local xPos = (col-1) * (width + spacing)
		local yPos = -1 * (row-1) * (height + spacing)

		button:ClearAllPoints()
		button:SetPoint("TOPLEFT", self, "TOPLEFT", xPos+xOffset, yPos+yOffset)
	end

	return columns * (width+spacing)-spacing, row * (height+spacing)-spacing
end

--[[!
	Places the buttons in a circle [experimental]
	@param radius <number> radius of the circle [optional]
	@param xOffset <number> x-offset of the whole layout [default: 0]
	@param yOffset <number> y-offset of the whole layout [default: 0]
]]
function layouts.circle(self, radius, xOffset, yOffset)
	radius = radius or (#self.buttons*50)/math.pi/2
	xOffset, yOffset = xOffset or 0, yOffset or 0

	local a = 360/#self.buttons

	for i, button in ipairs(self.buttons) do
		local x = radius*cos(a*i)
		local y = -radius*sin(a*i)

		button:ClearAllPoints()
		button:SetPoint("TOPLEFT", self, "TOPLEFT", radius+x+xOffset, y-radius+yOffset)
	end
	return radius*2, radius*2
end


text:
"""
@package mi.dataset.driver.ctdmo_ghqr.imodem
@file mi-dataset/mi/dataset/driver/ctdmo_ghqr/imodem/ctdmo_ghqr_imodem_recovered_driver.py
@author Mark Worden
@brief Driver for the ctdmo_ghqr_imodem instrument

Release notes:

Initial Release
"""

from mi.dataset.dataset_parser import DataSetDriverConfigKeys
from mi.dataset.dataset_driver import SimpleDatasetDriver
from mi.dataset.parser.ctdmo_ghqr_imodem import CtdmoGhqrImodemParser, \
    CtdmoGhqrImodemParticleClassKey, \
    CtdmoGhqrImodemMetadataRecoveredDataParticle, \
    CtdmoGhqrImodemInstrumentRecoveredDataParticle
from mi.core.versioning import version

@version("15.6.1")
def parse(unused, source_file_path, particle_data_handler):
    """
    This is the method called by Uframe
    :param unused
    :param source_file_path This is the full path and filename of the file to be parsed
    :param particle_data_handler Java Object to consume the output of the parser
    :return particle_data_handler
    """

    with open(source_file_path, 'rb') as stream_handle:

        driver = CtdmoGhqrImodemrecoveredDriver(unused, stream_handle, particle_data_handler)
        driver.processFileStream()

    return particle_data_handler

class CtdmoGhqrImodemrecoveredDriver(SimpleDatasetDriver):
    """
    All this needs to do is create a concrete _build_parser method
    """

    def _build_parser(self, stream_handle):

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE: 'mi.dataset.parser.ctdmo_ghqr_imodem',
            DataSetDriverConfigKeys.PARTICLE_CLASS: None,
            DataSetDriverConfigKeys.PARTICLE_CLASSES_DICT: {
                CtdmoGhqrImodemParticleClassKey.METADATA_PARTICLE_CLASS:
                    CtdmoGhqrImodemMetadataRecoveredDataParticle,
                CtdmoGhqrImodemParticleClassKey.INSTRUMENT_PARTICLE_CLASS:
                    CtdmoGhqrImodemInstrumentRecoveredDataParticle,
            }
        }

        parser = CtdmoGhqrImodemParser(parser_config,
                                       stream_handle,
                                       self._exception_callback)

        return parser


text:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using XenAdmin.Actions;
using XenAdmin.Model;
using XenAdmin.Network;
using XenAPI;

namespace XenAdmin.Controls
{
    public class TagsEditor : DoubleBufferedPanel
    {
        private readonly TagList _tagsList;

        public TagsEditor(List<string> tags, Panel panel)
        {
            _tagsList = new TagList(tags, panel, 0);
        }

        public List<string> Tags
        {
            get { return _tagsList.Tags; }
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            _tagsList.DrawSelf(null, new Rectangle(0, 0, Width, Height), false);
        }

        protected override void OnDrawToBuffer(PaintEventArgs e)
        {
            // Hack.  See Program.TransparentUsually.
            e.Graphics.TextContrast = 5;
            _tagsList.DrawSelf(e.Graphics, new Rectangle(0, 0, Width, Height), false);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            _tagsList.OnMouseMove(e.Location);
            base.OnMouseMove(e);
        }

        protected override void OnMouseClick(MouseEventArgs e)
        {
            _tagsList.OnMouseClick(e, e.Location);
            base.OnMouseClick(e);
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            _tagsList.OnMouseLeave();
            base.OnMouseLeave(e);
        }
    }
}


text:
using System;

namespace crypto_test
{
	public class CryptoTest
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			DateTime before = DateTime.Now;

			try
			{
				Org.BouncyCastle.Asn1.Tests.RegressionTest.Main(args);
				//Org.BouncyCastle.Bcpg.OpenPgp.Tests.Dsa2Test.?
				Org.BouncyCastle.Bcpg.OpenPgp.Tests.RegressionTest.Main(args);
				Org.BouncyCastle.Bcpg.OpenPgp.Examples.Tests.AllTests.Main(args);
				Org.BouncyCastle.Cms.Tests.AllTests.Main(args);
				Org.BouncyCastle.Crypto.Tests.RegressionTest.Main(args);
				Org.BouncyCastle.Crypto.IO.Tests.AllTests.Main(args);
				Org.BouncyCastle.Math.Tests.AllTests.Main(args);
				Org.BouncyCastle.Math.EC.Tests.AllTests.Main(args);
				Org.BouncyCastle.Ocsp.Tests.AllTests.Main(args);
				//Org.BouncyCastle.Pkcs.Tests.?
				Org.BouncyCastle.Pkcs.Tests.EncryptedPrivateKeyInfoTest.Main(args);
				Org.BouncyCastle.Pkcs.Tests.Pkcs10Test.Main(args);
				Org.BouncyCastle.Pkcs.Tests.Pkcs12StoreTest.Main(args);
				//Org.BouncyCastle.OpenSsl.Tests.?
				Org.BouncyCastle.OpenSsl.Tests.ReaderTest.Main(args);
				Org.BouncyCastle.OpenSsl.Tests.WriterTest.Main(args);
				//Org.BouncyCastle.Security.Tests.?
				Org.BouncyCastle.Tests.RegressionTest.Main(args);
				Org.BouncyCastle.Tsp.Tests.AllTests.Main(args);
				//Org.BouncyCastle.X509.Tests.?
			}
			catch (Exception e)
			{
				Console.WriteLine("Tests failed with exception: " + e.Message);
				Console.WriteLine(e.StackTrace);
			}

			DateTime after = DateTime.Now;
			long elapsedTicks = after.Ticks - before.Ticks;

			Console.WriteLine("Done in {0}ms.", elapsedTicks / TimeSpan.TicksPerMillisecond);
		}
	}
}


text:
require "tk"

hello = TkRoot.new
TkLabel.new(hello) do
  text "\n Hello, Matz! \n"
  pack
end
Tk.mainloop


text:
from django.contrib import admin
from .models import Usuario, Mensaje

admin.site.register(Usuario)
admin.site.register(Mensaje)


text:
import { padEnd } from "lodash";
export = padEnd;


text:
package com.pi4j.system;

public class NetworkInterface {

    private final String linkEncap;
    private final String ipAddress;
    private final String macAddress;
    private final String broadcastAddress;
    private final String subnetMask;
    private final String mtu;
    private final String metric;

    public NetworkInterface(String linkEncap,String macAddress,String ipAddress,String broadcastAddress,String subnetMask,String mtu,String metric) {
        this.linkEncap = linkEncap;
        this.ipAddress = ipAddress;
        this.macAddress = macAddress;
        this.broadcastAddress = broadcastAddress;
        this.subnetMask = subnetMask;
        this.mtu = mtu;
        this.metric = metric;
    }

    public String getLinkEncap() {
        return linkEncap;
    }

    public String getIPAddress() {
        return ipAddress;
    }

    public String getMACAddress() {
        return macAddress;
    }

    public String getBroadcastAddress() {
        return broadcastAddress;
    }

    public String getSubnetMask() {
        return subnetMask;
    }

    public String getMTU() {
        return mtu;
    }

    public String getMetric() {
        return metric;
    }
}


text:
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2009 CTTC
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Nicola Baldo <nbaldo@cttc.es>
 */

#include <ns3/object-factory.h>
#include <ns3/log.h>
#include <ns3/double.h>
#include <ns3/simulator.h>
#include <ns3/trace-source-accessor.h>
#include <ns3/antenna-model.h>

#include "spectrum-analyzer.h"

NS_LOG_COMPONENT_DEFINE ("SpectrumAnalyzer");

namespace ns3 {

NS_OBJECT_ENSURE_REGISTERED (SpectrumAnalyzer);

SpectrumAnalyzer::SpectrumAnalyzer ()
  : m_mobility (0),
    m_netDevice (0),
    m_channel (0),
    m_spectrumModel (0),
    m_sumPowerSpectralDensity (0),
    m_resolution (MilliSeconds (50)),
    m_active (false)
{
  NS_LOG_FUNCTION (this);
}

SpectrumAnalyzer::~SpectrumAnalyzer ()
{
  NS_LOG_FUNCTION (this);
}

void
SpectrumAnalyzer::DoDispose ()
{
  NS_LOG_FUNCTION (this);
  m_mobility = 0;
  m_netDevice = 0;
  m_channel = 0;
  m_spectrumModel = 0;
  m_sumPowerSpectralDensity = 0;
  m_energySpectralDensity = 0;
  SpectrumPhy::DoDispose ();
}

TypeId
SpectrumAnalyzer::GetTypeId (void)
{
  static TypeId tid = TypeId ("ns3::SpectrumAnalyzer")
    .SetParent<SpectrumPhy> ()
    .AddConstructor<SpectrumAnalyzer> ()
    .AddAttribute ("Resolution",
                   "the lengh of the time interval over which the power spectral "
                   "density of incoming signals is averaged",
                   TimeValue (MilliSeconds (1)),
                   MakeTimeAccessor (&SpectrumAnalyzer::m_resolution),
                   MakeTimeChecker ())
    .AddAttribute ("NoisePowerSpectralDensity",
                   "the power spectral density of the measuring instrument noise, in Watt/Hz. Mostly useful to make spectrograms look more similar to those obtained by real devices. Defaults to the value for thermal noise at 300K.",
                   DoubleValue (1.38e-23 * 300),
                   MakeDoubleAccessor (&SpectrumAnalyzer::m_noisePowerSpectralDensity),
                   MakeDoubleChecker<double> ())
    .AddTraceSource ("AveragePowerSpectralDensityReport",
                     "Trace fired whenever a new value for the average Power Spectral Density is calculated",
                     MakeTraceSourceAccessor (&SpectrumAnalyzer::m_averagePowerSpectralDensityReportTrace))
  ;
  return tid;
}

Ptr<NetDevice>
SpectrumAnalyzer::GetDevice ()
{
  return m_netDevice;
}

Ptr<MobilityModel>
SpectrumAnalyzer::GetMobility ()
{
  return m_mobility;
}

Ptr<const SpectrumModel>
SpectrumAnalyzer::GetRxSpectrumModel () const
{
  return m_spectrumModel;
}

void
SpectrumAnalyzer::SetDevice (Ptr<NetDevice> d)
{
  NS_LOG_FUNCTION (this << d);
  m_netDevice = d;
}

void
SpectrumAnalyzer::SetMobility (Ptr<MobilityModel> m)
{
  NS_LOG_FUNCTION (this << m);
  m_mobility = m;
}

void
SpectrumAnalyzer::SetChannel (Ptr<SpectrumChannel> c)
{
  NS_LOG_FUNCTION (this << c);
  m_channel = c;
}

Ptr<AntennaModel>
SpectrumAnalyzer::GetRxAntenna ()
{
  return m_antenna;
}

void
SpectrumAnalyzer::SetAntenna (Ptr<AntennaModel> a)
{
  NS_LOG_FUNCTION (this << a);
  m_antenna = a;
}

void
SpectrumAnalyzer::StartRx (Ptr<SpectrumSignalParameters> params)
{
  NS_LOG_FUNCTION ( this << params);
  AddSignal (params->psd);
  Simulator::Schedule (params->duration, &SpectrumAnalyzer::SubtractSignal, this, params->psd);
}

void
SpectrumAnalyzer::AddSignal  (Ptr<const SpectrumValue> psd)
{
  NS_LOG_FUNCTION (this << *psd);
  UpdateEnergyReceivedSoFar ();
  (*m_sumPowerSpectralDensity) += (*psd);
}

void
SpectrumAnalyzer::SubtractSignal  (Ptr<const SpectrumValue> psd)
{
  NS_LOG_FUNCTION (this << *psd);
  UpdateEnergyReceivedSoFar ();
  (*m_sumPowerSpectralDensity) -= (*psd);
}

void
SpectrumAnalyzer::UpdateEnergyReceivedSoFar  ()
{
  NS_LOG_FUNCTION (this);
  if (m_lastChangeTime < Now ())
    {
      (*m_energySpectralDensity) += (*m_sumPowerSpectralDensity) * ((Now () - m_lastChangeTime).GetSeconds ());
      m_lastChangeTime = Now ();
    }
  else
    {
      NS_ASSERT (m_lastChangeTime == Now ());
    }
}

void
SpectrumAnalyzer::GenerateReport ()
{
  NS_LOG_FUNCTION (this);

  UpdateEnergyReceivedSoFar ();
  Ptr<SpectrumValue> avgPowerSpectralDensity = Create<SpectrumValue> (m_sumPowerSpectralDensity->GetSpectrumModel ());
  (*avgPowerSpectralDensity) = (*m_energySpectralDensity) / m_resolution.GetSeconds ();
  (*avgPowerSpectralDensity) += m_noisePowerSpectralDensity;
  (*m_energySpectralDensity) = 0;

  NS_LOG_INFO ("generating report");
  m_averagePowerSpectralDensityReportTrace (avgPowerSpectralDensity);

  *avgPowerSpectralDensity = 0;

  if (m_active)
    {
      Simulator::Schedule (m_resolution, &SpectrumAnalyzer::GenerateReport, this);
    }
}

void
SpectrumAnalyzer::SetRxSpectrumModel (Ptr<SpectrumModel> f)
{
  NS_LOG_FUNCTION (this << f);
  m_spectrumModel = f;
  NS_ASSERT (!m_sumPowerSpectralDensity);
  m_sumPowerSpectralDensity = Create<SpectrumValue> (f);
  m_energySpectralDensity = Create<SpectrumValue> (f);
  NS_ASSERT (m_sumPowerSpectralDensity);
}

void
SpectrumAnalyzer::Start ()
{
  NS_LOG_FUNCTION (this);
  if (!m_active)
    {
      NS_LOG_LOGIC ("activating");
      m_active = true;
      Simulator::Schedule (m_resolution, &SpectrumAnalyzer::GenerateReport, this);
    }
}

void
SpectrumAnalyzer::Stop ()
{
  m_active = false;
}

} // namespace ns3


text:
/**
 * backbone-view-states.js
 *
 * @version 0.3.0
 * @author boris@washmatique.fr
 */
(function () {

    "use strict";

    var root = this,
        $=root.$,
        _ = root._,
        Backbone = root.Backbone,
        document = root.document,
        console = root.console,
        CSSStyleRule = root.CSSStyleRule,
        setTimeout=root.setTimeout,

        config = {
            stateAttr:"data-states",
            inAttr:"data-states-inc",
            outAttr:"data-states-exc",
            cssModifier:"-"
        },

    //---------------------------------
    // State events types
    //-----------------------------------
        EXIT = "state:exit",
        EXITED = "state:exited",
        ENTER = "state:enter",
        CHANGED = "state:changed";

    // turn off debug by default
    Backbone.DEBUG_STATES = false;

    //---------------------------------
    // utility functions
    //---------------------------------
    /**
     * debug function to log in console if available
     * @type {*}
     */
    var debug = (function () {
        var join = Array.prototype.join,
            canLog = console && console.log;
        return function () {
            return canLog && Backbone.DEBUG_STATES && console.log(join.call(arguments, ','));
        };
    }());

    /**
     * add the trim function if not availiable
     * @type {*}
     */
    if (!_.isFunction(String.prototype.trim)) {
        String.prototype.trim = function () {
            return this.replace(/^\s+|\s+$/g, "");
        };
    }

    /**
     * CSS utility functions.
     * @type {*}
     */
    var CSS = (function (document) {
        var _hasSheets = true,
            _stylesCache = {},
            _transitionsCache = {},
            _acceptedMediaTypes = ["screen", "all", ""];

        /**
         * return true if among the comma separated string list of media types declared on a sheet and passed as parameter
         * should be accepted for further process
         * @param mediaTypes
         * @return {Boolean}
         * @private
         */
        var _acceptSheet = function (sheet) {
            var mediaTypes = sheet.media.mediaText;
            mediaTypes = mediaTypes.split(",");
            return _.find(mediaTypes, function (mediaType) {
                return _.indexOf(_acceptedMediaTypes, mediaType.trim()) >= 0;
            }) !== void 0;
        };

        /**
         *  returns true if in the rule.selectorText passed as parameter one in the list (comma separated) matches
         *  the selectorText passed as parameter
         * @param rule
         * @param selectorText
         * @return {*}
         * @private
         */
        var _ruleHasSelectorText = function (rule, selectorText) {
            var selectors = rule.selectorText.split(",");
            return _.find(selectors, function (aSelectorText) {
                return aSelectorText.trim() === selectorText;
            });
        };

        /**
         * return the Style object among rules passed as parameter if one of the rules selectorText contains
         * the selector string passed a parameter.
         * @param rules a list of Rules
         * @param selector : a style selector
         * @return {*}
         * @private
         */
        var _findStyleInRules = function (rules, selector) {
            var rule;
            for (var j = 0, k = rules.length; j < k; j++) {
                rule = rules[j];
                if ((rule.constructor===CSSStyleRule) && _ruleHasSelectorText(rule, selector)) {
                    return rule.style;
                }
            }
            return null;
        };

        return {

            transitions:(function () {
                var el = document.createElement('div'),
                    transProps = ['transition', 'OTransition', 'MSTransition', 'MozTransition', 'WebkitTransition'],
                    props = el.style,
                    prop = _.find(transProps, function (value) {
                        return props[value] === void 0 ? false : value;
                    });

                return prop && {
                    durationProp:prop + "Duration",
                    delayProp:prop + "Delay"
                };
            }()),

            /**
             * returns the Style Object and caches it if a CSS rule was found among all
             * declared style sheets in the document.Sheets loaded from a different domain are excluded
             * @param selector
             * @return {*}
             */
            findStyle:function (selector) {
                if (_hasSheets && _stylesCache[selector] !== void 0) return _stylesCache[selector];
                var sheets = document.styleSheets;
                if (sheets === void 0) {
                    _hasSheets = false;
                    return null;
                }
                var sheet,
                    rules,
                    styleRule;
                for (var i = 0, l = sheets.length; i < l; i++) {
                    try {
                        sheet = sheets[i];
                        if (!sheet || !_acceptSheet(sheet)) continue; // exclude all media type except screen
                        rules = sheet.rules || sheet.cssRules;
                        if (rules === null) continue;
                        styleRule = _findStyleInRules(rules, selector);
                        if (styleRule !== null) {
                            _stylesCache[selector] = styleRule;
                            return styleRule;
                        }
                    } catch (e) {
                        console.log(e.message);
                        if (e.name === 'SecurityError') continue;
                        else throw e;
                    }
                }
                _stylesCache[selector] = "undefined";
                return _stylesCache[selector];
            },

            /**
             * returns true if a CSS rule corresponding to the selector rule was found among all
             * declared style sheets in the document
             * @param selector
             */
            hasRule:function (selector) {
                return this.findStyle(selector) !== "undefined";
            },

            /**
             * return the maximum number in milliseconds of a comma separated expression of CSS durations declarations
             * for instance '1s,2s' returns 2000.
             * @param expression
             */
            getMillis:function (expression) {
                var tokens = expression.split(","),
                    millis = 0,
                    t;
                _.each(tokens, function (token) {
                    t = parseFloat(token.replace("s", "").replace("m", ""));
                    millis = Math.max(millis, isNaN(t) ? 0 : t * (token.indexOf("ms") === -1 ? 1000 : 1));
                });
                return millis;
            },

            /**
             * return the total duration including delay of the CC3 transition in the CCS rule defined by the selector passed as parameter
             * @param selector
             */
            getTransDuration:function (selector) {
                if (!this.transitions) return 0;
                return _transitionsCache[selector] || (function (self) {
                    var style,
                        duration = 0;
                    if (self.hasRule(selector)) {
                        style = self.findStyle(selector);
                        duration = self.getMillis(style[self.transitions.durationProp]) + self.getMillis(style[self.transitions.delayProp]);
                    }
                    _transitionsCache[selector] = duration;
                    return _transitionsCache[selector];
                })(this);

            }
        };

    }(document));

    //---------
    // Core
    //---------
    /**
     * The ViewStateTarget object wraps an element (queried by the DOM selector library) that is included or excluded in a view state.
     * The class provides methods to manage the element visibility:display:block/none or visibility:visible/hidden
     * according the keepLayout option in the constructor
     * @type {*}
     */
    var ViewStateTarget = (function (CSS, config) {

        var _displayPolicies = [
            {
                type:"display",
                yes:"block",
                no:"none"
            },
            {
                type:"visibility",
                yes:"visible",
                no:"hidden"
            }

        ];

        var ViewStateTarget = function ($el, keepLayout) {
            this.$el = $el;
            this.display = _displayPolicies[keepLayout ? 1 : 0];
            this.ensure();
        };

        ViewStateTarget.prototype = {
            ensure:function () {
                if (this.$el.attr("class") === void 0) throw new Error(this.$el.selector + " element(s) must have at least a base style class");
                this.baseStyle = this.$el.attr("class").split(" ").pop();
            },

            isDisplayed:function () {
                // its' simpler to compare to the not displayed css value because in the case of display block/none
                // the initial display value of the element could not be "block"  but "inline-block" or else
                return this.$el.css(this.display.type) !== this.display.no;
            },

            toggle:function () {
                this.$el.css(this.display.type, this.isDisplayed() ? this.display.no : this.display.yes);
            },

            removeStateStyle:function (state) {
                var style = this.baseStyle + config.cssModifier + state;
                if (style && this.$el.hasClass(style)) this.$el.removeClass(style);
            },

            addStateStyle:function (state) {
                var selector = this.getStyleSelector(state);
                if (CSS.hasRule(selector)) this.$el.addClass(selector.replace(".", ""));
            },

            getStyleSelector:function (state) {
                return "." + this.baseStyle + config.cssModifier + state;
            }

        };

        return ViewStateTarget;
    }(CSS, config));

    /**
     *  The ViewState class encapsulate the different states declared on a DOM element.
     * - it references arrays of child DOM elements (state targets) that are included or excluded from the state
     * - the class provide an 'enter' and an 'exit' method that manages the state targets lifecycle during states transitions
     * @type {*}
     */
    var ViewState = (function (ViewStateTarget) {

        /**
         * @param name : the state name
         * @param $el : the DOM element targeted as a state container
         * @param keepLayout: the display policy for state targets.
         * @constructor
         */
        var ViewState = function (name, $el, keepLayout) {
            this.$el = $el;
            this.name = name;
            this.keepLayout = keepLayout;
            this.transDuration = -1;
            this.inclusions = [];
            this.exclusions = [];
        };

        ViewState.prototype = {

            addElement:function ($el, isIncluded) {
                (isIncluded ? this.inclusions : this.exclusions).push(new ViewStateTarget($el, this.keepLayout));
            },

            /**
             * the exit function removes all the state style class on each included target
             */
            exit:function () {
                _.each(this.inclusions, function (target) {
                    target.removeStateStyle(this.name);
                }, this);
            },

            /**
             * the enter state function hides all exclusions and shows all inclusions
             */
            enter:function () {
                _.each(this.exclusions, function (target) {
                    this._update(target, false);
                }, this);
                _.each(this.inclusions, function (target) {
                    this._update(target, true);
                }, this);
            },

            /**
             * update the visibility of a the state target and applies the state style class if the target has to be visible
             * @param target
             * @param mustDisplay
             * @private
             */
            _update:function (target, mustDisplay) {
                if (mustDisplay !== target.isDisplayed()) target.toggle();
                if (mustDisplay) target.addStateStyle(this.name);
            }

        };

        return ViewState;

    }(ViewStateTarget));

    /**
     * The CSS3StateTransition triggers the CSS3 transitions on a view state by applying style that contains transitions
     * and waits for the transition to be completed to invoke a callback method.
     * The listening strategy is based on full transition duration and not on transitionEnd events handling
     * @type {*}
     */

    var CSS3StateTransition = (function (CSS) {

        var CSS3StateTransition = function () {
            this.isPlaying = false;
            this.callBack = null;
            this.onCompleteCallBack = _.bind(this._onComplete, this);
        };

        CSS3StateTransition.prototype = {

            playOn:function (state) {
                this.isPlaying = true;
                this._playOn(state, false);
            },

            reverseOn:function (state) {
                this.isPlaying = true;
                this._playOn(state, true);
            },

            _playOn:function (state, reverseIt) {
                if (reverseIt) state.exit();
                else state.enter();
                var duration = this._getTransDuration(state);
                if (duration === 0) return this._onComplete();
                setTimeout(this.onCompleteCallBack, duration);
            },

            _onComplete:function () {
                this.callBack();
                this.isPlaying = false;
            },

            _getTransDuration:function (state) {
                if (state.transDuration >= 0) return state.transDuration;
                var duration = 0;
                _.each(state.inclusions, function (target) {
                    duration = Math.max(CSS.getTransDuration(target.getStyleSelector(state.name)), duration);
                });
                // cache transition in the state object
                state.transDuration = duration;
                return duration;
            }

        };

        return CSS3StateTransition;

    })(CSS);

    /**
     * the ViewStatesManager is the delegate of a StatesClient that manages its state change, without listening to transitions durations
     * @type {*}
     */
    var ViewStatesManager = (function () {

        /**
         *
         * @param attributes
         * @param options
         * @constructor
         */
        var ViewStatesManager = function (attributes, options) {
            this.view = attributes.view;
            this.states = attributes.states;
            this.initialize.call(this, options);
        };

        ViewStatesManager.prototype = {

            initialize:function (options) {
                this.silent = Boolean(options.silent);
                this.nextState = this.currentState = null;
            },

            notifyView:function (event, stateName) {
                if (!this.silent) this.view.trigger(event, event, stateName);
            },

            setState:function (name) {
                this.ensureState(name);
                this.nextState = this.states[name];
                this.exitCurrent();
                this.enterNext();
            },

            ensureState:function (name) {
                if (this.states[name] === void 0) throw new Error("unknown state:-" + name + "-");
            },

            exitCurrent:function () {
                if (!this.currentState) return;
                if (this.nextState === this.currentState.name) return;
                this.notifyView(EXIT, this.currentState.name);
                this.currentState.exit();
                this.notifyView(EXITED, this.currentState.name);
            },

            enterNext:function () {
                this.notifyView(ENTER, this.nextState.name);
                this.nextState.enter();
                this.currentState = this.nextState;
                this.afterNextEntered();
            },
            afterNextEntered:function () {
                this.currentState = this.nextState;
                this.notifyView(CHANGED, this.nextState.name);
            }
        };
        // borrows the extend function from Backbone
        ViewStatesManager.extend = Backbone.View.extend;

        return ViewStatesManager;

    }());

    /**
     * the ViewStatesTransitionsManager  manages states and CSS3 transitions on state change
     * @type {*}
     */
    var ViewStatesTransitionsManager = (function (ViewStatesManager, CSS3StateTransition) {

        var ViewStatesTransitionsManager = ViewStatesManager.extend({

            initialize:function (options) {
                ViewStatesManager.prototype.initialize.call(this, options);
                this.reverseTransitions = !!(options.reverseTransitions);
                this.transition = new CSS3StateTransition();
                this.onCurrentExited = _.bind(this.enterNext, this);
                this.afterNextEntered = _.bind(this.afterNextEntered, this);
            },

            setState:function (name) {
                if (this.transition.isPlaying) return;
                this.ensureState(name);
                this.nextState = this.states[name];
                if (this.nextState === this.currentState) return;
                this.exitCurrent();
            },

            exitCurrent:function () {
                if (!this.currentState) {
                    this.enterNext();
                    return;
                }
                this.notifyView(EXIT, this.currentState.name);
                if (this.reverseTransitions) {
                    this.transition.callBack = this.onCurrentExited;
                    this.transition.reverseOn(this.currentState);
                } else {
                    this.currentState.exit();
                    this.enterNext();
                }

            },

            enterNext:function () {
                if (this.currentState) {
                    this.notifyView(EXITED, this.currentState.name);
                }
                this.notifyView(ENTER, this.nextState.name);
                this.transition.callBack = this.afterNextEntered;
                this.transition.playOn(this.nextState);
            },

            afterNextEntered:function () {
                this.currentState = this.nextState;
                debug(this.currentState.name);
                this.notifyView(CHANGED, this.currentState.name);
            }

        });

        return ViewStatesTransitionsManager;

    }(ViewStatesManager, CSS3StateTransition));

    /**
     *  The make method returns the right state manager regarding the browser ability to supports CSS3 transitions or not.
     * @param attributes : required object members
     * @param options  : optional construction values
     * @return {*}
     */
    ViewStatesManager.make = function (attributes, options) {
        // if the browser doesn't support transitions return a simple StatesManager
        return CSS.transitions ? new ViewStatesTransitionsManager(attributes, options) : new ViewStatesManager(attributes, options);
    };

    /**
     * States builder function: search for all state targets (child elements) in a DOM element to build its view states.
     * @type {*}
     */
    var ViewStatesBuilder = (function (config, ViewState) {

        /**
         *  Create an object literal with states names as keys.
         * @param allStatesNames
         * @return {Object}
         * @private
         */
        var _createStatesObject = function (allStatesNames) {
            allStatesNames = allStatesNames.split(",");

            var statesObject = {},
                name;
            while ((name = allStatesNames.shift())) {
                name = name.trim();
                if (statesObject[name]) throw new Error("the state " + name + " is declared twice");
                statesObject[name] = null;
            }
            return statesObject;

        };

        /**
         * Add an element to a view state
         * @param states: a map of all the ViewStates
         * @param name : the name of the state on which a state target must be added
         * @param $el : the parent DOM element defined as the state container
         * @param $child : the element to be added
         * @param keepLayout : the layout policy for the child element
         * @param included : includes the state target in the View State with the "name" name if true, excludes it otherwise
         * @private
         */
        var _registerStateTarget = function (states, stateName, $el, $child, keepLayout, included) {
            stateName = stateName.trim();
            if (stateName === '') throw new Error("declared state on a child of " + $el.selector + " has an empty name");
            states[stateName] = states[stateName] || new ViewState(stateName, $el, keepLayout);
            states[stateName].addElement($child, included);
        };

        /**
         *
         * @param states
         * @param elStateNames
         * @param $container
         * @param $el
         * @param keepInLayout
         * @param includeIt
         */
        var _addElementToViewStates = function (states, elStateNames, $container, $el, keepInLayout, includeIt) {
            _.each(elStateNames, function (stateName) {
                _registerStateTarget(states, stateName, $container, $el, keepInLayout, includeIt);
            });
            _.each(_.difference(_.keys(states), elStateNames), function (stateName) {
                _registerStateTarget(states, stateName, $container, $el, keepInLayout, !includeIt);
            });
        };

        /**
         *  populate all view states with statesContext object
         * @param states
         * @param statesContext
         * @private
         */
        var _populateStates = function (states, statesContext) {
            var $el,
                declaredStates,
                included,
                $statesContainer = statesContext.container;

            _.each(statesContext.targets, function (targetProperties) {
                $el = targetProperties.$el;
                included = targetProperties.inc !== void 0;
                declaredStates = included ? targetProperties.inc : targetProperties.exc;

                if (declaredStates !== void 0) {
                    declaredStates = declaredStates.trim() === "all" ? statesContext.names : declaredStates.trim();
                    _addElementToViewStates(states, declaredStates.split(','), $statesContainer, $el, statesContext.keepLayout, included);
                }

            });
            // if includeRoot is true add the state container as an included element of every state
            if (statesContext.includeRoot) {
                _.each(statesContext.names.split(","), function (name) {
                    _registerStateTarget(states, name, $statesContainer, $statesContainer, statesContext.keepLayout, true);
                });
            }

        };

        return {
            build:function (stateContext) {
                var states = _createStatesObject(stateContext.names);
                _populateStates(states, stateContext);
                return states;
            }
        };

    }(config, ViewState));

    /**
     *
     * @type {*}
     */
    var StatesContextBuilder = (function (config, $, _) {
        /**
         * return all child elements  matching the selector value passed as parameter using a jQuery compatible selector API .
         * If deepFetch is false it returns only direct children, otherwise returns all elements.
         * @param $el
         * @param selector
         * @param deepFetch
         * @return {*}
         */
        var _findTargets = function ($el, selector, deepFetch) {
            if (deepFetch) return $el.find("[" + selector + "]");
            return $el.children("[" + selector + "]");
        };

        /**
         *  build a statesContext object from DOM data-* states declarations
         * @param $rootEl
         * @param allChildren
         * @return {Object}
         * @private
         */
        var _fromDOM = function ($statesContainer, options) {
            var targets = [],
                key,
                $elements,
                targetDef,
                $target,
                deepFetch = options.deepFetch;
            _.each([config.outAttr, config.inAttr], function (attribute) {
                $elements = _findTargets($statesContainer, attribute, deepFetch);

                key = attribute.replace(config.stateAttr + "-", "");
                _.each($elements, function (target) {
                    $target = $(target);
                    targetDef = _.find(targets, function (item) {
                        return item.$el === $target;
                    }) || {
                        $el:$target
                    };
                    targetDef[key] = $target.attr(attribute).trim();
                    targets.push(targetDef);
                });
            });
            return targets;
        };

        /**
         * build a statesContext object from states options declarations
         * @param $stateContainer
         * @param stateOptions
         * @return {Array}
         * @private
         */
        var _fromOptions = function ($stateContainer, options) {
            var targets = [],
                targetStatesDef,
                $targets,
                $target,
                allTargetOptions = options.targets;

            _.each(_.keys(allTargetOptions), function (selector) {
                $targets = $stateContainer.find(selector);
                _.each($targets, function (target) {
                    $target = $(target);
                    targetStatesDef = {
                        $el:$target
                    };
                    _.each(["inc", "exc"], function (prop) {
                        if (allTargetOptions[selector][prop] !== void 0) targetStatesDef[prop] = allTargetOptions[selector][prop];
                    });

                    if (allTargetOptions[selector].exc !== void 0) targetStatesDef.exc = allTargetOptions[selector].exc;
                    targets.push(targetStatesDef);
                });

            });
            return targets;
        };

        return {
            build:function ($statesContainer, options) {
                if (!$statesContainer || $statesContainer.size === 0) throw new Error("cannot build states on an unknown element");
                var ctx = {},
                    findTargets;
                // the state names must be declared in DOM or options
                ctx.names = options.names || $statesContainer.attr(config.stateAttr);
                if (ctx.names === void 0) throw new Error($statesContainer.selector + " has no state declared");

                ctx.container = $statesContainer;

                // apply all declared options in the context
                _.each(_.keys(options), function (prop) {
                    ctx[prop] = options[prop];
                });

                //default properties initialization
                ctx.keepLayout = ctx.keepLayout === void 0 ? true : ctx.keepLayout;
                ctx.initialState = ctx.initialState ? ctx.initialState : ctx.names.split(",")[0];

                findTargets = _.isObject(options.targets) ? _fromOptions : _fromDOM;
                ctx.targets = findTargets($statesContainer, options);
                return ctx;
            }
        };
    })(config, $, _);

    /**
     * The StateClient defines methods to enhance any Backbone view with view states feature
     * - it delegates the creation of its states to the buildStates function
     * - it delegates the management of the states lifecycle to its stateManager member
     * - it handles state life-cycle events triggered by its view member (un-directly through the stateManager) with the 'onStateEvent' function
     * @type {*}
     */
    var StateClient = (function (buildStates, createStateManager, buildStateContext, events, debug) {

        var initializeStates = function () {
            this.currentState = null;
            this.applyDefaults();
            var statesContext = buildStateContext(this.$el, this.options.states);
            var states = buildStates(statesContext);
            this.manageStates(states);
            this.setState(statesContext.initialState);
        };

        var applyDefaults = function () {
            this.options.states = this.options.states || {};
            if (this.statesDefaults !== void 0) {
                for (var prop in this.statesDefaults) {
                    if(this.statesDefaults.hasOwnProperty(prop)){
                        this.options.states[prop] = this.statesDefaults[prop];
                    }

                }
            }
        };

        var manageStates = function (states) {
            this.stateManager = createStateManager({
                view:this,
                states:states
            }, this.options.states);
            this.on(events.join(" "), this.onStateEvent, this);
        };

        var setState = function (name) {
            this.stateManager.setState(name);
            this.currentState = name;
        };

        /**
         * this function defined as the state life cycle events handler is intended to be overridden
         * @param event: the event name for instance state:enter
         * @param stateName: the state that is targeted by this event
         */
        var onStateEvent = function (event, stateName) {
            debug(this.cid + " " + this.$el.selector + " " + event + " on " + stateName);
        };

        return {
            initializeStates:initializeStates,
            applyDefaults:applyDefaults,
            manageStates:manageStates,
            setState:setState,
            onStateEvent:onStateEvent

        };

    })(ViewStatesBuilder.build, ViewStatesManager.make, StatesContextBuilder.build, [EXIT, EXITED, ENTER, CHANGED], debug);

    /**
     * The makeAsStatesClient method return a Backbone view descendant enhanced with the StateClient behaviour
     * @param View: a Backbone view or one of its descendant
     * @return a sub view of the view passed as parameter
     */
    var makeAsStatesClient = function (View) {
        // add all the functions defined in the behaviour to the view
        var StateClientView = View.extend(StateClient);

        // the render method must be overridden: view states are defined by querying the content of a DOM element attached to view.
        // If a view is rendered via a template engine, states must be defined after the render phase.
        var memo = View.prototype.render;

        StateClientView.prototype.render = function () {
            var rendered = memo.call(this);
            this.initializeStates();
            return rendered || this.$el.html();
        };

        return StateClientView;

    };

    Backbone.States = {
        ENTER:ENTER,
        EXIT:EXIT,
        EXITED:EXITED,
        CHANGE:CHANGED,
        config:config,
        // give public access for tests
        _StatesManager:ViewStatesManager,
        _StatesTransitionsManager:ViewStatesTransitionsManager,
        _ViewState:ViewState,
        _ViewStateTarget:ViewStateTarget,
        _buildStates:ViewStatesBuilder.build,
        _createStateManager:ViewStatesManager.make,
        _CSS:CSS,
        _buildStatesContext:StatesContextBuilder.build
    };

    // define and add the StatesClientView to the root of the Backbone object
    Backbone.StatesClientView = makeAsStatesClient(Backbone.View);

    // add the makeAsStatesClient as a static method of the Backbone.View class
    Backbone.View.makeAsStatesClient = makeAsStatesClient;

}).call(this);


text:
<?php namespace ZhiyangLee\LaravelDoraRpc\Client;

/**
 * User: zhiyanglee
 * Date: 6/25/16
 * Time: 6:22 PM
 */

use DoraRPC\Client;
use Illuminate\Support\ServiceProvider;

class DoraRpcClientServiceProvider extends ServiceProvider
{

    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Boot the provider.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__ . '/../config/doraclient.php' =>  config_path('doraclient.php')
        ]);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('DoraRPC\Client', function($app){

            $clientConfig = $app['config']['doraclient.clientConfig'];
            $clientMode = $app['config']['doraclient.clientMode'];

            $doraRpc = new Client($clientConfig);
            $doraRpc->changeMode($clientMode);

            return $doraRpc;

        });
    }
}