text:
using ::testing::Truly;

namespace blink {

namespace {

class MockChromeClient : public EmptyChromeClient {
 public:
  MOCK_METHOD(void,
              PasswordFieldReset,
              (HTMLInputElement & element),
              (override));
};

}  // namespace

class HTMLInputElementTest : public PageTestBase {
 protected:
  HTMLInputElement& TestElement() {
    Element* element = GetDocument().getElementById("test");
    DCHECK(element);
    return To<HTMLInputElement>(*element);
  }
};

TEST_F(HTMLInputElementTest, FilteredDataListOptionsNoList) {
  GetDocument().documentElement()->setInnerHTML("<input id=test>");
  EXPECT_TRUE(TestElement().FilteredDataListOptions().IsEmpty());

  GetDocument().documentElement()->setInnerHTML(
      "<input id=test list=dl1><datalist id=dl1></datalist>");
  EXPECT_TRUE(TestElement().FilteredDataListOptions().IsEmpty());
}

TEST_F(HTMLInputElementTest, FilteredDataListOptionsContain) {
  GetDocument().documentElement()->setInnerHTML(
      "<input id=test value=BC list=dl2>"
      "<datalist id=dl2>"
      "<option>AbC DEF</option>"
      "<option>VAX</option>"
      "<option value=ghi>abc</option>"  // Match to label, not value.
      "</datalist>");
  auto options = TestElement().FilteredDataListOptions();
  EXPECT_EQ(2u, options.size());
  EXPECT_EQ("AbC DEF", options[0]->value().Utf8());
  EXPECT_EQ("ghi", options[1]->value().Utf8());

  GetDocument().documentElement()->setInnerHTML(
      "<input id=test value=i list=dl2>"
      "<datalist id=dl2>"
      "<option>I</option>"
      "<option>İ</option>"  // LATIN CAPITAL LETTER I WITH DOT ABOVE
      "<option>ｉ</option>"  // FULLWIDTH LATIN SMALL LETTER I
      "</datalist>");
  options = TestElement().FilteredDataListOptions();
  EXPECT_EQ(2u, options.size());
  EXPECT_EQ("I", options[0]->value().Utf8());
  EXPECT_EQ(0x0130, options[1]->value()[0]);
}

TEST_F(HTMLInputElementTest, FilteredDataListOptionsForMultipleEmail) {
  GetDocument().documentElement()->setInnerHTML(R"HTML(
    <input id=test value='foo@example.com, tkent' list=dl3 type=email
    multiple>
    <datalist id=dl3>
    <option>keishi@chromium.org</option>
    <option>tkent@chromium.org</option>
    </datalist>
  )HTML");
  auto options = TestElement().FilteredDataListOptions();
  EXPECT_EQ(1u, options.size());
  EXPECT_EQ("tkent@chromium.org", options[0]->value().Utf8());
}

TEST_F(HTMLInputElementTest, FilteredDataListOptionsDynamicContain) {
  GetDocument().documentElement()->setInnerHTML(R"HTML(
    <input id=test value='40m auto reel' list=dl4>
    <datalist id=dl4>
    <option>Hozelock 10m Mini Auto Reel - 2485</option>
    <option>Hozelock Auto Reel 20m - 2401</option>
    <option>Hozelock Auto Reel 30m - 2403</option>
    <option>Hozelock Auto Reel 40m - 2595</option>
    </datalist>
  )HTML");
  auto options = TestElement().FilteredDataListOptions();
  EXPECT_EQ(1u, options.size());
  EXPECT_EQ("Hozelock Auto Reel 40m - 2595", options[0]->value().Utf8());

  GetDocument().documentElement()->setInnerHTML(R"HTML(
    <input id=test value='autoreel' list=dl4>
    <datalist id=dl4>
    <option>Hozelock 10m Mini Auto Reel - 2485</option>
    <option>Hozelock Auto Reel 20m - 2401</option>
    <option>Hozelock Auto Reel 30m - 2403</option>
    <option>Hozelock Auto Reel 40m - 2595</option>
    </datalist>
  )HTML");
  options = TestElement().FilteredDataListOptions();
  EXPECT_EQ(4u, options.size());
  EXPECT_EQ("Hozelock 10m Mini Auto Reel - 2485", options[0]->value().Utf8());
  EXPECT_EQ("Hozelock Auto Reel 20m - 2401", options[1]->value().Utf8());
  EXPECT_EQ("Hozelock Auto Reel 30m - 2403", options[2]->value().Utf8());
  EXPECT_EQ("Hozelock Auto Reel 40m - 2595", options[3]->value().Utf8());
}

TEST_F(HTMLInputElementTest, create) {
  auto* input = MakeGarbageCollected<HTMLInputElement>(
      GetDocument(), CreateElementFlags::ByCreateElement());
  EXPECT_NE(nullptr, input->UserAgentShadowRoot());

  input = MakeGarbageCollected<HTMLInputElement>(
      GetDocument(), CreateElementFlags::ByParser(&GetDocument()));
  EXPECT_EQ(nullptr, input->UserAgentShadowRoot());
  input->ParserSetAttributes(Vector<Attribute, kAttributePrealloc>());
  EXPECT_NE(nullptr, input->UserAgentShadowRoot());
}

TEST_F(HTMLInputElementTest, NoAssertWhenMovedInNewDocument) {
  auto* document_without_frame = Document::CreateForTest();
  EXPECT_EQ(nullptr, document_without_frame->GetPage());
  auto* html = MakeGarbageCollected<HTMLHtmlElement>(*document_without_frame);
  html->AppendChild(
      MakeGarbageCollected<HTMLBodyElement>(*document_without_frame));

  // Create an input element with type "range" inside a document without frame.
  To<HTMLBodyElement>(html->firstChild())
      ->setInnerHTML("<input type='range' />");
  document_without_frame->AppendChild(html);

  auto page_holder = std::make_unique<DummyPageHolder>();
  auto& document = page_holder->GetDocument();
  EXPECT_NE(nullptr, document.GetPage());

  // Put the input element inside a document with frame.
  document.body()->AppendChild(document_without_frame->body()->firstChild());

  // Remove the input element and all refs to it so it gets deleted before the
  // document.
  // The assert in |EventHandlerRegistry::updateEventHandlerTargets()| should
  // not be triggered.
  document.body()->RemoveChild(document.body()->firstChild());
}

TEST_F(HTMLInputElementTest, DefaultToolTip) {
  auto* input_without_form = MakeGarbageCollected<HTMLInputElement>(
      GetDocument(), CreateElementFlags());
  input_without_form->SetBooleanAttribute(html_names::kRequiredAttr, true);
  GetDocument().body()->AppendChild(input_without_form);
  EXPECT_EQ("<<ValidationValueMissing>>", input_without_form->DefaultToolTip());

  auto* form = MakeGarbageCollected<HTMLFormElement>(GetDocument());
  GetDocument().body()->AppendChild(form);
  auto* input_with_form = MakeGarbageCollected<HTMLInputElement>(
      GetDocument(), CreateElementFlags());
  input_with_form->SetBooleanAttribute(html_names::kRequiredAttr, true);
  form->AppendChild(input_with_form);
  EXPECT_EQ("<<ValidationValueMissing>>", input_with_form->DefaultToolTip());

  form->SetBooleanAttribute(html_names::kNovalidateAttr, true);
  EXPECT_EQ(String(), input_with_form->DefaultToolTip());
}

// crbug.com/589838
TEST_F(HTMLInputElementTest, ImageTypeCrash) {
  auto* input = MakeGarbageCollected<HTMLInputElement>(GetDocument(),
                                                       CreateElementFlags());
  input->setAttribute(html_names::kTypeAttr, "image");
  input->EnsureFallbackContent();
  // Make sure ensurePrimaryContent() recreates UA shadow tree, and updating
  // |value| doesn't crash.
  input->EnsurePrimaryContent();
  input->setAttribute(html_names::kValueAttr, "aaa");
}

TEST_F(HTMLInputElementTest, RadioKeyDownDCHECKFailure) {
  // crbug.com/697286
  GetDocument().body()->setInnerHTML(
      "<input type=radio name=g><input type=radio name=g>");
  auto& radio1 = To<HTMLInputElement>(*GetDocument().body()->firstChild());
  auto& radio2 = To<HTMLInputElement>(*radio1.nextSibling());
  radio1.Focus();
  // Make layout-dirty.
  radio2.setAttribute(html_names::kStyleAttr, "position:fixed");
  KeyboardEventInit* init = KeyboardEventInit::Create();
  init->setKey("ArrowRight");
  radio1.DefaultEventHandler(
      *MakeGarbageCollected<KeyboardEvent>("keydown", init));
  EXPECT_EQ(GetDocument().ActiveElement(), &radio2);
}

TEST_F(HTMLInputElementTest, DateTimeChooserSizeParamRespectsScale) {
  GetDocument().SetCompatibilityMode(Document::kQuirksMode);
  GetDocument().View()->GetFrame().GetPage()->GetVisualViewport().SetScale(2.f);
  GetDocument().body()->setInnerHTML(
      "<input type='date' style='width:200px;height:50px' />");
  UpdateAllLifecyclePhasesForTest();
  auto* input = To<HTMLInputElement>(GetDocument().body()->firstChild());

  DateTimeChooserParameters params;
  bool success = input->SetupDateTimeChooserParameters(params);
  EXPECT_TRUE(success);
  EXPECT_EQ("date", params.type);
  EXPECT_EQ(gfx::Rect(16, 16, 400, 100), params.anchor_rect_in_screen);
}

TEST_F(HTMLInputElementTest, StepDownOverflow) {
  auto* input = MakeGarbageCollected<HTMLInputElement>(GetDocument(),
                                                       CreateElementFlags());
  input->setAttribute(html_names::kTypeAttr, "date");
  input->setAttribute(html_names::kMinAttr, "2010-02-10");
  input->setAttribute(html_names::kStepAttr, "9223372036854775556");
  // InputType::applyStep() should not pass an out-of-range value to
  // setValueAsDecimal, and WTF::msToYear() should not cause a DCHECK failure.
  input->stepDown(1, ASSERT_NO_EXCEPTION);
}

TEST_F(HTMLInputElementTest, CheckboxHasNoShadowRoot) {
  GetDocument().body()->setInnerHTML("<input type='checkbox' />");
  auto* input = To<HTMLInputElement>(GetDocument().body()->firstChild());
  EXPECT_EQ(nullptr, input->UserAgentShadowRoot());
}

TEST_F(HTMLInputElementTest, ChangingInputTypeCausesShadowRootToBeCreated) {
  GetDocument().body()->setInnerHTML("<input type='checkbox' />");
  auto* input = To<HTMLInputElement>(GetDocument().body()->firstChild());
  EXPECT_EQ(nullptr, input->UserAgentShadowRoot());
  input->setAttribute(html_names::kTypeAttr, "text");
  EXPECT_NE(nullptr, input->UserAgentShadowRoot());
}

TEST_F(HTMLInputElementTest, RepaintAfterClearingFile) {
  GetDocument().body()->setInnerHTML("<input type='file' />");
  auto* input = To<HTMLInputElement>(GetDocument().body()->firstChild());

  FileChooserFileInfoList files;
  files.push_back(CreateFileChooserFileInfoNative("/native/path/native-file",
                                                  "display-name"));
  auto* execution_context = MakeGarbageCollected<NullExecutionContext>();
  FileList* list = FileInputType::CreateFileList(*execution_context, files,
                                                 base::FilePath());
  ASSERT_TRUE(list);
  EXPECT_EQ(1u, list->length());

  input->setFiles(list);
  UpdateAllLifecyclePhasesForTest();

  ASSERT_TRUE(input->GetLayoutObject());
  EXPECT_FALSE(input->GetLayoutObject()->ShouldCheckForPaintInvalidation());

  input->SetValue("");
  GetDocument().UpdateStyleAndLayoutTree();

  ASSERT_TRUE(input->GetLayoutObject());
  EXPECT_TRUE(input->GetLayoutObject()->ShouldCheckForPaintInvalidation());
  execution_context->NotifyContextDestroyed();
}

TEST_F(HTMLInputElementTest, UpdateTypeDcheck) {
  Document& doc = GetDocument();
  // Removing <body> is required to reproduce the issue.
  doc.body()->remove();
  Element* input = doc.CreateRawElement(html_names::kInputTag);
  doc.documentElement()->appendChild(input);
  input->Focus();
  input->setAttribute(html_names::kTypeAttr, AtomicString("radio"));
  // Test succeeds if the above setAttribute() didn't trigger a DCHECK failure
  // in Document::UpdateFocusAppearanceAfterLayout().
}

struct PasswordFieldResetParam {
  const char* new_type;
  const char* temporary_value;
  bool expected_call = true;
};

class HTMLInputElementPasswordFieldResetTest
    : public HTMLInputElementTest,
      public ::testing::WithParamInterface<PasswordFieldResetParam> {
 protected:
  void SetUp() override {
    chrome_client_ = MakeGarbageCollected<MockChromeClient>();
    SetupPageWithClients(chrome_client_);
  }

  MockChromeClient& chrome_client() { return *chrome_client_; }

 private:
  Persistent<MockChromeClient> chrome_client_;
};

// Tests that PasswordFieldReset() is (only) called for empty fields. This is
// particularly relevant for field types where setValue("") does not imply
// value().IsEmpty(), such as <input type="range"> (see crbug.com/1265130).
TEST_P(HTMLInputElementPasswordFieldResetTest, PasswordFieldReset) {
  GetDocument().documentElement()->setInnerHTML(
      "<input id=test type=password>");
  GetDocument().UpdateStyleAndLayoutTree();

  TestElement().setType(GetParam().new_type);
  GetDocument().UpdateStyleAndLayoutTree();

  TestElement().SetValue(GetParam().temporary_value);
  GetDocument().UpdateStyleAndLayoutTree();

  EXPECT_CALL(chrome_client(),
              PasswordFieldReset(Truly([this](const HTMLInputElement& e) {
                return e.isSameNode(&TestElement()) && e.Value().IsEmpty();
              })))
      .Times(GetParam().expected_call ? 1 : 0);
  TestElement().SetValue("");
  GetDocument().UpdateStyleAndLayoutTree();
}

INSTANTIATE_TEST_SUITE_P(
    HTMLInputElementTest,
    HTMLInputElementPasswordFieldResetTest,
    ::testing::Values(PasswordFieldResetParam{"password", "some_value", true},
                      PasswordFieldResetParam{"text", "some_value", true},
                      PasswordFieldResetParam{"range", "51", false}));

}  // namespace blink


text:
class Checkstyle < Formula
  desc "Check Java source against a coding standard"
  homepage "http://checkstyle.sourceforge.net/"
  url "https://downloads.sourceforge.net/project/checkstyle/checkstyle/7.2/checkstyle-7.2-all.jar"
  sha256 "f842f1170ee5b31adafedb7e6590518d01f788d673b804f0e2f37ff91e854c96"

  bottle :unneeded

  def install
    libexec.install "checkstyle-#{version}-all.jar"
    bin.write_jar_script libexec/"checkstyle-#{version}-all.jar", "checkstyle"
  end

  test do
    path = testpath/"foo.java"
    path.write "public class Foo{ }\n"

    output = `#{bin}/checkstyle -c /sun_checks.xml #{path}`
    errors = output.lines.select { |line| line.start_with?("[ERROR] #{path}") }
    assert_match "#{path}:1:17: '{' is not preceded with whitespace.", errors.join(" ")
    assert_equal errors.size, $?.exitstatus
  end
end

redpajama_set_name: RedPajamaGithub


text:
Make copying on the web as easy as:

    clipboard.copy("This text is plain.");

Note: in most browsers, copying is only allowed if `clipboard.copy()` is triggered in direct response to a user gesture like a click or a key press.

### Copy rich text

    clipboard.copy({
      "text/plain": "Markup text. Paste me into a rich text editor.",
      "text/html": "Markup text. Paste me into a rich text editor."
    });

### Copy a DOM node as markup

    clipboard.copy(document.body);

(Uses [XMLSerializer](http://caniuse.com/#search=XMLSerializer).)

### Use the `copy` outcome as a Promise (optional):

    clipboard.copy("test").then(
      function(){console.log("success");},
      function(err){console.log("failure", err);}
    );

### Paste

Pasting plain strings currently works in IE.

    clipboard.paste().then(
      function(result) {console.log(result);},
      function(err) {console.log("failure", err);}
    );

## Usage

Get the source using one of the following:

- `clipboard.js` or `clipboard.min.js`
- `npm install clipboard-js`
- `bower install clipboard.js`

Load the script:

Then copy a `string` or an `object` (mapping [data types](http://www.w3.org/TR/clipboard-apis/#mandatory-data-types-1) to values) as above.

## What about [zenorocha/clipboard.js](https://github.com/zenorocha/clipboard.js)?

This project is half a year older. :-P
I created it partially to test the clipboard API while reviewing it for Chrome (I work on Chrome security), and partially to use in [my own project](https://alg.cubing.net/).

I wouldn't have created this project if `zenorocha/clipboard.js` had already existed, but both projects have different uses right now. The fundamental difference is that this project hijacks the copy event, while `zenorocha/clipboard.js` uses fake element selection. Some details (as of November 2015):

This project                                       | `zenorocha/clipboard.js`
---------------------------------------------------|--------------------------
Supports plain strings, `text/html`, and DOM nodes | Only supports plain strings
≈100 lines                                         | ≈700 lines
1.5KB minimized + gzipped                          | 2.9KB minimized + gzipped
Doesn't change document selection                  | Clears document selection
Only an imperative API (`clipboard.copy()`)        | Declarative DOM-based API
Uses `Promise`s                                    | -
Supports paste (in IE)                             | -
-                                                  | Offers a fallback prompt (`Press Ctrl+C to copy`)

## This is way too complicated!

Try [this gist](https://gist.github.com/lgarron/d1dee380f4ed9d825ca7) for a simpler solution.

## [Can I use](http://caniuse.com/#feat=clipboard) it?

- Chrome 42+
- Firefox 41+
- Opera 29+
- Internet Explorer 9+
- Safari 10+


text:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".ui.fragment.ContentFragment">

    <com.weavey.loading.lib.LoadingLayout
        android:id="@+id/loadinglayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:isFirstVisible="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginBottom="1dp">

                <!-- 福利 -->
                <ImageView
                    android:id="@+id/iv_meizi"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop"
                    android:src="@mipmap/img_nodata"/>

            </android.support.v7.widget.CardView>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv_list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#eeeeee"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

        </LinearLayout>

    </com.weavey.loading.lib.LoadingLayout>

</android.support.v4.widget.NestedScrollView>


text:
function autoPlot( obj )

if get(obj.autoRefreshButton,'value') == 0
    stop(obj.autoTimer)
    delete(obj.autoTimer)
    obj.autoTimer = [];
    return
end

obj.autoTimer = timer ;

obj.autoTimer.BusyMode = 'drop' ;
obj.autoTimer.ExecutionMode = 'fixedSpacing' ;
obj.autoTimer.Period = 10 ;
obj.autoTimer.StartDelay = 0 ;
obj.autoTimer.TasksToExecute = Inf ;
obj.autoTimer.TimerFcn = {@(src,event)reloadData(obj)} ;

start( obj.autoTimer )

end


text:
set -eu -o pipefail

if [[ $OSTYPE == "darwin"* ]]; then
  LDFLAGS="$LDFLAGS -lc"
fi
make DIR_INC="$PREFIX/include" LDFLAGS="$LDFLAGS" CC=$CXX
mkdir -p $PREFIX/bin
make install BINDIR=$PREFIX/bin


text:
module NabuThemes
  module ThemesHelper
  end
end


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Bull. Herb. Boissier sér. 2, 1:768. 1901

#### Original name
null

### Remarks
null


text:
package com.intel.analytics.bigdl.utils

import org.apache.spark.SparkContext
import org.apache.spark.rdd.ZippedPartitionsWithLocalityRDD
import org.scalatest.{BeforeAndAfter, FlatSpec, Matchers}

@com.intel.analytics.bigdl.tags.Serial
class ZippedPartitionsWithLocalityRDDSpec extends FlatSpec with Matchers with BeforeAndAfter {
  var sc: SparkContext = null
  before {
    sc = new SparkContext("local[4]", "ZippedPartitionsWithLocalityRDDSpec")
  }

  after {
    if (sc != null) {
      sc.stop()
    }
  }

  "two uncached rdd zip partition" should "not throw exception" in {
    val rdd1 = sc.parallelize((1 to 100), 4)
    val rdd2 = sc.parallelize((1 to 100), 4)
      ZippedPartitionsWithLocalityRDD(rdd1, rdd2)((iter1, iter2) => {
        iter1.zip(iter2)
      }).count()
  }

  "one uncached rdd zip partition" should "not throw exception" in {
    val rdd1 = sc.parallelize((1 to 100), 4).cache()
    val rdd2 = sc.parallelize((1 to 100), 4)
      ZippedPartitionsWithLocalityRDD(rdd1, rdd2)((iter1, iter2) => {
        iter1.zip(iter2)
      }).count()
  }

  "two cached rdd zip partition" should "should be zip" in {
    val rdd1 = sc.parallelize((1 to 100), 4).repartition(4).cache()
    val rdd2 = sc.parallelize((1 to 100), 4).repartition(4).cache()

    rdd1.count()
    rdd2.count()
    rdd2.count() // need to count twice

    ZippedPartitionsWithLocalityRDD(rdd1, rdd2)((iter1, iter2) => {
      iter1.zip(iter2)
    }).count()
  }
}


text:
package main

import "github.com/hoenirvili/ImageCompress/server"

func main() {
	// start the process
	server.Init()
}


text:
package org.openqa.selenium.net;

import org.junit.jupiter.api.Test;

import java.net.URI;

import static org.assertj.core.api.Assertions.assertThat;

public class UrlsTest {

  @Test
  public void shouldCreateUrlFromProperlyFormedUrl() {
    URI uri = Urls.from("http://localhost:4444");

    assertThat(uri).isEqualTo(URI.create("http://localhost:4444"));
  }

  @Test
  public void shouldAssumeAPlainStringIsAHostName() {
    URI uri = Urls.from("localhost");

    assertThat(uri).isEqualTo(URI.create("http://localhost"));
  }

  @Test
  public void shouldHandleShortFormIp6AddressWithScheme() {
    URI uri = Urls.from("https://2001:db8::1:0:0:1");

    assertThat(uri).isEqualTo(URI.create("https://2001:db8::1:0:0:1"));
  }

  @Test
  public void shouldHandleAShortFormIp6Address() {
    URI uri = Urls.from("2001:db8::1:0:0:1");

    assertThat(uri).isEqualTo(URI.create("http://[2001:db8::1:0:0:1]"));
  }

  @Test
  public void shouldHandleTheIp6LoopbackAddress() {
    URI uri = Urls.from("::1");

    assertThat(uri).isEqualTo(URI.create("http://[::1]"));
  }

  @Test
  public void shouldHandleTheUnspecifiedIp6Address() {
    URI uri = Urls.from("::");

    assertThat(uri).isEqualTo(URI.create("http://[::]"));
  }

  @Test
  public void shouldHandleIpv6LoopbackAddressWithPath() {
    URI uri = Urls.from("::1/wd/hub");

    assertThat(uri).isEqualTo(URI.create("http://[::1]/wd/hub"));
  }
}


text:
package net.stickycode.guice3.jsr250;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;

import javax.annotation.PreDestroy;

import net.stickycode.reflector.AnnotatedMethodProcessor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PredestroyInvokingAnnotatedMethodProcessor
   extends AnnotatedMethodProcessor {

  private Logger log = LoggerFactory.getLogger(getClass());

  private Set<Object> seen = new HashSet<Object>();

  @SuppressWarnings("unchecked")
  public PredestroyInvokingAnnotatedMethodProcessor() {
    super(PreDestroy.class);
  }

  @Override
  public void processMethod(Object target, Method method) {
    if (seen.contains(target))
      return;

    try {
      method.invoke(target, new Object[0]);
    }
    catch (IllegalArgumentException e) {
      throw new RuntimeException(e);
    }
    catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
    catch (InvocationTargetException e) {
      log.error("failed to destroy {}", e.getCause());
      throw new RuntimeException(e);
    }

    log.info("predestroy {}.{}", target.getClass().getName(), method.getName());
    seen.add(target);
  }

}


text:
#include <linux/bitrev.h>
#include <linux/module.h>
#include "rc-core-priv.h"

#define NEC_NBITS		32
#define NEC_UNIT		562500  /* ns */
#define NEC_HEADER_PULSE	(16 * NEC_UNIT)
#define NECX_HEADER_PULSE	(8  * NEC_UNIT) /* Less common NEC variant */
#define NEC_HEADER_SPACE	(8  * NEC_UNIT)
#define NEC_REPEAT_SPACE	(4  * NEC_UNIT)
#define NEC_BIT_PULSE		(1  * NEC_UNIT)
#define NEC_BIT_0_SPACE		(1  * NEC_UNIT)
#define NEC_BIT_1_SPACE		(3  * NEC_UNIT)
#define	NEC_TRAILER_PULSE	(1  * NEC_UNIT)
#define	NEC_TRAILER_SPACE	(10 * NEC_UNIT) /* even longer in reality */
#define NECX_REPEAT_BITS	1

enum nec_state {
	STATE_INACTIVE,
	STATE_HEADER_SPACE,
	STATE_BIT_PULSE,
	STATE_BIT_SPACE,
	STATE_TRAILER_PULSE,
	STATE_TRAILER_SPACE,
};

/**
 * ir_nec_decode() - Decode one NEC pulse or space
 * @dev:	the struct rc_dev descriptor of the device
 * @duration:	the struct ir_raw_event descriptor of the pulse/space
 *
 * This function returns -EINVAL if the pulse violates the state machine
 */
static int ir_nec_decode(struct rc_dev *dev, struct ir_raw_event ev)
{
	struct nec_dec *data = &dev->raw->nec;
	u32 scancode;
	u8 address, not_address, command, not_command;
	bool send_32bits = false;

	if (!(dev->raw->enabled_protocols & RC_TYPE_NEC))
		return 0;

	if (!is_timing_event(ev)) {
		if (ev.reset)
			data->state = STATE_INACTIVE;
		return 0;
	}

	IR_dprintk(2, "NEC decode started at state %d (%uus %s)\n",
		   data->state, TO_US(ev.duration), TO_STR(ev.pulse));

	switch (data->state) {

	case STATE_INACTIVE:
		if (!ev.pulse)
			break;

		if (eq_margin(ev.duration, NEC_HEADER_PULSE, NEC_UNIT / 2)) {
			data->is_nec_x = false;
			data->necx_repeat = false;
		} else if (eq_margin(ev.duration, NECX_HEADER_PULSE, NEC_UNIT / 2))
			data->is_nec_x = true;
		else
			break;

		data->count = 0;
		data->state = STATE_HEADER_SPACE;
		return 0;

	case STATE_HEADER_SPACE:
		if (ev.pulse)
			break;

		if (eq_margin(ev.duration, NEC_HEADER_SPACE, NEC_UNIT / 2)) {
			data->state = STATE_BIT_PULSE;
			return 0;
		} else if (eq_margin(ev.duration, NEC_REPEAT_SPACE, NEC_UNIT / 2)) {
			if (!dev->keypressed) {
				IR_dprintk(1, "Discarding last key repeat: event after key up\n");
			} else {
				rc_repeat(dev);
				IR_dprintk(1, "Repeat last key\n");
				data->state = STATE_TRAILER_PULSE;
			}
			return 0;
		}

		break;

	case STATE_BIT_PULSE:
		if (!ev.pulse)
			break;

		if (!eq_margin(ev.duration, NEC_BIT_PULSE, NEC_UNIT / 2))
			break;

		data->state = STATE_BIT_SPACE;
		return 0;

	case STATE_BIT_SPACE:
		if (ev.pulse)
			break;

		if (data->necx_repeat && data->count == NECX_REPEAT_BITS &&
			geq_margin(ev.duration,
			NEC_TRAILER_SPACE, NEC_UNIT / 2)) {
				IR_dprintk(1, "Repeat last key\n");
				rc_repeat(dev);
				data->state = STATE_INACTIVE;
				return 0;

		} else if (data->count > NECX_REPEAT_BITS)
			data->necx_repeat = false;

		data->bits <<= 1;
		if (eq_margin(ev.duration, NEC_BIT_1_SPACE, NEC_UNIT / 2))
			data->bits |= 1;
		else if (!eq_margin(ev.duration, NEC_BIT_0_SPACE, NEC_UNIT / 2))
			break;
		data->count++;

		if (data->count == NEC_NBITS)
			data->state = STATE_TRAILER_PULSE;
		else
			data->state = STATE_BIT_PULSE;

		return 0;

	case STATE_TRAILER_PULSE:
		if (!ev.pulse)
			break;

		if (!eq_margin(ev.duration, NEC_TRAILER_PULSE, NEC_UNIT / 2))
			break;

		data->state = STATE_TRAILER_SPACE;
		return 0;

	case STATE_TRAILER_SPACE:
		if (ev.pulse)
			break;

		if (!geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2))
			break;

		address     = bitrev8((data->bits >> 24) & 0xff);
		not_address = bitrev8((data->bits >> 16) & 0xff);
		command	    = bitrev8((data->bits >>  8) & 0xff);
		not_command = bitrev8((data->bits >>  0) & 0xff);

		if ((command ^ not_command) != 0xff) {
			IR_dprintk(1, "NEC checksum error: received 0x%08x\n",
				   data->bits);
			send_32bits = true;
		}

		if (send_32bits) {
			/* NEC transport, but modified protocol, used by at
			 * least Apple and TiVo remotes */
			scancode = data->bits;
			IR_dprintk(1, "NEC (modified) scancode 0x%08x\n", scancode);
		} else if ((address ^ not_address) != 0xff) {
			/* Extended NEC */
			scancode = address     << 16 |
				   not_address <<  8 |
				   command;
			IR_dprintk(1, "NEC (Ext) scancode 0x%06x\n", scancode);
		} else {
			/* Normal NEC */
			scancode = address << 8 | command;
			IR_dprintk(1, "NEC scancode 0x%04x\n", scancode);
		}

		if (data->is_nec_x)
			data->necx_repeat = true;

		rc_keydown(dev, scancode, 0);
		data->state = STATE_INACTIVE;
		return 0;
	}

	IR_dprintk(1, "NEC decode failed at state %d (%uus %s)\n",
		   data->state, TO_US(ev.duration), TO_STR(ev.pulse));
	data->state = STATE_INACTIVE;
	return -EINVAL;
}

static struct ir_raw_handler nec_handler = {
	.protocols	= RC_TYPE_NEC,
	.decode		= ir_nec_decode,
};

static int __init ir_nec_decode_init(void)
{
	ir_raw_handler_register(&nec_handler);

	printk(KERN_INFO "IR NEC protocol handler initialized\n");
	return 0;
}

static void __exit ir_nec_decode_exit(void)
{
	ir_raw_handler_unregister(&nec_handler);
}

module_init(ir_nec_decode_init);
module_exit(ir_nec_decode_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com)");
MODULE_DESCRIPTION("NEC IR protocol decoder");


text:
@extends('layouts.app')

@section('content')

{{ __('Supplier') }}

    <form method="post" action="{{ url('/supplier/save') }}">
        @csrf

                {{ __('Name') }} *
                <input type="text" name="name" value="{{ $supplier->name }}" required="required" class="form-control">

                {{ __('Phone') }}
                <input type="tel" name="phone" value="{{ $supplier->phone }}" maxlength="15" class="form-control">

                E-mail
                <input type="email" name="email" value="{{ $supplier->email }}" maxlength="254" class="form-control">

                {{ __('Website') }}
                <input type="url" name="website" value="{{ $supplier->website }}" maxlength="255" class="form-control">

                <button type="submit" class="btn btn-primary">{{ __('Save') }}</button>

        <input type="hidden" name="id" value="{{ $supplier->id }}">
    </form>
@endsection


text:
import React from 'react'
import PropTypes from 'prop-types'
import _map from 'lodash/map'
import iconDownload from 'assets/imgs/icon-download.svg'
import './ResourcesList.scss'

export const ResourcesList = ({ data }) => (

    {
      _map(data, (item, i) => {
        return

          {item.name}

      })
    }

)

ResourcesList.propTypes = {
  data: PropTypes.array.isRequired
}

export default ResourcesList


text:
using System;

using Android.App;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace ReactiveUI.XamlForms.Sample.Droid
{
	[Activity (Label = "ReactiveUI.XamlForms.Sample", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
	public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
	{
		public MainActivity()
		{

		}

		protected override void OnCreate (Bundle bundle)
		{
			//Make sure this is before OnCreate otherwise the life cycle OnCreate won't fire
			//that creates the app state
			ReactiveUI.XamlForms.Sample.App.Initialize(this.Application);

			base.OnCreate (bundle);

            global::Xamarin.Forms.Forms.Init (this, bundle);
			LoadApplication (new ReactiveUI.XamlForms.Sample.App ());
		}
    }
}


text:
require 'test_helper'

describe 'AppsCommand' do
  include MockExecution

  let(:command) { CfScript::Command::Apps::AppsCommand.instance }

  it_behaves_like 'a command object that', {
    has_type:  :apps,
    has_name:  :apps,
    fails_with: CfScript::AppList.new # an empty AppList
  }

  it "returns an AppList object" do
    fake_cf do
      apps = command.run

      assert_instance_of CfScript::AppList, apps
      apps.each do |app_info|
        assert_instance_of CfScript::AppInfo, app_info
      end
    end
  end

  it "yields an AppList object when a block is given" do
    fake_cf do
      called = false

      command.run do |apps|
        called = true

        assert_instance_of CfScript::AppList, apps
        apps.each do |app_info|
          assert_instance_of CfScript::AppInfo, app_info
        end
      end

      assert called, "Expected block to have been called"
    end
  end

  it "correctly builds the AppInfo objects" do
    fake_cf do
      apps = command.run

      assert_equal [
        'org-one-api',
        'org-one-worker',
        'org-two-api',
        'org-two-worker'
      ], apps.map(&:name)

      assert_equal [
        'stopped',
        'started',
        'stopped',
        'started'
      ], apps.map(&:requested_state)

      assert_equal ['0/1', '1/3', '0/2', '1/1'], apps.map(&:instances)
      assert_equal ['256M', '1G', '256M', '2G'], apps.map(&:memory)
      assert_equal ['1G', '2G', '3G', '4G'], apps.map(&:disk)

      assert_equal [
        ['example.com', 'example.net'],
        [],
        ['example.io', 'example.org'],
        []
      ], apps.map(&:urls)
    end
  end

  it "returns an empty AppList for empty output" do
    fake_cf apps: :empty do
      apps = command.run

      assert_instance_of CfScript::AppList, apps
      assert_equal CfScript::AppList.new, apps
    end
  end

  it "returns an empty Array when no apps are found" do
    fake_cf apps: :no_apps do
      apps = command.run

      assert_instance_of CfScript::AppList, apps
      assert_equal CfScript::AppList.new, apps
    end
  end
end


text:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.xwalk.core;

import android.content.Context;
import android.content.res.AssetManager;
import android.net.Uri;
import android.util.Log;
import android.util.TypedValue;

import java.io.InputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.List;

import org.chromium.base.CalledByNativeUnchecked;
import org.chromium.base.JNINamespace;

/**
 * Implements the Java side of Android URL protocol jobs.
 * See android_protocol_handler.cc.
 */
@JNINamespace("xwalk")
class AndroidProtocolHandler {
    private static final String TAG = "AndroidProtocolHandler";

    // Supported URL schemes. This needs to be kept in sync with
    // clank/native/framework/chrome/url_request_android_job.cc.
    public static final String FILE_SCHEME = "file";
    private static final String CONTENT_SCHEME = "content";
    public static final String APP_SCHEME = "app";
    private static final String APP_SRC = "www";
    private static final String SCHEME_SEPARATOR = "//";

    /**
     * Open an InputStream for an Android resource.
     * @param context The context manager.
     * @param url The url to load.
     * @return An InputStream to the Android resource.
     */
    // TODO(bulach): this should have either a throw clause, or
    // handle the exception in the java side rather than the native side.
    @CalledByNativeUnchecked
    public static InputStream open(Context context, String url) {
        Uri uri = verifyUrl(url);
        if (uri == null) {
            return null;
        }
        String path = uri.getPath();
        if (uri.getScheme().equals(FILE_SCHEME)) {
            if (path.startsWith(nativeGetAndroidAssetPath())) {
                return openAsset(context, uri);
            } else if (path.startsWith(nativeGetAndroidResourcePath())) {
                return openResource(context, uri);
            }
        } else if (uri.getScheme().equals(CONTENT_SCHEME)) {
            return openContent(context, uri);
        } else if (uri.getScheme().equals(APP_SCHEME)) {
            // The host should be the same as the lower case of the package
            // name, otherwise the resource request should be rejected.
            if (!uri.getHost().equals(context.getPackageName().toLowerCase())) return null;

            // path == "/" or path == ""
            if (path.length() <= 1) return null;

            return openAsset(context, appUriToFileUri(uri));
        }

        return null;
    }

    // Get the asset path of file:///android_asset/* url.
    public static String getAssetPath(Uri uri) {
        assert(uri.getScheme().equals(FILE_SCHEME));
        assert(uri.getPath() != null);
        assert(uri.getPath().startsWith(nativeGetAndroidAssetPath()));
        String path = uri.getPath();
        // Remove duplicate slashes and normalize the URL.
        path = (new java.io.File(path)).getAbsolutePath();
        return path.replaceFirst(nativeGetAndroidAssetPath(), "");
    }

    // Convert app uri to file uri to access the actual files in assets.
    public static Uri appUriToFileUri(Uri uri) {
        assert(uri.getScheme().equals(APP_SCHEME));
        assert(uri.getPath() != null);

        try {
            URI fileUri = new URI(FILE_SCHEME, SCHEME_SEPARATOR +
                nativeGetAndroidAssetPath() + APP_SRC + uri.getPath(), null);
            return Uri.parse(fileUri.normalize().toString());
        } catch (URISyntaxException e) {
            Log.e(TAG, "Unable to convert app URI to file URI: " + uri, e);
            return null;
        }
    }

    private static int getFieldId(Context context, String assetType, String assetName)
        throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
        Class<?> d = context.getClassLoader()
            .loadClass(context.getPackageName() + ".R$" + assetType);
        java.lang.reflect.Field field = d.getField(assetName);
        int id = field.getInt(null);
        return id;
    }

    private static int getValueType(Context context, int field_id) {
      TypedValue value = new TypedValue();
      context.getResources().getValue(field_id, value, true);
      return value.type;
    }

    private static InputStream openResource(Context context, Uri uri) {
        assert(uri.getScheme().equals(FILE_SCHEME));
        assert(uri.getPath() != null);
        assert(uri.getPath().startsWith(nativeGetAndroidResourcePath()));
        // The path must be of the form "/android_res/asset_type/asset_name.ext".
        List<String> pathSegments = uri.getPathSegments();
        if (pathSegments.size() != 3) {
            Log.e(TAG, "Incorrect resource path: " + uri);
            return null;
        }
        String assetPath = pathSegments.get(0);
        String assetType = pathSegments.get(1);
        String assetName = pathSegments.get(2);
        if (!("/" + assetPath + "/").equals(nativeGetAndroidResourcePath())) {
            Log.e(TAG, "Resource path does not start with " + nativeGetAndroidResourcePath() +
                  ": " + uri);
            return null;
        }
        // Drop the file extension.
        assetName = assetName.split("\\.")[0];
        try {
            // Use the application context for resolving the resource package name so that we do
            // not use the browser's own resources. Note that if 'context' here belongs to the
            // test suite, it does not have a separate application context. In that case we use
            // the original context object directly.
            if (context.getApplicationContext() != null) {
                context = context.getApplicationContext();
            }
            int field_id = getFieldId(context, assetType, assetName);
            int value_type = getValueType(context, field_id);
            if (value_type == TypedValue.TYPE_STRING) {
                return context.getResources().openRawResource(field_id);
            } else {
                Log.e(TAG, "Asset not of type string: " + uri);
                return null;
            }
        } catch (ClassNotFoundException e) {
            Log.e(TAG, "Unable to open resource URL: " + uri, e);
            return null;
        } catch (NoSuchFieldException e) {
            Log.e(TAG, "Unable to open resource URL: " + uri, e);
            return null;
        } catch (IllegalAccessException e) {
            Log.e(TAG, "Unable to open resource URL: " + uri, e);
            return null;
        }
    }

    private static InputStream openAsset(Context context, Uri uri) {
        try {
            AssetManager assets = context.getAssets();
            return assets.open(getAssetPath(uri), AssetManager.ACCESS_STREAMING);
        } catch (IOException e) {
            Log.e(TAG, "Unable to open asset URL: " + uri);
            return null;
        }
    }

    private static InputStream openContent(Context context, Uri uri) {
        assert(uri.getScheme().equals(CONTENT_SCHEME));
        try {
            // We strip the query parameters before opening the stream to
            // ensure that the URL we try to load exactly matches the URL
            // we have permission to read.
            Uri baseUri = stripQueryParameters(uri);
            return context.getContentResolver().openInputStream(baseUri);
        } catch (Exception e) {
            Log.e(TAG, "Unable to open content URL: " + uri);
            return null;
        }
    }

    /**
     * Determine the mime type for an Android resource.
     * @param context The context manager.
     * @param stream The opened input stream which to examine.
     * @param url The url from which the stream was opened.
     * @return The mime type or null if the type is unknown.
     */
    // TODO(bulach): this should have either a throw clause, or
    // handle the exception in the java side rather than the native side.
    @CalledByNativeUnchecked
    public static String getMimeType(Context context, InputStream stream, String url) {
        Uri uri = verifyUrl(url);
        if (uri == null) {
            return null;
        }
        String path = uri.getPath();
        // The content URL type can be queried directly.
        if (uri.getScheme().equals(CONTENT_SCHEME)) {
            return context.getContentResolver().getType(uri);
        // Asset files may have a known extension.
        } else if (uri.getScheme().equals(APP_SCHEME) ||
                   uri.getScheme().equals(FILE_SCHEME) &&
                   path.startsWith(nativeGetAndroidAssetPath())) {
            String mimeType = URLConnection.guessContentTypeFromName(path);
            if (mimeType != null) {
                return mimeType;
            }
        }
        // Fall back to sniffing the type from the stream.
        try {
            return URLConnection.guessContentTypeFromStream(stream);
        } catch (IOException e) {
            return null;
        }
    }

    /**
     * Get the package name of the current Activity.
     * @param context The context manager.
     * @return Package name.
     */
    @CalledByNativeUnchecked
    public static String getPackageName(Context context) {
        // Make sure the context is the application context.
        // Or it will get the wrong package name in shared mode.
        return context.getPackageName();
    }

    /**
     * Make sure the given string URL is correctly formed and parse it into a Uri.
     * @return a Uri instance, or null if the URL was invalid.
     */
    private static Uri verifyUrl(String url) {
        if (url == null) {
            return null;
        }
        Uri uri = Uri.parse(url);
        if (uri == null) {
            Log.e(TAG, "Malformed URL: " + url);
            return null;
        }
        String path = uri.getPath();
        if (path == null || path.length() == 0) {
            Log.e(TAG, "URL does not have a path: " + url);
            return null;
        }
        return uri;
    }

    /**
     * Remove query parameters from a Uri.
     * @param uri The input uri.
     * @return The given uri without query parameters.
     */
    private static Uri stripQueryParameters(Uri uri) {
        assert(uri.getAuthority() != null);
        assert(uri.getPath() != null);
        Uri.Builder builder = new Uri.Builder();
        builder.scheme(uri.getScheme());
        builder.encodedAuthority(uri.getAuthority());
        builder.encodedPath(uri.getPath());
        return builder.build();
    }

    /**
     * Set the context to be used for resolving resource queries.
     * @param context Context to be used, or null for the default application
     *                context.
     */
    public static void setResourceContextForTesting(Context context) {
        nativeSetResourceContextForTesting(context);
    }

    private static native void nativeSetResourceContextForTesting(Context context);
    private static native String nativeGetAndroidAssetPath();
    private static native String nativeGetAndroidResourcePath();
}


text:
var Twitter = require('../lib/Twitter');

var twitterSearchClient = new Twitter.SearchClient(
    'CONSUMER_KEY',
    'CONSUMER_SECRET',
    'TOKEN',
    'TOKEN_SECRET'
);

twitterSearchClient.search({'q': 'node.js'}, function(error, result) {
    if (error)
    {
        console.log('Error: ' + (error.code ? error.code + ' ' + error.message : error.message));
    }

    if (result)
    {
        console.log(result);
    }
});


text:
<component name="ArtifactManager">
  <artifact type="exploded-war" name="ReportSystem:war exploded">
    <output-path>$PROJECT_DIR$/out/artifacts/ReportSystem_war_exploded</output-path>
    <root id="root">
      <element id="javaee-facet-resources" facet="ReportSystem/web/Web" />
      <element id="directory" name="WEB-INF">
        <element id="directory" name="classes">
          <element id="module-output" name="ReportSystem" />
        </element>
        <element id="directory" name="lib">
          <element id="library" level="project" name="Spring-4.3.9.RELEASE" />
          <element id="library" level="project" name="Spring MVC-4.3.9.RELEASE" />
          <element id="library" level="project" name="org.logback-extensions:logback-ext-spring:0.1.4" />
          <element id="library" level="project" name="org.slf4j:jcl-over-slf4j:1.7.25" />
          <element id="library" level="project" name="com.trilead:trilead-ssh2:Latest" />
          <element id="library" level="project" name="com.alibaba:druid:1.1.2" />
          <element id="library" level="project" name="db2jcc" />
          <element id="library" level="project" name="jstl" />
          <element id="library" level="project" name="jackson-annotations-2.9.0" />
          <element id="library" level="project" name="com.googlecode.aviator:aviator:3.1.0" />
          <element id="library" level="project" name="org.docx4j:docx4j:3.3.5" />
          <element id="library" level="project" name="commons-codec:commons-codec:1.10" />
        </element>
      </element>
    </root>
  </artifact>
</component>


text:
layout: page
title: "Carlos Frederico Martino"
comments: true
description: "blanks"
keywords: "Carlos Frederico Martino,CU,Boulder"
---
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://dl.dropboxusercontent.com/s/pc42nxpaw1ea4o9/highcharts.js?dl=0"></script>
<!-- <script src="../assets/js/highcharts.js"></script> -->
<style type="text/css">@font-face {
	font-family: "Bebas Neue";
	src: url(https://www.filehosting.org/file/details/544349/BebasNeue Regular.otf) format("opentype");
	}
	h1.Bebas {
		font-family: "Bebas Neue", Verdana, Tahoma;
	}
</style>
</head>

#### TEACHING INFORMATION

**College**: College of Engineering and Applied Science

**Classes taught**: MCEN 4047

#### MCEN 4047: Mechanical Engineering Laboratory

**Terms taught**: Fall 2010

**Instructor rating**: 3.25

**Standard deviation in instructor rating**: 0.0

**Average grade** (4.0 scale): 3.42

**Standard deviation in grades** (4.0 scale): 0.0

**Average workload** (raw): 2.4

**Standard deviation in workload** (raw): 0.0


text:
{-# LANGUAGE TypeOperators #-}
module Compiler.FreeVariables
( FreeVarA (..)
, ExpressionFV
, annotateExpression
, DefinitionFV
, DefinitionsFV
, annotateDefinitions
, dump
)
where

import Compiler.Generics
import Compiler.Expression
import Control.Arrow hiding (app)
import Data.List (intercalate)
import Data.Set hiding (map, insert)
import Compiler.LiftDefinitions (DefinitionsA (..), Definitions, DefinitionA (..))

data FreeVarA f a = FreeVarA { free :: Set String , expr :: f a }

type ExpressionFV = FixA FreeVarA ExpressionF

annotateExpression :: Arrow (~>) => Set String -> Expression ~> ExpressionFV
annotateExpression globs = arr ow
  where
  ow ex = rec ex
    where

    -- traversal function
    ann (App l r)   = ae (union (fv l') (fv r'))           (App  l' r') where l' = rec l; r' = rec r
    ann (Con c)     = ae (empty)                           (Con  c    )
    ann (Prim s vs) = ae (fromList vs)                     (Prim s vs )
    ann (Lam x e)   = ae (fv e' `difference` fromList x)   (Lam  x e' ) where e' = rec e
    ann (Var v)     = ae (singleton v `difference` globs)  (Var  v    )
    ann (Name n e)  = ae (fv e')                           (Name n e' ) where e' = rec e

    -- helpers
    rec = ann . unId . out
    ae vs e = In (FreeVarA vs e)
    fv = free . out

type DefinitionFV  = DefinitionA  FreeVarA
type DefinitionsFV = DefinitionsA FreeVarA

annotateDefinitions :: Arrow (~>) => Definitions ~> DefinitionsFV
annotateDefinitions = arr $ \(Defs ds) ->
  let globs = fromList (map defName ds)
      ann   = annotateExpression globs
  in Defs (map (\(Def n e) -> Def n (ann e)) ds)

dump :: Arrow (~>) => DefinitionsFV ~> String
dump = arr (intercalate "\n" . map one . unDefs)
  where
    one (Def d e) = "var " ++ d ++ " = " ++ rec e

    tr (App  f e ) = rec f ++ "(" ++ rec e ++ ")"
    tr (Con  c   ) = c
    tr (Prim s vf) = s vf
    tr (Lam  as e) = "function (" ++ intercalate ", " as ++ ") { return " ++ rec e ++ ";" ++ " }"
    tr (Var  v   ) = v
    tr (Name n e ) = "/* " ++ n ++ " */ " ++ rec e

    rec (In (FreeVarA vf x)) =
      if size vf /= 0
      then "/* free: " ++ show (toList vf) ++ " */" ++ tr x
      else "/* 0 */"                                ++ tr x


text:
import { assert } from 'chai';
import { resolve } from 'path';

import Module from '../../src/runtime/Module';
import { Program } from '~/syntax';

function testfilePath(path: string) {
    return resolve(__dirname, '../../../testfiles/' + path);
}

describe('Module', () => {
    it('should construct Module instance', () => {
        const mod = new Module(0, '/index.ren', {} as Program);
        assert.strictEqual(mod.id, 0);
        assert.strictEqual(mod.path, '/index.ren');
        assert.deepEqual(mod.ast, {});
        assert.deepEqual(mod.imports, {});
        assert.deepEqual(mod.exports, {});
        assert.deepEqual(mod.types, {});
        assert.deepEqual(mod.functions, {});
        assert.deepEqual(mod.constants, {});
    });

    it('should parse an unparsed module', () => {
        const path = testfilePath('import.ren');
        const mod = new Module(0, path);
        assert.strictEqual(mod.id, 0);
        assert.strictEqual(mod.path, path);
        assert.instanceOf(mod.ast, Program);
    });

    it('should resolve an import of a relative directory', () => {
        const currentPath = testfilePath('import.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.strictEqual(mod.resolvePath('.'), testfilePath('index.ren'));
    });

    it('should resolve an import of a relative file', () => {
        const currentPath = testfilePath('import.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.strictEqual(mod.resolvePath('./nested/nestedModule.ren'), testfilePath('nested/nestedModule.ren'));
    });

    it('should resolve an import of a relative module name', () => {
        const currentPath = testfilePath('import.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.strictEqual(mod.resolvePath('./nested/nestedModule'), testfilePath('nested/nestedModule.ren'));
    });

    it('should return null for a non-existent relative path', () => {
        const currentPath = testfilePath('import.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.isNull(mod.resolvePath('./impossiblepath'));
    });

    it('should return null for path to a non-importable directory', () => {
        const currentPath = testfilePath('import.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.isNull(mod.resolvePath('./packages'));
    });

    it('should resolve a package import', () => {
        const currentPath = testfilePath('nested/nestedModule.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.strictEqual(mod.resolvePath('packageModule'), testfilePath('nested/packages/packageModule.ren'));
    });

    it('should resolve a parent package import', () => {
        const currentPath = testfilePath('nested/nestedModule.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.strictEqual(mod.resolvePath('parentPackageModule'), testfilePath('packages/parentPackageModule.ren'));
    });

    it('should return null if a package is not resolved all the way to root', () => {
        const currentPath = testfilePath('nested/nestedModule.ren');
        const mod = new Module(0, currentPath, {} as Program);
        assert.isNull(mod.resolvePath('impossiblePackagePath'));
    });
});


text:
'use strict';
angular.module('adminToolApp.serviceProviders.details', [])
    .directive('service-provider', function(){
        return{
            restriction:'E',
            replace: true,
            templateUrl:'service-provider.html',
            controller: function($scope){

            },
            link: function(scope, element, attr){

            }
        };
    });
   /* .controller('ServiceProviderCtrl', function($scope, $http){
        $scope.serviceProvider={};
        $http.get('data/sp1000-details.json').succuss(function(data){
            $scope.serviceProvider = data;
        });
    });*/


text:
/// Copyright (c) 2012 Ecma International.  All rights reserved.
/**
 * @path ch15/15.4/15.4.4/15.4.4.19/15.4.4.19-8-c-i-4.js
 * @description Array.prototype.map - element to be retrieved is own data property that overrides an inherited data property on an Array
 */

function testcase() {

        var kValue = "abc";

        function callbackfn(val, idx, obj) {
            if (idx === 0) {
                return val === kValue;
            }
            return false;
        }

        try {
            Array.prototype[0] = 11;

            var testResult = [kValue].map(callbackfn);

            return testResult[0] === true;
        } finally {
            delete Array.prototype[0];
        }
    }
runTestCase(testcase);


text:
'''
test iam2 vm operations by platform admin/operator/member

# 1 create project
# 2 create virtual id (project admin/operator/member)
# 3 operations on vm with virtual id
# 4 delete

@author: quarkonics
'''
import os
import time
import zstackwoodpecker.test_util as test_util
import apibinding.inventory as inventory
import zstackwoodpecker.operations.account_operations as acc_ops
import zstackwoodpecker.operations.iam2_operations as iam2_ops
import zstackwoodpecker.operations.resource_operations as res_ops
import zstackwoodpecker.operations.image_operations as img_ops
import zstackwoodpecker.operations.volume_operations as vol_ops
import zstackwoodpecker.operations.account_operations as acc_ops
from zstackwoodpecker.operations import vm_operations as vm_ops
import zstackwoodpecker.operations.net_operations as net_ops
import zstackwoodpecker.operations.scheduler_operations as schd_ops
import zstackwoodpecker.operations.zwatch_operations as zwt_ops
import zstackwoodpecker.test_lib as test_lib
import zstackwoodpecker.zstack_test.zstack_test_vid as test_vid

project_uuid = None
virtual_id_uuid = None
project_admin_uuid = None
project_operator_uuid = None
plain_user_uuid = None
test_stub = test_lib.lib_get_test_stub()

case_flavor = dict(project_admin=                   dict(target_role='project_admin'),
                   project_operator=                dict(target_role='project_operator'),
                   project_member=                  dict(target_role='project_member'),
                   system_admin=                    dict(target_role='system_admin'),
                   )

def test():
    global project_uuid, project_admin_uuid, virtual_id_uuid, project_operator_uuid, plain_user_uuid

    flavor = case_flavor[os.environ.get('CASE_FLAVOR')]
    # 1 create project
    if flavor['target_role'] != 'system_admin':
        project_name = 'test_project'
        project = iam2_ops.create_iam2_project(project_name)
        project_uuid = project.uuid
        project_linked_account_uuid = project.linkedAccountUuid

    if flavor['target_role'] == 'project_admin':
        # 2 create virtual id
        project_admin_name = 'username'
        project_admin_password = 'password'
        project_admin_uuid = iam2_ops.create_iam2_virtual_id(project_admin_name, project_admin_password).uuid
        virtual_id_uuid = iam2_ops.create_iam2_virtual_id('usernametwo', 'password').uuid

        # 3 create project admin
        iam2_ops.add_iam2_virtual_ids_to_project([project_admin_uuid],project_uuid)
        attributes = [{"name": "__ProjectAdmin__", "value": project_uuid}]
        iam2_ops.add_attributes_to_iam2_virtual_id(project_admin_uuid, attributes)

        # 4 add the project admin role
        projectadminrole_uuid='55553cefbbfb42468873897c95408a43'
        iam2_ops.add_roles_to_iam2_virtual_id([projectadminrole_uuid], virtual_id_uuid)

        # login in project by project admin
        project_admin_session_uuid = iam2_ops.login_iam2_virtual_id(project_admin_name, project_admin_password)
        project_login_uuid = iam2_ops.login_iam2_project(project_name, session_uuid=project_admin_session_uuid).uuid
        # iam2_ops.remove_attributes_from_iam2_virtual_id(virtual_id_uuid, attributes)
    elif flavor['target_role'] == 'project_operator':
        project_operator_name = 'username2'
        project_operator_password = 'password'
        attributes = [{"name": "__ProjectOperator__", "value": project_uuid}]
        project_operator_uuid = iam2_ops.create_iam2_virtual_id(project_operator_name,project_operator_password,attributes=attributes).uuid
        virtual_id_uuid = iam2_ops.create_iam2_virtual_id('usernamethree','password').uuid

        # login in project by project operator
        iam2_ops.add_iam2_virtual_ids_to_project([project_operator_uuid],project_uuid)
        project_operator_session_uuid = iam2_ops.login_iam2_virtual_id(project_operator_name,project_operator_password)
        project_login_uuid = iam2_ops.login_iam2_project(project_name,session_uuid=project_operator_session_uuid).uuid
    elif flavor['target_role'] == 'project_member':
	plain_user_name = 'username'
	plain_user_password = 'password'
	plain_user_uuid = iam2_ops.create_iam2_virtual_id(plain_user_name, plain_user_password,
	                                                  project_uuid=project_uuid).uuid
	# 3 add virtual id to project
	iam2_ops.add_iam2_virtual_ids_to_project([plain_user_uuid],project_uuid)

	# 4 login in project by plain user
	plain_user_session_uuid = iam2_ops.login_iam2_virtual_id(plain_user_name, plain_user_password)

	# 4 login in project
	#project_inv=iam2_ops.get_iam2_projects_of_virtual_id(plain_user_session_uuid)
	project_login_uuid = iam2_ops.login_iam2_project(project_name, plain_user_session_uuid).uuid
    elif flavor['target_role'] == 'system_admin':
        username = "systemAdmin"
        password = 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86'
        vid_tst_obj = test_vid.ZstackTestVid()
        test_stub.create_system_admin(username, password, vid_tst_obj)
        virtual_id_uuid = vid_tst_obj.get_vid().uuid

        # add the system admin role
        systemadminrole_uuid='2069fe8ff0fb49efac0d4db3650a8076'
        iam2_ops.add_roles_to_iam2_virtual_id([systemadminrole_uuid], virtual_id_uuid)

        project_login_uuid = acc_ops.login_by_account(username, password)

    # Image related ops: Add, Delete, Expunge, sync image size, Update QGA, delete, expunge
    if flavor['target_role'] == 'project_member':
        statements = [{"effect": "Allow", "actions": ["org.zstack.header.vm.**"]}]
        role_uuid = iam2_ops.create_role('test_role', statements).uuid
        iam2_ops.add_roles_to_iam2_virtual_id([role_uuid], plain_user_uuid)

    vm_creation_option = test_util.VmOption()
    pub_l3_uuid = test_lib.lib_get_l3_by_name(os.environ.get('l3PublicNetworkName')).uuid
    if test_lib.lib_get_l3_by_name(os.environ.get('l3VlanNetworkName3')) == None:
        error_cleanup()
        test_util.test_skip('skip in no private l3 env.')
    else:
        l3_net_uuid = test_lib.lib_get_l3_by_name(os.environ.get('l3VlanNetworkName3')).uuid
    if flavor['target_role'] != 'system_admin':
        acc_ops.share_resources([project_linked_account_uuid], [l3_net_uuid])
    vm_creation_option.set_l3_uuids([l3_net_uuid])
    image_uuid = test_lib.lib_get_image_by_name(os.environ.get('imageName_net')).uuid
    vm_creation_option.set_image_uuid(image_uuid)
    if flavor['target_role'] != 'system_admin':
        acc_ops.share_resources([project_linked_account_uuid], [image_uuid])
    instance_offering_uuid = test_lib.lib_get_instance_offering_by_name(os.environ.get('instanceOfferingName_s')).uuid
    vm_creation_option.set_instance_offering_uuid(instance_offering_uuid)
    if flavor['target_role'] != 'system_admin':
        acc_ops.share_resources([project_linked_account_uuid], [instance_offering_uuid])
    vm_creation_option.set_name('vm_for_project_management')
    vm_creation_option.set_session_uuid(project_login_uuid)
    vm = test_stub.create_vm(image_uuid = image_uuid, session_uuid=project_login_uuid)
    vm_uuid = vm.get_vm().uuid

    vip_option = test_util.VipOption()
    vip_option.set_name("vip for pm")
    vip_option.set_session_uuid(project_login_uuid)
    vip_option.set_l3_uuid(pub_l3_uuid)

    vm_nic = vm.vm.vmNics[0]
    vm_nic_uuid = vm_nic.uuid
    vip = net_ops.create_vip(vip_option)
    eip_option = test_util.EipOption()
    eip_option.set_name('eip for pm')
    eip_option.set_session_uuid(project_login_uuid)
    eip_option.set_vip_uuid(vip.uuid)
    eip_option.set_vm_nic_uuid(vm_nic_uuid)
    eip = net_ops.create_eip(eip_option)

    net_ops.detach_eip(eip.uuid, session_uuid=project_login_uuid)
    net_ops.attach_eip(eip.uuid, vm_nic_uuid, session_uuid=project_login_uuid)
    net_ops.detach_eip(eip.uuid, session_uuid=project_login_uuid)
    net_ops.delete_eip(eip.uuid)
    net_ops.delete_vip(vip.uuid)

    vm_ops.destroy_vm(vm_uuid, session_uuid=project_login_uuid)
    vm_ops.expunge_vm(vm_uuid, session_uuid=project_login_uuid)

    # 11 delete
    acc_ops.logout(project_login_uuid)
    if virtual_id_uuid != None:
        iam2_ops.delete_iam2_virtual_id(virtual_id_uuid)
    if project_admin_uuid != None:
        iam2_ops.delete_iam2_virtual_id(project_admin_uuid)
    if project_operator_uuid != None:
        iam2_ops.delete_iam2_virtual_id(project_operator_uuid)
    if plain_user_uuid != None:
        iam2_ops.delete_iam2_virtual_id(plain_user_uuid)

    if flavor['target_role'] != 'system_admin':
        iam2_ops.delete_iam2_project(project_uuid)
        iam2_ops.expunge_iam2_project(project_uuid)

    test_util.test_pass('success test iam2 login in by project admin!')

def error_cleanup():
    global project_uuid, project_admin_uuid, virtual_id_uuid
    if virtual_id_uuid:
        iam2_ops.delete_iam2_virtual_id(virtual_id_uuid)
    if project_admin_uuid:
        iam2_ops.delete_iam2_virtual_id(project_admin_uuid)
    if project_uuid:
        iam2_ops.delete_iam2_project(project_uuid)
        iam2_ops.expunge_iam2_project(project_uuid)
    if plain_user_uuid != None:
        iam2_ops.delete_iam2_virtual_id(plain_user_uuid)


text:
import { trigger, state, style, transition, animate,keyframes, AnimationTriggerMetadata } from '@angular/animations';

export const bubbleIn: AnimationTriggerMetadata = trigger('bubbleIn', [
    state('in', style({opacity: 1, transform: 'scale(1)'})),
    transition('void => *', [
        animate('0.2s ease-in-out', keyframes([
            style({opacity: 0, transform: 'scale(0)', offset: 0}),
            style({opacity: 1, transform: 'scale(1)', offset: 1.0})
        ]))
    ]),
    transition('* => void', [
        animate('0.2s ease-in-out', keyframes([
            style({opacity: 1, transform: 'scale(1)', offset: 0}),
            style({opacity: 0, transform: 'scale(0)', offset: 1.0})
        ]))
    ])
]);


text:
#ifndef AXIS2_THREAD_MUTEX_H
#define AXIS2_THREAD_MUTEX_H

/**
 * @file axutil_thread_mutex.h
 * @brief AXIS2 Thread Mutex Routines
 */

#include <axis2_const.h>
#include <axutil_allocator.h>

#ifdef __cplusplus
extern "C"
{
#endif                          /* __cplusplus */

    /**
     * @defgroup axis2_mutex thread mutex routines
     * @ingroup axis2_util
     * @{
     */

    /** Opaque thread-local mutex structure */
    typedef struct axutil_thread_mutex_t axutil_thread_mutex_t;

#define AXIS2_THREAD_MUTEX_DEFAULT  0x0   /**< platform-optimal lock behavior */

#define AXIS2_THREAD_MUTEX_NESTED   0x1   /**< enable nested (recursive) locks */

#define AXIS2_THREAD_MUTEX_UNNESTED 0x2   /**< disable nested locks */

    /**
     * Create and initialize a mutex that can be used to synchronize threads.
     *
     * @param flags Or'ed value of:
     * <PRE>
     *           AXIS2_THREAD_MUTEX_DEFAULT   platform-optimal lock behavior.
     *           AXIS2_THREAD_MUTEX_NESTED    enable nested (recursive) locks.
     *           AXIS2_THREAD_MUTEX_UNNESTED  disable nested locks (non-recursive).
     * </PRE>
     * @param allocator the allocator from which to allocate the mutex.
     * @return mutex the memory address where the newly created mutex will be
     *        stored.
     * @warning Be cautious in using AXIS2_THREAD_MUTEX_DEFAULT.  While this is the
     * most optimial mutex based on a given platform's performance charateristics,
     * it will behave as either a nested or an unnested lock.
     */
    AXIS2_EXTERN axutil_thread_mutex_t *AXIS2_CALL

    axutil_thread_mutex_create(
        axutil_allocator_t * allocator,
        unsigned int flags);

    /**
     * Acquire the lock for the given mutex. If the mutex is already locked,
     * the current thread will be put to sleep until the lock becomes available.
     * @param mutex the mutex on which to acquire the lock.
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axutil_thread_mutex_lock(
        axutil_thread_mutex_t * mutex);

    /**
     * Attempt to acquire the lock for the given mutex. If the mutex has already
     * been acquired, the call returns immediately
     * @param mutex the mutex on which to attempt the lock acquiring.
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axutil_thread_mutex_trylock(
        axutil_thread_mutex_t * mutex);

    /**
     * Release the lock for the given mutex.
     * @param mutex the mutex from which to release the lock.
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axutil_thread_mutex_unlock(
        axutil_thread_mutex_t * mutex);

    /**
     * Destroy the mutex and free the memory associated with the lock.
     * @param mutex the mutex to destroy.
     */
    AXIS2_EXTERN axis2_status_t AXIS2_CALL
    axutil_thread_mutex_destroy(
        axutil_thread_mutex_t * mutex);

    /** @} */

#ifdef __cplusplus
}
#endif

#endif                          /* AXIS2_THREAD_MUTEX_H */