text:
package com.thoughtworks.go.plugin.access.pluggabletask;

import com.thoughtworks.go.plugin.access.PluginRequestHelper;
import com.thoughtworks.go.plugin.api.config.Property;
import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest;
import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse;
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
import com.thoughtworks.go.plugin.api.response.validation.ValidationResult;
import com.thoughtworks.go.plugin.api.task.TaskConfig;
import com.thoughtworks.go.plugin.api.task.TaskConfigProperty;
import com.thoughtworks.go.plugin.api.task.TaskView;
import com.thoughtworks.go.plugin.infra.PluginManager;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

import java.util.HashMap;
import java.util.List;

import static com.thoughtworks.go.plugin.domain.common.PluginConstants.PLUGGABLE_TASK_EXTENSION;
import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;

public class JsonBasedPluggableTaskTest {

    private PluginManager pluginManager;
    private JsonBasedPluggableTask task;
    private GoPluginApiResponse goPluginApiResponse;
    private String pluginId;

    @BeforeEach
    public void setup() {
        pluginManager = mock(PluginManager.class);
        pluginId = "plugin-id";
        final List<String> goSupportedVersions = asList("1.0");
        final HashMap<String, JsonBasedTaskExtensionHandler> handlerMap = new HashMap<>();
        handlerMap.put("1.0", new JsonBasedTaskExtensionHandler_V1());

        task = new JsonBasedPluggableTask(pluginId, new PluginRequestHelper(pluginManager, goSupportedVersions, PLUGGABLE_TASK_EXTENSION), handlerMap);
        goPluginApiResponse = mock(GoPluginApiResponse.class);
        when(pluginManager.submitTo(eq(pluginId), eq(PLUGGABLE_TASK_EXTENSION), any(GoPluginApiRequest.class))).thenReturn(goPluginApiResponse);
        when(pluginManager.resolveExtensionVersion(pluginId, PLUGGABLE_TASK_EXTENSION, goSupportedVersions)).thenReturn("1.0");
        when(goPluginApiResponse.responseCode()).thenReturn(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE);
        when(pluginManager.isPluginOfType(PLUGGABLE_TASK_EXTENSION, pluginId)).thenReturn(true);
    }

    @Test
    public void shouldGetTheTaskConfig() {

        String jsonResponse = "{" +
                "\"URL\":{\"default-value\":\"\",\"secure\":false,\"required\":true}," +
                "\"USER\":{\"default-value\":\"foo\",\"secure\":true,\"required\":true}," +
                "\"PASSWORD\":{}" +
                "}";

        when(goPluginApiResponse.responseBody()).thenReturn(jsonResponse);

        TaskConfig config = task.config();

        Property url = config.get("URL");
        assertThat(url.getOption(Property.REQUIRED), is(true));
        assertThat(url.getOption(Property.SECURE), is(false));

        Property user = config.get("USER");
        assertThat(user.getOption(Property.REQUIRED), is(true));
        assertThat(user.getOption(Property.SECURE), is(true));

        Property password = config.get("PASSWORD");
        assertThat(password.getOption(Property.REQUIRED), is(true));
        assertThat(password.getOption(Property.SECURE), is(false));

        ArgumentCaptor<GoPluginApiRequest> argument = ArgumentCaptor.forClass(GoPluginApiRequest.class);
        verify(pluginManager).submitTo(eq(pluginId), eq(PLUGGABLE_TASK_EXTENSION), argument.capture());
        MatcherAssert.assertThat(argument.getValue().extension(), Matchers.is(PLUGGABLE_TASK_EXTENSION));
        MatcherAssert.assertThat(argument.getValue().extensionVersion(), Matchers.is(JsonBasedTaskExtensionHandler_V1.VERSION));
        MatcherAssert.assertThat(argument.getValue().requestName(), Matchers.is(TaskExtension.CONFIGURATION_REQUEST));
    }

    @Test
    public void shouldGetTaskView() {
        String jsonResponse = "{\"displayValue\":\"MyTaskPlugin\", \"template\":\"junk\"}";
        when(goPluginApiResponse.responseBody()).thenReturn(jsonResponse);

        TaskView view = task.view();
        assertThat(view.displayValue(), is("MyTaskPlugin"));
        assertThat(view.template(), is("junk"));

        ArgumentCaptor<GoPluginApiRequest> argument = ArgumentCaptor.forClass(GoPluginApiRequest.class);
        verify(pluginManager).submitTo(eq(pluginId), eq(PLUGGABLE_TASK_EXTENSION), argument.capture());
        MatcherAssert.assertThat(argument.getValue().extension(), Matchers.is(PLUGGABLE_TASK_EXTENSION));
        MatcherAssert.assertThat(argument.getValue().extensionVersion(), Matchers.is(JsonBasedTaskExtensionHandler_V1.VERSION));
        MatcherAssert.assertThat(argument.getValue().requestName(), Matchers.is(TaskExtension.TASK_VIEW_REQUEST));
    }

    @Test
    public void shouldValidateTaskConfig() {
        String jsonResponse = "{\"errors\":{\"key1\":\"err1\",\"key2\":\"err3\"}}";
        String config = "{\"URL\":{\"secure\":false,\"value\":\"http://foo\",\"required\":true}}";

        when(goPluginApiResponse.responseBody()).thenReturn(jsonResponse);

        TaskConfig configuration = new TaskConfig();
        final TaskConfigProperty property = new TaskConfigProperty("URL", "http://foo");
        property.with(Property.SECURE, false);
        property.with(Property.REQUIRED, true);
        configuration.add(property);

        ValidationResult result = task.validate(configuration);

        assertThat(result.isSuccessful(), is(false));
        assertThat(result.getErrors().get(0).getKey(), is("key1"));
        assertThat(result.getErrors().get(0).getMessage(), is("err1"));
        assertThat(result.getErrors().get(1).getKey(), is("key2"));
        assertThat(result.getErrors().get(1).getMessage(), is("err3"));

        ArgumentCaptor<GoPluginApiRequest> argument = ArgumentCaptor.forClass(GoPluginApiRequest.class);
        verify(pluginManager).submitTo(eq(pluginId), eq(PLUGGABLE_TASK_EXTENSION), argument.capture());
        assertThat(argument.getValue().requestBody(), is(config));

        MatcherAssert.assertThat(argument.getValue().extension(), Matchers.is(PLUGGABLE_TASK_EXTENSION));
        MatcherAssert.assertThat(argument.getValue().extensionVersion(), Matchers.is(JsonBasedTaskExtensionHandler_V1.VERSION));
        MatcherAssert.assertThat(argument.getValue().requestName(), Matchers.is(TaskExtension.VALIDATION_REQUEST));
    }

    @Test
    public void shouldGetTaskExecutor() {
        assertTrue(task.executor() instanceof JsonBasedTaskExecutor);
    }
}


text:
<?php

namespace Nette\Caching;

use Nette;

/**
 * Implements the cache for a application.
 *
 * @copyright  Copyright (c) 2004, 2010 David Grudl
 * @package    Nette\Caching
 */
class Cache extends Nette\Object implements \ArrayAccess
{
	/**#@+ dependency */
	const PRIORITY = 'priority';
	const EXPIRE = 'expire';
	const SLIDING = 'sliding';
	const TAGS = 'tags';
	const FILES = 'files';
	const ITEMS = 'items';
	const CONSTS = 'consts';
	const CALLBACKS = 'callbacks';
	const ALL = 'all';
	/**#@-*/

	/** @ignore internal */
	const NAMESPACE_SEPARATOR = "\x00";

	/** @var ICacheStorage */
	private $storage;

	/** @var string */
	private $namespace;

	/** @var string  last query cache */
	private $key;

	/** @var mixed  last query cache */
	private $data;

	public function __construct(ICacheStorage $storage, $namespace = NULL)
	{
		$this->storage = $storage;
		$this->namespace = (string) $namespace;

		if (strpos($this->namespace, self::NAMESPACE_SEPARATOR) !== FALSE) {
			throw new \InvalidArgumentException("Namespace name contains forbidden character.");
		}
	}

	/**
	 * Returns cache storage.
	 * @return ICacheStorage
	 */
	public function getStorage()
	{
		return $this->storage;
	}

	/**
	 * Returns cache namespace.
	 * @return string
	 */
	public function getNamespace()
	{
		return $this->namespace;
	}

	/**
	 * Discards the internal cache.
	 * @return void
	 */
	public function release()
	{
		$this->key = $this->data = NULL;
	}

	/**
	 * Writes item into the cache.
	 * Dependencies are:
	 * - Cache::PRIORITY => (int) priority
	 * - Cache::EXPIRE => (timestamp) expiration
	 * - Cache::SLIDING => (bool) use sliding expiration?
	 * - Cache::TAGS => (array) tags
	 * - Cache::FILES => (array|string) file names
	 * - Cache::ITEMS => (array|string) cache items
	 * - Cache::CONSTS => (array|string) cache items
	 *
	 * @param  string key
	 * @param  mixed  value
	 * @param  array  dependencies
	 * @return mixed  value itself
	 * @throws \InvalidArgumentException
	 */
	public function save($key, $data, array $dp = NULL)
	{
		if (!is_string($key) && !is_int($key)) {
			throw new \InvalidArgumentException("Cache key name must be string or integer, " . gettype($key) ." given.");
		}
		$this->key = (string) $key;
		$key = $this->namespace . self::NAMESPACE_SEPARATOR . $key;

		// convert expire into relative amount of seconds
		if (!empty($dp[Cache::EXPIRE])) {
			$dp[Cache::EXPIRE] = Nette\Tools::createDateTime($dp[Cache::EXPIRE])->format('U') - time();
		}

		// convert FILES into CALLBACKS
		if (isset($dp[self::FILES])) {
			//clearstatcache();
			foreach ((array) $dp[self::FILES] as $item) {
				$dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkFile'), $item, @filemtime($item)); // intentionally @
			}
			unset($dp[self::FILES]);
		}

		// add namespaces to items
		if (isset($dp[self::ITEMS])) {
			$dp[self::ITEMS] = (array) $dp[self::ITEMS];
			foreach ($dp[self::ITEMS] as $k => $item) {
				$dp[self::ITEMS][$k] = $this->namespace . self::NAMESPACE_SEPARATOR . $item;
			}
		}

		// convert CONSTS into CALLBACKS
		if (isset($dp[self::CONSTS])) {
			foreach ((array) $dp[self::CONSTS] as $item) {
				$dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkConst'), $item, constant($item));
			}
			unset($dp[self::CONSTS]);
		}

		if ($data instanceof Nette\Callback || $data instanceof \Closure) {
			Nette\Environment::enterCriticalSection('Nette\Caching/' . $key);
			$data = $data->__invoke();
			Nette\Environment::leaveCriticalSection('Nette\Caching/' . $key);
		}

		if (is_object($data)) {
			$dp[self::CALLBACKS][] = array(array(__CLASS__, 'checkSerializationVersion'), get_class($data),
				Nette\Reflection\ClassReflection::from($data)->getAnnotation('serializationVersion'));
		}

		$this->data = $data;
		if ($data === NULL) {
			$this->storage->remove($key);
		} else {
			$this->storage->write($key, $data, (array) $dp);
		}
		return $data;
	}

	/**
	 * Removes items from the cache by conditions.
	 * Conditions are:
	 * - Cache::PRIORITY => (int) priority
	 * - Cache::TAGS => (array) tags
	 * - Cache::ALL => TRUE
	 *
	 * @param  array
	 * @return void
	 */
	public function clean(array $conds = NULL)
	{
		$this->release();
		$this->storage->clean((array) $conds);
	}

	/********************* interface \ArrayAccess ****************d*g**/

	/**
	 * Inserts (replaces) item into the cache (\ArrayAccess implementation).
	 * @param  string key
	 * @param  mixed
	 * @return void
	 * @throws \InvalidArgumentException
	 */
	public function offsetSet($key, $data)
	{
		$this->save($key, $data);
	}

	/**
	 * Retrieves the specified item from the cache or NULL if the key is not found (\ArrayAccess implementation).
	 * @param  string key
	 * @return mixed|NULL
	 * @throws \InvalidArgumentException
	 */
	public function offsetGet($key)
	{
		if (!is_string($key) && !is_int($key)) {
			throw new \InvalidArgumentException("Cache key name must be string or integer, " . gettype($key) ." given.");
		}

		$key = (string) $key;
		if ($this->key === $key) {
			return $this->data;
		}
		$this->key = $key;
		$this->data = $this->storage->read($this->namespace . self::NAMESPACE_SEPARATOR . $key);
		return $this->data;
	}

	/**
	 * Exists item in cache? (\ArrayAccess implementation).
	 * @param  string key
	 * @return bool
	 * @throws \InvalidArgumentException
	 */
	public function offsetExists($key)
	{
		return $this->offsetGet($key) !== NULL;
	}

	/**
	 * Removes the specified item from the cache.
	 * @param  string key
	 * @return void
	 * @throws \InvalidArgumentException
	 */
	public function offsetUnset($key)
	{
		$this->save($key, NULL);
	}

	/********************* dependency checkers ****************d*g**/

	/**
	 * Checks CALLBACKS dependencies.
	 * @param  array
	 * @return bool
	 */
	public static function checkCallbacks($callbacks)
	{
		foreach ($callbacks as $callback) {
			$func = array_shift($callback);
			if (!call_user_func_array($func, $callback)) {
				return FALSE;
			}
		}
		return TRUE;
	}

	/**
	 * Checks CONSTS dependency.
	 * @param  string
	 * @param  mixed
	 * @return bool
	 */
	private static function checkConst($const, $value)
	{
		return defined($const) && constant($const) === $value;
	}

	/**
	 * Checks FILES dependency.
	 * @param  string
	 * @param  int
	 * @return bool
	 */
	private static function checkFile($file, $time)
	{
		return @filemtime($file) == $time; // intentionally @
	}

	/**
	 * Checks object @serializationVersion label.
	 * @param  string
	 * @param  mixed
	 * @return bool
	 */
	private static function checkSerializationVersion($class, $value)
	{
		return Nette\Reflection\ClassReflection::from($class)->getAnnotation('serializationVersion') === $value;
	}

}

redpajama_set_name: RedPajamaGithub


text:
rubyiot_mobile
==============

このソフトウェアはIoTのmobile部をrubyで実装したものです。
主な機能は以下の通りです。

* 定期間隔(現状は5秒)毎にサーバからセンサー情報を取得し、一覧表示します。
* 機器(ファン)のON/OFF操作を行い、サーバを介してcontrollerへの制御を依頼します。
* サーバからセンサーの計測値を取得しグラフ表示します。
* センサーの監視値(上限、下限)を設定しサーバへ登録します。

使用方法
--------
### 動作環境

以下の環境で動作確認しています。

* OS X 10.9.5
* Xcode 6.2
* RubyMotion 3.14

### ビルド/実行方法
Xcode, RubyMotionはすでにインストールされていることを想定しています。
ここではiPhoneシミュレータでの実行方法を記します。

    $ git clone https://github.com/ossforumjp-app-IoT/rubyiot_mobile.git
    $ cd rubyiot_mobile/
    $ bundle install --path vendor/bundle
    $ bundle exec rake simulator

## ライセンス

個々のファイルについて、個別にライセンス・著作権表記があるものはそのライセンスに従います。
ライセンス表記がないものに関しては以下のライセンスを適用します。

Copyright 2015 Japan OSS Promotion Forum

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


text:
package org.mvcspec.ozark.test.validation;

import javax.mvc.binding.MvcBinding;
import javax.validation.constraints.Size;
import javax.ws.rs.FormParam;

/**
 * @author Christian Kaltepoth
 */
public class FormBean {

    @MvcBinding
    @FormParam("name")
    @Size(min = 5, max = 10)
    private String name;

    public String getName() {
        return name;
    }

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

}


text:
package com.couchbase.lite;

import com.couchbase.lite.internal.InterfaceAudience;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * A Couchbase Lite Document Revision.
 *

 * Stores information about a revision -- its docID, revID, and whether it's deleted.
 *

 * It can also store the sequence number and document contents (they can be added after creation).
 */
public abstract class Revision {

    /**
     * The document this is a revision of
     */
    protected Document document;

    /**
     * The ID of the parentRevision.
     */
    protected String parentRevID;

    /**
     * Constructor
     *
     * @exclude
     */
    @InterfaceAudience.Private
    Revision() {
        super();
    }

    /**
     * Constructor
     *
     * @exclude
     */
    @InterfaceAudience.Private
    protected Revision(Document document) {
        this.document = document;
    }

    /**
     * Get the revision's owning database.
     */
    @InterfaceAudience.Public
    public Database getDatabase() {
        return document.getDatabase();
    }

    /**
     * Get the document this is a revision of.
     */
    @InterfaceAudience.Public
    public Document getDocument() {
        return document;
    }

    /**
     * Gets the Revision's id. In the case of an unsaved revision, may return null.
     */
    @InterfaceAudience.Public
    public abstract String getId();

    /**
     * Does this revision mark the deletion of its document?
     * (In other words, does it have a "_deleted" property?)
     */
    @InterfaceAudience.Public
    public boolean isDeletion() {
        Object deleted = getProperty("_deleted");
        if (deleted == null) {
            return false;
        }
        Boolean deletedBool = (Boolean) deleted;
        return deletedBool.booleanValue();
    }

    /**
     * The contents of this revision of the document.
     * Any keys in the dictionary that begin with "_", such as "_id" and "_rev", contain
     * CouchbaseLite metadata.
     *
     * @return contents of this revision of the document.
     */
    @InterfaceAudience.Public
    public abstract Map<String, Object> getProperties();

    /**
     * The user-defined properties, without the ones reserved by CouchDB.
     * This is based on -properties, with every key whose name starts with "_" removed.
     *
     * @return user-defined properties, without the ones reserved by CouchDB.
     */
    @InterfaceAudience.Public
    public Map<String, Object> getUserProperties() {

        Map<String, Object> result = new HashMap<String, Object>();

        Map<String, Object> sourceMap = getProperties();
        for (String key : sourceMap.keySet()) {
            if (!key.startsWith("_")) {
                result.put(key, sourceMap.get(key));
            }
        }
        return result;
    }

    /**
     * The names of all attachments
     */
    @InterfaceAudience.Public
    public List<String> getAttachmentNames() {
        Map<String, Object> attachmentMetadata = getAttachmentMetadata();
        if (attachmentMetadata == null) {
            return new ArrayList<String>();
        }
        return new ArrayList<String>(attachmentMetadata.keySet());
    }

    /**
     * All attachments, as Attachment objects.
     */
    @InterfaceAudience.Public
    public List<Attachment> getAttachments() {
        Map<String, Object> attachmentMetadata = getAttachmentMetadata();
        if (attachmentMetadata == null) {
            return new ArrayList<Attachment>();
        }
        List<Attachment> result = new ArrayList<Attachment>(attachmentMetadata.size());
        for (Map.Entry<String, Object> entry : attachmentMetadata.entrySet()) {
            Attachment attachment = toAttachment(entry.getKey(), entry.getValue());
            if (attachment != null) {
                result.add(attachment);
            }
        }
        return result;
    }

    /**
     * Shorthand for getProperties().get(key)
     */
    @InterfaceAudience.Public
    public Object getProperty(String key) {
        return getProperties().get(key);
    }

    /**
     * Looks up the attachment with the given name (without fetching its contents yet).
     */
    @InterfaceAudience.Public
    public Attachment getAttachment(String name) {
        Map<String, Object> attachmentsMetadata = getAttachmentMetadata();
        if (attachmentsMetadata == null) {
            return null;
        }
        return toAttachment(name, attachmentsMetadata.get(name));
    }

    private Attachment toAttachment(String name, Object attachment) {
        if (attachment == null) {
            return null;
        } else if (attachment instanceof Attachment) {
            return (Attachment) attachment;
        } else {
            Map<String, Object> metadata = (Map<String, Object>) attachment;
            return new Attachment(this, name, metadata);
        }
    }

    /**
     * Gets the parent Revision.
     */
    @InterfaceAudience.Public
    public abstract SavedRevision getParent();

    /**
     * Gets the parent Revision's id.
     */
    @InterfaceAudience.Public
    public abstract String getParentId();

    /**
     * @exclude
     */
    @InterfaceAudience.Private
    /* package */ abstract long getParentSequence();

    /**
     * Returns the history of this document as an array of CBLRevisions, in forward order.
     * Older revisions are NOT guaranteed to have their properties available.
     *
     * @throws CouchbaseLiteException
     */
    @InterfaceAudience.Public
    public abstract List<SavedRevision> getRevisionHistory() throws CouchbaseLiteException;

    /**
     * Does this revision mark the deletion or removal (from available channels) of its document?
     * (In other words, does it have a "_deleted_ or "_removed" property?)
     */
    @InterfaceAudience.Public
    public boolean isGone() {
        boolean wasRemovedFromChannel = false;
        Object removed = getProperty("_removed");
        if (removed != null) {
            Boolean removedBoolean = (Boolean) removed;
            wasRemovedFromChannel = removedBoolean.booleanValue();
        }
        return isDeletion() || wasRemovedFromChannel;
    }

    /**
     * Compare this revision to the given revision to check for equality.
     * The comparison makes sure that both revisions have the same revision ID.
     *
     * @param o the revision to check for equality against
     * @return true if equal, false otherwise
     */
    @Override
    @InterfaceAudience.Public
    public boolean equals(Object o) {
        boolean result = false;
        if (o instanceof SavedRevision) {
            SavedRevision other = (SavedRevision) o;
            if (document.getId().equals(other.getDocument().getId()) && getId().equals(other.getId())) {
                result = true;
            }
        }
        return result;
    }

    /**
     * Custom hashCode based on the hash code of the Document Id and the Revision Id
     */
    @Override
    @InterfaceAudience.Public
    public int hashCode() {
        return document.getId().hashCode() ^ getId().hashCode();
    }

    /**
     * Returns a string representation of this Revision, including the Document Id, the Revision Id
     * and whether or not this Revision is a deletion.
     */
    @Override
    @InterfaceAudience.Public
    public String toString() {
        return '{' + this.document.getId() + " #" + this.getId() + (isDeletion() ? "DEL" : "") + '}';
    }

    /**
     * @exclude
     */
    @InterfaceAudience.Private
    protected Map<String, Object> getAttachmentMetadata() {
        return (Map<String, Object>) getProperty("_attachments");
    }

    /**
     * @exclude
     */
    @InterfaceAudience.Private
    protected void setParentRevisionID(String parentRevID) {
        this.parentRevID = parentRevID;
    }

    /**
     * @exclude
     */
    @InterfaceAudience.Private
    protected abstract long getSequence();

    /**
     * Generation number: 1 for a new document, 2 for the 2nd revision, ...
     * Extracted from the numeric prefix of the revID.
     *
     * @exclude
     */
    @InterfaceAudience.Private
    protected int getGeneration() {
        return generationFromRevID(getId());
    }

    /**
     * @exclude
     */
    @InterfaceAudience.Private
    public static int generationFromRevID(String revID) {
        int generation = 0;
        int length = Math.min(revID == null ? 0 : revID.length(), 9);
        for (int i = 0; i < length; ++i) {
            char c = revID.charAt(i);
            if (Character.isDigit(c))
                generation = 10 * generation + Character.getNumericValue(c);
            else if (c == '-')
                return generation;
            else
                break;
        }
        return 0;
    }
}


text:
package dpl.bobsun.dummypicloader.activities;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import java.util.ArrayList;

import dpl.bobsun.dummypicloader.R;
import dpl.bobsun.dummypicloader.adapters.ImageViewPagerAdapter;

/**
 * Created by bob.sun on 15/7/28.
 */
public class ImagePreviewActivity extends AppCompatActivity {
    private ArrayList images;
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_imagepreviewactivity);
        images = getIntent().getStringArrayListExtra("image_list");
        int index = getIntent().getIntExtra("start_image", 0);
        setupViewPager(index);
//        DummyPicLoader.getInstance(this.getApplicationContext()).loadImageFromFile(getIntent().getStringExtra("image_file_path"), (ImageView) findViewById(R.id.id_imageview));
    }

    private void setupViewPager(int index){
        ViewPager viewPager = (ViewPager) findViewById(R.id.id_viewpager_images);
        ImageViewPagerAdapter imageViewPagerAdapter = new ImageViewPagerAdapter(getSupportFragmentManager());
        imageViewPagerAdapter.setImages(images);
        viewPager.setAdapter(imageViewPagerAdapter);
        viewPager.setCurrentItem(index);
    }
}


text:
Ext.define('Df.data.reader.Csv', {
	extend: 'Ext.data.reader.Json',
	alias: 'reader.csv',
	responseType: 'text',
	getResponseData: function(response) {
		var error;
		try {
			var start = performance.now();
			var results = Papa.parse(response.responseText);
			console.log('csv', (performance.now()-start) + ' ms');
			return results.data;
		}
		catch (ex) {
			error = this.createReadError(ex.message);
            Ext.Logger.warn('Unable to parse the CSV returned by the server');
            this.fireEvent('exception', this, response, error);
            return error;
		}
	}
});


text:
package io.deepsense.deeplang.doperables.spark.wrappers.estimators

import io.deepsense.deeplang.doperables.spark.wrappers.params.common.RegressionImpurity.Variance
import io.deepsense.deeplang.params.ParamPair
import io.deepsense.deeplang.params.selections.NameSingleColumnSelection

class DecisionTreeRegressionSmokeTest extends AbstractEstimatorModelWrapperSmokeTest {

  override def className: String = "DecisionTreeRegression"

  override val estimator = new DecisionTreeRegression()

  import estimator._

  override val estimatorParams: Seq[ParamPair[_]] = Seq(
    maxDepth -> 4.0,
    maxBins -> 25.0,
    minInstancesPerNode -> 1.0,
    minInfoGain -> 0.1,
    maxMemoryInMB -> 200.0,
    cacheNodeIds -> false,
    checkpointInterval -> 11.0,
    seed -> 125.0,
    impurity -> Variance(),
    featuresColumn -> NameSingleColumnSelection("myFeatures"),
    labelColumn -> NameSingleColumnSelection("myLabel"),
    predictionColumn -> "pred"
  )
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/transitional.dtd">

  <meta HTTP-EQUIV=CONTENT-TYPE CONTENT="text/html; charset=utf-8">
  <title>Need property attribute control</title>

First page Back Continue Last page Overview Graphics

Need property attribute control

ES3 semantics define per-property attributes:

ReadOnly → writable: does assignment work?

DontEnum → enumerable: does for-in see it?

DontDelete → configurable: can its shape change?

ES3 code can only create properties that are

	writable, enumerable, and deletable.

Now controllable by ES5 code.


text:
//
// TextChangeEventArgsExtensions.cs
//
// Author:
//       Matt Ward <matt.ward@xamarin.com>
//
// Copyright (c) 2016 Xamarin Inc. (http://xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System.Collections.Generic;
using System.Linq;
using Microsoft.PowerShell.EditorServices.Protocol.LanguageServer;
using MonoDevelop.Core.Text;
using MonoDevelop.Ide.Editor;

namespace MonoDevelop.PowerShell
{
	static class TextChangeEventArgsExtensions
	{
		public static IEnumerable<TextDocumentChangeEvent> CreateTextDocumentChangeEvents (this TextChangeEventArgs e, TextEditor editor)
		{
			return e.TextChanges.Select (textChange => CreateTextDocumentChangeEvent (textChange, editor));
		}

		public static TextDocumentChangeEvent CreateTextDocumentChangeEvent (this TextChange textChange, TextEditor editor)
		{
			int startOffset = textChange.Offset;
			int endOffset = textChange.Offset + textChange.RemovalLength;

			var startLocation = editor.OffsetToLocation (startOffset);
			var endLocation = editor.OffsetToLocation (endOffset);

			return new TextDocumentChangeEvent {
				Range = new Range {
					Start = startLocation.CreatePosition (),
					End = endLocation.CreatePosition ()
				},
				RangeLength = endOffset - startOffset,
				Text = textChange.InsertedText.Text
			};
		}

		public static Position CreatePosition (this DocumentLocation location)
		{
			return new Position {
				Character = location.Column - 1,
				Line = location.Line - 1
			};
		}
	}
}


text:
package com.github.mgoeminne.iban

import org.scalatest.{Inspectors, Matchers, FlatSpec}

/**
 * Tests dedicated to Belgian BBANs.
 */
class BBANBelgiumTest extends FlatSpec with Matchers with Inspectors
{
   val validBBANs = Seq("068-2492526-41", "310-1269855-17",
                        "539-0075470-34")

   val invalidBBANs = Seq("844-0103701-34")

   "All valid BBAN" should "pass the validation test" in {
      forAll(validBBANs){ x => new BBANBelgium(x).isValid shouldBe Some(true) }
   }

   it should "produce correct string representation" in {
      forAll(invalidBBANs){x => new BBANBelgium(x).toString shouldBe x}
   }

   "All invalid BBAN" should "not pass the validation test" in {
      forAll(invalidBBANs){ x=> new BBANBelgium(x).isValid shouldBe Some(false)}
   }
}


text:
'use strict';
const problem7 = require('./problem-0007');

describe('nthPrime', () => {
  it('should calculate nth prime for known input', () => {
    expect(problem7.nthPrime(3)).toBe(5);
    expect(problem7.nthPrime(6)).toBe(13);
    expect(problem7.nthPrime(1)).toBe(2);
  });
});


text:
using System;
using System.Linq.Expressions;

namespace Mapster
{
    public class CompileException : InvalidOperationException
    {
        public CompileException(CompileArgument argument, Exception innerException) : base(null, innerException)
        {
            this.Argument = argument;
        }

        public override string Message =>
            "Error while compiling\n" +
            $"source={this.Argument.SourceType}\n" +
            $"destination={this.Argument.DestinationType}\n" +
            $"type={this.Argument.MapType}";

        public CompileArgument Argument { get; }
        public LambdaExpression? Expression { get; internal set; }
    }
}


text:
enum ContentSettingsType {
  // "DEFAULT" is only used as an argument to the Content Settings Window
  // opener; there it means "whatever was last shown".
  CONTENT_SETTINGS_TYPE_DEFAULT = -1,
  CONTENT_SETTINGS_TYPE_COOKIES = 0,
  CONTENT_SETTINGS_TYPE_IMAGES,
  CONTENT_SETTINGS_TYPE_JAVASCRIPT,
  CONTENT_SETTINGS_TYPE_PLUGINS,
  CONTENT_SETTINGS_TYPE_POPUPS,
  CONTENT_SETTINGS_TYPE_GEOLOCATION,
  CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
  CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
  CONTENT_SETTINGS_TYPE_FULLSCREEN,
  CONTENT_SETTINGS_TYPE_MOUSELOCK,
  CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
  CONTENT_SETTINGS_TYPE_MEDIASTREAM,  // Default setting for MIC and CAMERA.
  CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
  CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
  CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS,
  CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
  CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
  CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
#if defined(OS_WIN)
  CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP,
#endif
  CONTENT_SETTINGS_NUM_TYPES,
};

#endif  // CHROME_COMMON_CONTENT_SETTINGS_TYPES_H_


text:
namespace sandbox {

namespace {

base::Value ProcessIdList(std::vector<uint32_t> process_ids) {
  base::Value results(base::Value::Type::LIST);
  for (const auto pid : process_ids) {
    results.Append(base::strict_cast<double>(pid));
  }
  return results;
}

std::string GetTokenLevelInEnglish(TokenLevel token) {
  switch (token) {
    case USER_LOCKDOWN:
      return "Lockdown";
    case USER_RESTRICTED:
      return "Restricted";
    case USER_LIMITED:
      return "Limited";
    case USER_INTERACTIVE:
      return "Interactive";
    case USER_NON_ADMIN:
      return "Non Admin";
    case USER_RESTRICTED_SAME_ACCESS:
      return "Restricted Same Access";
    case USER_UNPROTECTED:
      return "Unprotected";
    case USER_RESTRICTED_NON_ADMIN:
      return "Restricted Non Admin";
    case USER_LAST:
      DCHECK(false) << "Unknown TokenType";
      return "Unknown";
  }
}

std::string GetJobLevelInEnglish(JobLevel job) {
  switch (job) {
    case JOB_LOCKDOWN:
      return "Lockdown";
    case JOB_RESTRICTED:
      return "Restricted";
    case JOB_LIMITED_USER:
      return "Limited User";
    case JOB_INTERACTIVE:
      return "Interactive";
    case JOB_UNPROTECTED:
      return "Unprotected";
    case JOB_NONE:
      return "None";
  }
}

std::string GetIntegrityLevelInEnglish(IntegrityLevel integrity) {
  switch (integrity) {
    case INTEGRITY_LEVEL_SYSTEM:
      return "S-1-16-16384 System";
    case INTEGRITY_LEVEL_HIGH:
      return "S-1-16-12288 High";
    case INTEGRITY_LEVEL_MEDIUM:
      return "S-1-16-8192 Medium";
    case INTEGRITY_LEVEL_MEDIUM_LOW:
      return "S-1-16-6144 Medium Low";
    case INTEGRITY_LEVEL_LOW:
      return "S-1-16-4096 Low";
    case INTEGRITY_LEVEL_BELOW_LOW:
      return "S-1-16-2048 Below Low";
    case INTEGRITY_LEVEL_UNTRUSTED:
      return "S-1-16-0 Untrusted";
    case INTEGRITY_LEVEL_LAST:
      return "Default";
  }
}

base::string16 GetSidAsString(const Sid* sid) {
  base::string16 result;
  if (!sid->ToSddlString(&result))
    DCHECK(false) << "Failed to make sddl string";
  return result;
}

std::string GetMitigationsAsHex(MitigationFlags mitigations) {
  return base::StringPrintf("%016" PRIx64,
                            base::checked_cast<uint64_t>(mitigations));
}

std::string GetPlatformMitigationsAsHex(MitigationFlags mitigations) {
  DWORD64 platform_flags[2] = {0};
  size_t flags_size = 0;
  sandbox::ConvertProcessMitigationsToPolicy(mitigations, &(platform_flags[0]),
                                             &flags_size);
  DCHECK(flags_size / sizeof(DWORD64) <= 2)
      << "Unexpected mitigation flags size";
  if (flags_size == 2 * sizeof(DWORD64))
    return base::StringPrintf("%016" PRIx64 "%016" PRIx64, platform_flags[0],
                              platform_flags[1]);
  return base::StringPrintf("%016" PRIx64, platform_flags[0]);
}

std::string GetIpcTagAsString(IpcTag service) {
  switch (service) {
    case IpcTag::UNUSED:
      DCHECK(false) << "Unused IpcTag";
      return "Unused";
    case IpcTag::PING1:
      return "Ping1";
    case IpcTag::PING2:
      return "Ping2";
    case IpcTag::NTCREATEFILE:
      return "NtCreateFile";
    case IpcTag::NTOPENFILE:
      return "NtOpenFile";
    case IpcTag::NTQUERYATTRIBUTESFILE:
      return "NtQueryAttributesFile";
    case IpcTag::NTQUERYFULLATTRIBUTESFILE:
      return "NtQueryFullAttributesFile";
    case IpcTag::NTSETINFO_RENAME:
      return "NtSetInfoRename";
    case IpcTag::CREATENAMEDPIPEW:
      return "CreateNamedPipeW";
    case IpcTag::NTOPENTHREAD:
      return "NtOpenThread";
    case IpcTag::NTOPENPROCESS:
      return "NtOpenProcess";
    case IpcTag::NTOPENPROCESSTOKEN:
      return "NtOpenProcessToken";
    case IpcTag::NTOPENPROCESSTOKENEX:
      return "NtOpenProcessTokenEx";
    case IpcTag::CREATEPROCESSW:
      return "CreateProcessW";
    case IpcTag::CREATEEVENT:
      return "CreateEvent";
    case IpcTag::OPENEVENT:
      return "OpenEvent";
    case IpcTag::NTCREATEKEY:
      return "NtCreateKey";
    case IpcTag::NTOPENKEY:
      return "NtOpenKey";
    case IpcTag::GDI_GDIDLLINITIALIZE:
      return "GdiDllInitialize";
    case IpcTag::GDI_GETSTOCKOBJECT:
      return "GetStockObject";
    case IpcTag::USER_REGISTERCLASSW:
      return "RegisterClassW";
    case IpcTag::CREATETHREAD:
      return "CreateThread";
    case IpcTag::USER_ENUMDISPLAYMONITORS:
      return "EnumDisplayMonitors";
    case IpcTag::USER_ENUMDISPLAYDEVICES:
      return "EnumDisplayDevices";
    case IpcTag::USER_GETMONITORINFO:
      return "GetMonitorInfo";
    case IpcTag::GDI_CREATEOPMPROTECTEDOUTPUTS:
      return "CreateOPMProtectedOutputs";
    case IpcTag::GDI_GETCERTIFICATE:
      return "GetCertificate";
    case IpcTag::GDI_GETCERTIFICATESIZE:
      return "GetCertificateSize";
    case IpcTag::GDI_DESTROYOPMPROTECTEDOUTPUT:
      return "DestroyOPMProtectedOutput";
    case IpcTag::GDI_CONFIGUREOPMPROTECTEDOUTPUT:
      return "ConfigureOPMProtectedOutput";
    case IpcTag::GDI_GETOPMINFORMATION:
      return "GetOPMInformation";
    case IpcTag::GDI_GETOPMRANDOMNUMBER:
      return "GetOPMRandomNumber";
    case IpcTag::GDI_GETSUGGESTEDOPMPROTECTEDOUTPUTARRAYSIZE:
      return "GetSuggestedOPMProtectedOutputArraySize";
    case IpcTag::GDI_SETOPMSIGNINGKEYANDSEQUENCENUMBERS:
      return "SetOPMSigningKeyAndSequenceNumbers";
    case IpcTag::NTCREATESECTION:
      return "NtCreateSection";
    case IpcTag::LAST:
      DCHECK(false) << "Unknown IpcTag";
      return "Unknown";
  }
}

std::string GetOpcodeAction(EvalResult action) {
  switch (action) {
    case EVAL_TRUE:
      return "true";
    case EVAL_FALSE:
      return "false";
    case EVAL_ERROR:
      return "error";
    case ASK_BROKER:
      return "askBroker";
    case DENY_ACCESS:
      return "deny";
    case GIVE_READONLY:
      return "readonly";
    case GIVE_ALLACCESS:
      return "allaccess";
    case GIVE_CACHED:
      return "cached";
    case GIVE_FIRST:
      return "first";
    case SIGNAL_ALARM:
      return "alarm";
    case FAKE_SUCCESS:
      return "fakeSuccess";
    case FAKE_ACCESS_DENIED:
      return "fakeDenied";
    case TERMINATE_PROCESS:
      return "terminate";
  }
}

std::string GetStringMatchOperation(int pos, uint32_t options) {
  if (pos == 0) {
    if (options & EXACT_LENGTH)
      return "exact";
    else
      return "prefix";
  } else if (pos < 0) {
    return "scan";
  } else if (pos == kSeekToEnd) {
    return "ends";
  } else {
    DCHECK(false) << "Invalid pos (" << pos << ")";
    return "unknown";
  }
}

std::string GetPolicyOpcode(const PolicyOpcode* opcode, bool continuation) {
  // See |policy_engine_opcodes.cc|.
  uint32_t args[4];
  auto options = opcode->GetOptions();
  auto param = opcode->GetParameter();
  std::string condition;

  if (options & kPolNegateEval)
    condition += "!(";

  switch (opcode->GetID()) {
    case OP_ALWAYS_FALSE:
      condition += "false";
      break;
    case OP_ALWAYS_TRUE:
      condition += "true";
      break;
    case OP_NUMBER_MATCH:
      opcode->GetArgument(1, &args[1]);
      if (args[1] == UINT32_TYPE) {
        opcode->GetArgument(0, &args[0]);
        condition += base::StringPrintf("p[%d] == %x", param, args[0]);
      } else {
        const void* match_ptr = nullptr;
        opcode->GetArgument(0, &match_ptr);
        condition += base::StringPrintf("p[%d] == %p", param, match_ptr);
      }
      break;
    case OP_NUMBER_MATCH_RANGE:
      opcode->GetArgument(0, &args[0]);
      opcode->GetArgument(1, &args[1]);
      condition +=
          base::StringPrintf("%x <= p[%d] <= %x", args[0], param, args[1]);
      break;
    case OP_NUMBER_AND_MATCH:
      opcode->GetArgument(0, &args[0]);
      condition += base::StringPrintf("p[%d] & %x", param, args[0]);
      break;
    case OP_WSTRING_MATCH: {
      int pos;
      opcode->GetArgument(1, &args[1]);  // Length.
      opcode->GetArgument(2, &pos);      // Position.
      opcode->GetArgument(3, &args[3]);  // Options.
      // These are not nul-terminated so we have to wrap them here.
      auto match_string = std::wstring(opcode->GetRelativeString(0), 0,
                                       static_cast<size_t>(args[1]));
      condition += GetStringMatchOperation(pos, args[3]);
      if (args[3] & CASE_INSENSITIVE)
        condition += "_i";
      condition +=
          base::StringPrintf("(p[%d], '%S')", param, match_string.c_str());
    } break;
    case OP_ACTION:
      opcode->GetArgument(0, &args[0]);
      condition += GetOpcodeAction(static_cast<EvalResult>(args[0]));
      break;
    default:
      DCHECK(false) << "Unknown Opcode";
      return "Unknown";
  }

  if (options & kPolNegateEval)
    condition += ")";
  // If there is another rule add a joining token.
  if (continuation) {
    if (options & kPolUseOREval)
      condition += " || ";
    else
      condition += " && ";
  }
  return condition;
}

// Uses |service| to index into |policy_rules| returning a list of opcodes.
base::Value GetPolicyOpcodes(const PolicyGlobal* policy_rules, IpcTag service) {
  base::Value entry(base::Value::Type::LIST);
  PolicyBuffer* policy_buffer =
      policy_rules->entry[static_cast<size_t>(service)];
  // Build up rules and emit when we hit an action.
  std::string cur_rule;
  for (size_t i = 0; i < policy_buffer->opcode_count; i++) {
    const PolicyOpcode* opcode = &policy_buffer->opcodes[i];
    if (opcode->GetID() != OP_ACTION) {
      DCHECK(i + 1 < policy_buffer->opcode_count)
          << "Non-actions should not terminate rules";
      bool peak = policy_buffer->opcodes[i + 1].GetID() != OP_ACTION;
      cur_rule += GetPolicyOpcode(opcode, peak);
    } else {
      cur_rule += " -> ";
      cur_rule += GetPolicyOpcode(opcode, false);
      entry.Append(cur_rule);
      cur_rule.clear();
    }
  }
  return entry;
}

base::Value GetPolicyRules(const PolicyGlobal* policy_rules) {
  DCHECK(policy_rules);
  base::Value results(base::Value::Type::DICTIONARY);

  for (size_t i = 0; i < kMaxServiceCount; i++) {
    if (!policy_rules->entry[i])
      continue;
    IpcTag service = static_cast<IpcTag>(i);
    results.SetKey(GetIpcTagAsString(service),
                   GetPolicyOpcodes(policy_rules, service));
  }

  return results;
}

}  // namespace

// We are a friend of PolicyBase so that we can steal its private members
// quickly in the BrokerServices tracker thread.
PolicyDiagnostic::PolicyDiagnostic(PolicyBase* policy) {
  DCHECK(policy);
  // TODO(crbug/997273) Add more fields once webui plumbing is complete.
  {
    AutoLock lock(&policy->lock_);
    for (auto&& target_process : policy->targets_) {
      process_ids_.push_back(
          base::strict_cast<uint32_t>(target_process->ProcessId()));
    }
  }
  lockdown_level_ = policy->lockdown_level_;
  job_level_ = policy->job_level_;

  // Select the final integrity level.
  if (policy->delayed_integrity_level_ == INTEGRITY_LEVEL_LAST)
    desired_integrity_level_ = policy->integrity_level_;
  else
    desired_integrity_level_ = policy->delayed_integrity_level_;

  desired_mitigations_ = policy->mitigations_ | policy->delayed_mitigations_;

  if (policy->app_container_profile_)
    app_container_sid_ =
        std::make_unique<Sid>(policy->app_container_profile_->GetPackageSid());
  if (policy->lowbox_sid_)
    lowbox_sid_ = std::make_unique<Sid>(policy->lowbox_sid_);

  if (policy->policy_) {
    size_t policy_mem_size = policy->policy_->data_size + sizeof(PolicyGlobal);
    policy_rules_.reset(
        static_cast<sandbox::PolicyGlobal*>(::operator new(policy_mem_size)));
    memcpy(policy_rules_.get(), policy->policy_, policy_mem_size);
    // Fixup pointers (see |PolicyGlobal| in policy_low_level.h).
    PolicyBuffer** original_entries = policy->policy_->entry;
    PolicyBuffer** copy_base = policy_rules_->entry;
    for (size_t i = 0; i < kMaxServiceCount; i++) {
      if (policy_rules_->entry[i]) {
        policy_rules_->entry[i] = reinterpret_cast<PolicyBuffer*>(
            reinterpret_cast<char*>(copy_base) +
            (reinterpret_cast<char*>(original_entries[i]) -
             reinterpret_cast<char*>(original_entries)));
      }
    }
  }
}

PolicyDiagnostic::~PolicyDiagnostic() = default;

const char* PolicyDiagnostic::JsonString() {
  // Lazily constructs json_string_.
  if (json_string_)
    return json_string_->c_str();

  base::Value value(base::Value::Type::DICTIONARY);
  value.SetKey(kProcessIds, ProcessIdList(process_ids_));
  value.SetKey(kLockdownLevel,
               base::Value(GetTokenLevelInEnglish(lockdown_level_)));
  value.SetKey(kJobLevel, base::Value(GetJobLevelInEnglish(job_level_)));
  value.SetKey(
      kDesiredIntegrityLevel,
      base::Value(GetIntegrityLevelInEnglish(desired_integrity_level_)));
  value.SetKey(kDesiredMitigations,
               base::Value(GetMitigationsAsHex(desired_mitigations_)));
  value.SetKey(kPlatformMitigations,
               base::Value(GetPlatformMitigationsAsHex(desired_mitigations_)));

  if (app_container_sid_)
    value.SetKey(kAppContainerSid,
                 base::Value(GetSidAsString(app_container_sid_.get())));

  if (lowbox_sid_)
    value.SetKey(kLowboxSid, base::Value(GetSidAsString(lowbox_sid_.get())));

  if (policy_rules_)
    value.SetKey(kPolicyRules, GetPolicyRules(policy_rules_.get()));

  auto json_string = std::make_unique<std::string>();
  JSONStringValueSerializer to_json(json_string.get());
  CHECK(to_json.Serialize(value));
  json_string_ = std::move(json_string);
  return json_string_->c_str();
}

}  // namespace sandbox


text:
<?php bloginfo('name'); ?>

<?php bloginfo('description'); ?>


text:
require 'rails_helper'

RSpec.describe Subscription, type: :model do
  subject { create :subscription, :location_subscription }
  it { is_expected.to validate_presence_of :user }
  it { is_expected.to validate_presence_of :role }
  it { is_expected.to belong_to :user }
  it { is_expected.to belong_to :subscriptable }
end


text:
package org.apache.isis.core.metamodel.facets.value.password;

import org.apache.isis.applib.value.Password;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facets.object.value.vsp.ValueFacetUsingSemanticsProviderFactory;

public class PasswordValueFacetUsingSemanticsProviderFactory extends ValueFacetUsingSemanticsProviderFactory<Password> {

    public PasswordValueFacetUsingSemanticsProviderFactory() {
        super();
    }

    @Override
    public void process(final ProcessClassContext processClassContext) {
        final Class<?> type = processClassContext.getCls();
        final FacetHolder holder = processClassContext.getFacetHolder();

        if (type != org.apache.isis.applib.value.Password.class) {
            return;
        }
        addFacets(new PasswordValueSemanticsProvider(holder, getConfiguration(), getContext()));
    }

}