text:
import testtools

from tackerclient.common import exceptions
from tackerclient.common import validators

class FakeParsedArgs():
    pass

class ValidatorTest(testtools.TestCase):

    def _test_validate_int(self, attr_val, attr_name='attr1',
                           min_value=1, max_value=10):
        obj = FakeParsedArgs()
        setattr(obj, attr_name, attr_val)
        ret = validators.validate_int_range(obj, attr_name,
                                            min_value, max_value)
        # Come here only if there is no exception.
        self.assertIsNone(ret)

    def _test_validate_int_error(self, attr_val, expected_msg,
                                 attr_name='attr1', expected_exc=None,
                                 min_value=1, max_value=10):
        if expected_exc is None:
            expected_exc = exceptions.CommandError
        e = self.assertRaises(expected_exc,
                              self._test_validate_int,
                              attr_val, attr_name, min_value, max_value)
        self.assertEqual(expected_msg, str(e))

    def test_validate_int_min_max(self):
        self._test_validate_int(1)
        self._test_validate_int(10)
        self._test_validate_int('1')
        self._test_validate_int('10')
        self._test_validate_int('0x0a')

        self._test_validate_int_error(
            0, 'attr1 "0" should be an integer [1:10].')
        self._test_validate_int_error(
            11, 'attr1 "11" should be an integer [1:10].')
        self._test_validate_int_error(
            '0x10', 'attr1 "0x10" should be an integer [1:10].')

    def test_validate_int_min_only(self):
        self._test_validate_int(1, max_value=None)
        self._test_validate_int(10, max_value=None)
        self._test_validate_int(11, max_value=None)
        self._test_validate_int_error(
            0, 'attr1 "0" should be an integer greater than or equal to 1.',
            max_value=None)

    def test_validate_int_max_only(self):
        self._test_validate_int(0, min_value=None)
        self._test_validate_int(1, min_value=None)
        self._test_validate_int(10, min_value=None)
        self._test_validate_int_error(
            11, 'attr1 "11" should be an integer smaller than or equal to 10.',
            min_value=None)

    def test_validate_int_no_limit(self):
        self._test_validate_int(0, min_value=None, max_value=None)
        self._test_validate_int(1, min_value=None, max_value=None)
        self._test_validate_int(10, min_value=None, max_value=None)
        self._test_validate_int(11, min_value=None, max_value=None)
        self._test_validate_int_error(
            'abc', 'attr1 "abc" should be an integer.',
            min_value=None, max_value=None)

    def _test_validate_subnet(self, attr_val, attr_name='attr1'):
        obj = FakeParsedArgs()
        setattr(obj, attr_name, attr_val)
        ret = validators.validate_ip_subnet(obj, attr_name)
        # Come here only if there is no exception.
        self.assertIsNone(ret)

    def test_validate_ip_subnet(self):
        self._test_validate_subnet('192.168.2.0/24')
        self._test_validate_subnet('192.168.2.3/20')
        self._test_validate_subnet('192.168.2.1')

        e = self.assertRaises(exceptions.CommandError,
                              self._test_validate_subnet,
                              '192.168.2.256')
        self.assertEqual('attr1 "192.168.2.256" is not a valid CIDR.', str(e))


text:
<?php

namespace Sands\Asasi\Policy\Middleware;

use Closure;
use Sands\Asasi\Policy\Policy;

class AuthorizeControllerAccess
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     *
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (!app('policy')->checkCurrentRoute()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()
                    ->to('/')
                    ->with('danger', trans('auth.unauthorized'));
            }
        }

        return $next($request);
    }
}

redpajama_set_name: RedPajamaGithub


text:
      Export Messages

      Generates a JSON file that includes the API endpoint,
      upstream/downstream messages and errors caught while communicating
      with the KGS go server. Helps you report a bug or read KGS messages
      later.

    <form ng-submit="export()">

        Indentation
        <select
          id="indent"
          class="form-control"
          ng-model="indent">
          <option value="1">1 space</option>
          <option value="2">2 spaces</option>
          <option value="3">3 spaces</option>
          <option value="4">4 spaces</option>
          <option value="5">5 spaces</option>
          <option value="6">6 spaces</option>
          <option value="7">7 spaces</option>
          <option value="8">8 spaces</option>
          <option value="tab">Tab</option>
          <option value="0">None</option>
        </select>

          <input
            type="checkbox"
            id="hide-password"
            class="form-control"
            ng-model="hidePassword">
          Hide password

      <input class="btn" type="submit" value="Export">
    </form>


text:
<?php
if ( ! defined( 'ABSPATH' ) ) exit;

/**
* Adds the Style tab to the Quiz Settings page.
*
* @return void
* @since 4.4.0
*/
function qmn_settings_style_tab()
{
	global $mlwQuizMasterNext;
	$mlwQuizMasterNext->pluginHelper->register_quiz_settings_tabs(__("Style", 'quiz-master-next'), 'mlw_options_styling_tab_content');
}
add_action("plugins_loaded", 'qmn_settings_style_tab', 5);

/**
* Adds the Style tab content to the tab.
*
* @return void
* @since 4.4.0
*/
function mlw_options_styling_tab_content()
{
	global $wpdb;
	global $mlwQuizMasterNext;
	$quiz_id = $_GET["quiz_id"];
	if (isset($_POST["save_style_options"]) && $_POST["save_style_options"] == "confirmation")
	{
		//Function Variables
		$mlw_qmn_style_id = intval($_POST["style_quiz_id"]);
		$mlw_qmn_theme = $_POST["save_quiz_theme"];
		$mlw_qmn_style = htmlspecialchars(stripslashes($_POST["quiz_css"]), ENT_QUOTES);

		//Save the new css
		$mlw_save_stle_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET quiz_stye='%s', theme_selected='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_style, $mlw_qmn_theme, $mlw_qmn_style_id ) );
		if ($mlw_save_stle_results != false)
		{
			$mlwQuizMasterNext->alertManager->newAlert(__('The style has been saved successfully.', 'quiz-master-next'), 'success');

			//Insert Action Into Audit Trail
			global $current_user;
			get_currentuserinfo();
			$table_name = $wpdb->prefix . "mlw_qm_audit_trail";
			$insert = "INSERT INTO " . $table_name .
				"(trail_id, action_user, action, time) " .
				"VALUES (NULL , '" . $current_user->display_name . "' , 'Styles Have Been Saved For Quiz Number ".$mlw_qmn_style_id."' , '" . date("h:i:s A m/d/Y") . "')";
			$results = $wpdb->query( $insert );
		}
		else
		{
			$mlwQuizMasterNext->alertManager->newAlert(sprintf(__('There has been an error in this action. Please share this with the developer. Error Code: %s', 'quiz-master-next'), '0015'), 'error');
		}
	}

	if (isset($_GET["quiz_id"]))
	{
		$table_name = $wpdb->prefix . "mlw_quizzes";
		$mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"]));
	}
	?>

		<?php
			echo "<form action='' method='post' name='quiz_style_form'>";
			echo "<input type='hidden' name='save_style_options' value='confirmation' />";
			echo "<input type='hidden' name='style_quiz_id' value='".$quiz_id."' />";
			echo "<input type='hidden' name='save_quiz_theme' id='save_quiz_theme' value='".$mlw_quiz_options->theme_selected."' />";
		?>

<?php _e('Quiz Styles', 'quiz-master-next'); ?>

<?php _e('Choose your style:', 'quiz-master-next'); ?>

		<div onclick="mlw_qmn_theme('default');" id="mlw_qmn_theme_block_default" class="mlw_qmn_themeBlock <?php if ($mlw_quiz_options->theme_selected == 'default') {echo 'mlw_qmn_themeBlockActive';} ?>"><?php _e('Custom', 'quiz-master-next'); ?>

		<?php do_action('mlw_qmn_quiz_themes'); ?>

		<button id="save_styles_button" class="button-primary" onclick="javascript: document.quiz_style_form.submit();"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>

<?php _e('Custom Style CSS', 'quiz-master-next'); ?>

<?php _e('For detailed help and guidance along with a list of different classes used in this plugin, please visit the following link:', 'quiz-master-next'); ?>
		Style Guide

		<button id="save_styles_button" class="button-primary" onclick="javascript: document.quiz_style_form.submit();">Save Quiz Style</button>

				<textarea style="width: 100%; height: 700px;" id="quiz_css" name="quiz_css"><?php echo $mlw_quiz_options->quiz_stye; ?></textarea>

		<button id="save_styles_button" class="button-primary" onclick="javascript: document.quiz_style_form.submit();"><?php _e('Save Quiz Style', 'quiz-master-next'); ?></button>
		</form>

	<?php
}
?>


text:
require 'rails_helper'

RSpec.describe User, type: :model do
  let(:user) { create(:user) }
  describe 'attributes' do
    subject { user }

    it { should respond_to(:name) }
    it { should respond_to(:username) }
    # alias for username
    it { should respond_to(:nickname) }
    it { should respond_to(:email) }
    it { should respond_to(:password) }
    it { should respond_to(:password_confirmation) }
    it { should respond_to(:create_new_auth_token) }
    it { should respond_to(:invite_token) }
  end

  describe 'validations' do
    subject { user }

    it { should validate_presence_of(:name) }
    it { should validate_presence_of(:username) }
    # it { should validate_uniqueness_of(:username).case_insensitive }
    it { should validate_presence_of(:email) }
    it { should validate_uniqueness_of(:email).case_insensitive }
    it { should allow_value('iamokemail@valid.namespace.com').for(:email) }
    it { should_not allow_value('notokatinvalid.@com').for(:email) }
  end

  describe 'assocations' do
    subject { user }

    context 'as a grader' do
      it { should have_many(:scores) }
      it { should have_many(:invites) }
      it { should have_many(:attended_cuppings).through(:accepted_invites) }

      describe '#attended_cuppings' do
        before :each do
          @host = create(:user)
          @past_cuppings = Array.new(3) { create(:cupping, host_id: @host.id) }
          @future_cupping = create(:cupping,
                                   host_id: @host.id,
                                   cup_date: DateTime.now + 1)
          @past_cuppings.each { |cupping| cupping.invites.create(grader_id: user.id) }
          @accepted_invite = user.invites.first
          @accepted_invite.update(status: 1)
        end

        it "must have an 'accepted' status on invite joins user and cupping" do
          expect(user.attended_cuppings.size).to eq 1
          expect(user.attended_cuppings[0].id).to eq @accepted_invite.cupping_id
        end

        it 'must have occurred in the past (as of current date-time)' do
          @future_cupping.invites.create(grader_id: user.id)
          future_accepted_invite = user.invites.where(cupping_id: @future_cupping.id)
          future_accepted_invite.update(status: 1)

          expect(user.attended_cuppings.size).to eq 1
          expect(user.attended_cuppings).not_to include(@future_cupping)
        end
      end
    end
    context 'as a cupping host' do
      it { should have_many(:hosted_cuppings) }
    end
  end
end


text:
package org.miczilla.lcm.domain;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.miczilla.lcm.JsonHelper;

public class OrderRequest
{
  public enum Type
  {
    REQUEST, APPROVAL
  }

  public enum Status
  {
    APPROVED, REJECTED
  }

  private String id = UUID.randomUUID().toString();
  private Map<String, Integer> orderEntries = new HashMap<>();
  private Type type = Type.REQUEST;
  private Status status = Status.REJECTED;

  public String getId()
  {
    return id;
  }

  public void setId(final String id)
  {
    this.id = id;
  }

  public Map<String, Integer> getOrderEntries()
  {
    return orderEntries;
  }

  public void setOrderEntries(final Map<String, Integer> orderEntries)
  {
    this.orderEntries = orderEntries;
  }

  public void addOrderEntry(final String productId, final int amount)
  {
    this.orderEntries.put(productId, amount);
  }

  public Type getType()
  {
    return type;
  }

  public void setType(final Type type)
  {
    this.type = type;
  }

  public Status getStatus()
  {
    return status;
  }

  public void setStatus(final Status status)
  {
    this.status = status;
  }

  @Override
  public boolean equals(final Object o)
  {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    final OrderRequest that = (OrderRequest) o;
    return new EqualsBuilder()
      .append(id, that.id)
      .isEquals();
  }

  @Override
  public int hashCode()
  {
    return new HashCodeBuilder(17, 37)
      .append(id)
      .toHashCode();
  }

  @Override
  public String toString()
  {
    return JsonHelper.marshal(this);
  }
}


text:
:: Purpose:       Rotating differential backup using 7-Zip for compression.
:: Requirements:  - forfiles.exe from Microsoft
::                - 7-Zip
:: Author:        vocatus on reddit.com/r/sysadmin ( vocatus.gate@gmail.com ) // PGP key ID: 0x82A211A2
:: Version:       1.5.1 * Add standard boilerplate comments
::                1.5.0 * Overhauled Date/Time conversion so we can handle ALL versions of Windows using ANY local date-time format
::                1.4.9 * Reworked CUR_DATE variable to handle more than one Date/Time format
::                        Can now handle all Windows date formats
::                1.4.8 + Added SCRIPT_UPDATED variable to timestamp last update of the script
::                1.4.7 - Removed some redundant %TIME% stamps in the logs, under the Cleanup section
::                1.4.6 + Added two additional "help" flags: "-h" and "--help"
::                1.4.5 + Added better instructions for what variables can be set to
::                1.4.4 + Added quotes around variables that could contain spaces in a few places
::                      * Some comment cleanup, and some logging formatting cleanup.
::                1.4.3 / Tweaked logging to only display exclamation point if there was an error
::                      / Tweaked logging to display time correctly (no extra spaces)
::                1.4.2 / Some logging tweaks
::                1.4.1 / Some logging tweaks
::                1.4   + Added quotes around SOURCE variable that were missing in a couple places
::                1.3   * Fixed backup archiving - wasn't rotating properly on network paths. We use pushd to get around this
::                      - Added "-s" option to show job options that the script WOULD execute with
::                      - Major overhaul of code order and logic. Stuff should break less now.
::                      - Many fixes to exclusions file checking
::                1.2   - Fixed problem with cleaning backups. Now cleans staging area and long-term destination area.
::                        Normally an archive (-a) switch cleans the staging area, but now the -c switch does as well, just in case.
::                      - Also fixed issue with forfiles.exe not being able to read UNC paths. We use pushd to get around this.
::                        Pushd auto-assigns the next available drive letter to a UNC path, then discards it when we use popd.
::                1.1   - Added option to use an exclude file to specify files/folders to exclude from the backup
::                1.0b    Some tweaks to logging
::                1.0     Initial write

:: Notes:         My intention for this script was to keep the logic controlling schedules, backup type, etc out of the script and
::                let an invoking program handle it (e.g. Task Scheduler). You simply run this script with a flag to perform an action.
::                If you want to schedule monthly backups, purge old files, etc, just set up task scheduler jobs for those tasks,
::                where each job calls the script with a different flag.

:: Usage:         Run this script without any flags for a list of possible actions. Run it with a flag to perform that action.
::                Flags:
::                 -f   create full backup
::                 -d   create differential backup (full backup must already exist)
::                 -r   restore from a backup (extracts to your staging area)
::                 -a   archive (close out/rotate) the current backup set. This:
::                      1. moves all .7z files in the %DESTINATION% into a folder named with the current date
::                      2. deletes all .7z files from the staging area
::                 -c   clean up (delete) old backup sets from staging and destination. If you specify a number
::                      of days after the command it will run automatically without any confirmation. Be careful with this!
::                 -s   show job options (show what the variables are set to)

:: Important:     If you want to set this script up in Windows Task Scheduler, be aware that Task Scheduler
::                can't use mapped network drives (X:\, Z:\, etc) when it is set to "Run even if user isn't logged on."
::                The task will simply fail to do anything (because Scheduler can't see the drives). To work around this use
::                UNC paths instead (\\server\backup_folder etc) for your source, destination, and staging areas.

:: TODO:          1. Add md5sum checksum file in the backup directory (md5sum each full and diff and store in a file)
SETLOCAL

:::::::::::::::
:: VARIABLES :: -- Set these to your desired values
:::::::::::::::
:: Rules for variables:
::  * NO quotes!                       (bad:  "c:\directory\path"       )
::  * NO trailing slashes on the path! (bad:   c:\directory\            )
::  * Spaces are okay                  (okay:  c:\my folder\with spaces )
::  * Network paths are okay           (okay:  \\server\share name      )
::                                     (       \\172.16.1.5\share name  )
:: Specify the folder you want to back up here.
set SOURCE=R:\

:: Work area where everything is stored while compressing. Should be a fast drive or something that can handle a lot of writes
:: Recommend not using a network share unless it's Gigabit or faster.
set STAGING=P:\backup_staging

:: This is the final, long-term destination for your backup after it is compressed.
set DESTINATION=\\server\personal

:: If you want to customize the prefix of the backup files, do so here. Don't use any special characters (like underscores)
:: The script automatically suffixes an underscore to this name. Recommend not changing this unless you really need to.
::  * Spaces are NOT OKAY to use here!
set BACKUP_PREFIX=backup

:: OPTIONAL: If you want to exclude some files or folders, you can specify your exclude file here. The exclude file is a list of
:: files or folders (wildcards in the form of * are allowed and recommended) to exclude.
:: If you specify a file here and the script can't find it, it will abort.
:: If you leave this blank, the script won't ignore any files.
set EXCLUSIONS_FILE=R:\Scripts\sysadmin\backup_differential_excludes.txt

:: Log settings. Max size is how big (in bytes) the log can be before it is archived. 1048576 bytes is one megabyte
set LOGPATH=%SystemDrive%\Logs
set LOGFILE=%COMPUTERNAME%_%BACKUP_PREFIX%_differential.log
set LOG_MAX_SIZE=104857600

:: Location of 7-Zip and forfiles.exe
set SEVENZIP="C:\Program Files\7-Zip\7z.exe"
set FORFILES=%WINDIR%\system32\forfiles.exe

:: --------------------------- Don't edit anything below this line --------------------------- ::

:::::::::::::::::::::
:: PREP AND CHECKS ::
:::::::::::::::::::::
@echo off && cls
set SCRIPT_VERSION=1.5.1
set SCRIPT_UPDATED=2015-08-27
:: Get the date into ISO 8601 standard date format (yyyy-mm-dd) so we can use it
FOR /f %%a in ('WMIC OS GET LocalDateTime ^| find "."') DO set DTS=%%a
set CUR_DATE=%DTS:~0,4%-%DTS:~4,2%-%DTS:~6,2%

:: Preload variables for use later
set JOB_TYPE=%1
set JOB_ERROR=0
set DAYS=%2
set RESTORE_TYPE=NUL
set SCRIPT_NAME=%0%

::::::::::::::::::::::::::::
:: JOB TYPE DETERMINATION ::
::::::::::::::::::::::::::::
:job_type_determination
if '%JOB_TYPE%'=='' set JOB_TYPE=help
if '%JOB_TYPE%'=='/?' set JOB_TYPE=help
if '%JOB_TYPE%'=='-?' set JOB_TYPE=help
if '%JOB_TYPE%'=='-h' set JOB_TYPE=help
if '%JOB_TYPE%'=='--help' set JOB_TYPE=help
if /i '%1'=='/f' set JOB_TYPE=full
if /i '%1'=='-f' set JOB_TYPE=full
if /i '%1'=='/d' set JOB_TYPE=differential
if /i '%1'=='-d' set JOB_TYPE=differential
if /i '%1'=='/r' set JOB_TYPE=restore
if /i '%1'=='-r' set JOB_TYPE=restore
if /i '%1'=='/a' set JOB_TYPE=archive_backup_set
if /i '%1'=='-a' set JOB_TYPE=archive_backup_set
if /i '%1'=='/c' set JOB_TYPE=cleanup_archives
if /i '%1'=='-c' set JOB_TYPE=cleanup_archives
if /i '%1'=='/s' goto show_options
if /i '%1'=='-s' goto show_options
:: If none of the above were specified then show the help screen
if %JOB_TYPE%==help (
	echo.
	echo   %SCRIPT_NAME% v%SCRIPT_VERSION%
	echo.
	echo   Usage: %SCRIPT_NAME% ^< -f ^| -d ^| -r ^| -a ^| -c ^[days^] ^>
	echo.
	echo   Flags:
	echo    -f:  create a full backup
	echo    -d:  create a differential backup ^(requires an existing full backup^)
	echo    -r:  restore from a backup ^(extracts to %STAGING%\%BACKUP_PREFIX%_restore^)
	echo    -a:  archive the current backup set. This will:
	echo           1. move all .7z files located in:
	echo              %DESTINATION%
	echo              into a dated archive folder.
	echo           2. purge ^(delete^) all copies in the staging area ^(%STAGING%^)
	echo    -c:  clean ^(AKA delete^) archived backup sets from staging and long-term storage.
	echo         Optionally specify number of days to run automatically. Be careful with this!
	echo         Note that this requires a previously-archived backup set ^(-a option^)
	echo    -s:  show job options ^(show what parameters the script WOULD execute with^)
	echo.
	echo   Edit this script before running it to specify your source, destination, and work directories.
	goto end
	)

:::::::::::::::::::::::
:: LOG FILE HANDLING ::
:::::::::::::::::::::::
:log
:: Make the logfile if it doesn't exist
if not exist %LOGPATH% mkdir %LOGPATH%
if not exist %LOGPATH%\%LOGFILE% echo. > %LOGPATH%\%LOGFILE%

:: Check log size. If it's less than our max, then go ahead and get started
for %%R in (%LOGPATH%\%LOGFILE%) do if %%~zR LSS %LOG_MAX_SIZE% goto required_files_check

:: If the log was too big, go ahead and rotate it.
pushd %LOGPATH% 2>&1
del /F %LOGFILE%.ancient 2>NUL
rename %LOGFILE%.oldest %LOGFILE%.ancient 2>NUL
rename %LOGFILE%.older %LOGFILE%.oldest 2>NUL
rename %LOGFILE%.old %LOGFILE%.older 2>NUL
rename %LOGFILE% %LOGFILE%.old 2>NUL
popd

::::::::::::::::::::::::::
:: REQUIRED FILES CHECK ::
::::::::::::::::::::::::::
:required_files_check
:: Make sure we can find 7-Zip
IF NOT EXIST %SEVENZIP% (
		echo %TIME%   ERROR: Couldn't find 7z.exe when script was invoked.>> %LOGPATH%\%LOGFILE%
		cls
		color 0c
		echo.
		echo  ERROR:
		echo.
		echo  Cannot find 7z.exe. You must edit this script
		echo  and specify the location of 7-Zip before continuing.
		echo.
		echo  Script tried to find it here:
		echo  %SEVENZIP%
		echo.
		pause
		color
		cls
		goto end
		)
:: Make sure we can find forfiles.exe
IF NOT EXIST %FORFILES% (
		echo %TIME%   ERROR: Couldn't find forfiles.exe when script was invoked.>> %LOGPATH%\%LOGFILE%
		cls
		color 0c
		echo.
		echo  ERROR:
		echo.
		echo  Cannot find forfiles.exe. You must edit this script
		echo  and specify the location of forfiles.exe before continuing.
		echo.
		echo  Script tried to find it here:
		echo  %FORFILES%
		echo.
		pause
		color
		cls
		goto end
		)

::::::::::::::::::::
:: DECISION POINT ::
::::::::::::::::::::
:decision_point
if '%JOB_TYPE%'=='full' goto %JOB_TYPE%
if '%JOB_TYPE%'=='differential' goto %JOB_TYPE%
if '%JOB_TYPE%'=='restore' goto %JOB_TYPE%
if '%JOB_TYPE%'=='archive_backup_set' goto %JOB_TYPE%
if '%JOB_TYPE%'=='cleanup_archives' goto %JOB_TYPE%
goto end

::::::::::::::::::::::
:: SHOW JOB OPTIONS ::
::::::::::::::::::::::
:show_options
echo.
echo  Current configuration:
echo.
echo   Script Version:       %SCRIPT_VERSION%
echo   Script Updated:       %SCRIPT_UPDATED%
echo   Source:               %SOURCE%
echo   Destination:          %DESTINATION%
echo   Staging area:         %STAGING%
echo   Exclusions file:      %EXCLUSIONS_FILE%
echo   Backup prefix:        %BACKUP_PREFIX%
echo   Restores unpacked to: %STAGING%\%BACKUP_PREFIX%_restore
echo   Log file:             %LOGPATH%\%LOGFILE%
echo   Log max size:         %LOG_MAX_SIZE% bytes
echo.
echo  Edit this script with a text editor to customize these options.
echo.
goto end

::::::::::::::::::::::::
:: CREATE FULL BACKUP ::
::::::::::::::::::::::::
:full
:: Check for an exclude file and make sure it exists.
if '%EXCLUSIONS_FILE%'=='' goto full_go
IF NOT EXIST %EXCLUSIONS_FILE% (
		echo.
		echo %TIME%   ERROR: An exclusions file was specified but couldn't be found:>> %LOGPATH%\%LOGFILE%
		echo                %EXCLUSIONS_FILE%>> %LOGPATH%\%LOGFILE%
		echo %TIME%   ERROR: An exclusions file was specified but couldn't be found:
		echo                %EXCLUSIONS_FILE%
		goto end
		)
:full_go
echo.
echo.>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo  Differential Backup Script v%SCRIPT_VERSION% - initialized %CUR_DATE% at%TIME% by %USERDOMAIN%\%USERNAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Script location:  %~dp0\%SCRIPT_NAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Job Options>> %LOGPATH%\%LOGFILE%
echo   Job type:        Full backup>> %LOGPATH%\%LOGFILE%
echo   Source:          %SOURCE%>> %LOGPATH%\%LOGFILE%
echo   Destination:     %DESTINATION%>> %LOGPATH%\%LOGFILE%
echo   Staging area:    %STAGING%>> %LOGPATH%\%LOGFILE%
echo   Exclusions file: %EXCLUSIONS_FILE%>> %LOGPATH%\%LOGFILE%
echo   Backup prefix:   %BACKUP_PREFIX%>> %LOGPATH%\%LOGFILE%
echo   Log location:    %LOGPATH%\%LOGFILE%>> %LOGPATH%\%LOGFILE%
echo   Log max size:    %LOG_MAX_SIZE% bytes>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo %TIME%   Performing full backup of %SOURCE%...>> %LOGPATH%\%LOGFILE%
echo %TIME%   Performing full backup of %SOURCE%...

:: Build archive
echo.
echo %TIME%   Building archive in staging area %STAGING%...>> %LOGPATH%\%LOGFILE%
echo %TIME%   Building archive in staging area %STAGING%...
echo.>> %LOGPATH%\%LOGFILE%
echo ------- [ Beginning of 7zip output ] ------->> %LOGPATH%\%LOGFILE% 2>&1
if not '%EXCLUSIONS_FILE%'=='' %SEVENZIP% a "%STAGING%\%BACKUP_PREFIX%_full.7z" "%SOURCE%" -xr@"%EXCLUSIONS_FILE%" >> %LOGPATH%\%LOGFILE%
if '%EXCLUSIONS_FILE%'=='' %SEVENZIP% a "%STAGING%\%BACKUP_PREFIX%_full.7z" "%SOURCE%" >> %LOGPATH%\%LOGFILE%
echo ------- [    End of 7zip output    ] ------->> %LOGPATH%\%LOGFILE% 2>&1
echo.>> %LOGPATH%\%LOGFILE%
echo.

:: Report on the build
if %ERRORLEVEL%==0 (
		echo %TIME%   Archive built successfully.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Archive built successfully.
		)
if not %ERRORLEVEL%==0 (
		set JOB_ERROR=1
		echo %TIME% ! Archive built with errors.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! Archive built with errors.
		)
:: Upload to destination
echo.
echo %TIME%   Uploading %BACKUP_PREFIX%_full.7z to %DESTINATION%...>> %LOGPATH%\%LOGFILE%
echo %TIME%   Uploading %BACKUP_PREFIX%_full.7z to %DESTINATION%...
echo.
echo.>> %LOGPATH%\%LOGFILE%
xcopy "%STAGING%\%BACKUP_PREFIX%_full.7z" "%DESTINATION%\" /Q /J /Y /Z >> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%

:: Report on the upload
if %ERRORLEVEL%==0 (
		echo %TIME%   Uploaded full backup to '%DESTINATION%' successfully.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Uploaded full backup to '%DESTINATION%' successfully.
		) ELSE (
		set JOB_ERROR=1
		echo %TIME% ! Upload of full backup to '%DESTINATION%' failed.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! Upload of full backup to '%DESTINATION%' failed.
		)

goto done

::::::::::::::::::::::::::::::::
:: CREATE DIFFERENTIAL BACKUP ::
::::::::::::::::::::::::::::::::
:differential
:: Check for an exclude file and make sure it exists.
if '%EXCLUSIONS_FILE%'=='' goto differential_go
IF NOT EXIST %EXCLUSIONS_FILE% (
		echo %TIME%   An exclusions file was specified but couldn't be found. Aborting.>> %LOGPATH%\%LOGFILE%
		echo           Looked here: %EXCLUSIONS_FILE%>> %LOGPATH%\%LOGFILE%
		echo %TIME%   An exclusions file was specified but couldn't be found. Aborting.
		echo           Looked here: %EXCLUSIONS_FILE%
		goto end
		)
:differential_go
echo.>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo  Differential Backup Script v%SCRIPT_VERSION% - initialized %CUR_DATE% at%TIME% by %USERDOMAIN%\%USERNAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Script location:  %SCRIPT_NAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Job Options>> %LOGPATH%\%LOGFILE%
echo   Job type:        Differential backup>> %LOGPATH%\%LOGFILE%
echo   Source:          %SOURCE%>> %LOGPATH%\%LOGFILE%
echo   Destination:     %DESTINATION%>> %LOGPATH%\%LOGFILE%
echo   Staging area:    %STAGING%>> %LOGPATH%\%LOGFILE%
echo   Exclusions file: %EXCLUSIONS_FILE%>> %LOGPATH%\%LOGFILE%
echo   Backup prefix:   %BACKUP_PREFIX%>> %LOGPATH%\%LOGFILE%
echo   Log location:    %LOGPATH%\%LOGFILE%>> %LOGPATH%\%LOGFILE%
echo   Log max size:    %LOG_MAX_SIZE% bytes>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo.
:: Check for full backup existence
if not exist "%STAGING%\%BACKUP_PREFIX%_full.7z" (
		set JOB_ERROR=1
		echo %TIME% ! ERROR: Couldn't find full backup file ^(%BACKUP_PREFIX%_full.7z^). You must create a full backup before a differential can be created.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! ERROR: Couldn't find full backup file ^(%BACKUP_PREFIX%_full.7z^). You must create a full backup before a differential can be created.
		goto end
		) ELSE (
		:: Backup existed, so go ahead
		echo %TIME%   Performing differential backup of %SOURCE%...>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Performing differential backup of %SOURCE%...
		)

:: Build archive
:differential_build
echo.
echo %TIME%   Building archive in staging area %STAGING%...>> %LOGPATH%\%LOGFILE%
echo %TIME%   Building archive in staging area %STAGING%...
echo.>> %LOGPATH%\%LOGFILE%
echo ------- [ Beginning of 7zip output ] ------->> %LOGPATH%\%LOGFILE% 2>&1
if not '%EXCLUSIONS_FILE%'=='' %SEVENZIP% u "%STAGING%\%BACKUP_PREFIX%_full.7z" "%SOURCE%" -ms=off -mx=9 -xr@"%EXCLUSIONS_FILE%" -t7z -u- -up0q3r2x2y2z0w2!"%STAGING%\%BACKUP_PREFIX%_differential_%CUR_DATE%.7z" >> %LOGPATH%\%LOGFILE% 2>&1
if '%EXCLUSIONS_FILE%'=='' %SEVENZIP% u "%STAGING%\%BACKUP_PREFIX%_full.7z" "%SOURCE%" -ms=off -mx=9 -t7z -u- -up0q3r2x2y2z0w2!"%STAGING%\%BACKUP_PREFIX%_differential_%CUR_DATE%.7z" >> %LOGPATH%\%LOGFILE% 2>&1
echo ------- [    End of 7zip output    ] ------->> %LOGPATH%\%LOGFILE% 2>&1
echo.>> %LOGPATH%\%LOGFILE%
echo.
:: Report on the build
if %ERRORLEVEL%==0 (
		echo %TIME%   Archive built successfully.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Archive built successfully.
		)
if not %ERRORLEVEL%==0 (
		set JOB_ERROR=1
		echo %TIME% ! Archive built with errors.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! Archive built with errors.
		)

:: Upload to destination
echo.
echo %TIME%   Uploading %BACKUP_PREFIX%_differential_%CUR_DATE%.7z to %DESTINATION%... >> %LOGPATH%\%LOGFILE%
echo %TIME%   Uploading %BACKUP_PREFIX%_differential_%CUR_DATE%.7z to %DESTINATION%...
echo.>> %LOGPATH%\%LOGFILE%
xcopy "%STAGING%\%BACKUP_PREFIX%_differential_%CUR_DATE%.7z" "%DESTINATION%\" /Q /J /Y /Z >> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
:: Report on the upload
if %ERRORLEVEL%==0 (
		echo %TIME%   Uploaded differential file successfully.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Uploaded differential file successfully.
		)

if not %ERRORLEVEL%==0 (
		set JOB_ERROR=1
		echo %TIME% ! Upload of differential file failed.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! Upload of differential file failed.
		)

goto done

:::::::::::::::::::::::::::
:: RESTORE FROM A BACKUP ::
:::::::::::::::::::::::::::
:restore
echo.
echo  Restoring from a backup set.
echo.
echo   These backups are available:
echo.
dir /B /A:-D "%STAGING%" 2>NUL
echo.
echo  Enter the filename to restore from exactly as it appears above.
echo  ^(Note: archived backup sets are not shown^)
echo.
:restore_menu
set BACKUP_FILE=
set /p BACKUP_FILE=Filename:
if %BACKUP_FILE%==exit goto end
echo.
:: Make sure user didn't fat-finger the file name
if not exist "%STAGING%\%BACKUP_FILE%" (
		echo  ! ERROR: That file wasn^'t found. Check your typing and try again. && echo. && goto restore_menu
		goto restore_menu
		)

set CHOICE=y
echo  ! Selected file '%BACKUP_FILE%'
echo.
set /p CHOICE=Is this correct [y]?:
	if not %CHOICE%==y echo  Going back to menu... && goto restore_menu
echo.
echo  Great. Press any key to get started.
pause >NUL
echo  ! Starting restoration at %TIME% on %CUR_DATE%
echo    This might take a while, be patient...

:: Test if we're doing a full or differential restore.
if %BACKUP_FILE%==%BACKUP_PREFIX%_full.7z set RESTORE_TYPE=full
if not %BACKUP_FILE%==%BACKUP_PREFIX%_full.7z set RESTORE_TYPE=differential

:restore_go
echo.>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo  Differential Backup Script v%SCRIPT_VERSION% - initialized %CUR_DATE% at%TIME% by %USERDOMAIN%\%USERNAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Script location:  %SCRIPT_NAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Job Options>> %LOGPATH%\%LOGFILE%
echo   Job type:        %RESTORE_TYPE% restore>> %LOGPATH%\%LOGFILE%
echo   Source:          %STAGING%\%BACKUP_PREFIX%_full.7z>> %LOGPATH%\%LOGFILE%
echo   Destination:     %STAGING%\%BACKUP_PREFIX%\>> %LOGPATH%\%LOGFILE%
echo   Staging area:    %STAGING%>> %LOGPATH%\%LOGFILE%
echo   Exclusions file: %EXCLUSIONS_FILE%>> %LOGPATH%\%LOGFILE%
echo   Backup prefix:   %BACKUP_PREFIX%>> %LOGPATH%\%LOGFILE%
echo   Log location:    %LOGPATH%\%LOGFILE%>> %LOGPATH%\%LOGFILE%
echo   Log max size:    %LOG_MAX_SIZE% bytes>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo.
:: Detect our backup type and inform the user
if %RESTORE_TYPE%==differential (
		echo %TIME%   Restoring from differential backup. Will unpack full backup then differential.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Restoring from differential backup. Will unpack full backup then differential.
		)
if %RESTORE_TYPE%==full (
		echo %TIME%   Restoring from full backup.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Restoring from full backup.
		echo %TIME%   Unpacking full backup...>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Unpacking full backup...
		)

:: Start the restoration
echo.>> %LOGPATH%\%LOGFILE%
echo.
echo ------- [ Beginning of 7zip output ] ------->> %LOGPATH%\%LOGFILE% 2>&1
%SEVENZIP% x "%STAGING%\%BACKUP_PREFIX%_full.7z" -y -o"%STAGING%\%BACKUP_PREFIX%_restore\">> %LOGPATH%\%LOGFILE% 2>&1
echo ------- [    End of 7zip output    ] ------->> %LOGPATH%\%LOGFILE% 2>&1
:: Report on the unpack
if %ERRORLEVEL%==0 (
		echo %TIME%   Full backup unpacked successfully.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Full backup unpacked successfully.
		)
if not %ERRORLEVEL%==0 (
		set JOB_ERROR=1
		echo %TIME% ! Full backup unpacked with errors.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! Full backup unpacked with errors.
		)
:: If we're just doing a full restore (no differential), then go to the end
if %RESTORE_TYPE%==full goto done

:: Now we unpack our differential file
echo.
echo %TIME%   Unpacking differential file %BACKUP_FILE%...>> %LOGPATH%\%LOGFILE%
echo %TIME%   Unpacking differential file %BACKUP_FILE%...
echo.>> %LOGPATH%\%LOGFILE%
echo ------- [ Beginning of 7zip output ] ------->> %LOGPATH%\%LOGFILE% 2>&1
%SEVENZIP% x "%STAGING%\%BACKUP_FILE%" -aoa -y -o"%STAGING%\%BACKUP_PREFIX%_restore\">> %LOGPATH%\%LOGFILE% 2>&1
echo ------- [    End of 7zip output    ] ------->> %LOGPATH%\%LOGFILE% 2>&1
echo.
:: Report on the unpack
if %ERRORLEVEL%==0 (
		echo %TIME%   Differential file unpacked successfully.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Differential file unpacked successfully.
		) ELSE (
		:: Something broke!
		set JOB_ERROR=1
		echo %TIME% ! Differential file unpacked with errors.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! Differential file unpacked with errors.
		)
goto done

::::::::::::::::::::::::
:: ARCHIVE BACKUP SET :: aka rotate backups
::::::::::::::::::::::::
:archive_backup_set
echo.>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo  Differential Backup Script v%SCRIPT_VERSION% - initialized %CUR_DATE% at%TIME% by %USERDOMAIN%\%USERNAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Script location:  %SCRIPT_NAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Job Options>> %LOGPATH%\%LOGFILE%
echo   Job type:        Archive/rotate backup set>> %LOGPATH%\%LOGFILE%
echo   Source:          %SOURCE%>> %LOGPATH%\%LOGFILE%
echo   Destination:     %DESTINATION%>> %LOGPATH%\%LOGFILE%
echo   Staging area:    %STAGING%>> %LOGPATH%\%LOGFILE%
echo   Exclusions file: %EXCLUSIONS_FILE%>> %LOGPATH%\%LOGFILE%
echo   Backup prefix:   %BACKUP_PREFIX%>> %LOGPATH%\%LOGFILE%
echo   Log location:    %LOGPATH%\%LOGFILE%>> %LOGPATH%\%LOGFILE%
echo   Log max size:    %LOG_MAX_SIZE% bytes>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo %TIME%   Archiving current backup set to %DESTINATION%\%CUR_DATE%_%BACKUP_PREFIX%_set.>> %LOGPATH%\%LOGFILE%
echo %TIME%   Archiving current backup set to %DESTINATION%\%CUR_DATE%_%BACKUP_PREFIX%_set.
:: Final destination: Make directory, move files
pushd "%DESTINATION%"
mkdir %CUR_DATE%_%BACKUP_PREFIX%_set >> %LOGPATH%\%LOGFILE%
move /Y *.* %CUR_DATE%_%BACKUP_PREFIX%_set >> %LOGPATH%\%LOGFILE%
popd
echo.
echo %TIME%   Deleting all copies in the staging area...>> %LOGPATH%\%LOGFILE%
echo %TIME%   Deleting all copies in the staging area...
:: Staging area: Delete old files
del /Q /F "%STAGING%\*.7z">> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo.

:: Report
echo.>> %LOGPATH%\%LOGFILE%
echo %TIME%   Backup set archived. All unarchived files in staging area were deleted.>> %LOGPATH%\%LOGFILE%
echo %TIME%   Backup set archived. All unarchived files in staging area were deleted.
echo.>> %LOGPATH%\%LOGFILE%
goto done

:::::::::::::::::::::::::::::::::::
:: CLEAN UP ARCHIVED BACKUP SETS :: aka delete old sets
:::::::::::::::::::::::::::::::::::
:cleanup_archives
IF NOT '%DAYS%'=='' goto cleanup_archives_go

:: List the backup sets
:cleanup_archives_list
echo.
echo CURRENT BACKUP SETS:
echo.
echo IN STAGING          : ^(%STAGING%^)
echo ---------------------
dir /B /A:D "%STAGING%" 2>&1
echo.
echo.
echo IN LONG-TERM STORAGE: ^(%DESTINATION%^)
echo ---------------------
dir /B /A:D "%DESTINATION%" 2>&1
echo.
:cleanup_archives_list2
echo.
set DAYS=180
echo Delete backup sets older than how many days? ^(you will be prompted for confirmation^)
set /p DAYS=[%DAYS%]?:
if %DAYS%==exit goto end
echo.
:: Tell user what will happen
echo THESE BACKUP SETS WILL BE DELETED:
echo ----------------------------------
:: List files that would match.
:: We have to use PushD to get around forfiles.exe not using UNC paths. pushd automatically assigns the next free drive letter
echo From staging:
pushd "%STAGING%"
FORFILES /D -%DAYS% /C "cmd /c IF @isdir == TRUE echo @path" 2>NUL
popd
echo.
echo From long-term storage:
pushd "%DESTINATION%"
FORFILES /D -%DAYS% /C "cmd /c IF @isdir == TRUE echo @path" 2>NUL
popd
echo.
set HMMM=n
set /p HMMM=Is this okay [%HMMM%]?:
if /i %HMMM%==n echo. && echo Canceled. Returning to menu. && goto cleanup_archives_list2
if %DAYS%==exit goto end
echo.
set CHOICE=n
set /p CHOICE=Are you absolutely sure [%CHOICE%]?:
if not %CHOICE%==y echo. && echo Canceled. Returning to menu. && goto cleanup_archives_list2
echo.
echo  Okay, starting deletion.

:: Go ahead and do the cleanup.
:cleanup_archives_go
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo  Differential Backup Script v%SCRIPT_VERSION% - initialized %CUR_DATE% at%TIME% by %USERDOMAIN%\%USERNAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo  Script location:  %SCRIPT_NAME%>> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo   Job type:        Delete archived backup sets older than %DAYS% days.>> %LOGPATH%\%LOGFILE%
echo   Source:          %SOURCE%>> %LOGPATH%\%LOGFILE%
echo   Destination:     %DESTINATION%>> %LOGPATH%\%LOGFILE%
echo   Staging area:    %STAGING%>> %LOGPATH%\%LOGFILE%
echo   Exclusions file: %EXCLUSIONS_FILE%>> %LOGPATH%\%LOGFILE%
echo   Backup prefix:   %BACKUP_PREFIX%>> %LOGPATH%\%LOGFILE%
echo   Log location:    %LOGPATH%\%LOGFILE%>> %LOGPATH%\%LOGFILE%
echo   Log max size:    %LOG_MAX_SIZE% bytes>> %LOGPATH%\%LOGFILE%
echo --------------------------------------------------------------------------------------------------->> %LOGPATH%\%LOGFILE%
echo.>> %LOGPATH%\%LOGFILE%
echo.
echo %TIME%   Deleting backup sets that are older than %DAYS% days...>> %LOGPATH%\%LOGFILE%
echo %TIME%   Deleting backup sets that are older than %DAYS% days...

:: This cleans out the staging area.
:: First FORFILES command tells the logfile what will get deleted. Second command actually deletes.
pushd "%STAGING%"
FORFILES /D -%DAYS% /C "cmd /c IF @isdir == TRUE echo @path" >> %LOGPATH%\%LOGFILE%
FORFILES /S /D -%DAYS% /C "cmd /c IF @isdir == TRUE rmdir /S /Q @path"
popd

:: This cleans out the destination / long-term storage area.
:: First FORFILES command tells the logfile what will get deleted. Second command actually deletes.
pushd "%DESTINATION%"
FORFILES /D -%DAYS% /C "cmd /c IF @isdir == TRUE echo @path" >> %LOGPATH%\%LOGFILE%
FORFILES /S /D -%DAYS% /C "cmd /c IF @isdir == TRUE rmdir /S /Q @path"
popd

echo.
:: Report on the cleanup
if %ERRORLEVEL%==0 (
		echo %TIME%   Cleanup completed successfully.>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Cleanup completed successfully.
		)
if not %ERRORLEVEL%==0 (
		set JOB_ERROR=1
		echo %TIME% ! Cleanup completed with errors.>> %LOGPATH%\%LOGFILE%
		echo %TIME% ! Cleanup completed with errors.
		)
goto done

:::::::::::::::::::::::
:: COMPLETION REPORT ::
:::::::::::::::::::::::
:done
:: One of these displays if the operation was a restore operation
if %RESTORE_TYPE%==full (
		echo %TIME%   Restored full backup to %STAGING%\%BACKUP_PREFIX%>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Restored full backup to %STAGING%\%BACKUP_PREFIX%
		)

if %RESTORE_TYPE%==differential (
		echo.
		echo %TIME%   Restored full and differential backup to %STAGING%\%BACKUP_PREFIX%>> %LOGPATH%\%LOGFILE%
		echo %TIME%   Restored full and differential backup to %STAGING%\%BACKUP_PREFIX%
		)

echo.
echo %TIME%   %SCRIPT_NAME% complete.>> %LOGPATH%\%LOGFILE%
echo %TIME%   %SCRIPT_NAME% complete.
if '%JOB_ERROR%'=='1' echo. && echo %TIME% ! Note: Script exited with errors.>> %LOGPATH%\%LOGFILE%
if '%JOB_ERROR%'=='1' echo. && echo %TIME% ! Note: Script exited with errors. Maybe check the log.

:end
:: Clean up our temp exclude file
if exist %TEMP%\DEATH_BY_HAMSTERS.txt del /F /Q %TEMP%\DEATH_BY_HAMSTERS.txt
ENDLOCAL


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/item_title"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.67"/>

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/bt_storage" />
    </LinearLayout>


text:
namespace views {

namespace internal {

// A helper that combines each border image-set painter with arrows and metrics.
struct BorderImages {
  BorderImages(const int border_image_ids[],
               const int arrow_image_ids[],
               int border_interior_thickness,
               int arrow_interior_thickness,
               int corner_radius);

  scoped_ptr<Painter> border_painter;
  gfx::ImageSkia left_arrow;
  gfx::ImageSkia top_arrow;
  gfx::ImageSkia right_arrow;
  gfx::ImageSkia bottom_arrow;

  // The thickness of border and arrow images and their interior areas.
  // Thickness is the width of left/right and the height of top/bottom images.
  // The interior is measured without including stroke or shadow pixels.
  int border_thickness;
  int border_interior_thickness;
  int arrow_thickness;
  int arrow_interior_thickness;
  // The corner radius of the bubble's rounded-rect interior area.
  int corner_radius;
};

BorderImages::BorderImages(const int border_image_ids[],
                           const int arrow_image_ids[],
                           int border_interior_thickness,
                           int arrow_interior_thickness,
                           int corner_radius)
    : border_painter(Painter::CreateImageGridPainter(border_image_ids)),
      border_thickness(0),
      border_interior_thickness(border_interior_thickness),
      arrow_thickness(0),
      arrow_interior_thickness(arrow_interior_thickness),
      corner_radius(corner_radius) {
  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  border_thickness = rb.GetImageSkiaNamed(border_image_ids[0])->width();
  if (arrow_image_ids[0] != 0) {
    left_arrow = *rb.GetImageSkiaNamed(arrow_image_ids[0]);
    top_arrow = *rb.GetImageSkiaNamed(arrow_image_ids[1]);
    right_arrow = *rb.GetImageSkiaNamed(arrow_image_ids[2]);
    bottom_arrow = *rb.GetImageSkiaNamed(arrow_image_ids[3]);
    arrow_thickness = top_arrow.height();
  }
}

}  // namespace internal

namespace {

// The border and arrow stroke size used in image assets, in pixels.
const int kStroke = 1;

// Macros to define arrays of IDR constants used with CreateImageGridPainter.
#define IMAGE_BORDER(x) { x ## _TOP_LEFT,    x ## _TOP,    x ## _TOP_RIGHT, \
                          x ## _LEFT,        0,            x ## _RIGHT, \
                          x ## _BOTTOM_LEFT, x ## _BOTTOM, x ## _BOTTOM_RIGHT, }
#define IMAGE_BORDER_ACRONYM(x) { x ## _TL, x ## _T, x ## _TR, \
                                  x ## _L,  0,       x ## _R, \
                                  x ## _BL, x ## _B, x ## _BR, }
#define ARROWS(x) { x ## _LEFT, x ## _TOP, x ## _RIGHT, x ## _BOTTOM, }

// Bubble border and arrow image resource ids.
const int kShadowImages[] = IMAGE_BORDER_ACRONYM(IDR_BUBBLE_SHADOW);
const int kShadowArrows[] = { 0, 0, 0, 0 };
const int kNoShadowImages[] = IMAGE_BORDER_ACRONYM(IDR_BUBBLE);
const int kNoShadowArrows[] = { IDR_BUBBLE_L_ARROW, IDR_BUBBLE_T_ARROW,
                                IDR_BUBBLE_R_ARROW, IDR_BUBBLE_B_ARROW, };
const int kBigShadowImages[] = IMAGE_BORDER(IDR_WINDOW_BUBBLE_SHADOW_BIG);
const int kBigShadowArrows[] = ARROWS(IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG);
const int kSmallShadowImages[] = IMAGE_BORDER(IDR_WINDOW_BUBBLE_SHADOW_SMALL);
const int kSmallShadowArrows[] = ARROWS(IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL);

using internal::BorderImages;

// Returns the cached BorderImages for the given |shadow| type.
BorderImages* GetBorderImages(BubbleBorder::Shadow shadow) {
  // Keep a cache of bubble border image-set painters, arrows, and metrics.
  static BorderImages* kBorderImages[BubbleBorder::SHADOW_COUNT] = { NULL };

  CHECK_LT(shadow, BubbleBorder::SHADOW_COUNT);
  struct BorderImages*& set = kBorderImages[shadow];
  if (set)
    return set;

  switch (shadow) {
    case BubbleBorder::SHADOW:
      // Note: SHADOW's border interior thickness is actually 10, but 0 is used
      // here to match the legacy appearance of SHADOW's extra large inset.
      set = new BorderImages(kShadowImages, kShadowArrows, 0, 0, 3);
      break;
    case BubbleBorder::NO_SHADOW:
      set = new BorderImages(kNoShadowImages, kNoShadowArrows, 6, 7, 4);
      break;
    case BubbleBorder::BIG_SHADOW:
      set = new BorderImages(kBigShadowImages, kBigShadowArrows, 23, 9, 2);
      break;
    case BubbleBorder::SMALL_SHADOW:
      set = new BorderImages(kSmallShadowImages, kSmallShadowArrows, 5, 6, 2);
      break;
    case BubbleBorder::SHADOW_COUNT:
      NOTREACHED();
      break;
  }

  return set;
}

}  // namespace

BubbleBorder::BubbleBorder(Arrow arrow, Shadow shadow, SkColor color)
    : arrow_(arrow),
      arrow_offset_(0),
      arrow_paint_type_(PAINT_NORMAL),
      alignment_(ALIGN_ARROW_TO_MID_ANCHOR),
      shadow_(shadow),
      background_color_(color) {
  DCHECK(shadow < SHADOW_COUNT);
  images_ = GetBorderImages(shadow);
}

BubbleBorder::~BubbleBorder() {}

gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& anchor_rect,
                                  const gfx::Size& contents_size) const {
  // Enlarge the contents size by the thickness of the border images.
  gfx::Size size(contents_size);
  const gfx::Insets insets = GetInsets();
  size.Enlarge(insets.width(), insets.height());

  // Ensure the bubble is large enough to not overlap border and arrow images.
  const int min = 2 * images_->border_thickness;
  const int min_with_arrow_width = min + images_->top_arrow.width();
  const int min_with_arrow_thickness = images_->border_thickness +
      std::max(images_->arrow_thickness + images_->border_interior_thickness,
               images_->border_thickness);
  if (is_arrow_on_horizontal(arrow_))
    size.ClampToMin(gfx::Size(min_with_arrow_width, min_with_arrow_thickness));
  else if (has_arrow(arrow_))
    size.ClampToMin(gfx::Size(min_with_arrow_thickness, min_with_arrow_width));
  else
    size.ClampToMin(gfx::Size(min, min));

  int x = anchor_rect.x();
  int y = anchor_rect.y();
  int w = anchor_rect.width();
  int h = anchor_rect.height();
  const int arrow_offset = GetArrowOffset(size);
  const int arrow_size =
      images_->arrow_interior_thickness + kStroke - images_->arrow_thickness;
  const bool mid_anchor = alignment_ == ALIGN_ARROW_TO_MID_ANCHOR;

  // Calculate the bubble coordinates based on the border and arrow settings.
  if (is_arrow_on_horizontal(arrow_)) {
    if (is_arrow_on_left(arrow_)) {
      x += mid_anchor ? w / 2 - arrow_offset : kStroke - GetBorderThickness();
    } else if (is_arrow_at_center(arrow_)) {
      x += w / 2 - arrow_offset;
    } else {
      x += mid_anchor ? w / 2 + arrow_offset - size.width() :
                        w - size.width() + GetBorderThickness() - kStroke;
    }
    y += is_arrow_on_top(arrow_) ? h + arrow_size : -arrow_size - size.height();
  } else if (has_arrow(arrow_)) {
    x += is_arrow_on_left(arrow_) ? w + arrow_size : -arrow_size - size.width();
    if (is_arrow_on_top(arrow_)) {
      y += mid_anchor ? h / 2 - arrow_offset : kStroke - GetBorderThickness();
    } else if (is_arrow_at_center(arrow_)) {
      y += h / 2 - arrow_offset;
    } else {
      y += mid_anchor ? h / 2 + arrow_offset - size.height() :
                        h - size.height() + GetBorderThickness() - kStroke;
    }
  } else {
    x += (w - size.width()) / 2;
    y += (arrow_ == NONE) ? h : (h - size.height()) / 2;
  }

  return gfx::Rect(x, y, size.width(), size.height());
}

int BubbleBorder::GetBorderThickness() const {
  return images_->border_thickness - images_->border_interior_thickness;
}

int BubbleBorder::GetBorderCornerRadius() const {
  return images_->corner_radius;
}

int BubbleBorder::GetArrowOffset(const gfx::Size& border_size) const {
  const int edge_length = is_arrow_on_horizontal(arrow_) ?
      border_size.width() : border_size.height();
  if (is_arrow_at_center(arrow_) && arrow_offset_ == 0)
    return edge_length / 2;

  // Calculate the minimum offset to not overlap arrow and corner images.
  const int min = images_->border_thickness + (images_->top_arrow.width() / 2);
  // Ensure the returned value will not cause image overlap, if possible.
  return std::max(min, std::min(arrow_offset_, edge_length - min));
}

gfx::Insets BubbleBorder::GetInsets() const {
  // The insets contain the stroke and shadow pixels outside the bubble fill.
  const int inset = GetBorderThickness();
  if (arrow_paint_type_ == PAINT_NONE)
    return gfx::Insets(inset, inset, inset, inset);
  const int inset_with_arrow = std::max(inset, images_->arrow_thickness);
  if (is_arrow_on_horizontal(arrow_)) {
    if (is_arrow_on_top(arrow_))
      return gfx::Insets(inset_with_arrow, inset, inset, inset);
    return gfx::Insets(inset, inset, inset_with_arrow, inset);
  } else if (has_arrow(arrow_)) {
    if (is_arrow_on_left(arrow_))
      return gfx::Insets(inset, inset_with_arrow, inset, inset);
    return gfx::Insets(inset, inset, inset, inset_with_arrow);
  }
  return gfx::Insets(inset, inset, inset, inset);
}

void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
  gfx::Rect bounds(view.GetContentsBounds());
  bounds.Inset(-GetBorderThickness(), -GetBorderThickness());
  const gfx::Rect arrow_bounds = GetArrowRect(view.GetLocalBounds());
  if (arrow_bounds.IsEmpty()) {
    Painter::PaintPainterAt(canvas, images_->border_painter.get(), bounds);
    return;
  }

  // Clip the arrow bounds out to avoid painting the overlapping edge area.
  canvas->Save();
  SkRect arrow_rect(gfx::RectToSkRect(arrow_bounds));
  canvas->sk_canvas()->clipRect(arrow_rect, SkRegion::kDifference_Op);
  Painter::PaintPainterAt(canvas, images_->border_painter.get(), bounds);
  canvas->Restore();

  DrawArrow(canvas, arrow_bounds);
}

gfx::ImageSkia* BubbleBorder::GetArrowImage() const {
  if (is_arrow_on_horizontal(arrow_)) {
    return is_arrow_on_top(arrow_) ?
        &images_->top_arrow : &images_->bottom_arrow;
  } else if (has_arrow(arrow_)) {
    return is_arrow_on_left(arrow_) ?
        &images_->left_arrow : &images_->right_arrow;
  }
  return NULL;
}

gfx::Rect BubbleBorder::GetArrowRect(const gfx::Rect& bounds) const {
  if (!has_arrow(arrow_) || arrow_paint_type_ != PAINT_NORMAL)
    return gfx::Rect();

  gfx::Point origin;
  int offset = GetArrowOffset(bounds.size());
  const int half_length = images_->top_arrow.width() / 2;
  const gfx::Insets insets = GetInsets();

  if (is_arrow_on_horizontal(arrow_)) {
    origin.set_x(is_arrow_on_left(arrow_) || is_arrow_at_center(arrow_) ?
        offset : bounds.width() - offset);
    origin.Offset(-half_length, 0);
    if (is_arrow_on_top(arrow_))
      origin.set_y(insets.top() - images_->arrow_thickness);
    else
      origin.set_y(bounds.height() - insets.bottom());
  } else {
    origin.set_y(is_arrow_on_top(arrow_)  || is_arrow_at_center(arrow_) ?
        offset : bounds.height() - offset);
    origin.Offset(0, -half_length);
    if (is_arrow_on_left(arrow_))
      origin.set_x(insets.left() - images_->arrow_thickness);
    else
      origin.set_x(bounds.width() - insets.right());
  }
  return gfx::Rect(origin, GetArrowImage()->size());
}

void BubbleBorder::DrawArrow(gfx::Canvas* canvas,
                             const gfx::Rect& arrow_bounds) const {
  canvas->DrawImageInt(*GetArrowImage(), arrow_bounds.x(), arrow_bounds.y());
  const bool horizontal = is_arrow_on_horizontal(arrow_);
  const int thickness = images_->arrow_interior_thickness;
  float tip_x = horizontal ? arrow_bounds.CenterPoint().x() :
      is_arrow_on_left(arrow_) ? arrow_bounds.right() - thickness :
                                 arrow_bounds.x() + thickness;
  float tip_y = !horizontal ? arrow_bounds.CenterPoint().y() + 0.5f :
      is_arrow_on_top(arrow_) ? arrow_bounds.bottom() - thickness :
                                arrow_bounds.y() + thickness;
  const bool positive_offset = horizontal ?
      is_arrow_on_top(arrow_) : is_arrow_on_left(arrow_);
  const int offset_to_next_vertex = positive_offset ?
      images_->arrow_interior_thickness : -images_->arrow_interior_thickness;

  SkPath path;
  path.incReserve(4);
  path.moveTo(SkDoubleToScalar(tip_x), SkDoubleToScalar(tip_y));
  path.lineTo(SkDoubleToScalar(tip_x + offset_to_next_vertex),
              SkDoubleToScalar(tip_y + offset_to_next_vertex));
  const int multiplier = horizontal ? 1 : -1;
  path.lineTo(SkDoubleToScalar(tip_x - multiplier * offset_to_next_vertex),
              SkDoubleToScalar(tip_y + multiplier * offset_to_next_vertex));
  path.close();

  SkPaint paint;
  paint.setStyle(SkPaint::kFill_Style);
  paint.setColor(background_color_);

  canvas->DrawPath(path, paint);
}

void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
  // Clip out the client bounds to prevent overlapping transparent widgets.
  if (!border_->client_bounds().IsEmpty()) {
    SkRect client_rect(gfx::RectToSkRect(border_->client_bounds()));
    canvas->sk_canvas()->clipRect(client_rect, SkRegion::kDifference_Op);
  }

  // Fill the contents with a round-rect region to match the border images.
  SkPaint paint;
  paint.setAntiAlias(true);
  paint.setStyle(SkPaint::kFill_Style);
  paint.setColor(border_->background_color());
  SkPath path;
  gfx::Rect bounds(view->GetLocalBounds());
  bounds.Inset(border_->GetInsets());

  // Note: This matches the legacy appearance of SHADOW's extra large inset.
  if (border_->shadow() == BubbleBorder::SHADOW)
    bounds.Inset(-10, -10);

  SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius());
  path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
  canvas->DrawPath(path, paint);
}

}  // namespace views


text:
using Sundial.Core.Manager;
using Sundial.Core.Manager.Default;
using Sundial.Core.Manager.Default.Measurements;
using Sundial.Core.Manager.Interfaces;
using Sundial.Core.Tests.BaseClasses;
using Xunit;

namespace Sundial.Core.Tests.Manager
{
    public class ProfilerManagerTests : TestingDirectoryFixture
    {
        [Fact]
        public void Creation()
        {
            var TestObject = new ProfilerManager(new IProfiler[] { new InternalProfiler(new IMeasurement[] { new TimeMeasurement() }, CacheManager) });
            Assert.NotNull(TestObject);
        }

        [Fact]
        public void Profile()
        {
            var TestObject = new ProfilerManager(new IProfiler[] { new InternalProfiler(new IMeasurement[] { new TimeMeasurement(), new MemoryMeasurement() }, CacheManager) });
            using (var Profiler = TestObject.StartProfiling())
            {
                using (var TestProfiler = TestObject.Profile("TestProfiler"))
                {
                }
            }
            var Result = TestObject.StopProfiling(false);
            Assert.NotNull(Result);
            Assert.Equal(1, Result.Children.Count);
            Assert.Equal(2, Result.Entries.Count);
            Assert.Equal("Start", Result.Function);
        }

        [Fact]
        public void StartProfiling()
        {
            var TestObject = new ProfilerManager(new IProfiler[] { new InternalProfiler(new IMeasurement[] { new TimeMeasurement(), new MemoryMeasurement() }, CacheManager) });
            using (var Profiler = TestObject.StartProfiling())
            {
                Assert.NotNull(Profiler);
            }
            var Result = TestObject.StopProfiling(false);
        }

        [Fact]
        public void StopProfiling()
        {
            var TestObject = new ProfilerManager(new IProfiler[] { new InternalProfiler(new IMeasurement[] { new TimeMeasurement(), new MemoryMeasurement() }, CacheManager) });
            using (var Profiler = TestObject.StartProfiling())
            {
            }
            var Result = TestObject.StopProfiling(false);
            Assert.NotNull(Result);
            Assert.Equal(0, Result.Children.Count);
            Assert.Equal(2, Result.Entries.Count);
            Assert.Equal("Start", Result.Function);
        }
    }
}


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

    <string name="app_name">SMXL</string>
    <string name="action_settings">Settings</string>
    <string name="action_exit">Exit</string>
    <string name="action_disconnect">Disconnect</string>
    <string name="title_section_profiles">Profiles</string>
    <string name="aPropos">About</string>
    <string name="texteHomme">Man</string>
    <string name="texteFemme">Woman</string>
    <string name="sectionProfileDetail">File</string>
    <string name="measure">Measures</string>
    <string name="garments">Wardrobe</string>
    <string name="profile">Profile</string>
    <string name="title_section_measures">Measures</string>

    <string name="libBust">Bust</string>
    <string name="libHeight">Height</string>
    <string name="libWeight">Weight</string>
    <string name="libChest">Chest</string>
    <string name="libWaist">Waist</string>
    <string name="libHips">Hips</string>
    <string name="measurements">Measurements</string>
    <string name="libCollar">Neck</string>
    <string name="libSleeve">Sleeve</string>
    <string name="libInseam">Leg</string>
    <string name="libFeet">Feet</string>
    <string name="libthigh">Thigh</string>

    <string name="changeMeasure">Enter value</string>
    <string name="libTaillePopup">Actual height</string><!--sapu-->
    <string name="libBoutonRetour">Back</string>
    <string name="shareDialogTitle">Share</string>
    <string name="shareDialogEmail">Mail</string>
    <string name="shareDialogSms">SMS</string>
    <string name="shareDialogOK">Share</string>
    <string name="shareDialogCancel">Cancel</string>
    <string name="saveGarment">Save</string>
    <string name="addGarmentOK">Garment add to your collection</string>
    <string name="addGarmentKO">Unable to add to your collection</string>
    <string name="settings">Settings</string>
    <string name="libUnit">Unit</string>
    <string name="majProfile">Profile update</string>
    <string name="libImc">BMI</string>
    <string name="unimplemented">Developing…</string>
    <string name="addNote">Shipping address</string><!--Add a description, a comment…-->
    <string name="ShoeSize">Size</string>
    <string name="title_activity_profil">ProfilActivity</string>
    <string name="hello_world">Hello world!</string>
    <string name="title_activity_profil_detail">ProfilDetailActivity</string>
    <string name="title_activity_add_measure">AddMeasure</string>
    <string name="createProfil">Create new profile</string>
    <string name="title_activity_measure_pager">Measures</string>
    <string name="title_activity_share_profil">ShareProfil</string>
    <string name="title_activity_csvcreation">CSVCreationActivity</string>
    <string name="title_activity_import_profil">SMXL - Import Profile</string>
    <string name="title_activity_login">Login</string>
    <string name="title_activity_create_account">Create Your Account</string>
    <string name="importProfile">Import Profile</string>
    <string name="remove">Remove</string>
    <string name="message_delete_garment">Do you want to remove this garment ?</string>
    <string name="incompleteProfile">You must enter first and last name</string>
    <string name="firstname">Firstname</string>
    <string name="surname">Lastname</string>
    <string name="dateOfBirth">Date of birth</string>
    <string name="addMeasure">Add Measure</string>
    <string name="addGarment">Add Garment</string>
    <string name="removeGarment">Do you want to remove this profile ?</string>
    <string name="viewMore">View more</string>
    <string name="libPointure">Pointure</string>
    <string name="remarque">Notes</string>
    <string name="mesurer">How to mesure</string>
    <string name="title_activity_add_garment">Add garment</string>
    <string name="title_choose_category">Choose a category of garment</string>
    <string name="title_choose_garment">Choose a type of garment</string>
    <string name="add_garment">Add garment</string>
    <string name="update">Update</string>
    <string name="edit_garment">Edit garment</string>
    <string name="title_choose_brand">Choose a brand</string>
    <string name="title_summary">Summary</string>
    <string name="description_add_garment">Comments for this garment</string>
    <string name="validate">Validate</string>
    <string name="title_activity_add_measure_fragment">AddMeasureFragment</string>
    <string name="add_measure">Add measure</string>
    <string name="title_activity_list_garment">ListGarmentActivity</string>
    <string name="my_clothes">My clothes</string>
    <string name="title_activity_display_garment">My garment</string>
    <string name="remove_garment">Delete this garment ?</string>

    <string name="no_user">Create your profile !</string>
    <string name="notes">Notes</string>
    <string name="buttonNextStep">Next Step</string>
    <string name="size_guide">Size Guide</string>
    <string name="title_activity_size_guide">SizeGuideActivity</string>
    <string name="title_activity_select_brands">Select your favorite brands</string>
    <string name="manage_favorite_brands">Manage your favorite brands</string>
    <string name="favorite_brands">Favorite brands</string>
    <string name="all_Brands">All brands</string>

    <string name="garment">Garment</string>
    <string name="brand">Brand</string>

    <string name="returnCreate">Press back again to cancel</string>
    <string name="newProfile1">Add</string>
    <string name="newProfile2">Profile</string>

    <string name="man">Man</string>
    <string name="woman">Woman</string>
    <string name="years">years old</string>

    <string name="select_category">Sort by category</string>

    <string name="facebook_app_id">893068277430661</string>
    <string name="title_activity_connexion">Connexion</string>

    <string name="prompt_email">Email</string>
    <string name="prompt_password">Password</string>
    <string name="confirm_password">Confirm Password</string>
    <string name="action_sign_in">Sign in</string>
    <string name="create_account">Create Account!</string>
    <string name="show_password">Show Password</string>
    <string name="checkingAvailability">Checking account availability…</string>
    <string name="alreadyExistingAccount">Account already exists!</string>
    <string name="errorRetrievingAccount">Error retrieving account!</string>
    <string name="retrieving_account">Retrieving Account…</string>
    <string name="wrong_email">Wrong Email!</string>
    <string name="wrong_password">Wrong Password!</string>
    <string name="no_connexion">Check your connexion!</string>
    <string name="disconnected">Disconnected!</string>
    <string name="email_not_valid">This is not a valid Email!</string>
    <string name="password_not_valid">Password must be at least 6 characters long!</string>

    <string name="jacket">Jacket</string>
    <string name="search">Search</string>
    <string name="title_activity_browser">BrowserActivity</string>

    <string name="my_profiles">My Profiles</string>
    <string name="my_profile">My Profile</string>
    <string name="my_measurements">My Measurements</string>
    <string name="my_wardrobe">My Wardrobe</string>
    <string name="title_activity_quicksize">QuicksizeActivity</string>

    <!--translation from database-->
    <string name="BLOUSON">Jacket</string>
    <string name="CHAUSSURE">Shoes</string>
    <string name="CHEMISE">Shirt</string>
    <string name="CHEMISIER">Blouse</string>
    <string name="COSTUME">Suit</string>
    <string name="JEANS">Jeans</string>
    <string name="MANTEAU">Coat</string>
    <string name="PANTALON">Pants</string>
    <string name="PULL">Sweater</string>
    <string name="SHORT">Shorts</string>
    <string name="SLIP">UnderPants</string>
    <string name="SWEATER">Hoodie</string>
    <string name="TSHIRT">T-Shirt</string>
    <string name="VESTE">Vest</string>
    <string name="JUPE">Skirt</string>
    <string name="ROBE">Dress</string>
    <string name="SOUTIEN_GORGE">Bra</string>
    <string name="MAILLOTS_DE_BAIN">swimwear</string>

    <string name="nc">N/C</string>
    <string name="Coat">Coat</string>
    <string name="addColor">Add Color</string>
    <string name="favoriteColor">Favorite Color</string>
    <string name="hello_blank_fragment">Hello</string>
    <string name="libFoot">Foot</string>
    <string name="wrong_username">Wrong Email!</string>

    <string name="Dress_Skirt">Dresses/Skirts</string>
    <string name="Tshirt">T-shirts</string>
    <string name="Pants_Shorts">Pants/Shorts</string>
    <string name="Blouse">Shirts/Blouses</string>
    <string name="Jacket_Coat">Jackets/Coats</string>
    <string name="Vest">Vest</string>
    <string name="Shoes">Shoes</string>
    <string name="Sweater_Hoodie">Sweater/Hoodies</string>
    <string name="Underwear">Underwear</string>
    <string name="Suit">Suits</string>
    <string name="addBrandToFavorite">Add to favorite brands</string>
    <string name="goToWebsite">Go to website</string>
    <string name="title_quickmeasurefragment">Set your size</string>
    <string name="libGO">GO !</string>
    <string name="cm">cm</string>
    <string name="shoe_size">size</string>
    <string name="quicksize">QuickSize</string>
    <string name="removeBrand">Remove From Favorite Brands</string>

    <string name="shareProfile">Share your main profile!</string>
    <string name="code">Code : </string>
    <string name="obtainProfile">Obtain a friend\'s profile by entering his code here :</string>
    <string name="getProfile">Get!</string>
    <string name="share">Share</string>
    <string name="title_activity_create_facebook_profile">CreateFacebookProfile</string>
    <string name="step">Step</string>
    <string name="brand_already_selected">Brand has already been selected .</string>
    <string name="max_brands_selected">You already have 5 Favorites Brands .</string>
    <string name="not_enough_brands_selected">Please choose more Brands .</string>
    <string name="ok">OK</string>
    <string name="select_brand_popup_message">Please choose from 2 to 5 Favorites Brands</string>
    <string name="quickmeasure_popup_message">Choose a Brand per garment and enter your size to unlock the QuickSize .</string>
    <string name="Share">Share</string>
    <string name="dont_show">Don\'t show again</string>
    <string name="title_sharing_activity">SharingActivity</string>
    <string name="profile_import_success">Profile was imported successfully .</string>
    <string name="profile_import_already_exist">You already have this profile</string>
    <string name="profile_import_not_exist">Couldn\'t find a profile with this code.</string>
    <string name="tuto_mobile_title">No more surprises !</string>
    <string name="Jacket">Jacket</string>
    <string name="title_activity_wishlist">AddWishListActivity</string>
    <string name="title_activity_image_viewer">ImageViewerActivity</string>
    <string name="inclompleteBirthDate">You must enter your birthdate</string>
    <string name="empty_wishlist">The wishlist is empty .</string>
    <string name="missingMeasures">Missing Measures</string>
    <string name="message_enter_measures">Enter your Quicksize measurements in your profile or directly using the Measurement tab :</string>
    <string name="couldnt_create_user_local">Error : User couldn\'t be created locally .</string>
    <string name="logout">Log Out</string>
    <string name="home">Home</string>
    <string name="blogs">Blogs</string>
    <string name="shopOnLine">Shop On Line</string>

</resources>


text:
require File.join(File.dirname(__FILE__), *%w[spec_helper])

describe "ActiveRecord class with belongs_to_image mixed in" do
  before do
    @klass = ActiveRecordStub.dup
    @klass.send(:include, Ketlai::Image::Associations)
  end

  it "should set up the belongs_to relationship" do
    @klass.should_receive(:belongs_to).with(:sample, {})
    @klass.send(:belongs_to_image, :sample)
  end

  describe "when updating with empty or nil data" do
    before do
      @klass.send(:belongs_to_image, :sample)
    end

    it "should not reflect on association" do
      k = @klass.new
      @klass.should_not_receive(:reflect_on_association)
      k.sample = nil
    end
  end

  describe "when uploading a file" do

    before do
      @klass.send(:belongs_to_image, :sample)
      @association_details = mock('association details', :build => nil,
        :class_name => 'FakeImageStub', :association_foreign_key => 'fake_image_stub_id')
      @klass.stub!(:reflect_on_association).with(:sample).and_return(@association_details)
      @k = @klass.new
      @sample_data = StringIO.new('sample data')
    end

    def upload_file
      @k.sample = @sample_data
    end

    it "should build the new association" do
      FakeImageStub.should_receive(:create!).with(:uploaded_data => @sample_data)
      upload_file
    end

    it "should set the foreign key to that of the new object" do
      @k.should_receive(:write_attribute).with('fake_image_stub_id', 4)
      upload_file
    end
  end
end


text:
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>LightZone: Navigating Folders</title>
    <meta name="description"
      content="How to navigate the folders and browse photos."/>
    <link rel="stylesheet" type="text/css" href="Help.css" media="all"/>
    <link rel="stylesheet" type="text/css" href="Platform.css" media="all"/>

        Ayuda de LightZone

        Index

Navigating folders

      On the left side of the LightZone window
      is the Folder Navigator
      that shows the folders on your computer.
      The Folder Navigator looks and works much like a
      Finder
      Windows Explorer
      window in list view mode.

      The major difference, however,
      is that only folders and disks are shown -- files are not.
      Instead, thumbnails for the photos in the selected folder
      are displayed in the
      thumbnails
      section of the window.

      The Folder Navigator
      allows you to navigate to, select,
      and view the thumbnails and metadata
      for photos in folders on your computer.

To navigate to a folder:

          Click the
          triangles
          plus signs '+'
          to expand the folders.

          Select the desired folder.

      Additionally, the navigator tool buttons can be used to navigate.

      The Back/Forward buttons
      can be used to navigate either back or forward
      to the folder you were previously in.

      The Path button
      can be used to navigate up the folder tree quickly.

See also:

          Dragging & dropping photos


text:
package com.ciklum.testing.places.utils;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;

import com.nostra13.universalimageloader.core.DisplayImageOptions;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.location.Location;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.util.TypedValue;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;

public final class Utils {

    /**
     * Return ability of network connection
     *
     * @param context
     * @return
     */
    public static boolean isNetworkAvailable(Context context) {
        return ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo()
                != null;
    }

    public static void startWebActivity(Context context, String url) {
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        context.startActivity(browserIntent);
    }

    public static void startVideoActivity(Context context, String url) {
        try {
            Intent videoIntent = new Intent(Intent.ACTION_VIEW);
            videoIntent.setDataAndType(Uri.parse(url), "video/*");
            context.startActivity(videoIntent);
        } catch (ActivityNotFoundException e) {
            new AlertDialog.Builder(context)
                    .setTitle(android.R.string.dialog_alert_title)
                    .setMessage(e.getLocalizedMessage())
                    .setCancelable(true)
                    .setPositiveButton(android.R.string.ok, null)
                    .create()
                    .show();
        }
    }

    public static void hideKeyboard(TextView textView) {
        InputMethodManager imm = (InputMethodManager)
                textView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(textView.getWindowToken(), 0);
    }

    public static float  getFloatConstant(Resources resources, int idRes) {
        TypedValue outValue = new TypedValue();
        resources.getValue(idRes, outValue, true);
        float value = outValue.getFloat();
        return value;
    }

    /**
     * Stores activity data in the Bundle.
     */
    public static boolean isGooglePlayServicesAvailable(Activity context) {
        int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
        if (ConnectionResult.SUCCESS == status) {
            return true;
        } else {
            GooglePlayServicesUtil.getErrorDialog(status, context, 0).show();
            return false;
        }
    }

    public static final DisplayImageOptions MEMORY_CACHE_OPT = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(false)
            .resetViewBeforeLoading(true)
            .build();

    public static final int getDistanceInMetres(final Location location, final double lat2, final double lng2) {
        if(location!=null) {
            float[] dist = new float[1];
            Location.distanceBetween(location.getLatitude(), location.getLongitude(), lat2, lng2, dist);
            return (int) dist[0];
        }
        return 0;
    }

}


text:
<!DOCTYPE html>

	<title>Integration Cards Types</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

				Integration Card Types

UI Integration Cards support the following card types:

Adaptive

Analytical

Calendar

Component

List

Object

Table

Timeline

WebPage


text:
<?php

namespace Google\Service\CloudSearch;

class Button extends \Google\Model
{
  protected $imageButtonType = ImageButton::class;
  protected $imageButtonDataType = '';
  protected $textButtonType = TextButton::class;
  protected $textButtonDataType = '';

  /**
   * @param ImageButton
   */
  public function setImageButton(ImageButton $imageButton)
  {
    $this->imageButton = $imageButton;
  }
  /**
   * @return ImageButton
   */
  public function getImageButton()
  {
    return $this->imageButton;
  }
  /**
   * @param TextButton
   */
  public function setTextButton(TextButton $textButton)
  {
    $this->textButton = $textButton;
  }
  /**
   * @return TextButton
   */
  public function getTextButton()
  {
    return $this->textButton;
  }
}

// Adding a class alias for backwards compatibility with the previous class name.
class_alias(Button::class, 'Google_Service_CloudSearch_Button');


text:
using System;
using System.Reflection;
using UnityEngine.Events;

namespace ExtendedLibrary.Events
{
    public abstract class ExtendedDelegate
    {
        public MethodInfo Method { get; private set; }

        public object Target { get; private set; }

        public abstract object Invoke();

        protected ExtendedDelegate(MethodInfo method, object target)
        {
            this.Method = method;
            this.Target = target;
        }
    }

    public sealed class ExtendedAction : ExtendedDelegate
    {
        private Action action;

        public ExtendedAction(Action action)
            : base(action.Method, action.Target)
        {
            this.action = action;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke();
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null Action.");
        }
    }

    public sealed class ExtendedAction<T> : ExtendedDelegate
    {
        private Action<T> action;

        private T param;

        public ExtendedAction(Action<T> action, T param)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param = param;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null Action.");
        }
    }

    public sealed class ExtendedAction<T1, T2> : ExtendedDelegate
    {
        private Action<T1, T2> action;

        private T1 param1;

        private T2 param2;

        public ExtendedAction(Action<T1, T2> action, T1 param1, T2 param2)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param1 = param1;
            this.param2 = param2;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param1, this.param2);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null Action.");
        }
    }

    public sealed class ExtendedAction<T1, T2, T3> : ExtendedDelegate
    {
        private Action<T1, T2, T3> action;

        private T1 param1;

        private T2 param2;

        private T3 param3;

        public ExtendedAction(Action<T1, T2, T3> action, T1 param1, T2 param2, T3 param3)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param1 = param1;
            this.param2 = param2;
            this.param3 = param3;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param1, this.param2, this.param3);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null Action.");
        }
    }

    public sealed class ExtendedAction<T1, T2, T3, T4> : ExtendedDelegate
    {
        private Action<T1, T2, T3, T4> action;

        private T1 param1;

        private T2 param2;

        private T3 param3;

        private T4 param4;

        public ExtendedAction(Action<T1, T2, T3, T4> action, T1 param1, T2 param2, T3 param3, T4 param4)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param1 = param1;
            this.param2 = param2;
            this.param3 = param3;
            this.param4 = param4;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param1, this.param2, this.param3, this.param4);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null Action.");
        }
    }

    public sealed class ExtendedUnityAction : ExtendedDelegate
    {
        private UnityAction action;

        public ExtendedUnityAction(UnityAction action)
            : base(action.Method, action.Target)
        {
            this.action = action;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke();
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null UnityAction.");
        }
    }

    public sealed class ExtendedUnityAction<T> : ExtendedDelegate
    {
        private UnityAction<T> action;

        private T param;

        public ExtendedUnityAction(UnityAction<T> action, T param)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param = param;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null UnityAction.");
        }
    }

    public sealed class ExtendedUnityAction<T1, T2> : ExtendedDelegate
    {
        private UnityAction<T1, T2> action;

        private T1 param1;

        private T2 param2;

        public ExtendedUnityAction(UnityAction<T1, T2> action, T1 param1, T2 param2)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param1 = param1;
            this.param2 = param2;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param1, this.param2);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null UnityAction.");
        }
    }

    public sealed class ExtendedUnityAction<T1, T2, T3> : ExtendedDelegate
    {
        private UnityAction<T1, T2, T3> action;

        private T1 param1;

        private T2 param2;

        private T3 param3;

        public ExtendedUnityAction(UnityAction<T1, T2, T3> action, T1 param1, T2 param2, T3 param3)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param1 = param1;
            this.param2 = param2;
            this.param3 = param3;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param1, this.param2, this.param3);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null UnityAction.");
        }
    }

    public sealed class ExtendedUnityAction<T1, T2, T3, T4> : ExtendedDelegate
    {
        private UnityAction<T1, T2, T3, T4> action;

        private T1 param1;

        private T2 param2;

        private T3 param3;

        private T4 param4;

        public ExtendedUnityAction(UnityAction<T1, T2, T3, T4> action, T1 param1, T2 param2, T3 param3, T4 param4)
            : base(action.Method, action.Target)
        {
            this.action = action;
            this.param1 = param1;
            this.param2 = param2;
            this.param3 = param3;
            this.param4 = param4;
        }

        public override object Invoke()
        {
            if (this.action != null)
            {
                this.action.Invoke(this.param1, this.param2, this.param3, this.param4);
                return null;
            }
            else
                throw new InvalidOperationException("Cannot invoke null UnityAction.");
        }
    }

    public abstract class ExtendedFuncBase<TResult> : ExtendedDelegate
    {
        protected ExtendedFuncBase(MethodInfo method, object target)
            : base(method, target)
        {
        }
    }

    public sealed class ExtendedFunc<TResult> : ExtendedFuncBase<TResult>
    {
        private Func<TResult> func;

        public ExtendedFunc(Func<TResult> func)
            : base(func.Method, func.Target)
        {
            this.func = func;
        }

        public override object Invoke()
        {
            if (this.func != null)
                return this.func.Invoke();

            throw new InvalidOperationException("Cannot invoke null Func.");
        }
    }

    public sealed class ExtendedFunc<T, TResult> : ExtendedFuncBase<TResult>
    {
        private Func<T, TResult> func;

        private T param;

        public ExtendedFunc(Func<T, TResult> func, T param)
            : base(func.Method, func.Target)
        {
            this.func = func;
            this.param = param;
        }

        public override object Invoke()
        {
            if (this.func != null)
                return this.func.Invoke(this.param);

            throw new InvalidOperationException("Cannot invoke null Func.");
        }
    }

    public sealed class ExtendedFunc<T1, T2, TResult> : ExtendedFuncBase<TResult>
    {
        private Func<T1, T2, TResult> func;

        private T1 param1;

        private T2 param2;

        public ExtendedFunc(Func<T1, T2, TResult> func, T1 param1, T2 param2)
            : base(func.Method, func.Target)
        {
            this.func = func;
            this.param1 = param1;
            this.param2 = param2;
        }

        public override object Invoke()
        {
            if (this.func != null)
                return this.func.Invoke(this.param1, this.param2);

            throw new InvalidOperationException("Cannot invoke null Func.");
        }
    }

    public sealed class ExtendedFunc<T1, T2, T3, TResult> : ExtendedFuncBase<TResult>
    {
        private Func<T1, T2, T3, TResult> func;

        private T1 param1;

        private T2 param2;

        private T3 param3;

        public ExtendedFunc(Func<T1, T2, T3, TResult> func, T1 param1, T2 param2, T3 param3)
            : base(func.Method, func.Target)
        {
            this.func = func;
            this.param1 = param1;
            this.param2 = param2;
            this.param3 = param3;
        }

        public override object Invoke()
        {
            if (this.func != null)
                return this.func.Invoke(this.param1, this.param2, this.param3);

            throw new InvalidOperationException("Cannot invoke null Func.");
        }
    }

    public sealed class ExtendedFunc<T1, T2, T3, T4, TResult> : ExtendedFuncBase<TResult>
    {
        private Func<T1, T2, T3, T4, TResult> func;

        private T1 param1;

        private T2 param2;

        private T3 param3;

        private T4 param4;

        public ExtendedFunc(Func<T1, T2, T3, T4, TResult> func, T1 param1, T2 param2, T3 param3, T4 param4)
            : base(func.Method, func.Target)
        {
            this.func = func;
            this.param1 = param1;
            this.param2 = param2;
            this.param3 = param3;
            this.param4 = param4;
        }

        public override object Invoke()
        {
            if (this.func != null)
                return this.func.Invoke(this.param1, this.param2, this.param3, this.param4);

            throw new InvalidOperationException("Cannot invoke null Func.");
        }
    }
}


text:
package com.perunlabs.tool.jvalgen.java.type;

public interface JCallable {
  public JExpression jCall(Iterable<? extends JExpression> args);

  public JType returnJType();
}


text:
/*
This file is part of BGSLibrary.

BGSLibrary 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 3 of the License, or
(at your option) any later version.

BGSLibrary 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 BGSLibrary.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "MixtureOfGaussianV2BGS.h"

MixtureOfGaussianV2BGS::MixtureOfGaussianV2BGS() : firstTime(true), alpha(0.05), enableThreshold(true), threshold(15), showOutput(true)
{
  std::cout << "MixtureOfGaussianV2BGS()" << std::endl;
}

MixtureOfGaussianV2BGS::~MixtureOfGaussianV2BGS()
{
  std::cout << "~MixtureOfGaussianV2BGS()" << std::endl;
}

void MixtureOfGaussianV2BGS::process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel)
{
  if(img_input.empty())
    return;

  loadConfig();

  if(firstTime)
    saveConfig();

  //------------------------------------------------------------------
  // BackgroundSubtractorMOG2
  // http://opencv.itseez.com/modules/video/doc/motion_analysis_and_object_tracking.html#backgroundsubtractormog2
  //
  // Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm.
  //
  // The class implements the Gaussian mixture model background subtraction described in:
  //  (1) Z.Zivkovic, Improved adaptive Gausian mixture model for background subtraction, International Conference Pattern Recognition, UK, August, 2004,
  //  The code is very fast and performs also shadow detection. Number of Gausssian components is adapted per pixel.
  //
  //  (2) Z.Zivkovic, F. van der Heijden, Efficient Adaptive Density Estimation per Image Pixel for the Task of Background Subtraction,
  //  Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006.
  //  The algorithm similar to the standard Stauffer&Grimson algorithm with additional selection of the number of the Gaussian components based on:
  //    Z.Zivkovic, F.van der Heijden, Recursive unsupervised learning of finite mixture models, IEEE Trans. on Pattern Analysis and Machine Intelligence,
  //    vol.26, no.5, pages 651-656, 2004.
  //------------------------------------------------------------------

  mog(img_input, img_foreground, alpha);

  cv::Mat img_background;
  mog.getBackgroundImage(img_background);

  if(enableThreshold)
    cv::threshold(img_foreground, img_foreground, threshold, 255, cv::THRESH_BINARY);

  if(showOutput)
  {
    cv::imshow("GMM (Zivkovic&Heijden)", img_foreground);
    cv::imshow("GMM BKG (Zivkovic&Heijden)", img_background);
  }

  img_foreground.copyTo(img_output);
  img_background.copyTo(img_bgmodel);

  firstTime = false;
}

void MixtureOfGaussianV2BGS::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/MixtureOfGaussianV2BGS.xml", 0, CV_STORAGE_WRITE);

  cvWriteReal(fs, "alpha", alpha);
  cvWriteInt(fs, "enableThreshold", enableThreshold);
  cvWriteInt(fs, "threshold", threshold);
  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}

void MixtureOfGaussianV2BGS::loadConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/MixtureOfGaussianV2BGS.xml", 0, CV_STORAGE_READ);

  alpha = cvReadRealByName(fs, 0, "alpha", 0.05);
  enableThreshold = cvReadIntByName(fs, 0, "enableThreshold", true);
  threshold = cvReadIntByName(fs, 0, "threshold", 15);
  showOutput = cvReadIntByName(fs, 0, "showOutput", true);

  cvReleaseFileStorage(&fs);
}