text:
/* include/mcld/Config/Config.h.  Generated from Config.h.in by configure.  */
/* include/mcld/Config/Config.h.in.  Generated from configure.ac by autoheader.  */

//===- Config.h.in --------------------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_CONFIG_H
#define MCLD_CONFIG_H

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Define if you have POSIX threads libraries and header files. */
#define HAVE_PTHREAD 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define to the sub-directory in which libtool stores uninstalled libraries.
   */
#define LT_OBJDIR ".libs/"

/* Target triple MCLinker will generate code for by default */
#define MCLD_DEFAULT_TARGET_TRIPLE "x86_64--netbsd"

/* Define if this is Unixish platform */
#define MCLD_ON_UNIX 1

/* Define if this is Win32ish platform */
/* #undef MCLD_ON_WIN32 */

/* MCLINKER version */
#define MCLD_VERSION "2.1.0.0-NanHu"

/* Name of package */
#define PACKAGE "mclinker"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "mclinker@googlegroups.com"

/* Define to the full name of this package. */
#define PACKAGE_NAME "MCLinker"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "MCLinker NanHu"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "mclinker"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "NanHu"

/* Define to necessary symbol if this constant uses a non-standard name on
   your system. */
/* #undef PTHREAD_CREATE_JOINABLE */

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Define for standalone Android linker */
/* #undef TARGET_BUILD */

/* Version number of package */
#define VERSION "NanHu"

#define MCLD_REGION_CHUNK_SIZE 32
#define MCLD_NUM_OF_INPUTS 32
#define MCLD_SECTIONS_PER_INPUT 16
#define MCLD_SYMBOLS_PER_INPUT 128
#define MCLD_RELOCATIONS_PER_INPUT 1024

#endif


text:
<?php

namespace Mackstar\Spout\Test\Module\Repository\Repositories;

use Mackstar\Spout\Test\Module\Repository\Repositories\Mocks\TagsRepositoryMock;
use Mackstar\Spout\Test\Module\Repository\Mocks\QueryBuilderMock;

class TagsRepositoryTest extends \PHPUnit_Framework_TestCase
{
    private $tags;
    private $qb;

    protected function setUp()
    {
        $this->tags = new TagsRepositoryMock();
        $this->qb = new QueryBuilderMock();
        $this->tags->setQb($this->qb);
    }

    public function testSearchQuery()
    {
        $this->tags->search("something");
        $this->assertEquals($this->qb->from[0], 'tags');
        $this->assertEquals($this->qb->setParameter[1], '%something%');
    }
}

redpajama_set_name: RedPajamaGithub


text:
namespace ewok {

  Renderer::Renderer()
    : clearEnabled_(true)
  {
  }

  Renderer::~Renderer()
  {
    std::vector<IRenderable*>::iterator it;
    for (it = renderables_.begin(); it != renderables_.end(); it++) {
      delete *it;
    }
    renderables_.clear();
  }

  void Renderer::init()
  {
    LogOpenGLVars();

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    glDepthRangef(0.0f, 1.0f);
    // glDepthFunc(GL_ALWAYS);

    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    glFrontFace(GL_CCW);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);

    CheckGLError();
  }

  void Renderer::deinit()
  {
  }

  void Renderer::addRenderable(IRenderable &r)
  {
    renderables_.push_back(&r);
  }

  void Renderer::removeRenderable(IRenderable &r)
  {
    renderables_.erase(std::remove(renderables_.begin(), renderables_.end(), &r),
                       renderables_.end());
  }

  void Renderer::render()
  {
    if (clearEnabled_) glClear(GL_COLOR_BUFFER_BIT);

    std::vector<IRenderable*>::iterator it;
    for (it = renderables_.begin(); it != renderables_.end(); it++) {
      (*it)->render();
    }
  }

  void Renderer::enableCulling(bool b)
  {
    b ? glEnable(GL_CULL_FACE)
      : glDisable(GL_CULL_FACE);
  }

  void Renderer::enableClearing(bool b)
  {
    clearEnabled_ = b;
  }

} // namespace ewok


text:
ACCEPTED

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

#### Published in
Mycotaxon 21: 332 (1984)

#### Original name
Poria odora Sacc., 1888

### Remarks
null


text:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<type language="gradle" name="org.gradle.platform.base.binary.BaseBinarySpec.BinaryInfo" version="3.0"/>


text:
title: Weekly summary 2016-12-17
published: 2016-12-17
modified: 2016-12-17
tags: reinforcement learning, control theory
type: summary
showTOC: True
---

[Last week](2016-12-10.html)

# RL project

* LQR
	* Understanding
		* Why $\pi_t(x) = -P_t(x)$, why no closed form in general
		* (What is the Hamiltonian?)
		* Fitted Q-iteration
		* Add a linear term
		* Differential equation for $P$
	* Remaining questions
		* Prove convergence (check w/ linear term)
		* Hamiltonian: Pontryagin proof
	* Approaches
		* Thinking of minimum as circuit - doesn't work.
		* Local steps using quadratic approximation - how to analyze?
		* Using softmax and sampling - cf. [AH16]. (How to collapse multiple? cf. Toda)
* Planning in POMDPs
	* [Collaboration](https://docs.google.com/document/d/1gy-xJlwOQKKHHMFXSBAZsLM2A4x-uRmBRu7QzpKLdq0/edit)
	* See list of papers.
	* Idea: relax memoryless POMDPs, ex. only depending on posterior probabilities? (belief states)
* RL learning: tutorial

# Alexa/NLP experiments

* Started programming treeflow.
* [Minutes](https://workflowy.com/#/c9991294df94)

# To read, think about

* Contextual MDPs: Bellman rank
* [AH16]
* [SB] Section 10-13, continue RL tutorial
* [LP16] reducing bias for Q-learning
	* SSGD theory
* (for planning in POMDP)
	* Geometry (12/20)
	* Contextual MDP paper (spectral)
	* Restarts in tensor methods

# To do over break

* Write up notes on RL
* Try AI gym
* Read on AI safety
* More reading
	* Graphical models, exponential families
	* Hi-dim prob
	* Convex opt
	* SoS
	* PDE
* Alexa
* LaTeX blog setup
* (@Vlad) neural nets in Haskell


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This code was generated by https://github.com/googleapis/google-api-java-client-services/
 * Modify at your own risk.
 */

package com.google.api.services.cloudbilling.model;

/**
 * A billing account in [GCP Console](https://console.cloud.google.com/). You can assign a billing
 * account to one or more projects.
 *
 *
 This is the Java data model class that specifies how to parse/serialize into the JSON that is
 * transmitted over HTTP when working with the Cloud Billing API. For a detailed explanation see:
 * https://developers.google.com/api-client-library/java/google-http-java-client/json
 *

 *
 * @author Google, Inc.
 */
@SuppressWarnings("javadoc")
public final class BillingAccount extends com.google.api.client.json.GenericJson {

  /**
   * The display name given to the billing account, such as `My Billing Account`. This name is
   * displayed in the GCP Console.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.String displayName;

  /**
   * If this account is a [subaccount](https://cloud.google.com/billing/docs/concepts), then this
   * will be the resource name of the master billing account that it is being resold through.
   * Otherwise this will be empty.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.String masterBillingAccount;

  /**
   * The resource name of the billing account. The resource name has the form
   * `billingAccounts/{billing_account_id}`. For example, `billingAccounts/012345-567890-ABCDEF`
   * would be the resource name for billing account `012345-567890-ABCDEF`.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.String name;

  /**
   * Output only. True if the billing account is open, and will therefore be charged for any usage
   * on associated projects. False if the billing account is closed, and therefore projects
   * associated with it will be unable to use paid services.
   * The value may be {@code null}.
   */
  @com.google.api.client.util.Key
  private java.lang.Boolean open;

  /**
   * The display name given to the billing account, such as `My Billing Account`. This name is
   * displayed in the GCP Console.
   * @return value or {@code null} for none
   */
  public java.lang.String getDisplayName() {
    return displayName;
  }

  /**
   * The display name given to the billing account, such as `My Billing Account`. This name is
   * displayed in the GCP Console.
   * @param displayName displayName or {@code null} for none
   */
  public BillingAccount setDisplayName(java.lang.String displayName) {
    this.displayName = displayName;
    return this;
  }

  /**
   * If this account is a [subaccount](https://cloud.google.com/billing/docs/concepts), then this
   * will be the resource name of the master billing account that it is being resold through.
   * Otherwise this will be empty.
   * @return value or {@code null} for none
   */
  public java.lang.String getMasterBillingAccount() {
    return masterBillingAccount;
  }

  /**
   * If this account is a [subaccount](https://cloud.google.com/billing/docs/concepts), then this
   * will be the resource name of the master billing account that it is being resold through.
   * Otherwise this will be empty.
   * @param masterBillingAccount masterBillingAccount or {@code null} for none
   */
  public BillingAccount setMasterBillingAccount(java.lang.String masterBillingAccount) {
    this.masterBillingAccount = masterBillingAccount;
    return this;
  }

  /**
   * The resource name of the billing account. The resource name has the form
   * `billingAccounts/{billing_account_id}`. For example, `billingAccounts/012345-567890-ABCDEF`
   * would be the resource name for billing account `012345-567890-ABCDEF`.
   * @return value or {@code null} for none
   */
  public java.lang.String getName() {
    return name;
  }

  /**
   * The resource name of the billing account. The resource name has the form
   * `billingAccounts/{billing_account_id}`. For example, `billingAccounts/012345-567890-ABCDEF`
   * would be the resource name for billing account `012345-567890-ABCDEF`.
   * @param name name or {@code null} for none
   */
  public BillingAccount setName(java.lang.String name) {
    this.name = name;
    return this;
  }

  /**
   * Output only. True if the billing account is open, and will therefore be charged for any usage
   * on associated projects. False if the billing account is closed, and therefore projects
   * associated with it will be unable to use paid services.
   * @return value or {@code null} for none
   */
  public java.lang.Boolean getOpen() {
    return open;
  }

  /**
   * Output only. True if the billing account is open, and will therefore be charged for any usage
   * on associated projects. False if the billing account is closed, and therefore projects
   * associated with it will be unable to use paid services.
   * @param open open or {@code null} for none
   */
  public BillingAccount setOpen(java.lang.Boolean open) {
    this.open = open;
    return this;
  }

  @Override
  public BillingAccount set(String fieldName, Object value) {
    return (BillingAccount) super.set(fieldName, value);
  }

  @Override
  public BillingAccount clone() {
    return (BillingAccount) super.clone();
  }

}


text:
export const REMOVE_FROM_ITINERARY = 'REMOVE_FROM_ITINERARY';

export function removeFromItinerary(payload) {
  return {
    type: REMOVE_FROM_ITINERARY,
    payload,
  };
}


text:
<?xml version="1.0" encoding="utf-8"?>
<!--Generated by crowdin.com-->
<resources>
    <string name="settings_activity_title">Ajustes</string>

    <!-- Categories -->
    <string name="settings_category_title_security">Seguridad</string>
    <string name="settings_category_title_ui">Interfaz de usuario</string>
    <string name="settings_category_title_openpgp">OpenPGP</string>

    <!-- Titles -->
    <string name="settings_title_tap_to_reveal">Toca para mostrar</string>
    <string name="settings_title_auth_device">Pedir credenciales de dispositivo</string>
    <string name="settings_title_backup_password">Contraseña de copia de seguridad</string>

    <string name="settings_title_theme">Aspecto</string>
    <string name="settings_title_label_size">Tamaño de fuente</string>

    <string name="settings_title_openpgp_provider">Seleccionar aplicación OpenPGP</string>
    <string name="settings_title_openpgp_keyid">Seleccionar clave OpenPGP</string>
    <string name="settings_title_openpgp_sign">Firmar copias de seguridad cifradas</string>
    <string name="settings_title_openpgp_verify">Comprobar copias de seguridad cifradas</string>

    <!-- Descriptions -->
    <string name="settings_desc_tap_to_reveal">Esconder códigos OTP por defecto,
        necesitando mostrarlos manualmente</string>

    <string name="settings_desc_auth_device">El usuario tiene que autenticarse con los
        credenciales de dispositivo al abrir andOTP</string>
    <string name="settings_desc_auth_device_pre_lollipop">Esta característica requiere al menos
        Android 5.0 (Lollipop)</string>
    <string name="settings_desc_auth_device_not_secure">Esta característica requiere bloqueo de salvapantallas
        seguro (Settings -> Security -> Screenlock)</string>

    <string name="settings_desc_backup_password">Establecer la contraseña usada para cifrar las
        copias de seguridad</string>

    <string name="settings_desc_openpgp_sign">Cada copia de seguridad cifrada es además firmada con
        tu clave (necesita contraseña)</string>
    <string name="settings_desc_openpgp_verify">Las contraseñas de copias de seguridad cifradas sólo se importan
        si están firmadas con una clave válida</string>

    <!-- List entries -->
    <string-array name="settings_entries_theme">
        <item>Tema claro</item>
        <item>Tema oscuro</item>
    </string-array>
</resources>


text:
function [img, meanColor, modeColor] = getBackgroundColor (img)
%
% function [img, meanColor, modeColor] = getBackgroundColor (img)
%
%    img   -   Either a string representing the filename of an image to open
%              or an image itself.  If the latter, it must be either a
%              3-dimensional matrix representing an RGB image or a 2-dimensional
%              matrix representing a grayscale image.

if ischar(img)
  img = imread(imageFile);
end
img = double(img);

% Handle RGB and Grayscale separately.
if ndims(img)==3
  % There are probably some spiffy ways to consolidate this sprawl
  % so that the R, G, and B channels are not being processed
  % independently, but for the time being, this does work.
  red   = getBG(img(:, :, 1));
  green = getBG(img(:, :, 2));
  blue  = getBG(img(:, :, 3));

  % For each channel, remove the "foreground" regions identified in
  % each of the other channels.
  red(isnan(green)) = NaN;
  red(isnan(blue)) = NaN;

  green(isnan(red)) = NaN;
  green(isnan(blue)) = NaN;

  blue(isnan(red)) = NaN;
  blue(isnan(green)) = NaN;

  % Compute the mean and mode colors.
  meanColor = [ ...
      mean(mean( red(~isnan(red)) )) ...
      mean(mean( green(~isnan(green)) )) ...
      mean(mean( blue(~isnan(blue)) )) ];
  modeColor = [ ...
      mode(mode( red(~isnan(red)) )) ...
      mode(mode( green(~isnan(green)) )) ...
      mode(mode( blue(~isnan(blue)) )) ];

  % Update each the foreground regions of each channel and set them
  % to their mean colors.  This is only necessary for visualization.
  red(isnan(red)) = meanColor(1);
  green(isnan(green)) = meanColor(2);
  blue(isnan(blue)) = meanColor(3);

  img(:, :, 1) = red;
  img(:, :, 2) = green;
  img(:, :, 3) = blue;
else
  img = getBG(img);
  meanColor = mean(mean( img( ~isnan(img) ) ));
  modeColor = mode(mode( img( ~isnan(img) ) ));
  img(isnan(img)) = meanColor;
end

% Convert the image back to integers (optional)
img = uint8(img);

% Display the results before returning
display(meanColor)
display(modeColor)

  function image = getBG (image)
      mask = getAttenuationMask(size(image), min(size(image)) / 2, 0, 1);

      % Assume that the background is mostly constant, so isolate the high-frequency
      % parts of the image in the frequency domain and then transform it back into the spatial domain
      fftImage = fftshift(fft2(image));
      fftImage = fftImage .* mask;
      invFftImage = abs(ifft2(fftImage));

      % Expand the high-frequency areas of the image and fill in any holes.  This should
      % cover all but the (hopefully) low frequency background areas.
      edgeRegion = imfill(imdilate(invFftImage, strel('disk', 4, 4)), 'holes');

      % Now remove the parts of the image that are covered by edgeRegion
      edgeMean = mean(mean(edgeRegion));
      image(edgeRegion>edgeMean) = NaN;
  end
end


text:
These tests illustrate behavior implemented by `op_main.py`.

`op_main.py` is the module used to run Python modules.

## Exception tracebacks

By default `op_main.py` removes Guild specific stack layers from
reported exceptions. The rationale for this behavior is that the Guild
stack layers are noise wrt user errors. The intent is that exceptions
resemble those that would be generated if the user script was run
directly with Python.

We use the `fail.py` script in `optimizers` sample project.

    >>> project = Project(sample("projects/optimizers"))

The project contains some invalid operation specs and as a result,
generates warnings whenver an operation is run.

When we run `fail.py`, the script generates an error by raising an
exception.

    >>> project.run("fail.py")
    Traceback (most recent call last):
      File ".../.guild/sourcecode/fail.py", line 17, in <module>
        fail()
      File ".../.guild/sourcecode/fail.py", line 7, in fail
        fail2()
      File ".../.guild/sourcecode/fail.py", line 14, in fail2
        raise Exception("FAIL")
    Exception: FAIL
    <exit 1>

When we run with the debug option, we get the full stack:

    >>> project.run("fail.py", debug=True)
    DEBUG: [guild] checking '.' for model sources
    ...
    DEBUG: [guild] loading module from '.../.guild/sourcecode/fail.py'
    Traceback (most recent call last):
      ...
      File ".../guild/op_main.py", line ..., in <module>
        main()
      File ".../guild/op_main.py", line ..., in main
        _main()
      ...
      File ".../guild/op_main.py", line ..., in exec_script
        python_util.exec_script(module_info.mod_path, globals, mod_name=mod_name)
      File ".../guild/python_util.py", line ..., in exec_script
        exec(code, script_globals)
      File ".../.guild/sourcecode/fail.py", line 17, in <module>
        fail()
      File ".../.guild/sourcecode/fail.py", line 7, in fail
        fail2()
      File ".../.guild/sourcecode/fail.py", line 14, in fail2
        raise Exception("FAIL")
    Exception: FAIL
    <exit 1>

Guild does not print stack information for calls to `sys.exit()` (or
`SystemExit` exceptions). Our sample script supports a `code` flag
that, when set to a value other than `1`, causes the script to exit
with a call to `sys.exit()` instead of raising an exception.

    >>> project.run("fail.py", flags={"code": 2})
    FAIL
    <exit 2>

The same behavior applies to modules run through a Guild file. In this
case, the project defines a `fail` operation that runs `fail.py`.

    >>> project.run("fail")
    Traceback (most recent call last):
      File ".../.guild/sourcecode/fail.py", line 17, in <module>
        fail()
      File ".../.guild/sourcecode/fail.py", line 7, in fail
        fail2()
      File ".../.guild/sourcecode/fail.py", line 14, in fail2
        raise Exception("FAIL")
    Exception: FAIL
    <exit 1>

    >>> project.run("fail", flags={"code": 2})
    FAIL
    <exit 2>

## Relative imports

Guild loads modules using their package name so that `__package__` is
correctly defined.

    >>> project = Project(sample("projects/op-main-package"))

The `op-main-package` contains operation defs that generate warnings
due to mis-specifications (see tests below). These warnings are logged
whenever the project Guild file is loaded. We can run a `pass` (no-op)
operation to generate these warnings.

    >>> project.run("pass")
    WARNING: cannot import flags from abc_123: No module named abc_123
    WARNING: cannot import flags from pkg: No module named pkg.__main__
    ('pkg' is a package and cannot be directly executed)

The warnings are suppressed as needed by setting
`NO_WARN_FLAGS_IMPORT` below for tests.

Guild uses different methods of loading modules depending on whether
the module is loaded with global flag assignments.

Here's the case where globals are not used (i.e. dest args):

    >>> with Env({"NO_WARN_FLAGS_IMPORT": "1"}):
    ...     project.run("args")
    hello from __main__ in pkg
    hello from pkg.main_impl in pkg

Here's the case where globals are used:

    >>> with Env({"NO_WARN_FLAGS_IMPORT": "1"}):
    ...    project.run("globals")
    hello from __main__ in pkg
    hello from pkg.main_impl in pkg

The same scheme applies when `main` contains a path to the package, as
is the case with `op-args-2`.

    >>> with Env({"NO_IMPORT_FLAGS_CACHE": "1", "NO_WARN_FLAGS_IMPORT": "1"}):
    ...     project.run("args-2")
    hello from __main__ in pkg
    hello from pkg.main_impl in pkg

We can execute a package provided it contains a `__main__` module.

    >>> with Env({"NO_WARN_FLAGS_IMPORT": "1"}):
    ...    project.run("pkg-main")
    a package!

A package that does not contain a `__main__` module causes an error.

    >>> with Env({"NO_WARN_FLAGS_IMPORT": "1"}):
    ...     project.run("pkg")
    guild: No module named pkg.__main__ ('pkg' is a package and cannot
    be directly executed)
    <exit 1>


text:
using ui::MessageBoxFlags;

namespace views {

class View;

///////////////////////////////////////////////////////////////////////////////
//
// DialogDelegate
//
//  DialogDelegate is an interface implemented by objects that wish to show a
//  dialog box Window. The window that is displayed uses this interface to
//  determine how it should be displayed and notify the delegate object of
//  certain events.
//
///////////////////////////////////////////////////////////////////////////////
class DialogDelegate : public WindowDelegate {
 public:
  virtual DialogDelegate* AsDialogDelegate();

  // Returns a mask specifying which of the available DialogButtons are visible
  // for the dialog. Note: If an OK button is provided, you should provide a
  // CANCEL button. A dialog box with just an OK button is frowned upon and
  // considered a very special case, so if you're planning on including one,
  // you should reconsider, or beng says there will be stabbings.
  //
  // To use the extra button you need to override GetDialogButtons()
  virtual int GetDialogButtons() const;

  // Returns whether accelerators are enabled on the button. This is invoked
  // when an accelerator is pressed, not at construction time. This
  // returns true.
  virtual bool AreAcceleratorsEnabled(
      ui::MessageBoxFlags::DialogButton button);

  // Returns the label of the specified DialogButton.
  virtual std::wstring GetDialogButtonLabel(
      ui::MessageBoxFlags::DialogButton button) const;

  // Override this function if with a view which will be shown in the same
  // row as the OK and CANCEL buttons but flush to the left and extending
  // up to the buttons.
  virtual View* GetExtraView();

  // Returns whether the height of the extra view should be at least as tall as
  // the buttons. The default (false) is to give the extra view it's preferred
  // height. By returning true the height becomes
  // max(extra_view preferred height, buttons preferred height).
  virtual bool GetSizeExtraViewHeightToButtons();

  // Returns the default dialog button. This should not be a mask as only
  // one button should ever be the default button.  Return
  // ui::MessageBoxFlags::DIALOGBUTTON_NONE if there is no default.  Default
  // behavior is to return ui::MessageBoxFlags::DIALOGBUTTON_OK or
  // ui::MessageBoxFlags::DIALOGBUTTON_CANCEL (in that order) if they are
  // present, ui::MessageBoxFlags::DIALOGBUTTON_NONE otherwise.
  virtual int GetDefaultDialogButton() const;

  // Returns whether the specified dialog button is enabled.
  virtual bool IsDialogButtonEnabled(
      ui::MessageBoxFlags::DialogButton button) const;

  // Returns whether the specified dialog button is visible.
  virtual bool IsDialogButtonVisible(
      ui::MessageBoxFlags::DialogButton button) const;

  // For Dialog boxes, if there is a "Cancel" button, this is called when the
  // user presses the "Cancel" button or the Close button on the window or
  // in the system menu, or presses the Esc key. This function should return
  // true if the window can be closed after it returns, or false if it must
  // remain open.
  virtual bool Cancel();

  // For Dialog boxes, this is called when the user presses the "OK" button,
  // or the Enter key.  Can also be called on Esc key or close button
  // presses if there is no "Cancel" button.  This function should return
  // true if the window can be closed after the window can be closed after
  // it returns, or false if it must remain open.  If |window_closing| is
  // true, it means that this handler is being called because the window is
  // being closed (e.g.  by Window::Close) and there is no Cancel handler,
  // so Accept is being called instead.
  virtual bool Accept(bool window_closing);
  virtual bool Accept();

  // Overridden from WindowDelegate:
  virtual View* GetInitiallyFocusedView();

  // Overridden from WindowDelegate:
  virtual ClientView* CreateClientView(Window* window);

  // Called when the window has been closed.
  virtual void OnClose() {}

  // A helper for accessing the DialogClientView object contained by this
  // delegate's Window.
  DialogClientView* GetDialogClientView() const;

 protected:
  // Overridden from WindowDelegate:
  virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const OVERRIDE;
};

}  // namespace views

#endif  // VIEWS_WINDOW_DIALOG_DELEGATE_H_


text:
We love pull requests from everyone. By participating in this project, you
agree to abide by the Hangar's [code of conduct][codeofconduct].

[codeofconduct]: https://github.com/hangarcr/gethangar/blob/develop/CODE_OF_CONDUCT.md

Fork, then clone the repo:

    git clone git@github.com:your-username/gethangar.git

Push to your fork and [submit a pull request][pr].

[pr]: https://github.com/hangarcr/gethangar/compare/

At this point you're waiting on us. We like to at least comment on pull requests
within three business days (and, typically, one business day). We may suggest
some changes or improvements or alternatives.

Some things that will increase the chance that your pull request is accepted:

* Write a [good commit message][commit].

[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html


text:
class GobstonesTestHook < Mumukit::Defaults::TestHook
  def run!(request)
    output, status = request.precompiled_result

    if request.precompiled_batch.options[:interactive]
      ['', :passed]
    elsif status.passed?
      request.precompiled_batch.run_tests! output
    else
      request.precompiled_result
    end
  end
end


text:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="81dp">

    <TextView
        android:id="@+id/textView3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:text="Click/touch/longtouch the imageview"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

    <ImageView
        android:id="@+id/boardfield"
        android:layout_width="0dp"
        android:layout_height="200dp"
        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:clickable="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView3"/>

    <ScrollView
        android:id="@+id/horizontalScrollView1"
        android:layout_width="0dp"
        android:layout_height="0dp"

        android:layout_marginStart="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/boardfield">

        <TextView
            android:id="@+id/log"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Log:"
            />

    </ScrollView>

</androidx.constraintlayout.widget.ConstraintLayout>


text:
class FoodPolicy < ApplicationPolicy
  def show?
    record_belongs_to_user? || record.try(:from_api?)
  end

  def edit?
    record_belongs_to_user?
  end

  def update?
    edit?
  end

  def destroy?
    edit? && record_not_used_in_recipe?
  end

  class Scope < Scope
    def resolve
      Food.where(user_id: user.id).or(Food.from_api)
    end
  end

  private

  def record_not_used_in_recipe?
    !Ingredient.exists?(food_id: record.id)
  end
end


text:
<?php

class Uploader
{
    /**
     * Maximum size of uploaded file.
     * Defaults to 16M.
     * @var integer
     */
    protected $_maximumFileSize = 16777216;

    /**
     * Location where uploaded files are saved.
     * @var string
     */
    protected $_uploadPath = __DIR__ . '/uploads/';

    /**
     * Constructor.
     */
    public function __construct(array $params = array())
    {
        if ($params) {
            if (isset($params['max_file_size']) && $params['max_file_size'] > 0) {
                $this->_maximumFileSize = (int) $params['max_file_size'];
            }
            if (isset($params['upload_path']) && $params['upload_path'] != '') {
                $this->_uploadPath = $params['upload_path'];
            }
        }

        return $this;
    }

    protected function _getHashedFileName($fileName)
    {
        $tmpName = md5($fileName . mt_rand());
        return $tmpName;
    }

    protected function _prepareResponse($fileName, $path, $size, $error = '')
    {
        return array(
            'error'     => $error,
            'filename'  => $fileName,
            'path'      => $path,
            'size'      => sprintf('%.2fKb', array_sum($size) / 1024),
            'dt'        => date('Y-m-d H:i:s')
        );
    }

    protected function _getPatchContentFromSh($content)
    {
        $pattern = '~(.*__PATCHFILE_FOLLOWS__)~s';
        $content = trim(preg_replace($pattern, '', $content));

        return $content;
    }

    public function upload()
    {
        $fileElementName = $_POST['file_element'];
        $error           = array();
        $filenames       = $_FILES[$fileElementName]['name'];
        $newFileName     = array();
        $size            = array();

        foreach ($filenames as $fileId => $name) {
            if (!empty($_FILES[$fileElementName]['error'][$fileId])) {
                switch($_FILES[$fileElementName]['error'][$fileId]) {
                    case '1':
                        $error[$fileId][] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
                        break;
                    case '2':
                        $error[$fileId][] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.';
                        break;
                    case '3':
                        $error[$fileId][] = 'The uploaded file was only partially uploaded.';
                        break;
                    case '4':
                        $error[$fileId][] = 'No file was uploaded.';
                        break;
                    case '6':
                        $error[$fileId][] = 'Missing a temporary folder.';
                        break;
                    case '7':
                        $error[$fileId][] = 'Failed to write file to disk.';
                        break;
                    case '8':
                        $error[$fileId][] = 'File upload stopped by extension.';
                        break;
                    case '999':
                    default:
                        $error[$fileId][] = 'No error code available.';
                }
            } elseif (empty($_FILES[$fileElementName]['tmp_name'][$fileId])
                || $_FILES[$fileElementName]['tmp_name'][$fileId] == 'none'
            ) {
                $error[$fileId][] = 'No file was uploaded.';
            } else {
                $size[$fileId] = @filesize($_FILES[$fileElementName]['tmp_name'][$fileId]);

                $newFileName[$fileId] = $this->_getHashedFileName($name) . '.patch';
                if (move_uploaded_file(
                    $_FILES[$fileElementName]['tmp_name'][$fileId],
                    $this->_uploadPath . $newFileName[$fileId]
                )) {
                    if (pathinfo($_FILES[$fileElementName]['tmp_name'][$fileId], PATHINFO_EXTENSION) == 'sh') {
                        $content = file_get_contents($this->_uploadPath . $newFileName[$fileId]);
                        $content = $this->_getPatchContentFromSh($content);
                        if (!$content ) {
                            @unlink($this->_uploadPath . $newFileName[$fileId]);
                            $error[$fileId][] = 'Sh script has incorrect format.';
                        } else {
                            file_put_contents($this->_uploadPath . $newFileName[$fileId], $content);
                        }
                    }
                } else {
                    $error[$fileId][] = 'Unable to move uploaded file from tmp folder.';
                }
            }
        }

        return array(
            'result'        => $this->_prepareResponse($filenames, $_POST['folder'], $size, $error),
            'new_file_name' => $newFileName
        );
    }
}


text:
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h"
#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET)

#include <ares.h>
#include <sys/ioctl.h>

#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h"

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"

typedef struct fd_node {
  /** the owner of this fd node */
  grpc_ares_ev_driver* ev_driver;
  /** a closure wrapping on_readable_cb, which should be invoked when the
      grpc_fd in this node becomes readable. */
  grpc_closure read_closure;
  /** a closure wrapping on_writable_cb, which should be invoked when the
      grpc_fd in this node becomes writable. */
  grpc_closure write_closure;
  /** next fd node in the list */
  struct fd_node* next;

  /** mutex guarding the rest of the state */
  gpr_mu mu;
  /** the grpc_fd owned by this fd node */
  grpc_fd* fd;
  /** if the readable closure has been registered */
  bool readable_registered;
  /** if the writable closure has been registered */
  bool writable_registered;
  /** if the fd is being shut down */
  bool shutting_down;
} fd_node;

struct grpc_ares_ev_driver {
  /** the ares_channel owned by this event driver */
  ares_channel channel;
  /** pollset set for driving the IO events of the channel */
  grpc_pollset_set* pollset_set;
  /** refcount of the event driver */
  gpr_refcount refs;

  /** mutex guarding the rest of the state */
  gpr_mu mu;
  /** a list of grpc_fd that this event driver is currently using. */
  fd_node* fds;
  /** is this event driver currently working? */
  bool working;
  /** is this event driver being shut down */
  bool shutting_down;
};

static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver);

static grpc_ares_ev_driver* grpc_ares_ev_driver_ref(
    grpc_ares_ev_driver* ev_driver) {
  gpr_log(GPR_DEBUG, "Ref ev_driver %" PRIuPTR, (uintptr_t)ev_driver);
  gpr_ref(&ev_driver->refs);
  return ev_driver;
}

static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver) {
  gpr_log(GPR_DEBUG, "Unref ev_driver %" PRIuPTR, (uintptr_t)ev_driver);
  if (gpr_unref(&ev_driver->refs)) {
    gpr_log(GPR_DEBUG, "destroy ev_driver %" PRIuPTR, (uintptr_t)ev_driver);
    GPR_ASSERT(ev_driver->fds == nullptr);
    gpr_mu_destroy(&ev_driver->mu);
    ares_destroy(ev_driver->channel);
    gpr_free(ev_driver);
  }
}

static void fd_node_destroy(fd_node* fdn) {
  gpr_log(GPR_DEBUG, "delete fd: %d", grpc_fd_wrapped_fd(fdn->fd));
  GPR_ASSERT(!fdn->readable_registered);
  GPR_ASSERT(!fdn->writable_registered);
  gpr_mu_destroy(&fdn->mu);
  /* c-ares library has closed the fd inside grpc_fd. This fd may be picked up
     immediately by another thread, and should not be closed by the following
     grpc_fd_orphan. */
  grpc_fd_orphan(fdn->fd, nullptr, nullptr, true /* already_closed */,
                 "c-ares query finished");
  gpr_free(fdn);
}

static void fd_node_shutdown(fd_node* fdn) {
  gpr_mu_lock(&fdn->mu);
  fdn->shutting_down = true;
  if (!fdn->readable_registered && !fdn->writable_registered) {
    gpr_mu_unlock(&fdn->mu);
    fd_node_destroy(fdn);
  } else {
    grpc_fd_shutdown(
        fdn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING("c-ares fd shutdown"));
    gpr_mu_unlock(&fdn->mu);
  }
}

grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver,
                                       grpc_pollset_set* pollset_set) {
  *ev_driver = static_cast<grpc_ares_ev_driver*>(
      gpr_malloc(sizeof(grpc_ares_ev_driver)));
  int status = ares_init(&(*ev_driver)->channel);
  gpr_log(GPR_DEBUG, "grpc_ares_ev_driver_create");
  if (status != ARES_SUCCESS) {
    char* err_msg;
    gpr_asprintf(&err_msg, "Failed to init ares channel. C-ares error: %s",
                 ares_strerror(status));
    grpc_error* err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(err_msg);
    gpr_free(err_msg);
    gpr_free(*ev_driver);
    return err;
  }
  gpr_mu_init(&(*ev_driver)->mu);
  gpr_ref_init(&(*ev_driver)->refs, 1);
  (*ev_driver)->pollset_set = pollset_set;
  (*ev_driver)->fds = nullptr;
  (*ev_driver)->working = false;
  (*ev_driver)->shutting_down = false;
  return GRPC_ERROR_NONE;
}

void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver* ev_driver) {
  // It's not safe to shut down remaining fds here directly, becauses
  // ares_host_callback does not provide an exec_ctx. We mark the event driver
  // as being shut down. If the event driver is working,
  // grpc_ares_notify_on_event_locked will shut down the fds; if it's not
  // working, there are no fds to shut down.
  gpr_mu_lock(&ev_driver->mu);
  ev_driver->shutting_down = true;
  gpr_mu_unlock(&ev_driver->mu);
  grpc_ares_ev_driver_unref(ev_driver);
}

void grpc_ares_ev_driver_shutdown(grpc_ares_ev_driver* ev_driver) {
  gpr_mu_lock(&ev_driver->mu);
  ev_driver->shutting_down = true;
  fd_node* fn = ev_driver->fds;
  while (fn != nullptr) {
    grpc_fd_shutdown(fn->fd, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
                                 "grpc_ares_ev_driver_shutdown"));
    fn = fn->next;
  }
  gpr_mu_unlock(&ev_driver->mu);
}

// Search fd in the fd_node list head. This is an O(n) search, the max possible
// value of n is ARES_GETSOCK_MAXNUM (16). n is typically 1 - 2 in our tests.
static fd_node* pop_fd_node(fd_node** head, int fd) {
  fd_node dummy_head;
  dummy_head.next = *head;
  fd_node* node = &dummy_head;
  while (node->next != nullptr) {
    if (grpc_fd_wrapped_fd(node->next->fd) == fd) {
      fd_node* ret = node->next;
      node->next = node->next->next;
      *head = dummy_head.next;
      return ret;
    }
    node = node->next;
  }
  return nullptr;
}

/* Check if \a fd is still readable */
static bool grpc_ares_is_fd_still_readable(grpc_ares_ev_driver* ev_driver,
                                           int fd) {
  size_t bytes_available = 0;
  return ioctl(fd, FIONREAD, &bytes_available) == 0 && bytes_available > 0;
}

static void on_readable_cb(void* arg, grpc_error* error) {
  fd_node* fdn = static_cast<fd_node*>(arg);
  grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
  gpr_mu_lock(&fdn->mu);
  const int fd = grpc_fd_wrapped_fd(fdn->fd);
  fdn->readable_registered = false;
  if (fdn->shutting_down && !fdn->writable_registered) {
    gpr_mu_unlock(&fdn->mu);
    fd_node_destroy(fdn);
    grpc_ares_ev_driver_unref(ev_driver);
    return;
  }
  gpr_mu_unlock(&fdn->mu);

  gpr_log(GPR_DEBUG, "readable on %d", fd);
  if (error == GRPC_ERROR_NONE) {
    do {
      ares_process_fd(ev_driver->channel, fd, ARES_SOCKET_BAD);
    } while (grpc_ares_is_fd_still_readable(ev_driver, fd));
  } else {
    // If error is not GRPC_ERROR_NONE, it means the fd has been shutdown or
    // timed out. The pending lookups made on this ev_driver will be cancelled
    // by the following ares_cancel() and the on_done callbacks will be invoked
    // with a status of ARES_ECANCELLED. The remaining file descriptors in this
    // ev_driver will be cleaned up in the follwing
    // grpc_ares_notify_on_event_locked().
    ares_cancel(ev_driver->channel);
  }
  gpr_mu_lock(&ev_driver->mu);
  grpc_ares_notify_on_event_locked(ev_driver);
  gpr_mu_unlock(&ev_driver->mu);
  grpc_ares_ev_driver_unref(ev_driver);
}

static void on_writable_cb(void* arg, grpc_error* error) {
  fd_node* fdn = static_cast<fd_node*>(arg);
  grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
  gpr_mu_lock(&fdn->mu);
  const int fd = grpc_fd_wrapped_fd(fdn->fd);
  fdn->writable_registered = false;
  if (fdn->shutting_down && !fdn->readable_registered) {
    gpr_mu_unlock(&fdn->mu);
    fd_node_destroy(fdn);
    grpc_ares_ev_driver_unref(ev_driver);
    return;
  }
  gpr_mu_unlock(&fdn->mu);

  gpr_log(GPR_DEBUG, "writable on %d", fd);
  if (error == GRPC_ERROR_NONE) {
    ares_process_fd(ev_driver->channel, ARES_SOCKET_BAD, fd);
  } else {
    // If error is not GRPC_ERROR_NONE, it means the fd has been shutdown or
    // timed out. The pending lookups made on this ev_driver will be cancelled
    // by the following ares_cancel() and the on_done callbacks will be invoked
    // with a status of ARES_ECANCELLED. The remaining file descriptors in this
    // ev_driver will be cleaned up in the follwing
    // grpc_ares_notify_on_event_locked().
    ares_cancel(ev_driver->channel);
  }
  gpr_mu_lock(&ev_driver->mu);
  grpc_ares_notify_on_event_locked(ev_driver);
  gpr_mu_unlock(&ev_driver->mu);
  grpc_ares_ev_driver_unref(ev_driver);
}

ares_channel* grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver* ev_driver) {
  return &ev_driver->channel;
}

// Get the file descriptors used by the ev_driver's ares channel, register
// driver_closure with these filedescriptors.
static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) {
  fd_node* new_list = nullptr;
  if (!ev_driver->shutting_down) {
    ares_socket_t socks[ARES_GETSOCK_MAXNUM];
    int socks_bitmask =
        ares_getsock(ev_driver->channel, socks, ARES_GETSOCK_MAXNUM);
    for (size_t i = 0; i < ARES_GETSOCK_MAXNUM; i++) {
      if (ARES_GETSOCK_READABLE(socks_bitmask, i) ||
          ARES_GETSOCK_WRITABLE(socks_bitmask, i)) {
        fd_node* fdn = pop_fd_node(&ev_driver->fds, socks[i]);
        // Create a new fd_node if sock[i] is not in the fd_node list.
        if (fdn == nullptr) {
          char* fd_name;
          gpr_asprintf(&fd_name, "ares_ev_driver-%" PRIuPTR, i);
          fdn = static_cast<fd_node*>(gpr_malloc(sizeof(fd_node)));
          gpr_log(GPR_DEBUG, "new fd: %d", socks[i]);
          fdn->fd = grpc_fd_create(socks[i], fd_name);
          fdn->ev_driver = ev_driver;
          fdn->readable_registered = false;
          fdn->writable_registered = false;
          fdn->shutting_down = false;
          gpr_mu_init(&fdn->mu);
          GRPC_CLOSURE_INIT(&fdn->read_closure, on_readable_cb, fdn,
                            grpc_schedule_on_exec_ctx);
          GRPC_CLOSURE_INIT(&fdn->write_closure, on_writable_cb, fdn,
                            grpc_schedule_on_exec_ctx);
          grpc_pollset_set_add_fd(ev_driver->pollset_set, fdn->fd);
          gpr_free(fd_name);
        }
        fdn->next = new_list;
        new_list = fdn;
        gpr_mu_lock(&fdn->mu);
        // Register read_closure if the socket is readable and read_closure has
        // not been registered with this socket.
        if (ARES_GETSOCK_READABLE(socks_bitmask, i) &&
            !fdn->readable_registered) {
          grpc_ares_ev_driver_ref(ev_driver);
          gpr_log(GPR_DEBUG, "notify read on: %d", grpc_fd_wrapped_fd(fdn->fd));
          grpc_fd_notify_on_read(fdn->fd, &fdn->read_closure);
          fdn->readable_registered = true;
        }
        // Register write_closure if the socket is writable and write_closure
        // has not been registered with this socket.
        if (ARES_GETSOCK_WRITABLE(socks_bitmask, i) &&
            !fdn->writable_registered) {
          gpr_log(GPR_DEBUG, "notify write on: %d",
                  grpc_fd_wrapped_fd(fdn->fd));
          grpc_ares_ev_driver_ref(ev_driver);
          grpc_fd_notify_on_write(fdn->fd, &fdn->write_closure);
          fdn->writable_registered = true;
        }
        gpr_mu_unlock(&fdn->mu);
      }
    }
  }
  // Any remaining fds in ev_driver->fds were not returned by ares_getsock() and
  // are therefore no longer in use, so they can be shut down and removed from
  // the list.
  while (ev_driver->fds != nullptr) {
    fd_node* cur = ev_driver->fds;
    ev_driver->fds = ev_driver->fds->next;
    fd_node_shutdown(cur);
  }
  ev_driver->fds = new_list;
  // If the ev driver has no working fd, all the tasks are done.
  if (new_list == nullptr) {
    ev_driver->working = false;
    gpr_log(GPR_DEBUG, "ev driver stop working");
  }
}

void grpc_ares_ev_driver_start(grpc_ares_ev_driver* ev_driver) {
  gpr_mu_lock(&ev_driver->mu);
  if (!ev_driver->working) {
    ev_driver->working = true;
    grpc_ares_notify_on_event_locked(ev_driver);
  }
  gpr_mu_unlock(&ev_driver->mu);
}

#endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET) */


text:
languages:
- csharp
products:
- windows-wpf
page_type: sample
name: "ContextMenuOpening Handlers Sample"
---

# ContextMenuOpening Handlers Sample
This example illustrates some handling techniques for the ContextMenuOpening event. This event is useful for adjusting or replacing the context menu just prior to display in the user interface (UI).
Replacing the context menu does have some timing issues that you should be aware of. For more information, see the task topic that is intended as a companion topic for this sample, [How to: Handle the ContextMenuOpening Event](https://msdn.microsoft.com/en-us/library/bb625936.aspx).

## Build the sample
The easiest way to use these samples without using Git is to download the zip file containing the current version (using the link below or by clicking the "Download ZIP" button on the repo page). You can then unzip the entire archive and use the samples in [Visual Studio 2019](https://www.visualstudio.com/wpf-vs).

### Deploying the sample
- Select Build > Deploy Solution.

### Deploying and running the sample
- To debug the sample and then run it, press F5 or select Debug >  Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging.


text:
actions :create, :delete

attribute :domain, :kind_of => String
attribute :username, :kind_of => String
attribute :password, :kind_of => String
attribute :name, :kind_of => String
attribute :description, :kind_of => String, :default => "Input automatically created by Chef"
attribute :type, :kind_of => String, :equal_to => [ "http", "syslogudp", "syslogtcp", "syslog_tls", "syslogtcp_strip", "syslogudp_strip" ]


text:
layout: kanji
v4: 135
v6: 143
kanji: 願
keyword: petition
elements: petition, meadow, cliff, white, dove, small, little, head, page, one, ceiling, drop, shellfish, clam, oyster, eye, animal legs, eight
strokes: 19
image: E9A198
on-yomi: ガン
kun-yomi: ねが.う、-ねがい
permalink: /rtk/願/
prev: 原
next: 泳
---

1) [Christine_Tham] 27-7-2007(310): Let's petition to save that beautiful MEADOW from overdevelopment by signing on this PAGE.

2) [Danieru] 9-11-2007(107): Japanese hippies PETITION to save a meadow by getting people on the street to sign their page - as you pass by they call out: " お願いします、おねがいします。" .

3) [ketsensei] 10-2-2013(32): Dorothy, the Scarecrow, the Tin Man, and the Cowardly Lion cross the meadow to get to the large head that is Oz and make their PETITIONs for brains, heart, courage and a way home.

4) [shorinsakka] 20-6-2007(24): In the meadow a giant head has appeared. Everyone signs a petition so that it won't eat everyone.

5) [stereovibe] 3-3-2008(19): To save the meadow from development, a page of signatures was submitted as a petition.


text:
// Python Tools for Visual Studio
// Copyright(c) Microsoft Corporation
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the License); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABILITY OR NON-INFRINGEMENT.
//
// See the Apache Version 2.0 License for specific language governing
// permissions and limitations under the License.

using System;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;

namespace Microsoft.PythonTools.Editor {
    internal class SmartIndent : ISmartIndent {
        private readonly PythonToolsService _pyService;
        private readonly ITextView _textView;

        public SmartIndent(PythonToolsService pyService, ITextView view) {
            _pyService = pyService ?? throw new ArgumentNullException(nameof(pyService));
            _textView = view ?? throw new ArgumentNullException(nameof(view));
        }

        public int? GetDesiredIndentation(ITextSnapshotLine line) {
            if (_pyService.LangPrefs.IndentMode == vsIndentStyle.vsIndentStyleSmart) {
                return AutoIndent.GetLineIndentation(PythonTextBufferInfo.ForBuffer(_pyService.Site, line.Snapshot.TextBuffer), line, _textView);
            } else {
                return null;
            }
        }

        public void Dispose() {
        }
    }
}


text:
/*================================================================================
  code generated by: java2cpp
  author: Zoran Angelov, mailto://baldzar@gmail.com
  class: java.util.ResourceBundle
================================================================================*/

#ifndef J2CPP_INCLUDE_IMPLEMENTATION

#ifndef J2CPP_JAVA_UTIL_RESOURCEBUNDLE_HPP_DECL
#define J2CPP_JAVA_UTIL_RESOURCEBUNDLE_HPP_DECL

namespace j2cpp { namespace java { namespace lang { class String; } } }
namespace j2cpp { namespace java { namespace lang { class Object; } } }
namespace j2cpp { namespace java { namespace lang { class ClassLoader; } } }
namespace j2cpp { namespace java { namespace util { class Enumeration; } } }
namespace j2cpp { namespace java { namespace util { class Locale; } } }

#include <java/lang/ClassLoader.hpp>
#include <java/lang/Object.hpp>
#include <java/lang/String.hpp>
#include <java/util/Enumeration.hpp>
#include <java/util/Locale.hpp>

namespace j2cpp {

namespace java { namespace util {

	class ResourceBundle;
	class ResourceBundle
		: public object<ResourceBundle>
	{
	public:

		J2CPP_DECLARE_CLASS

		J2CPP_DECLARE_METHOD(0)
		J2CPP_DECLARE_METHOD(1)
		J2CPP_DECLARE_METHOD(2)
		J2CPP_DECLARE_METHOD(3)
		J2CPP_DECLARE_METHOD(4)
		J2CPP_DECLARE_METHOD(5)
		J2CPP_DECLARE_METHOD(6)
		J2CPP_DECLARE_METHOD(7)
		J2CPP_DECLARE_METHOD(8)
		J2CPP_DECLARE_METHOD(9)
		J2CPP_DECLARE_METHOD(10)
		J2CPP_DECLARE_FIELD(0)

		explicit ResourceBundle(jobject jobj)
		: object<ResourceBundle>(jobj)
		{
		}

		operator local_ref<java::lang::Object>() const;

		ResourceBundle();
		static local_ref< java::util::ResourceBundle > getBundle(local_ref< java::lang::String >  const&);
		static local_ref< java::util::ResourceBundle > getBundle(local_ref< java::lang::String >  const&, local_ref< java::util::Locale >  const&);
		static local_ref< java::util::ResourceBundle > getBundle(local_ref< java::lang::String >  const&, local_ref< java::util::Locale >  const&, local_ref< java::lang::ClassLoader >  const&);
		local_ref< java::util::Enumeration > getKeys();
		local_ref< java::util::Locale > getLocale();
		local_ref< java::lang::Object > getObject(local_ref< java::lang::String >  const&);
		local_ref< java::lang::String > getString(local_ref< java::lang::String >  const&);
		local_ref< array< local_ref< java::lang::String >, 1> > getStringArray(local_ref< java::lang::String >  const&);

	}; //class ResourceBundle

} //namespace util
} //namespace java

} //namespace j2cpp

#endif //J2CPP_JAVA_UTIL_RESOURCEBUNDLE_HPP_DECL

#else //J2CPP_INCLUDE_IMPLEMENTATION

#ifndef J2CPP_JAVA_UTIL_RESOURCEBUNDLE_HPP_IMPL
#define J2CPP_JAVA_UTIL_RESOURCEBUNDLE_HPP_IMPL

namespace j2cpp {

java::util::ResourceBundle::operator local_ref<java::lang::Object>() const
{
	return local_ref<java::lang::Object>(get_jobject());
}

java::util::ResourceBundle::ResourceBundle()
: object<java::util::ResourceBundle>(
	call_new_object<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(0),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(0)
	>()
)
{
}

local_ref< java::util::ResourceBundle > java::util::ResourceBundle::getBundle(local_ref< java::lang::String > const &a0)
{
	return call_static_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(1),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(1),
		local_ref< java::util::ResourceBundle >
	>(a0);
}

local_ref< java::util::ResourceBundle > java::util::ResourceBundle::getBundle(local_ref< java::lang::String > const &a0, local_ref< java::util::Locale > const &a1)
{
	return call_static_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(2),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(2),
		local_ref< java::util::ResourceBundle >
	>(a0, a1);
}

local_ref< java::util::ResourceBundle > java::util::ResourceBundle::getBundle(local_ref< java::lang::String > const &a0, local_ref< java::util::Locale > const &a1, local_ref< java::lang::ClassLoader > const &a2)
{
	return call_static_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(3),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(3),
		local_ref< java::util::ResourceBundle >
	>(a0, a1, a2);
}

local_ref< java::util::Enumeration > java::util::ResourceBundle::getKeys()
{
	return call_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(4),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(4),
		local_ref< java::util::Enumeration >
	>(get_jobject());
}

local_ref< java::util::Locale > java::util::ResourceBundle::getLocale()
{
	return call_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(5),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(5),
		local_ref< java::util::Locale >
	>(get_jobject());
}

local_ref< java::lang::Object > java::util::ResourceBundle::getObject(local_ref< java::lang::String > const &a0)
{
	return call_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(6),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(6),
		local_ref< java::lang::Object >
	>(get_jobject(), a0);
}

local_ref< java::lang::String > java::util::ResourceBundle::getString(local_ref< java::lang::String > const &a0)
{
	return call_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(7),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(7),
		local_ref< java::lang::String >
	>(get_jobject(), a0);
}

local_ref< array< local_ref< java::lang::String >, 1> > java::util::ResourceBundle::getStringArray(local_ref< java::lang::String > const &a0)
{
	return call_method<
		java::util::ResourceBundle::J2CPP_CLASS_NAME,
		java::util::ResourceBundle::J2CPP_METHOD_NAME(8),
		java::util::ResourceBundle::J2CPP_METHOD_SIGNATURE(8),
		local_ref< array< local_ref< java::lang::String >, 1> >
	>(get_jobject(), a0);
}

J2CPP_DEFINE_CLASS(java::util::ResourceBundle,"java/util/ResourceBundle")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,0,"<init>","()V")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,1,"getBundle","(Ljava/lang/String;)Ljava/util/ResourceBundle;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,2,"getBundle","(Ljava/lang/String;Ljava/util/Locale;)Ljava/util/ResourceBundle;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,3,"getBundle","(Ljava/lang/String;Ljava/util/Locale;Ljava/lang/ClassLoader;)Ljava/util/ResourceBundle;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,4,"getKeys","()Ljava/util/Enumeration;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,5,"getLocale","()Ljava/util/Locale;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,6,"getObject","(Ljava/lang/String;)Ljava/lang/Object;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,7,"getString","(Ljava/lang/String;)Ljava/lang/String;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,8,"getStringArray","(Ljava/lang/String;)[java.lang.String")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,9,"handleGetObject","(Ljava/lang/String;)Ljava/lang/Object;")
J2CPP_DEFINE_METHOD(java::util::ResourceBundle,10,"setParent","(Ljava/util/ResourceBundle;)V")
J2CPP_DEFINE_FIELD(java::util::ResourceBundle,0,"parent","Ljava/util/ResourceBundle;")

} //namespace j2cpp

#endif //J2CPP_JAVA_UTIL_RESOURCEBUNDLE_HPP_IMPL

#endif //J2CPP_INCLUDE_IMPLEMENTATION