text:
<?php

namespace Gobie\Test\Regex\Wrappers;

use Gobie\Regex\Wrappers\RegexFacade;

class RegexFacadeTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @dataProvider provideTestShouldCreateRegexWithDriver
     */
    public function testShouldCreateRegexWithDriver($driver)
    {
        $regex = new RegexFacade($driver);
        $this->assertSame($regex->getDriverClass(), $driver);
    }

    /**
     * @dataProvider provideTestShouldMatch
     */
    public function testShouldMatch($driver, $pattern, $subject, $expectedResult)
    {
        $regex = new RegexFacade($driver);
        $this->assertSame($regex->match($pattern, $subject), $expectedResult);
    }

    /**
     * @dataProvider provideTestShouldFailExecutingUnknownDriverMethod
     */
    public function testShouldFailExecutingUnknownDriverMethod($driver, $methodName, $exceptionMessage)
    {
        try {
            $regex = new RegexFacade($driver);
            \call_user_func(array($regex, $methodName));
        } catch (\BadMethodCallException $ex) {
            $this->assertSame($exceptionMessage, $ex->getMessage());

            return;
        }

        $this->fail();
    }

    public function provideTestShouldCreateRegexWithDriver()
    {
        return array(
            array(RegexFacade::PCRE),
            array(RegexFacade::MB),
        );
    }

    public function provideTestShouldMatch()
    {
        return array(
            array(RegexFacade::PCRE, '/abc/', '01abc23', true),
            array(RegexFacade::MB, 'abc', '01abc23', true),
        );
    }

    public function provideTestShouldFailExecutingUnknownDriverMethod()
    {
        return array(
            array(RegexFacade::PCRE, 'foo', 'Method \Gobie\Regex\Wrappers\Pcre\PcreRegex::foo not implemented'),
            array(RegexFacade::MB, 'bar', 'Method \Gobie\Regex\Wrappers\Mb\MbRegex::bar not implemented'),
        );
    }
}

redpajama_set_name: RedPajamaGithub


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
{
    internal class Session<TController, TModel, TPresenterSession> : ISession<TModel>
        where TPresenterSession : IIntelliSensePresenterSession
        where TController : IController<TModel>
        where TModel : class
    {
        public TController Controller { get; }
        public ModelComputation<TModel> Computation { get; }

        // The presenter session for the computation we've got going.  It's lifetime is tied 1:1 with
        // the computation.  When the computation starts we make a presenter (note: this does not
        // mean that the user will ever see any UI), and when the computation is stopped, we will
        // end the presentation session.
        public TPresenterSession PresenterSession { get; }

        public Session(TController controller, ModelComputation<TModel> computation, TPresenterSession presenterSession)
        {
            this.Controller = controller;
            this.Computation = computation;
            this.PresenterSession = presenterSession;

            // If the UI layer dismisses the presenter, then we want to know about it so we can stop
            // doing whatever it is we're doing.
            this.PresenterSession.Dismissed += OnPresenterSessionDismissed;
        }

        public TModel InitialUnfilteredModel { get { return this.Computation.InitialUnfilteredModel; } }

        private void OnPresenterSessionDismissed(object sender, EventArgs e)
        {
            Computation.ThreadingContext.ThrowIfNotOnUIThread();
            Contract.ThrowIfFalse(ReferenceEquals(this.PresenterSession, sender));
            Controller.StopModelComputation();
        }

        public virtual void Stop()
        {
            Computation.ThreadingContext.ThrowIfNotOnUIThread();
            this.Computation.Stop();
            this.PresenterSession.Dismissed -= OnPresenterSessionDismissed;
            this.PresenterSession.Dismiss();
        }

        public TModel WaitForController()
        {
            Computation.ThreadingContext.ThrowIfNotOnUIThread();
            return Computation.WaitForController();
        }
    }
}


text:
<?php
    Migration::alterField (
        'roundcreatures',
        'desire',
        'destination',
        'ENUM("NONE","NORTH","EAST","SOUTH","WEST") COLLATE utf8_unicode_ci NOT NULL'
    );
?>


text:
hostname=$( hostname -s )

. ${HOME}/bin/qtile/configs/volume_common.${hostname}

volume_toggle
update_volume


text:
//Copyright (c) Microsoft Corporation.  All rights reserved.

using MS.WindowsAPICodePack.Internal;

namespace Microsoft.WindowsAPICodePack.Shell
{
    /// <summary>
    /// Represents a saved search
    /// </summary>
    public class ShellSavedSearchCollection : ShellSearchCollection
    {
        internal ShellSavedSearchCollection(IShellItem2 shellItem)
            : base(shellItem)
        {
            CoreHelpers.ThrowIfNotVista();
        }
    }
}


text:
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Search;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace SDKTemplate
{
    public sealed partial class Scenario2 : Page
    {
        public Scenario2()
        {
            this.InitializeComponent();
        }

        /// <summary>
        /// list all the files and folders in Pictures library by month
        /// </summary>
        private async void GroupByMonthButton_Click(object sender, RoutedEventArgs e)
        {
            await GroupByHelperAsync(new QueryOptions(CommonFolderQuery.GroupByMonth));
        }

        /// <summary>
        /// list all the files and folders in Pictures library by rating
        /// </summary>
        private async void GroupByRatingButton_Click(object sender, RoutedEventArgs e)
        {
            await GroupByHelperAsync(new QueryOptions(CommonFolderQuery.GroupByRating));
        }

        /// <summary>
        /// list all the files and folders in Pictures library by tag
        /// </summary>
        private async void GroupByTagButton_Click(object sender, RoutedEventArgs e)
        {
            await GroupByHelperAsync(new QueryOptions(CommonFolderQuery.GroupByTag));
        }

        /// <summary>
        /// helper for all list by functions
        /// </summary>
        async Task GroupByHelperAsync(QueryOptions queryOptions)
        {
            OutputPanel.Children.Clear();

            StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
            StorageFolderQueryResult queryResult = picturesFolder.CreateFolderQueryWithOptions(queryOptions);

            IReadOnlyList<StorageFolder> folderList = await queryResult.GetFoldersAsync();
            foreach (StorageFolder folder in folderList)
            {
                IReadOnlyList<StorageFile> fileList = await folder.GetFilesAsync();
                OutputPanel.Children.Add(CreateHeaderTextBlock(folder.Name + " (" + fileList.Count + ")"));
                foreach (StorageFile file in fileList)
                {
                    OutputPanel.Children.Add(CreateLineItemTextBlock(file.Name));
                }
            }
        }

        TextBlock CreateHeaderTextBlock(string contents)
        {
            TextBlock textBlock = new TextBlock();
            textBlock.Text = contents;
            textBlock.Style = (Style)Application.Current.Resources["SampleHeaderTextStyle"];
            textBlock.TextWrapping = TextWrapping.Wrap;
            return textBlock;
        }

        TextBlock CreateLineItemTextBlock(string contents)
        {
            TextBlock textBlock = new TextBlock();
            textBlock.Text = contents;
            textBlock.Style = (Style)Application.Current.Resources["BasicTextStyle"];
            textBlock.TextWrapping = TextWrapping.Wrap;
            Thickness margin = textBlock.Margin;
            margin.Left = 20;
            textBlock.Margin = margin;
            return textBlock;
        }
    }
}


text:
#import <DevToolsCore/XCBuildCommandOutputParser.h>

@class NSMutableArray;

@interface XCUnitTestOutputParser : XCBuildCommandOutputParser
{
    BOOL _isRunningUnitTests;
    NSMutableArray *_recorders;
}

+ (void)initialize;
- (void)writeBytes:(const char *)arg1 length:(unsigned long long)arg2;
- (void)testCaseFailed:(id)arg1;
- (void)testCaseDidFinish:(id)arg1;
- (void)testCaseDidStart:(id)arg1;
- (void)testSuiteDidFinish:(id)arg1;
- (void)testSuiteWillFinish:(id)arg1;
- (void)testSuiteDidStart:(id)arg1;
- (void)unitTestsWereSkipped:(id)arg1;
- (void)unitTestsDidNote:(id)arg1;
- (void)unitTestsDidFail:(id)arg1;
- (void)unitTestsDidComplete:(id)arg1;
- (void)unitTestsDidFinish:(id)arg1;
- (void)unitTestsDidStart:(id)arg1;
- (void)unitTestsWillStart:(id)arg1;
- (void)recorderWillFinish:(id)arg1;
- (void)setTestExecutedStringsFromString:(id)arg1;
- (void)finishUnfinishedRecorder:(id)arg1;
- (void)appendAndPropagateUpText:(id)arg1 startingWithRecorder:(id)arg2;
- (id)parentSection;
- (id)currentSection;
- (id)currentRecorder;
- (void)dealloc;
- (id)initWithNextOutputStream:(id)arg1;

@end


text:
bool KVPacker::WriteAsBinary( KeyValues *pNode, CUtlBuffer &buffer )
{
	if ( buffer.IsText() ) // must be a binary buffer
		return false;

	if ( !buffer.IsValid() ) // must be valid, no overflows etc
		return false;

	// Write subkeys:

	// loop through all our peers
	for ( KeyValues *dat = pNode; dat != NULL; dat = dat->GetNextKey() )
	{
		// write type
		switch ( dat->GetDataType() )
		{
		case KeyValues::TYPE_NONE:
			{
				buffer.PutUnsignedChar( PACKTYPE_NONE );
				break;
			}
		case KeyValues::TYPE_STRING:
			{
				buffer.PutUnsignedChar( PACKTYPE_STRING );
				break;
			}
		case KeyValues::TYPE_WSTRING:
			{
				buffer.PutUnsignedChar( PACKTYPE_WSTRING );
				break;
			}

		case KeyValues::TYPE_INT:
			{
				buffer.PutUnsignedChar( PACKTYPE_INT );
				break;
			}

		case KeyValues::TYPE_UINT64:
			{
				buffer.PutUnsignedChar( PACKTYPE_UINT64 );
				break;
			}

		case KeyValues::TYPE_FLOAT:
			{
				buffer.PutUnsignedChar( PACKTYPE_FLOAT );
				break;
			}
		case KeyValues::TYPE_COLOR:
			{
				buffer.PutUnsignedChar( PACKTYPE_COLOR );
				break;
			}
		case KeyValues::TYPE_PTR:
			{
				buffer.PutUnsignedChar( PACKTYPE_PTR );
				break;
			}

		default:
			break;
		}

		// write name
		buffer.PutString( dat->GetName() );

		// write value
		switch ( dat->GetDataType() )
		{
		case KeyValues::TYPE_NONE:
			{
				if( !WriteAsBinary( dat->GetFirstSubKey(), buffer ) )
					return false;
				break;
			}
		case KeyValues::TYPE_STRING:
			{
				if (dat->GetString() && *(dat->GetString()))
				{
					buffer.PutString( dat->GetString() );
				}
				else
				{
					buffer.PutString( "" );
				}
				break;
			}
		case KeyValues::TYPE_WSTRING:
			{
				int nLength = dat->GetWString() ? Q_wcslen( dat->GetWString() ) : 0;
				buffer.PutShort( nLength );
				for( int k = 0; k < nLength; ++ k )
				{
					buffer.PutShort( ( unsigned short ) dat->GetWString()[k] );
				}
				break;
			}

		case KeyValues::TYPE_INT:
			{
				buffer.PutInt( dat->GetInt() );
				break;
			}

		case KeyValues::TYPE_UINT64:
			{
				buffer.PutInt64( dat->GetUint64() );
				break;
			}

		case KeyValues::TYPE_FLOAT:
			{
				buffer.PutFloat( dat->GetFloat() );
				break;
			}
		case KeyValues::TYPE_COLOR:
			{
				Color color = dat->GetColor();
				buffer.PutUnsignedChar( color[0] );
				buffer.PutUnsignedChar( color[1] );
				buffer.PutUnsignedChar( color[2] );
				buffer.PutUnsignedChar( color[3] );
				break;
			}
		case KeyValues::TYPE_PTR:
			{
				buffer.PutUnsignedInt( (int)dat->GetPtr() );
				break;
			}

		default:
			break;
		}
	}

	// write tail, marks end of peers
	buffer.PutUnsignedChar( PACKTYPE_NULLMARKER );

	return buffer.IsValid();
}

// read KeyValues from binary buffer, returns true if parsing was successful
bool KVPacker::ReadAsBinary( KeyValues *pNode, CUtlBuffer &buffer )
{
	if ( buffer.IsText() ) // must be a binary buffer
		return false;

	if ( !buffer.IsValid() ) // must be valid, no overflows etc
		return false;

	pNode->Clear();

	char		token[KEYVALUES_TOKEN_SIZE];
	KeyValues	*dat = pNode;
	EPackType		ePackType = (EPackType)buffer.GetUnsignedChar();

	// loop through all our peers
	while ( true )
	{
		if ( ePackType == PACKTYPE_NULLMARKER )
			break; // no more peers

		buffer.GetString( token, KEYVALUES_TOKEN_SIZE-1 );
		token[KEYVALUES_TOKEN_SIZE-1] = 0;

		dat->SetName( token );

		switch ( ePackType )
		{
		case PACKTYPE_NONE:
			{
				KeyValues *pNewNode = new KeyValues("");
				dat->AddSubKey( pNewNode );
				if( !ReadAsBinary( pNewNode, buffer ) )
					return false;
				break;
			}
		case PACKTYPE_STRING:
			{
				buffer.GetString( token, KEYVALUES_TOKEN_SIZE-1 );
				token[KEYVALUES_TOKEN_SIZE-1] = 0;
				dat->SetStringValue( token );
				break;
			}
		case PACKTYPE_WSTRING:
			{
				int nLength = buffer.GetShort();
				wchar_t *pTemp = (wchar_t *)stackalloc( sizeof(wchar_t) * ( 1 + nLength ) );

				for( int k = 0; k < nLength; ++ k )
				{
					pTemp[k] = buffer.GetShort();
				}
				pTemp[ nLength ] = 0;

				dat->SetWString( NULL, pTemp );
				break;
			}

		case PACKTYPE_INT:
			{
				dat->SetInt( NULL, buffer.GetInt() );
				break;
			}

		case PACKTYPE_UINT64:
			{
				dat->SetUint64( NULL, (uint64)buffer.GetInt64() );
				break;
			}

		case PACKTYPE_FLOAT:
			{
				dat->SetFloat( NULL, buffer.GetFloat() );
				break;
			}
		case PACKTYPE_COLOR:
			{
				Color color(
					buffer.GetUnsignedChar(),
					buffer.GetUnsignedChar(),
					buffer.GetUnsignedChar(),
					buffer.GetUnsignedChar() );
				dat->SetColor( NULL, color );
				break;
			}
		case PACKTYPE_PTR:
			{
				dat->SetPtr( NULL, (void*)buffer.GetUnsignedInt() );
				break;
			}

		default:
			break;
		}

		if ( !buffer.IsValid() ) // error occured
			return false;

		ePackType = (EPackType)buffer.GetUnsignedChar();

		if ( ePackType == PACKTYPE_NULLMARKER )
			break;

		// new peer follows
		KeyValues *pNewPeer = new KeyValues("");
		dat->SetNextKey( pNewPeer );
		dat = pNewPeer;
	}

	return buffer.IsValid();
}


text:
package pl.hycom.pip.messanger.controller;

import javax.annotation.security.RolesAllowed;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import lombok.extern.log4j.Log4j2;
import ma.glasnost.orika.MapperFacade;
import pl.hycom.pip.messanger.controller.model.UserDTO;
import pl.hycom.pip.messanger.exception.EmailNotUniqueException;
import pl.hycom.pip.messanger.exception.SecurityException;
import pl.hycom.pip.messanger.repository.model.Role;
import pl.hycom.pip.messanger.repository.model.User;
import pl.hycom.pip.messanger.service.UserService;

/**
 * Created by Rafal Lebioda on 25.05.2017.
 */
@Log4j2
@Controller
public class AccountController {

    private static final String ACCOUNT_VIEW = "account";

    @Autowired
    private UserService userService;

    @Autowired
    private MapperFacade orikaMapper;

    @GetMapping("/user/account")
    public String showLoggedUserAccount(Model model, @AuthenticationPrincipal User user) {
        if (user != null) {
            model.addAttribute("user", orikaMapper.map(user, UserDTO.class));
            return ACCOUNT_VIEW;
        }

        log.info(" There is no user logged in");
        return "redirect:/admin";
    }

    @RolesAllowed(Role.Name.ADMIN)
    @GetMapping("/user/account/{userId}")
    public String showAccount(Model model, @PathVariable("userId") final Integer userId) {
        UserDTO user = userService.findUserById(userId);
        if (user != null) {
            model.addAttribute("user", user);
            return ACCOUNT_VIEW;
        }

        log.error("There is no user with id = " + userId);
        return "redirect:/admin/users";
    }

    @PostMapping("/user/account/update")
    public String updateAccount(@Valid UserDTO user, BindingResult bindingResult, Model model, @AuthenticationPrincipal User currentUser) {
        if (bindingResult.hasErrors()) {
            model.addAttribute("user", user);
            model.addAttribute("errors", bindingResult.getFieldErrors());
            log.info("Validation user account error !!!");
            return ACCOUNT_VIEW;
        }

        try {
            userService.addOrUpdateUser(user);
        } catch (EmailNotUniqueException | SecurityException e) {
            log.warn("Error during user update", e);

            model.addAttribute("user", user);
            model.addAttribute("error", new ObjectError("validation.error.user.exists", "Użytkownik z takim adresem email już istnieje."));
            return ACCOUNT_VIEW;
        }

        if (currentUser != null) {
            return user.getId().equals(currentUser.getId()) ? "redirect:/user/account" : "redirect:/user/account/" + user.getId();
        }

        log.info(" There is no user logged in");
        return "redirect:/admin";
    }

}


text:
/**
 * @file esc.cpp
 *
 * @author Pavel Kirienko <pavel.kirienko@gmail.com>
 */

#include "esc.hpp"
#include <systemlib/err.h>
#include <drivers/drv_hrt.h>

#define MOTOR_BIT(x) (1<<(x))

using namespace time_literals;

UavcanEscController::UavcanEscController(uavcan::INode &node) :
	_node(node),
	_uavcan_pub_raw_cmd(node),
	_uavcan_sub_status(node),
	_orb_timer(node)
{
	_uavcan_pub_raw_cmd.setPriority(UAVCAN_COMMAND_TRANSFER_PRIORITY);

	if (_perfcnt_invalid_input == nullptr) {
		errx(1, "uavcan: couldn't allocate _perfcnt_invalid_input");
	}

	if (_perfcnt_scaling_error == nullptr) {
		errx(1, "uavcan: couldn't allocate _perfcnt_scaling_error");
	}
}

UavcanEscController::~UavcanEscController()
{
	perf_free(_perfcnt_invalid_input);
	perf_free(_perfcnt_scaling_error);
}

int UavcanEscController::init()
{
	// ESC status subscription
	int res = _uavcan_sub_status.start(StatusCbBinder(this, &UavcanEscController::esc_status_sub_cb));

	if (res < 0) {
		warnx("ESC status sub failed %i", res);
		return res;
	}

	// ESC status will be relayed from UAVCAN bus into ORB at this rate
	_orb_timer.setCallback(TimerCbBinder(this, &UavcanEscController::orb_pub_timer_cb));
	_orb_timer.startPeriodic(uavcan::MonotonicDuration::fromMSec(1000 / ESC_STATUS_UPDATE_RATE_HZ));

	return res;
}

void UavcanEscController::update_outputs(float *outputs, unsigned num_outputs)
{
	if ((outputs == nullptr) ||
	    (num_outputs > uavcan::equipment::esc::RawCommand::FieldTypes::cmd::MaxSize) ||
	    (num_outputs > esc_status_s::CONNECTED_ESC_MAX)) {
		perf_count(_perfcnt_invalid_input);
		return;
	}

	/*
	 * Rate limiting - we don't want to congest the bus
	 */
	const auto timestamp = _node.getMonotonicTime();

	if ((timestamp - _prev_cmd_pub).toUSec() < (1000000 / MAX_RATE_HZ)) {
		return;
	}

	_prev_cmd_pub = timestamp;

	/*
	 * Fill the command message
	 * If unarmed, we publish an empty message anyway
	 */
	uavcan::equipment::esc::RawCommand msg;

	actuator_outputs_s actuator_outputs = {};
	actuator_outputs.noutputs = num_outputs;
	actuator_outputs.timestamp = hrt_absolute_time();

	static const int cmd_max = uavcan::equipment::esc::RawCommand::FieldTypes::cmd::RawValueType::max();
	const float cmd_min = _run_at_idle_throttle_when_armed ? 1.0F : 0.0F;

	for (unsigned i = 0; i < num_outputs; i++) {
		if (_armed_mask & MOTOR_BIT(i)) {
			float scaled = (outputs[i] + 1.0F) * 0.5F * cmd_max;

			// trim negative values back to minimum
			if (scaled < cmd_min) {
				scaled = cmd_min;
				perf_count(_perfcnt_scaling_error);
			}

			if (scaled > cmd_max) {
				scaled = cmd_max;
				perf_count(_perfcnt_scaling_error);
			}

			msg.cmd.push_back(static_cast<int>(scaled));

			_esc_status.esc[i].esc_setpoint_raw = abs(static_cast<int>(scaled));
			actuator_outputs.output[i] = scaled;

		} else {
			msg.cmd.push_back(static_cast<unsigned>(0));
			actuator_outputs.output[i] = 0.0f;
		}
	}

	/*
	 * Remove channels that are always zero.
	 * The objective of this optimization is to avoid broadcasting multi-frame transfers when a single frame
	 * transfer would be enough. This is a valid optimization as the UAVCAN specification implies that all
	 * non-specified ESC setpoints should be considered zero.
	 * The positive outcome is a (marginally) lower bus traffic and lower CPU load.
	 *
	 * From the standpoint of the PX4 architecture, however, this is a hack. It should be investigated why
	 * the mixer returns more outputs than are actually used.
	 */
	for (int index = int(msg.cmd.size()) - 1; index >= _max_number_of_nonzero_outputs; index--) {
		if (msg.cmd[index] != 0) {
			_max_number_of_nonzero_outputs = index + 1;
			break;
		}
	}

	msg.cmd.resize(_max_number_of_nonzero_outputs);

	/*
	 * Publish the command message to the bus
	 * Note that for a quadrotor it takes one CAN frame
	 */
	(void)_uavcan_pub_raw_cmd.broadcast(msg);

	// Publish actuator outputs
	if (_actuator_outputs_pub != nullptr) {
		orb_publish(ORB_ID(actuator_outputs), _actuator_outputs_pub, &actuator_outputs);

	} else {
		int instance;
		_actuator_outputs_pub = orb_advertise_multi(ORB_ID(actuator_outputs), &actuator_outputs,
					&instance, ORB_PRIO_DEFAULT);
	}

}

void UavcanEscController::arm_all_escs(bool arm)
{
	if (arm) {
		_armed_mask = -1;

	} else {
		_armed_mask = 0;
	}
}

void UavcanEscController::arm_single_esc(int num, bool arm)
{
	if (arm) {
		_armed_mask = MOTOR_BIT(num);

	} else {
		_armed_mask = 0;
	}
}

void UavcanEscController::esc_status_sub_cb(const uavcan::ReceivedDataStructure<uavcan::equipment::esc::Status> &msg)
{
	if (msg.esc_index < esc_status_s::CONNECTED_ESC_MAX) {
		auto &ref = _esc_status.esc[msg.esc_index];

		ref.esc_address = msg.getSrcNodeID().get();
		ref.timestamp       = hrt_absolute_time();
		ref.esc_voltage     = msg.voltage;
		ref.esc_current     = msg.current;
		ref.esc_temperature = msg.temperature;
		ref.esc_setpoint    = msg.power_rating_pct;
		ref.esc_rpm         = msg.rpm;
		ref.esc_errorcount  = msg.error_count;
	}
}

void UavcanEscController::orb_pub_timer_cb(const uavcan::TimerEvent &)
{
	_esc_status.timestamp = hrt_absolute_time();
	_esc_status.esc_count = _rotor_count;
	_esc_status.counter += 1;
	_esc_status.esc_connectiontype = esc_status_s::ESC_CONNECTION_TYPE_CAN;
	_esc_status.esc_online_flags = UavcanEscController::check_escs_status();

	if (_esc_status_pub != nullptr) {
		(void)orb_publish(ORB_ID(esc_status), _esc_status_pub, &_esc_status);

	} else {
		_esc_status_pub = orb_advertise(ORB_ID(esc_status), &_esc_status);
	}
}

uint8_t UavcanEscController::check_escs_status()
{
	int esc_status_flags = 0;
	hrt_abstime now = hrt_absolute_time();

	for (int index = 0; index < esc_status_s::CONNECTED_ESC_MAX; index++) {

		if (_esc_status.esc[index].timestamp > 0 && now - _esc_status.esc[index].timestamp < 1200_ms) {
			esc_status_flags |= (1 << index);
		}

	}

	return esc_status_flags;
}


text:
<!DOCTYPE html>

        <meta charset="UTF-8">
        <title>Katanga</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <link rel="apple-touch-icon" sizes="57x57" href="assets/icons/apple-icon-57x57.png">
        <link rel="apple-touch-icon" sizes="60x60" href="assets/icons/apple-icon-60x60.png">
        <link rel="apple-touch-icon" sizes="72x72" href="assets/icons/apple-icon-72x72.png">
        <link rel="apple-touch-icon" sizes="76x76" href="assets/icons/apple-icon-76x76.png">
        <link rel="apple-touch-icon" sizes="114x114" href="assets/icons/apple-icon-114x114.png">
        <link rel="apple-touch-icon" sizes="120x120" href="assets/icons/apple-icon-120x120.png">
        <link rel="apple-touch-icon" sizes="144x144" href="assets/icons/apple-icon-144x144.png">
        <link rel="apple-touch-icon" sizes="152x152" href="assets/icons/apple-icon-152x152.png">
        <link rel="apple-touch-icon" sizes="180x180" href="assets/icons/apple-icon-180x180.png">
        <link rel="icon" type="image/png" sizes="192x192" href="assets/icons/android-icon-192x192.png">
        <link rel="icon" type="image/png" sizes="32x32" href="assets/icons/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="96x96" href="assets/icons/favicon-96x96.png">
        <link rel="icon" type="image/png" sizes="16x16" href="assets/icons/favicon-16x16.png">
        <meta name="msapplication-TileColor" content="#FFDA04">
        <meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
        <meta name="theme-color" content="#ffffff">
        <link rel="manifest" href="/manifest.json">
        <link href='https://fonts.googleapis.com/css?family=Quicksand:400,300,700' rel='stylesheet' type='text/css'>


text:
package io.sarl.lang.ui.editor;

import javax.inject.Inject;

import com.google.inject.Provider;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.Region;
import org.eclipse.xtext.ui.editor.XtextEditor;
import org.eclipse.xtext.ui.editor.formatting2.ContentFormatter;
import org.eclipse.xtext.ui.editor.model.IXtextDocument;
import org.eclipse.xtext.ui.editor.utils.EditorUtils;

/**
 * Handler for correct the indentation within a SARL code.
 *
 * @author $Author: sgalland$
 * @version $FullVersion$
 * @mavengroupid $GroupId$
 * @mavenartifactid $ArtifactId$
 * @since 0.7
 */
public class CorrectIndentationHandler extends AbstractHandler {

	@Inject
	private Provider<ContentFormatter> formatterProvider;

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		final XtextEditor activeXtextEditor = EditorUtils.getActiveXtextEditor(event);
		if (activeXtextEditor == null) {
			return null;
		}
		final IXtextDocument doc = activeXtextEditor.getDocument();
		final ITextSelection selection = (ITextSelection) activeXtextEditor.getSelectionProvider().getSelection();
		final IRegion region = new Region(selection.getOffset(), selection.getLength());
		this.formatterProvider.get().format(doc, region);
		return null;
	}

}


text:
package com.novoda.demo.optionaldependencies;

import android.app.Application;

import com.novoda.demo.optionaldependencies.OptionalDependencies;

public class OptionalDependencyApplication extends Application {
    private OptionalDependencies optionalDependencies;

    @Override
    public void onCreate() {
        super.onCreate();
        optionalDependencies = new OptionalDependencies();
    }

    public OptionalDependencies getOptionalDependencies() {
        return optionalDependencies;
    }
}


text:
package micro

import (
	"context"

	"go-micro.dev/v4/client"
)

type event struct {
	c     client.Client
	topic string
}

func (e *event) Publish(ctx context.Context, msg interface{}, opts ...client.PublishOption) error {
	return e.c.Publish(ctx, e.c.NewMessage(e.topic, msg), opts...)
}


text:
module Bluepill
  module Application
    module Client
    end
  end
end


text:
package com.amazonaws.services.codecommit.model.transform;

import java.util.List;
import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.services.codecommit.model.*;

import com.amazonaws.protocol.*;
import com.amazonaws.annotation.SdkInternalApi;

/**
 * BatchGetCommitsRequestMarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class BatchGetCommitsRequestMarshaller {

    private static final MarshallingInfo<List> COMMITIDS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("commitIds").build();
    private static final MarshallingInfo<String> REPOSITORYNAME_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("repositoryName").build();

    private static final BatchGetCommitsRequestMarshaller instance = new BatchGetCommitsRequestMarshaller();

    public static BatchGetCommitsRequestMarshaller getInstance() {
        return instance;
    }

    /**
     * Marshall the given parameter object.
     */
    public void marshall(BatchGetCommitsRequest batchGetCommitsRequest, ProtocolMarshaller protocolMarshaller) {

        if (batchGetCommitsRequest == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        try {
            protocolMarshaller.marshall(batchGetCommitsRequest.getCommitIds(), COMMITIDS_BINDING);
            protocolMarshaller.marshall(batchGetCommitsRequest.getRepositoryName(), REPOSITORYNAME_BINDING);
        } catch (Exception e) {
            throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
        }
    }

}