text:
/// <reference path="../../includes.d.ts" />
/// <reference path="kubernetesPlugin.d.ts" />
declare module Kubernetes {
    var FABRIC8_PROJECT_JSON: string;
    var environemntsConfigMapName: string;
    /**
     * The object which keeps track of all the pods, replication controllers, services and their associations
     */
    class KubernetesModelService {
        kubernetes: KubernetesState;
        apps: any[];
        replicationControllers: Array<any>;
        services: any[];
        pods: any[];
        hosts: any[];
        namespaces: Array<string>;
        appViews: any[];
        replicationcontrollers: any[];
        replicasets: any[];
        replicas: any[];
        deployments: any[];
        deploymentconfigs: any[];
        allDeployments: any[];
        ingresses: any[];
        routes: any[];
        templates: any[];
        redraw: boolean;
        resourceVersions: {};
        deploymentsByKey: {};
        podsByHost: {};
        servicesByKey: {};
        replicationControllersByKey: {};
        replicasByKey: {};
        podsByKey: {};
        namespaceEnvironments: {};
        fetched: boolean;
        isFetched(kind: string): boolean;
        showRunButton: boolean;
        configmaps: any[];
        environments: any[];
        buildconfigs: any[];
        events: any[];
        workspaces: any[];
        projects: any[];
        project: any;
        watcher: WatcherService;
        serviceApps: Array<any>;
        $keepPolling(): boolean;
        orRedraw(flag: any): void;
        getService(namespace: any, id: any): any;
        getConfigMap(name: any): any;
        getReplicationController(namespace: any, id: any): any;
        getNamespaceOrProject(name: any): any;
        getDeployment(namespace: any, id: any): any;
        getPod(namespace: any, id: any): any;
        podsForNamespace(namespace?: any): any[];
        getBuildConfig(name: any): any;
        findObject(kind: any, name: any): {};
        objectsWithLabels(desiredLabels: any): any[];
        getProject(name: any, ns?: any): any;
        setProject(buildConfig: any): void;
        /**
         * Returns the current selected namespace or the default namespace
         */
        currentNamespace(): any;
        protected updateIconUrlAndAppInfo(entity: any, nameField: string): void;
        maybeInit(): void;
        protected buildHosts(): any[];
        protected handleRoutes(): void;
        protected enrichDeployments(): void;
        protected enrichReplicas(): void;
        protected enrichServices(): void;
        protected enrichPods(): void;
        protected updateApps(): void;
        /**
         * Returns the name of the environment for the given project namespace and environment namespace
         */
        environmentName(projectNamespace: any, environmentNamespace: any): any;
        /**
         * Loads the environments for the given project
         */
        protected loadEnvironments(): any[];
        createEnvironment(key: any, values: any, ns: any): any;
        protected discoverPodConnections(entity: any): void;
    }
    function getJenkinshiftBuildConfigURL($scope: any): string;
}


text:
//
// Copyright (c) 2010-2013, Peter Jekel
// All rights reserved.
//
//	The Checkbox Tree (cbtree) is released under to following three licenses:
//
//	1 - BSD 2-Clause				(http://thejekels.com/cbtree/LICENSE)
//	2 - The "New" BSD License		(http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L13)
//	3 - The Academic Free License	(http://trac.dojotoolkit.org/browser/dojo/trunk/LICENSE#L43)
//
define(function () {

	function IE8_Event(target, type, props, ieEventObject) {
		// summary:
		//		Create a DOM4 style event (remove with 2.0)
		// NOTE:
		//		THIS FUNCTION SHOULD ONLY BE USED WHEN RUNNING IE < 9
		this.target = target;
		this.currentTarget = target;
		this.eventPhase = 2;
		this.bubbles = !!(props && props.bubbles);
		this.cancelable = !!(props && props.cancelable);
		this.isTrusted = false;
		this.defaultPrevented = false;
		this.ieEventObject = ieEventObject;
		this.type = type;
		this.stopPropagation = this.stopImmediatePropagation = function () {
			ieEventObject.cancelBubble = true;
		};
		this.preventDefault = function () {
			ieEventObject.returnValue = false;
			this.defaultPrevented = true;
		};
	}

	return IE8_Event;
});	/* end define() */

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

  <meta name="robots" content="noindex, nofollow">

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Läkare Utan Gränser - Besök vår gåvoshop</title>

      <meta name="description" content="Besök vår gåvoshop" />

  <meta name="author" content="">

  <link rel="stylesheet" media="screen" href="/prototyp/dist/css/bootstrap.css" type="text/css" />

  <link rel="stylesheet" media="screen" href="/prototyp/assets/bootstrap-slider/bootstrap-slider.min.css" type="text/css" />

  <link rel="stylesheet" media="screen" href="/prototyp/assets/bootstrap-modal-carousel/css/bootstrap-modal-carousel.min.css" type="text/css" />

  <link href="/prototyp/assets/flexslider/flexslider.css" rel="stylesheet">

  <link rel="stylesheet" type="text/css" href="/prototyp/assets/socialicious/css/socialicious.css">

  <link rel="stylesheet" type="text/css" href="/prototyp/assets/socjs/soc.min.css">

  <link href="/prototyp/assets/css/custom.css" rel="stylesheet">

  Hoppa till huvudinnehåll

                Om oss

                Givarservice

                Press

                Kontakt

              <button type="button" class="btn btn-primary navbar-btn">Ge en gåva</button>

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
          Toggle navigation

        </button>
        Läkare Utan Gränser

Stöd oss

Bli fältarbetare

Vårt arbete

            Sök

Om oss

Givarservice

Press

Kontakt

        <button type="button" class="btn btn-default navbar-btn">Ge en gåva</button>

Besök vår gåvoshop

            Dela

Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Donec sed odio dui. Nulla vitae elit libero, a pharetra augue. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Aktuellt

24 November 2014

            Säker förlossning för syriska flyktingar

6 November 2014

            Läkemedelsresistent tuberkulos är en global folkhälsokris

3 October 2014

            Ebola - Irak - Sydsudan - Gaza - CAR - Syrien

26 September 2014

            Min vän på andra sidan staketet

19 September 2014

            Vi söker ny generalsekreterare

Kontakta oss

010-199 32 00 (växel)

        010-199 33 00 (givarservice)

        010-199 32 01 (fax)

        Läkare Utan Gränser

        Fredsborgsgatan 24

        4 trappor

        Box 47021

        100 74 Stockholm

Stöd oss

Bli fältarbetare

Vårt arbete

Om oss

Givarservice

Press

Kontakt

          Lediga tjänster

          Om cookies

© Copyright 2015 | Läkare Utan Gränser


text:
package lxcmap

import (
	"fmt"
	"net"
	"unsafe"

	"github.com/cilium/cilium/pkg/addressing"
	"github.com/cilium/cilium/pkg/bpf"
	"github.com/cilium/cilium/pkg/mac"
)

const (
	MapName = "cilium_lxc"

	// MaxEntries represents the maximum number of endpoints in the map
	MaxEntries = 65535

	// PortMapMax represents the maximum number of Ports Mapping per container.
	PortMapMax = 16
)

var (
	// LXCMap represents the BPF map for endpoints
	LXCMap = bpf.NewMap(MapName,
		bpf.MapTypeHash,
		&EndpointKey{},
		int(unsafe.Sizeof(EndpointKey{})),
		&EndpointInfo{},
		int(unsafe.Sizeof(EndpointInfo{})),
		MaxEntries,
		0, 0,
		bpf.ConvertKeyValue,
	).WithCache().WithPressureMetric()
)

// MAC is the __u64 representation of a MAC address.
type MAC uint64

func (m MAC) String() string {
	return fmt.Sprintf("%02X:%02X:%02X:%02X:%02X:%02X",
		uint64((m & 0x0000000000FF)),
		uint64((m&0x00000000FF00)>>8),
		uint64((m&0x000000FF0000)>>16),
		uint64((m&0x0000FF000000)>>24),
		uint64((m&0x00FF00000000)>>32),
		uint64((m&0xFF0000000000)>>40),
	)
}

const (
	// EndpointFlagHost indicates that this endpoint represents the host
	EndpointFlagHost = 1
)

// EndpointFrontend is the interface to implement for an object to synchronize
// with the endpoint BPF map.
type EndpointFrontend interface {
	LXCMac() mac.MAC
	GetNodeMAC() mac.MAC
	GetIfIndex() int
	GetID() uint64
	IPv4Address() addressing.CiliumIPv4
	IPv6Address() addressing.CiliumIPv6
}

// GetBPFKeys returns all keys which should represent this endpoint in the BPF
// endpoints map
func GetBPFKeys(e EndpointFrontend) []*EndpointKey {
	keys := []*EndpointKey{}
	if e.IPv6Address().IsSet() {
		keys = append(keys, NewEndpointKey(e.IPv6Address().IP()))
	}

	if e.IPv4Address().IsSet() {
		keys = append(keys, NewEndpointKey(e.IPv4Address().IP()))
	}

	return keys
}

// GetBPFValue returns the value which should represent this endpoint in the
// BPF endpoints map
// Must only be called if init() succeeded.
func GetBPFValue(e EndpointFrontend) (*EndpointInfo, error) {
	mac, err := e.LXCMac().Uint64()
	if err != nil {
		return nil, fmt.Errorf("invalid LXC MAC: %v", err)
	}

	nodeMAC, err := e.GetNodeMAC().Uint64()
	if err != nil {
		return nil, fmt.Errorf("invalid node MAC: %v", err)
	}

	info := &EndpointInfo{
		IfIndex: uint32(e.GetIfIndex()),
		// Store security identity in network byte order so it can be
		// written into the packet without an additional byte order
		// conversion.
		LxcID:   uint16(e.GetID()),
		MAC:     MAC(mac),
		NodeMAC: MAC(nodeMAC),
	}

	return info, nil

}

type pad4uint32 [4]uint32

// DeepCopyInto is a deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *pad4uint32) DeepCopyInto(out *pad4uint32) {
	copy(out[:], in[:])
	return
}

// EndpointInfo represents the value of the endpoints BPF map.
//
// Must be in sync with struct endpoint_info in <bpf/lib/common.h>
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapValue
type EndpointInfo struct {
	IfIndex uint32 `align:"ifindex"`
	Unused  uint16 `align:"unused"`
	LxcID   uint16 `align:"lxc_id"`
	Flags   uint32 `align:"flags"`
	// go alignment
	_       uint32
	MAC     MAC        `align:"mac"`
	NodeMAC MAC        `align:"node_mac"`
	Pad     pad4uint32 `align:"pad"`
}

// GetValuePtr returns the unsafe pointer to the BPF value
func (v *EndpointInfo) GetValuePtr() unsafe.Pointer { return unsafe.Pointer(v) }

// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapKey
type EndpointKey struct {
	bpf.EndpointKey
}

// NewValue returns a new empty instance of the structure representing the BPF
// map value
func (k EndpointKey) NewValue() bpf.MapValue { return &EndpointInfo{} }

// NewEndpointKey returns an EndpointKey based on the provided IP address. The
// address family is automatically detected
func NewEndpointKey(ip net.IP) *EndpointKey {
	return &EndpointKey{
		EndpointKey: bpf.NewEndpointKey(ip),
	}
}

// IsHost returns true if the EndpointInfo represents a host IP
func (v *EndpointInfo) IsHost() bool {
	return v.Flags&EndpointFlagHost != 0
}

// String returns the human readable representation of an EndpointInfo
func (v *EndpointInfo) String() string {
	if v.Flags&EndpointFlagHost != 0 {
		return "(localhost)"
	}

	return fmt.Sprintf("id=%-5d flags=0x%04X ifindex=%-3d mac=%s nodemac=%s",
		v.LxcID,
		v.Flags,
		v.IfIndex,
		v.MAC,
		v.NodeMAC,
	)
}

// WriteEndpoint updates the BPF map with the endpoint information and links
// the endpoint information to all keys provided.
func WriteEndpoint(f EndpointFrontend) error {
	info, err := GetBPFValue(f)
	if err != nil {
		return err
	}

	// FIXME: Revert on failure
	for _, v := range GetBPFKeys(f) {
		if err := LXCMap.Update(v, info); err != nil {
			return err
		}
	}

	return nil
}

// AddHostEntry adds a special endpoint which represents the local host
func AddHostEntry(ip net.IP) error {
	key := NewEndpointKey(ip)
	ep := &EndpointInfo{Flags: EndpointFlagHost}
	return LXCMap.Update(key, ep)
}

// SyncHostEntry checks if a host entry exists in the lxcmap and adds one if needed.
// Returns boolean indicating if a new entry was added and an error.
func SyncHostEntry(ip net.IP) (bool, error) {
	key := NewEndpointKey(ip)
	value, err := LXCMap.Lookup(key)
	if err != nil || value.(*EndpointInfo).Flags&EndpointFlagHost == 0 {
		err = AddHostEntry(ip)
		if err == nil {
			return true, nil
		}
	}
	return false, err
}

// DeleteEntry deletes a single map entry
func DeleteEntry(ip net.IP) error {
	return LXCMap.Delete(NewEndpointKey(ip))
}

// DeleteElement deletes the endpoint using all keys which represent the
// endpoint. It returns the number of errors encountered during deletion.
func DeleteElement(f EndpointFrontend) []error {
	var errors []error
	for _, k := range GetBPFKeys(f) {
		if err := LXCMap.Delete(k); err != nil {
			errors = append(errors, fmt.Errorf("Unable to delete key %v from %s: %s", k, bpf.MapPath(MapName), err))
		}
	}

	return errors
}

// DumpToMap dumps the contents of the lxcmap into a map and returns it
func DumpToMap() (map[string]*EndpointInfo, error) {
	m := map[string]*EndpointInfo{}
	callback := func(key bpf.MapKey, value bpf.MapValue) {
		if info, ok := value.DeepCopyMapValue().(*EndpointInfo); ok {
			if endpointKey, ok := key.(*EndpointKey); ok {
				m[endpointKey.ToIP().String()] = info
			}
		}
	}

	if err := LXCMap.DumpWithCallback(callback); err != nil {
		return nil, fmt.Errorf("unable to read BPF endpoint list: %s", err)
	}

	return m, nil
}


text:
__all__ = ["fourier"]

from dftintegrate import fourier


text:
package alien4cloud.tosca.parser.impl.base;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.yaml.snakeyaml.nodes.Node;

import alien4cloud.tosca.parser.INodeParser;
import alien4cloud.tosca.parser.ParsingContextExecution;
import alien4cloud.tosca.parser.ParsingError;
import alien4cloud.tosca.parser.impl.ErrorCode;

/**
 * Parser implementation that delegates parsing to a parser referenced in the parser registry based on the type key.
 */
@Slf4j
@AllArgsConstructor
public class ReferencedParser<T> implements INodeParser<T> {

    private String typeName;

    private boolean deferred;

    private int deferredOrder;

    public ReferencedParser(String typeName) {
        this.deferred = false;
        this.deferredOrder = 0;
        this.typeName = typeName;
    }

    @Override
    public boolean isDeferred(ParsingContextExecution context) {
        if (deferred) {
            return true;
        } else {
            INodeParser<?> innerNodeParser = getParser(context);
            return innerNodeParser.isDeferred(context);
        }
    }

    @Override
    public int getDeferredOrder(ParsingContextExecution context) {
        if (deferredOrder > 0) {
            return deferredOrder;
        } else {
            INodeParser<?> innerNodeParser = getParser(context);
            return innerNodeParser.getDeferredOrder(context);
        }
    }

    @Override
    public T parse(Node node, ParsingContextExecution context) {
        INodeParser<?> delegate = context.getRegistry().get(typeName);
        if (delegate == null) {
            log.error("No parser found for yaml type {}", typeName);
            context.getParsingErrors().add(
                    new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", node.getStartMark(), "", node.getEndMark(), typeName));
            return null;
        }
        return (T) delegate.parse(node, context);
    }

    private INodeParser<?> getParser(ParsingContextExecution context) {
        INodeParser<?> innerNodeParser = context.getRegistry().get(typeName);
        if (innerNodeParser == null) {
            context.getParsingErrors().add(new ParsingError(ErrorCode.ALIEN_MAPPING_ERROR, "No parser found for yaml type", null, "", null, typeName));
        }
        return innerNodeParser;
    }
}


text:
package org.neo4j.consistency.checking;

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

import org.neo4j.consistency.report.ConsistencyReport;
import org.neo4j.consistency.store.RecordAccess;
import org.neo4j.kernel.impl.store.LabelIdArray;
import org.neo4j.kernel.impl.store.PropertyType;
import org.neo4j.kernel.impl.store.record.AbstractBaseRecord;
import org.neo4j.kernel.impl.store.record.DynamicRecord;
import org.neo4j.kernel.impl.store.record.Record;

import static org.neo4j.kernel.impl.store.AbstractDynamicStore.readFullByteArrayFromHeavyRecords;
import static org.neo4j.kernel.impl.store.DynamicArrayStore.getRightArray;

public class LabelChainWalker<RECORD extends AbstractBaseRecord, REPORT extends ConsistencyReport> implements
        ComparativeRecordChecker<RECORD, DynamicRecord, REPORT>
{
    private final Validator<RECORD, REPORT> validator;

    private final HashMap<Long, DynamicRecord> recordIds = new HashMap<>();
    private final List<DynamicRecord> recordList = new ArrayList<>();
    private boolean allInUse = true;

    public LabelChainWalker( Validator<RECORD, REPORT> validator )
    {
        this.validator = validator;
    }

    @Override
    public void checkReference( RECORD record, DynamicRecord dynamicRecord,
                                CheckerEngine<RECORD, REPORT> engine,
                                RecordAccess records )
    {
        recordIds.put( dynamicRecord.getId(), dynamicRecord );

        if ( dynamicRecord.inUse() )
        {
            recordList.add( dynamicRecord );
        }
        else
        {
            allInUse = false;
            validator.onRecordNotInUse( dynamicRecord, engine );
        }

        long nextBlock = dynamicRecord.getNextBlock();
        if ( Record.NO_NEXT_BLOCK.is( nextBlock ) )
        {
            if ( allInUse )
            {
                // only validate label ids if all dynamic records seen were in use
                validator.onWellFormedChain( labelIds( recordList ), engine, records );
            }
        }
        else
        {
            if ( recordIds.containsKey( nextBlock ) )
            {
                validator.onRecordChainCycle( recordIds.get( nextBlock ), engine );
            }
            else
            {
                engine.comparativeCheck( records.nodeLabels( nextBlock ), this );
            }
        }
    }

    public static long[] labelIds( List<DynamicRecord> recordList )
    {
        long[] idArray =
                (long[]) getRightArray( readFullByteArrayFromHeavyRecords( recordList, PropertyType.ARRAY ) );
        return LabelIdArray.stripNodeId( idArray );
    }

    public interface Validator<RECORD extends AbstractBaseRecord, REPORT extends ConsistencyReport>
    {
        void onRecordNotInUse( DynamicRecord dynamicRecord, CheckerEngine<RECORD, REPORT> engine );
        void onRecordChainCycle( DynamicRecord record, CheckerEngine<RECORD, REPORT> engine );
        void onWellFormedChain( long[] labelIds, CheckerEngine<RECORD, REPORT> engine, RecordAccess records );
    }
}


text:
module BeaconControl
  module AnalyticsExtension
    class AnalyticsController < BeaconControl::AdminController
      inherit_resources

      def show
        @application = begin_of_association_chain.applications.find(params[:application_id]).decorate
      end

      def begin_of_association_chain
        current_admin
      end
    end
  end
end


text:
package ru.job4j.array;

import org.junit.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
/**
* Test.
*
* @author Vitaly Zubov (mailto:Zubov.VP@yandex.ru).
* @version $Id$
* @since 0.1
*/
 public class ArrayDuplicatesTest {
	/**
	* Test add.
	*/
	@Test
	public void whenRemoveDuplicatesThenArrayWithoutDuplicate() {
		String[] original = {"Раз", "Три", "Два", "Три", "Раз", "Четыре"};
		ArrayDuplicate duplicate = new ArrayDuplicate();
		String[] result = duplicate.remove(original);
		String[] expected = {"Раз", "Три", "Два", "Четыре"};
		assertThat(result, is(expected));
	}
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Hedwigia 52: 384 (1912)

#### Original name
Cortinarius angustilamellatus Herp.

### Remarks
null


text:
namespace TeleConsult.Data.Proxies
{
    using System;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Web.Mvc;
    using Common.Helpers;
    using TeleConsult.Common;
    using TeleConsult.Data.Models.Enumerations;

    public class VisualExaminationProxy
    {
        [HiddenInput(DisplayValue = false)]
        public int? Id { get; set; }

        [Required(ErrorMessage = GlobalConstants.DateRequireText)]
        [DisplayName(GlobalConstants.DateDisplay)]
        [UIHint("DateTemplate")]
        public DateTime? Date { get; set; }

        [Required(ErrorMessage = GlobalConstants.TypeRequireText)]
        [DisplayName(GlobalConstants.TypeDisplay)]
        [UIHint("EnumTemplate")]
        public VisualExaminationType Type { get; set; }

        public string TypeName
        {
            get
            {
                return this.Type.GetDescription();
            }
        }

        [DisplayName(GlobalConstants.InputInformationDisplay)]
        [UIHint("MultiLineTemplate")]
        public string InputInformation { get; set; }

        [DisplayName(GlobalConstants.ConsultationInformationDisplay)]
        [UIHint("MultiLineTemplate")]
        public string ConsultInformation { get; set; }

        [Required]
        public string FileContent { get; set; }

        [Required]
        public string FileType { get; set; }
    }
}


text:
package org.ovirt.engine.core.common.businessentities.profiles;

import java.util.HashMap;
import java.util.Map;

import org.ovirt.engine.core.common.businessentities.Identifiable;

public enum ProfileType implements Identifiable {
    DISK(1),
    CPU(2);

    private final int value;
    private static final Map<Integer, ProfileType> valueToStatus = new HashMap<Integer, ProfileType>();

    static {
        for (ProfileType status : values()) {
            valueToStatus.put(status.getValue(), status);
        }
    }

    private ProfileType(int value) {
        this.value = value;
    }

    @Override
    public int getValue() {
        return value;
    }

    public static ProfileType forValue(int value) {
        return valueToStatus.get(value);
    }
}


text:
<?php

namespace common\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\ProductReview;

/**
 * ProductReviewSearch represents the model behind the search form about `common\models\ProductReview`.
 */
class ProductReviewSearch extends ProductReview
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'stars', 'product_id', 'user_id', 'sn_review_id', 'status'], 'integer'],
            [['description', 'created_by', 'created_date', 'modified_by', 'modified_date'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = ProductReview::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query->where(['status' => [Status::STATUS_ACTIVE, Status::STATUS_INACTIVE]]),
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'stars' => $this->stars,
            'product_id' => $this->product_id,
            'user_id' => $this->user_id,
            'sn_review_id' => $this->sn_review_id,
            'created_date' => $this->created_date,
            'modified_date' => $this->modified_date,
            'status' => $this->status,
        ]);

        $query->andFilterWhere(['like', 'description', $this->description])
            ->andFilterWhere(['like', 'created_by', $this->created_by])
            ->andFilterWhere(['like', 'modified_by', $this->modified_by]);

        return $dataProvider;
    }
}


text:
package org.apache.hadoop.yarn.server.timelineservice.storage;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.AbstractService;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineDomain;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntities;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineWriteResponse;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineWriteResponse.TimelineWriteError;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext;
import org.apache.hadoop.yarn.util.timeline.TimelineUtils;

import com.google.common.annotations.VisibleForTesting;

/**
 * This implements a local file based backend for storing application timeline
 * information. This implementation may not provide a complete implementation of
 * all the necessary features. This implementation is provided solely for basic
 * testing purposes, and should not be used in a non-test situation.
 */
@InterfaceAudience.Private
@InterfaceStability.Unstable
public class FileSystemTimelineWriterImpl extends AbstractService
    implements TimelineWriter {

  private String outputRoot;

  /** Config param for timeline service storage tmp root for FILE YARN-3264. */
  public static final String TIMELINE_SERVICE_STORAGE_DIR_ROOT
      = YarnConfiguration.TIMELINE_SERVICE_PREFIX + "fs-writer.root-dir";

  public static final String ENTITIES_DIR = "entities";

  /** Default extension for output files. */
  public static final String TIMELINE_SERVICE_STORAGE_EXTENSION = ".thist";

  /** default value for storage location on local disk. */
  private static final String STORAGE_DIR_ROOT = "timeline_service_data";

  FileSystemTimelineWriterImpl() {
    super((FileSystemTimelineWriterImpl.class.getName()));
  }

  @Override
  public TimelineWriteResponse write(TimelineCollectorContext context,
      TimelineEntities entities, UserGroupInformation callerUgi)
      throws IOException {
    TimelineWriteResponse response = new TimelineWriteResponse();
    String clusterId = context.getClusterId();
    String userId = context.getUserId();
    String flowName = context.getFlowName();
    String flowVersion = context.getFlowVersion();
    long flowRunId = context.getFlowRunId();
    String appId = context.getAppId();

    for (TimelineEntity entity : entities.getEntities()) {
      write(clusterId, userId, flowName, flowVersion, flowRunId, appId, entity,
          response);
    }
    return response;
  }

  @Override
  public TimelineWriteResponse write(TimelineCollectorContext context,
      TimelineDomain domain)
      throws IOException {
    // TODO implementation for storing domain into FileSystem
    return null;
  }

  private synchronized void write(String clusterId, String userId,
      String flowName, String flowVersion, long flowRun, String appId,
      TimelineEntity entity, TimelineWriteResponse response)
      throws IOException {
    PrintWriter out = null;
    try {
      String dir = mkdirs(outputRoot, ENTITIES_DIR, clusterId, userId,
          escape(flowName), escape(flowVersion), String.valueOf(flowRun), appId,
          entity.getType());
      String fileName = dir + entity.getId() +
          TIMELINE_SERVICE_STORAGE_EXTENSION;
      out =
          new PrintWriter(new BufferedWriter(new OutputStreamWriter(
              new FileOutputStream(fileName, true), "UTF-8")));
      out.println(TimelineUtils.dumpTimelineRecordtoJSON(entity));
      out.write("\n");
    } catch (IOException ioe) {
      TimelineWriteError error = new TimelineWriteError();
      error.setEntityId(entity.getId());
      error.setEntityType(entity.getType());
      /*
       * TODO: set an appropriate error code after PoC could possibly be:
       * error.setErrorCode(TimelineWriteError.IO_EXCEPTION);
       */
      response.addError(error);
    } finally {
      if (out != null) {
        out.close();
      }
    }
  }

  @Override
  public TimelineWriteResponse aggregate(TimelineEntity data,
      TimelineAggregationTrack track) throws IOException {
    return null;

  }

  @VisibleForTesting
  String getOutputRoot() {
    return outputRoot;
  }

  @Override
  public void serviceInit(Configuration conf) throws Exception {
    outputRoot = conf.get(TIMELINE_SERVICE_STORAGE_DIR_ROOT,
        conf.get("hadoop.tmp.dir") + File.separator + STORAGE_DIR_ROOT);
  }

  @Override
  public void serviceStart() throws Exception {
    mkdirs(outputRoot, ENTITIES_DIR);
  }

  @Override
  public void flush() throws IOException {
    // no op
  }

  private static String mkdirs(String... dirStrs) throws IOException {
    StringBuilder path = new StringBuilder();
    for (String dirStr : dirStrs) {
      path.append(dirStr).append(File.separatorChar);
      File dir = new File(path.toString());
      if (!dir.exists()) {
        if (!dir.mkdirs()) {
          throw new IOException("Could not create directories for " + dir);
        }
      }
    }
    return path.toString();
  }

  // specifically escape the separator character
  private static String escape(String str) {
    return str.replace(File.separatorChar, '_');
  }
}


text:
/**
 * Creates a new iterable yielding all in-order combinations of values from
 * the given iterables.
 *
 * @example
 *
 *   toArray(combine([range(0, 1), range(4, 5)]))
 *   // [[0, 4], [0, 5], [1, 4], [1, 5]]
 */
export function* combine<T>(iterables: Array<Iterable<T>>): Iterable<Array<T>> {
  switch (iterables.length) {
    case 0:
      return;

    case 1:
      for (const value of iterables[0]) {
        yield [value];
      }
      break;

    default: {
      const tails = copy(combine(iterables.slice(1)));

      for (const head of iterables[0]) {
        for (const tail of tails) {
          yield [head, ...tail];
        }
      }
      break;
    }
  }
}

/**
 * Returns an iterable yielding all the values from the given iterables in
 * order. If any iterables are infinite then none of the values from
 * subsequent iterables will be read.
 *
 * @example
 *
 *   toArray(concat([range(0, 1), range(4, 5)]))
 *   // [0, 1, 4, 5]
 */
export function* concat<T>(iterables: Array<Iterable<T>>): Iterable<T> {
  for (const iterable of iterables) {
    yield* iterable;
  }
}

/**
 * Returns an iterable that yields values from another iterable passing a
 * predicate.
 *
 * @example
 *
 *   toArray(filter(range(0, 5), x => x % 2 === 0))
 *   // [0, 2, 4]
 */
export function* filter<T>(
  iterable: Iterable<T>,
  predicate: (value: T) => boolean
): Iterable<T> {
  for (const value of iterable) {
    if (predicate(value)) {
      yield value;
    }
  }
}

/**
 * Combines `filter` and `map` in one transform. Instead of returning false,
 * filtering is done by calling the `skip` function passed as the second
 * argument to transform.
 *
 * @example
 *
 *   toArray(filter(range(0, 5), (x, skip) => (x % 2 === 0) ? skip() : x * x))
 *   // [1, 9, 25]
 */
export function* filterMap<T, U>(
  iterable: Iterable<T>,
  transform: (value: T, skip: () => void) => U | undefined
): Iterable<U> {
  for (const value of iterable) {
    let skipped = false;
    const mappedValue = transform(value, () => {
      skipped = true;
    });

    if (!skipped && mappedValue !== undefined) {
      yield mappedValue;
    }
  }
}

/**
 * Makes an iterable from an iterable producing other iterables.
 *
 * @example
 *
 *   toArray(flatten(fromArray([range(2, 5), range(6,7))))
 *   // [2,3,4,5,6,7]
 */
export function* flatten<T>(iterable: Iterable<Iterable<T>>): Iterable<T> {
  for (const yieldedIterable of iterable) {
    yield* yieldedIterable;
  }
}

/**
 * Calls a function for each value in an iterable.
 *
 * @example
 *
 *   forEach(range(1, 4), console.log)
 *   // prints "1\n2\n3\n4\n"
 */
export function forEach<T>(
  iterable: Iterable<T>,
  callback: (value: T) => void
): void {
  for (const value of iterable) {
    callback(value);
  }
}

/**
 * Returns an iterable yielding the values from the given array in order.
 *
 * @example
 *
 *   toArray(fromArray([1, 2, 3]))
 *   // [1, 2, 3]
 */
export function* fromArray<T>(array: Array<T>): Iterable<T> {
  for (const value of array) {
    yield value;
  }
}

/**
 * Maps one iterable to another by passing all values through a transformer.
 *
 * @example
 *
 *   toArray(map(range(2, 5), x => x * 2))
 *   // [4, 6, 8, 10]
 */
export function* map<T, U>(
  iterable: Iterable<T>,
  transformer: (value: T) => U
): Iterable<U> {
  for (const value of iterable) {
    yield transformer(value);
  }
}

/**
 * Returns an iterable yielding values from min up to and including max.
 *
 * @example
 *
 *   toArray(range(8, 10))
 *   // [8, 9, 10]
 */
export function* range(min: number, max: number): Iterable<number> {
  for (let i = min; i <= max; i++) {
    yield i;
  }
}

/**
 * Returns up to the first count values of an iterable.
 *
 * @example
 *
 *   take(range(10, 20), 3)
 *   // [10, 11, 12]
 */
export function take<T>(iterable: Iterable<T>, count: number): Array<T> {
  const result = [];
  const iterator = iterable[Symbol.iterator]();

  while (count-- > 0) {
    const iteration = iterator.next();

    if (iteration.done) {
      if (iteration.value !== undefined) {
        result.push(iteration.value);
      }
      break;
    }

    result.push(iteration.value);
  }

  return result;
}

/**
 * Reads all values from an iterable and returns an array containing them. Be
 * careful not to use this with infinite iterables, as it will never return and
 * your program will eventually run out of memory.
 *
 * @example
 *
 *   toArray(range(7, 9))
 *   // [7, 8, 9]
 */
export function toArray<T>(iterable: Iterable<T>): Array<T> {
  return Array.from(iterable);
}

/**
 * Create a new iterable that, whenever it is iterated over, yields the same
 * values from `iterable` in order.
 *
 * @example
 *
 *   const copied = copy(range(0, 2));
 *   const notCopied = range(0, 2);
 *
 *   // Consumes the underlying iterable as-is…
 *   toArray(copied);
 *   // [0, 1, 2]
 *
 *   // …but caches the results to be replayed.
 *   toArray(copied);
 *   // [0, 1, 2]
 *
 *   // Consumes the iterable…
 *   toArray(notCopied);
 *   // [0, 1, 2]
 *
 *   // …and has nothing left.
 *   toArray(notCopied);
 *   // []
 */
export function copy<T>(iterable: Iterable<T>): Iterable<T> {
  const values: Array<T> = [];
  const indexes: Array<number> = [];
  const iterators: Array<Iterator<T>> = [];
  let done = false;
  let maxIndex = Infinity;

  function getIteratorResultAtIndex(index: number): IteratorResult<T> {
    while (values.length <= index) {
      if (!done) {
        const valueArray = take(iterable, 1);

        if (valueArray.length === 0) {
          done = true;
          maxIndex = values.length - 1;
        }

        values.push(valueArray[0]);
      }
    }

    return {
      done: index > maxIndex,
      value: values[index],
    };
  }

  return {
    [Symbol.iterator](): Iterator<T> {
      const id = iterators.length;

      indexes[id] = 0;
      iterators[id] = {
        next(): IteratorResult<T> {
          const result = getIteratorResultAtIndex(indexes[id]++);
          return result;
        },
      };

      return iterators[id];
    },
  };
}


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>LSU Tigers App</title>
    <link href="style.css" type="text/css" rel="stylesheet"/>

    Hello {{username? '' + '' username : ''}}!Click Here to Logout

Inside my LSU Team App


text:
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include "Basic/ERMsg.h"
//#include "TaskBase.h"

namespace WBSF
{

	enum { NB_COUNTRIES = 284 };
	class CCountrySelection : public std::bitset < NB_COUNTRIES >
	{
	public:

		enum TSearch { BY_ABVR, BY_NAME };

		class CInfo
		{
		public:

			std::string operator[](size_t i)const
			{
				ASSERT(i >= 0 && i < 2);
				return (i == 0 ? m_abrv : m_name);
			}

			std::string m_abrv;
			std::string m_name;
		};

		static const CInfo DEFAULT_LIST[NB_COUNTRIES];

		static std::string GetAllPossibleValue(bool bAbvr = true, bool bName = true);
		static size_t GetCountry(const std::string& in, size_t t = BY_ABVR);//by abr

		CCountrySelection(const std::string& in = "");

		std::string ToString()const;
		ERMsg FromString(const std::string& in);

		static std::string GetName(size_t i, size_t t = BY_ABVR);

		//		using std::bitset<NB_COUNTRIES>::at;
		bool at(const std::string& in)const
		{
			if (none())
				return false;

			if (all())
				return true;

			size_t p = GetCountry(in);
			return p < size() ? test(p) : false;
		}

		using std::bitset<NB_COUNTRIES>::set;
		ERMsg set(const std::string& in);
	};

	enum { NB_COUNTRIES_WU = 230 };
	class CCountrySelectionWU : public std::bitset < NB_COUNTRIES_WU >
	{
	public:

		enum TSearch { BY_ABVR, BY_NAME };

		class CInfo
		{
		public:

			std::string operator[](size_t i)const
			{
				ASSERT(i >= 0 && i < 2);
				return (i == 0 ? m_abrv : m_name);
			}

			std::string m_abrv;
			std::string m_name;
		};

		static const CInfo DEFAULT_LIST[NB_COUNTRIES_WU];

		static std::string GetAllPossibleValue(bool bAbvr = true, bool bName = true);
		static size_t GetCountry(const std::string& in, size_t t = BY_ABVR);//by abr

		CCountrySelectionWU(const std::string& in = "");

		std::string ToString()const;
		ERMsg FromString(const std::string& in);

		static std::string GetName(size_t i, size_t t = BY_ABVR);

		//		using std::bitset<NB_COUNTRIES_WU>::at;
		bool at(const std::string& in)const
		{
			if (none())
				return true;

			size_t p = GetCountry(in);
			return p < size() ? test(p) : false;
		}

		using std::bitset<NB_COUNTRIES_WU>::set;
		ERMsg set(const std::string& in);
	};

	class CCountrySelectionGADM : public boost::dynamic_bitset<size_t>
	{
	public:

		enum TSearch { BY_ID3, BY_NAME, BY_ID2, BY_NUMBER, BY_NOAA_ID, NB_COLUMNS };

		static std::vector<std::array<std::string, NB_COLUMNS> > m_default_list;
		static void LoadDefault();
		static ERMsg Load(const std::string& file_path);
		static std::string NOAA_to_GADM(std::string country);

		static std::string GetAllPossibleValue(bool bAbvr = true, bool bName = true, const std::string& ignore = "");
		static size_t GetCountry(const std::string& in, size_t t = BY_ID3);//by abr

		CCountrySelectionGADM(const std::string& in = "");

		std::string ToString()const;
		ERMsg FromString(const std::string& in);

		static std::string GetName(size_t i, size_t t = BY_ID3);

		bool at(const std::string& in)const
		{
			if (none())
				return false;

			if (all())
				return true;

			size_t p = GetCountry(in);
			return p < size() ? test(p) : false;
		}

		using boost::dynamic_bitset<size_t>::set;
		ERMsg set(const std::string& in);
	};

}


text:
class Admin::WidgetStatsController < Admin::DashboardController

  authorize_resource :class => :admin_widget_stats

  def index
    @week_of = params[:week_of] || 0
    @widget_stats = WidgetLog.find_all_url_summary_for_week(@week_of)
  end
  def show
    @widget_url = params[:widget_url]
    @week_of = params[:week_of] || 0
    @widget_stats = WidgetLog.find_one_url_summary_for_week(@widget_url, @week_of)
  end
end


text:
namespace google {
namespace protobuf {
namespace internal {

// Alias to std::shared_ptr for any C++11 platform,
// and for any supported MSVC compiler.
#if !defined(UTIL_GTL_USE_STD_SHARED_PTR) && \
    (defined(COMPILER_MSVC) || defined(LANG_CXX11))
#define UTIL_GTL_USE_STD_SHARED_PTR 1
#endif

#if defined(UTIL_GTL_USE_STD_SHARED_PTR) && UTIL_GTL_USE_STD_SHARED_PTR

// These are transitional.  They will be going away soon.
// Please just #include <memory> and just type std::shared_ptr yourself, instead
// of relying on this file.
//
// Migration doc: http://go/std-shared-ptr-lsc
using std::enable_shared_from_this;
using std::shared_ptr;
using std::static_pointer_cast;
using std::weak_ptr;

#else  // below, UTIL_GTL_USE_STD_SHARED_PTR not set or set to 0.

// For everything else there is the google3 implementation.
inline bool RefCountDec(volatile Atomic32 *ptr) {
  return Barrier_AtomicIncrement(ptr, -1) != 0;
}

inline void RefCountInc(volatile Atomic32 *ptr) {
  NoBarrier_AtomicIncrement(ptr, 1);
}

template <typename T> class shared_ptr;
template <typename T> class weak_ptr;

// This class is an internal implementation detail for shared_ptr. If two
// shared_ptrs point to the same object, they also share a control block.
// An "empty" shared_pointer refers to NULL and also has a NULL control block.
// It contains all of the state that's needed for reference counting or any
// other kind of resource management. In this implementation the control block
// happens to consist of two atomic words, the reference count (the number
// of shared_ptrs that share ownership of the object) and the weak count
// (the number of weak_ptrs that observe the object, plus 1 if the
// refcount is nonzero).
//
// The "plus 1" is to prevent a race condition in the shared_ptr and
// weak_ptr destructors. We need to make sure the control block is
// only deleted once, so we need to make sure that at most one
// object sees the weak count decremented from 1 to 0.
class SharedPtrControlBlock {
  template <typename T> friend class shared_ptr;
  template <typename T> friend class weak_ptr;
 private:
  SharedPtrControlBlock() : refcount_(1), weak_count_(1) { }
  Atomic32 refcount_;
  Atomic32 weak_count_;
};

// Forward declaration. The class is defined below.
template <typename T> class enable_shared_from_this;

template <typename T>
class shared_ptr {
  template <typename U> friend class weak_ptr;
 public:
  typedef T element_type;

  shared_ptr() : ptr_(NULL), control_block_(NULL) {}

  explicit shared_ptr(T* ptr)
      : ptr_(ptr),
        control_block_(ptr != NULL ? new SharedPtrControlBlock : NULL) {
    // If p is non-null and T inherits from enable_shared_from_this, we
    // set up the data that shared_from_this needs.
    MaybeSetupWeakThis(ptr);
  }

  // Copy constructor: makes this object a copy of ptr, and increments
  // the reference count.
  template <typename U>
  shared_ptr(const shared_ptr<U>& ptr)
      : ptr_(NULL),
        control_block_(NULL) {
    Initialize(ptr);
  }
  // Need non-templated version to prevent the compiler-generated default
  shared_ptr(const shared_ptr<T>& ptr)
      : ptr_(NULL),
        control_block_(NULL) {
    Initialize(ptr);
  }

  // Assignment operator. Replaces the existing shared_ptr with ptr.
  // Increment ptr's reference count and decrement the one being replaced.
  template <typename U>
  shared_ptr<T>& operator=(const shared_ptr<U>& ptr) {
    if (ptr_ != ptr.ptr_) {
      shared_ptr<T> me(ptr);   // will hold our previous state to be destroyed.
      swap(me);
    }
    return *this;
  }

  // Need non-templated version to prevent the compiler-generated default
  shared_ptr<T>& operator=(const shared_ptr<T>& ptr) {
    if (ptr_ != ptr.ptr_) {
      shared_ptr<T> me(ptr);   // will hold our previous state to be destroyed.
      swap(me);
    }
    return *this;
  }

  // TODO(austern): Consider providing this constructor. The draft C++ standard
  // (20.8.10.2.1) includes it. However, it says that this constructor throws
  // a bad_weak_ptr exception when ptr is expired. Is it better to provide this
  // constructor and make it do something else, like fail with a CHECK, or to
  // leave this constructor out entirely?
  //
  // template <typename U>
  // shared_ptr(const weak_ptr<U>& ptr);

  ~shared_ptr() {
    if (ptr_ != NULL) {
      if (!RefCountDec(&control_block_->refcount_)) {
        delete ptr_;

        // weak_count_ is defined as the number of weak_ptrs that observe
        // ptr_, plus 1 if refcount_ is nonzero.
        if (!RefCountDec(&control_block_->weak_count_)) {
          delete control_block_;
        }
      }
    }
  }

  // Replaces underlying raw pointer with the one passed in.  The reference
  // count is set to one (or zero if the pointer is NULL) for the pointer
  // being passed in and decremented for the one being replaced.
  //
  // If you have a compilation error with this code, make sure you aren't
  // passing NULL, nullptr, or 0 to this function.  Call reset without an
  // argument to reset to a null ptr.
  template <typename Y>
  void reset(Y* p) {
    if (p != ptr_) {
      shared_ptr<T> tmp(p);
      tmp.swap(*this);
    }
  }

  void reset() {
    reset(static_cast<T*>(NULL));
  }

  // Exchanges the contents of this with the contents of r.  This function
  // supports more efficient swapping since it eliminates the need for a
  // temporary shared_ptr object.
  void swap(shared_ptr<T>& r) {
    using std::swap;  // http://go/using-std-swap
    swap(ptr_, r.ptr_);
    swap(control_block_, r.control_block_);
  }

  // The following function is useful for gaining access to the underlying
  // pointer when a shared_ptr remains in scope so the reference-count is
  // known to be > 0 (e.g. for parameter passing).
  T* get() const {
    return ptr_;
  }

  T& operator*() const {
    return *ptr_;
  }

  T* operator->() const {
    return ptr_;
  }

  long use_count() const {
    return control_block_ ? control_block_->refcount_ : 1;
  }

  bool unique() const {
    return use_count() == 1;
  }

 private:
  // If r is non-empty, initialize *this to share ownership with r,
  // increasing the underlying reference count.
  // If r is empty, *this remains empty.
  // Requires: this is empty, namely this->ptr_ == NULL.
  template <typename U>
  void Initialize(const shared_ptr<U>& r) {
    // This performs a static_cast on r.ptr_ to U*, which is a no-op since it
    // is already a U*. So initialization here requires that r.ptr_ is
    // implicitly convertible to T*.
    InitializeWithStaticCast<U>(r);
  }

  // Initializes *this as described in Initialize, but additionally performs a
  // static_cast from r.ptr_ (V*) to U*.
  // NOTE(gfc): We'd need a more general form to support const_pointer_cast and
  // dynamic_pointer_cast, but those operations are sufficiently discouraged
  // that supporting static_pointer_cast is sufficient.
  template <typename U, typename V>
  void InitializeWithStaticCast(const shared_ptr<V>& r) {
    if (r.control_block_ != NULL) {
      RefCountInc(&r.control_block_->refcount_);

      ptr_ = static_cast<U*>(r.ptr_);
      control_block_ = r.control_block_;
    }
  }

  // Helper function for the constructor that takes a raw pointer. If T
  // doesn't inherit from enable_shared_from_this<T> then we have nothing to
  // do, so this function is trivial and inline. The other version is declared
  // out of line, after the class definition of enable_shared_from_this.
  void MaybeSetupWeakThis(enable_shared_from_this<T>* ptr);
  void MaybeSetupWeakThis(...) { }

  T* ptr_;
  SharedPtrControlBlock* control_block_;

#ifndef SWIG
  template <typename U>
  friend class shared_ptr;

  template <typename U, typename V>
  friend shared_ptr<U> static_pointer_cast(const shared_ptr<V>& rhs);
#endif
};

// Matches the interface of std::swap as an aid to generic programming.
template <typename T> void swap(shared_ptr<T>& r, shared_ptr<T>& s) {
  r.swap(s);
}

template <typename T, typename U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& rhs) {
  shared_ptr<T> lhs;
  lhs.template InitializeWithStaticCast<T>(rhs);
  return lhs;
}

// See comments at the top of the file for a description of why this
// class exists, and the draft C++ standard (as of July 2009 the
// latest draft is N2914) for the detailed specification.
template <typename T>
class weak_ptr {
  template <typename U> friend class weak_ptr;
 public:
  typedef T element_type;

  // Create an empty (i.e. already expired) weak_ptr.
  weak_ptr() : ptr_(NULL), control_block_(NULL) { }

  // Create a weak_ptr that observes the same object that ptr points
  // to.  Note that there is no race condition here: we know that the
  // control block can't disappear while we're looking at it because
  // it is owned by at least one shared_ptr, ptr.
  template <typename U> weak_ptr(const shared_ptr<U>& ptr) {
    CopyFrom(ptr.ptr_, ptr.control_block_);
  }

  // Copy a weak_ptr. The object it points to might disappear, but we
  // don't care: we're only working with the control block, and it can't
  // disappear while we're looking at because it's owned by at least one
  // weak_ptr, ptr.
  template <typename U> weak_ptr(const weak_ptr<U>& ptr) {
    CopyFrom(ptr.ptr_, ptr.control_block_);
  }

  // Need non-templated version to prevent default copy constructor
  weak_ptr(const weak_ptr& ptr) {
    CopyFrom(ptr.ptr_, ptr.control_block_);
  }

  // Destroy the weak_ptr. If no shared_ptr owns the control block, and if
  // we are the last weak_ptr to own it, then it can be deleted. Note that
  // weak_count_ is defined as the number of weak_ptrs sharing this control
  // block, plus 1 if there are any shared_ptrs. We therefore know that it's
  // safe to delete the control block when weak_count_ reaches 0, without
  // having to perform any additional tests.
  ~weak_ptr() {
    if (control_block_ != NULL &&
        !RefCountDec(&control_block_->weak_count_)) {
      delete control_block_;
    }
  }

  weak_ptr& operator=(const weak_ptr& ptr) {
    if (&ptr != this) {
      weak_ptr tmp(ptr);
      tmp.swap(*this);
    }
    return *this;
  }
  template <typename U> weak_ptr& operator=(const weak_ptr<U>& ptr) {
    weak_ptr tmp(ptr);
    tmp.swap(*this);
    return *this;
  }
  template <typename U> weak_ptr& operator=(const shared_ptr<U>& ptr) {
    weak_ptr tmp(ptr);
    tmp.swap(*this);
    return *this;
  }

  void swap(weak_ptr& ptr) {
    using std::swap;  // http://go/using-std-swap
    swap(ptr_, ptr.ptr_);
    swap(control_block_, ptr.control_block_);
  }

  void reset() {
    weak_ptr tmp;
    tmp.swap(*this);
  }

  // Return the number of shared_ptrs that own the object we are observing.
  // Note that this number can be 0 (if this pointer has expired).
  long use_count() const {
    return control_block_ != NULL ? control_block_->refcount_ : 0;
  }

  bool expired() const { return use_count() == 0; }

  // Return a shared_ptr that owns the object we are observing. If we
  // have expired, the shared_ptr will be empty. We have to be careful
  // about concurrency, though, since some other thread might be
  // destroying the last owning shared_ptr while we're in this
  // function.  We want to increment the refcount only if it's nonzero
  // and get the new value, and we want that whole operation to be
  // atomic.
  shared_ptr<T> lock() const {
    shared_ptr<T> result;
    if (control_block_ != NULL) {
      Atomic32 old_refcount;
      do {
        old_refcount = control_block_->refcount_;
        if (old_refcount == 0)
          break;
      } while (old_refcount !=
               NoBarrier_CompareAndSwap(
                   &control_block_->refcount_, old_refcount,
                   old_refcount + 1));
      if (old_refcount > 0) {
        result.ptr_ = ptr_;
        result.control_block_ = control_block_;
      }
    }

    return result;
  }

 private:
  void CopyFrom(T* ptr, SharedPtrControlBlock* control_block) {
    ptr_ = ptr;
    control_block_ = control_block;
    if (control_block_ != NULL)
      RefCountInc(&control_block_->weak_count_);
  }

 private:
  element_type* ptr_;
  SharedPtrControlBlock* control_block_;
};

template <typename T> void swap(weak_ptr<T>& r, weak_ptr<T>& s) {
  r.swap(s);
}

// See comments at the top of the file for a description of why this class
// exists, and section 20.8.10.5 of the draft C++ standard (as of July 2009
// the latest draft is N2914) for the detailed specification.
template <typename T>
class enable_shared_from_this {
  friend class shared_ptr<T>;
 public:
  // Precondition: there must be a shared_ptr that owns *this and that was
  // created, directly or indirectly, from a raw pointer of type T*. (The
  // latter part of the condition is technical but not quite redundant; it
  // rules out some complicated uses involving inheritance hierarchies.)
  shared_ptr<T> shared_from_this() {
    // Behavior is undefined if the precondition isn't satisfied; we choose
    // to die with a CHECK failure.
    CHECK(!weak_this_.expired()) << "No shared_ptr owns this object";
    return weak_this_.lock();
  }
  shared_ptr<const T> shared_from_this() const {
    CHECK(!weak_this_.expired()) << "No shared_ptr owns this object";
    return weak_this_.lock();
  }

 protected:
  enable_shared_from_this() { }
  enable_shared_from_this(const enable_shared_from_this& other) { }
  enable_shared_from_this& operator=(const enable_shared_from_this& other) {
    return *this;
  }
  ~enable_shared_from_this() { }

 private:
  weak_ptr<T> weak_this_;
};

// This is a helper function called by shared_ptr's constructor from a raw
// pointer. If T inherits from enable_shared_from_this<T>, it sets up
// weak_this_ so that shared_from_this works correctly. If T does not inherit
// from weak_this we get a different overload, defined inline, which does
// nothing.
template<typename T>
void shared_ptr<T>::MaybeSetupWeakThis(enable_shared_from_this<T>* ptr) {
  if (ptr) {
    CHECK(ptr->weak_this_.expired()) << "Object already owned by a shared_ptr";
    ptr->weak_this_ = *this;
  }
}

#endif  // UTIL_GTL_USE_STD_SHARED_PTR

}  // internal
}  // namespace protobuf
}  // namespace google

#endif  // GOOGLE_PROTOBUF_STUBS_SHARED_PTR_H__


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        style="@style/TitleStyle"
        android:text="4.恭喜你设置完成" />

    <CheckBox
        android:id="@+id/cb_openDefend"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5sp"
        android:text=" 您没有开启防盗保护"
        android:textSize="18sp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="160dp"
        android:gravity="center">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:drawable/presence_invisible" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:drawable/presence_invisible" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:drawable/presence_invisible" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@android:drawable/presence_online" />
    </LinearLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="50dp"
            android:background="@drawable/phone" />

        <Button
            style="@style/PreButton"
            android:onClick="prePage" />

        <Button
            style="@style/NextButton"
            android:text="设置完成"
            android:onClick="nextPage" />
    </RelativeLayout>

</LinearLayout>