text:
from setuptools import setup, Extension
import os
import pwd
import grp
from myDevices import __version__
from myDevices.system.hardware import Hardware

classifiers = ['Development Status :: 5 - Production/Stable',
               'Operating System :: POSIX :: Linux',
               'License :: OSI Approved :: MIT License',
               'Intended Audience :: Developers',
               'Programming Language :: Python :: 3',
               'Topic :: Software Development',
               'Topic :: Home Automation',
               'Topic :: System :: Hardware',
               'Topic :: System :: Monitoring']

try:
    # Try to install under the cayenne user, if it exists.
    username = 'cayenne'
    user = pwd.getpwnam(username)
    user_id = user.pw_uid
    group_id = user.pw_gid
except KeyError:
    # Otherwise install under the user that ran sudo.
    user_id = int(os.environ['SUDO_UID'])
    group_id = int(os.environ['SUDO_GID'])
    username = pwd.getpwuid(user_id).pw_name
directories = ('/etc/myDevices', '/etc/myDevices/scripts', '/etc/myDevices/plugins', '/var/log/myDevices', '/var/run/myDevices')
for directory in directories:
    try:
        os.makedirs(directory)
    except FileExistsError:
        pass
    os.chown(directory, user_id, group_id)

# Touch config file so it overwrites older versions
os.utime('scripts/config.sh', None)

setup(name             = 'myDevices',
      version          = __version__,
      author           = 'myDevices',
      author_email     = 'N/A',
      description      = 'myDevices Cayenne agent',
      long_description = 'N/A',
      license          = 'N/A',
      keywords         = 'myDevices Cayenne IoT',
      url              = 'https://www.mydevices.com/',
      classifiers      = classifiers,
      packages         = ["myDevices", "myDevices.cloud", "myDevices.utils", "myDevices.system", "myDevices.sensors" , "myDevices.schedule", "myDevices.requests_futures", "myDevices.devices", "myDevices.devices.analog", "myDevices.devices.digital", "myDevices.devices.sensor", "myDevices.decorators", "myDevices.plugins"],
      install_requires = ['enum34', 'netifaces >= 0.10.5', 'psutil >= 0.7.0', 'requests', 'paho-mqtt'],
      data_files       = [('/etc/myDevices/scripts', ['scripts/config.sh'])]
      )

os.chmod('/etc/myDevices/scripts/config.sh', 0o0755)

# Add conf file to create /var/run/myDevices at boot
with open('/usr/lib/tmpfiles.d/cayenne.conf', 'w') as tmpfile:
    tmpfile.write('d /run/myDevices 0744 {0} {0} -\n'.format(username))

relogin = False
# Add user to the i2c group if it isn't already a member
user_groups = [g.gr_name for g in grp.getgrall() if username in g.gr_mem]
if not 'i2c' in user_groups:
    os.system('adduser {} i2c'.format(username))
    relogin = True

if Hardware().isTinkerBoard():
    # Add spi group if it doesn't exist
    all_groups = [g.gr_name for g in grp.getgrall()]
    if not 'spi' in all_groups:
        os.system('groupadd -f -f spi')
        os.system('adduser {} spi'.format(username))
        with open('/etc/udev/rules.d/99-com.rules', 'w') as spirules:
            spirules.write('SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"\n')
        os.system('udevadm control --reload-rules && udevadm trigger')
        relogin = True
    # Install GPIO library if it doesn't exist
    try:
        import ASUS.GPIO
    except:
        current_dir = os.getcwd()
        try:
            TEMP_FOLDER = '/tmp/GPIO_API_for_Python'
            GPIO_API_ZIP = TEMP_FOLDER + '.zip'
            import urllib.request
            print('Downloading ASUS.GPIO library')
            urllib.request.urlretrieve('http://dlcdnet.asus.com/pub/ASUS/mb/Linux/Tinker_Board_2GB/GPIO_API_for_Python.zip', GPIO_API_ZIP)
            import zipfile
            with zipfile.ZipFile(GPIO_API_ZIP, 'r') as lib_zip:
                lib_zip.extractall(TEMP_FOLDER)
                os.chdir(TEMP_FOLDER)
                import distutils.core
                print('Installing ASUS.GPIO library')
                distutils.core.run_setup(TEMP_FOLDER + '/setup.py', ['install'])
        except Exception as ex:
            print('Error installing ASUS.GPIO library: {}'.format(ex))
        finally:
            os.chdir(current_dir)

if relogin:
    print('\nYou may need to re-login in order to use I2C or SPI devices')


text:
define(['react', 'draggable'], function (React, Draggable) {
  'use strict';

  var d = React.DOM;

  var TableHeader = React.createClass({
    displayName: 'TableHeader',

    getDefaultProps: function () {
      // allow the initial position to be passed in as a prop
      return {
        changePostion: function () {},
        onDragEnd: function () {}
      };
    },

    getInitialState: function () {
      return {pathName: [], dragging: false};
    },

    render: function () {
      var moveBtnClasses = 'btn btn-xs btn-default';
      return d.th({},
        d.input({
          type: 'checkbox',
          onChange: this.toggleDisabled,
          checked: !this.props.disabled
        }),
        d.div(
          {className: 'pull-right btn-group'},
          d.button({
            className: moveBtnClasses,
            title: 'Move column left',
            disabled: this.props.isFirst,
            onClick: this.changePostion.bind(this, -1)
          }, d.i({className: 'fa fa-angle-left'})),
          d.button({
            className: moveBtnClasses,
            title: 'Move column right',
            disabled: this.props.isLast,
            onClick: this.changePostion.bind(this, +1)
          }, d.i({className: 'fa fa-angle-right'}))),
        ' ',
        d.span({
          className: 'text-muted',
          style: {
            position: 'absolute',
            display: this.state.dragging ? 'inline-block' : 'none'
          }
        }, this.renderPathName()),
        Draggable(
          {
            style: {display: 'inline-block'},
            onDragStart: this.onDragStart,
            draggableBy: {x: true, y: false},
            onDragEnd: this.onDragEnd
          },
          d.span(
            {
              key: 'pathName',
              className: (this.props.disabled || !this.props.columnHeaders)
                          ? 'text-muted' : null},
            this.renderPathName())
        )
        );
    },

    renderPathName: function () {
      return this.state.pathName;
    },

    changePostion: function (delta) {
      this.props.changePostion(delta);
    },

    onDragStart: function () {
      this.setState({dragging: true});
    },

    onDragEnd: function (pos) {
      this.setState({dragging: false});
      this.props.onDragEnd(pos);
    },

    componentWillMount: function () {
      this.computeState(this.props);
    },

    componentWillReceiveProps: function (props) {
      this.computeState(props);
    },

    computeState: function (props) {
      var that = this;
      props.path.getDisplayName().then(function (name) {
        that.setState({pathName: name});
      });
    },

    toggleDisabled: function () {
      this.props.setDisabled(!this.props.disabled);
    }
  });

  return TableHeader;

});

redpajama_set_name: RedPajamaGithub


text:
package security

import be.objectify.deadbolt.scala.DeadboltExecutionContextProvider

import scala.concurrent.ExecutionContext

/**
 * A custom execution context can be provided to Deadbolt for asynchronous operations.
 *
 * @author Steve Chaloner (steve@objectify.be)
 */
class CustomDeadboltExecutionContextProvider extends DeadboltExecutionContextProvider {
  override def get(): ExecutionContext = scala.concurrent.ExecutionContext.global
}


text:
<?php
namespace Community\Model;

class Core {
	/**
	 * @return \Community\Model\Table\CommunitiesTable
	 */
	public static function getCommunitiesTable(){
		return getTableModel('Communities', 'Community\Model\Table\CommunitiesTable');
	}
	/**
	 * @return \Community\Model\Table\CommunityMembersTable
	 */
	public static function getCommunityMembersTable(){
		return getTableModel('CommunityMembers', 'Community\Model\Table\CommunityMembersTable');
	}
	/**
	 * @return \Community\Model\Table\CommunityThreadsTable
	 */
	public static function getCommunityThreadsTable(){
		return getTableModel('CommunityThreads', 'Community\Model\Table\CommunityThreadsTable');
	}

}


text:
package ibm

import (
	"fmt"
	"os"

	"github.com/GoogleCloudPlatform/terraformer/terraformutils"
	"github.com/IBM/go-sdk-core/v4/core"
	"github.com/IBM/vpc-go-sdk/vpcv1"
)

// SubnetGenerator ...
type SubnetGenerator struct {
	IBMService
}

func (g SubnetGenerator) createSubnetResources(subnetID, subnetName string) terraformutils.Resource {
	resource := terraformutils.NewResource(
		subnetID,
		normalizeResourceName(subnetName, true),
		"ibm_is_subnet",
		"ibm",
		map[string]string{},
		[]string{},
		map[string]interface{}{})

	resource.IgnoreKeys = append(resource.IgnoreKeys,
		"^total_ipv4_address_count$",
	)
	return resource
}

// InitResources ...
func (g *SubnetGenerator) InitResources() error {
	region := g.Args["region"].(string)
	apiKey := os.Getenv("IC_API_KEY")
	if apiKey == "" {
		return fmt.Errorf("No API key set")
	}

	isURL := GetVPCEndPoint(region)
	iamURL := GetAuthEndPoint()
	vpcoptions := &vpcv1.VpcV1Options{
		URL: isURL,
		Authenticator: &core.IamAuthenticator{
			ApiKey: apiKey,
			URL:    iamURL,
		},
	}
	vpcclient, err := vpcv1.NewVpcV1(vpcoptions)
	if err != nil {
		return err
	}
	start := ""
	var allrecs []vpcv1.VPC
	for {
		listVpcsOptions := &vpcv1.ListVpcsOptions{}
		if start != "" {
			listVpcsOptions.Start = &start
		}
		if rg := g.Args["resource_group"].(string); rg != "" {
			rg, err = GetResourceGroupID(apiKey, rg, region)
			if err != nil {
				return fmt.Errorf("Error Fetching Resource Group Id %s", err)
			}
			listVpcsOptions.ResourceGroupID = &rg
		}
		vpcs, response, err := vpcclient.ListVpcs(listVpcsOptions)
		if err != nil {
			return fmt.Errorf("Error Fetching vpcs %s\n%s", err, response)
		}
		start = GetNext(vpcs.Next)
		allrecs = append(allrecs, vpcs.Vpcs...)
		if start == "" {
			break
		}
	}

	for _, vpc := range allrecs {
		start = ""
		var allSubNetRecs []vpcv1.Subnet
		for {
			options := &vpcv1.ListSubnetsOptions{}
			if start != "" {
				options.Start = &start
			}

			subnets, response, err := vpcclient.ListSubnets(options)
			if err != nil {
				return fmt.Errorf("Error Fetching subnets %s\n%s", err, response)
			}
			start = GetNext(subnets.Next)
			allSubNetRecs = append(allSubNetRecs, subnets.Subnets...)
			if start == "" {
				break
			}
		}

		for _, subnet := range allSubNetRecs {
			if *vpc.ID == *subnet.VPC.ID {
				g.Resources = append(g.Resources, g.createSubnetResources(*subnet.ID, *subnet.Name))
			}
		}
	}

	return nil
}


text: This Flask-based application is a web app for a personal cloud service or remote fileserver.


text:
/**
 * PropertyArray is a particular flavour of AxiomArray for when "of" is
 * Property.
 */
foam.CLASS({
  package: 'foam.core.property',
  name: 'PropertyArray',
  extends: 'foam.core.property.AxiomArray',

  properties: [
    ['of', 'Property'],
    {
      /**
       * Specialized adaptArrayElement that handles the many flavours of
       * defining a Property.
       */
      name: 'adaptArrayElement',
      value: function(o) {
        /*
          Properties can be defined using three formats:
          1. Short-form String:  'firstName' or 'sex'

          2. Medium-form Array:  ['firstName', 'John'] or ['sex', 'Male']
             The first element of the array is the name and the second is the
             default value.

          3. Long-form JSON:     {class: 'String', name: 'sex', value: 'Male'}
             The long-form will support many options, but only 'name' is
             mandatory.
         */
        if ( foam.String.isInstance(o) ) {
          var p = foam.core.Property.create();
          p.name = o;
          return p;
        }

        if ( foam.Array.isInstance(o) ) {
          // TODO(adamvy): Ensure that name is typechecked and validated
          // when model validation becomes a thing.
          var p = foam.core.Property.create();
          p.name  = o[0];
          p.value = o[1];
          return p;
        }

        if ( o.class ) {
          var m = foam.lookup(o.class);
          return m.create(o);
        }

        return foam.core.Property.isInstance(o) ?
          o : foam.core.Property.create(o);
      }
    }
  ]
});


text:
import { GraphQLObjectType, GraphQLString, GraphQLInt } from 'graphql';

const AdminType = new GraphQLObjectType({
  name: 'Admin',
  fields: {
    id: { type: GraphQLInt },
    username: { type: GraphQLString },
  }
});

export default AdminType;


text:
package proguard.classfile.editor;

import proguard.classfile.*;
import proguard.classfile.attribute.*;
import proguard.classfile.attribute.annotation.*;
import proguard.classfile.attribute.annotation.target.*;
import proguard.classfile.attribute.annotation.target.visitor.*;
import proguard.classfile.attribute.annotation.visitor.TypeAnnotationVisitor;
import proguard.classfile.attribute.preverification.*;
import proguard.classfile.attribute.preverification.visitor.*;
import proguard.classfile.attribute.visitor.*;
import proguard.classfile.instruction.*;
import proguard.classfile.instruction.visitor.InstructionVisitor;
import proguard.classfile.util.SimplifiedVisitor;
import proguard.util.ArrayUtil;

import java.util.*;

/**
 * This AttributeVisitor accumulates specified changes to code, and then applies
 * these accumulated changes to the code attributes that it visits.
 *
 * The class also supports labels ({@link #label()}) and exception handlers
 * ({@link #catch_(int,int,int)}) in replacement sequences. They provide
 * local branch offsets inside the replacement sequences
 * ({@link Label#offset()}). For example, creating a replacement sequence
 * with the help of {@link InstructionSequenceBuilder}:
 * <code>
 *     final CodeAttributeEditor.Label TRY_START = codeAttributeEditor.label();
 *     final CodeAttributeEditor.Label TRY_END   = codeAttributeEditor.label();
 *     final CodeAttributeEditor.Label CATCH_END = codeAttributeEditor.label();
 *
 *     final CodeAttributeEditor.Label CATCH_EXCEPTION =
 *         codeAttributeEditor.catch_(TRY_START.offset(),
 *                                    TRY_END.offset(),
 *                                    constantPoolEditor.addClassConstant("java/lang/Exception", null));
 *
 *     Instructions[] replacementInstructions = builder
 *         .label(TRY_START)
 *         ......
 *         .label(TRY_END)
 *         .goto_(CATCH_END.offset())
 *         .catch_(CATCH_EXCEPTION)
 *         ......
 *         .athrow()
 *         .label(CATCH_END)
 *         ......
 *         .instructions();
 * </code>
 *
 * @author Eric Lafortune
 */
public class CodeAttributeEditor
extends      SimplifiedVisitor
implements   AttributeVisitor,
             InstructionVisitor,
             ExceptionInfoVisitor,
             StackMapFrameVisitor,
             VerificationTypeVisitor,
             LineNumberInfoVisitor,
             LocalVariableInfoVisitor,
             LocalVariableTypeInfoVisitor,
             TypeAnnotationVisitor,
             TargetInfoVisitor,
             LocalVariableTargetElementVisitor
{
    //*
    private static final boolean DEBUG = false;
    /*/
    public  static       boolean DEBUG = System.getProperty("cae") != null;
    //*/

    private static final int LABEL_FLAG = 0x20000000;

    private final boolean updateFrameSizes;
    private final boolean shrinkInstructions;

    private int     codeLength;
    private boolean modified;
    private boolean simple;

    private Map labels = new HashMap();

    /*private*/public Instruction[]    preOffsetInsertions = new Instruction[ClassConstants.TYPICAL_CODE_LENGTH];
    /*private*/public Instruction[]    preInsertions       = new Instruction[ClassConstants.TYPICAL_CODE_LENGTH];
    /*private*/public Instruction[]    replacements        = new Instruction[ClassConstants.TYPICAL_CODE_LENGTH];
    /*private*/public Instruction[]    postInsertions      = new Instruction[ClassConstants.TYPICAL_CODE_LENGTH];
    /*private*/public boolean[]        deleted             = new boolean[ClassConstants.TYPICAL_CODE_LENGTH];

    private int[]   newInstructionOffsets = new int[ClassConstants.TYPICAL_CODE_LENGTH];
    private int     newOffset;
    private boolean lengthIncreased;

    private int expectedStackMapFrameOffset;

    private final StackSizeUpdater    stackSizeUpdater    = new StackSizeUpdater();
    private final VariableSizeUpdater variableSizeUpdater = new VariableSizeUpdater();
    private final InstructionWriter   instructionWriter   = new InstructionWriter();

    /**
     * Creates a new CodeAttributeEditor that automatically updates frame
     * sizes and shrinks instructions.
     */
    public CodeAttributeEditor()
    {
        this(true, true);
    }

    /**
     * Creates a new CodeAttributeEditor.
     * @param updateFrameSizes   specifies whether frame sizes of edited code
     *                           should be updated.
     * @param shrinkInstructions specifies whether added instructions should
     *                           automatically be shrunk before being written.
     */
    public CodeAttributeEditor(boolean updateFrameSizes,
                               boolean shrinkInstructions)
    {
        this.updateFrameSizes   = updateFrameSizes;
        this.shrinkInstructions = shrinkInstructions;
    }

    /**
     * Resets the accumulated code changes for a given anticipated maximum
     * code length. If necessary, the size may still be extended while
     * editing the code, with {@link #extend(int)}.
     * @param codeLength the length of the code that will be edited next.
     */
    public void reset(int codeLength)
    {
        labels.clear();

        // Try to reuse the previous arrays.
        if (preInsertions.length < codeLength)
        {
            preOffsetInsertions = new Instruction[codeLength];
            preInsertions       = new Instruction[codeLength];
            replacements        = new Instruction[codeLength];
            postInsertions      = new Instruction[codeLength];
            deleted             = new boolean[codeLength];
        }
        else
        {
            Arrays.fill(preOffsetInsertions, 0, codeLength, null);
            Arrays.fill(preInsertions,       0, codeLength, null);
            Arrays.fill(replacements,        0, codeLength, null);
            Arrays.fill(postInsertions,      0, codeLength, null);
            Arrays.fill(deleted,             0, codeLength, false);
        }

        this.codeLength = codeLength;

        modified = false;
        simple   = true;
    }

    /**
     * Extends the size of the accumulated code changes.
     * @param codeLength the length of the code that will be edited next.
     */
    public void extend(int codeLength)
    {
        // Try to reuse the previous arrays.
        if (preInsertions.length < codeLength)
        {
            preOffsetInsertions = ArrayUtil.extendArray(preOffsetInsertions, codeLength);
            preInsertions       = ArrayUtil.extendArray(preInsertions,       codeLength);
            replacements        = ArrayUtil.extendArray(replacements,        codeLength);
            postInsertions      = ArrayUtil.extendArray(postInsertions,      codeLength);
            deleted             = ArrayUtil.extendArray(deleted,             codeLength);
        }
        else
        {
            Arrays.fill(preOffsetInsertions, this.codeLength, codeLength, null);
            Arrays.fill(preInsertions,       this.codeLength, codeLength, null);
            Arrays.fill(replacements,        this.codeLength, codeLength, null);
            Arrays.fill(postInsertions,      this.codeLength, codeLength, null);
            Arrays.fill(deleted,             this.codeLength, codeLength, false);
        }

        this.codeLength = codeLength;
    }

    /**
     * Remembers to place the given instruction right before the instruction
     * at the given offset. Any branches to the existing instruction will
     * land after the new instruction. Similarly, any try blocks that start at
     * the existing instruction will not include the new instruction. However,
     * any try blocks that end right before the existing instruction wil now
     * include the new instruction.
     * @param instructionOffset the offset of the instruction.
     * @param instruction       the new instruction.
     */
    public void insertBeforeOffset(int instructionOffset, Instruction instruction)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        preOffsetInsertions[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
        simple   = false;
    }

    /**
     * Remembers to place the given instruction right before the instruction
     * at the given offset. Any branches to the existing instruction will
     * also go to the new instruction. Similarly, any try blocks that include
     * the existing instruction will also include the new instruction.
     * @param instructionOffset the offset of the instruction.
     * @param instruction       the new instruction.
     */
    public void insertBeforeInstruction(int instructionOffset, Instruction instruction)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        preInsertions[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
        simple   = false;
    }

    /**
     * Remembers to place the given instructions right before the instruction
     * at the given offset. Any branches to the existing instruction will
     * land after the new instructions. Similarly, any try blocks that start at
     * the existing instruction will not include the new instructions. However,
     * any try blocks that end right before the existing instruction wil now
     * include the new instructions.
     * @param instructionOffset the offset of the instruction.
     * @param instructions      the new instructions.
     */
    public void insertBeforeOffset(int instructionOffset, Instruction[] instructions)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        CompositeInstruction instruction =
            new CompositeInstruction(instructions);

        preOffsetInsertions[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
        simple   = false;
    }

    /**
     * Remembers to place the given instructions right before the instruction
     * at the given offset. Any branches to the existing instruction will
     * also go to the new instructions. Similarly, any try blocks that include
     * the existing instruction will also include the new instructions.
     * @param instructionOffset the offset of the instruction.
     * @param instructions      the new instructions.
     */
    public void insertBeforeInstruction(int instructionOffset, Instruction[] instructions)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        CompositeInstruction instruction =
            new CompositeInstruction(instructions);

        preInsertions[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
        simple   = false;
    }

    /**
     * Remembers to replace the instruction at the given offset by the given
     * instruction.
     * @param instructionOffset the offset of the instruction to be replaced.
     * @param instruction       the new instruction.
     */
    public void replaceInstruction(int instructionOffset, Instruction instruction)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        replacements[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
    }

    /**
     * Remembers to replace the instruction at the given offset by the given
     * instructions.
     * @param instructionOffset the offset of the instruction to be replaced.
     * @param instructions      the new instructions.
     */
    public void replaceInstruction(int instructionOffset, Instruction[] instructions)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        CompositeInstruction instruction =
            new CompositeInstruction(instructions);

        replacements[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
    }

    /**
     * Remembers to place the given instruction right after the instruction
     * at the given offset.
     * @param instructionOffset the offset of the instruction.
     * @param instruction       the new instruction.
     */
    public void insertAfterInstruction(int instructionOffset, Instruction instruction)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        postInsertions[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
        simple   = false;
    }

    /**
     * Remembers to place the given instructions right after the instruction
     * at the given offset.
     * @param instructionOffset the offset of the instruction.
     * @param instructions      the new instructions.
     */
    public void insertAfterInstruction(int instructionOffset, Instruction[] instructions)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        CompositeInstruction instruction =
            new CompositeInstruction(instructions);

        postInsertions[instructionOffset] = shrinkInstructions ?
            instruction.shrink() :
            instruction;

        modified = true;
        simple   = false;
    }

    /**
     * Remembers to delete the instruction at the given offset.
     * @param instructionOffset the offset of the instruction to be deleted.
     */
    public void deleteInstruction(int instructionOffset)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        deleted[instructionOffset] = true;

        modified = true;
        simple   = false;
    }

    /**
     * Remembers not to delete the instruction at the given offset.
     * @param instructionOffset the offset of the instruction not to be deleted.
     */
    public void undeleteInstruction(int instructionOffset)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        deleted[instructionOffset] = false;
    }

    /**
     * Clears all modifications of the instruction at the given offset.
     * @param instructionOffset the offset of the instruction to be deleted.
     */
    public void clearModifications(int instructionOffset)
    {
        if (instructionOffset < 0 ||
            instructionOffset >= codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+instructionOffset+"] in code with length ["+codeLength+"]");
        }

        preOffsetInsertions[instructionOffset] = null;
        preInsertions[instructionOffset]       = null;
        replacements[instructionOffset]        = null;
        postInsertions[instructionOffset]      = null;
        deleted[instructionOffset]             = false;
    }

    /**
     * Returns whether the code has been modified in any way.
     */
    public boolean isModified()
    {
        return modified;
    }

    /**
     * Returns whether the instruction at the given offset has been modified
     * in any way.
     */
    public boolean isModified(int instructionOffset)
    {
        return preOffsetInsertions[instructionOffset] != null ||
               preInsertions[instructionOffset]       != null ||
               replacements[instructionOffset]        != null ||
               postInsertions[instructionOffset]      != null ||
               deleted[instructionOffset];
    }

    // Implementations for AttributeVisitor.

    public void visitAnyAttribute(Clazz clazz, Attribute attribute) {}

    public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
    {
//        DEBUG =
//            clazz.getName().equals("abc/Def") &&
//            method.getName(clazz).equals("abc");

        // TODO: Remove this when the code has stabilized.
        // Catch any unexpected exceptions from the actual visiting method.
        try
        {
            // Process the code.
            visitCodeAttribute0(clazz, method, codeAttribute);
        }
        catch (RuntimeException ex)
        {
            System.err.println("Unexpected error while editing code:");
            System.err.println("  Class       = ["+clazz.getName()+"]");
            System.err.println("  Method      = ["+method.getName(clazz)+method.getDescriptor(clazz)+"]");
            System.err.println("  Exception   = ["+ex.getClass().getName()+"] ("+ex.getMessage()+")");

            throw ex;
        }
    }

    public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute)
    {
        // Do we have to update the code?
        if (modified)
        {
            if (DEBUG)
            {
                System.out.println("CodeAttributeEditor: "+clazz.getName()+"."+method.getName(clazz)+method.getDescriptor(clazz));
            }

            // Can we perform a faster simple replacement of instructions?
            if (canPerformSimpleReplacements(codeAttribute))
            {
                if (DEBUG)
                {
                    System.out.println("  Simple editing");
                }

                // Simply overwrite the instructions.
                performSimpleReplacements(codeAttribute);
            }
            else
            {
                if (DEBUG)
                {
                    System.out.println("  Full editing");
                }

                // Move and remap the instructions.
                codeAttribute.u4codeLength =
                    updateInstructions(clazz, method, codeAttribute);

                // Update the exception table.
                codeAttribute.exceptionsAccept(clazz, method, this);

                // Remove exceptions with empty code blocks.
                codeAttribute.u2exceptionTableLength =
                    removeEmptyExceptions(codeAttribute.exceptionTable,
                                          codeAttribute.u2exceptionTableLength);

                // Update the line number table and the local variable tables.
                codeAttribute.attributesAccept(clazz, method, this);
            }

            // Make sure instructions are widened if necessary.
            instructionWriter.visitCodeAttribute(clazz, method, codeAttribute);
        }

        // Update the maximum stack size and local variable frame size.
        if (updateFrameSizes)
        {
            stackSizeUpdater.visitCodeAttribute(clazz, method, codeAttribute);
            variableSizeUpdater.visitCodeAttribute(clazz, method, codeAttribute);
        }
    }

    public void visitStackMapAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapAttribute stackMapAttribute)
    {
        // Update all stack map entries.
        expectedStackMapFrameOffset = -1;
        stackMapAttribute.stackMapFramesAccept(clazz, method, codeAttribute, this);
    }

    public void visitStackMapTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, StackMapTableAttribute stackMapTableAttribute)
    {
        // Update all stack map table entries.
        expectedStackMapFrameOffset = 0;
        stackMapTableAttribute.stackMapFramesAccept(clazz, method, codeAttribute, this);
    }

    public void visitLineNumberTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberTableAttribute lineNumberTableAttribute)
    {
        // Update all line number table entries.
        lineNumberTableAttribute.lineNumbersAccept(clazz, method, codeAttribute, this);

        // Remove line numbers with empty code blocks.
//        lineNumberTableAttribute.u2lineNumberTableLength =
//           removeEmptyLineNumbers(lineNumberTableAttribute.lineNumberTable,
//                                  lineNumberTableAttribute.u2lineNumberTableLength,
//                                  codeAttribute.u4codeLength);
    }

    public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute)
    {
        // Update all local variable table entries.
        localVariableTableAttribute.localVariablesAccept(clazz, method, codeAttribute, this);
    }

    public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute)
    {
        // Update all local variable table entries.
        localVariableTypeTableAttribute.localVariablesAccept(clazz, method, codeAttribute, this);
    }

    public void visitAnyTypeAnnotationsAttribute(Clazz clazz, TypeAnnotationsAttribute typeAnnotationsAttribute)
    {
        typeAnnotationsAttribute.typeAnnotationsAccept(clazz, this);
    }

    /**
     * Checks if it is possible to modifies the given code without having to
     * update any offsets.
     * @param codeAttribute the code to be changed.
     * @return the new code length.
     */
    private boolean canPerformSimpleReplacements(CodeAttribute codeAttribute)
    {
        if (!simple)
        {
            return false;
        }

        byte[] code       = codeAttribute.code;
        int    codeLength = codeAttribute.u4codeLength;

        // Go over all replacement instructions.
        for (int offset = 0; offset < codeLength; offset++)
        {
            // Check if the replacement instruction, if any, has a different
            // length than the original instruction.
            Instruction replacementInstruction = replacements[offset];
            if (replacementInstruction != null &&
                replacementInstruction.length(offset) !=
                    InstructionFactory.create(code, offset).length(offset))
            {
                return false;
            }
        }

        return true;
    }

    /**
     * Modifies the given code without updating any offsets.
     * @param codeAttribute the code to be changed.
     */
    private void performSimpleReplacements(CodeAttribute codeAttribute)
    {
        int codeLength = codeAttribute.u4codeLength;

        // Go over all replacement instructions.
        for (int offset = 0; offset < codeLength; offset++)
        {
            // Overwrite the original instruction with the replacement
            // instruction if any.
            Instruction replacementInstruction = replacements[offset];
            if (replacementInstruction != null)
            {
                replacementInstruction.write(codeAttribute, offset);

                if (DEBUG)
                {
                    System.out.println("  Replaced "+replacementInstruction.toString(offset));
                }
            }
        }
    }

    /**
     * Modifies the given code based on the previously specified changes.
     * @param clazz         the class file of the code to be changed.
     * @param method        the method of the code to be changed.
     * @param codeAttribute the code to be changed.
     * @return the new code length.
     */
    private int updateInstructions(Clazz         clazz,
                                   Method        method,
                                   CodeAttribute codeAttribute)
    {
        byte[] oldCode   = codeAttribute.code;
        int    oldLength = codeAttribute.u4codeLength;

        // Make sure there is a sufficiently large instruction offset map.
        if (newInstructionOffsets.length < oldLength + 1)
        {
            newInstructionOffsets = new int[oldLength + 1];
        }

        // Fill out the instruction offset map.
        int newLength = mapInstructions(oldCode,
                                        oldLength);

        // Create a new code array if necessary.
        if (lengthIncreased)
        {
            codeAttribute.code = new byte[newLength];
        }

        // Prepare for possible widening of instructions.
        instructionWriter.reset(newLength);

        // Move the instructions into the new code array.
        moveInstructions(clazz,
                         method,
                         codeAttribute,
                         oldCode,
                         oldLength);

        // We can return the new length.
        return newLength;
    }

    /**
     * Fills out the instruction offset map for the given code block.
     * @param oldCode   the instructions to be moved.
     * @param oldLength the code length.
     * @return the new code length.
     */
    private int mapInstructions(byte[] oldCode, int oldLength)
    {
        // Start mapping instructions at the beginning.
        newOffset       = 0;
        lengthIncreased = false;

        int oldOffset = 0;
        do
        {
            // Get the next instruction.
            Instruction instruction = InstructionFactory.create(oldCode, oldOffset);

            // Compute the mapping of the instruction.
            mapInstruction(oldOffset, instruction);

            oldOffset += instruction.length(oldOffset);

            if (newOffset > oldOffset)
            {
                lengthIncreased = true;
            }
        }
        while (oldOffset < oldLength);

        // Also add an entry for the first offset after the code.
        newInstructionOffsets[oldOffset] = newOffset;

        return newOffset;
    }

    /**
     * Fills out the instruction offset map for the given instruction.
     * @param oldOffset   the instruction's old offset.
     * @param instruction the instruction to be moved.
     */
    private void mapInstruction(int         oldOffset,
                                Instruction instruction)
    {
        // Account for the pre-offset-inserted instruction, if any.
        Instruction preOffsetInstruction = preOffsetInsertions[oldOffset];
        if (preOffsetInstruction != null)
        {
            newOffset += preOffsetInstruction.length(newOffset);
        }

        newInstructionOffsets[oldOffset] = newOffset;

        // Account for the pre-inserted instruction, if any.
        Instruction preInstruction = preInsertions[oldOffset];
        if (preInstruction != null)
        {
            newOffset += preInstruction.length(newOffset);
        }

        // Account for the replacement instruction, or for the current
        // instruction, if it shouldn't be  deleted.
        Instruction replacementInstruction = replacements[oldOffset];
        if (replacementInstruction != null)
        {
            newOffset += replacementInstruction.length(newOffset);
        }
        else if (!deleted[oldOffset])
        {
            // Note that the instruction's length may change at its new offset,
            // e.g. if it is a switch instruction.
            newOffset += instruction.length(newOffset);
        }

        // Account for the post-inserted instruction, if any.
        Instruction postInstruction = postInsertions[oldOffset];
        if (postInstruction != null)
        {
            newOffset += postInstruction.length(newOffset);
        }
    }

    /**
     * Moves the given code block to the new offsets.
     * @param clazz         the class file of the code to be changed.
     * @param method        the method of the code to be changed.
     * @param codeAttribute the code to be changed.
     * @param oldCode       the original code to be moved.
     * @param oldLength     the original code length.
     */
    private void moveInstructions(Clazz         clazz,
                                  Method        method,
                                  CodeAttribute codeAttribute,
                                  byte[]        oldCode,
                                  int           oldLength)
    {
        // Start writing instructions at the beginning.
        newOffset = 0;

        int oldOffset = 0;
        do
        {
            // Get the next instruction.
            Instruction instruction = InstructionFactory.create(oldCode, oldOffset);

            // Move the instruction to its new offset.
            moveInstruction(clazz,
                            method,
                            codeAttribute,
                            oldOffset,
                            instruction);

            oldOffset += instruction.length(oldOffset);
        }
        while (oldOffset < oldLength);
    }

    /**
     * Moves the given instruction to its new offset.
     * @param clazz         the class file of the code to be changed.
     * @param method        the method of the code to be changed.
     * @param codeAttribute the code to be changed.
     * @param oldOffset     the original instruction offset.
     * @param instruction   the original instruction.
     */
    private void moveInstruction(Clazz         clazz,
                                 Method        method,
                                 CodeAttribute codeAttribute,
                                 int           oldOffset,
                                 Instruction   instruction)
    {
        // Update and insert the pre-inserted instruction, if any.
        Instruction preOffsetInstruction = preOffsetInsertions[oldOffset];
        if (preOffsetInstruction != null)
        {
            if (DEBUG)
            {
                System.out.println("  Pre-inserted  ["+oldOffset+"] -> "+preOffsetInstruction.toString(newOffset));
            }

            // Update the instruction.
            preOffsetInstruction.accept(clazz, method, codeAttribute, oldOffset, this);
        }

        // Update and insert the pre-inserted instruction, if any.
        Instruction preInstruction = preInsertions[oldOffset];
        if (preInstruction != null)
        {
            if (DEBUG)
            {
                System.out.println("  Pre-inserted  ["+oldOffset+"] -> "+preInstruction.toString(newOffset));
            }

            // Update the instruction.
            preInstruction.accept(clazz, method, codeAttribute, oldOffset, this);
        }

        // Update and insert the replacement instruction, or the current
        // instruction, if it shouldn't be deleted.
        Instruction replacementInstruction = replacements[oldOffset];
        if (replacementInstruction != null)
        {
            if (DEBUG)
            {
                System.out.println("  Replaced      ["+oldOffset+"] -> "+replacementInstruction.toString(newOffset));
            }

            // Update the instruction.
            replacementInstruction.accept(clazz, method, codeAttribute, oldOffset, this);
        }
        else if (!deleted[oldOffset])
        {
            if (DEBUG)
            {
                System.out.println("  Copied        ["+oldOffset+"] -> "+instruction.toString(newOffset));
            }

            // Update the instruction.
            instruction.accept(clazz, method, codeAttribute, oldOffset, this);
        }

        // Update and insert the post-inserted instruction, if any.
        Instruction postInstruction = postInsertions[oldOffset];
        if (postInstruction != null)
        {
            if (DEBUG)
            {
                System.out.println("  Post-inserted ["+oldOffset+"] -> "+postInstruction.toString(newOffset));
            }

            // Update the instruction.
            postInstruction.accept(clazz, method, codeAttribute, oldOffset, this);
        }
    }

    // Implementations for InstructionVisitor.

    public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
    {
        // Write out the instruction.
        instructionWriter.visitSimpleInstruction(clazz,
                                                 method,
                                                 codeAttribute,
                                                 newOffset,
                                                 simpleInstruction);

        newOffset += simpleInstruction.length(newOffset);
    }

    public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
    {
        // Write out the instruction.
        instructionWriter.visitConstantInstruction(clazz,
                                                   method,
                                                   codeAttribute,
                                                   newOffset,
                                                   constantInstruction);

        newOffset += constantInstruction.length(newOffset);
    }

    public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction)
    {
        // Write out the instruction.
        instructionWriter.visitVariableInstruction(clazz,
                                                   method,
                                                   codeAttribute,
                                                   newOffset,
                                                   variableInstruction);

        newOffset += variableInstruction.length(newOffset);
    }

    public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
    {
        // Update the branch offset, relative to the precise new offset.
        branchInstruction.branchOffset =
            newBranchOffset(offset, branchInstruction.branchOffset, newOffset);

        // Write out the instruction.
        instructionWriter.visitBranchInstruction(clazz,
                                                 method,
                                                 codeAttribute,
                                                 newOffset,
                                                 branchInstruction);

        newOffset += branchInstruction.length(newOffset);
    }

    public void visitTableSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, TableSwitchInstruction tableSwitchInstruction)
    {
        // Update the default jump offset, relative to the precise new offset.
        tableSwitchInstruction.defaultOffset =
            newBranchOffset(offset, tableSwitchInstruction.defaultOffset, newOffset);

        // Update the jump offsets, relative to the precise new offset.
        newJumpOffsets(offset,
                       tableSwitchInstruction.jumpOffsets,
                       newOffset);

        // Write out the instruction.
        instructionWriter.visitTableSwitchInstruction(clazz,
                                                      method,
                                                      codeAttribute,
                                                      newOffset,
                                                      tableSwitchInstruction);

        newOffset += tableSwitchInstruction.length(newOffset);
    }

    public void visitLookUpSwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, LookUpSwitchInstruction lookUpSwitchInstruction)
    {
        // Update the default jump offset, relative to the precise new offset.
        lookUpSwitchInstruction.defaultOffset =
            newBranchOffset(offset, lookUpSwitchInstruction.defaultOffset, newOffset);

        // Update the jump offsets, relative to the precise new offset.
        newJumpOffsets(offset,
                       lookUpSwitchInstruction.jumpOffsets,
                       newOffset);

        // Write out the instruction.
        instructionWriter.visitLookUpSwitchInstruction(clazz,
                                                       method,
                                                       codeAttribute,
                                                       newOffset,
                                                       lookUpSwitchInstruction);

        newOffset += lookUpSwitchInstruction.length(newOffset);
    }

    // Implementations for ExceptionInfoVisitor.

    public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
    {
        // Update the code offsets. Note that the instruction offset map also
        // has an entry for the first offset after the code, for u2endPC.
        exceptionInfo.u2startPC   = newInstructionOffset(exceptionInfo.u2startPC);
        exceptionInfo.u2endPC     = newInstructionOffset(exceptionInfo.u2endPC);
        exceptionInfo.u2handlerPC = newInstructionOffset(exceptionInfo.u2handlerPC);
    }

    // Implementations for StackMapFrameVisitor.

    public void visitAnyStackMapFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, StackMapFrame stackMapFrame)
    {
        // Update the stack map frame offset.
        int stackMapFrameOffset = newInstructionOffset(offset);

        int offsetDelta = stackMapFrameOffset;

        // Compute the offset delta if the frame is part of a stack map frame
        // table (for JDK 6.0) instead of a stack map (for Java Micro Edition).
        if (expectedStackMapFrameOffset >= 0)
        {
            offsetDelta -= expectedStackMapFrameOffset;

            expectedStackMapFrameOffset = stackMapFrameOffset + 1;
        }

        stackMapFrame.u2offsetDelta = offsetDelta;
    }

    public void visitSameOneFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SameOneFrame sameOneFrame)
    {
        // Update the stack map frame offset.
        visitAnyStackMapFrame(clazz, method, codeAttribute, offset, sameOneFrame);

        // Update the verification type offset.
        sameOneFrame.stackItemAccept(clazz, method, codeAttribute, offset, this);
    }

    public void visitMoreZeroFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, MoreZeroFrame moreZeroFrame)
    {
        // Update the stack map frame offset.
        visitAnyStackMapFrame(clazz, method, codeAttribute, offset, moreZeroFrame);

        // Update the verification type offsets.
        moreZeroFrame.additionalVariablesAccept(clazz, method, codeAttribute, offset, this);
    }

    public void visitFullFrame(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, FullFrame fullFrame)
    {
        // Update the stack map frame offset.
        visitAnyStackMapFrame(clazz, method, codeAttribute, offset, fullFrame);

        // Update the verification type offsets.
        fullFrame.variablesAccept(clazz, method, codeAttribute, offset, this);
        fullFrame.stackAccept(clazz, method, codeAttribute, offset, this);
    }

    // Implementations for VerificationTypeVisitor.

    public void visitAnyVerificationType(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VerificationType verificationType) {}

    public void visitUninitializedType(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, UninitializedType uninitializedType)
    {
        // Update the offset of the 'new' instruction.
        uninitializedType.u2newInstructionOffset = newInstructionOffset(uninitializedType.u2newInstructionOffset);
    }

    // Implementations for LineNumberInfoVisitor.

    public void visitLineNumberInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LineNumberInfo lineNumberInfo)
    {
        // Update the code offset.
        lineNumberInfo.u2startPC = newInstructionOffset(lineNumberInfo.u2startPC);
    }

    // Implementations for LocalVariableInfoVisitor.

    public void visitLocalVariableInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfo localVariableInfo)
    {
        // Update the code offset and length.
        // Be careful to update the length first.
        localVariableInfo.u2length  = newBranchOffset(localVariableInfo.u2startPC, localVariableInfo.u2length);
        localVariableInfo.u2startPC = newInstructionOffset(localVariableInfo.u2startPC);
    }

    // Implementations for LocalVariableTypeInfoVisitor.

    public void visitLocalVariableTypeInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfo localVariableTypeInfo)
    {
        // Update the code offset and length.
        // Be careful to update the length first.
        localVariableTypeInfo.u2length  = newBranchOffset(localVariableTypeInfo.u2startPC, localVariableTypeInfo.u2length);
        localVariableTypeInfo.u2startPC = newInstructionOffset(localVariableTypeInfo.u2startPC);
    }

    // Implementations for TypeAnnotationVisitor.

    public void visitTypeAnnotation(Clazz clazz, TypeAnnotation typeAnnotation)
    {
        // Update all local variable targets.
        typeAnnotation.targetInfoAccept(clazz, this);
    }

    // Implementations for TargetInfoVisitor.

    public void visitAnyTargetInfo(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfo targetInfo) {}

    public void visitLocalVariableTargetInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo)
    {
        // Update the offsets of the variables.
        localVariableTargetInfo.targetElementsAccept(clazz, method, codeAttribute, typeAnnotation, this);
    }

    public void visitOffsetTargetInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, OffsetTargetInfo offsetTargetInfo)
    {
        // Update the offset.
        offsetTargetInfo.u2offset = newInstructionOffset(offsetTargetInfo.u2offset);
    }

    // Implementations for LocalVariableTargetElementVisitor.

    public void visitLocalVariableTargetElement(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo, LocalVariableTargetElement localVariableTargetElement)
    {
        // Update the variable start offset and length.
        // Be careful to update the length first.
        localVariableTargetElement.u2length  = newBranchOffset(localVariableTargetElement.u2startPC, localVariableTargetElement.u2length);
        localVariableTargetElement.u2startPC = newInstructionOffset(localVariableTargetElement.u2startPC);
    }

    // Small utility methods.

    /**
     * Updates the given jump offsets for the instruction at the given offset,
     * relative to the given new offset.
     */
    private void newJumpOffsets(int   oldInstructionOffset,
                                int[] oldJumpOffsets,
                                int   newInstructionOffset)
    {
        for (int index = 0; index < oldJumpOffsets.length; index++)
        {
            oldJumpOffsets[index] = newBranchOffset(oldInstructionOffset,
                                                    oldJumpOffsets[index],
                                                    newInstructionOffset);
        }
    }

    /**
     * Computes the new branch offset for the instruction at the given offset
     * with the given branch offset, relative to the new instruction (block)
     * offset.
     */
    private int newBranchOffset(int oldInstructionOffset,
                                int oldBranchOffset)
    {
        return newInstructionOffset(oldInstructionOffset + oldBranchOffset) -
               newInstructionOffset(oldInstructionOffset);
    }

    /**
     * Computes the new branch offset for the instruction at the given offset
     * with the given branch offset, relative to the given new offset.
     */
    private int newBranchOffset(int oldInstructionOffset,
                                int oldBranchOffset,
                                int newInstructionOffset)
    {
        // Compute the old branch target.
        // Pass a label offset unchanged.
        int oldBranchTargetOffset = isLabel(oldBranchOffset) ? oldBranchOffset :
            oldInstructionOffset + oldBranchOffset;

        return newInstructionOffset(oldBranchTargetOffset) -
               newInstructionOffset;
    }

    /**
     * Computes the new instruction offset for the instruction at the given
     * offset.
     */
    private int newInstructionOffset(int oldInstructionOffset)
    {
        // Special case: is it actually a label?
        if (isLabel(oldInstructionOffset))
        {
            // Retrieve the new offset from the label.
            int labelIdentifier = labelIdentifier(oldInstructionOffset);
            Label label = (Label)labels.get(labelIdentifier);
            if (label == null)
            {
                throw new IllegalArgumentException("Reference to unknown label identifier ["+labelIdentifier+"]");
            }

            return label.newOffset;
        }

        // Otherwise retrieve the new instruction offset.
        if (oldInstructionOffset < 0 ||
            oldInstructionOffset > codeLength)
        {
            throw new IllegalArgumentException("Invalid instruction offset ["+oldInstructionOffset+"] in code with length ["+codeLength+"]");
        }

        return newInstructionOffsets[oldInstructionOffset];
    }

    /**
     * Returns the given list of exceptions, without the ones that have empty
     * code blocks.
     */
    private int removeEmptyExceptions(ExceptionInfo[] exceptionInfos,
                                      int             exceptionInfoCount)
    {
        // Overwrite all empty exceptions.
        int newIndex = 0;
        for (int index = 0; index < exceptionInfoCount; index++)
        {
            ExceptionInfo exceptionInfo = exceptionInfos[index];
            if (exceptionInfo.u2startPC < exceptionInfo.u2endPC)
            {
                exceptionInfos[newIndex++] = exceptionInfo;
            }
        }

        return newIndex;
    }

    /**
     * Returns the given list of line numbers, without the ones that have empty
     * code blocks or that exceed the code size.
     */
    private int removeEmptyLineNumbers(LineNumberInfo[] lineNumberInfos,
                                       int              lineNumberInfoCount,
                                       int              codeLength)
    {
        // Overwrite all empty line number entries.
        int newIndex = 0;
        for (int index = 0; index < lineNumberInfoCount; index++)
        {
            LineNumberInfo lineNumberInfo = lineNumberInfos[index];
            int startPC = lineNumberInfo.u2startPC;
            if (startPC < codeLength &&
                (index == 0 || startPC > lineNumberInfos[index-1].u2startPC))
            {
                lineNumberInfos[newIndex++] = lineNumberInfo;
            }
        }

        return newIndex;
    }

    /**
     * This pseudo-instruction is a composite of other instructions, for local
     * use inside the editor class only.
     */
    private class CompositeInstruction
    extends       Instruction
    {
        private Instruction[] instructions;

        private CompositeInstruction(Instruction[] instructions)
        {
            this.instructions = instructions;
        }

        // Implementations for Instruction.

        public Instruction shrink()
        {
            for (int index = 0; index < instructions.length; index++)
            {
                instructions[index] = instructions[index].shrink();
            }

            return this;
        }

        public void write(byte[] code, int offset)
        {
            for (int index = 0; index < instructions.length; index++)
            {
                Instruction instruction = instructions[index];

                instruction.write(code, offset);

                offset += instruction.length(offset);
            }
        }

        protected void readInfo(byte[] code, int offset)
        {
            throw new UnsupportedOperationException("Can't read composite instruction");
        }

        protected void writeInfo(byte[] code, int offset)
        {
            throw new UnsupportedOperationException("Can't write composite instruction");
        }

        public int length(int offset)
        {
            int newOffset = offset;

            for (int index = 0; index < instructions.length; index++)
            {
                newOffset += instructions[index].length(newOffset);
            }

            return newOffset - offset;
        }

        public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, InstructionVisitor instructionVisitor)
        {
            if (instructionVisitor != CodeAttributeEditor.this)
            {
                throw new UnsupportedOperationException("Unexpected visitor ["+instructionVisitor+"]");
            }

            for (int index = 0; index < instructions.length; index++)
            {
                Instruction instruction = instructions[index];

                instruction.accept(clazz, method, codeAttribute, offset, CodeAttributeEditor.this);
            }
        }

        // Implementations for Object.

        public String toString()
        {
            StringBuffer stringBuffer = new StringBuffer();

            for (int index = 0; index < instructions.length; index++)
            {
                stringBuffer.append(instructions[index].toString()).append("; ");
            }

            return stringBuffer.toString();
        }
    }

    // For convenience, we also define two pseudo-instructions, to conveniently
    // mark local labels and create new exceptions handlers.

    /**
     * Creates a new label that can be used as a pseudo-instruction to mark
     * a local offset. Its offset can be used as a branch target in
     * replacement instructions ({@link Label#offset()}).
     */
    public Label label()
    {
        return label(labels.size());
    }

    /**
     * Creates a new label that can be used as a pseudo-instruction to mark
     * a local offset. Its offset can be used as a branch target in
     * replacement instructions ({@link Label#offset()}).
     */
    public Label label(int identifier)
    {
        Label label = new Label(identifier);

        // Remember the label, so we can retrieve its offset later on.
        labels.put(new Integer(identifier), label);

        return label;
    }

    /**
     * Creates a new catch instance that can be used as a pseudo-instruction
     * to mark the start of an exception handler. Its offset can be used as
     * a branch target in replacement instructions ({@link Label#offset()}).
     */
    public Label catch_(int startOffset,
                        int endOffset,
                        int catchType)
    {
        return catch_(labels.size(),
                      startOffset,
                      endOffset,
                      catchType);
    }

    /**
     * Creates a new catch instance that can be used as a pseudo-instruction
     * to mark the start of an exception handler. Its offset can be used as
     * a branch target in replacement instructions ({@link Label#offset()}).
     */
    public Label catch_(int identifier,
                        int startOffset,
                        int endOffset,
                        int catchType)
    {
        Label catch_ = new Catch(identifier, startOffset, endOffset, catchType);

        // Remember the label, so we can retrieve its offset later on.
        labels.put(new Integer(identifier), catch_);

        return catch_;
    }

    /**
     * Returns whether the given instruction offset actually represents a
     * label (which contains the actual offset).
     */
    private static boolean isLabel(int instructionOffset)
    {
        return (instructionOffset & 0xff000000) == LABEL_FLAG;
    }

    /**
     * Returns the label identifier that corrresponds to the given
     * instruction offset.
     */
    private static int labelIdentifier(int instructionOffset)
    {
        return instructionOffset & ~LABEL_FLAG;
    }

    /**
     * This pseudo-instruction represents a label that marks an instruction
     * offset, for use in the context of the code attribute editor only.
     */
    public static class Label
    extends             Instruction
    {
        protected final int identifier;

        private int newOffset;

        /**
         * Creates a new Label.
         * @param identifier an identifier that can be chosen freely.
         */
        public Label(int identifier)
        {
            this.identifier = identifier;
        }

        /**
         * Returns the offset that can then be used as a branch target in
         * other replacement instructions.
         */
        public int offset()
        {
            return LABEL_FLAG | identifier;
        }

        // Implementations for Instruction.

        public Instruction shrink()
        {
            return this;
        }

        public void write(byte[] code, int offset)
        {
        }

        protected void readInfo(byte[] code, int offset)
        {
            throw new UnsupportedOperationException("Can't read label instruction");
        }

        protected void writeInfo(byte[] code, int offset)
        {
            throw new UnsupportedOperationException("Can't write label instruction");
        }

        public int length(int offset)
        {
            // Remember the offset, so we can retrieve it later on.
            newOffset = offset;

            return 0;
        }

        public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, InstructionVisitor instructionVisitor)
        {
            if (instructionVisitor.getClass() != CodeAttributeEditor.class)
            {
                throw new UnsupportedOperationException("Unexpected visitor ["+instructionVisitor+"]");
            }
        }

        // Implementations for Object.

        public String toString()
        {
            return "label_"+offset();
        }
    }

    /**
     * This pseudo-instruction represents an exception handler,
     * for use in the context of the code attribute editor only.
     */
    private static class Catch
    extends              Label
    {
        private final int startOfffset;
        private final int endOffset;
        private final int catchType;

        /**
         * Creates a new Catch instance.
         * @param identifier  an identifier that can be chosen freely.
         * @param startOffset the start offset of the catch block.
         * @param endOffset   the end offset of the catch block.
         * @param catchType   the index of the catch type in the constant pool.
         */
        public Catch(int identifier,
                     int startOffset,
                     int endOffset,
                     int catchType)
        {
            super(identifier);

            this.startOfffset = startOffset;
            this.endOffset    = endOffset;
            this.catchType    = catchType;
        }

       // Implementations for Instruction.

        public Instruction shrink()
        {
            return this;
        }

        public void write(byte[] code, int offset)
        {
        }

        protected void readInfo(byte[] code, int offset)
        {
            throw new UnsupportedOperationException("Can't read catch instruction");
        }

        protected void writeInfo(byte[] code, int offset)
        {
            throw new UnsupportedOperationException("Can't write catch instruction");
        }

        public int length(int offset)
        {
            return super.length(offset);
        }

        public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, InstructionVisitor instructionVisitor)
        {
            if (instructionVisitor.getClass() != CodeAttributeEditor.class)
            {
                throw new UnsupportedOperationException("Unexpected visitor ["+instructionVisitor+"]");
            }

            // Add the exception. Its offsets will still be updated later on,
            // like any other exception.
            new ExceptionInfoEditor(codeAttribute).prependException(
                new ExceptionInfo(startOfffset,
                                  endOffset,
                                  offset(),
                                  catchType));
        }

        // Implementations for Object.

        public String toString()
        {
            return "catch " +
                   (isLabel(startOfffset) ? "label_" : "") + startOfffset + ", " +
                   (isLabel(endOffset)    ? "label_" : "") + endOffset    + ", #" +
                   catchType;
        }
    }
}


text:
<?php
    /**
     * @author Manuel Thalmann <m@nuth.ch>
     * @license Apache-2.0
     */
    namespace System\Web;
    use ManuTh\TemPHPlate\Properties\Settings;
    use System\Globalization\CultureInfo;
    use System\Web\Forms\Control;
    use System\Web\Forms\MenuBar;
    use System\Web\Forms\Rendering\Renderer;
    use System\Web\Forms\Rendering\IRenderer;
    use System\Web\Forms\Rendering\IRenderable;
    {
        /**
         * Represents a page.
         *
         * @property MenuBar $MenuBar
         * Gets or sets the menu-bar of the page.
         *
         * @property-read bool $SupportsMenuBar
         * Gets a value indicating whether the page supports menu-bars.
         *
         * @property Renderer $Renderer
         * Gets or sets the renderer of the page.
         */
        class Page extends WebContent implements IRenderer
        {
            /**
             * The menu-bar of the page.
             *
             * @var MenuBar
             */
            private $menuBar;

            /**
             * Gets or sets the renderer of the page.
             *
             * @var IRenderer
             */
            private $renderer;

            /**
             * Initializes a new instance of the `Page` class.
             */
            public function Page()
            {
            }

            /**
             * @ignore
             */
            public function getMenuBar() : ?MenuBar
            {
                return $this->menuBar;
            }

            /**
             * @ignore
             */
            public function setMenuBar(?MenuBar $value)
            {
                $this->menuBar = $value;
            }

            /**
             * @ignore
             */
            public function getSupportsMenuBar()
            {
                return true;
            }

            /**
             * @ignore
             */
            public function getRenderer() : ?Renderer
            {
                return $this->renderer;
            }

            /**
             * @ignore
             */
            public function setRenderer(?Renderer $value)
            {
                $this->renderer = $value;
            }

            /**
             * Draws the object.
             *
             * @return void
             */
            protected function DrawInternal()
            {
            }

            /**
             * Renders a renderable item.
             *
             * @param Control $item
             * The item to render.
             *
             * @return string
             * A string that represents the rendered item.
             */
            public function Render(Control $item) : string
            {
                if (!($item instanceof MenuBar) || $this->SupportsMenuBar)
                {
                    return $this->Renderer->Render($item);
                }
            }

            /**
             * @ignore
             */
            private function __Initialize() : array
            {
                return array(
                    'renderer' => new Renderer(),
                    'menuBar' => Settings::$MenuBar);
            }
        }
    }
?>


text:
<?php
//only run if this is a hook call
if(defined("HOOK") AND HOOK){
    //Add the twilio libarary so we can get information about calls
    require_once(APPPATH . 'libraries/twilio.php');

    //We're making a call using the restClient using the twilio credentials for this VBX instalation
    $this->twilio = new TwilioRestClient($this->twilio_sid,
    $this->twilio_token,
    $this->twilio_endpoint);

    if(!isset($_POST['Flow'])){
        echo json_encode(array('isError' => true, 'message' => 'no flow name given'));
        return;
    }

    $flows = OpenVBX::getFlows(array('name' => $_POST['Flow']));

    if(!isset($flows[0])){
        echo json_encode(array('isError' => true, 'message' => 'invlalid flow name'));
        return;
    }

    $flow = $flows[0];

    if(is_null($flow->data)){
        echo json_encode(array('isError' => true, 'message' => "flow '{$flow->name}' not valid for calls"));
        return;
    }

    if(count($flow->numbers) == 0){
        echo json_encode(array('isError' => true, 'message' => "flow '{$flow->name}' has no attached numbers"));
        return;
    }

    if(!isset($_POST['Called'])){
        echo json_encode(array('isError' => true, 'message' => 'missing number to call'));
        return;
    }

    $response = $this->twilio->request("Accounts/{$this->twilio_sid}/Calls",
        'POST',
        array(
            'Caller' => $flow->numbers[0],
            'Called' => normalize_phone_to_E164($_POST['Called']),
            'Url' => site_url('twiml/start/voice/'.$flow->id)));

    if($response->IsError){
        echo json_encode(array('isError' => true, 'message' => $response->ErrorMessage));
        return;
    }

    echo json_encode(array('isError' => false, 'message' => 'call placed'));
    return;

} else {
?>

Click-To-Flow

Initate a call from any flow by posting the flow name and the number
        to call:

<?php echo site_url("hook/click_to_flow");?>

The flow must be connected to a number, and be a valid flow for voice

Example:

        <?php
            $example = "\n<form method='POST' action='" . site_url("hook/click_to_flow") . "'>\n";
            $example .= "\t<input type='text' name='Called'>\n";
            $example .= "\t<input type='hidden' name='Flow' value='Name'>\n";
            $example .= "\t<input type='submit' value='Call Me'>\n";
            $example .= "</form>";
            echo htmlspecialchars($example);
        ?>

A JSON status will be returned.

WARNING: This is a proof-of-concept requiring modified OpenVBX code to run. Please treat it as such.

<?php
}
?>


text:
#include "rtabmap/gui/KeypointItem.h"

#include <QtGui/QPen>
#include <QtGui/QBrush>
#include <QGraphicsScene>
#include "rtabmap/utilite/ULogger.h"

namespace rtabmap {

KeypointItem::KeypointItem(int id, const cv::KeyPoint & kpt, const QColor & color, QGraphicsItem * parent) :
	QGraphicsEllipseItem(kpt.pt.x-(kpt.size==0?3.0f:kpt.size)/2.0f, kpt.pt.y-(kpt.size==0?3.0f:kpt.size)/2.0f, kpt.size==0?3.0f:kpt.size, kpt.size==0?3.0f:kpt.size, parent),
	_id(id),
	_kpt(kpt),
	_placeHolder(0)
{
	this->setColor(color);
	this->setAcceptHoverEvents(true);
	this->setFlag(QGraphicsItem::ItemIsFocusable, true);
	_width = pen().width();
}

KeypointItem::~KeypointItem()
{
	if(_placeHolder)
	{
		delete _placeHolder;
	}
}

void KeypointItem::setColor(const QColor & color)
{
	this->setPen(QPen(color));
	this->setBrush(QBrush(color));
}

void KeypointItem::showDescription()
{
	if(!_placeHolder)
	{
		_placeHolder = new QGraphicsRectItem (this);
		_placeHolder->setVisible(false);
		_placeHolder->setBrush(QBrush(QColor ( 0, 0, 0, 170 ))); // Black transparent background
		QGraphicsTextItem * text = new QGraphicsTextItem(_placeHolder);
		text->setDefaultTextColor(this->pen().color().rgb());
		text->setPlainText(QString( "Id = %1\n"
				"Dir = %3\n"
				"Hessian = %4\n"
				"X = %5\n"
				"Y = %6\n"
				"Size = %7").arg(_id).arg(_kpt.angle).arg(_kpt.response).arg(_kpt.pt.x).arg(_kpt.pt.y).arg(_kpt.size));
		_placeHolder->setRect(text->boundingRect());
	}

	if(_placeHolder->parentItem())
	{
		_placeHolder->setParentItem(0); // Make it a to level item
	}
	QPen pen = this->pen();
	this->setPen(QPen(pen.color(), _width+2));
	_placeHolder->setZValue(this->zValue()+1);
	_placeHolder->setPos(this->mapFromScene(0,0));
	_placeHolder->setVisible(true);
}

void KeypointItem::hideDescription()
{
	if(_placeHolder)
	{
		_placeHolder->setVisible(false);
	}
	this->setPen(QPen(pen().color(), _width));
}

void KeypointItem::hoverEnterEvent ( QGraphicsSceneHoverEvent * event )
{
	QGraphicsScene * scene = this->scene();
	if(scene && scene->focusItem() == 0)
	{
		this->showDescription();
	}
	else
	{
		this->setPen(QPen(pen().color(), _width+2));
	}
	QGraphicsEllipseItem::hoverEnterEvent(event);
}

void KeypointItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event )
{
	if(!this->hasFocus())
	{
		this->hideDescription();
	}
	QGraphicsEllipseItem::hoverEnterEvent(event);
}

void KeypointItem::focusInEvent ( QFocusEvent * event )
{
	this->showDescription();
	QGraphicsEllipseItem::focusInEvent(event);
}

void KeypointItem::focusOutEvent ( QFocusEvent * event )
{
	this->hideDescription();
	QGraphicsEllipseItem::focusOutEvent(event);
}

}


text:
{% extends "base.html" %}
{% load filters %}
{% load bootstrap %}
{% block task_content %}
<div class="container col-md-8 padding-left">
    {% block content %}
        {{ content }}
    {% endblock %}
</div>
{% endblock task_content %}


text:
package org.umlg.sqlg.structure;

/**
 * Date: 2017/01/22
 * Time: 6:39 PM
 */
public interface TopologyListener {

    void change(TopologyInf topologyInf, TopologyInf oldValue, TopologyChangeAction action);
}


text:
/**
 * @file object-bee entry file
 */

'use strict';

const bee = require('./bee');

bee.$install(require('./registers/create'));
bee.$install(require('./registers/ensure'));
bee.$install(require('./registers/entity'));
bee.$install(require('./registers/function'));
bee.$install(require('./registers/glob'));
bee.$install(require('./registers/match'));
bee.$install(require('./registers/mirror'));
bee.$install(require('./registers/noop'));
bee.$install(require('./registers/object'));
bee.$install(require('./registers/queue'));
bee.$install(require('./registers/remove'));
bee.$install(require('./registers/rename'));

module.exports = bee;


text:
using Map.Model;
using UnityEngine;
using NUnit.Framework;

namespace Model
{
    public class BoardCreatorTests
    {

        private BoardCreator boardCreator;

        [SetUp]
        public void setUp()
        {
            boardCreator = new BoardCreator();
        }

        [Test]
        public void testGenerateCorridorsShouldGenerateOneLessCorridorThanRooms()
        {
            const int roomCount = 6;
            const int corridorsExpected = 5;

            BoardCreator.Corridor[] corridors = boardCreator.GenerateCorridors(roomCount);
            Assert.AreEqual(corridorsExpected, corridors.Length);
        }

    }
}


text:
package org.capcaval.lafabrique.common._test;

import junit.framework.Assert;

import org.capcaval.lafabrique.common.CommandResult;
import org.capcaval.lafabrique.common.CommandResult.Type;
import org.capcaval.lafabrique.lang.StringMultiLine;

public class CommandResultTest {
	@org.junit.Test
	public void commandResultAddTest() {
		CommandResult cr = new CommandResult("This is a comment");
		Assert.assertEquals("This is a comment", cr.toString());
		Assert.assertEquals(Type.NONE, cr.getType());
		//Assert.assertEquals(null, cr.getErrorType());
	}

	@org.junit.Test
	public void commandResultErrorTest() {
		CommandResult.applicationName.set("HypeApp");
		CommandResult cr = new CommandResult(Type.ERROR,  "This is a comment");
		Assert.assertEquals(Type.ERROR, cr.getType());
		//Assert.assertEquals(ErrorType.COMMAND_NOT_FOUND, cr.getErrorType());
		Assert.assertEquals("[HypeApp] ERROR : This is a comment", cr.toString());
	}

	@org.junit.Test
	public void commandResultWarningTest() {
		CommandResult.applicationName.set("HypeApp");
		CommandResult cr = new CommandResult(Type.WARNING,  "This is a comment");
		Assert.assertEquals(Type.WARNING, cr.getType());
		//Assert.assertEquals(null, cr.getErrorType());
		Assert.assertEquals("[HypeApp] WARNING : This is a comment", cr.toString());
	}

	@org.junit.Test
	public void commandResultNullTypeTest() {
		CommandResult.applicationName.set("HypeApp");
		CommandResult cr = new CommandResult((Type)null,  "This is a comment");
		Assert.assertEquals(null, cr.getType());
		// Assert.assertEquals(null, cr.getErrorType());
		Assert.assertEquals("This is a comment", cr.toString());
	}

	@org.junit.Test
	public void commandResultMultiMessageTest() {
		CommandResult.applicationName.set("HypeApp");
		CommandResult cr = new CommandResult(Type.INFO,  "This is a comment");
		cr.addMessage( Type.ERROR, "This is an error comment");
		cr.addMessage("       This is a error comment on another line");
		cr.addMessage(Type.WARNING, "This is a warning error comment");

		StringMultiLine sm = new StringMultiLine(
				"[HypeApp] INFO : This is a comment",
				"[HypeApp] ERROR : This is an error comment",
				"       This is a error comment on another line",
				"[HypeApp] WARNING : This is a warning error comment"
				);

		Assert.assertEquals(sm.toString(), cr.toString());
		Assert.assertEquals(Type.ERROR, cr.getType());
		//Assert.assertEquals(ErrorType.DOMAIN, cr.getErrorType());
	}

	@org.junit.Test
	public void commandResultConcatMessageTest() {
		CommandResult.applicationName.set("HypeApp");
		CommandResult cr = new CommandResult(Type.INFO,  "This is a comment");
		cr.addMessage("       This is an info comment on another line");
		cr.addMessage(Type.WARNING, "This is a warning error comment");

		CommandResult cr2 = new CommandResult(Type.ERROR,  "This is an error comment");

		cr.concat(cr2);

		StringMultiLine sm = new StringMultiLine(
				"[HypeApp] INFO : This is a comment",
				"       This is an info comment on another line",
				"[HypeApp] WARNING : This is a warning error comment",
				"[HypeApp] ERROR : This is an error comment"
				);

		Assert.assertEquals(sm.toString(), cr.toString());
		Assert.assertEquals(Type.ERROR, cr.getType());
		//Assert.assertEquals(ErrorType.DOMAIN, cr.getErrorType());
	}

}


text:
from django.views.generic import TemplateView

class FB登入SDK(TemplateView):
    template_name = "socialaccount/snippets/login_extra.html"


text:
package email

import "github.com/vjeantet/bitfan/processors/doc"

func (p *processor) Doc() *doc.Processor {
	return &doc.Processor{
  Name:       "email",
  ImportPath: "github.com/vjeantet/bitfan/processors/output-email",
  Doc:        "Send email when an output is received. Alternatively, you may include or exclude the email output execution using conditionals.",
  DocShort:   "Sends email to a specified address when output is received",
  Options:    &doc.ProcessorOptions{
    Doc:     "",
    Options: []*doc.ProcessorOption{
      &doc.ProcessorOption{
        Name:           "Host",
        Alias:          "address",
        Doc:            "The address used to connect to the mail server",
        Required:       false,
        Type:           "string",
        DefaultValue:   "\"localhost\"",
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "Port",
        Alias:          "port",
        Doc:            "Port used to communicate with the mail server",
        Required:       false,
        Type:           "int",
        DefaultValue:   "25",
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "Username",
        Alias:          "username",
        Doc:            "Username to authenticate with the server",
        Required:       false,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "Password",
        Alias:          "password",
        Doc:            "Password to authenticate with the server",
        Required:       false,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "From",
        Alias:          "from",
        Doc:            "The fully-qualified email address for the From: field in the email",
        Required:       false,
        Type:           "string",
        DefaultValue:   "\"bitfan@nowhere.com\"",
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "Replyto",
        Alias:          "replyto",
        Doc:            "The fully qualified email address for the Reply-To: field",
        Required:       false,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "replyto => \"test@nowhere.com\"",
      },
      &doc.ProcessorOption{
        Name:           "To",
        Alias:          "to",
        Doc:            "The fully-qualified email address to send the email to.\n\nThis field also accepts a comma-separated string of addresses, for example: `\"me@host.com, you@host.com\"`\n\nYou can also use dynamic fields from the event with the %{fieldname} syntax",
        Required:       true,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "to => \"me@host.com, you@host.com\"",
      },
      &doc.ProcessorOption{
        Name:           "Cc",
        Alias:          "cc",
        Doc:            "The fully-qualified email address(es) to include as cc: address(es).\n\nThis field also accepts a comma-separated string of addresses, for example: `\"me@host.com, you@host.com\"`",
        Required:       false,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "cc => \"me@host.com, you@host.com\"",
      },
      &doc.ProcessorOption{
        Name:           "Bcc",
        Alias:          "bcc",
        Doc:            "The fully-qualified email address(es) to include as bcc: address(es).\n\nThis field also accepts a comma-separated string of addresses, for example: `\"me@host.com, you@host.com\"`",
        Required:       false,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "bcc => \"me@host.com, you@host.com\"",
      },
      &doc.ProcessorOption{
        Name:           "Subject",
        Alias:          "subject",
        Doc:            "Subject: for the email\n\nYou can use template",
        Required:       false,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "subject => \"message from {{.host}}\"",
      },
      &doc.ProcessorOption{
        Name:           "Subjectfile",
        Alias:          "subjectfile",
        Doc:            "Path to Subject template file for the email",
        Required:       false,
        Type:           "string",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "HTMLBody",
        Alias:          "htmlbody",
        Doc:            "HTML Body for the email, which may contain HTML markup",
        Required:       false,
        Type:           "location",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "htmlBody => \"
Hello
 message received : {{.message}}\"",
      },
      &doc.ProcessorOption{
        Name:           "Body",
        Alias:          "body",
        Doc:            "Body for the email - plain text only.",
        Required:       false,
        Type:           "location",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "body => \"message : {{.message}}. from {{.host}}.\"",
      },
      &doc.ProcessorOption{
        Name:           "Attachments",
        Alias:          "attachments",
        Doc:            "Attachments - specify the name(s) and location(s) of the files",
        Required:       false,
        Type:           "array",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "AttachEventData",
        Alias:          "attachments_with_event",
        Doc:            "Use event field's values as attachment content\neach pair is  : event field's path => attachment's name",
        Required:       false,
        Type:           "hash",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      " attachments_with_event=>{\"mydata\"=>\"myimage.jpg\"}",
      },
      &doc.ProcessorOption{
        Name:           "Images",
        Alias:          "images",
        Doc:            "Images - specify the name(s) and location(s) of the images",
        Required:       false,
        Type:           "array",
        DefaultValue:   nil,
        PossibleValues: []string{},
        ExampleLS:      "",
      },
      &doc.ProcessorOption{
        Name:           "EmbedB64Images",
        Alias:          "embed_b64_images",
        Doc:            "Search for img:data in HTML body, and replace them to a reference to inline attachment",
        Required:       false,
        Type:           "bool",
        DefaultValue:   "false",
        PossibleValues: []string{},
        ExampleLS:      "",
      },
    },
  },
  Ports: []*doc.ProcessorPort{},
}
}


text:
package br.com.tattobr.openglestests;

import javax.microedition.khronos.opengles.GL10;

import br.com.tattobr.openglestests.utils.Texture;

/**
 * Created by tattobr on 07/01/2017.
 */

public class MultipleTexturesRotationActivity extends MultipleTexturesActivity {
    private float rotation;

    @Override
    public void onDrawFrame(GL10 gl10) {
        super.onDrawFrame(gl10);

        rotation += 2;
        if (rotation > 360) {
            rotation = 0;
        }
    }

    protected void drawTexture(GL10 gl10, Texture texture, float scale, float x, float y) {
        float translationScaled = .5f * scale;
        gl10.glLoadIdentity();
        gl10.glTranslatef(x + translationScaled, y, 0);
        gl10.glRotatef(rotation, 0, 1, 0);
        gl10.glTranslatef(-translationScaled, 0, 0);
        gl10.glScalef(scale, scale, 0);
        texture.bind(gl10);
        gl10.glDrawElements(GL10.GL_TRIANGLES, 6, GL10.GL_UNSIGNED_SHORT, shortBuffer);
        texture.unbind(gl10);
    }
}


text:
#include <cusp/array1d.h>
//MW: if device is not cuda then do not include cuda stuff and redirect device multiply to host
#include <cusp/detail/host/multiply.h>
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
#include <cusp/detail/device/multiply.h>
#endif

namespace cusp
{
namespace detail
{
namespace dispatch
{

////////////////
// Host Paths //
////////////////
template <typename LinearOperator,
          typename MatrixOrVector1,
          typename MatrixOrVector2>
void multiply(const LinearOperator&  A,
              const MatrixOrVector1& B,
                    MatrixOrVector2& C,
              cusp::host_memory,
              cusp::host_memory,
              cusp::host_memory)
{
    cusp::detail::host::multiply(A, B, C);
}

//////////////////
// Device Paths //
//////////////////
template <typename LinearOperator,
          typename MatrixOrVector1,
          typename MatrixOrVector2>
void multiply(const LinearOperator&  A,
              const MatrixOrVector1& B,
                    MatrixOrVector2& C,
              cusp::device_memory,
              cusp::device_memory,
              cusp::device_memory)
{
#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA
    cusp::detail::device::multiply(A, B, C);
#else
    cusp::detail::host::multiply(A, B, C);
#endif
}

} // end namespace dispatch
} // end namespace detail
} // end namespace cusp


text:
class SettlementsController < ApplicationController
  before_action :authenticate_user!
  def index
    @settlements = Settlement.order(:user_id).includes(:user, :coin, :gift).page params[:page]
    authorize Settlement
    respond_to do |format|
      format.html
      format.json {render json: @settlements}
    end
  end

  def create
    @settlement = Settlement.new(create_params)
    user = @settlement.user
    gift = @settlement.gift
    begin
      authorize @settlement
      @settlement.validate!
      @settlement.transaction do
        user.increment(:closed_coins, gift.value)
        user.decrement(:opened_coins, gift.value)
        user.save!
        @settlement.save!
      end
    rescue ActiveRecord::RecordInvalid => e
      @error_message = e.record.errors.full_messages[0]
    rescue Pundit::NotAuthorizedError => e
      @error_message = I18n.t('errors.messages.not_permitted');
    end
    respond_to do |format|
      format.js
    end
  end

  private
  def create_params
    permitted_params = params.require(:settlement).permit
    permitted_params[:user_id] = params[:settlement][:user][:id]
    permitted_params[:coin_id] = params[:settlement][:coin][:id]
    permitted_params[:gift_id] = params[:settlement][:gift][:id]
    permitted_params
  end
end