text:
var types = require("HAP-NodeJS/accessories/types.js");
var request = require("request");

// This seems to be the "id" of the official LiftMaster iOS app
var APP_ID = "JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu"

function LiftMasterAccessory(log, config) {
  this.log = log;
  this.name = config["name"];
  this.username = config["username"];
  this.password = config["password"];
  this.requiredDeviceId = config["requiredDeviceId"];
}

LiftMasterAccessory.prototype = {

  setState: function(state) {
    this.targetState = state;
    this.login();
  },

  login: function() {
    var that = this;

    // reset our logged-in state hint until we're logged in
    this.deviceId = null;

    // querystring params
    var query = {
      appId: APP_ID,
      username: this.username,
      password: this.password,
      culture: "en"
    };

    // login to liftmaster
    request.get({
      url: "https://myqexternal.myqdevice.com/api/user/validatewithculture",
      qs: query
    }, function(err, response, body) {

      if (!err && response.statusCode == 200) {

        // parse and interpret the response
        var json = JSON.parse(body);
        that.userId = json["UserId"];
        that.securityToken = json["SecurityToken"];
        that.log("Logged in with user ID " + that.userId);
        that.getDevice();
      }
      else {
        that.log("Error '"+err+"' logging in: " + body);
      }
    });
  },

  // find your garage door ID
  getDevice: function() {
    var that = this;

    // querystring params
    var query = {
      appId: APP_ID,
      SecurityToken: this.securityToken,
      filterOn: "true"
    };

    // some necessary duplicated info in the headers
    var headers = {
      MyQApplicationId: APP_ID,
      SecurityToken: this.securityToken
    };

    // request details of all your devices
    request.get({
      url: "https://myqexternal.myqdevice.com/api/v4/userdevicedetails/get",
      qs: query,
      headers: headers
    }, function(err, response, body) {

      if (!err && response.statusCode == 200) {

        // parse and interpret the response
        var json = JSON.parse(body);
        var devices = json["Devices"];
        var foundDoors = [];

        // look through the array of devices for an opener
        for (var i=0; i<devices.length; i++) {
          var device = devices[i];

          if (device["MyQDeviceTypeName"] == "GarageDoorOpener") {

            // If we haven't explicity specified a door ID, we'll loop to make sure we don't have multiple openers, which is confusing
            if (that.requiredDeviceId == undefined) {
              var thisDeviceId = device.MyQDeviceId;
              var thisDoorName = "Unknown";
              for (var j = 0; j < device.Attributes.length; j ++) {
                var thisAttributeSet = device.Attributes[j];
                if (thisAttributeSet.AttributeDisplayName == "desc") {
                  thisDoorName = thisAttributeSet.Value;
                  break;
                }
              }
              foundDoors.push(thisDeviceId + " - " + thisDoorName);
            }

            // We specified a door ID, sanity check to make sure it's the one we expected
            else if (that.requiredDeviceId == device.MyQDeviceId) {
              that.deviceId = device.MyQDeviceId;
              break;
            }

          }

        }

        // If we have multiple found doors, refuse to proceed
        if (foundDoors.length > 1) {
          that.log("WARNING: You have multiple doors on your MyQ account.");
          that.log("WARNING: Specify the ID of the door you want to control using the 'requiredDeviceId' property in your config.json file.");
          that.log("WARNING: You can have multiple liftmaster accessories to cover your multiple doors");

          for (var j = 0; j < foundDoors.length; j++) {
            that.log("Found Door: " + foundDoors[j]);
          }

          throw "FATAL: Please specify which specific door this Liftmaster accessory should control - you have multiples on your account";

        }

        // Did we get a device ID?
        if (that.deviceId) {
          that.log("Found an opener with ID " + that.deviceId +". Ready to send command...");
          that.setTargetState();
        }
        else
        {
          that.log("Error: Couldn't find a door device, or the ID you specified isn't associated with your account");
        }
      }
      else {
        that.log("Error '"+err+"' getting devices: " + body);
      }
    });
  },

  setTargetState: function() {

    var that = this;
    var liftmasterState = (this.targetState + "") == "1" ? "0" : "1";

    // querystring params
    var query = {
      appId: APP_ID,
      SecurityToken: this.securityToken,
      filterOn: "true"
    };

    // some necessary duplicated info in the headers
    var headers = {
      MyQApplicationId: APP_ID,
      SecurityToken: this.securityToken
    };

    // PUT request body
    var body = {
      AttributeName: "desireddoorstate",
      AttributeValue: liftmasterState,
      ApplicationId: APP_ID,
      SecurityToken: this.securityToken,
      MyQDeviceId: this.deviceId
    };

    // send the state request to liftmaster
    request.put({
      url: "https://myqexternal.myqdevice.com/api/v4/DeviceAttribute/PutDeviceAttribute",
      qs: query,
      headers: headers,
      body: body,
      json: true
    }, function(err, response, json) {

      if (!err && response.statusCode == 200) {

        if (json["ReturnCode"] == "0")
          that.log("State was successfully set.");
        else
          that.log("Bad return code: " + json["ReturnCode"]);
          that.log("Raw response " + JSON.stringify(json));
      }
      else {
        that.log("Error '"+err+"' setting door state: " + JSON.stringify(json));
      }
    });
  },

  getServices: function() {
    var that = this;
    return [{
      sType: types.ACCESSORY_INFORMATION_STYPE,
      characteristics: [{
        cType: types.NAME_CTYPE,
        onUpdate: null,
        perms: ["pr"],
        format: "string",
        initialValue: this.name,
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "Name of the accessory",
        designedMaxLength: 255
      },{
        cType: types.MANUFACTURER_CTYPE,
        onUpdate: null,
        perms: ["pr"],
        format: "string",
        initialValue: "LiftMaster",
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "Manufacturer",
        designedMaxLength: 255
      },{
        cType: types.MODEL_CTYPE,
        onUpdate: null,
        perms: ["pr"],
        format: "string",
        initialValue: "Rev-1",
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "Model",
        designedMaxLength: 255
      },{
        cType: types.SERIAL_NUMBER_CTYPE,
        onUpdate: null,
        perms: ["pr"],
        format: "string",
        initialValue: "A1S2NASF88EW",
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "SN",
        designedMaxLength: 255
      },{
        cType: types.IDENTIFY_CTYPE,
        onUpdate: null,
        perms: ["pw"],
        format: "bool",
        initialValue: false,
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "Identify Accessory",
        designedMaxLength: 1
      }]
    },{
      sType: types.GARAGE_DOOR_OPENER_STYPE,
      characteristics: [{
        cType: types.NAME_CTYPE,
        onUpdate: null,
        perms: ["pr"],
        format: "string",
        initialValue: "Garage Door Opener Control",
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "Name of service",
        designedMaxLength: 255
      },{
        cType: types.CURRENT_DOOR_STATE_CTYPE,
        onUpdate: function(value) { that.log("Update current state to " + value); },
        perms: ["pr","ev"],
        format: "int",
        initialValue: 0,
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "BlaBla",
        designedMinValue: 0,
        designedMaxValue: 4,
        designedMinStep: 1,
        designedMaxLength: 1
      },{
        cType: types.TARGET_DOORSTATE_CTYPE,
        onUpdate: function(value) { that.setState(value); },
        perms: ["pr","pw","ev"],
        format: "int",
        initialValue: 0,
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "BlaBla",
        designedMinValue: 0,
        designedMaxValue: 1,
        designedMinStep: 1,
        designedMaxLength: 1
      },{
        cType: types.OBSTRUCTION_DETECTED_CTYPE,
        onUpdate: function(value) { that.log("Obstruction detected: " + value); },
        perms: ["pr","ev"],
        format: "bool",
        initialValue: false,
        supportEvents: false,
        supportBonjour: false,
        manfDescription: "BlaBla"
      }]
    }];
  }
};

module.exports.accessory = LiftMasterAccessory;


text:
local component = require("component")

--library table
local tapefile = {}

--This function replaces the stream methods after calling stream:close().
local function alreadyClosed()
  return nil, "Stream closed!"
end

local function closer(self)
  --replace methods
  self.seek  = alreadyClosed
  self.read  = alreadyClosed
  self.write = alreadyClosed
  self.close = alreadyClosed
end
local function seeker(self, whence, offset)
  --set default values
  whence = whence or "cur"
  offset = offset or 0
  --determine change in position
  local dpos
  if whence == "cur" then
    dpos = offset
  elseif whence == "set" then
    dpos = offset - self.pos
  elseif whence == "end" then
    dpos = self.size + offset - self.pos
  else
    return nil, "Unknown 'whence' value!"
  end
  --clip targeted position to available space
  dpos = math.max(math.min(dpos, self.size - self.pos), -self.pos)
  --try seeking
  dpos = self.drive.seek(dpos)
  --calculate position
  self.pos = self.pos + dpos
  --return new position
  return self.pos
end

function tapefile.open(address, rewinding, mode)
  --extract mode
  mode = mode or "r"
  mode = mode:match("^([rw])b?")
  if mode == nil then
    return nil, "Unsupported mode!"
  end
  --create stream object
  local stream = {
    close  = closer,
    seek   = seeker,
    drive  = component.proxy(address),
    pos    = 0,
    size   = tapefile.size(address, rewinding),
  }
  if stream.drive == nil then
    return nil, "Tape drive not found!"
  end
  if rewinding then
    stream.drive.seek(-stream.drive.getSize())
  end

  if mode == "r" then
    --open file in reading mode: define a read function
    function stream:read(count)
      local value = self.drive.read(count)
      self.pos = math.min(self.pos + #value, self.size)
      return value
    end
  elseif mode == "w" then
    --open file in a writing mode: define a write function
    function stream:write(value)
      local reachedEnd = (self.pos + #value > self.size)
      self.drive.write(value)
      self.pos = math.min(self.pos + #value, self.size)
      return not reachedEnd, reachedEnd and "eof" or nil
    end
  end
  if rewinding then
    stream.drive.seek(-stream.drive.getSize())
  end
  return stream
end
--return the size of the given file
function tapefile.size(address, rewinding)
  local tape_drive = component.proxy(address)
  if tape_drive == nil then
    return nil, "Tape drive not found!"
  end
  if rewinding then
    return tape_drive.getSize()
  else
    local totalBytes = tape_drive.getSize()
    if totalBytes == 0 then
      return 0
    end
    --get remaining size by seeking to the end
    local previousBytes = -tape_drive.seek(-totalBytes)
    --seek to original position
    tape_drive.seek(previousBytes)
    return totalBytes - previousBytes
  end
end

--returns a driver compatible file table
function tapefile.new(address, rewinding)
  return {
    open = function(path, mode)
      return tapefile.open(address, rewinding, mode)
    end,
    size = function(path)
      return tapefile.size(address, rewinding)
    end,
  }
end

--return library
return tapefile

redpajama_set_name: RedPajamaGithub


text:
[[#group]]

[[name]]

Parent organization: [[#parent]][[name]][[/parent]][[^parent]]not
        available[[/parent]]

Children organizations: [[#children]] [[name]]
        [[/children]][[^children]]not available[[/children]]

    [[#homepage]]

[[descriptionPublic]]

    [[#descriptionForMembers]]
[[descriptionForMembers]]
[[/descriptionForMembers]]

In this group you are [[#role]][[role]][[/role]][[^role]]visitor[[/role]]
        [[#isAdmin]]
        <button type="button" class="btn btn-small btn-warning" data-toggle="collapse" data-target="#groupParameters">
            Edit
        </button>
        [[/isAdmin]]

    [[/homepage]]
    [[#isAdmin]]

        <form class="form-horizontal" action="/api/groups/[[_id]]" method="post">
            <input type="hidden" value="[[csrf]]" name="_csrf"/>
            <input type="hidden" value="PUT" name="_method"/>

                Description for visitors

                    <textarea class="span10" name="descriptionPublic" id="descriptionPublic">[[homepage.descriptionPublic]]</textarea>

                Description for members only

                    <textarea class="span10" name="descriptionForMembers" id="descriptionForMembers">[[homepage.descriptionForMembers]]</textarea>

                        <input type="checkbox" name="isOpenToAll" value="1" [[#isOpenToAll]]checked[[/isOpenToAll]] >
                        Group is open - everybody can
                        join it

                    <input type="submit" class="btn btn-success" value="Save">
                    <input type="reset" class="btn btn-warning">

        </form>

    [[/isAdmin]]

Recent comments

    [[#messages]]

        [[#user]]

[[firstName]] [[lastName]] ([[username]])

        [[/user]]

[[createdAt]]

[[message]]

    [[/messages]]

    [[#isMember]]
    <form class="form-inline" action="/api/groups/createMessage/[[_id]]" method="post">
        <input type="hidden" name="_csrf" value="[[csrf]]"/>
        <textarea name="message" rows="3" cols="60" class="span12" placeholder="Send comment to the group"></textarea>
        <input type="submit" value="Send comment" class="btn btn-success btn-large pull-right"/>
    </form>
    [[/isMember]]

    [[^isMember]]
    <form class="form-inline" action="/api/groups/join/[[_id]]" method="post">
        <input type="hidden" name="_csrf" value="[[csrf]]"/>
        <input type="submit" value="Join this group" class="btn btn-success btn-large pull-right"/>
    </form>
    [[/isMember]]

    [[#isMember]]

You are a member of this group

    <form class="form-inline" action="/api/groups/leave/[[_id]]" method="post" id="formLeave">
        <input type="hidden" name="_csrf" value="[[csrf]]"/>
        <input type="submit" value="Leave this group" class="btn btn-danger"/>
    </form>
    [[/isMember]]

    [[^isMember]]
    <form class="form-inline" action="/api/groups/join/[[_id]]" method="post">
        <input type="hidden" name="_csrf" value="[[csrf]]"/>
        <input type="submit" value="Join this group" class="btn btn-success"/>
    </form>
    [[/isMember]]
    [[#isAdmin]]

Being a admin, you can invite somebody to this group:

    <form class="form-inline" action="/api/groups/invite/[[_id]]" method="post">
        <input type="hidden" name="_csrf" value="[[csrf]]"/>
        <input type="text" name="username" value="" placeholder="Enter username or email here">
        <input type="submit" value="Invite" class="btn btn-success"/>
    </form>
    [[/isAdmin]]

Members

    [[#members]]

    [[/members]]

[[/group]]


text:
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

import Page = require('../../../../../base/Page');
import Response = require('../../../../../http/response');
import V1 = require('../../../V1');
import serialize = require('../../../../../base/serialize');
import { SerializableClass } from '../../../../../interfaces';

/**
 * @description Initialize the WorkerStatisticsList
 *
 * @param version - Version of the resource
 * @param workspaceSid - The workspace_sid
 * @param workerSid - The worker_sid
 */
declare function WorkerStatisticsList(version: V1, workspaceSid: string, workerSid: string): WorkerStatisticsListInstance;

/**
 * Options to pass to fetch
 *
 * @property endDate - Filter cumulative statistics by a end date.
 * @property minutes - Filter cumulative statistics by up to 'x' minutes in the past.
 * @property startDate - Filter cumulative statistics by a start date.
 * @property taskChannel - Filter cumulative statistics by TaskChannel.
 */
interface WorkerStatisticsInstanceFetchOptions {
  endDate?: Date;
  minutes?: number;
  startDate?: Date;
  taskChannel?: string;
}

interface WorkerStatisticsListInstance {
  /**
   * @param sid - sid of instance
   */
  (sid: string): WorkerStatisticsContext;
  /**
   * Constructs a worker_statistics
   */
  get(): WorkerStatisticsContext;
}

interface WorkerStatisticsPayload extends WorkerStatisticsResource, Page.TwilioResponsePayload {
}

interface WorkerStatisticsResource {
  account_sid: string;
  cumulative: string;
  url: string;
  worker_sid: string;
  workspace_sid: string;
}

interface WorkerStatisticsSolution {
  workerSid?: string;
  workspaceSid?: string;
}

declare class WorkerStatisticsContext {
  /**
   * Initialize the WorkerStatisticsContext
   *
   * @param version - Version of the resource
   * @param workspaceSid - The workspace_sid
   * @param workerSid - The worker_sid
   */
  constructor(version: V1, workspaceSid: string, workerSid: string);

  /**
   * fetch a WorkerStatisticsInstance
   *
   * @param opts - Options for request
   * @param callback - Callback to handle processed record
   */
  fetch(opts?: WorkerStatisticsInstanceFetchOptions, callback?: (error: Error | null, items: WorkerStatisticsInstance) => any): Promise<WorkerStatisticsInstance>;
}

declare class WorkerStatisticsInstance extends SerializableClass {
  /**
   * Initialize the WorkerStatisticsContext
   *
   * @property accountSid - The account_sid
   * @property cumulative - The cumulative
   * @property workerSid - The worker_sid
   * @property workspaceSid - The workspace_sid
   * @property url - The url
   *
   * @param version - Version of the resource
   * @param payload - The instance payload
   * @param workspaceSid - The workspace_sid
   * @param workerSid - The worker_sid
   */
  constructor(version: V1, payload: WorkerStatisticsPayload, workspaceSid: string, workerSid: string);

  private _proxy: WorkerStatisticsContext;
  accountSid: string;
  cumulative: string;
  /**
   * fetch a WorkerStatisticsInstance
   *
   * @param opts - Options for request
   * @param callback - Callback to handle processed record
   */
  fetch(opts?: WorkerStatisticsInstanceFetchOptions, callback?: (error: Error | null, items: WorkerStatisticsInstance) => any): void;
  /**
   * Produce a plain JSON object version of the WorkerStatisticsInstance for serialization.
   * Removes any circular references in the object.
   */
  toJSON(): any;
  url: string;
  workerSid: string;
  workspaceSid: string;
}

declare class WorkerStatisticsPage extends Page<V1, WorkerStatisticsPayload, WorkerStatisticsResource, WorkerStatisticsInstance> {
  /**
   * Initialize the WorkerStatisticsPage
   *
   * @param version - Version of the resource
   * @param response - Response from the API
   * @param solution - Path solution
   */
  constructor(version: V1, response: Response<string>, solution: WorkerStatisticsSolution);

  /**
   * Build an instance of WorkerStatisticsInstance
   *
   * @param payload - Payload response from the API
   */
  getInstance(payload: WorkerStatisticsPayload): WorkerStatisticsInstance;
}

export { WorkerStatisticsContext, WorkerStatisticsInstance, WorkerStatisticsList, WorkerStatisticsListInstance, WorkerStatisticsPage, WorkerStatisticsPayload, WorkerStatisticsResource, WorkerStatisticsSolution }


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>WinPcap: Filtering expression syntax</title>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">

Main Page

Related Pages

Modules

Data Structures

Files

Filtering expression syntax

[WinPcap user's manual]

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>

Note: this document has been drawn from the tcpdump man page. The original version can
  be found at  www.tcpdump.org.

wpcap filters are based on a declarative predicate syntax. A filter is
  an ASCII string containing a filtering expression. pcap_compile()
  takes the expression and translates it in a program for the kernel-level
  packet filter.

The expression selects which packets will be dumped.
If no expression
is given, all packets on the net will be accepted by the kernel-level filtering
engine.
Otherwise,
only packets for which expression is `true' will be accepted.

The expression consists of one or more
primitives.

Primitives usually consist of an
id

(name or number) preceded by one or more qualifiers.
There are three
different kinds of qualifier:

type

qualifiers say what kind of thing the id name or number refers to.
Possible types are
host,

net

and
port.

E.g., `host foo', `net 128.3', `port 20'.
If there is no type
qualifier,
host

is assumed.

dir

qualifiers specify a particular transfer direction to and/or from
id.

Possible directions are
src,

dst,

src or dst

and
src and

dst.

E.g., `src foo', `dst net 128.3', `src or dst port ftp-data'.
If
there is no dir qualifier,
src or dst

is assumed.
For `null' link layers (i.e. point to point protocols such as slip) the
inbound

and
outbound

qualifiers can be used to specify a desired direction.

proto

qualifiers restrict the match to a particular protocol.
Possible
protos are:
ether,

fddi,

tr,

ip,

ip6,

arp,

rarp,

decnet,

tcp

and
udp.

E.g., `ether src foo', `arp net 128.3', `tcp port 21'.
If there is
no proto qualifier, all protocols consistent with the type are
assumed.
E.g., `src foo' means `(ip or arp or rarp) src foo'
(except the latter is not legal syntax), `net bar' means `(ip or
arp or rarp) net bar' and `port 53' means `(tcp or udp) port 53'.

[`fddi' is actually an alias for `ether'; the parser treats them
identically as meaning ``the data link level used on the specified
network interface.''  FDDI headers contain Ethernet-like source
and destination addresses, and often contain Ethernet-like packet
types, so you can filter on these FDDI fields just as with the
analogous Ethernet fields.
FDDI headers also contain other fields,
but you cannot name them explicitly in a filter expression.

Similarly, `tr' is an alias for `ether'; the previous paragraph's
statements about FDDI headers also apply to Token Ring headers.]

In addition to the above, there are some special `primitive' keywords
that don't follow the pattern:
gateway,

broadcast,

less,

greater

and arithmetic expressions.
All of these are described below.

More complex filter expressions are built up by using the words
and,

or

and
not

to combine primitives.
E.g., `host foo and not port ftp and not port ftp-data'.
To save typing, identical qualifier lists can be omitted.
E.g.,
`tcp dst port ftp or ftp-data or domain' is exactly the same as
`tcp dst port ftp or tcp dst port ftp-data or tcp dst port domain'.

Allowable primitives are:

dst host host

True if the IPv4/v6 destination field of the packet is host,
which may be either an address or a name.

src host host

True if the IPv4/v6 source field of the packet is host.

host host

True if either the IPv4/v6 source or destination of the packet is host.
Any of the above host expressions can be prepended with the keywords,
ip, arp, rarp, or ip6 as in:

ip host host

which is equivalent to:

ether proto \ip and host host

If host is a name with multiple IP addresses, each address will
be checked for a match.

ether dst ehost

True if the ethernet destination address is ehost.
Ehost
may be either a name from /etc/ethers or a number (see
ethers(3N)

for numeric format).

ether src ehost

True if the ethernet source address is ehost.

ether host ehost

True if either the ethernet source or destination address is ehost.

gateway host

True if the packet used host as a gateway.
I.e., the ethernet
source or destination address was host but neither the IP source
nor the IP destination was host.
Host must be a name and
must be found both by the machine's host-name-to-IP-address resolution
mechanisms (host name file, DNS, NIS, etc.) and by the machine's
host-name-to-Ethernet-address resolution mechanism (/etc/ethers, etc.).
(An equivalent expression is

ether host ehost and not host host

which can be used with either names or numbers for host / ehost.)
This syntax does not work in IPv6-enabled configuration at this moment.

dst net net

True if the IPv4/v6 destination address of the packet has a network
number of net.
Net may be either a name from /etc/networks
or a network number (see networks(4) for details).

src net net

True if the IPv4/v6 source address of the packet has a network
number of net.

net net

True if either the IPv4/v6 source or destination address of the packet has a network
number of net.

net net mask netmask

True if the IP address matches net with the specific netmask.
May be qualified with src or dst.
Note that this syntax is not valid for IPv6 net.

net net/len

True if the IPv4/v6 address matches net with a netmask len
bits wide.
May be qualified with src or dst.

dst port port

True if the packet is ip/tcp, ip/udp, ip6/tcp or ip6/udp and has a
destination port value of port.
The port can be a number or a name used in /etc/services (see
tcp(4P)

and
udp(4P)).

If a name is used, both the port
number and protocol are checked.
If a number or ambiguous name is used,
only the port number is checked (e.g., dst port 513 will print both
tcp/login traffic and udp/who traffic, and port domain will print
both tcp/domain and udp/domain traffic).

src port port

True if the packet has a source port value of port.

port port

True if either the source or destination port of the packet is port.
Any of the above port expressions can be prepended with the keywords,
tcp or udp, as in:

tcp src port port

which matches only tcp packets whose source port is port.

less length

True if the packet has a length less than or equal to length.
This is equivalent to:

len <= length.

greater length

True if the packet has a length greater than or equal to length.
This is equivalent to:

len >= length.

ip proto protocol

True if the packet is an IP packet (see
ip(4P))

of protocol type protocol.
Protocol can be a number or one of the names
icmp, icmp6, igmp, igrp, pim, ah,
esp, vrrp, udp, or tcp.
Note that the identifiers tcp, udp, and icmp are also
keywords and must be escaped via backslash (\), which is \\ in the C-shell.
Note that this primitive does not chase the protocol header chain.

ip6 proto protocol

True if the packet is an IPv6 packet of protocol type protocol.
Note that this primitive does not chase the protocol header chain.

ip6 protochain protocol

True if the packet is IPv6 packet,
and contains protocol header with type protocol
in its protocol header chain.
For example,

ip6 protochain 6

matches any IPv6 packet with TCP protocol header in the protocol header chain.
The packet may contain, for example,
authentication header, routing header, or hop-by-hop option header,
between IPv6 header and TCP header.
The BPF code emitted by this primitive is complex and
cannot be optimized by BPF optimizer code in tcpdump,
so this can be somewhat slow.

ip protochain protocol

Equivalent to ip6 protochain protocol, but this is for IPv4.

ether broadcast

True if the packet is an ethernet broadcast packet.
The ether
keyword is optional.

ip broadcast

True if the packet is an IP broadcast packet.
It checks for both
the all-zeroes and all-ones broadcast conventions, and looks up
the local subnet mask.

ether multicast

True if the packet is an ethernet multicast packet.
The ether
keyword is optional.
This is shorthand for `ether[0] & 1 != 0'.

ip multicast

True if the packet is an IP multicast packet.

ip6 multicast

True if the packet is an IPv6 multicast packet.

ether proto protocol

True if the packet is of ether type protocol.
Protocol can be a number or one of the names
ip, ip6, arp, rarp, atalk, aarp,
decnet, sca, lat, mopdl, moprc,
iso, stp, ipx, or netbeui.
Note these identifiers are also keywords
and must be escaped via backslash (\).

[In the case of FDDI (e.g., `fddi protocol arp') and Token Ring
(e.g., `tr protocol arp'), for most of those protocols, the
protocol identification comes from the 802.2 Logical Link Control (LLC)
header, which is usually layered on top of the FDDI or Token Ring
header.

When filtering for most protocol identifiers on FDDI or Token Ring,
tcpdump checks only the protocol ID field of an LLC header in
so-called SNAP format with an Organizational Unit Identifier (OUI) of
0x000000, for encapsulated Ethernet; it doesn't check whether the packet
is in SNAP format with an OUI of 0x000000.

The exceptions are iso, for which it checks the DSAP (Destination
Service Access Point) and SSAP (Source Service Access Point) fields of
the LLC header, stp and netbeui, where it checks the DSAP of
the LLC header, and atalk, where it checks for a SNAP-format
packet with an OUI of 0x080007 and the Appletalk etype.

In the case of Ethernet, tcpdump checks the Ethernet type field
for most of those protocols; the exceptions are iso, sap,
and netbeui, for which it checks for an 802.3 frame and then
checks the LLC header as it does for FDDI and Token Ring, atalk,
where it checks both for the Appletalk etype in an Ethernet frame and
for a SNAP-format packet as it does for FDDI and Token Ring, aarp,
where it checks for the Appletalk ARP etype in either an Ethernet frame
or an 802.2 SNAP frame with an OUI of 0x000000, and ipx, where it
checks for the IPX etype in an Ethernet frame, the IPX DSAP in the LLC
header, the 802.3 with no LLC header encapsulation of IPX, and the IPX
etype in a SNAP frame.]

decnet src host

True if the DECNET source address is
host,

which may be an address of the form ``10.123'', or a DECNET host
name.
[DECNET host name support is only available on Ultrix systems
that are configured to run DECNET.]

decnet dst host

True if the DECNET destination address is
host.

decnet host host

True if either the DECNET source or destination address is
host.

ip, ip6, arp, rarp, atalk, aarp, decnet, iso, stp, ipx, netbeui

Abbreviations for:

ether proto p

where p is one of the above protocols.

lat, moprc, mopdl

Abbreviations for:

ether proto p

where p is one of the above protocols.
Note that
tcpdump does not currently know how to parse these protocols.

vlan [vlan_id]

True if the packet is an IEEE 802.1Q VLAN packet.
If [vlan_id] is specified, only true is the packet has the specified
vlan_id.
Note that the first vlan keyword encountered in expression
changes the decoding offsets for the remainder of expression
on the assumption that the packet is a VLAN packet.

tcp, udp, icmp

Abbreviations for:

ip proto p or ip6 proto p

where p is one of the above protocols.

iso proto protocol

True if the packet is an OSI packet of protocol type protocol.
Protocol can be a number or one of the names
clnp, esis, or isis.

clnp, esis, isis

Abbreviations for:

iso proto p

where p is one of the above protocols.
Note that tcpdump does an incomplete job of parsing these protocols.

expr relop expr

True if the relation holds, where relop is one of >, <, >=, <=, =, !=,
and expr is an arithmetic expression composed of integer constants
(expressed in standard C syntax), the normal binary operators
[+, -, *, /, &, |], a length operator, and special packet data accessors.
To access
data inside the packet, use the following syntax:

proto [ expr : size ]

Proto is one of ether, fddi, tr,
ip, arp, rarp, tcp, udp, icmp or ip6, and
indicates the protocol layer for the index operation.
Note that tcp, udp and other upper-layer protocol types only
apply to IPv4, not IPv6 (this will be fixed in the future).
The byte offset, relative to the indicated protocol layer, is
given by expr.
Size is optional and indicates the number of bytes in the
field of interest; it can be either one, two, or four, and defaults to one.
The length operator, indicated by the keyword len, gives the
length of the packet.

For example, `ether[0] & 1 != 0' catches all multicast traffic.
The expression `ip[0] & 0xf != 5'
catches all IP packets with options.
The expression
`ip[6:2] & 0x1fff = 0'
catches only unfragmented datagrams and frag zero of fragmented datagrams.
This check is implicitly applied to the tcp and udp
index operations.
For instance, tcp[0] always means the first
byte of the TCP header, and never means the first byte of an
intervening fragment.

Some offsets and field values may be expressed as names rather than
as numeric values.
The following protocol header field offsets are
available: icmptype (ICMP type field), icmpcode (ICMP
code field), and tcpflags (TCP flags field).

The following ICMP type field values are available: icmp-echoreply,
icmp-unreach, icmp-sourcequench, icmp-redirect,
icmp-echo, icmp-routeradvert, icmp-routersolicit,
icmp-timxceed, icmp-paramprob, icmp-tstamp,
icmp-tstampreply, icmp-ireq, icmp-ireqreply,
icmp-maskreq, icmp-maskreply.

The following TCP flags field values are available: tcp-fin,
tcp-syn, tcp-rst, tcp-push, tcp-push,
tcp-ack, tcp-urg.

Primitives may be combined using:

A parenthesized group of primitives and operators
(parentheses are special to the Shell and must be escaped).

Negation (`<B>!</B>' or `not').

Concatenation (`<B>&&</B>' or `and').

Alternation (`<B>||</B>' or `or').

Negation has highest precedence.
Alternation and concatenation have equal precedence and associate
left to right.
Note that explicit and tokens, not juxtaposition,
are now required for concatenation.

If an identifier is given without a keyword, the most recent keyword
is assumed.
For example,

not host vs and ace

is short for

not host vs and host ace

which should not be confused with

not ( host vs or ace )

Expression arguments can be passed to tcpdump as either a single
argument or as multiple arguments, whichever is more convenient.
Generally, if the expression contains Shell metacharacters, it is
easier to pass it as a single, quoted argument.
Multiple arguments are concatenated with spaces before being parsed.

documentation. Copyright (c) 2002-2005 Politecnico di Torino. Copyright (c) 2005-2009
CACE Technologies. All rights reserved.


text:
/*
 * Copyright 2012-2013 Mo McRoberts.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "p_sqlite.h"

SQL_FIELD_API sql_sqlite_field_api_ = {
	sql_field_def_queryinterface_,
	sql_field_def_addref_,
	sql_field_sqlite_free_,
	sql_field_sqlite_name_,
	sql_field_sqlite_width_
};

/* Free a SQL_FIELD structure */
unsigned long
sql_field_sqlite_free_(SQL_FIELD *me)
{
	me->refcount--;
	if(me->refcount)
	{
		return me->refcount;
	}
	free(me);
	return 0;
}

/* Return a pointer to the name of the column */
const char *
sql_field_sqlite_name_(SQL_FIELD *me)
{
	return sqlite3_column_name(me->stmt->stmt, me->index);
}

/* Return the maximum width (i.e., number of characters) for this column */
size_t
sql_field_sqlite_width_(SQL_FIELD *me)
{
	return 1;
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.oriongate</groupId>
        <artifactId>oriongate_web</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <groupId>com.oriongate</groupId>
    <artifactId>oriongate_web_app_error</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>OrionGate WebApp Error</name>
    <description>OrionGate WebApp Error</description>

    <dependencies>
        <dependency>
            <groupId>com.oriongate</groupId>
            <artifactId>oriongate_web_app_core</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>com.oriongate</groupId>
            <artifactId>oriongate_web_jsp_fragments</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>


text:
using System;
using System.Text.Json;
using Azure.Core;

namespace Azure.ResourceManager.Synapse.Models
{
    public partial class KekIdentityProperties : IUtf8JsonSerializable
    {
        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
        {
            writer.WriteStartObject();
            if (Optional.IsDefined(UserAssignedIdentity))
            {
                writer.WritePropertyName("userAssignedIdentity");
                writer.WriteStringValue(UserAssignedIdentity);
            }
            if (Optional.IsDefined(UseSystemAssignedIdentity))
            {
                writer.WritePropertyName("useSystemAssignedIdentity");
#if NET6_0_OR_GREATER
				writer.WriteRawValue(UseSystemAssignedIdentity);
#else
                JsonSerializer.Serialize(writer, JsonDocument.Parse(UseSystemAssignedIdentity.ToString()).RootElement);
#endif
            }
            writer.WriteEndObject();
        }

        internal static KekIdentityProperties DeserializeKekIdentityProperties(JsonElement element)
        {
            Optional<string> userAssignedIdentity = default;
            Optional<BinaryData> useSystemAssignedIdentity = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("userAssignedIdentity"))
                {
                    userAssignedIdentity = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("useSystemAssignedIdentity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    useSystemAssignedIdentity = BinaryData.FromString(property.Value.GetRawText());
                    continue;
                }
            }
            return new KekIdentityProperties(userAssignedIdentity.Value, useSystemAssignedIdentity.Value);
        }
    }
}


text:
(function () {
    'use strict';

    angular.module('ariaNg').factory('ariaNgCommonService', ['$window', '$location', '$timeout', 'base64', 'moment', 'SweetAlert', 'ariaNgConstants', 'ariaNgLocalizationService', function ($window, $location, $timeout, base64, moment, SweetAlert, ariaNgConstants, ariaNgLocalizationService) {
        var getTimeOption = function (time) {
            var name = '';
            var value = time;

            if (time < 1000) {
                value = time;
                name = (value === 1 ? 'format.time.millisecond' : 'format.time.milliseconds');
            } else if (time < 1000 * 60) {
                value = time / 1000;
                name = (value === 1 ? 'format.time.second' : 'format.time.seconds');
            } else if (time < 1000 * 60 * 24) {
                value = time / 1000 / 60;
                name = (value === 1 ? 'format.time.minute' : 'format.time.minutes');
            } else {
                value = time / 1000 / 60 / 24;
                name = (value === 1 ? 'format.time.hour' : 'format.time.hours');
            }

            return {
                name: name,
                value: value,
                optionValue: time
            };
        };

        var showDialog = function (title, text, type, callback, options) {
            $timeout(function () {
                SweetAlert.swal({
                    title: title,
                    text: text,
                    type: type,
                    confirmButtonText: options && options.confirmButtonText || null
                }, function () {
                    if (callback) {
                        callback();
                    }
                });
            }, 100);
        };

        var showConfirmDialog = function (title, text, type, callback, notClose, extendSettings) {
            var options = {
                title: title,
                text: text,
                type: type,
                showCancelButton: true,
                showLoaderOnConfirm: !!notClose,
                closeOnConfirm: !notClose,
                confirmButtonText: extendSettings && extendSettings.confirmButtonText || null,
                cancelButtonText: extendSettings && extendSettings.cancelButtonText || null
            };

            if (type === 'warning') {
                options.confirmButtonColor = '#F39C12';
            }

            SweetAlert.swal(options, function (isConfirm) {
                if (!isConfirm) {
                    return;
                }

                if (callback) {
                    callback();
                }
            });
        }

        return {
            getFullPageUrl: function () {
                return $window.location.protocol + '//'
                    + $window.location.host
                    + $window.location.pathname
                    + ($window.location.search ? $window.location.search : '');
            },
            base64Encode: function (value) {
                return base64.encode(value);
            },
            base64Decode: function (value) {
                return base64.decode(value);
            },
            base64UrlEncode: function (value) {
                return base64.urlencode(value);
            },
            base64UrlDecode: function (value) {
                return base64.urldecode(value);
            },
            generateUniqueId: function () {
                var sourceId = ariaNgConstants.appPrefix + '_' + Math.round(new Date().getTime() / 1000) + '_' + Math.random();
                var hashedId = this.base64Encode(sourceId);

                return hashedId;
            },
            showDialog: function (title, text, type, callback, extendSettings) {
                if (!extendSettings) {
                    extendSettings = {};
                }

                if (title) {
                    title = ariaNgLocalizationService.getLocalizedText(title);
                }

                if (text) {
                    text = ariaNgLocalizationService.getLocalizedText(text, extendSettings.textParams);
                }

                extendSettings.confirmButtonText = ariaNgLocalizationService.getLocalizedText('OK');

                showDialog(title, text, type, callback, extendSettings);
            },
            showInfo: function (title, text, callback, extendSettings) {
                this.showDialog(title, text, 'info', callback, extendSettings);
            },
            showError: function (text, callback, extendSettings) {
                this.showDialog('Error', text, 'error', callback, extendSettings);
            },
            showOperationSucceeded: function (text, callback) {
                this.showDialog('Operation Succeeded', text, 'success', callback);
            },
            confirm: function (title, text, type, callback, notClose, extendSettings) {
                if (!extendSettings) {
                    extendSettings = {};
                }

                if (title) {
                    title = ariaNgLocalizationService.getLocalizedText(title);
                }

                if (text) {
                    text = ariaNgLocalizationService.getLocalizedText(text, extendSettings.textParams);
                }

                extendSettings.confirmButtonText = ariaNgLocalizationService.getLocalizedText('OK');
                extendSettings.cancelButtonText = ariaNgLocalizationService.getLocalizedText('Cancel');

                showConfirmDialog(title, text, type, callback, notClose, extendSettings);
            },
            closeAllDialogs: function () {
                SweetAlert.close();
            },
            getFileExtension: function (filePath) {
                if (!filePath || filePath.lastIndexOf('.') < 0) {
                    return filePath;
                }

                return filePath.substring(filePath.lastIndexOf('.'));
            },
            parseUrlsFromOriginInput: function (s) {
                if (!s) {
                    return [];
                }

                var lines = s.split('\n');
                var result = [];

                for (var i = 0; i < lines.length; i++) {
                    var line = lines[i];

                    if (line.match(/^(http|https|ftp|sftp):\/\/.+$/)) {
                        result.push(line);
                    } else if (line.match(/^magnet:\?.+$/)) {
                        result.push(line);
                    }
                }

                return result;
            },
            decodePercentEncodedString: function (s) {
                if (!s) {
                    return s;
                }

                var ret = '';

                for (var i = 0; i < s.length; i++) {
                    var ch = s.charAt(i);

                    if (ch === '%' && i < s.length - 2) {
                        var code = s.substring(i + 1, i + 3);
                        ret += String.fromCharCode(parseInt(code, 16));
                        i += 2;
                    } else {
                        ret += ch;
                    }
                }

                return ret;
            },
            extendArray: function (sourceArray, targetArray, keyProperty) {
                if (!targetArray || !sourceArray || sourceArray.length !== targetArray.length) {
                    return false;
                }

                for (var i = 0; i < targetArray.length; i++) {
                    if (targetArray[i][keyProperty] === sourceArray[i][keyProperty]) {
                        angular.extend(targetArray[i], sourceArray[i]);
                    } else {
                        return false;
                    }
                }

                return true;
            },
            copyObjectTo: function (from, to) {
                if (!to) {
                    return from;
                }

                for (var name in from) {
                    if (!from.hasOwnProperty(name)) {
                        continue;
                    }

                    var fromValue = from[name];
                    var toValue = to[name];

                    if (angular.isObject(fromValue) || angular.isArray(fromValue)) {
                        to[name] = this.copyObjectTo(from[name], to[name]);
                    } else {
                        if (fromValue !== toValue) {
                            to[name] = fromValue;
                        }
                    }
                }

                return to;
            },
            pushArrayTo: function (array, items) {
                if (!angular.isArray(array)) {
                    array = [];
                }

                if (!angular.isArray(items) || items.length < 1) {
                    return array;
                }

                for (var i = 0; i < items.length; i++) {
                    array.push(items[i]);
                }

                return array;
            },
            combineArray: function () {
                var result = [];

                for (var i = 0; i < arguments.length; i++) {
                    if (angular.isArray(arguments[i])) {
                        this.pushArrayTo(result, arguments[i]);
                    } else {
                        result.push(arguments[i]);
                    }
                }

                return result;
            },
            countArray: function (array, value) {
                if (!angular.isArray(array) || array.length < 1) {
                    return 0;
                }

                var count = 0;

                for (var i = 0; i < array.length; i++) {
                    count += (array[i] === value ? 1 : 0);
                }

                return count;
            },
            parseOrderType: function (value) {
                var values = value.split(':');

                var obj = {
                    type: values[0],
                    order: values[1],
                    equals: function (obj) {
                        if (angular.isUndefined(obj.order)) {
                            return this.type === obj.type;
                        } else {
                            return this.type === obj.type && this.order === obj.order;
                        }
                    },
                    getValue: function () {
                        return this.type + ':' + this.order;
                    }
                };

                Object.defineProperty(obj, 'reverse', {
                    get: function () {
                        return this.order === 'desc';
                    },
                    set: function (value) {
                        this.order = (value ? 'desc' : 'asc');
                    }
                });

                return obj;
            },
            getCurrentUnixTime: function () {
                return moment().format('X');
            },
            getLongTimeFromUnixTime: function (unixTime) {
                return moment(unixTime, 'X').format('HH:mm:ss');
            },
            isUnixTimeAfter: function (datetime, duration, unit) {
                return moment(datetime, 'X').isAfter(moment().add(duration, unit));
            },
            formatDateTime: function (datetime, format) {
                return moment(datetime).format(format);
            },
            getTimeOption: function (time) {
                return getTimeOption(time);
            },
            getTimeOptions: function (timeList, withDisabled) {
                var options = [];

                if (withDisabled) {
                    options.push({
                        name: 'Disabled',
                        value: 0,
                        optionValue: 0
                    });
                }

                if (!angular.isArray(timeList) || timeList.length < 1) {
                    return options;
                }

                for (var i = 0; i < timeList.length; i++) {
                    var time = timeList[i];
                    var option = getTimeOption(time);

                    options.push(option);
                }

                return options;
            }
        };
    }]);
}());


text:
package armapplicationinsights_test

import (
	"context"
	"log"

	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/applicationinsights/armapplicationinsights/v2"
)

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysList.json
func ExampleAPIKeysClient_NewListPager() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	client, err := armapplicationinsights.NewAPIKeysClient("subid", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := client.NewListPager("my-resource-group",
		"my-component",
		nil)
	for pager.More() {
		nextResult, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range nextResult.Value {
			// TODO: use page item
			_ = v
		}
	}
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysCreate.json
func ExampleAPIKeysClient_Create() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	client, err := armapplicationinsights.NewAPIKeysClient("subid", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := client.Create(ctx,
		"my-resource-group",
		"my-component",
		armapplicationinsights.APIKeyRequest{
			Name: to.Ptr("test2"),
			LinkedReadProperties: []*string{
				to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api"),
				to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig")},
			LinkedWriteProperties: []*string{
				to.Ptr("/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations")},
		},
		nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// TODO: use response item
	_ = res
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysDelete.json
func ExampleAPIKeysClient_Delete() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	client, err := armapplicationinsights.NewAPIKeysClient("subid", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := client.Delete(ctx,
		"my-resource-group",
		"my-component",
		"bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a",
		nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// TODO: use response item
	_ = res
}

// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2015-05-01/examples/APIKeysGet.json
func ExampleAPIKeysClient_Get() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	client, err := armapplicationinsights.NewAPIKeysClient("subid", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	res, err := client.Get(ctx,
		"my-resource-group",
		"my-component",
		"bb820f1b-3110-4a8b-ba2c-8c1129d7eb6a",
		nil)
	if err != nil {
		log.Fatalf("failed to finish the request: %v", err)
	}
	// TODO: use response item
	_ = res
}


text:
This error occurs when two modules have the same name.

## Fix

- Make sure your module names are correct.
- Check to make sure you do not have any duplicate modules in your dependencies.
- If you are passing input files to the compiler using a wildcard, make sure it is not
  including any files twice.

## Notes


text:
package org.apache.hadoop.mapred;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.net.Node;
import org.apache.hadoop.net.TopologyCache;
import org.apache.hadoop.mapred.JobInProgress.Counter;

import java.util.ArrayList;

/**
 * Record locality information. Can perform the locality computation in a
 * separate thread.
 */
public class LocalityStats implements Runnable {
  /** Logger. */
  private static final Log LOG = LogFactory.getLog(LocalityStats.class);
  /** Topology cache. */
  private final TopologyCache topologyCache;
  /** Max locality level. */
  private final int maxLevel;
  /** Job Counters. */
  private final Counters jobCounters;
  /** Job Statistics. */
  private final JobStats jobStats;
  /** List of records to be used for asynchronous operation. */
  private final ArrayList<Record> localityRecords = new ArrayList<Record>();
  /** In async mode, used to check if we are running. */
  private volatile boolean running = true;

  /**
   * Constructor.
   * @param jobConf Job Configuration.
   * @param maxLevel The maximum locality level.
   * @param counters The job counters to update.
   * @param jobStats The job statistics to update.
   */
  public LocalityStats(
    JobConf jobConf, int maxLevel, Counters counters, JobStats jobStats,
    TopologyCache topologyCache) {
    this.topologyCache = topologyCache;
    this.maxLevel = maxLevel;
    this.jobCounters = counters;
    this.jobStats = jobStats;
  }

  public String getNode(String host) {
    return topologyCache.getNode(host).toString();
  }

  /**
   * Representation of information for asynchronous update.
   */
  private static class Record {
    /** The task. */
    private final TaskInProgress tip;
    /** The task tracker host. */
    private final String host;
    /** The number of bytes processed. */
    private final long inputBytes;

    /**
     * Constructor
     * @param tip The task.
     * @param host The task tracker host.
     * @param inputBytes The number of bytes processed.
     */
    private Record(TaskInProgress tip, String host, long inputBytes) {
      this.tip = tip;
      this.host = host;
      this.inputBytes = inputBytes;
    }
  }

  /**
   * In async mode, stop the thread.
   */
  public void stop() {
    running = false;
  }

  /**
   * Asynchronous update of locality.
   * @param tip The task.
   * @param host The task tracker host.
   * @param inputBytes The number of bytes processed.
   */
  public void record(
    TaskInProgress tip, String host, long inputBytes) {
    synchronized (localityRecords) {
      localityRecords.add(new Record(tip, host, inputBytes));
      localityRecords.notify();
    }
  }

  @Override
  public void run() {
    LOG.info("Starting locality computation thread");
    while (running) {
      Record record = null;
      synchronized (localityRecords) {
        while (localityRecords.isEmpty()) {
          try {
            localityRecords.wait();
          } catch (InterruptedException e) {
            if (!running) {
              return;
            }
          }
        }
        // Remove last element in the array.
        record = localityRecords.remove(localityRecords.size() - 1);
      }
      computeStatistics(record);
    }
    LOG.info("Exiting locality computation thread");
  }

  /**
   * Peform the computation statistics based on a locality record.
   * @param record The locality information.
   */
  private void computeStatistics(Record record) {
    computeStatistics(record.tip, record.host, record.inputBytes);
  }

  /**
   * Peform the computation statistics.
   * @param tip The task.
   * @param host The task tracker host.
   * @param inputBytes The number of bytes processed.
   */
  private void computeStatistics(
    TaskInProgress tip, String host, long inputBytes) {
    int level = this.maxLevel;
    String[] splitLocations = tip.getSplitLocations();
    if (splitLocations.length > 0) {
      Node tracker = topologyCache.getNode(host);
      // find the right level across split locations
      for (String local : splitLocations) {
        Node datanode = topologyCache.getNode(local);
        int newLevel = this.maxLevel;
        if (tracker != null && datanode != null) {
          newLevel = getMatchingLevelForNodes(tracker, datanode, maxLevel);
        }
        if (newLevel < level) {
          level = newLevel;
          if (level == 0) {
            break;
          }
        }
      }
    }
    boolean updateTaskCountOnly = inputBytes < 0;
    switch (level) {
    case 0:
      if (updateTaskCountOnly) {
        LOG.info("Chose data-local task " + tip.getTIPId());
        jobCounters.incrCounter(Counter.DATA_LOCAL_MAPS, 1);
        jobStats.incNumDataLocalMaps();
      } else {
        jobCounters.incrCounter(Counter.LOCAL_MAP_INPUT_BYTES, inputBytes);
        jobStats.incLocalMapInputBytes(inputBytes);
      }
      break;
    case 1:
      if (updateTaskCountOnly) {
        LOG.info("Chose rack-local task " + tip.getTIPId());
        jobCounters.incrCounter(Counter.RACK_LOCAL_MAPS, 1);
        jobStats.incNumRackLocalMaps();
      } else {
        jobCounters.incrCounter(Counter.RACK_MAP_INPUT_BYTES, inputBytes);
        jobStats.incRackMapInputBytes(inputBytes);
      }
      break;
    default:
      LOG.info("Chose non-local task " + tip.getTIPId() + " at level " + level);
      // check if there is any locality
      if (updateTaskCountOnly && level != this.maxLevel) {
        jobCounters.incrCounter(Counter.OTHER_LOCAL_MAPS, 1);
      }
      break;
    }
  }

  public static int getMatchingLevelForNodes(Node n1, Node n2, int maxLevel) {
    int count = 0;
    do {
      if (n1.equals(n2)) {
        return count;
      }
      ++count;
      n1 = n1.getParent();
      n2 = n2.getParent();
    } while (n1 != null && n2 != null);
    return maxLevel;
  }

}


text:
module Homestead
  class ListingsController < ApplicationController
    def index
      # @listings = office.listings
      @listings = ListingDecorator.decorate_collection @q.result
    end
    def search
      @q = Listing.search(params[:q])
    end
    def show
      @listing = ListingDecorator.decorate Listing.find(params[:id])
    end
  end
end


text:
<?php

/**
 * @var $midia Midias
 */

use Winged\Form\Form;

$form = new Form($midia);

echo $form->begin('#', 'post', ['id' => 'update-midia-form'], 'multipart/form-data', true);

echo $form->addInput(Midias::primaryKeyName(), 'Input', ['type' => 'hidden'], ['class' => ['no-display']]);

?>

                        Somente substituição
                        <button class="btn btn-primary display-inline-block replace mr-10" style="float: right;"> Substituir arquivo
                        </button>

<?php

$form->end();


text:
#pragma once

#include "../visualizationbase_api.h"
#include "../layouts/Layout.h"
#include "Cursor.h"

namespace Visualization {

class FormElement;

class VISUALIZATIONBASE_API LayoutCursor : public Cursor {
	public:
		LayoutCursor(Item* owner, CursorType type);
		virtual LayoutCursor* clone() const override;

		virtual void update() override;

		void setVisualizationSize(const QSize& size);

		void set2DIndex(int x, int y);
		void setIndex(int index);
		void setVisualizationPosition(const QPoint& pos);
		void setOwnerElement(FormElement* ownerElement);

		int x();
		int y();
		int index();
		FormElement* ownerElement();

		void setIsAtBoundary(bool isAtBoundary);

		virtual bool isSame(Cursor* c) override;
		virtual bool isAtBoundary() const override;

	private:
		int x_;
		int y_;
		int index_;
		bool isAtBoundary_;
		FormElement* ownerElement_;
};

inline void LayoutCursor::set2DIndex(int x, int y) { x_ = x; y_ = y; }
inline void LayoutCursor::setIndex(int index) { index_ = index; }
inline void LayoutCursor::setOwnerElement(FormElement* ownerElement) {ownerElement_ = ownerElement;}

inline int LayoutCursor::x() { return x_; }
inline int LayoutCursor::y() { return y_; }
inline int LayoutCursor::index() { return index_; }
inline FormElement* LayoutCursor::ownerElement() { return ownerElement_; }

inline void LayoutCursor::setIsAtBoundary(bool isAtBoundary) { isAtBoundary_ = isAtBoundary; }

}


text:
/*-------------------------------------------------------------------------
 *
 * Created:     H5Clog.c
 *
 * Purpose:     Functions for metadata cache logging
 *
 *-------------------------------------------------------------------------
 */

/****************/
/* Module Setup */
/****************/
#include "H5Cmodule.h"         /* This source code file is part of the H5C module */

/***********/
/* Headers */
/***********/
#include "H5private.h"          /* Generic Functions                        */
#define H5AC_FRIEND     /* Suppress error about including H5ACpkg */
#include "H5ACpkg.h"            /* Metadata cache                           */
#include "H5Cpkg.h"             /* Cache                                    */
#include "H5Clog.h"             /* Cache logging                            */
#include "H5Eprivate.h"         /* Error handling                           */

/****************/
/* Local Macros */
/****************/

/******************/
/* Local Typedefs */
/******************/

/********************/
/* Package Typedefs */
/********************/

/********************/
/* Local Prototypes */
/********************/

/*********************/
/* Package Variables */
/*********************/

/*****************************/
/* Library Private Variables */
/*****************************/

/*******************/
/* Local Variables */
/*******************/

/*-------------------------------------------------------------------------
 * Function:    H5C_log_set_up
 *
 * Purpose:     Setup for metadata cache logging.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately)
{
    int mpi_rank = -1;              /* -1 indicates serial (no MPI rank) */
    herr_t ret_value = SUCCEED;     /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);
    HDassert(log_location);

    /* Check logging flags */
    if(cache->log_info->enabled)
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging already set up")

    /* Get the rank when MPI is in use. Logging clients will usually
     * use that to create per-process logs.
     */
#ifdef H5_HAVE_PARALLEL
    if(NULL != cache->aux_ptr)
        mpi_rank = ((H5AC_aux_t *)(cache->aux_ptr))->mpi_rank;
#endif /*H5_HAVE_PARALLEL*/

    /* Set up logging */
    if(H5C_LOG_STYLE_JSON == style) {
        if(H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up json logging")
    }
    else if(H5C_LOG_STYLE_TRACE == style) {
        if(H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up trace logging")
    }
    else
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unknown logging style")

    /* Set logging flags */
    cache->log_info->enabled = TRUE;

    /* Start logging if requested */
    if(start_immediately)
        if(H5C_start_logging(cache) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to start logging")

 done:

    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_set_up() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_tear_down
 *
 * Purpose:     Tear-down for metadata cache logging.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_tear_down(H5C_t *cache)
{
    herr_t ret_value = SUCCEED;      /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Check logging flags */
    if(FALSE == cache->log_info->enabled)
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled")

    /* Stop logging if that's going on */
    if(cache->log_info->logging)
        if(H5C_stop_logging(cache) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to stop logging")

    /* Tear down logging */
    if(cache->log_info->cls->tear_down_logging)
        if(cache->log_info->cls->tear_down_logging(cache->log_info) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific tear down call failed")

    /* Unset logging flags */
    cache->log_info->enabled = FALSE;

 done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_tear_down() */

/*-------------------------------------------------------------------------
 * Function:    H5C_start_logging
 *
 * Purpose:     Start logging metadata cache operations.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_start_logging(H5C_t *cache)
{
    herr_t ret_value = SUCCEED;      /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Check logging flags */
    if(FALSE == cache->log_info->enabled)
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled")

    /* Start logging */
    if(cache->log_info->cls->start_logging)
        if(cache->log_info->cls->start_logging(cache->log_info) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific start call failed")

    /* Set logging flags */
    cache->log_info->logging = TRUE;

    /* Write a log message */
    if(cache->log_info->cls->write_start_log_msg)
        if(cache->log_info->cls->write_start_log_msg(cache->log_info->udata) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write start call failed")

 done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_start_logging() */

/*-------------------------------------------------------------------------
 * Function:    H5C_stop_logging
 *
 * Purpose:     Stop logging metadata cache operations.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_stop_logging(H5C_t *cache)
{
    herr_t ret_value = SUCCEED;      /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Check logging flags */
    if(FALSE == cache->log_info->enabled)
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled")
    if(FALSE == cache->log_info->logging)
        HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not in progress")

    /* Write a log message */
    if(cache->log_info->cls->write_stop_log_msg)
        if(cache->log_info->cls->write_stop_log_msg(cache->log_info->udata) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write stop call failed")

    /* Stop logging */
    if(cache->log_info->cls->stop_logging)
        if(cache->log_info->cls->stop_logging(cache->log_info) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific stop call failed")

    /* Set logging flags */
    cache->log_info->logging = FALSE;

 done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_stop_logging() */

/*-------------------------------------------------------------------------
 * Function:    H5C_get_logging_status
 *
 * Purpose:     Determines if the cache is actively logging (via the OUT
 *              parameters).
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled,
                       /*OUT*/ hbool_t *is_currently_logging)
{
    FUNC_ENTER_NOAPI_NOERR

    /* Sanity checks */
    HDassert(cache);
    HDassert(is_enabled);
    HDassert(is_currently_logging);

    /* Get logging flags */
    *is_enabled = cache->log_info->enabled;
    *is_currently_logging = cache->log_info->logging;

    FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5C_get_logging_status() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_create_cache_msg
 *
 * Purpose:     Write a log message for cache creation.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_create_cache_log_msg)
        if(cache->log_info->cls->write_create_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write create cache call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_create_cache_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_destroy_cache_msg
 *
 * Purpose:     Write a log message for cache destruction.
 *
 * NOTE:        This can't print out the H5AC call return value, since we
 *              won't know that until the cache is destroyed and at that
 *              point we no longer have pointers to the logging information.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_destroy_cache_msg(H5C_t *cache)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_destroy_cache_log_msg)
        if(cache->log_info->cls->write_destroy_cache_log_msg(cache->log_info->udata) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write destroy cache call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_destroy_cache_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_evict_cache_msg
 *
 * Purpose:     Write a log message for eviction of cache entries.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_evict_cache_log_msg)
        if(cache->log_info->cls->write_evict_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write evict cache call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_evict_cache_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_expunge_entry_msg
 *
 * Purpose:     Write a log message for expunge of cache entries.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address,
    int type_id, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_expunge_entry_log_msg)
        if(cache->log_info->cls->write_expunge_entry_log_msg(cache->log_info->udata, address, type_id, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write expunge entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_expunge_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_flush_cache_msg
 *
 * Purpose:     Write a log message for cache flushes.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_flush_cache_log_msg)
        if(cache->log_info->cls->write_flush_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific flush cache call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_flush_cache_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_insert_entry_msg
 *
 * Purpose:     Write a log message for insertion of cache entries.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address,
    int type_id, unsigned flags, size_t size, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_insert_entry_log_msg)
        if(cache->log_info->cls->write_insert_entry_log_msg(cache->log_info->udata, address, type_id, flags, size, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific insert entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_insert_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_mark_entry_dirty_msg
 *
 * Purpose:     Write a log message for marking cache entries as dirty.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_mark_entry_dirty_log_msg)
        if(cache->log_info->cls->write_mark_entry_dirty_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark dirty entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_mark_entry_dirty_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_mark_entry_clean_msg
 *
 * Purpose:     Write a log message for marking cache entries as clean.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_mark_entry_clean_log_msg)
        if(cache->log_info->cls->write_mark_entry_clean_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark clean entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_mark_entry_clean_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_mark_unserialized_entry_msg
 *
 * Purpose:     Write a log message for marking cache entries as unserialized.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache,
    const H5C_cache_entry_t *entry, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_mark_unserialized_entry_log_msg)
        if(cache->log_info->cls->write_mark_unserialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark unserialized entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_mark_unserialized_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_mark_serialized_entry_msg
 *
 * Purpose:     Write a log message for marking cache entries as serialize.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;         /* Return value */

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_mark_serialized_entry_log_msg)
        if(cache->log_info->cls->write_mark_serialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark serialized entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_mark_serialized_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_move_entry_msg
 *
 * Purpose:     Write a log message for moving a cache entry.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr,
    int type_id, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_move_entry_log_msg)
        if(cache->log_info->cls->write_move_entry_log_msg(cache->log_info->udata, old_addr, new_addr, type_id, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific move entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_move_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_pin_entry_msg
 *
 * Purpose:     Write a log message for pinning a cache entry.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_pin_entry_log_msg)
        if(cache->log_info->cls->write_pin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific pin entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_pin_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_create_fd_msg
 *
 * Purpose:     Write a log message for creating a flush dependency between
 *              two cache entries.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent,
    const H5C_cache_entry_t *child, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(parent);
    HDassert(child);
    if(cache->log_info->cls->write_create_fd_log_msg)
        if(cache->log_info->cls->write_create_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific create fd call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_create_fd_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_protect_entry_msg
 *
 * Purpose:     Write a log message for protecting a cache entry.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    int type_id, unsigned flags, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_protect_entry_log_msg)
        if(cache->log_info->cls->write_protect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific protect entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_protect_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_resize_entry_msg
 *
 * Purpose:     Write a log message for resizing a cache entry.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    size_t new_size, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_resize_entry_log_msg)
        if(cache->log_info->cls->write_resize_entry_log_msg(cache->log_info->udata, entry, new_size, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific resize entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_resize_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_unpin_entry_msg
 *
 * Purpose:     Write a log message for unpinning a cache entry.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_unpin_entry_log_msg)
        if(cache->log_info->cls->write_unpin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unpin entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_unpin_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_destroy_fd_msg
 *
 * Purpose:     Write a log message for destroying a flush dependency
 *              between two cache entries.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent,
    const H5C_cache_entry_t *child, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(parent);
    HDassert(child);
    if(cache->log_info->cls->write_destroy_fd_log_msg)
        if(cache->log_info->cls->write_destroy_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific destroy fd call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_destroy_fd_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_unprotect_entry_msg
 *
 * Purpose:     Write a log message for unprotecting a cache entry.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_unprotect_entry_msg(H5C_t *cache, haddr_t address,
    int type_id, unsigned flags, herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    if(cache->log_info->cls->write_unprotect_entry_log_msg)
        if(cache->log_info->cls->write_unprotect_entry_log_msg(cache->log_info->udata, address, type_id, flags, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unprotect entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_unprotect_entry_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_set_cache_config_msg
 *
 * Purpose:     Write a log message for setting the cache configuration.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config,
    herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(config);
    if(cache->log_info->cls->write_set_cache_config_log_msg)
        if(cache->log_info->cls->write_set_cache_config_log_msg(cache->log_info->udata, config, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific set cache config call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_set_cache_config_msg() */

/*-------------------------------------------------------------------------
 * Function:    H5C_log_write_remove_entry_msg
 *
 * Purpose:     Write a log message for removing a cache entry.
 *
 * Return:      SUCCEED/FAIL
 *
 * Programmer:  Dana Robinson
 *              Fall 2018
 *
 *-------------------------------------------------------------------------
 */
herr_t
H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry,
    herr_t fxn_ret_value)
{
    herr_t ret_value = SUCCEED;

    FUNC_ENTER_NOAPI(FAIL)

    /* Sanity checks */
    HDassert(cache);

    /* Write a log message */
    HDassert(entry);
    if(cache->log_info->cls->write_remove_entry_log_msg)
        if(cache->log_info->cls->write_remove_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0)
            HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific remove entry call failed")

done:
    FUNC_LEAVE_NOAPI(ret_value)
} /* H5C_log_write_remove_entry_msg() */


text:
// <copyright file="SalesTaxCalculationService.cs" company="Automate The Planet Ltd.">
// Copyright 2021 Automate The Planet Ltd.
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
// <author>Anton Angelov</author>
// <site>http://automatetheplanet.com/</site>

using AdvancedStrategyDesignPattern.Enums;

namespace AdvancedStrategyDesignPattern.Services
{
    public class SalesTaxCalculationService
    {
        public decimal Calculate(decimal price, States state, string zip)
        {
            var taxPrice = default(decimal);

            // Call Real Web Service to determine the Sales Tax.
            switch (state)
            {
                case States.Arizona:
                    taxPrice = CalculateTaxPriceInternal(price, 7.125, zip);
                    break;
                case States.Illinois:
                    taxPrice = CalculateTaxPriceInternal(price, 3.75, zip);
                    break;
                case States.Massachusetts:
                    taxPrice = CalculateTaxPriceInternal(price, 6.25, zip);
                    break;
                case States.California:
                    taxPrice = CalculateTaxPriceInternal(price, 2.50, zip);
                    break;
                case States.Washington:
                    taxPrice = CalculateTaxPriceInternal(price, 3.10, zip);
                    break;
                case States.NewJersey:
                    taxPrice = CalculateTaxPriceInternal(price, 7.00, zip);
                    break;
                case States.Texas:
                    taxPrice = CalculateTaxPriceInternal(price, 8.15, zip);
                    break;
                default:
                    taxPrice = 0;
                    break;
            }

            return taxPrice;
        }

        private static decimal CalculateTaxPriceInternal(decimal price, double percent, string zip)
        {
            var taxPrice = price / (decimal)percent;
            return taxPrice;
        }
    }
}


text:
#ifndef _JIMI_MTL_SCOPED_LOCK_H_
#define _JIMI_MTL_SCOPED_LOCK_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#include "jimi/basic/stddef.h"
#include "jimi/internal/NonCopyable.h"
#include "jimi/log/log.h"

namespace jimi {

NS_JIMI_MT_BEGIN

template<class T>
class JIMI_DLL scoped_lock : public internal::NonCopyable
{
public:
    //! Construct lock that has not acquired a mutex.
    scoped_lock() : _pmutex(NULL) {};

    //! Acquire lock on given mutex.
    scoped_lock(T & mutex) /* : _pmutex(NULL) */ {
        acquire_init(mutex);
    }

    //! Release lock (if lock is held).
    ~scoped_lock() {
        release();
    }

    T * get_mutex() { return _pmutex; }
    void set_mutex(T * pmutex) { _pmutex = pmutex; }

    // ISO C++0x compatibility methods

    //! Acquire lock on given mutex(use in constructor only).
    void acquire_init(T & mutex) {
#if JIMI_USE_ASSERT
        internal_acquire(mutex);
#else
        mutex.lock();
        _pmutex = &mutex;
#endif /* JIMI_USE_ASSERT */
    }

    //! Acquire lock on given mutex.
    void acquire(T & mutex) {
#if JIMI_USE_ASSERT
        internal_acquire(mutex);
#else
        T* pmutex_new = &mutex;
        if (_pmutex && (_pmutex != pmutex_new))
            _pmutex->unlock();
        mutex.lock();
        _pmutex = pmutex_new;
#endif /* JIMI_USE_ASSERT */
    }

    //! Try acquire lock on given mutex.
    bool try_acquire(T & mutex, unsigned int spin_count = 0) {
#if JIMI_USE_ASSERT
        return internal_try_acquire(mutex);
#else
        bool result = mutex.try_lock(spin_count);
        if (result)
            _pmutex = &mutex;
        return result;
#endif /* JIMI_USE_ASSERT */
    }

    //! Acquire lock on given mutex(use in constructor only).
    bool has_acquired() {
#if JIMI_USE_ASSERT
        return internal_has_acquired();
#else
        if (_pmutex)
            return _pmutex->locked();
        else
            return false;
#endif /* JIMI_USE_ASSERT */
    }

    //! Release lock
    void release() {
#if JIMI_USE_ASSERT
        if (_pmutex)
            internal_release(*_pmutex);
#else
        if (_pmutex) {
            _pmutex->unlock();
            _pmutex = NULL;
        }
#endif /* JIMI_USE_ASSERT */
    }

public:

#if JIMI_USE_ASSERT
    //! All checks from acquire using mutex.state were moved here
    void JIMI_EXPORTED_METHOD internal_acquire(T & mutex)
    {
        //
    }

    //! All checks from try_acquire using mutex.state were moved here
    bool JIMI_EXPORTED_METHOD internal_try_acquire(T & mutex, unsigned int spin_count = 0)
    {
        return true;
    }

    //! The metux lock has acquired?
    bool JIMI_EXPORTED_METHOD internal_has_acquired()
    {
        if (_pmutex)
            return _pmutex->locked();
        else
            return false;
    }

    //! All checks from release using mutex.state were moved here
    void JIMI_EXPORTED_METHOD internal_release(T & mutex)
    {
        //
    }

#endif  /* JIMI_USE_ASSERT */

    //! The pointer to the current mutex to work
    T * _pmutex;
};

NS_JIMI_MT_END

}  /* namespace jimi */

#endif  /* _JIMI_MTL_SCOPED_LOCK_H_ */