text:
require "parser/current"
require "unparser"
require "dissociated_introspection/try"
require "dissociated_introspection/ruby_class"
require "dissociated_introspection/block"
require "dissociated_introspection/method_call"

RSpec.describe DissociatedIntrospection::RubyClass do

  it "#class_begin" do
    subject = described_class.new source: <<-RUBY
      module C
        class A < B
          def method
          end
        end
      end
    RUBY
    expect(subject.class_begin.to_s).to eq "(class\n  (const nil :A)\n  (const nil :B)\n  (def :method\n    (args) nil))"
  end

  describe "class_method_calls" do
    it "method call with primitives" do
      subject = described_class.new source: <<-RUBY
      class A
        attr_reader :name, "hello"
      end
      RUBY
      expect(subject.class_method_calls.first.to_h).to eq(name: :attr_reader, arguments: [:name, "hello"])
    end

    it "methods call with lambda block" do
      subject = described_class.new source: <<-RUBY
      class A
        scope :find_all_people, ->(a, _) {
          value = a + 1
          return 3 if value == 2
        }
      end
      RUBY
      expect(subject.class_method_calls.first.name).to eq(:scope)
      expect(subject.class_method_calls.first.arguments.first).to eq(:find_all_people)
      expect(subject.class_method_calls.first.arguments.last.body.source).to eq("value = (a + 1)\nif (value == 2)\n  return 3\nend")
      expect(subject.class_method_calls.first.arguments.last.arguments.source).to eq("a, _")
    end
  end

  describe "#class_name" do

    it "returns the class name as a symbol" do
      subject = described_class.new source: <<-RUBY
      require "uri-open"

      class A < B
        def method1
        end
      end
      RUBY
      expect(subject.class_name).to eq "A"
      expect(subject.defs.count).to eq 1
    end
  end

  describe "#parent_class_name" do

    it "returns the parent class as a symbol" do
      subject = described_class.new source: <<-RUBY
      require "uri-open"
      class A < B
        def method
        end
      end
      RUBY
      expect(subject.parent_class_name).to eq "B"
    end

    it "returns the parent class as a symbol with modules" do
      subject = described_class.new source: <<-RUBY
      class A < B::C
        def method
        end
      end
      RUBY
      expect(subject.parent_class_name).to eq "B::C"
    end
  end

  describe "#parent_class?" do

    it "has parent class" do
      subject = described_class.new source: <<-RUBY
      require "uri-open"
      class A < B
        def method
        end
      end
      RUBY
      expect(subject.parent_class?).to eq true

      subject = described_class.new source: <<-RUBY
      class A < B
        def method
        end
      end
      RUBY
      expect(subject.parent_class?).to eq true
    end

    it "has parent class within module" do
      subject = described_class.new source: <<-RUBY
      module C
        class A < B
          def method
          end
        end
      end
      RUBY
      expect(subject.parent_class?).to eq true
    end

    it "has no parent class" do
      subject = described_class.new source: <<-RUBY
      require "uri-open"
      class A
        def method
        end
      end
      RUBY
      expect(subject.parent_class?).to eq false

      subject = described_class.new source: <<-RUBY
      class A
        def method
        end
      end
      RUBY
      expect(subject.parent_class?).to eq false
    end

    it "its not a class" do
      subject = described_class.new source: <<-RUBY
      def method

      end
      RUBY
      expect(subject.parent_class?).to eq false
    end
  end

  describe "#modify_parent_class" do

    it "will change parent class const" do
      subject = described_class.new source: <<-RUBY
      class A < B
        def method(name:)
        end
      end
      RUBY
      expect(subject.modify_parent_class("C").source).to eq "class A < C\n  def method(name:)\n  end\nend"

      subject = described_class.new source: <<-RUBY
      require "uri-open"
      class A < B
        def method(name:)
        end
      end
      RUBY
      expect(subject.modify_parent_class("C").source).to eq "class A < C\n  def method(name:)\n  end\nend"
    end

    it "will change parent class const with module" do
      subject = described_class.new source: <<-RUBY
      class A < B::D::C
        def method(name:)
        end
      end
      RUBY
      expect(subject.modify_parent_class("X::Y").source).to eq "class A < X::Y\n  def method(name:)\n  end\nend"
    end

    it "will change parent class const within a module but will not return the module" do
      subject = described_class.new source: <<-RUBY
      module C
        class A < B
          def method
          end
        end
      end
      RUBY
      expect(subject.modify_parent_class("Y::Z").source).to eq "class A < Y::Z\n  def method\n  end\nend"
    end

    it "will change parent class const within a doubly nested class" do
      subject = described_class.new source: <<-RUBY
      module A
        module B
          class C < D
            def method
            end
          end
        end
      end
      RUBY
      expect(subject.modify_parent_class("Y::Z").source).to eq "class C < Y::Z\n  def method\n  end\nend"
    end

    it "if non set it will add the parent" do
      subject = described_class.new source: <<-RUBY
      class A
        def method(*args)
        end
      end
      RUBY
      expect(subject.modify_parent_class("C").source).to eq "class A < C\n  def method(*args)\n  end\nend"
    end
  end

  describe "#change_class_name" do

    it "will change the class constant" do
      subject = described_class.new source: <<-RUBY
      class A
        def method(options={})
        end
      end
      RUBY
      expect(subject.change_class_name("C").source).to eq "class C\n  def method(options = {})\n  end\nend"
    end
  end

  describe "#class?" do

    it "is a class" do
      subject = described_class.new source: <<-RUBY
      class A
        def method(options={})
        end
      end
      RUBY
      expect(subject.class?).to eq true
    end

    it "is not a class" do
      subject = described_class.new source: <<-RUBY
        def method(options={})
        end
      RUBY
      expect(subject.class?).to eq false
    end
  end

  describe "defs" do
    let(:ruby_class) {
      <<-RUBY
      class A
        def method1(arg, named_arg:)
          1+1
        end

        # This is a comment
        def method2(arg=nil)
          puts "hello"
        end
      end
      RUBY
    }

    subject {
      described_class.new(
          DissociatedIntrospection::RubyCode.build_from_source(
              ruby_class,
              parse_with_comments: true
          )
      )
    }

    it "returns a list of methods as Def object" do
      expect(subject.defs.map(&:class).uniq).to eq [described_class::Def]
    end

    describe "Def object" do
      it "name" do
        expect(subject.defs.first.name).to eq :method1
        expect(subject.defs.last.name).to eq :method2
      end

      it "argument" do
        expect(subject.defs.first.arguments.to_s).to eq "arg, named_arg:"
        expect(subject.defs.last.arguments.to_s).to eq "arg = nil"
      end

      it "body" do
        expect(subject.defs.first.body.source).to eq "1 + 1"
        expect(subject.defs.last.body.source).to eq "puts(\"hello\")"
      end

      it "source" do
        expect(subject.defs.first.source).to eq "def method1(arg, named_arg:)\n  1 + 1\nend"
        expect(subject.defs.last.source).to eq "# This is a comment\ndef method2(arg = nil)\n  puts(\"hello\")\nend"
      end

      describe "inspect_methods" do
        it "name" do
          expect(subject.inspect_methods(:instance_methods).first.name).to eq :method1
          expect(subject.inspect_methods(:instance_methods).last.name).to eq :method2
        end
      end
    end
  end

  describe "class_defs" do
    let(:ruby_class) {
      <<-RUBY
      class A
        # my comment
        def self.method1(arg, named_arg:)
          1+1
        end

        class << self
          # This is a comment
          def method2(arg=nil)
            puts "hello"
          end

          def method3(**args)
            puts "goodbye"
          end
        end
      end
      RUBY
    }

    subject {
      described_class.new(
          DissociatedIntrospection::RubyCode.build_from_source(
              ruby_class,
              parse_with_comments: true
          )
      )
    }

    describe "Def object" do
      it "name" do
        expect(subject.class_defs.first.name).to eq :method1
        expect(subject.class_defs[1].name).to eq :method2
        expect(subject.class_defs[2].name).to eq :method3
      end

      it "argument" do
        expect(subject.class_defs.first.arguments.to_s).to eq "arg, named_arg:"
        expect(subject.class_defs[1].arguments.to_s).to eq "arg = nil"
        expect(subject.class_defs[2].arguments.to_s).to eq "**args"
      end

      it "body" do
        expect(subject.class_defs.first.body.source).to eq "1 + 1"
        expect(subject.class_defs[1].body.to_s).to eq "puts(\"hello\")"
        expect(subject.class_defs[2].body.to_s).to eq "puts(\"goodbye\")"
      end

      it "source" do
        expect(subject.class_defs.first.to_s).to eq "# my comment\ndef method1(arg, named_arg:)\n  1 + 1\nend"
        expect(subject.class_defs[1].source).to eq "# This is a comment\ndef method2(arg = nil)\n  puts(\"hello\")\nend"
        expect(subject.class_defs[2].source).to eq "def method3(**args)\n  puts(\"goodbye\")\nend"
      end

      context "single method" do
        let(:ruby_class) {
          <<-RUBY
          class A
            class << self
              def foo
                :buz
              end
            end
          end
          RUBY
        }

        it "class_defs" do
          expect(subject.class_defs.first.name).to eq :foo
          expect(subject.class_defs.first.arguments.to_s).to eq ""
          expect(subject.class_defs.first.body.to_s).to eq ":buz"
        end
      end

      describe "inspect_methods" do
        it "name" do
          expect(subject.inspect_methods(:class_methods).first.name).to eq :method1
          expect(subject.inspect_methods(:methods)[1].name).to eq :method2
          expect(subject.inspect_methods(:methods)[2].name).to eq :method3
        end
      end
    end
  end

  describe "#scrub_inner_classes" do
    let(:ruby_class) {
      <<-RUBY
      require "bla"
      class A
        include MyModule
        class MyError < StandardError;end
        def keep_me
        end
        def self.hello
        end
      end
      RUBY
    }

    subject { described_class.new(source: ruby_class) }

    it "will return a ruby string without the inner class" do
      expect(subject.scrub_inner_classes.source).to eq("class include(MyModule) < def keep_me\nend\n  def self.hello\n  end\nend")
    end
  end

  describe "#defined_nested_modules" do
    let(:ruby_class) {
      <<-RUBY
      require "bla"
      class A
        module MyError
          def hello
            :good_day
          end
        end
        include MyError

      end
      RUBY
    }

    subject { described_class.new(source: ruby_class) }

    it "RubyCode object of defined nested modules" do
      expect(subject.defined_nested_modules.map(&:source).map(&:chomp)).to eq(["module MyError\n  def hello\n    :good_day\n  end\nend"])
    end
  end

  describe "#defined_nested_classes" do
    let(:ruby_class) {
      <<-RUBY
      require "bla"
      class A
        class MyError
          def hello
            :good_day
          end
        end
      end
      RUBY
    }

    subject { described_class.new(source: ruby_class) }

    it "RubyCode object of defined nested classess" do
      expect(subject.defined_nested_classes.map(&:source)).to eq(["class MyError\n  def hello\n    :good_day\n  end\nend"])
    end
  end

  describe "module_nesting" do
    subject { described_class.new(source: ruby_class) }

    context "single nesting" do
      let(:ruby_class) {
        <<-RUBY
      module Api
        class MyClass < OtherClass
          ParentModule::NestedModule
        end
       end
        RUBY
      }

      it "returns the module nesting" do
        expect(subject.module_nesting).to eq [:Api]
      end
    end

    context "double nesting" do
      let(:ruby_class) {
        <<-RUBY
      module Api
        module Namespace
        class MyClass
          module IgnoreMe
          end
        end
        end
       end
        RUBY
      }

      it "returns the module nesting" do
        expect(subject.module_nesting).to eq [:Api, :Namespace]
      end
    end

    context "no nesting" do
      let(:ruby_class) {
        <<-RUBY
        class MyClass
        end
        RUBY
      }

      it "returns the module nesting" do
        expect(subject.module_nesting).to eq []
      end
    end
  end
end


text:
package com.lopez.espada.falconi.people_list_devspark;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by gabriel on 30/07/15.
 */
public class Person implements Parcelable {
    private int id;
    private String name;
    private String phone;
    private String email;
    private String address;
    private String dob;
    private String photo;

    public Person(Parcel pc){
        id = pc.readInt();
        name = pc.readString();
        phone = pc.readString();
        email = pc.readString();
        address = pc.readString();
        dob = pc.readString();
        photo = pc.readString();
    }

    public Person(){}

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(name);
        dest.writeString(phone);
        dest.writeString(email);
        dest.writeString(address);
        dest.writeString(dob);
        dest.writeString(photo);
    }

    public static final Parcelable.Creator<Person> CREATOR = new Parcelable.Creator<Person>() {
        public Person createFromParcel(Parcel pc) {
            return new Person(pc);
        }
        public Person[] newArray(int size) {
            return new Person[size];
        }
    };

    public int getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getDob() {
        return dob;
    }

    public void setDob(String dob) {
        this.dob = dob;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="89">
  <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
    <logicalFolder name="HeaderFiles"
                   displayName="Header Files"
                   projectFiles="true">
      <itemPath>src/CircleList.h</itemPath>
      <itemPath>src/FindVariationSequence.h</itemPath>
      <itemPath>src/utils.h</itemPath>
    </logicalFolder>
    <logicalFolder name="ResourceFiles"
                   displayName="Resource Files"
                   projectFiles="true">
    </logicalFolder>
    <logicalFolder name="SourceFiles"
                   displayName="Source Files"
                   projectFiles="true">
      <itemPath>src/CircleList.cpp</itemPath>
      <itemPath>src/FindVariationSequence.cpp</itemPath>
      <itemPath>src/main.cpp</itemPath>
      <itemPath>src/utils.cpp</itemPath>
    </logicalFolder>
    <logicalFolder name="TestFiles"
                   displayName="Test Files"
                   projectFiles="false"
                   kind="TEST_LOGICAL_FOLDER">
      <logicalFolder name="f1"
                     displayName="TestCircleList"
                     projectFiles="true"
                     kind="TEST">
        <itemPath>tests/TestCircleList.cpp</itemPath>
      </logicalFolder>
    </logicalFolder>
    <logicalFolder name="ExternalFiles"
                   displayName="Important Files"
                   projectFiles="false"
                   kind="IMPORTANT_FILES_FOLDER">
      <itemPath>Makefile</itemPath>
    </logicalFolder>
  </logicalFolder>
  <projectmakefile>Makefile</projectmakefile>
  <confs>
    <conf name="Debug" type="1">
      <toolsSet>
        <remote-sources-mode>LOCAL_SOURCES</remote-sources-mode>
        <compilerSet>default</compilerSet>
        <dependencyChecking>true</dependencyChecking>
        <rebuildPropChanged>false</rebuildPropChanged>
      </toolsSet>
      <compileType>
        <ccTool>
          <incDir>
            <pElem>../CrossMatchLibrary/src</pElem>
            <pElem>../../../software/cfitsio/cfitsio</pElem>
          </incDir>
          <commandLine>-std=c++0x</commandLine>
        </ccTool>
        <linkerTool>
          <output>${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/findvariationsequence</output>
          <linkerAddLib>
            <pElem>.</pElem>
            <pElem>../../../software/cfitsio/cfitsio</pElem>
            <pElem>../../../software/lib</pElem>
          </linkerAddLib>
          <commandLine>-lm -lCrossMatchLibrary -lcfitsio</commandLine>
        </linkerTool>
      </compileType>
      <folder path="TestFiles">
        <ccTool>
          <incDir>
            <pElem>../CrossMatchLibrary/src</pElem>
            <pElem>../../../software/cfitsio/cfitsio</pElem>
            <pElem>src</pElem>
          </incDir>
          <commandLine>-std=c++0x</commandLine>
        </ccTool>
        <linkerTool>
          <linkerAddLib>
            <pElem>../../../software/cfitsio/cfitsio</pElem>
            <pElem>../../../software/lib</pElem>
          </linkerAddLib>
          <commandLine>-lm -lCrossMatchLibrary -lcfitsio</commandLine>
        </linkerTool>
      </folder>
      <folder path="TestFiles/f1">
        <cTool>
          <incDir>
            <pElem>.</pElem>
            <pElem>.</pElem>
          </incDir>
        </cTool>
        <ccTool>
          <incDir>
            <pElem>.</pElem>
            <pElem>.</pElem>
          </incDir>
        </ccTool>
        <linkerTool>
          <output>${TESTDIR}/TestFiles/f1</output>
          <linkerAddLib>
            <pElem>../../../software/cfitsio/cfitsio</pElem>
          </linkerAddLib>
          <commandLine>-lm -lCrossMatchLibrary -lcfitsio</commandLine>
        </linkerTool>
      </folder>
      <item path="src/CircleList.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/CircleList.h" ex="false" tool="3" flavor2="0">
      </item>
      <item path="src/FindVariationSequence.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/FindVariationSequence.h" ex="false" tool="3" flavor2="0">
      </item>
      <item path="src/main.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/utils.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/utils.h" ex="false" tool="3" flavor2="0">
      </item>
      <item path="tests/TestCircleList.cpp" ex="false" tool="1" flavor2="0">
      </item>
    </conf>
    <conf name="Release" type="1">
      <toolsSet>
        <remote-sources-mode>LOCAL_SOURCES</remote-sources-mode>
        <compilerSet>default</compilerSet>
        <dependencyChecking>true</dependencyChecking>
        <rebuildPropChanged>false</rebuildPropChanged>
      </toolsSet>
      <compileType>
        <cTool>
          <developmentMode>5</developmentMode>
        </cTool>
        <ccTool>
          <developmentMode>5</developmentMode>
          <incDir>
            <pElem>../CrossMatchLibrary/src</pElem>
            <pElem>../../../software/cfitsio/cfitsio</pElem>
          </incDir>
          <commandLine>-std=c++0x</commandLine>
        </ccTool>
        <fortranCompilerTool>
          <developmentMode>5</developmentMode>
        </fortranCompilerTool>
        <asmTool>
          <developmentMode>5</developmentMode>
        </asmTool>
        <linkerTool>
          <linkerAddLib>
            <pElem>.</pElem>
            <pElem>../../../software/cfitsio/cfitsio</pElem>
            <pElem>../../../software/lib</pElem>
          </linkerAddLib>
          <commandLine>-lm -lCrossMatchLibrary -lcfitsio</commandLine>
        </linkerTool>
      </compileType>
      <folder path="TestFiles/f1">
        <cTool>
          <incDir>
            <pElem>.</pElem>
            <pElem>.</pElem>
          </incDir>
        </cTool>
        <ccTool>
          <incDir>
            <pElem>.</pElem>
            <pElem>.</pElem>
          </incDir>
        </ccTool>
        <linkerTool>
          <output>${TESTDIR}/TestFiles/f1</output>
        </linkerTool>
      </folder>
      <item path="src/CircleList.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/CircleList.h" ex="false" tool="3" flavor2="0">
      </item>
      <item path="src/FindVariationSequence.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/FindVariationSequence.h" ex="false" tool="3" flavor2="0">
      </item>
      <item path="src/main.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/utils.cpp" ex="false" tool="1" flavor2="0">
      </item>
      <item path="src/utils.h" ex="false" tool="3" flavor2="0">
      </item>
      <item path="tests/TestCircleList.cpp" ex="false" tool="1" flavor2="0">
      </item>
    </conf>
  </confs>
</configurationDescriptor>


text:
"""
The tvm.meta_schedule.mutator package.
Meta Schedule mutator that mutates the trace to explore the
design space.
"""
from .mutator import Mutator, PyMutator


text:
<?php $this->load->view('pages/templates/header'); ?>
<?php $this->load->view('pages/'.$content); ?>
<?php $this->load->view('pages/templates/footer'); ?>


text:
import React from "react";
import Tabs from "@material-ui/core/Tabs";
import Tab from "@material-ui/core/Tab";
import { ListAlt } from "@material-ui/icons";
import { ChatOutlined } from "@material-ui/icons";
import DashboardReview from "./DashboardReview";
import DashboardAds from "./DashboardAds"
import AppBar from '@material-ui/core/AppBar';
import Typography from '@material-ui/core/Typography';
import { withStyles } from '@material-ui/core/styles';
import orange from '@material-ui/core/colors/orange'

function TabContainer(props) {
    return (
        <Typography component="div" style={{ padding: 8 * 3 }}>
            {props.children}
        </Typography>
    );
}

const styles = theme => ({
    root: {
        flexGrow: 0,
        backgroundColor: theme.palette.background.paper,
    },
    middle: {
        justifyContent: "center",
    },
    tabs: {
        color: orange[500],
        backgroundColor: theme.palette.background.paper,
    },
});

class IconLabelTabs extends React.Component {
    state = {
        value: 0
    };

    handleChange = (event, value) => {
        this.setState({ value });
    };
    render() {
        const { classes } = this.props;
        const { value } = this.state;

        return (
            <div className={classes.middle}>
                <AppBar position="static" elevation={1}>
                    <Tabs
                        value={value}
                        className={classes.tabs}
                        onChange={this.handleChange}
                        centered
                    >
                        <Tab icon={<ListAlt />} label="Your Ads" />
                        <Tab icon={<ChatOutlined />} label="Your Reviews" />
                    </Tabs>
                </AppBar>
                {value === 0 && <TabContainer><DashboardAds /></TabContainer>}
                {value === 1 && <TabContainer><DashboardReview /></TabContainer>}
            </div>

        );
    }
}

export default withStyles(styles)(IconLabelTabs);


text:
<?php

namespace Application\View;

use ArrayAccess,
    Zend\Di\Locator,
    Zend\EventManager\EventCollection,
    Zend\EventManager\ListenerAggregate,
    Zend\EventManager\StaticEventCollection,
    Zend\Http\PhpEnvironment\Response,
    Zend\Mvc\Application,
    Zend\Mvc\MvcEvent,
    Zend\View\Renderer;

class Listener implements ListenerAggregate
{
    protected $layout;
    protected $listeners = array();
    protected $staticListeners = array();
    protected $view;
    protected $displayExceptions = false;

    public function __construct(Renderer $renderer, $layout = 'layout.phtml')
    {
        $this->view   = $renderer;
        $this->layout = $layout;
    }

    public function setDisplayExceptionsFlag($flag)
    {
        $this->displayExceptions = (bool) $flag;
        return $this;
    }

    public function displayExceptions()
    {
        return $this->displayExceptions;
    }

    public function attach(EventCollection $events)
    {
        $this->listeners[] = $events->attach('dispatch.error', array($this, 'renderError'));
        $this->listeners[] = $events->attach('dispatch', array($this, 'render404'), -80);
        $this->listeners[] = $events->attach('dispatch', array($this, 'renderLayout'), -1000);
    }

    public function detach(EventCollection $events)
    {
        foreach ($this->listeners as $key => $listener) {
            $events->detach($listener);
            unset($this->listeners[$key]);
            unset($listener);
        }
    }

    public function registerStaticListeners(StaticEventCollection $events, $locator)
    {
        $ident   = 'Application\Controller\PageController';
        $handler = $events->attach($ident, 'dispatch', array($this, 'renderPageController'), -50);
        $this->staticListeners[] = array($ident, $handler);

        $ident   = 'Zend\Mvc\Controller\ActionController';
        $handler = $events->attach($ident, 'dispatch', array($this, 'renderView'), -50);
        $this->staticListeners[] = array($ident, $handler);
    }

    public function detachStaticListeners(StaticEventCollection $events)
    {
        foreach ($this->staticListeners as $i => $info) {
            list($id, $handler) = $info;
            $events->detach($id, $handler);
            unset($this->staticListeners[$i]);
        }
    }

    public function renderPageController(MvcEvent $e)
    {
        $page = $e->getResult();
        if ($page instanceof Response) {
            return;
        }

        $response = $e->getResponse();
        if ($response->isNotFound()) {
            return;
        }

        $routeMatch = $e->getRouteMatch();

        if (!$routeMatch) {
            $page = '404';
        } else {
            $page = $routeMatch->getParam('action', '404');
        }

        if ($page == '404') {
            $response->setStatusCode(404);
        }

        $script     = 'error/' . $page . '.phtml';

        // Action content
        $content    = $this->view->render($script);
        $e->setResult($content);

        return $this->renderLayout($e);
    }

    public function renderView(MvcEvent $e)
    {
        $response = $e->getResponse();
        if (!$response->isSuccess()) {
            return;
        }

        $routeMatch = $e->getRouteMatch();
        $controller = $routeMatch->getParam('controller', 'index');
        $action     = $routeMatch->getParam('action', 'index');
        $script     = $controller . '/' . $action . '.phtml';

        $vars       = $e->getResult();
        if (is_scalar($vars)) {
            $vars = array('content' => $vars);
        } elseif (is_object($vars) && !$vars instanceof ArrayAccess) {
            $vars = (array) $vars;
        }

        $content    = $this->view->render($script, $vars);

        $e->setResult($content);
        return $content;
    }

    public function renderLayout(MvcEvent $e)
    {
        $response = $e->getResponse();
        if (!$response) {
            $response = new Response();
            $e->setResponse($response);
        }
        if ($response->isRedirect()) {
            return $response;
        }

        $footer   = $e->getParam('footer', false);
        $vars     = array('footer' => $footer);

        if (false !== ($contentParam = $e->getParam('content', false))) {
            $vars['content'] = $contentParam;
        } else {
            $vars['content'] = $e->getResult();
        }

        $layout   = $this->view->render($this->layout, $vars);
        $response->setContent($layout);
        return $response;
    }

    public function render404(MvcEvent $e)
    {
        $vars = $e->getResult();
        if ($vars instanceof Response) {
            return;
        }

        $response = $e->getResponse();
        if ($response->getStatusCode() != 404) {
            // Only handle 404's
            return;
        }

        $vars = array(
            'message'            => 'Page not found.',
            'exception'          => $e->getParam('exception'),
            'display_exceptions' => $this->displayExceptions(),
        );

        $content = $this->view->render('error/404.phtml', $vars);

        $e->setResult($content);

        return $this->renderLayout($e);
    }

    public function renderError(MvcEvent $e)
    {
        $error    = $e->getError();
        $app      = $e->getTarget();
        $response = $e->getResponse();
        if (!$response) {
            $response = new Response();
            $e->setResponse($response);
        }

        switch ($error) {
            case Application::ERROR_CONTROLLER_NOT_FOUND:
            case Application::ERROR_CONTROLLER_INVALID:
                $vars = array(
                    'message'            => 'Page not found.',
                    'exception'          => $e->getParam('exception'),
                    'display_exceptions' => $this->displayExceptions(),
                );
                $response->setStatusCode(404);
                break;

            case Application::ERROR_EXCEPTION:
            default:
                $exception = $e->getParam('exception');
                $vars = array(
                    'message'            => 'An error occurred during execution; please try again later.',
                    'exception'          => $e->getParam('exception'),
                    'display_exceptions' => $this->displayExceptions(),
                );
                $response->setStatusCode(500);
                break;
        }

        $content = $this->view->render('error/index.phtml', $vars);

        $e->setResult($content);

        return $this->renderLayout($e);
    }
}


text:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using WinArgv;

namespace OldFrameworkTester
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Any())
            {
                var i = 1;
                foreach (var arg in args)
                {
                    Console.WriteLine($"argv[{i}] = {arg}");
                    i++;
                }
            }
            else
            {
                Console.WriteLine("Manual test application for WinArgv.");
                Console.WriteLine("Enter the literal args to pass and type DONE after your last argument:");

                var argv = new List<string>();
                var assemblyUri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
                var assemblyPath = Uri.UnescapeDataString(assemblyUri.AbsolutePath);
                argv.Add(assemblyPath);
                for (var i = 1; ; i++)
                {
                    Console.Write($"argv[{i}]: ");
                    var arg = Console.ReadLine();
                    if (arg == null)
                        continue;
                    if (arg.Equals("DONE"))
                        break;
                    argv.Add(arg);
                }

                var processStartInfo = ArgvParser.GetProcessStartInfo(argv);

                Console.WriteLine($"Command: {processStartInfo.FileName}");
                Console.WriteLine($"Arguments String: {processStartInfo.Arguments}");
                Console.WriteLine("");
                Console.WriteLine("Press any key...");
                Console.ReadKey();

                processStartInfo.CreateNoWindow = true;
                processStartInfo.LoadUserProfile = false;
                processStartInfo.UseShellExecute = false;
                processStartInfo.RedirectStandardOutput = true;

                var process = Process.Start(processStartInfo);
                if (process == null)
                {
                    Console.WriteLine("Process failed to start :(");
                }
                else
                {
                    while (!process.StandardOutput.EndOfStream)
                    {
                        Console.WriteLine(process.StandardOutput.ReadLine());
                    }
                    process.WaitForExit(1000);
                }

                Console.WriteLine("Press any key...");
                Console.ReadKey();
            }
        }
    }
}


text:
package pacman.entries.pacman;

import pacman.game.Game;

/**
 * Represents a task which runs every game tick.
 */
public interface GameTask
{
	/**
	 * Runs the task.
	 * @param game The current game state.
	 */
	void run(Game game);
}


text:
using System;
using Xwt.Drawing;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Xwt
{
	public class CellViewCollection: Collection<CellView>
	{
		ICellContainer parent;

		internal CellViewCollection (ICellContainer parent)
		{
			this.parent = parent;
		}

		protected override void InsertItem (int index, CellView item)
		{
			base.InsertItem (index, item);
			if (parent != null)
				parent.NotifyCellChanged ();
		}

		protected override void RemoveItem (int index)
		{
			base.RemoveItem (index);
			if (parent != null)
				parent.NotifyCellChanged ();
		}

		protected override void SetItem (int index, CellView item)
		{
			base.SetItem (index, item);
			if (parent != null)
				parent.NotifyCellChanged ();
		}

		protected override void ClearItems ()
		{
			base.ClearItems ();
			if (parent != null)
				parent.NotifyCellChanged ();
		}
	}
}


text:
namespace Microsoft.Azure.Management.CognitiveServices
{
    using Microsoft.Azure;
    using Microsoft.Azure.Management;
    using Microsoft.Rest;
    using Microsoft.Rest.Azure;
    using Models;
    using System.Collections;
    using System.Collections.Generic;
    using System.Threading;
    using System.Threading.Tasks;

    /// <summary>
    /// Extension methods for CheckSkuAvailabilityOperations.
    /// </summary>
    public static partial class CheckSkuAvailabilityOperationsExtensions
    {
            /// <summary>
            /// Check available SKUs.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='location'>
            /// Resource location.
            /// </param>
            /// <param name='skus'>
            /// The SKU of the resource.
            /// </param>
            /// <param name='kind'>
            /// The Kind of the resource. Possible values include: 'Academic',
            /// 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck',
            /// 'ComputerVision', 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face',
            /// 'LUIS', 'Recommendations', 'SpeakerRecognition', 'Speech',
            /// 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM'
            /// </param>
            /// <param name='type'>
            /// The Type of the resource.
            /// </param>
            public static CheckSkuAvailabilityResultList List(this ICheckSkuAvailabilityOperations operations, string location, IList<string> skus, string kind, string type)
            {
                return operations.ListAsync(location, skus, kind, type).GetAwaiter().GetResult();
            }

            /// <summary>
            /// Check available SKUs.
            /// </summary>
            /// <param name='operations'>
            /// The operations group for this extension method.
            /// </param>
            /// <param name='location'>
            /// Resource location.
            /// </param>
            /// <param name='skus'>
            /// The SKU of the resource.
            /// </param>
            /// <param name='kind'>
            /// The Kind of the resource. Possible values include: 'Academic',
            /// 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck',
            /// 'ComputerVision', 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face',
            /// 'LUIS', 'Recommendations', 'SpeakerRecognition', 'Speech',
            /// 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM'
            /// </param>
            /// <param name='type'>
            /// The Type of the resource.
            /// </param>
            /// <param name='cancellationToken'>
            /// The cancellation token.
            /// </param>
            public static async Task<CheckSkuAvailabilityResultList> ListAsync(this ICheckSkuAvailabilityOperations operations, string location, IList<string> skus, string kind, string type, CancellationToken cancellationToken = default(CancellationToken))
            {
                using (var _result = await operations.ListWithHttpMessagesAsync(location, skus, kind, type, null, cancellationToken).ConfigureAwait(false))
                {
                    return _result.Body;
                }
            }

    }
}


text:
package com.nextreme.lib;

/**
 * Created by huazhang on 10/26/15.
 */
public class Primes {
    static int [] knownPrimes = new int[4];

    // static initialize block
    static {
        knownPrimes[0] = 2;
        for( int i=1; i<knownPrimes.length; ++i ) {
            knownPrimes[i] = nextPrime();
        }
    }

    static int nextPrime() {
        return 0;
    }
}


text:
version="3.4.6"

# Do not change the first line as it is parsed by scripts

if __name__ == '__main__':
	import sys
	sys.stdout.write(version)


text:
<?php

namespace Hifone\Events\Pm;

use Hifone\Events\EventInterface;

interface PmEventInterface extends EventInterface
{
    //
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GSoft.Dynamite.Events;
using GSoft.Dynamite.Search.Contracts.Configuration;
using GSoft.Dynamite.Search.Contracts.Constants;

namespace GSoft.Dynamite.Search.Core.Configuration
{
    /// <summary>
    /// Event receivers configuration for the search module
    /// </summary>
    public class SearchEventReceiverInfoConfig : ISearchEventReceiverInfoConfig
    {
        /// <summary>
        /// Property that return all the event receivers to create or configure in the search module
        /// </summary>
        public IList<EventReceiverInfo> EventReceivers
        {
            // The collection in set by features depending on the solution type
            get { return new List<EventReceiverInfo>(); }
        }
    }
}


text:
set -e

export ContinuousIntegrationBuild=true

declare -r ROOT=$(realpath $(dirname $0)/..)
cd $ROOT

dotnet --info

dotnet build -c Release src/NodaTime.sln

dotnet test -c Release src/NodaTime.Test
dotnet test -c Release src/NodaTime.Demo

dotnet build -c Release src/NodaTime.TzdbCompiler
dotnet test -c Release src/NodaTime.TzdbCompiler.Test

# Run the tests under dotCover. (This is after the non-coverage tests,
# so that if there are any test failures we get those sooner.)
build/coverage.sh


text:
package org.wildfly.extension.camel.parser;

import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinition;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.registry.AttributeAccess.Flag;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelType;

/**
 * @author Thomas.Diesler@jboss.com
 * @since 23-Aug-2013
 */
final class CamelContextResource extends SimpleResourceDefinition {

    static final PathElement CONTEXT_PATH = PathElement.pathElement(ModelConstants.CONTEXT);
    static final SimpleAttributeDefinition VALUE = new SimpleAttributeDefinitionBuilder(ModelConstants.VALUE, ModelType.STRING)
            .addFlag(Flag.RESTART_NONE)
            .setAllowExpression(true)
            .build();

    CamelContextResource(SubsystemState subsystemState) {
        super(CONTEXT_PATH, CamelResolvers.getResolver("camel-context"), new CamelContextAdd(subsystemState), new CamelContextRemove(subsystemState));
    }

    @Override
    public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
        resourceRegistration.registerReadWriteAttribute(VALUE, null, CamelContextWrite.INSTANCE);
    }
}


text:
package com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.ModuleContainer.Component.Help;

import java.net.URL;

import com.google.security.zynamics.binnavi.Help.CHelpFunctions;
import com.google.security.zynamics.binnavi.Help.IHelpInformation;

/**
 * Context-sensitive help information for fields that show relocated module addresses.
 */
public final class CRelocatedAddressHelp implements IHelpInformation {
  @Override
  public String getText() {
    return "This field shows the relocated base address of the file in memory. Most of the time BinNavi automatically updates this value when you debug the target.";
  }

  @Override
  public URL getUrl() {
    return CHelpFunctions.urlify(CHelpFunctions.MAIN_WINDOW_FILE);
  }
}


text:
package org.apache.activemq.transport.nio;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.JmsDurableTopicSendReceiveTest;
import org.apache.activemq.broker.BrokerService;

public class NIOJmsDurableTopicSendReceiveTest extends JmsDurableTopicSendReceiveTest {

   protected BrokerService broker;

   @Override
   protected void setUp() throws Exception {
      if (broker == null) {
         broker = createBroker();
         broker.start();
      }
      super.setUp();
   }

   @Override
   protected void tearDown() throws Exception {
      super.tearDown();
      if (broker != null) {
         broker.stop();
      }
   }

   @Override
   protected ActiveMQConnectionFactory createConnectionFactory() {
      ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(getBrokerURL());
      return connectionFactory;
   }

   protected String getBrokerURL() {
      return "nio://localhost:61616";
   }

   protected BrokerService createBroker() throws Exception {
      BrokerService answer = new BrokerService();
      answer.setPersistent(false);
      answer.addConnector(getBrokerURL());
      return answer;
   }
}


text:
require 'mixlib/cli'

module Stressque
  class CLI
    include Mixlib::CLI

    option :config,
      short: "-c CONFIG",
      long:  "--config CONFIG",
      description: "The DSL config to use",
      required: true

    option :redis,
      short: "-r REDIS",
      long: "--redis REDIS",
      description: "The redis connection string",
      required: false
  end
end


text:
import * as CheckboxField from './checkbox-field';
import * as Form from './form';
import * as FormField from './field';
import * as InputField from './input-field';
import * as Select from './select';
import * as SelectField from './select-field';
import * as TextField from './text-field';

// core components
export { Form, FormField, Select };

// field components
export { CheckboxField, InputField, SelectField, TextField };


text:
var assert = require('assert');

var R = require('..');

describe('allPass', function() {
  var odd = function(n) { return n % 2 !== 0; };
  var lt20 = function(n) { return n < 20; };
  var gt5 = function(n) { return n > 5; };
  var plusEq = function(w, x, y, z) { return w + x === y + z; };

  it('reports whether all predicates are satisfied by a given value', function() {
    var ok = R.allPass([odd, lt20, gt5]);
    assert.strictEqual(ok(7), true);
    assert.strictEqual(ok(9), true);
    assert.strictEqual(ok(10), false);
    assert.strictEqual(ok(3), false);
    assert.strictEqual(ok(21), false);
  });

  it('returns true on empty predicate list', function() {
    assert.strictEqual(R.allPass([])(3), true);
  });

  it('returns a curried function whose arity matches that of the highest-arity predicate', function() {
    assert.strictEqual(R.allPass([odd, gt5, plusEq]).length, 4);
    assert.strictEqual(R.allPass([odd, gt5, plusEq])(9, 9, 9, 9), true);
    assert.strictEqual(R.allPass([odd, gt5, plusEq])(9)(9)(9)(9), true);
  });
});


text:
A command line interface to Pocket

# Requirements
* `bash`
* `curl`
* [jo](https://github.com/jpmens/jo)
* [jq](https://stedolan.github.io/jq/)

# Getting started

## Register a new Pocket application

* Open https://getpocket.com/developer/apps/new in a browser that's logged in to your Pocket account
* Fill out the form:
  - Give your application a unique name
  - Grant all permissions: Add, Modify, and Retrieve
  - For platform, choose "Desktop (other)"
  - Accept the Terms of Service and click "Create Application"
* Find your application's `consumer_key` listed on https://getpocket.com/developer/apps/

## Authorize your application

Run this:
```bash
curl \
  -d "consumer_key=$consumer_key" \
  -d "redirect_uri=pockesh:auth" \
  https://getpocket.com/v3/oauth/request
```

The output should read something like this:
```
code=abcdef01-2345-6789-abcd-ef0123
```

Take the value of `code` above and substitute it for `$code` in this URL:

```
https://getpocket.com/auth/authorize?request_token=$code&redirect_uri=https://github.com/drench/pockesh
```

Open the URL in a browser that is logged in to your Pocket account.
Click the "Authorize" button and you should get redirected back to this project's
Github page.

Run this command to complete the authorization process, substituting your
`consumer_key` and `code` values:

```bash
curl \
  -d "consumer_key=$consumer_key" \
  -d "code=$code" \
  https://getpocket.com/v3/oauth/authorize
```

The output should read something like this:
```
access_token=abcdef01-2345-6789-abcd-ef0123&username=yourname%40example.com
```

Create a file in your home directory called `.pocketrc` and save your codes in
it using this format:
```
consumer_key=01234-567890abcdef0123456789ab
access_token=abcdef01-2345-6789-abcd-ef0123
```

Put the `pocket-*` files somewhere in your `$PATH`. I like `~/bin`.

# Examples

Add a URL and tag it with `shell`:
```bash
pocket-add --url https://github.com/drench/pockesh --tags shell
```

Delete an item:
```bash
pocket-modify --action delete --item_id 1455241157
```

Get the URLs of all items tagged `longreads`, sorted by most recently added first:
```bash
pocket-get --tag longreads --sort-newest-first | jq '.list | .[] | .resolved_url'
```

Flag an item as a "favorite":
```bash
pocket-modify --action favorite --item_id 145416741
```

# For more information

https://getpocket.com/developer/docs/overview


text:
.panel-default.startPage {
    border-style: dashed;
    border-color: #a9a9a9;
    border-width:3px;
}

.busy-updating-wrapper {
   text-align: center;
   font-size: 20px;
   position: fixed;
   bottom: 0;
   right: 55px;
   z-index: 1;
}

.busy-submitting-wrapper {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    bottom: 0;
}

.dropzone h4.panel-title {
    height: 17px;
    overflow: hidden;
}

.container.admin-form {
    margin-top: 70px;
}

.public-form input, .public-form textarea {
	background-color: #000000;
    background-color: rgba(0,0,0,0);
    border: 2px dashed #ddd!important;
}

.public-form input:focus, .public-form textarea:focus {
    border: 2px dashed #ddd!important;
    outline: 0;
}

/*.public-form input.no-border.ng-invalid, .public-form textarea.no-border {
    border-color: none;
}*/
.public-form input.ng-valid, .public-form textarea.ng-valid {
	border-color: #20FF20!important;
	border-style: solid!important;
	border-width: 3px!important;
}

.public-form input.ng-invalid.ng-dirty, .public-form textarea.ng-invalid.ng-dirty {
	border-color: #FA787E!important;
	border-style: solid!important;
	border-width: 3px!important;
}

section.content p.breakwords {
    word-break: break-all;
}

.btn {
    border: 1px solid #c6c6c6;
}

.btn[type='submit'] {
    font-size: 1.5em;
    padding: 0.35em 1.2em 0.35em 1.2em;
}

section.content > section > section.container {
    margin-top: 70px;
}

/*
** Modal CSS Styles
*/
.modal-header {
    padding: 15px;
    border-bottom: 1px solid #e5e5e5;
    font-size: 18px;
    font-weight: normal;
}
.input-block {
    display: block;
    width: 100%;
}
.modal-footer input[type='text'] {
    min-height: 34px;
    padding: 7px 8px;
    font-size: 13px;
    color: #333;
    vertical-align: middle;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: right 8px center;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.075);
}
.modal-body > .modal-body-alert {
    color: #796620;
    background-color: #f8eec7;
    border-color: #f2e09a;
    margin: -16px -15px 15px;
    padding: 10px 15px;
    border-style: solid;
    border-width: 1px 0;
}

div.form-fields {
	position: relative;
	padding-top: 35vh;
}
.letter {
	position: relative;
    display: -moz-inline-stack;
    display: inline-block;
    vertical-align: top;
    zoom: 1;
    width: 16px;
    margin-top: 1px;
    padding: 0;
    height: 17px;
    font-size: 12px;
    line-height: 19px;
    border: 1px solid #000;
    border: 1px solid rgba(0,0,0,.2);
    margin-right: 7px;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
	text-align: center;
    font-weight: 700;
}

div.form-submitted > .field.row {
    padding-bottom: 2%;
    margin-top: 35vh;
}
div.form-submitted > .field.row > div {
    font-size: 1.7em;
}

/* Styles for accordion */
form .accordion-edit {
    width: inherit;
}

/*Styles for ui-datepicker*/
.ui-datepicker.ui-widget {
    z-index: 99!important;
}

form .row.field .field-number {
	margin-right: 0.5em;
}

/* Styles for form submission view (/forms/:formID) */
form .row.field {
    padding: 1em 0 0 0;
    width: inherit;
}
    form .row.field > .field-title {
        margin-top:0.5em;
        font-size:1.2em;
        padding-bottom: 1.8em;
        width: inherit;
    }
    form .row.field > .field-input {
        font-size: 1.4em;
        color: #777;
    }
    form.submission-form .row.field.statement > .field-title {
        font-size:1.7em;
    }
    form.submission-form .row.field.statement > .field-input {
        font-size:1em;
        color:#ddd;
    }

        form.submission-form .select.radio > .field-input input, form.submission-form .select > .field-input input {
            width:20%;
        }

        form.submission-form .field.row.radio .btn.activeBtn {
            background-color: rgb(0,0,0)!important;
            background-color: rgba(0,0,0,0.7)!important;
            color: white;
        }
        form.submission-form .field.row.radio .btn {
            margin-right:1.2em;
        }

        form.submission-form .select > .field-input .btn {
            text-align: left;
            margin-bottom:0.7em;
        }
        form.submission-form .select > .field-input .btn > span {
            font-size: 1.10em;
        }

        /*form.submission-form .field-input > input:focus {
            font-size:1em;
        }*/

        form .field-input > textarea{
            padding: 0.45em 0.9em;
            width: 100%;
            line-height: 160%;
        }

        form .field-input > input.hasDatepicker{
            padding: 0.45em 0.9em;
            width: 50%;
            line-height: 160%;
        }
        form .field-input > input.text-field-input{
            padding: 0.45em 0.9em;
            width: 100%;
            line-height: 160%;
        }
        form .required-error{
            color: #ddd;
            font-size:0.8em;
        }

    form .row.field.dropdown > .field-input input {
        min-height: 34px;
		border-width: 0 0 2px 0;
		border-radius: 5px;
    }

	form .row.field.dropdown > .field-input input:focus {
		border: none;
	}

	   	form .dropdown > .field-input .ui-select-choices-row-inner {
			border-radius: 3px;
			margin: 5px;
			padding: 10px;
			background-color: #000000;
			background-color: rgba(0,0,0,0.05);
		}

		form .dropdown > .field-input .ui-select-choices-row-inner.active, form .dropdown > .field-input .ui-select-choices-row-inner.active:focus {
			background-color: #000000;
			background-color: rgba(0,0,0,0.1);
        }
.config-form {
    max-width: 100%;
}

.config-form > .row {
    padding: 19px;
    margin-bottom: 20px;
    background-color: #f5f5f5;
    border: 1px solid #e3e3e3;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
    -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
}

div.config-form .row.field {
    padding-top:1.5em;
}

    div.config-form > .row > .container:nth-of-type(odd){
        border-right: 1px #ddd solid;
    }
    div.config-form.design > .row > .container:nth-of-type(odd){
        border-right: none;
    }

        div.config-form .row > .field-input {
            padding-left:0.1em;
        }
            div.config-form .row > .field-input label {
                padding-left:1.3em;
                display: block;
            }

/* Styles for form admin view (/forms/:formID/admin) */
.admin-form > .page-header {
    padding-bottom: 0;
    margin-bottom: 40px;
}
    .admin-form > .page-header h1 {
        margin-bottom: 0;
        margin-top: 0;
    }
    .admin-form > .page-header > .col-xs-3 {
        padding-top: 1.4em;
    }
.admin-form .form-controls .row {
    padding: 5px;
}
.admin-form .page-header {
    border: none;
}

/*Styles for admin view tabs */
.admin-form .tab-content {
    padding-top: 3em;
}

.admin-form .panel-heading {
    background-color: #f1f1f1;
	position: relative!important;
}
    .admin-form .panel-heading:hover {
        background-color: #fff;
        cursor: pointer;
    }
        .admin-form .panel-heading a:hover {
            text-decoration: none;
        }

.current-fields .panel-body .row.question input[type='text'], .current-fields .panel-body .row.description textarea{
    width: 100%;
}
.current-fields .panel-body .row.options input[type='text'] {
    width: 80%;
}

/*Override Select2 UI*/
.ui-select-choices.ui-select-dropdown {
	top:2.5em!important;
}
.ui-select-toggle {
	box-shadow:none!important;
	border:none!important;
}

.current-fields .tool-panel > .panel-default:hover {
    border-color: #9d9d9d;
    cursor: pointer;
}

.current-fields .tool-panel > .panel-default .panel-heading {
    background-color: #fff;
    color: #9d9d9d!important;
}
    .current-fields .tool-panel > .panel-default .panel-heading:hover {
        background-color: #eee;
        color: #000!important;
        cursor: pointer;
    }
.current-fields .tool-panel > .panel-default .panel-heading a {
    color: inherit;
}
.current-fields .tool-panel > .panel-default .panel-heading a:hover{
    text-decoration: none;
}

/*Styles for submission table*/
.submissions-table .table-outer.row {
    margin: 1.5em 0 2em 0!important;
}
.submissions-table .table-outer .col-xs-12 {
    padding-left: 0!important;
    border:1px solid #ddd;
    overflow-x: scroll;
    border-radius:3px;
}
.submissions-table .table > thead > tr > th {
    min-width:8em;
}
.submissions-table .table > tbody > tr.selected {
    background-color:#efefef;
}

/*Styles for add fields tab*/
.admin-form .add-field {
    background-color: #ddd;
    padding: 0 2% 0 2%;
    border-radius: 3px;
}
    .admin-form .add-field .col-xs-6 {
        padding: 0.25em 0.4em;
    }
        .admin-form .add-field .col-xs-6 .panel-heading {
            border-width: 1px;
            border-style: solid;
            border-color: #bbb;
            border-radius: 4px;
        }

        .admin-form .oscar-field-select {
            margin: 10px 0 10px;
        }

.view-form-btn.span {
    padding-right:0.6em;
}
.status-light.status-light-off {
    color: #BE0000;
}
.status-light.status-light-on {
    color: #33CC00;
}

/* Styles for form list view (/forms) */
section.public-form {
    padding: 0 10% 0 10%;
}
section.public-form .form-submitted {
    height: 100vh;
}

section.public-form .btn {
    border: 1px solid;
}

.form-item {
    text-align: center;
    border-bottom: 6px inset #ccc;
    background-color: #eee;
    width: 180px;
    /*width:100%;*/
    position: relative;
    height: 215px;
    /*padding-bottom: 25%;*/
    margin-bottom: 45px;
}
.form-item.create-new input[type='text']{
    width: inherit;
    color:black;
    border:none;
}

.form-item.create-new {
    background-color: rgb(131,131,131);
    color: white;
}

/*CREATE-NEW FORM MODAL*/
.form-item.new-form {
    background-color: rgb(300,131,131);
    z-index: 11;
}
.form-item.new-form:hover {
    background-color: rgb(300,100,100);
}
    .form-item.new-form input[type='text'] {
        margin-top:0.2em;
        width: inherit;
        color:black;
        border:none;
        padding: 0.3em 0.6em 0.3em 0.6em;
    }
    .form-item.new-form .custom-select {
        margin-top: 0.2em
    }
        .form-item.new-form .custom-select select {
            background-color: white;
        }

    .form-item.new-form .details-row {
        margin-top: 1em;
    }
    .form-item.new-form .details-row.submit {
        margin-top: 1.7em;
    }
        .form-item.new-form .details-row.submit .btn {
            font-size: 0.95em;
        }

    .form-item.new-form .title-row {
        margin-top: 1em;
        top:0;
    }

/*Modal overlay (for lightbox effect)*/
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: rgb(0,0,0);
    background-color: rgba(0,0,0,0.5);
    z-index: 10;
}
.overlay.submitform {
    background-color: rgb(256,256,256);
    background-color: rgba(256,256,256,0.8);
}
.field-directive {
    z-index: 9;
    padding: 10% 10% 10% 0;
    border: 25px transparent solid;
    position: relative;
}
.activeField {
    z-index: 11;
    position: relative;
    background-color: transparent;
}
.activeField.field-directive {
    display: inline-block;
    border-radius: 7px;
    width: 100%;
    border: 25px transparent solid;
}
	.activeField input {
		background-color: transparent;
	}

.form-item:hover, .form-item.create-new:hover {
    border-bottom: 8px inset #ccc;
    background-color: #d9d9d9;
}

.form-item.create-new:hover {
    background-color: rgb(81,81,81);
}

.form-item > .row.footer {
    position: absolute;
    bottom: 0;
    left: 30%;
}

.form-item .title-row{
    position: relative;
    top: 15px;
    padding-top:3em;
    padding-bottom:3.65em;
}
    .form-item .title-row h4 {
        font-size: 1.3em;
    }

.form-item.create-new  .title-row{
    padding: 0;
}
    .form-item.create-new  .title-row h4 {
        font-size: 7em;
    }

.form-item .details-row{
    margin-top: 3.2em;
}
    .form-item  .details-row small {
        font-size: 0.6em;
    }
    .form-item.create-new  .details-row small {
        font-size: 0.95em;
    }


text:
| Rendering | Repo Files | Source |
|-----------|------------|--------|
| ![Initial chessboard](board-init.svg) | [ASCII input](board-init.asc)
[SVG output](board-init.svg) | [Wikipedia: Chess](https://en.wikipedia.org/wiki/Chess) |
| ![Immortal Game chessboard](board-immortal.svg) | [ASCII input](board-immortal.asc)
[SVG output](board-immortal.svg) | [Wikipedia: Immortal Game](https://en.wikipedia.org/wiki/Immortal_Game) (last position) |
| ![Kasparov's Immortal chessboard](board-kasparov-immortal.svg) | [ASCII input](board-kasparov-immortal.asc)
[SVG output](board-karparov-immortal.svg) | [Wikipedia: Karparov's Immortal](https://en.wikipedia.org/wiki/Kasparov%27s_Immortal) (last position) |

## Drawings with Attack Graph

| Rendering | Repo Files | Source |
|-----------|------------|--------|
| ![Initial chessboard](graph-board-init.svg) | [ASCII input](board-init.asc)
[SVG output](board-init.svg) | [Wikipedia: Chess](https://en.wikipedia.org/wiki/Chess) |
| ![Immortal Game chessboard](graph-board-immortal.svg) | [ASCII input](board-immortal.asc)
[SVG output](board-immortal.svg) | [Wikipedia: Immortal Game](https://en.wikipedia.org/wiki/Immortal_Game) (last position) |
| ![Kasparov's Immortal chessboard](graph-board-kasparov-immortal.svg) | [ASCII input](board-kasparov-immortal.asc)
[SVG output](board-karparov-immortal.svg) | [Wikipedia: Karparov's Immortal](https://en.wikipedia.org/wiki/Kasparov%27s_Immortal) (last position) |

## Mapping

* [CoffeeScript mapping file](map.coffee) and equivalent
  [JavaScript mapping file](map.jsx), illustrating:
  * Computing the square parity to automatically shade dark squares
  * Using `require` to load and modify external SVG files
    (strip off unnecessary `<svg>` wrapper)
  * JSX notation for creating and composing symbols
  * `svgtiler.background` for rendering a background white rectangle
* [CoffeeScript file](graph.coffee) for rendering the graph of attacks,
  illustrating more advanced `export postprocess` usage.

## Piece Shapes

Piece shapes are defined by unmodified SVGs from
[Wikimedia's Standard chess diagrams](https://commons.wikimedia.org/wiki/Standard_chess_diagram),
authored by [Cburnett](https://commons.wikimedia.org/wiki/User:Cburnett)
(Colin M.L. Burnett)
and licensed under [BSD license](https://opensource.org/licenses/BSD-3-Clause)
(among other licenses).

| Image | Repo file | Wikimedia link |
|-------|-----------|----------------|
| ![](Chess_bdt45.svg) | [Chess_bdt45.svg](Chess_bdt45.svg) | [Chess_bdt45.svg](https://commons.wikimedia.org/wiki/File:Chess_bdt45.svg) |
| ![](Chess_blt45.svg) | [Chess_blt45.svg](Chess_blt45.svg) | [Chess_blt45.svg](https://commons.wikimedia.org/wiki/File:Chess_blt45.svg) |
| ![](Chess_kdt45.svg) | [Chess_kdt45.svg](Chess_kdt45.svg) | [Chess_kdt45.svg](https://commons.wikimedia.org/wiki/File:Chess_kdt45.svg) |
| ![](Chess_klt45.svg) | [Chess_klt45.svg](Chess_klt45.svg) | [Chess_klt45.svg](https://commons.wikimedia.org/wiki/File:Chess_klt45.svg) |
| ![](Chess_ndt45.svg) | [Chess_ndt45.svg](Chess_ndt45.svg) | [Chess_ndt45.svg](https://commons.wikimedia.org/wiki/File:Chess_ndt45.svg) |
| ![](Chess_nlt45.svg) | [Chess_nlt45.svg](Chess_nlt45.svg) | [Chess_nlt45.svg](https://commons.wikimedia.org/wiki/File:Chess_nlt45.svg) |
| ![](Chess_pdt45.svg) | [Chess_pdt45.svg](Chess_pdt45.svg) | [Chess_pdt45.svg](https://commons.wikimedia.org/wiki/File:Chess_pdt45.svg) |
| ![](Chess_plt45.svg) | [Chess_plt45.svg](Chess_plt45.svg) | [Chess_plt45.svg](https://commons.wikimedia.org/wiki/File:Chess_plt45.svg) |
| ![](Chess_qdt45.svg) | [Chess_qdt45.svg](Chess_qdt45.svg) | [Chess_qdt45.svg](https://commons.wikimedia.org/wiki/File:Chess_qdt45.svg) |
| ![](Chess_qlt45.svg) | [Chess_qlt45.svg](Chess_qlt45.svg) | [Chess_qlt45.svg](https://commons.wikimedia.org/wiki/File:Chess_qlt45.svg) |
| ![](Chess_rdt45.svg) | [Chess_rdt45.svg](Chess_rdt45.svg) | [Chess_rdt45.svg](https://commons.wikimedia.org/wiki/File:Chess_rdt45.svg) |
| ![](Chess_rlt45.svg) | [Chess_rlt45.svg](Chess_rlt45.svg) | [Chess_rlt45.svg](https://commons.wikimedia.org/wiki/File:Chess_rlt45.svg) |


text:
layout: default
title: Projects
bodyid: products
cotype: products-content
projects:
- name: Otto 0.3
  hook: Define Rack-apps in plain-text
  link: http://github.com/delano/otto/
  desc: "Apps build with Otto have three, basic parts: a rackup file, a ruby file, and a routes file. If you've built a Rack app before, then you've seen a rackup file before. The ruby file is your actual app and the routes file is what Otto uses to map URI paths to a Ruby method."
- name: Rye 0.9
  hook: Safe, parallel SSH from Ruby
  link: http://github.com/delano/rye/
  desc: Safely run SSH commands on a bunch of machines at the same time (from Ruby).
- name: Gibbler 0.8
  hook: Git-like hashes and history for Ruby objects
  link: http://github.com/delano/gibbler/
  desc: Gibbler creates SHA1 digests of your Ruby objects so you can easily tell when changes have been made. You can also "commit" objects to revert or retrieve them later.
- name: Tryouts 2.1
  hook: Put your tests in the comments.
  link: http://github.com/delano/tryouts/
  desc: Tryouts allows you to put your test expectations into comments so your test scripts look like sample code.
- name: Bone 0.3
  hook: Remote environment variables
  link: http://github.com/solutious/bone/
  desc: Bone is a command-line tool and Ruby library that acts just like environment variables. However, because the values are stored remotely, they can be accessed from any machine, anywhere. There's a Redis API and a REST API that securely signs each request using a secret (based on the one used by AWS).
- name: Familia 0.7
  hook: A helper library for Redis.
  link: http://github.com/delano/familia/
  desc: Familia helps organize data stored in Redis.
- name: Bluth 0.7
  hook: Simple, redis queuing.
  link: http://github.com/delano/bluth/
  desc: A Redis queuing system built on top of Familia
- name: Storable 0.8
  hook: Marshal Ruby classes into and out of multiple formats (yaml, json, csv, tsv)
  link: http://github.com/delano/storable/
  desc: It's cool to output an object as YAML or JSON.
- name: Sysinfo 0.7
  hook: Basic, platform-specific, system information
  link: http://github.com/delano/sysinfo/
  desc: "SysInfo takes a very quick glance at the system it's running on and exposes the results as YAML, JSON, CSV, or TSV. It also determines a platform identifier for the system that takes the form: VM-OS-IMPLEMENTATION-ARCHITECTURE (e.g. ruby-unix-osx-x86_64)."
- name: Annoy 0.5
  hook: Like your annoying friend that asks you questions all the time.
  link: http://github.com/delano/annoy/
  desc: Annoy helps you ask questions and simple, interactive questions on the command-line.
- name: Attic 0.4
  hook: A place for Ruby objects to hide instance variables
  link: http://github.com/delano/attic/
  desc: A small hack based on _why's metaid.rb which stores instance variables in a Ruby object's metaclass.
- name: Drydock 0.6
  hook: Build seaworthy command-line apps like a Captain with a powerful Ruby DSL.
  link: http://github.com/delano/drydock/
  desc: Drydock is a seaworthy DSL for building really powerful command line applications.
- name: Caesars 0.7
  hook: Rapid and delicious DSL prototyping in Ruby
  link: http://github.com/delano/caesars/
  desc: Start writing and refining your domain specific languages without worrying about the implementation.
---

				Stella 0.8

FANCY A TEST?

Blame Stella for breaking your web application

					Now in public beta
					Follow on GitHub

Stella is an agile testing tool for web applications. Software development has changed in a way that demands a new kind of toolset. Stella integrates quickly into your existing development process to help you run functional and performance tests throughout your product lifecycle.

				Rudy 0.9

TO THE SERVERS, PLEASE!

Not your grandparents' EC2 deployment tool

					Now in public beta
					Follow on GitHub

Rudy is a development and deployment tool for Amazon EC2. Define infrastructure and processes using a powerful Ruby DSL* and Rudy takes care of the rest (like creating security groups and keypairs).

* domain specific language

			OTHER PROJECTS

			{% for project in page.projects limit:10 %}

    	  {{ project.name }}
  			{{ project.hook }}

{{ project.desc }}

      {% endfor %}


text:
import {join} from 'path';
import {getGlobalVariable} from '../utils/env';
import { exec, npm } from '../utils/process';
import {updateJsonFile} from '../utils/project';

const packages = require('../../../lib/packages').packages;

export default function() {
  const argv = getGlobalVariable('argv');

  if (argv.nobuild) {
    return;
  }
  if (!argv.devkit) {
    return;
  }

  return exec(`${argv.devkit}/bin/devkit-admin`, 'build', '--local');
}


text:
package com.rasterfoundry.common.ast

import java.util.UUID

trait RFMLRaster extends Serializable {
  def id: UUID
}


text:
import React from 'react';
import TypographyElement from './TypographyElement';

const defaultProps = {
  component: 'p',
};

const Body1 = props => (
  <TypographyElement
    modificator="body1"
    {...props}
  />
);

Body1.defaultProps = defaultProps;
export default Body1;


text:
<?php

	// Initialize WTCBB.
	require('./includes/init.inc.php');

	// What are they wanting to do?
	switch($_REQUEST['action'])
	{
		case 'openthread':
		{
			OpenThread((int)$_REQUEST['threadid']);
		}

		case 'closethread':
		{
			CloseThread((int)$_REQUEST['threadid']);
		}

		case 'stickthread':
		{
			StickThread((int)$_REQUEST['threadid']);
		}

		case 'unstickthread':
		{
			UnStickThread((int)$_REQUEST['threadid']);
		}

		case 'deletethread':
		{
			DeleteThread((int)$_REQUEST['threadid']);
		}

		case 'deleteposts':
		{
			DeletePosts((int)$_REQUEST['threadid']);
		}

		case 'movethread':
		{
			MoveThread((int)$_REQUEST['threadid']);
		}

		case 'getip':
		{
			GetIP();
		}
	}

// *************************************************************************** \\

// Opens the specified thread.
function OpenThread($iThreadID)
{
	global $CFG, $dbConn;

	// Do they have permission to open/close threads?
	if(!$_SESSION['permissions']['cmopenclosethreads'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// Get some information on the thread.
	$dbConn->query("SELECT closed FROM thread WHERE id={$iThreadID}");
	if(!(list($bIsClosed) = $dbConn->getresult()))
	{
		// Thread does not exist.
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Is the thread already open?
	if(!$bIsClosed)
	{
		Msg("The specified thread is already open.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
	}

	// Open the thread.
	$dbConn->query("UPDATE thread SET closed=0 WHERE id={$iThreadID}");

	// Render page.
	Msg("The thread has been successfully opened.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
}

// *************************************************************************** \\

// Closes the specified thread.
function CloseThread($iThreadID)
{
	global $CFG, $dbConn;

	// Do they have permission to open/close threads?
	if(!$_SESSION['permissions']['cmopenclosethreads'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// Get some information on the thread.
	$dbConn->query("SELECT closed FROM thread WHERE id={$iThreadID}");
	if(!(list($bIsClosed) = $dbConn->getresult()))
	{
		// Thread does not exist.
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Is the thread already closed?
	if($bIsClosed)
	{
		Msg("The specified thread is already closed.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
	}

	// Close the thread.
	$dbConn->query("UPDATE thread SET closed=1 WHERE id={$iThreadID}");

	// Render page.
	Msg("The thread has been successfully closed.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
}

// *************************************************************************** \\

// Makes the specified thread sticky.
function StickThread($iThreadID)
{
	global $CFG, $dbConn;

	// Do they have permission to stick/unstick threads?
	if(!$_SESSION['permissions']['cmstickythreads'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// Get some information on the thread.
	$dbConn->query("SELECT sticky FROM thread WHERE id={$iThreadID}");
	if(!(list($bIsSticky) = $dbConn->getresult()))
	{
		// Thread does not exist.
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Is the thread already sticky?
	if($bIsSticky)
	{
		Msg("The specified thread is already sticky.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
	}

	// Make the thread sticky.
	$dbConn->query("UPDATE thread SET sticky=1 WHERE id={$iThreadID}");

	// Render page.
	Msg("The thread has been successfully stuck.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
}

// *************************************************************************** \\

// Makes the specified thread not sticky.
function UnStickThread($iThreadID)
{
	global $CFG, $dbConn;

	// Do they have permission to stick/unstick threads?
	if(!$_SESSION['permissions']['cmstickythreads'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// Get some information on the thread.
	$dbConn->query("SELECT sticky FROM thread WHERE id={$iThreadID}");
	if(!(list($bIsSticky) = $dbConn->getresult()))
	{
		// Thread does not exist.
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Is the thread already sticky?
	if(!$bIsSticky)
	{
		Msg("The specified thread is not sticky.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
	}

	// Unstick the thread.
	$dbConn->query("UPDATE thread SET sticky=0 WHERE id={$iThreadID}");

	// Render page.
	Msg("The thread has been successfully unstuck.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
}

// *************************************************************************** \\

// User wants to delete a thread.
function DeleteThread($iThreadID)
{
	global $CFG, $dbConn;

	// Do they have permission to delete threads?
	if(!$_SESSION['permissions']['cmdeletethreads'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// What forum is this thread in? What is its title?
	$dbConn->query("SELECT title, parent FROM thread WHERE id={$iThreadID}");
	if(!(list($strThreadTitle, $iForumID) = $dbConn->getresult()))
	{
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Are they submitting?
	if(($_REQUEST['submit'] == 'Delete Now') && ((bool)$_REQUEST['delete']))
	{
		// Yes, do that now.
		DeleteThreadNow($iThreadID, $iForumID);
	}

	// Get the forum name as well as the ID and name of the category the thread belongs to.
	$dbConn->query("SELECT board.name, cat.id, cat.name FROM board INNER JOIN board AS cat ON (board.parent = cat.id) WHERE board.id={$iForumID}");
	list($strForumName, $iCategoryID, $strCategoryName) = $dbConn->getresult();

	// Template
	require("./skins/{$CFG['skin']}/deletethread.tpl.php");

	// Send the page.
	exit;
}

// Deletes a specified thread.
function DeleteThreadNow($iThreadID, $iForumID)
{
	global $CFG, $dbConn;

	// Get a list of all posts in the thread.
	$dbConn->query("SELECT id, author FROM post WHERE parent={$iThreadID}");
	while(list($iPostID, $iAuthorID) = $dbConn->getresult())
	{
		// Save the post in the list to delete.
		$aPosts[] = $iPostID;

		// Increment the author's postcount of this thread.
		$aPostCounts[$iAuthorID]++;
	}
	$strPostIDs = implode(', ', $aPosts);

	// Subtract from the users' postcounts the number of posts they had in the thread.
	foreach($aPostCounts as $iAuthorID => $iPostCount)
	{
		$dbConn->query("UPDATE citizen SET postcount=postcount-{$iPostCount} WHERE id={$iAuthorID}");
	}

	// Delete the posts' records, the thread's record, and any attachments.
	$dbConn->query("DELETE FROM post WHERE parent={$iThreadID}");
	$dbConn->query("DELETE FROM thread WHERE id={$iThreadID}");
	$dbConn->query("DELETE FROM attachment WHERE parent IN ({$strPostIDs})");
	$dbConn->query("DELETE FROM poll WHERE id={$iThreadID}");
	$dbConn->query("DELETE FROM pollvote WHERE parent={$iThreadID}");

	// Remove all searchindexes for the posts.
	$dbConn->query("DELETE FROM searchindex WHERE postid IN ({$strPostIDs})");

	// Get the total number of posts we've deleted.
	$iPostCount = count($aPosts);

	// Update the forum's post and thread counts.
	$dbConn->query("UPDATE board SET postcount=postcount-{$iPostCount}, threadcount=threadcount-1 WHERE id={$iForumID}");

	// Update the forum stats.
	$dbConn->query("UPDATE stats SET content=content-{$iPostCount} WHERE name='postcount'");
	$dbConn->query("UPDATE stats SET content=content-1 WHERE name='threadcount'");

	// Update the forum's statistics.
	UpdateForumStats($iForumID);

	// Render the page.
	Msg("The thread has been successfully deleted.

You should be redirected to the forum momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "forumdisplay.php?forumid={$iForumID}");
}

// *************************************************************************** \\

// User wants to delete posts from a thread.
function DeletePosts($iThreadID)
{
	global $CFG, $dbConn;

	// Constants
	define('AUTHOR',    0);
	define('POSTDATE',  1);
	define('BODY',      2);

	// Do they have permission to delete posts?
	if(!$_SESSION['permissions']['cmdeleteposts'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// What forum is this thread in? What is its title?
	$dbConn->query("SELECT title, parent FROM thread WHERE id={$iThreadID}");
	if(!(list($strThreadTitle, $iForumID) = $dbConn->getresult()))
	{
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Are they submitting?
	if($_REQUEST['submit'] == 'Delete Posts')
	{
		// Yes, do that now.
		DeletePostsNow($iThreadID, $iForumID, (array)$_REQUEST['postid']);
	}

	// Get the forum name as well as the ID and name of the category the thread belongs to.
	$dbConn->query("SELECT board.name, cat.id, cat.name FROM board INNER JOIN board AS cat ON (board.parent = cat.id) WHERE board.id={$iForumID}");
	list($strForumName, $iCategoryID, $strCategoryName) = $dbConn->getresult();

	// Get the information of each post and poster in this thread.
	$dbConn->query("SELECT post.id, post.author, post.datetime_posted, post.body, citizen.username FROM post LEFT JOIN citizen ON (post.author = citizen.id) WHERE post.parent={$iThreadID} ORDER BY post.datetime_posted ASC");
	while($aSQLResult = $dbConn->getresult(TRUE))
	{
		// Store the post information into the Master array.
		$iPostID = $aSQLResult['id'];
		$aPosts[$iPostID][AUTHOR] = $aSQLResult['author'];
		$aPosts[$iPostID][POSTDATE] = $aSQLResult['datetime_posted'];
		$aPosts[$iPostID][BODY] = substr($aSQLResult['body'], 0, 128);

		// Add some ellipses if the conditions are right.
		if(strlen($aSQLResult['body']) > 128)
		{
			if(strpos($aSQLResult['body'], ' ', 128))
			{
				$aPosts[$iPostID][BODY] = "{$aPosts[$iPostID][BODY]}...";
			}
		}

		// Store the member's username.
		if(!isset($aUsernames[$aPosts[$iPostID][AUTHOR]]))
		{
			$aUsernames[$aPosts[$iPostID][AUTHOR]] = $aSQLResult['username'];
		}
	}

	// Template
	require("./skins/{$CFG['skin']}/deleteposts.tpl.php");

	// Send the page.
	exit;
}

// Deletes specified posts.
function DeletePostsNow($iThreadID, $iForumID, $aPosts)
{
	global $dbConn;

	// Are there any posts to delete?
	if(!count($aPosts))
	{
		Msg("No posts specified for deletion.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
	}

	// Sanitize the elements of the array, and then convert it into a string.
	$strPostIDs = implode(', ', array_map('intval', $aPosts));
	unset($aPosts);

	// Filter out any posts that aren't in this thread.
	$dbConn->query("SELECT id, author FROM post WHERE id IN ({$strPostIDs}) AND parent={$iThreadID}");
	while(list($iPostID, $iAuthorID) = $dbConn->getresult())
	{
		// Save the post in the list to delete.
		$aPosts[] = $iPostID;

		// Increment the author's postcount of this thread.
		$aPostCounts[$iAuthorID]++;
	}

	// Are there still some posts to delete?
	if(!is_array($aPosts))
	{
		Msg("No posts specified for deletion.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
	}
	$strPostIDs = implode(', ', $aPosts);

	// Get the thread's root.
	$dbConn->query("SELECT post.id FROM post LEFT JOIN thread ON (post.parent = thread.id) WHERE thread.id={$iThreadID} ORDER BY post.datetime_posted ASC LIMIT 1");
	list($iRootID) = $dbConn->getresult();

	// Is one of the posts we'll be deleting the root post?
	// (Are we deleting the thread?)
	if(in_array($iRootID, $aPosts))
	{
		// Yes. Subtract from the users' postcounts the number of total posts they had in the thread.
		$dbConn->query("SELECT author, COUNT(post.id) FROM post WHERE post.parent={$iThreadID} GROUP BY author");
		$aSQLAllResults = $dbConn->getall();
		while(list($key, $aPostCount) = each($aSQLAllResults))
		{
			list($iAuthorID, $iPostCount) = $aPostCount;
			$dbConn->query("UPDATE citizen SET postcount=postcount-{$iPostCount} WHERE id={$iAuthorID}");

			// Add it to the total deleted postcount.
			$iTotalCount = $iTotalCount + $iPostCount;
		}

		// Delete the posts' records, the thread's record, and any attachments.
		$dbConn->query("DELETE FROM post WHERE parent={$iThreadID}");
		$dbConn->query("DELETE FROM thread WHERE id={$iThreadID}");
		$dbConn->query("DELETE FROM attachment WHERE parent IN ({$strPostIDs})");
		$dbConn->query("DELETE FROM poll WHERE id={$iThreadID}");
		$dbConn->query("DELETE FROM pollvote WHERE parent={$iThreadID}");

		// Delete all search indexes for the posts.
		$dbConn->query("DELETE FROM searchindex WHERE postid IN ({$strPostIDs})");

		// Update the forum's post and thread counts.
		$dbConn->query("UPDATE board SET postcount=postcount-{$iTotalCount}, threadcount=threadcount-1 WHERE id={$iForumID}");

		// Update the forum stats.
		$dbConn->query("UPDATE stats SET content=content-{$iTotalCount} WHERE name='postcount'");
		$dbConn->query("UPDATE stats SET content=content-1 WHERE name='threadcount'");

		// Set the redirect page.
		$strRedirect = "forumdisplay.php?forumid={$iForumID}";
	}
	else
	{
		// No. Subtract from the users' postcounts the number of posts they had in the thread which are marked for deletion.
		foreach($aPostCounts as $iAuthorID => $iPostCount)
		{
			$dbConn->query("UPDATE citizen SET postcount=postcount-{$iPostCount} WHERE id={$iAuthorID}");
		}

		// Get the number of attachments that we'll be deleting.
		$dbConn->query("SELECT COUNT(*) FROM attachment WHERE parent IN ({$strPostIDs})");
		list($iAttachmentCount) = $dbConn->getresult();

		// Delete the posts' record and any attachments.
		$dbConn->query("DELETE FROM post WHERE id IN ({$strPostIDs})");
		$dbConn->query("DELETE FROM attachment WHERE parent IN ({$strPostIDs})");

		// Delete all search indexes for the post.
		$dbConn->query("DELETE FROM searchindex WHERE postid IN ({$strPostIDs})");

		// Get the total number of posts we've deleted.
		$iPostCount = count($aPosts);

		// Update the forum's post count.
		$dbConn->query("UPDATE board SET postcount=postcount-{$iPostCount} WHERE id={$iForumID}");

		// Update the forum stats.
		$dbConn->query("UPDATE stats SET content=content-{$iPostCount} WHERE name='postcount'");

		// Get the post date and author ID of the new last post of the thread.
		$dbConn->query("SELECT post.datetime_posted, post.author FROM post LEFT JOIN thread ON (post.parent = thread.id) WHERE thread.id={$iThreadID} ORDER BY post.datetime_posted DESC LIMIT 1");
		list($tLastPost, $iNewLastPoster) = $dbConn->getresult();

		// Update the thread's record.
		$dbConn->query("UPDATE thread SET lpost={$tLastPost}, lposter={$iNewLastPoster}, postcount=postcount-{$iPostCount}, attachcount=attachcount-{$iAttachmentCount} WHERE id={$iThreadID}");

		// Set the redirect page.
		$strRedirect = "thread.php?threadid={$iThreadID}";
	}

	// Update the forum's statistics.
	UpdateForumStats($iForumID);

	// Render the page.
	Msg("The posts have been successfully deleted.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", $strRedirect);
}

// *************************************************************************** \\

// User wants to move or copy the specified thread to another forum.
function MoveThread($iThreadID)
{
	global $CFG, $dbConn;

	// Do they have permission to move/copy threads?
	if(!$_SESSION['permissions']['cmovethreads'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// Are they submitting?
	if(isset($_REQUEST['submit']))
	{
		// What method do they want to use?
		switch((int)$_REQUEST['method'])
		{
			// Move thread
			case 0:
			{
				MoveThreadNow($iThreadID);
			}

			// Move thread with redirect
			case 1:
			{
				// TODO
				break;
			}

			// Copy thread
			case 2:
			{
				CopyThreadNow($iThreadID);
			}

			default:
			{
				Msg('You must specify whether to move or copy the thread.');
			}
		}
	}

	// Get the thread's title and its parent.
	$dbConn->query("SELECT title, parent FROM thread WHERE id={$iThreadID}");
	if(!(list($strThreadTitle, $iForumID) = $dbConn->getresult()))
	{
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Get the information of each forum.
	list($aCategory, $aForum) = GetForumInfo();

	// Get the name of the category and forum the thread is in.
	$iCategoryID = $aForum[$iForumID][0];
	$strCategoryName = $aCategory[$iCategoryID];
	$strForumName = $aForum[$iForumID][1];

	// Template
	require("./skins/{$CFG['skin']}/movecopythread.tpl.php");

	// Send the page.
	exit;
}

// Moves the specified thread to another forum.
function MoveThreadNow($iThreadID)
{
	global $CFG, $dbConn;

	// What (destination) forum do they want to move it to?
	$iDestinationID = (int)$_REQUEST['forumid'];

	// Get the thread's parent (source) and its postcount.
	$dbConn->query("SELECT parent, postcount FROM thread WHERE id={$iThreadID}");
	if(!(list($iSourceID, $iPostCount) = $dbConn->getresult()))
	{
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Make sure the destination isn't the same as the source.
	if($iSourceID == $iDestinationID)
	{
		Msg("You cannot move a thread to a forum it's already in.");
	}

	// Make sure the destination is valid (exists and isn't a category).
	$dbConn->query("SELECT displaydepth FROM board WHERE id={$iDestinationID}");
	if(!(list($iLevel) = $dbConn->getresult()))
	{
		Msg('The destination forum you specified does not exist.');
	}
	else if($iLevel == 0)
	{
		Msg('The destination forum you specified cannot contain posts. Please select a different forum.');
	}

	// Move the thread, i.e. change the thread's parent.
	$dbConn->query("UPDATE thread SET parent={$iDestinationID} WHERE id={$iThreadID}");

	// Update the forums' post and thread counts.
	$dbConn->query("UPDATE board SET postcount=postcount-{$iPostCount}, threadcount=threadcount-1 WHERE id={$iSourceID}");
	$dbConn->query("UPDATE board SET postcount=postcount+{$iPostCount}, threadcount=threadcount+1 WHERE id={$iDestinationID}");

	// Update the source and destination forums' stats.
	UpdateForumStats($iSourceID);
	UpdateForumStats($iDestinationID);

	// Render page.
	Msg("The thread has been moved successfully.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iThreadID}");
}

// Copies the specified thread (and all its posts, attachments, and polls) to another forum.
// (Let me know if you have a better way of doing all of this. ;D)
function CopyThreadNow($iThreadID)
{
	global $CFG, $dbConn;

	// What forum do they want to copy it to?
	$iDestinationID = (int)$_REQUEST['forumid'];

	// Get the thread's information.
	$dbConn->query("SELECT * FROM thread WHERE thread.id={$iThreadID}");
	if(!($aThreadInfo = $dbConn->getresult(TRUE)))
	{
		Msg("Invalid thread specified.{$CFG['msg']['invalidlink']}");
	}

	// Make sure the destination isn't the same as the parent.
	if($aThreadInfo['parent'] == $iDestinationID)
	{
		Msg("You cannot copy a thread to a forum it's already in.");
	}

	// Make sure the destination is valid (exists and isn't a category).
	$dbConn->query("SELECT displaydepth FROM board WHERE id={$iDestinationID}");
	if(!(list($iLevel) = $dbConn->getresult()))
	{
		Msg('The destination forum you specified does not exist.');
	}
	else if($iLevel == 0)
	{
		Msg('The destination forum you specified cannot contain posts. Please select a different forum.');
	}

	// Get a list of the posts in the thread.
	$dbConn->query("SELECT id, author FROM post WHERE parent={$iThreadID}");
	while(list($iPostID, $iAuthorID) = $dbConn->getresult())
	{
		// Save the post to the list.
		$aPosts[] = $iPostID;

		// Increment the author's postcount of this thread.
		$aPostCounts[$iAuthorID]++;
	}
	$strPosts = implode(', ', $aPosts);

	// Sanitize some thread fields.
	$aThreadInfo['title'] = $dbConn->sanitize($aThreadInfo['title']);
	$aThreadInfo['description'] = $dbConn->sanitize($aThreadInfo['description']);
	$aThreadInfo['notes'] = $dbConn->sanitize($aThreadInfo['notes']);
	$aThreadInfo['poll'] = (int)(bool)$aThreadInfo['poll'];

	// Copy the thread record (but keep it closed and invisible until we're done).
	$dbConn->query("INSERT INTO thread(title, description, parent, viewcount, postcount, attachcount, lpost, lposter, icon, author, notes, poll, closed, visible, sticky) VALUES('{$aThreadInfo['title']}', '{$aThreadInfo['description']}', {$iDestinationID}, {$aThreadInfo['viewcount']}, {$aThreadInfo['postcount']}, {$aThreadInfo['attachcount']}, {$aThreadInfo['lpost']}, {$aThreadInfo['lposter']}, {$aThreadInfo['icon']}, {$aThreadInfo['author']}, '{$aThreadInfo['notes']}', {$aThreadInfo['poll']}, 1, 0, {$aThreadInfo['sticky']})");

	// What is the ID of the thread we just created?
	$iNewThreadID = $dbConn->getinsertid('thread');

	// Get a list of the attachments in this thread.
	$dbConn->query("SELECT id, parent FROM attachment WHERE parent IN ({$strPosts})");
	while(list($iAttachmentID, $iParentID) = $dbConn->getresult())
	{
		$aAttachments[$iAttachmentID] = $iParentID;
	}

	// Copy all of the post records.
	$dbConn->query("SELECT * FROM post WHERE parent={$iThreadID}");
	$aSQLAllResults = $dbConn->getall(TRUE);
	while(list($key, $aPostInfo) = each($aSQLAllResults))
	{
		// Convert data types, if necessary.
		if($aPostInfo['datetime_edited'] === NULL)
		{
			$aPostInfo['datetime_edited'] = 'NULL';
		}
		if($aPostInfo['ipaddress'] === NULL)
		{
			$aPostInfo['ipaddress'] = 'NULL';
		}

		// Sanitize some post fields.
		$strTitle = $aPostInfo['title'];
		$strBody = $aPostInfo['body'];
		$aPostInfo['title'] = $dbConn->sanitize($aPostInfo['title']);
		$aPostInfo['body'] = $dbConn->sanitize($aPostInfo['body']);

		// Insert the copy of the post.
		$dbConn->query("INSERT INTO post(author, datetime_posted, datetime_edited, title, body, parent, ipaddress, icon, dsmilies) VALUES({$aPostInfo['author']}, {$aPostInfo['datetime_posted']}, {$aPostInfo['datetime_edited']}, '{$aPostInfo['title']}', '{$aPostInfo['body']}', {$iNewThreadID}, {$aPostInfo['ipaddress']}, {$aPostInfo['icon']}, {$aPostInfo['dsmilies']})");

		// Get the ID of the post we just created.
		$iPostID = $dbConn->getinsertid('post');

		// Now let's add the message into the search engine index.
		AddSearchIndex($iPostID, $strTitle, $strBody);

		// Store the attachments the post has (if any).
		if(is_array($aAttachments))
		{
			// Did the original post contain any attachments?
			$temp = array_keys($aAttachments, $aPostInfo['id']);
			if(is_array($temp))
			{
				// Yes, so save them.
				foreach($temp as $iAttachmentID)
				{
					$aAttachments[$iAttachmentID] = $iPostID;
				}
			}
		}
	}

	// Copy all of the attachment records.
	if(is_array($aAttachments))
	{
		$dbConn->query("SELECT * FROM attachment WHERE parent IN ({$strPosts})");
		$aSQLAllResults = $dbConn->getall(TRUE);
		while(list($key, $aAttachmentInfo) = each($aSQLAllResults))
		{
			// What is the new post ID that will be the parent of this new attachment?
			$iParentID = $aAttachments[$aAttachmentInfo['id']];

			// Break the file data into an array of 64KB strings.
			$aData = sqlsplit($aAttachmentInfo['filedata'], 65536);

			// Sanitize the filename.
			$aAttachmentInfo['filename'] = $dbConn->sanitize($aAttachmentInfo['filename']);

			// Insert the duplicate attachment's record.
			$dbConn->query("INSERT INTO attachment(filename, filedata, viewcount, parent) VALUES('{$aAttachmentInfo['filename']}', '{$aData[0]}', {$aAttachmentInfo['viewcount']}, {$iParentID})");
			$iAttachmentID = $dbConn->getinsertid('attachment');
			unset($aData[0]);

			// Insert the rest of the attachment's data.
			foreach($aData as $strData)
			{
				$dbConn->squery(CONCAT_ATTACHMENT, $strData, $iAttachmentID);
			}

			// Reset the data array for the next attachment.
			unset($aData);
		}
	}

	// Copy the poll, if there is one.
	if($aThreadInfo['poll'])
	{
		CopyPoll($iThreadID, $iNewThreadID);
	}

	// Add to the users' postcounts the number of posts they had in the original thread.
	foreach($aPostCounts as $iAuthorID => $iPostCount)
	{
		$dbConn->query("UPDATE citizen SET postcount=postcount+{$iPostCount} WHERE id={$iAuthorID}");
	}

	// Give the new thread life.
	$dbConn->query("UPDATE thread SET closed={$aThreadInfo['closed']}, visible={$aThreadInfo['visible']} WHERE id={$iNewThreadID}");

	// Get the total number of posts we've copied/added.
	$iPostCount = count($aPosts);

	// Update the destination forum's post and thread counts.
	$dbConn->query("UPDATE board SET postcount=postcount+{$iPostCount}, threadcount=threadcount+1 WHERE id={$iDestinationID}");

	// Update the forum stats.
	$dbConn->query("UPDATE stats SET content=content+{$iPostCount} WHERE name='postcount'");
	$dbConn->query("UPDATE stats SET content=content+1 WHERE name='threadcount'");

	// Update the destination forum's stats.
	UpdateForumStats($iDestinationID);

	// Render page.
	Msg("The thread has been copied successfully.

You should be redirected momentarily. Click here if you do not want to wait any longer or if you are not redirected.", "thread.php?threadid={$iNewThreadID}");
}

// Copies a poll (and all votes) of a thread to another thread.
function CopyPoll($iSourceID, $iDestinationID)
{
	global $dbConn;

	// Get the poll's information.
	$dbConn->query("SELECT * FROM poll WHERE id={$iSourceID}");
	$aPollInfo = $dbConn->getresult(TRUE);

	// Sanitize the poll's information.
	$aPollInfo['question'] = $dbConn->sanitize($aPollInfo['question']);
	$aPollInfo['answers'] = $dbConn->sanitize($aPollInfo['answers']);

	// Insert a copy of the poll's record.
	$dbConn->query("INSERT INTO poll(id, datetime, question, answers, multiplechoices, timeout) VALUES({$iDestinationID}, {$aPollInfo['datetime']}, '{$aPollInfo['question']}', '{$aPollInfo['answers']}', {$aPollInfo['multiplechoices']}, {$aPollInfo['timeout']})");

	// Now we need to copy all of the votes for the poll.
	$dbConn->query("SELECT * FROM pollvote WHERE parent={$iSourceID}");
	$aSQLAllResults = $dbConn->getall(TRUE);
	while(list($key, $aPollInfo) = each($aSQLAllResults))
	{
		$dbConn->query("INSERT INTO pollvote(parent, ownerid, vote, votedate) VALUES({$iDestinationID}, {$aPollInfo['ownerid']}, {$aPollInfo['vote']}, {$aPollInfo['votedate']})");
	}
}

// *************************************************************************** \\

// Gets the IP of a specified post or private message.
function GetIP()
{
	global $CFG, $dbConn;

	// Are they authorized to view IP addresses?
	if(!$_SESSION['permissions']['cviewips'])
	{
		// No, so give them the bad news.
		Unauthorized();
	}

	// What do they want to get an IP address of?
	if(isset($_REQUEST['postid']))
	{
		// Post
		$iPostID = (int)$_REQUEST['postid'];
		$strWhat = 'post';

		// Get the IP address and thread ID of the post.
		$dbConn->query("SELECT ipaddress, parent FROM post WHERE id={$iPostID}");
		if(!(list($iIP, $iThreadID) = $dbConn->getresult()))
		{
			// Invalid post specified.
			Msg("Invalid post specified.{$CFG['msg']['invalidlink']}");
		}
		$strIP = long2ip($iIP);
		$strBackURL = "thread.php?threadid={$iThreadID}&postid={$iPostID}#post{$iPostID}";
	}
	else if(isset($_REQUEST['messageid']))
	{
		// Private message
		$iMessageID = (int)$_REQUEST['messageid'];
		$strWhat = 'PM';
		$strBackURL = "private.php?action=viewmessage&id={$iMessageID}";

		// Get the IP address of the PM.
		$dbConn->query("SELECT ipaddress FROM pm WHERE id={$iMessageID}");
		if(!(list($iIP) = $dbConn->getresult()))
		{
			// Invalid PM specified.
			Msg("Invalid PM specified.{$CFG['msg']['invalidlink']}");
		}
		$strIP = long2ip($iIP);
	}
	else
	{
		// Nothing was specified.
		Msg('You must specify a post or PM for which to get an IP address.');
	}

	// Was there an IP address stored with the post/PM?
	if($iIP === NULL)
	{
		// Nope.
		Msg("No IP address was stored with the specified {$strWhat}. If you believe this is an error, please notify the Webmaster.");
	}

	// Get the information of each forum.
	list($aCategory, $aForum) = GetForumInfo();

	// Template
	require("./skins/{$CFG['skin']}/getip.tpl.php");

	// Send the page.
	exit;
}
?>


text:
package com.jeremyworboys.incDecValue;

import com.intellij.openapi.editor.Caret;

/**
 * Created by jeremyworboys on 18/01/15.
 */
public class StringAdjuster extends Adjuster
{
    protected Boolean doTransform(Amount action, Caret caret)
    {
        if (action == Amount.INC_ALL || action == Amount.DEC_ALL) {
            return false;
        }

        String newWord;
        String word = caret.getSelectedText();
        assert word != null;

        switch (action) {
            case INC_MIN:
                newWord = Character.isUpperCase(word.charAt(0))
                        ? word.toUpperCase()
                        : Character.toString(word.charAt(0)).toUpperCase() + word.substring(1);
                break;
            case DEC_MIN:
                newWord = word.toUpperCase().equals(word)
                        ? Character.toString(word.charAt(0)).toUpperCase() + word.substring(1).toLowerCase()
                        : word.toLowerCase();
                break;
            case INC_MAX:
                newWord = word.toUpperCase();
                break;
            case DEC_MAX:
                newWord = word.toLowerCase();
                break;
            default:
                newWord = word;
        }

        if (!newWord.equals(word)) {
            replaceSelection(caret, newWord);
        }

        return true;
    }
}


text:
@interface PodsDummy_Pods_ZXKit_Example : NSObject
@end
@implementation PodsDummy_Pods_ZXKit_Example
@end