text:
// coding: utf-8

// ----------------------------------------------------------------------------

#ifndef XPCC_ITG3200_HPP
#define XPCC_ITG3200_HPP

#include <xpcc/architecture/interface/i2c_device.hpp>
#include <xpcc/math/geometry/angle.hpp>

namespace xpcc
{

// forward declaration for friending with itg3200::Data
template < class I2cMaster >
class Itg3200;

struct itg3200
{
protected:
	/// @cond
	/// The addresses of the Configuration and Data Registers
	enum class
	Register : uint8_t
	{
		WHO_AM_I = 0x00,		///< I2C ID 0x68

		SMPLRT_DIV = 0x15,		///< Sample Rate Divider
		DLPF_FS = 0x16,			///< Digital Low Pass Filter and Full Scale
		INT_CFG = 0x17,			///< Interrupt Configuration

		INT_STATUS = 0x1A,		///< Interrupt Status

		TEMP_OUT_H = 0x1B,		///< Temperature Data MSB
		TEMP_OUT_L = 0x1C,		///< Temperature Data LSB

		GYRO_XOUT_H = 0x1D,		///< X-Axis Data MSB
		GYRO_XOUT_L = 0x1E,		///< X-Axis Data LSB
		GYRO_YOUT_H = 0x1F,		///< Y-Axis Data MSB
		GYRO_YOUT_L = 0x20,		///< Y-Axis Data LSB
		GYRO_ZOUT_H = 0x21,		///< Z-Axis Data MSB
		GYRO_ZOUT_L = 0x22,		///< Z-Axis Data LSB

		PWR_MGM = 0x3E,			///< Power Management
	};

	enum class
	Filter : uint8_t
	{
		FS_SEL1 = Bit4,
		FS_SEL0 = Bit3,
		FS_SEL_Mask = Bit4 | Bit3,
		FullScale = FS_SEL0,

		DLPF_CFG2 = Bit2,
		DLPF_CFG1 = Bit1,
		DLPF_CFG0 = Bit0,
		DLPF_CFG_Mask = Bit2 | Bit1 | Bit0,
	};
	/// @endcond

public:
	enum class
	LowPassFilter : uint8_t
	{
		Hz256 = 0,
		Hz188 = Filter::DLPF_CFG0,
		Hz98 = Filter::DLPF_CFG1,
		Hz42 = int(Filter::DLPF_CFG1) | int(Filter::DLPF_CFG0),
		Hz20 = Filter::DLPF_CFG2,
		Hz10 = int(Filter::DLPF_CFG2) | int(Filter::DLPF_CFG0),
		Hz5 = int(Filter::DLPF_CFG2) | int(Filter::DLPF_CFG1),
	};

protected:
	/// @cond
	XPCC_FLAGS8(Filter);
	typedef Configuration< Filter_t, LowPassFilter, (Bit2 | Bit1 | Bit0) > LowPassFilter_t;
	/// @endcond

public:
	/// The bit masks of the INT_CFG register
	enum class
	Interrupt : uint8_t
	{
		ACTL = Bit7,				///< Logic level for INT output pin: 1=active low, 0=active high
		OPEN = Bit6,				///< Drive type for INT output pin: 1=open drain, 0=push-pull
		LATCH_INT_EN = Bit5,		///< Latch mode: 1=latch until interrupt is cleared, 0=50us pulse
		INT_ANYRD_2CLEAR = Bit4,	///< Latch clear method: 1=any register read, 0=status register read only
		ITG_RDY_EN = Bit2,			///< Enable interrupt when device is ready (PLL ready after changing clock source)
		RAW_RDY_EN = Bit0,			///< Enable interrupt when data is available
	};
	XPCC_FLAGS8(Interrupt);

	/// The bit masks of the INT_STATUS register
	enum class
	Status : uint8_t
	{
		ITG_RDY = Bit2,			///< PLL ready
		RAW_DATA_RDY = Bit0,	///< Raw data is ready
	};
	XPCC_FLAGS8(Status);

	/// The bit masks of the PWR_MGM register
	enum class
	Power : uint8_t
	{
		H_RESET = Bit7,			///< Reset device and internal registers to the power-up-default settings
		SLEEP = Bit6,			///< Enable low power sleep mode

		STBY_XG = Bit5,			///< Put gyro X in standby mode (1=standby, 0=normal)
		STBY_YG = Bit4,			///< Put gyro Y in standby mode (1=standby, 0=normal)
		STBY_ZG = Bit3,			///< Put gyro Z in standby mode (1=standby, 0=normal)

		CLK_SEL2 = Bit2,
		CLK_SEL1 = Bit1,
		CLK_SEL0 = Bit0,
		CLK_SEL_Mask = Bit2 | Bit1 | Bit0,
	};
	XPCC_FLAGS8(Power);

	enum class
	ClockSource : uint8_t
	{
		Internal = 0,						///< Internal oscillator
		PllX = Power::CLK_SEL0,				///< PLL with X Gyro reference
		PllY = Power::CLK_SEL1,				///< PLL with Y Gyro reference
		PllZ = int(Power::CLK_SEL1) | int(Power::CLK_SEL0),		///< PLL with Z Gyro reference
		PllExternal32kHz = Power::CLK_SEL2,	///< PLL with external 32.768kHz reference
		PllExternal19MHz = int(Power::CLK_SEL2) | int(Power::CLK_SEL0),	///< PLL with external 19.2MHz reference
	};
	typedef Configuration< Power_t, ClockSource, (Bit2 | Bit1 | Bit0) > ClockSource_t;

public:
	struct ATTRIBUTE_PACKED
	Data
	{
		template< class I2cMaster >
		friend class Itg3200;

		/// returns the rotation rate in degrees per second
		///@{
		inline float
		getX() { return getRate(1); }

		inline float
		getY() { return getRate(2); }

		inline float
		getZ() { return getRate(3); }
		///@}

		/// returns the temperature in degrees Celcius
		inline float
		getTemperature()
		{
			int16_t* rawData = reinterpret_cast<int16_t*>(data);
			int16_t rateValue = xpcc::fromBigEndian(rawData[0]) + 13200;
			return (rateValue / 280.f) + 35.f;
		}

		inline float
		operator [](uint8_t index)
		{ return (index < 3) ? getRate(index+1) : 0; }

	private:
		uint8_t data[8];

		/// index must be in range of [1, 3] !!!
		float inline
		getRate(uint8_t index)
		{
			int16_t* rawData = reinterpret_cast<int16_t*>(data);
			int16_t rateValue = xpcc::fromBigEndian(rawData[index]);
			return rateValue * (1.f / 14.375f);
		}
	};
}; // struct itg3200

/**
 * Basic ITG3200 digital gyroscope sensor driver
 *
 * For further information on the special sensing functions, consult the
 *
 * datasheet.
 *
 * @author	Niklas Hauser
 * @ingroup driver_inertial
 */
template < typename I2cMaster >
class Itg3200 : public itg3200, public xpcc::I2cDevice< I2cMaster, 2 >
{
public:
	/// Constructor, requires an itg3200::Data object, sets address to default of 0x68 (AD0 low: 0x69)
	Itg3200(Data &data, uint8_t address=0x68);

	xpcc::ResumableResult<bool>
	configure(LowPassFilter filter=LowPassFilter::Hz20, uint8_t divider=0);

	/// reads the temperature and gyro registers and buffer the results
	xpcc::ResumableResult<bool>
	readRotation();

	xpcc::ResumableResult<bool> inline
	setLowPassFilter(LowPassFilter filter)
	{ return updateFilter(filter, Filter::DLPF_CFG_Mask); }

	xpcc::ResumableResult<bool> inline
	setSampleRateDivider(uint8_t divider);

	xpcc::ResumableResult<bool> inline
	updateInterrupt(Interrupt_t setMask, Interrupt_t clearMask = Interrupt_t(0xf5))
	{ return updateRegister(1, setMask.value, clearMask.value); }

	xpcc::ResumableResult<bool> inline
	updatePower(Power_t setMask, Power_t clearMask = Power_t(0xff))
	{ return updateRegister(11, setMask.value, clearMask.value); }

	// MARK: Registers with instant access
	LowPassFilter getLowPassFilter()
	{ return LowPassFilter_t::get(getFilter()); }

	Interrupt_t getInterrupt()
	{ return Interrupt_t(rawBuffer[1]); }

	Power_t getPower()
	{ return Power_t(rawBuffer[11]); }

	// MARK: Registers with buffered access
	Status_t getStatus()
	{ return Status_t(rawBuffer[2]); }

	xpcc::ResumableResult<bool>
	readStatus();

protected:
	/// @cond
	xpcc::ResumableResult<bool> inline
	updateFilter(Filter_t setMask, Filter_t clearMask = Filter_t(0x1f))
	{ return updateRegister(0, setMask.value, clearMask.value); }

	Filter_t getFilter()
	{ return Filter_t(rawBuffer[0]); }
	/// @endcond

public:
	/// Get the data object for this sensor.
	inline Data&
	getData()
	{ return data; }

protected:
	/// @cond
	/// write a 8bit value a register
	xpcc::ResumableResult<bool> ALWAYS_INLINE
	write(Register reg, uint8_t &value)
	{ return write(reg, &value, 1); }

	/// write multiple 8bit values from a start register
	xpcc::ResumableResult<bool>
	write(Register reg, uint8_t *buffer, uint8_t length, bool copyBuffer=true);

	/// read a 8bit value from a register
	xpcc::ResumableResult<bool> ALWAYS_INLINE
	read(Register reg, uint8_t &value)
	{ return read(reg, &value, 1); }

	/// read multiple 8bit values from a start register
	xpcc::ResumableResult<bool>
	read(Register reg, uint8_t *buffer, uint8_t length);

private:
	xpcc::ResumableResult<bool>
	updateRegister(uint8_t index, uint8_t setMask, uint8_t clearMask = 0xff);
	/// @endcond

protected:
	/// @cond
	Data &data;
	// the read buffer is for a continous read from address 0x00 -> 0x09
	// (x: SMPLRT_DIV is not buffered!)
	// 0: DLPF_FS
	// 1: INT_CFG
	//
	// 2: INT_STATUS
	// 3: TEMP_OUT_H  -- also used for write address of register
	// 4: TEMP_OUT_L -- also used for write buffer[0]
	// 5: GYRO_XOUT_H  -- also used for write buffer[1]
	// 6: GYRO_XOUT_L -- also used for write buffer[2]
	// 7: GYRO_YOUT_H
	// 8: GYRO_YOUT_L
	// 9: GYRO_ZOUT_H
	// 10: GYRO_ZOUT_L
	//
	// 11: PWR_MGM
	uint8_t rawBuffer[12];
	/// @endcond
};

}	// namespace xpcc

#include "itg3200_impl.hpp"

#endif // XPCC_ITG3200_HPP


text:
BotDet
======

Getting started
------------------

```bash
$ git clone git@github.com:pyar6329/BotDet.git
$ cd BotDet
$ ./get_started.sh

```

redpajama_set_name: RedPajamaGithub


text:
require 'rubygems'
require 'conjur/cli'
require 'uri'
require 'json'

Conjur::Config.load
Conjur::Config.apply

policy = JSON.load(File.read(File.expand_path('../policy-sandbox.json', __FILE__)))
policy_id = policy['policy']
hostname = URI.parse(Conjur.configuration.appliance_url).host

File.write File.expand_path('../backend/sdf.yml', __FILE__), <<SDF
global:
  conjur:
    hostname: #{hostname}

gatekeeper:
  port: 80
  service: service:4567
  conjur_account:  #{Conjur.configuration.account}
  conjur_resource: webservice/#{policy_id}/backend
SDF

File.write File.expand_path('../webapp/sdf.yml', __FILE__), <<SDF
global:
  conjur:
    hostname: #{hostname}

gatekeeper:
  port: 80
  service: service:4567
  conjur_account:  #{Conjur.configuration.account}
  conjur_resource: webservice/#{policy_id}/webapp

forward:
  backend:
    service: backend:80
SDF


text:
package com.coreoz.plume.file.services.file.data;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@Setter
@Getter
@Accessors(chain = true)
public class FileUploadBase64 {

	private String filename;
	private String base64;

}


text:
from copy import deepcopy
import re

from django.utils.datastructures import SortedDict, MultiValueDict
from django.utils.html import conditional_escape
from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode
from django.utils.safestring import mark_safe
from django.forms.widgets import flatatt
from google.appengine.ext import db
from ragendja.dbutils import transaction

class FormWithSets(object):
    def __init__(self, form, formsets=()):
        self.form = form
        setattr(self, '__module__', form.__module__)
        setattr(self, '__name__', form.__name__ + 'WithSets')
        setattr(self, '__doc__', form.__doc__)
        self._meta = form._meta
        fields = [(name, field) for name, field in form.base_fields.iteritems() if isinstance(field, FormSetField)]
        formset_dict = dict(formsets)
        newformsets = []
        for name, field in fields:
            if formset_dict.has_key(name):
                continue
            newformsets.append((name, {'formset':field.make_formset(form._meta.model)}))
        self.formsets = formsets + tuple(newformsets)

    def __call__(self, *args,  **kwargs):
        prefix = kwargs['prefix'] + '-' if 'prefix' in kwargs else ''
        form = self.form(*args,  **kwargs)
        formsets = []
        for name, formset in self.formsets:
            kwargs['prefix'] = prefix + name
            instance = formset['formset'](*args, **kwargs)
            if form.base_fields.has_key(name):
                field = form.base_fields[name]
            else:
                field = FormSetField(formset['formset'].model, **formset)
            formsets.append(BoundFormSet(field, instance, name, formset))
        return type(self.__name__ + 'Instance', (FormWithSetsInstance, ), {})(self, form, formsets)

def pretty_name(name):
    "Converts 'first_name' to 'First name'"
    name = name[0].upper() + name[1:]
    return name.replace('_', ' ')

table_sections_re = re.compile(r'^(.*?)(
.*
)(.*?)$', re.DOTALL)
table_row_re = re.compile(r'(
(<label.*?	)(.*?	)
)', re.DOTALL)
ul_sections_re = re.compile(r'^(.*?)(
.*
)(.*?)$', re.DOTALL)
ul_row_re = re.compile(r'(
(<label.*?)(.*?)
)', re.DOTALL)
p_sections_re = re.compile(r'^(.*?)(
.*
)(.*?)$', re.DOTALL)
p_row_re = re.compile(r'(
(<label.*?)(.*?)
)', re.DOTALL)
label_re = re.compile(r'^(.*)(.*)(.*)$')

class BoundFormSet(StrAndUnicode):
    def __init__(self, field, formset, name, args):
        self.field = field
        self.formset = formset
        self.name = name
        self.args = args
        if self.field.label is None:
            self.label = pretty_name(name)
        else:
            self.label = self.field.label
        self.auto_id = self.formset.auto_id % self.formset.prefix
        if args.has_key('attrs'):
            self.attrs = args['attrs'].copy()
        else:
            self.attrs = {}

    def __unicode__(self):
        """Renders this field as an HTML widget."""
        return self.as_widget()

    def as_widget(self, attrs=None):
        """
        Renders the field by rendering the passed widget, adding any HTML
        attributes passed as attrs.  If no widget is specified, then the
        field's default widget will be used.
        """
        attrs = attrs or {}
        auto_id = self.auto_id
        if auto_id and 'id' not in attrs and not self.args.has_key('id'):
            attrs['id'] = auto_id
        try:
            data = self.formset.as_table()
            name = self.name
            return self.render(name, data, attrs=attrs)
        except Exception, e:
            import traceback
            return traceback.format_exc()

    def render(self, name, value, attrs=None):
        table_sections = table_sections_re.search(value).groups()
        output = []
        heads = []
        current_row = []
        first_row = True
        first_head_id = None
        prefix = 'id_%s-%%s-' % self.formset.prefix
        for row, head, item in table_row_re.findall(table_sections[1]):
            if first_row:
                head_groups = label_re.search(head).groups()
                if first_head_id == head_groups[1]:
                    first_row = False
                    output.append(current_row)
                    current_row = []
                else:
                    heads.append('%s%s%s' % (head_groups[0], head_groups[2], head_groups[3]))
                    if first_head_id is None:
                        first_head_id = head_groups[1].replace('-0-','-1-')
            current_row.append(item)
            if not first_row and len(current_row) >= len(heads):
                output.append(current_row)
                current_row = []
        if len(current_row) != 0:
            raise Exception('Unbalanced render')
        return mark_safe(u'%s

%s

%s

%s'%(
            table_sections[0],
            flatatt(attrs),
            u''.join(heads),
            u'

'.join((u''.join(x) for x in output)),
            table_sections[2]))

class CachedQuerySet(object):
    def __init__(self, get_queryset):
        self.queryset_results = (x for x in get_queryset())

    def __call__(self):
        return self.queryset_results

class FormWithSetsInstance(object):
    def __init__(self, master, form, formsets):
        self.master = master
        self.form = form
        self.formsets = formsets
        self.instance = form.instance

    def __unicode__(self):
        return self.as_table()

    def is_valid(self):
        result = self.form.is_valid()
        for bf in self.formsets:
            result = bf.formset.is_valid() and result
        return result

    def save(self, *args,  **kwargs):
        def save_forms(forms, obj=None):
            for form in forms:
                if not instance and form != self.form:
                    for row in form.forms:
                        row.cleaned_data[form.rel_name] = obj
                form_obj = form.save(*args,  **kwargs)
                if form == self.form:
                    obj = form_obj
            return obj

        instance = self.form.instance
        grouped = [self.form]
        ungrouped = []
        # cache the result of get_queryset so that it doesn't run inside the transaction
        for bf in self.formsets:
            if bf.formset.rel_name == 'parent':
                grouped.append(bf.formset)
            else:
                ungrouped.append(bf.formset)
            bf.formset_get_queryset = bf.formset.get_queryset
            bf.formset.get_queryset = CachedQuerySet(bf.formset_get_queryset)
        obj = db.run_in_transaction(save_forms, grouped)
        save_forms(ungrouped, obj)
        for bf in self.formsets:
            bf.formset.get_queryset = bf.formset_get_queryset
            del bf.formset_get_queryset
        return obj

    def _html_output(self, form_as, normal_row, help_text_html, sections_re, row_re):
        formsets = SortedDict()
        for bf in self.formsets:
            if bf.label:
                label = conditional_escape(force_unicode(bf.label))
                # Only add the suffix if the label does not end in
                # punctuation.
                if self.form.label_suffix:
                    if label[-1] not in ':?.!':
                        label += self.form.label_suffix
                label = label or ''
            else:
                label = ''
            if bf.field.help_text:
                help_text = help_text_html % force_unicode(bf.field.help_text)
            else:
                help_text = u''
            formsets[bf.name] = normal_row % {'label': force_unicode(label), 'field': unicode(bf), 'help_text': help_text}

        try:
            output = []
            data = form_as()
            section_search = sections_re.search(data)
            if not section_search:
                output.append(data)
            else:
                section_groups = section_search.groups()
                for row, head, item in row_re.findall(section_groups[1]):
                    head_search = label_re.search(head)
                    if head_search:
                        id = head_search.groups()[1]
                        if formsets.has_key(id):
                            row = formsets[id]
                            del formsets[id]
                    output.append(row)

            for name, row in formsets.items():
                if name in self.form.fields.keyOrder:
                    output.append(row)

            return mark_safe(u'\n'.join(output))
        except Exception,e:
            import traceback
            return traceback.format_exc()

    def as_table(self):
        "Returns this form rendered as HTML
s -- excluding the

."
        return self._html_output(self.form.as_table,  u'
%(label)s	%(help_text)s%(field)s
', u'
%s', table_sections_re, table_row_re)

    def as_ul(self):
        "Returns this form rendered as HTML
s -- excluding the

."
        return self._html_output(self.form.as_ul,  u'
%(label)s %(help_text)s%(field)s
', u' %s', ul_sections_re, ul_row_re)

    def as_p(self):
        "Returns this form rendered as HTML
s."
        return self._html_output(self.form.as_p,  u'
%(label)s %(help_text)s
%(field)s', u' %s', p_sections_re, p_row_re)

    def full_clean(self):
        self.form.full_clean()
        for bf in self.formsets:
            bf.formset.full_clean()

    def has_changed(self):
        result = self.form.has_changed()
        for bf in self.formsets:
            result = bf.formset.has_changed() or result
        return result

    def is_multipart(self):
        result = self.form.is_multipart()
        for bf in self.formsets:
            result = bf.formset.is_multipart() or result
        return result

from django.forms.fields import Field
from django.forms.widgets import Widget
from django.forms.models import inlineformset_factory

class FormSetWidget(Widget):

    def __init__(self, field, attrs=None):
        super(FormSetWidget, self).__init__(attrs)
        self.field = field

    def render(self, name, value, attrs=None):
        if value is None: value = 'FormWithSets decorator required to render %s FormSet' % self.field.model.__name__
        value = force_unicode(value)
        final_attrs = self.build_attrs(attrs, name=name)
        return mark_safe(conditional_escape(value))

class FormSetField(Field):

    def __init__(self, model, widget=FormSetWidget, label=None, initial=None,
                 help_text=None, error_messages=None, show_hidden_initial=False,
                 formset_factory=inlineformset_factory, *args, **kwargs):
        widget = widget(self)
        super(FormSetField, self).__init__(required=False, widget=widget, label=label, initial=initial, help_text=help_text, error_messages=error_messages, show_hidden_initial=show_hidden_initial)
        self.model = model
        self.formset_factory = formset_factory
        self.args = args
        self.kwargs = kwargs

    def make_formset(self, parent_model):
        return self.formset_factory(parent_model, self.model, *self.args, **self.kwargs)


text:
redirect_to: https://anvio.org/help/main/artifacts/layer-taxonomy
---


text:
using System;
using Ninject.Core;
#endregion

namespace Ninject.Tests
{
	public class InitializableMock : IMock, IInitializable
	{
		private bool _init;

		public bool Initialized
		{
			get { return _init; }
		}

		public void Initialize()
		{
			_init = true;
		}
	}
}