text:
import requests

from will.plugin import WillPlugin
from will.decorators import respond_to, periodic, hear, randomly, route, rendered_template, require_settings

class PugPlugin(WillPlugin):

    @hear(r'\bpugs?\b')
    def talk_on_pug(self, message):
        req = requests.get('http://pugme.herokuapp.com/random')
        if req.ok:
            pug = req.json()['pug']

            if 'media.tumblr.com' in pug:
                # replace *.media.tumblr.com with media.tumblr.com and force ssl
                pug = 'https://media.tumblr.com' + pug.split('media.tumblr.com')[1]

            self.say(pug, message=message)


text:
package io.unequal.reuse.data;
import java.sql.Types;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import io.unequal.reuse.util.Strings;
import io.unequal.reuse.util.Util;
import io.unequal.reuse.util.IntegrityException;

@SuppressWarnings("rawtypes")
class TypeMappings {

	private static final Map<Class<?>,TypeMapping<?,?>> _mappings = new HashMap<>();

	public static TypeMapping<?,?> get(Class<?> arg) {
		if(Instance.class.isAssignableFrom(arg)) {
			return _mappings.get(Instance.class);
		}
		if(Constant.class.isAssignableFrom(arg)) {
			return _mappings.get(Constant.class);
		}
		TypeMapping<?,?> mapping = _mappings.get(arg);
		if(mapping == null) {
			throw new IntegrityException(arg);
		}
		return mapping;
	}

	public static boolean supported(Class<?> c) {
		if(Instance.class.isAssignableFrom(c)) {
			return true;
		}
		if(Constant.class.isAssignableFrom(c)) {
			return true;
		}
		return _mappings.containsKey(c);
	}

	private static void _register(Class<?> type, TypeMapping<?,?> mapping) {
		if(_mappings.containsKey(type)) {
			throw new IllegalArgumentException(Util.x("duplicate mapping for type '{}'", type.getSimpleName()));
		}
		_mappings.put(type, mapping);
	}

	static {
		// String:
		_register(String.class, new TypeMapping<String,String>(String.class, String.class, Types.LONGVARCHAR) {
			public String wrap(Object arg, Class<?> type, Connection c) {
				String s = (String)arg;
				if(Strings.empty(s)) {
					return null;
				}
				return s;
			}
			public String unwrap(Object arg) {
				String s = (String)arg;
				if(Strings.empty(s)) {
					return null;
				}
				return s;
			}
			public int compare(Object a, Object b) {
				return ((String)a).compareTo((String)b);
			}
		});
		// Boolean:
		_register(Boolean.class, new TypeMapping<Boolean,Boolean>(Boolean.class, Boolean.class, Types.BOOLEAN) {
			public int compare(Object a, Object b) {
				return ((Boolean)a).compareTo((Boolean)b);
			}
		});
		// Integer:
		_register(Integer.class, new TypeMapping<Integer,Integer>(Integer.class, Integer.class, Types.INTEGER) {
			public int compare(Object a, Object b) {
				return ((Integer)a).compareTo((Integer)b);
			}
		});
		// Long:
		_register(Long.class, new TypeMapping<Long,Long>(Long.class, Long.class, Types.BIGINT) {
			public int compare(Object a, Object b) {
				return ((Long)a).compareTo((Long)b);
			}
		});
		// Double:
		_register(Double.class, new TypeMapping<Double,Double>(Double.class, Double.class, Types.DOUBLE) {
			public int compare(Object a, Object b) {
				return ((Double)a).compareTo((Double)b);
			}
		});
		// Date:
		_register(Date.class, new TypeMapping<Date,Date>(Date.class, Date.class, Types.TIMESTAMP) {
			public int compare(Object a, Object b) {
				return ((Date)a).compareTo((Date)b);
			}
		});
		// Constant:
		_register(Constant.class, new TypeMapping<Constant,Integer>(Constant.class, Integer.class, Types.INTEGER) {
			public Constant wrap(Object arg, Class<?> type, Connection c) {
				return Constant.valueOf(type, (Integer)arg);
			}
			public Object unwrap(Object arg) {
				return ((Constant)arg).code();
			}
			public int compare(Object a, Object b) {
				return ((Integer)a).compareTo((Integer)b);
			}
		});
		// Instance:
		_register(Instance.class, new TypeMapping<Instance,Long>(Instance.class, Long.class, Types.BIGINT) {
			public Instance wrap(Object arg, Class<?> type, Connection c) {
				return c.database().entityForInstance(type).find((Long)arg, c);
			}
			public Object unwrap(Object arg) {
				return ((Instance)arg).id();
			}
			public int compare(Object a, Object b) {
				return ((Long)a).compareTo((Long)b);
			}
		});
	}
}

redpajama_set_name: RedPajamaGithub


text:
package com.trilead.ssh2.packets;

import java.io.IOException;
import java.security.SecureRandom;

import com.trilead.ssh2.compression.CompressionFactory;
import com.trilead.ssh2.crypto.CryptoWishList;
import com.trilead.ssh2.transport.KexParameters;

/**
 * PacketKexInit.
 *
 * @author Christian Plattner, plattner@trilead.com
 * @version $Id: PacketKexInit.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $
 */
public class PacketKexInit
{
	byte[] payload;

	KexParameters kp = new KexParameters();

	public PacketKexInit(CryptoWishList cwl, SecureRandom rnd)
	{
		kp.cookie = new byte[16];
		rnd.nextBytes(kp.cookie);

		kp.kex_algorithms = cwl.kexAlgorithms;
		kp.server_host_key_algorithms = cwl.serverHostKeyAlgorithms;
		kp.encryption_algorithms_client_to_server = cwl.c2s_enc_algos;
		kp.encryption_algorithms_server_to_client = cwl.s2c_enc_algos;
		kp.mac_algorithms_client_to_server = cwl.c2s_mac_algos;
		kp.mac_algorithms_server_to_client = cwl.s2c_mac_algos;
		kp.compression_algorithms_client_to_server = cwl.c2s_comp_algos;
		kp.compression_algorithms_server_to_client = cwl.s2c_comp_algos;
		kp.languages_client_to_server = new String[] {};
		kp.languages_server_to_client = new String[] {};
		kp.first_kex_packet_follows = false;
		kp.reserved_field1 = 0;
	}

	public PacketKexInit(byte payload[], int off, int len) throws IOException
	{
		this.payload = new byte[len];
		System.arraycopy(payload, off, this.payload, 0, len);

		TypesReader tr = new TypesReader(payload, off, len);

		int packet_type = tr.readByte();

		if (packet_type != Packets.SSH_MSG_KEXINIT)
			throw new IOException("This is not a KexInitPacket! (" + packet_type + ")");

		kp.cookie = tr.readBytes(16);
		kp.kex_algorithms = tr.readNameList();
		kp.server_host_key_algorithms = tr.readNameList();
		kp.encryption_algorithms_client_to_server = tr.readNameList();
		kp.encryption_algorithms_server_to_client = tr.readNameList();
		kp.mac_algorithms_client_to_server = tr.readNameList();
		kp.mac_algorithms_server_to_client = tr.readNameList();
		kp.compression_algorithms_client_to_server = tr.readNameList();
		kp.compression_algorithms_server_to_client = tr.readNameList();
		kp.languages_client_to_server = tr.readNameList();
		kp.languages_server_to_client = tr.readNameList();
		kp.first_kex_packet_follows = tr.readBoolean();
		kp.reserved_field1 = tr.readUINT32();

		if (tr.remain() != 0)
			throw new IOException("Padding in KexInitPacket!");
	}

	public byte[] getPayload()
	{
		if (payload == null)
		{
			TypesWriter tw = new TypesWriter();
			tw.writeByte(Packets.SSH_MSG_KEXINIT);
			tw.writeBytes(kp.cookie, 0, 16);
			tw.writeNameList(kp.kex_algorithms);
			tw.writeNameList(kp.server_host_key_algorithms);
			tw.writeNameList(kp.encryption_algorithms_client_to_server);
			tw.writeNameList(kp.encryption_algorithms_server_to_client);
			tw.writeNameList(kp.mac_algorithms_client_to_server);
			tw.writeNameList(kp.mac_algorithms_server_to_client);
			tw.writeNameList(kp.compression_algorithms_client_to_server);
			tw.writeNameList(kp.compression_algorithms_server_to_client);
			tw.writeNameList(kp.languages_client_to_server);
			tw.writeNameList(kp.languages_server_to_client);
			tw.writeBoolean(kp.first_kex_packet_follows);
			tw.writeUINT32(kp.reserved_field1);
			payload = tw.getBytes();
		}
		return payload;
	}

	public KexParameters getKexParameters()
	{
		return kp;
	}

	public String[] getCompression_algorithms_client_to_server()
	{
		return kp.compression_algorithms_client_to_server;
	}

	public String[] getCompression_algorithms_server_to_client()
	{
		return kp.compression_algorithms_server_to_client;
	}

	public byte[] getCookie()
	{
		return kp.cookie;
	}

	public String[] getEncryption_algorithms_client_to_server()
	{
		return kp.encryption_algorithms_client_to_server;
	}

	public String[] getEncryption_algorithms_server_to_client()
	{
		return kp.encryption_algorithms_server_to_client;
	}

	public boolean isFirst_kex_packet_follows()
	{
		return kp.first_kex_packet_follows;
	}

	public String[] getKex_algorithms()
	{
		return kp.kex_algorithms;
	}

	public String[] getLanguages_client_to_server()
	{
		return kp.languages_client_to_server;
	}

	public String[] getLanguages_server_to_client()
	{
		return kp.languages_server_to_client;
	}

	public String[] getMac_algorithms_client_to_server()
	{
		return kp.mac_algorithms_client_to_server;
	}

	public String[] getMac_algorithms_server_to_client()
	{
		return kp.mac_algorithms_server_to_client;
	}

	public int getReserved_field1()
	{
		return kp.reserved_field1;
	}

	public String[] getServer_host_key_algorithms()
	{
		return kp.server_host_key_algorithms;
	}
}


text:
import base64
import json
import random
import re
import time
import uuid

from streamlink.plugin import Plugin
from streamlink.plugin.api import validate
from streamlink.plugin.api.useragents import CHROME as USER_AGENT
from streamlink.stream import (HLSStream, HTTPStream)

HUAJIAO_URL = "http://www.huajiao.com/l/{}"
LAPI_URL = "http://g2.live.360.cn/liveplay?stype=flv&channel={}&bid=huajiao&sn={}&sid={}&_rate=xd&ts={}&r={}" \
           "&_ostype=flash&_delay=0&_sign=null&_ver=13"

_url_re = re.compile(r"""
        http(s)?://(www\.)?huajiao.com
        /l/(?P<channel>[^/]+)
""", re.VERBOSE)

_feed_json_re = re.compile(r'^\s*var\s*feed\s*=\s*(?P<feed>{.*})\s*;', re.MULTILINE)

_feed_json_schema = validate.Schema(
    validate.all(
        validate.transform(_feed_json_re.search),
        validate.any(
            None,
            validate.all(
                validate.get('feed'),
                validate.transform(json.loads)
            )
        )
    )
)

class Huajiao(Plugin):
    @classmethod
    def can_handle_url(self, url):
        return _url_re.match(url)

    def _get_streams(self):
        match = _url_re.match(self.url)
        channel = match.group("channel")

        self.session.http.headers.update({"User-Agent": USER_AGENT})
        self.session.http.verify = False

        feed_json = self.session.http.get(HUAJIAO_URL.format(channel), schema=_feed_json_schema)
        if feed_json['feed']['m3u8']:
            stream = HLSStream(self.session, feed_json['feed']['m3u8'])
        else:
            sn = feed_json['feed']['sn']
            channel_sid = feed_json['relay']['channel']
            sid = uuid.uuid4().hex.upper()
            encoded_json = self.session.http.get(LAPI_URL.format(channel_sid, sn, sid, time.time(), random.random())).content
            decoded_json = base64.decodestring(encoded_json[0:3] + encoded_json[6:]).decode('utf-8')
            video_data = json.loads(decoded_json)
            stream = HTTPStream(self.session, video_data['main'])
        yield "live", stream

__plugin__ = Huajiao


text:
namespace {

const int kHideKeyboardDelayMs = 100;

// The virtual keyboard show/hide animation duration.
const int kAnimationDurationMs = 200;

// The opacity of virtual keyboard container when show animation starts or
// hide animation finishes.
const float kAnimationStartOrAfterHideOpacity = 0.2f;

// Event targeter for the keyboard container.
class KeyboardContainerTargeter : public wm::MaskedWindowTargeter {
 public:
  KeyboardContainerTargeter(aura::Window* container,
                            keyboard::KeyboardControllerProxy* proxy)
      : wm::MaskedWindowTargeter(container),
        proxy_(proxy) {
  }

  virtual ~KeyboardContainerTargeter() {}

 private:
  // wm::MaskedWindowTargeter:
  virtual bool GetHitTestMask(aura::Window* window,
                              gfx::Path* mask) const OVERRIDE {
    if (proxy_ && !proxy_->HasKeyboardWindow())
      return true;
    gfx::Rect keyboard_bounds = proxy_ ? proxy_->GetKeyboardWindow()->bounds() :
        keyboard::DefaultKeyboardBoundsFromWindowBounds(window->bounds());
    mask->addRect(RectToSkRect(keyboard_bounds));
    return true;
  }

  keyboard::KeyboardControllerProxy* proxy_;

  DISALLOW_COPY_AND_ASSIGN(KeyboardContainerTargeter);
};

// The KeyboardWindowDelegate makes sure the keyboard-window does not get focus.
// This is necessary to make sure that the synthetic key-events reach the target
// window.
// The delegate deletes itself when the window is destroyed.
class KeyboardWindowDelegate : public aura::WindowDelegate {
 public:
  explicit KeyboardWindowDelegate(keyboard::KeyboardControllerProxy* proxy)
      : proxy_(proxy) {}
  virtual ~KeyboardWindowDelegate() {}

 private:
  // Overridden from aura::WindowDelegate:
  virtual gfx::Size GetMinimumSize() const OVERRIDE { return gfx::Size(); }
  virtual gfx::Size GetMaximumSize() const OVERRIDE { return gfx::Size(); }
  virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
                               const gfx::Rect& new_bounds) OVERRIDE {
    bounds_ = new_bounds;
  }
  virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
    return gfx::kNullCursor;
  }
  virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE {
    return HTNOWHERE;
  }
  virtual bool ShouldDescendIntoChildForEventHandling(
      aura::Window* child,
      const gfx::Point& location) OVERRIDE {
    return true;
  }
  virtual bool CanFocus() OVERRIDE { return false; }
  virtual void OnCaptureLost() OVERRIDE {}
  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {}
  virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE {}
  virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {}
  virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE { delete this; }
  virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {}
  virtual bool HasHitTestMask() const OVERRIDE {
    return !proxy_ || proxy_->HasKeyboardWindow();
  }
  virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {
    if (proxy_ && !proxy_->HasKeyboardWindow())
      return;
    gfx::Rect keyboard_bounds = proxy_ ? proxy_->GetKeyboardWindow()->bounds() :
        keyboard::DefaultKeyboardBoundsFromWindowBounds(bounds_);
    mask->addRect(RectToSkRect(keyboard_bounds));
  }

  gfx::Rect bounds_;
  keyboard::KeyboardControllerProxy* proxy_;

  DISALLOW_COPY_AND_ASSIGN(KeyboardWindowDelegate);
};

void ToggleTouchEventLogging(bool enable) {
#if defined(OS_CHROMEOS)
  if (!base::SysInfo::IsRunningOnChromeOS())
    return;
  CommandLine command(
      base::FilePath("/opt/google/touchscreen/toggle_touch_event_logging"));
  if (enable)
    command.AppendArg("1");
  else
    command.AppendArg("0");
  VLOG(1) << "Running " << command.GetCommandLineString();
  base::LaunchOptions options;
  options.wait = true;
  base::LaunchProcess(command, options, NULL);
#endif
}

aura::Window *GetFrameWindow(aura::Window *window) {
  // Each container window has a non-negative id.  Stop traversing at the child
  // of a container window.
  if (!window)
    return NULL;
  while(window->parent() && window->parent()->id() < 0) {
    window = window->parent();
  }
  return window;
}

}  // namespace

namespace keyboard {

// Observer for both keyboard show and hide animations. It should be owned by
// KeyboardController.
class CallbackAnimationObserver : public ui::LayerAnimationObserver {
 public:
  CallbackAnimationObserver(ui::LayerAnimator* animator,
                            base::Callback<void(void)> callback);
  virtual ~CallbackAnimationObserver();

 private:
  // Overridden from ui::LayerAnimationObserver:
  virtual void OnLayerAnimationEnded(ui::LayerAnimationSequence* seq) OVERRIDE;
  virtual void OnLayerAnimationAborted(
      ui::LayerAnimationSequence* seq) OVERRIDE;
  virtual void OnLayerAnimationScheduled(
      ui::LayerAnimationSequence* seq) OVERRIDE {}

  ui::LayerAnimator* animator_;
  base::Callback<void(void)> callback_;

  DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver);
};

CallbackAnimationObserver::CallbackAnimationObserver(
    ui::LayerAnimator* animator, base::Callback<void(void)> callback)
    : animator_(animator), callback_(callback) {
}

CallbackAnimationObserver::~CallbackAnimationObserver() {
  animator_->RemoveObserver(this);
}

void CallbackAnimationObserver::OnLayerAnimationEnded(
    ui::LayerAnimationSequence* seq) {
  if (animator_->is_animating())
    return;
  animator_->RemoveObserver(this);
  callback_.Run();
}

void CallbackAnimationObserver::OnLayerAnimationAborted(
    ui::LayerAnimationSequence* seq) {
  animator_->RemoveObserver(this);
}

class WindowBoundsChangeObserver : public aura::WindowObserver {
 public:
  virtual void OnWindowBoundsChanged(aura::Window* window,
                                     const gfx::Rect& old_bounds,
                                     const gfx::Rect& new_bounds) OVERRIDE;
};

void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window,
    const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) {
  KeyboardController* controller =  KeyboardController::GetInstance();
  if (controller)
    controller->UpdateWindowInsets(window);
}

// static
KeyboardController* KeyboardController::instance_ = NULL;

KeyboardController::KeyboardController(KeyboardControllerProxy* proxy)
    : proxy_(proxy),
      input_method_(NULL),
      keyboard_visible_(false),
      lock_keyboard_(false),
      type_(ui::TEXT_INPUT_TYPE_NONE),
      weak_factory_(this) {
  CHECK(proxy);
  input_method_ = proxy_->GetInputMethod();
  input_method_->AddObserver(this);
  window_bounds_observer_.reset(new WindowBoundsChangeObserver());
}

KeyboardController::~KeyboardController() {
  if (container_)
    container_->RemoveObserver(this);
  if (input_method_)
    input_method_->RemoveObserver(this);
  ResetWindowInsets();
}

// static
void KeyboardController::ResetInstance(KeyboardController* controller) {
  if (instance_ && instance_ != controller)
    delete instance_;
  instance_ = controller;
}

// static
KeyboardController* KeyboardController::GetInstance() {
  return instance_;
}

aura::Window* KeyboardController::GetContainerWindow() {
  if (!container_.get()) {
    container_.reset(new aura::Window(
        new KeyboardWindowDelegate(proxy_.get())));
    container_->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
        new KeyboardContainerTargeter(container_.get(), proxy_.get())));
    container_->SetName("KeyboardContainer");
    container_->set_owned_by_parent(false);
    container_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
    container_->AddObserver(this);
    container_->SetLayoutManager(new KeyboardLayoutManager(this));
  }
  return container_.get();
}

void KeyboardController::NotifyKeyboardBoundsChanging(
    const gfx::Rect& new_bounds) {
  current_keyboard_bounds_ = new_bounds;
  if (proxy_->HasKeyboardWindow() && proxy_->GetKeyboardWindow()->IsVisible()) {
    FOR_EACH_OBSERVER(KeyboardControllerObserver,
                      observer_list_,
                      OnKeyboardBoundsChanging(new_bounds));
    if (keyboard::IsKeyboardOverscrollEnabled()) {
      // Adjust the height of the viewport for visible windows on the primary
      // display.
      // TODO(kevers): Add EnvObserver to properly initialize insets if a
      // window is created while the keyboard is visible.
      scoped_ptr<content::RenderWidgetHostIterator> widgets(
          content::RenderWidgetHost::GetRenderWidgetHosts());
      aura::Window *keyboard_window = proxy_->GetKeyboardWindow();
      aura::Window *root_window = keyboard_window->GetRootWindow();
      while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
        content::RenderWidgetHostView* view = widget->GetView();
        // Can be NULL, e.g. if the RenderWidget is being destroyed or
        // the render process crashed.
        if (view) {
          aura::Window *window = view->GetNativeView();
          if (window != keyboard_window &&
              window->GetRootWindow() == root_window) {
            gfx::Rect window_bounds = window->GetBoundsInScreen();
            gfx::Rect intersect = gfx::IntersectRects(window_bounds,
                                                      new_bounds);
            int overlap = intersect.height();
            if (overlap > 0 && overlap < window_bounds.height())
              view->SetInsets(gfx::Insets(0, 0, overlap, 0));
            else
              view->SetInsets(gfx::Insets());
            AddBoundsChangedObserver(window);
          }
        }
      }
    } else {
      ResetWindowInsets();
    }
  } else {
    current_keyboard_bounds_ = gfx::Rect();
  }
}

void KeyboardController::HideKeyboard(HideReason reason) {
  keyboard_visible_ = false;
  ToggleTouchEventLogging(true);

  keyboard::LogKeyboardControlEvent(
      reason == HIDE_REASON_AUTOMATIC ?
          keyboard::KEYBOARD_CONTROL_HIDE_AUTO :
          keyboard::KEYBOARD_CONTROL_HIDE_USER);

  NotifyKeyboardBoundsChanging(gfx::Rect());

  set_lock_keyboard(false);

  ui::LayerAnimator* container_animator = container_->layer()->GetAnimator();
  animation_observer_.reset(new CallbackAnimationObserver(
      container_animator,
      base::Bind(&KeyboardController::HideAnimationFinished,
                 base::Unretained(this))));
  container_animator->AddObserver(animation_observer_.get());

  ui::ScopedLayerAnimationSettings settings(container_animator);
  settings.SetTweenType(gfx::Tween::EASE_OUT);
  settings.SetTransitionDuration(
      base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
  gfx::Transform transform;
  transform.Translate(0, proxy_->GetKeyboardWindow()->bounds().height());
  container_->SetTransform(transform);
  container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity);
}

void KeyboardController::AddObserver(KeyboardControllerObserver* observer) {
  observer_list_.AddObserver(observer);
}

void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) {
  observer_list_.RemoveObserver(observer);
}

void KeyboardController::ShowKeyboard(bool lock) {
  set_lock_keyboard(lock);
  ShowKeyboardInternal();
}

void KeyboardController::OnWindowHierarchyChanged(
    const HierarchyChangeParams& params) {
  if (params.new_parent && params.target == container_.get())
    OnTextInputStateChanged(proxy_->GetInputMethod()->GetTextInputClient());
}

void KeyboardController::Reload() {
  if (proxy_->HasKeyboardWindow())
    proxy_->ReloadKeyboardIfNeeded();
}

void KeyboardController::OnTextInputStateChanged(
    const ui::TextInputClient* client) {
  if (!container_.get())
    return;

  if (IsKeyboardUsabilityExperimentEnabled()) {
    ShowKeyboardInternal();
    return;
  }

  type_ = client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;

  if (type_ == ui::TEXT_INPUT_TYPE_NONE && !lock_keyboard_) {
    if (keyboard_visible_) {
      // Set the visibility state here so that any queries for visibility
      // before the timer fires returns the correct future value.
      keyboard_visible_ = false;
      base::MessageLoop::current()->PostDelayedTask(
          FROM_HERE,
          base::Bind(&KeyboardController::HideKeyboard,
                     weak_factory_.GetWeakPtr(), HIDE_REASON_AUTOMATIC),
          base::TimeDelta::FromMilliseconds(kHideKeyboardDelayMs));
    }
  } else {
    // Abort a pending keyboard hide.
    if (WillHideKeyboard()) {
      weak_factory_.InvalidateWeakPtrs();
      keyboard_visible_ = true;
    }
    proxy_->SetUpdateInputType(type_);
    // Do not explicitly show the Virtual keyboard unless it is in the process
    // of hiding. Instead, the virtual keyboard is shown in response to a user
    // gesture (mouse or touch) that is received while an element has input
    // focus. Showing the keyboard requires an explicit call to
    // OnShowImeIfNeeded.
  }
}

void KeyboardController::OnInputMethodDestroyed(
    const ui::InputMethod* input_method) {
  DCHECK_EQ(input_method_, input_method);
  input_method_ = NULL;
}

void KeyboardController::OnShowImeIfNeeded() {
  ShowKeyboardInternal();
}

void KeyboardController::UpdateWindowInsets(aura::Window* window) {
  aura::Window *keyboard_window = proxy_->GetKeyboardWindow();
  if (window == keyboard_window)
    return;

  bool enableInsets = (keyboard_window->GetRootWindow() ==
      window->GetRootWindow()) && keyboard::IsKeyboardOverscrollEnabled() &&
      proxy_->GetKeyboardWindow()->IsVisible();

  scoped_ptr<content::RenderWidgetHostIterator> widgets(
      content::RenderWidgetHost::GetRenderWidgetHosts());
  while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
    content::RenderWidgetHostView* view = widget->GetView();
    if (view && window->Contains(view->GetNativeView())) {
      gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen();
      gfx::Rect intersect = gfx::IntersectRects(window_bounds,
          proxy_->GetKeyboardWindow()->bounds());
      int overlap = enableInsets ? intersect.height() : 0;
      if (overlap > 0 && overlap < window_bounds.height())
        view->SetInsets(gfx::Insets(0, 0, overlap, 0));
      else
        view->SetInsets(gfx::Insets());
      return;
    }
  }
}

void KeyboardController::ShowKeyboardInternal() {
  if (!container_.get())
    return;

  if (container_->children().empty()) {
    keyboard::MarkKeyboardLoadStarted();
    aura::Window* keyboard = proxy_->GetKeyboardWindow();
    keyboard->Show();
    container_->AddChild(keyboard);
    keyboard->set_owned_by_parent(false);
  }

  proxy_->ReloadKeyboardIfNeeded();

  if (keyboard_visible_ || proxy_->GetKeyboardWindow()->bounds().height() == 0)
    return;

  keyboard_visible_ = true;

  // If the controller is in the process of hiding the keyboard, do not log
  // the stat here since the keyboard will not actually be shown.
  if (!WillHideKeyboard())
    keyboard::LogKeyboardControlEvent(keyboard::KEYBOARD_CONTROL_SHOW);

  weak_factory_.InvalidateWeakPtrs();

  // If |container_| has hide animation, its visibility is set to false when
  // hide animation finished. So even if the container is visible at this
  // point, it may in the process of hiding. We still need to show keyboard
  // container in this case.
  if (container_->IsVisible() &&
      !container_->layer()->GetAnimator()->is_animating())
    return;

  ToggleTouchEventLogging(false);
  ui::LayerAnimator* container_animator = container_->layer()->GetAnimator();

  // If the container is not animating, makes sure the position and opacity
  // are at begin states for animation.
  if (!container_animator->is_animating()) {
    gfx::Transform transform;
    transform.Translate(0, proxy_->GetKeyboardWindow()->bounds().height());
    container_->SetTransform(transform);
    container_->layer()->SetOpacity(kAnimationStartOrAfterHideOpacity);
  }

  container_animator->set_preemption_strategy(
      ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
  animation_observer_.reset(new CallbackAnimationObserver(
      container_animator,
      base::Bind(&KeyboardController::ShowAnimationFinished,
                 base::Unretained(this))));
  container_animator->AddObserver(animation_observer_.get());

  proxy_->ShowKeyboardContainer(container_.get());

  {
    // Scope the following animation settings as we don't want to animate
    // visibility change that triggered by a call to the base class function
    // ShowKeyboardContainer with these settings. The container should become
    // visible immediately.
    ui::ScopedLayerAnimationSettings settings(container_animator);
    settings.SetTweenType(gfx::Tween::EASE_IN);
    settings.SetTransitionDuration(
        base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
    container_->SetTransform(gfx::Transform());
    container_->layer()->SetOpacity(1.0);
  }
}

void KeyboardController::ResetWindowInsets() {
  const gfx::Insets insets;
  scoped_ptr<content::RenderWidgetHostIterator> widgets(
      content::RenderWidgetHost::GetRenderWidgetHosts());
  while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
    content::RenderWidgetHostView* view = widget->GetView();
    if (view) {
      view->SetInsets(insets);
      aura::Window *window = view->GetNativeView();
      RemoveBoundsChangedObserver(window);
    }
  }
}

bool KeyboardController::WillHideKeyboard() const {
  return weak_factory_.HasWeakPtrs();
}

void KeyboardController::ShowAnimationFinished() {
  // Notify observers after animation finished to prevent reveal desktop
  // background during animation.
  NotifyKeyboardBoundsChanging(proxy_->GetKeyboardWindow()->bounds());
  proxy_->EnsureCaretInWorkArea();
}

void KeyboardController::HideAnimationFinished() {
  proxy_->HideKeyboardContainer(container_.get());
}

void KeyboardController::AddBoundsChangedObserver(aura::Window* window) {
  aura::Window* target_window = GetFrameWindow(window);
  if (target_window &&
      !target_window->HasObserver(window_bounds_observer_.get())) {
    target_window->AddObserver(window_bounds_observer_.get());
  }
}

void KeyboardController::RemoveBoundsChangedObserver(aura::Window* window) {
  aura::Window* target_window = GetFrameWindow(window);
  if (target_window &&
      target_window->HasObserver(window_bounds_observer_.get())) {
    target_window->RemoveObserver(window_bounds_observer_.get());
  }
}

}  // namespace keyboard


text:
#include <op/utest/unit_test.h>
#include <op/utest/unit_test_is.h>
#include <random>
#include <algorithm>

#include <map>
#include <set>

#include <op/common/Range.h>
template <class Os, class Int1, class Int2 >
Os& operator << (Os& os, const OP::Range<Int1, Int2>& r)
{
    return os << r.pos() << ":" << r.right() << "(" << r.count() << ")";
}
#include <op/common/SpanContainer.h>

template <class Container, class Sampler>
void comparative_test(OP::utest::TestRuntime& tresult, Container& co, Sampler samples)
{
    for (auto found = co.begin(); found != co.end(); ++found)
    {
        auto probe_iter = samples.find(*found);
        tresult.assert_true(samples.end() != probe_iter);
        samples.erase(probe_iter);
    }
    tresult.assert_true(samples.empty());
}

template <class Span, class SpanContainer, class Sampler>
void intersect_test(OP::utest::TestRuntime& tresult, const Span& test_span, SpanContainer& from, Sampler samples)
{
    auto tracker = from.intersect_with(test_span);
    while (tracker != from.end() && OP::zones::is_overlapping(*tracker, test_span) && !samples.empty())
    {
        auto probe_iter = samples.find(*tracker);
        tresult.assert_true(samples.end() != probe_iter);
        samples.erase(probe_iter);
        ++tracker;
    }
    tresult.assert_true(samples.empty());
}
using zone_t = OP::Range<unsigned, unsigned>;
struct less_by_pos{ //used as less for std::set
    bool operator () (const zone_t& a, const zone_t& b) const
    {
        return a.pos() < b.pos() || (a.pos() == b.pos() && a.count() < b.count());
    }
};
using check_container_t = std::multiset<zone_t, less_by_pos>;

void test_add(OP::utest::TestRuntime& tresult)
{
    using span_container_t = OP::zones::SpanSet<zone_t>;
    using tracker_t = typename span_container_t::IntersectionTracker;
    span_container_t container;
    check_container_t check_container;
    tracker_t oo1 (container, zone_t(0, 0));
    tresult.assert_true(!oo1 );

    auto r = container.emplace(10, 1000);
    tresult.assert_true(r->pos() == 10 && r->count() == 1000);
    check_container.emplace(*r);
    comparative_test(tresult, container, check_container);
    tracker_t  oo2(container, zone_t(10, 0));
    tresult.assert_true(!oo2);
    tracker_t oo3 (container, zone_t(0, 1));
    tresult.assert_true(!oo3 );
    tracker_t oo4 (container, zone_t(1111, 1));
    tresult.assert_true(!oo4 );

    tracker_t cs1 (container, zone_t(10, 1));
    tresult.assert_true(cs1->pos() == 10 && cs1->count() == 1000);

    r = std::move(container.emplace(10, 20));
    tresult.assert_true(r->pos() == 10 && r->count() == 20);
    check_container.emplace(*r);

    comparative_test(tresult, container, check_container);

    {
        const zone_t test_span(5, 7);
        intersect_test(tresult, test_span, container, check_container);
        container.emplace(1, 3);
        container.emplace(1001, 1);
        container.dump(std::cout << "--=======\n");
        intersect_test(tresult, test_span, container, check_container);
    }
    {
        const zone_t test_span(999, 5);
        check_container_t check_container;
        intersect_test(tresult, test_span, container, check_container_t{zone_t(10, 1000), zone_t(1001, 1)});
    }
    tresult.info() << "test dupplicate addings...\n";
    {
        tresult.info() << "\tover existing values\n";
        check_container.emplace(1001, 1);
        check_container.emplace(1, 3);

        r = container.emplace(10, 1000);
        check_container.emplace(*r);
        comparative_test(tresult, container, check_container);

        r = container.emplace(1, 3);
        check_container.emplace(*r);

        r = container.emplace(1, 3);
        check_container.emplace(*r);

        r = container.emplace(10, 1000);//3-times
        check_container.emplace(*r);
        comparative_test(tresult, container, check_container);
        container.dump(std::cout << "--*3---\n");
        intersect_test(
            tresult,
            zone_t(3, 10), container,
            check_container_t{zone_t(1, 3), zone_t(1, 3), zone_t(1, 3), zone_t(10, 20), zone_t(10, 1000), zone_t(10, 1000), zone_t(10, 1000)} );
    }

    {//smoke on erase
        const auto tst_span = zone_t(10, 1000);
        auto found = container.intersect_with(tst_span);
        while(*found != tst_span )
            ++found;
        tresult.assert_true(1 == container.erase(found));
        intersect_test(tresult,
            zone_t(3, 10), container,
            check_container_t{zone_t(1, 3), zone_t(1, 3), zone_t(1, 3), zone_t(10, 20), zone_t(10, 1000), zone_t(10, 1000)} );
    }
}
int overlap_add(OP::utest::TestRuntime& tresult)
{
    using span_container_t = OP::zones::SpanSet<zone_t>;
    span_container_t container;
    check_container_t check_container;
    {
        auto r = container.emplace(10, 10);
        check_container.emplace(*r);
        r = container.emplace(20, 10);
        check_container.emplace(*r);
        container.dump(std::cout << "--=======\n");
        comparative_test(tresult, container, check_container);
        intersect_test(tresult,
            zone_t(9, 2), container, check_container_t{zone_t(10, 10)});
        intersect_test(tresult,
            zone_t(9, 31), container, check_container);
        intersect_test(tresult,
            zone_t(19, 21), container, check_container);
        intersect_test(tresult,
            zone_t(31, 1), container, check_container_t{});

    }
    {
        auto r = container.emplace(100, 10);
        check_container.emplace(*r);
        r = container.emplace(100, 5);
        check_container.emplace(*r);
        container.dump(tresult.debug() << "--=======\n");
        comparative_test(tresult, container, check_container);
        intersect_test(tresult,
            zone_t(99, 2), container, check_container_t{zone_t(100, 10), zone_t(100, 5)});
        intersect_test(tresult,
            zone_t(99, 12), container, check_container_t{zone_t(100, 10), zone_t(100, 5)});
        intersect_test(tresult,
            zone_t(104, 1), container, check_container_t{zone_t(100, 10), zone_t(100, 5)});
        intersect_test(tresult,
            zone_t(111, 1), container, check_container_t{});

        r = container.emplace(130, 5);
        check_container.emplace(*r);
        r = container.emplace(130, 10);
        check_container.emplace(*r);
        intersect_test(tresult,
            zone_t(129, 2), container, check_container_t{zone_t(130, 10), zone_t(130, 5)});
        intersect_test(tresult,
            zone_t(129, 12), container, check_container_t{zone_t(130, 10), zone_t(130, 5)});
        intersect_test(tresult,
            zone_t(134, 1), container, check_container_t{zone_t(130, 10), zone_t(130, 5)});
        intersect_test(tresult,
            zone_t(141, 1), container, check_container_t{});
    }
    {
        auto r = container.emplace(1000, 10);
        check_container.emplace(*r);
        r = container.emplace(999, 5);
        check_container.emplace(*r);
        r = container.emplace(1009, 5);
        check_container.emplace(*r);
        container.dump(std::cout << "--=======\n");
        comparative_test(tresult,
            container, check_container);
        intersect_test(tresult,
            zone_t(999, 2), container, check_container_t{zone_t(999, 5), zone_t(1000, 10)});
        intersect_test(tresult,
            zone_t(1003, 5), container, check_container_t{zone_t(999, 5), zone_t(1000, 10)});
        intersect_test(tresult,
            zone_t(1008, 2), container, check_container_t{zone_t(1000, 10), zone_t(1009, 5)});
        intersect_test(tresult,
            zone_t(1011, 2), container, check_container_t{zone_t(1009, 5)});
        intersect_test(tresult,
            zone_t(1015, 1), container, check_container_t{});
    }
    intersect_test(tresult,
        zone_t(1, 10000), container, check_container);
    return 0;
}

constexpr unsigned UNIFIED_MAGIC_NUM = 1;
constexpr unsigned TST_NUM_RUNS = 20;
constexpr unsigned TST_CHUNK_SIZE = 111 * 16;

std::uniform_int_distribution<unsigned> pos_dist(0, 0x10000); //rules to generate zone begining
std::uniform_int_distribution<unsigned> size_dist(0x10, 0x1000);// rules to generate zone size

template <class Pt, class Rnd, class Vext>
void generate_rand_chunk(Rnd& rnd, Vext& container)
{
    container.clear();
    container.reserve(TST_CHUNK_SIZE);
    for (unsigned i = 0; i < TST_CHUNK_SIZE; ++i)
    {
        container.emplace_back(typename Vext::value_type{ Pt(pos_dist(rnd)), Pt(size_dist(rnd)) });
    }
}
auto find_all_intersects = [](const zone_t& what, const check_container_t& from) -> check_container_t {
    check_container_t rv;
    std::copy_if(from.begin(), from.end(),
            std::inserter(rv, rv.end()),
        [&](const auto& chk )->bool{ return OP::zones::is_overlapping(what, chk);}
        );
    return rv;
};

void random_stuff_test(OP::utest::TestRuntime& tresult)
{
    using span_container_t = OP::zones::SpanSet<zone_t>;
    using tracker_t = typename span_container_t::IntersectionTracker ;
    span_container_t container;
    check_container_t check_container;
    std::mt19937 rgen;
    // Seed the engine with an unsigned int
    rgen.seed(UNIFIED_MAGIC_NUM);

    for (unsigned i = 0; i < TST_CHUNK_SIZE; ++i)
    {
        auto p = pos_dist(rgen);
        auto sz = size_dist(rgen);
        auto r = container.emplace(p, sz);
        tresult.assert_true(*r == *check_container.emplace(p, sz));
    }
    comparative_test(tresult,
        container, check_container);
    //
    // Positive test, check all intersections are foundable
    //
    std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();

    for (const auto& z : check_container)
    {
        auto expected = find_all_intersects(z, check_container);
        /*if(z.pos() == 0x1f && z.count() == 0x1a9)
        {
            container.dump(std::cout<<"======================\n");
        }*/
        intersect_test(tresult,
            z, container, expected);
    }
    std::chrono::steady_clock::time_point finish = std::chrono::steady_clock::now();
    tresult.info() << "Positive took:"
        << std::chrono::duration<double, std::milli>(finish - start).count() << "[mls]\n"
        ;
    //
    //  Positive + Negative tests - intersect with random span that exists and non exists
    //
    unsigned prev_p = 0, prev_sz = 0;
    start = std::chrono::steady_clock::now();
    for(auto i = 0; i < TST_CHUNK_SIZE; ++i)
    {
        auto p = pos_dist(rgen);
        auto sz = size_dist(rgen);
        zone_t z(p, sz);
        auto expected = find_all_intersects(z, check_container);
        intersect_test(tresult,
            z, container, expected);
    }
    finish = std::chrono::steady_clock::now();
    tresult.info() << "Negative+Positive took:"
        << std::chrono::duration<double, std::milli>(finish - start).count() << "[mks]"
        << std::endl;
}
void test_erase(OP::utest::TestRuntime& tresult)
{
    using span_container_t = OP::zones::SpanSet<zone_t>;
    span_container_t container;

    tresult.assert_true(0 == container.erase(container.begin()));

    auto r = container.emplace(10, 3);
    intersect_test( tresult,
        zone_t(3, 10), container,
        check_container_t{zone_t(10, 3)} );

    tresult.assert_true(1 == container.erase(r));

    intersect_test( tresult,
        zone_t(3, 10), container,
        check_container_t{} );

    r = container.emplace(10, 3);
    container.emplace(7, 5);
    container.emplace(11, 7);
    container.emplace(3, 20);
    tresult.assert_true(1 == container.erase(r));
    intersect_test( tresult,
        zone_t(3, 10), container,
        check_container_t{zone_t(7, 5), zone_t(11, 7), zone_t(3, 20)} );
    {//test to proove independance of erasure order
        std::random_device rd;
        std::mt19937 g(rd());

        for (int i = 0; i < 25; ++i)
        {
             std::vector<decltype(r)> ins_res = {
                container.emplace(10, 3),
                container.emplace(10, 3),
                container.emplace(10, 3),
                container.emplace(10, 3)
             };
             std::shuffle(ins_res.begin(), ins_res.end(), g);

             for(auto &ri : ins_res)
                tresult.assert_true(1 == container.erase(ri));

             intersect_test( tresult,
                 zone_t(3, 10), container,
                check_container_t{zone_t(7, 5), zone_t(11, 7), zone_t(3, 20)} );
        }
    }
    container.dump(std::cout << "----[After erasure]----\n");
    {
        std::vector<decltype(r)> check_container;
        check_container_t exist_conatiner;
        std::mt19937 rgen;
        // Seed the engine with an unsigned int
        rgen.seed(UNIFIED_MAGIC_NUM);

        for (unsigned i = 0; i < TST_CHUNK_SIZE; ++i)
        {
            auto p = pos_dist(rgen);
            auto sz = size_dist(rgen);
            auto r = container.emplace(p, sz);
            if( (i % 3) == 0 ) //peek each 3d
                check_container.emplace_back(r);
            else
                exist_conatiner.emplace(*r);
        }
        // **********
        for (auto & w : check_container)
        {
            tresult.assert_true(1 == container.erase(w));
        }
        // ********** check integrity
        for (const auto& z : exist_conatiner)
        {
            auto expected = find_all_intersects(z, exist_conatiner);
            intersect_test(tresult,
                z, container, expected);
        }

    }
}
void test_dump(OP::utest::TestRuntime& tresult)
{
    using span_container_t = OP::zones::SpanSet<zone_t>;
    using tracker_t = typename span_container_t::IntersectionTracker ;
    span_container_t container;
    std::mt19937 rgen;
    // Seed the engine with an unsigned int
    rgen.seed(UNIFIED_MAGIC_NUM);
    const unsigned limit_c = 200;
    for (unsigned i = 0; i < limit_c; ++i)
    {
        auto p = pos_dist(rgen);
        auto sz = size_dist(rgen);
        auto r = container.emplace(p, sz);
    }
    container.dump(tresult.debug() << "--====##### Branches dump for :("<< limit_c<< ") node #####====--\n");
}

void test_map(OP::utest::TestRuntime& tresult)
{

    using span_map_t = OP::zones::SpanMap<zone_t, double>;
    span_map_t map;
    map.emplace(zone_t(1, 2), 1.2);
    map.emplace(zone_t(1, 3), 1.3);
    map.emplace(zone_t(1, 4), 1.4);
    map.emplace(zone_t(1, 4), 1.4);
    map.emplace(zone_t(1, 4), 1.4);
    map.emplace(zone_t(1, 4), 1.4);
    map.emplace(zone_t(2, 2), 2.2);
    map.emplace(zone_t(4, 2), 4.2);
    map.emplace(zone_t(1, 3), 1.3);

    std::multimap<zone_t, double, less_by_pos> sample_map{
        {zone_t(1, 2), 1.2},
        {zone_t(1, 3), 1.3},
        {zone_t(1, 4), 1.4},
        {zone_t(1, 4), 1.4},
        {zone_t(1, 4), 1.4},
        {zone_t(1, 4), 1.4},
        {zone_t(2, 2), 2.2},
        {zone_t(1, 3), 1.3}
    };

    for(auto i = map.intersect_with(zone_t(2, 1)); i != map.end(); ++i)
    {
        tresult.debug() << i->first << ":*:" << i->second << "\n";
        auto fnd = sample_map.find(i->first);
        tresult.assert_true(fnd != sample_map.end() );
        sample_map.erase(fnd);
    }
    tresult.assert_true(sample_map.empty());
}
static auto& module_suite = OP::utest::default_test_suite("SpanContainer")
.declare("add", test_add)
.declare("overlap", overlap_add)
.declare("random", random_stuff_test)
.declare("erase", test_erase)
.declare("map", test_map)
;


text: Copyright © <?php echo date('Y', now()) ?> <?php echo $this->config->item('site_name') ?>. All rights reserved.


text:
package com.harry0000.fit.vo;

public enum SourceType implements ValueObject<Integer> {
    ANT(0),
    ANTPLUS(1),
    BLUETOOTH(2),
    BLUETOOTH_LOW_ENERGY(3),
    WIFI(4),
    LOCAL(5);

    /**
     * @param value
     * @return
     */
    public static SourceType get(final Integer value) {
        return VoUtils.get(SourceType.values(), value);
    }

    private final int value;

    /**
     * @param value
     */
    private SourceType(final int value) {
       this.value = value;
    }

    /* (non-Javadoc)
     * @see com.harry0000.Fit.vo.ValueObject#getValue()
     */
    @Override
    public Integer getValue() {
        return value;
    }

}


text:
class Test {
  void some(SuppressWarnings my) {
    if (my == null) {
      System.out.println("null");
    }
  }
}


text:
package org.apache.ambari.server.cleanup;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.ClassUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.reflect.ClassPath;

/**
 * Utility for looking up classes on the classpath that are potentially subject to be bound by a multibinder.
 */
public class ClasspathScannerUtils {

  private static final Logger LOGGER = LoggerFactory.getLogger(ClasspathScannerUtils.class);

  /**
   * Scans the classpath for classes based on the provided arguments
   *
   * @param packageName the package to be scanned
   * @param exclusions  a list with classes excluded from the result
   * @param selectors   a list with annotation and interface classes that identify classes to be found (lookup criteria)
   * @return a list of classes from the classpath that match the lookup criteria
   */
  public static Set<Class<?>> findOnClassPath(String packageName, List<Class<?>> exclusions,
      List<Class<?>> selectors) {

    Set<Class<?>> bindingSet = new LinkedHashSet<>();
    try {
      ClassPath classpath = ClassPath.from(ClasspathScannerUtils.class.getClassLoader());
      LOGGER.info("Checking package [{}] for binding candidates.", packageName);

      for (ClassPath.ClassInfo classInfo : classpath.getTopLevelClassesRecursive(packageName)) {
        Class<?> candidate = classInfo.load();

        if (exclusions.contains(candidate)) {
          LOGGER.debug("Candidate [{}] is excluded excluded.", candidate);
          continue;
        }

        if (isEligible(candidate, selectors)) {
          LOGGER.debug("Found class [{}]", candidate);
          bindingSet.add(candidate);
        } else {
          LOGGER.debug("Candidate [{}] doesn't match.", candidate);
        }
      }

    } catch (IOException e) {
      LOGGER.error("Failure during configuring JUICE bindings.", e);
      throw new IllegalArgumentException(e);
    }
    return bindingSet;
  }

  /**
   * Checks whether the candidate class matches lookup conditions.
   *
   * @param candidate the type to be checked
   * @return true if the class matches, false otherwise
   */
  private static boolean isEligible(Class<?> candidate, List<Class<?>> selectors) {
    return checkSubClasses(candidate, selectors) || checkAnnotations(candidate, selectors);
  }

  /**
   * Checks if the candidate has annotations listed in the selection criteria
   *
   * @param candidate the type to be checked
   * @return true if the candidate has annotations listed in the selection criteria, false otherwise
   */
  private static boolean checkAnnotations(Class<?> candidate, List<Class<?>> selectors) {
    LOGGER.debug("Checking annotations for: [{}]", candidate);
    boolean ret = false;
    for (Annotation candidateAnn : candidate.getDeclaredAnnotations()) {
      if (selectors.contains(candidateAnn.annotationType())) {
        ret = true;
        break;
      }
    }
    return ret;
  }

  /**
   * Checks if the candidate implements interfaces listed in the selection criteria
   *
   * @param candidate the type to be checked
   * @return true if the candidate implements interfaces listed in the selection criteria, false otherwise
   */
  private static boolean checkSubClasses(Class<?> candidate, List<Class<?>> selectors) {
    boolean ret = false;
    LOGGER.debug("Checking interfaces for: [{}]", candidate);
    List interfaces = ClassUtils.getAllInterfaces(candidate);

    for (Class selectorItf : selectors) {
      if (interfaces.contains(selectorItf)) {
        LOGGER.debug("Checking candidate for subclassing interface: ", selectorItf);
        if (selectorItf.getClass().isAssignableFrom(candidate.getClass())) {
          ret = true;
          break;
        }
      }
    }
    return ret;
  }
}


text:
var riodatamine = require('../lib/riodatamine'),
	appId = 'APP_ID',
	appSecret = 'APP_SECRET';

riodatamine.initialize( appId, appSecret );

riodatamine.request(riodatamine.Services.Agua.HIDROGRAFIA, {}, function(data) {
	console.log(data);
});


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<TITLE
>DROP FUNCTION</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.2.8 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SQL Commands"
HREF="sql-commands.html"><LINK
REL="PREVIOUS"
TITLE="DROP FOREIGN TABLE"
HREF="sql-dropforeigntable.html"><LINK
REL="NEXT"
TITLE="DROP GROUP"
HREF="sql-dropgroup.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2014-03-17T19:46:29">

PostgreSQL 9.2.8 Documentation

Prev	Up		Next

DROP FUNCTION

Name
DROP FUNCTION -- remove a function

Synopsis

DROP FUNCTION [ IF EXISTS ] <TT
CLASS="REPLACEABLE"
>name</TT
> ( [ [ <TT
CLASS="REPLACEABLE"
>argmode</TT
> ] [ <TT
CLASS="REPLACEABLE"
>argname</TT
> ] <TT
CLASS="REPLACEABLE"
>argtype</TT
> [, ...] ] )
    [ CASCADE | RESTRICT ]

Description

   <TT
CLASS="COMMAND"
>DROP FUNCTION</TT
> removes the definition of an existing
   function. To execute this command the user must be the
   owner of the function. The argument types to the
   function must be specified, since several different functions
   can exist with the same name and different argument lists.

Parameters

<TT
CLASS="LITERAL"
>IF EXISTS</TT
>

      Do not throw an error if the function does not exist. A notice is issued
      in this case.

<TT
CLASS="REPLACEABLE"
>name</TT
>

      The name (optionally schema-qualified) of an existing function.

<TT
CLASS="REPLACEABLE"
>argmode</TT
>

      The mode of an argument: <TT
CLASS="LITERAL"
>IN</TT
>, <TT
CLASS="LITERAL"
>OUT</TT
>,
      <TT
CLASS="LITERAL"
>INOUT</TT
>, or <TT
CLASS="LITERAL"
>VARIADIC</TT
>.
      If omitted, the default is <TT
CLASS="LITERAL"
>IN</TT
>.
      Note that <TT
CLASS="COMMAND"
>DROP FUNCTION</TT
> does not actually pay
      any attention to <TT
CLASS="LITERAL"
>OUT</TT
> arguments, since only the input
      arguments are needed to determine the function's identity.
      So it is sufficient to list the <TT
CLASS="LITERAL"
>IN</TT
>, <TT
CLASS="LITERAL"
>INOUT</TT
>,
      and <TT
CLASS="LITERAL"
>VARIADIC</TT
> arguments.

<TT
CLASS="REPLACEABLE"
>argname</TT
>

      The name of an argument.
      Note that <TT
CLASS="COMMAND"
>DROP FUNCTION</TT
> does not actually pay
      any attention to argument names, since only the argument data
      types are needed to determine the function's identity.

<TT
CLASS="REPLACEABLE"
>argtype</TT
>

      The data type(s) of the function's arguments (optionally
      schema-qualified), if any.

<TT
CLASS="LITERAL"
>CASCADE</TT
>

      Automatically drop objects that depend on the function (such as
      operators or triggers).

<TT
CLASS="LITERAL"
>RESTRICT</TT
>

      Refuse to drop the function if any objects depend on it.  This
      is the default.

Examples

   This command removes the square root function:

DROP FUNCTION sqrt(integer);

Compatibility

   A <TT
CLASS="COMMAND"
>DROP FUNCTION</TT
> statement is defined in the SQL
   standard, but it is not compatible with this command.

See Also
CREATE FUNCTION, ALTER FUNCTION

Prev	Home	Next

DROP FOREIGN TABLE	Up	DROP GROUP


text:
The monitoring for one of our applications warned us that the memory is getting low. Please find the application that is low on memory and increase the memory to 1GB.

After you found the application edit the config file for the application and restart it.

_Remember to use **help** at any time to show the available commands_


text:
package org.apache.spark.sql.sources.v2

import scala.collection.JavaConverters._

import org.apache.spark.SparkFunSuite

/**
 * A simple test suite to verify `DataSourceV2Options`.
 */
class DataSourceV2OptionsSuite extends SparkFunSuite {

  test("key is case-insensitive") {
    val options = new DataSourceV2Options(Map("foo" -> "bar").asJava)
    assert(options.get("foo").get() == "bar")
    assert(options.get("FoO").get() == "bar")
    assert(!options.get("abc").isPresent)
  }

  test("value is case-sensitive") {
    val options = new DataSourceV2Options(Map("foo" -> "bAr").asJava)
    assert(options.get("foo").get == "bAr")
  }

  test("getInt") {
    val options = new DataSourceV2Options(Map("numFOo" -> "1", "foo" -> "bar").asJava)
    assert(options.getInt("numFOO", 10) == 1)
    assert(options.getInt("numFOO2", 10) == 10)

    intercept[NumberFormatException]{
      options.getInt("foo", 1)
    }
  }

  test("getBoolean") {
    val options = new DataSourceV2Options(
      Map("isFoo" -> "true", "isFOO2" -> "false", "foo" -> "bar").asJava)
    assert(options.getBoolean("isFoo", false))
    assert(!options.getBoolean("isFoo2", true))
    assert(options.getBoolean("isBar", true))
    assert(!options.getBoolean("isBar", false))
    assert(!options.getBoolean("FOO", true))
  }

  test("getLong") {
    val options = new DataSourceV2Options(Map("numFoo" -> "9223372036854775807",
      "foo" -> "bar").asJava)
    assert(options.getLong("numFOO", 0L) == 9223372036854775807L)
    assert(options.getLong("numFoo2", -1L) == -1L)

    intercept[NumberFormatException]{
      options.getLong("foo", 0L)
    }
  }

  test("getDouble") {
    val options = new DataSourceV2Options(Map("numFoo" -> "922337.1",
      "foo" -> "bar").asJava)
    assert(options.getDouble("numFOO", 0d) == 922337.1d)
    assert(options.getDouble("numFoo2", -1.02d) == -1.02d)

    intercept[NumberFormatException]{
      options.getDouble("foo", 0.1d)
    }
  }
}


text:
package com.netflix.conductor.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.netflix.conductor.common.metadata.events.EventHandler;
import com.netflix.conductor.core.events.EventQueues;

@Service
public class EventServiceImpl implements EventService {

    private final MetadataService metadataService;

    public EventServiceImpl(MetadataService metadataService, EventQueues eventQueues) {
        this.metadataService = metadataService;
    }

    /**
     * Add a new event handler.
     *
     * @param eventHandler Instance of {@link EventHandler}
     */
    public void addEventHandler(EventHandler eventHandler) {
        metadataService.addEventHandler(eventHandler);
    }

    /**
     * Update an existing event handler.
     *
     * @param eventHandler Instance of {@link EventHandler}
     */
    public void updateEventHandler(EventHandler eventHandler) {
        metadataService.updateEventHandler(eventHandler);
    }

    /**
     * Remove an event handler.
     *
     * @param name Event name
     */
    public void removeEventHandlerStatus(String name) {
        metadataService.removeEventHandlerStatus(name);
    }

    /**
     * Get all the event handlers.
     *
     * @return list of {@link EventHandler}
     */
    public List<EventHandler> getEventHandlers() {
        return metadataService.getAllEventHandlers();
    }

    /**
     * Get event handlers for a given event.
     *
     * @param event Event Name
     * @param activeOnly `true|false` for active only events
     * @return list of {@link EventHandler}
     */
    public List<EventHandler> getEventHandlersForEvent(String event, boolean activeOnly) {
        return metadataService.getEventHandlersForEvent(event, activeOnly);
    }
}


text:
using System;
using System.Buffers;
using Orleans.Serialization.Buffers;
using Orleans.Serialization.Cloning;
using Orleans.Serialization.WireProtocol;

namespace Orleans.Serialization.Codecs
{
    /// <summary>
    /// Serializer for <see cref="byte"/> arrays.
    /// </summary>
    [RegisterSerializer]
    public sealed class ByteArrayCodec : TypedCodecBase<byte[], ByteArrayCodec>, IFieldCodec<byte[]>
    {
        /// <summary>
        /// The codec field type
        /// </summary>
        private static readonly Type CodecFieldType = typeof(byte[]);

        /// <inheritdoc/>
        byte[] IFieldCodec<byte[]>.ReadValue<TInput>(ref Reader<TInput> reader, Field field) => ReadValue(ref reader, field);

        /// <summary>
        /// Reads a value.
        /// </summary>
        /// <typeparam name="TInput">The reader input type.</typeparam>
        /// <param name="reader">The reader.</param>
        /// <param name="field">The field.</param>
        /// <returns>The value.</returns>
        public static byte[] ReadValue<TInput>(ref Reader<TInput> reader, Field field)
        {
            if (field.WireType == WireType.Reference)
            {
                return ReferenceCodec.ReadReference<byte[], TInput>(ref reader, field);
            }

            if (field.WireType != WireType.LengthPrefixed)
            {
                ThrowUnsupportedWireTypeException(field);
            }

            var length = reader.ReadVarUInt32();
            var result = reader.ReadBytes(length);
            ReferenceCodec.RecordObject(reader.Session, result);
            return result;
        }

        /// <inheritdoc/>
        void IFieldCodec<byte[]>.WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, byte[] value) => WriteField(ref writer, fieldIdDelta, expectedType, value);

        /// <summary>
        /// Writes a field.
        /// </summary>
        /// <typeparam name="TBufferWriter">The buffer writer type.</typeparam>
        /// <param name="writer">The writer.</param>
        /// <param name="fieldIdDelta">The field identifier delta.</param>
        /// <param name="expectedType">The expected type.</param>
        /// <param name="value">The value.</param>
        public static void WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, byte[] value) where TBufferWriter : IBufferWriter<byte>
        {
            if (ReferenceCodec.TryWriteReferenceField(ref writer, fieldIdDelta, expectedType, value))
            {
                return;
            }

            writer.WriteFieldHeader(fieldIdDelta, expectedType, CodecFieldType, WireType.LengthPrefixed);
            writer.WriteVarUInt32((uint)value.Length);
            writer.Write(value);
        }

        private static void ThrowUnsupportedWireTypeException(Field field) => throw new UnsupportedWireTypeException(
            $"Only a {nameof(WireType)} value of {WireType.LengthPrefixed} is supported for byte[] fields. {field}");
    }

    /// <summary>
    /// Copier for <see cref="byte"/> arrays.
    /// </summary>
    [RegisterCopier]
    public sealed class ByteArrayCopier : IDeepCopier<byte[]>
    {
        /// <inheritdoc/>
        byte[] IDeepCopier<byte[]>.DeepCopy(byte[] input, CopyContext context) => DeepCopy(input, context);

        /// <summary>
        /// Creates a deep copy of the provided input.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="context">The context.</param>
        /// <returns>A copy of <paramref name="input" />.</returns>
        public static byte[] DeepCopy(byte[] input, CopyContext context)
        {
            if (context.TryGetCopy<byte[]>(input, out var result))
            {
                return result;
            }

            result = new byte[input.Length];
            context.RecordCopy(input, result);
            input.CopyTo(result.AsSpan());
            return result;
        }
    }

    /// <summary>
    /// Serializer for <see cref="ReadOnlyMemory{Byte}"/>.
    /// </summary>
    [RegisterSerializer]
    public sealed class ReadOnlyMemoryOfByteCodec : TypedCodecBase<ReadOnlyMemory<byte>, ReadOnlyMemoryOfByteCodec>, IFieldCodec<ReadOnlyMemory<byte>>
    {
        /// <summary>
        /// The codec field type
        /// </summary>
        private static readonly Type CodecFieldType = typeof(ReadOnlyMemory<byte>);

        /// <inheritdoc/>
        ReadOnlyMemory<byte> IFieldCodec<ReadOnlyMemory<byte>>.ReadValue<TInput>(ref Reader<TInput> reader, Field field) => ReadValue(ref reader, field);

        /// <summary>
        /// Reads a value.
        /// </summary>
        /// <typeparam name="TInput">The reader input type.</typeparam>
        /// <param name="reader">The reader.</param>
        /// <param name="field">The field.</param>
        /// <returns>The value.</returns>
        public static byte[] ReadValue<TInput>(ref Reader<TInput> reader, Field field)
        {
            if (field.WireType == WireType.Reference)
            {
                return ReferenceCodec.ReadReference<byte[], TInput>(ref reader, field);
            }

            if (field.WireType != WireType.LengthPrefixed)
            {
                ThrowUnsupportedWireTypeException(field);
            }

            var length = reader.ReadVarUInt32();
            var result = reader.ReadBytes(length);
            ReferenceCodec.RecordObject(reader.Session, result);
            return result;
        }

        /// <inheritdoc/>
        void IFieldCodec<ReadOnlyMemory<byte>>.WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, ReadOnlyMemory<byte> value) => WriteField(ref writer, fieldIdDelta, expectedType, value);

        /// <summary>
        /// Writes a field.
        /// </summary>
        /// <typeparam name="TBufferWriter">The buffer writer type.</typeparam>
        /// <param name="writer">The writer.</param>
        /// <param name="fieldIdDelta">The field identifier delta.</param>
        /// <param name="expectedType">The expected type.</param>
        /// <param name="value">The value.</param>
        public static void WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, ReadOnlyMemory<byte> value) where TBufferWriter : IBufferWriter<byte>
        {
            if (ReferenceCodec.TryWriteReferenceField(ref writer, fieldIdDelta, expectedType, value))
            {
                return;
            }

            writer.WriteFieldHeader(fieldIdDelta, expectedType, CodecFieldType, WireType.LengthPrefixed);
            writer.WriteVarUInt32((uint)value.Length);
            writer.Write(value.Span);
        }

        private static void ThrowUnsupportedWireTypeException(Field field) => throw new UnsupportedWireTypeException(
            $"Only a {nameof(WireType)} value of {WireType.LengthPrefixed} is supported for ReadOnlyMemory<byte> fields. {field}");
    }

    /// <summary>
    /// Copier for <see cref="ReadOnlyMemory{Byte}"/>.
    /// </summary>
    [RegisterCopier]
    public sealed class ReadOnlyMemoryOfByteCopier : IDeepCopier<ReadOnlyMemory<byte>>
    {
        /// <inheritdoc/>
        ReadOnlyMemory<byte> IDeepCopier<ReadOnlyMemory<byte>>.DeepCopy(ReadOnlyMemory<byte> input, CopyContext _) => DeepCopy(input, _);

        /// <summary>
        /// Copies the input.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="copyContext">The copy context.</param>
        /// <returns>A copy of the input.</returns>
        public static ReadOnlyMemory<byte> DeepCopy(ReadOnlyMemory<byte> input, CopyContext copyContext)
        {
            if (input.IsEmpty)
            {
                return default;
            }

            var result = new byte[input.Length];
            input.CopyTo(result.AsMemory());
            return result;
        }
    }

    /// <summary>
    /// Copier for <see cref="ArraySegment{Byte}"/>.
    /// </summary>
    [RegisterCopier]
    public sealed class ArraySegmentOfByteCopier : IDeepCopier<ArraySegment<byte>>
    {
        /// <inheritdoc/>
        ArraySegment<byte> IDeepCopier<ArraySegment<byte>>.DeepCopy(ArraySegment<byte> input, CopyContext _) => DeepCopy(input, _);

        /// <summary>
        /// Copies the input.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="copyContext">The copy context.</param>
        /// <returns>A copy of the input.</returns>
        public static ArraySegment<byte> DeepCopy(ArraySegment<byte> input, CopyContext copyContext)
        {
            if (input.Array is null)
            {
                return default;
            }

            var result = new byte[input.Count];
            input.AsSpan().CopyTo(result.AsSpan());
            return new ArraySegment<byte>(result);
        }
    }

    /// <summary>
    /// Serializer for <see cref="Memory{Byte}"/>.
    /// </summary>
    [RegisterSerializer]
    public sealed class MemoryOfByteCodec : TypedCodecBase<Memory<byte>, MemoryOfByteCodec>, IFieldCodec<Memory<byte>>
    {
        private static readonly Type CodecFieldType = typeof(Memory<byte>);

        /// <inheritdoc/>
        Memory<byte> IFieldCodec<Memory<byte>>.ReadValue<TInput>(ref Reader<TInput> reader, Field field) => ReadValue(ref reader, field);

        /// <summary>
        /// Reads a value.
        /// </summary>
        /// <typeparam name="TInput">The reader input type.</typeparam>
        /// <param name="reader">The reader.</param>
        /// <param name="field">The field.</param>
        /// <returns>The value.</returns>
        public static Memory<byte> ReadValue<TInput>(ref Reader<TInput> reader, Field field)
        {
            if (field.WireType == WireType.Reference)
            {
                return ReferenceCodec.ReadReference<byte[], TInput>(ref reader, field);
            }

            if (field.WireType != WireType.LengthPrefixed)
            {
                ThrowUnsupportedWireTypeException(field);
            }

            var length = reader.ReadVarUInt32();
            var result = reader.ReadBytes(length);
            ReferenceCodec.RecordObject(reader.Session, result);
            return result;
        }

        /// <inheritdoc/>
        void IFieldCodec<Memory<byte>>.WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, Memory<byte> value) => WriteField(ref writer, fieldIdDelta, expectedType, value);

        /// <summary>
        /// Writes a field.
        /// </summary>
        /// <typeparam name="TBufferWriter">The buffer writer type.</typeparam>
        /// <param name="writer">The writer.</param>
        /// <param name="fieldIdDelta">The field identifier delta.</param>
        /// <param name="expectedType">The expected type.</param>
        /// <param name="value">The value.</param>
        public static void WriteField<TBufferWriter>(ref Writer<TBufferWriter> writer, uint fieldIdDelta, Type expectedType, Memory<byte> value) where TBufferWriter : IBufferWriter<byte>
        {
            if (ReferenceCodec.TryWriteReferenceField(ref writer, fieldIdDelta, expectedType, value))
            {
                return;
            }

            writer.WriteFieldHeader(fieldIdDelta, expectedType, CodecFieldType, WireType.LengthPrefixed);
            writer.WriteVarUInt32((uint)value.Length);
            writer.Write(value.Span);
        }

        private static void ThrowUnsupportedWireTypeException(Field field) => throw new UnsupportedWireTypeException(
            $"Only a {nameof(WireType)} value of {WireType.LengthPrefixed} is supported for ReadOnlyMemory<byte> fields. {field}");
    }

    /// <summary>
    /// Copier for <see cref="Memory{T}"/> of <see cref="byte"/>.
    /// </summary>
    [RegisterCopier]
    public sealed class MemoryOfByteCopier : IDeepCopier<Memory<byte>>
    {
        /// <inheritdoc/>
        Memory<byte> IDeepCopier<Memory<byte>>.DeepCopy(Memory<byte> input, CopyContext _) => DeepCopy(input, _);

        /// <summary>
        /// Copies the input.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="copyContext">The copy context.</param>
        /// <returns>A copy of the input.</returns>
        public static Memory<byte> DeepCopy(Memory<byte> input, CopyContext copyContext)
        {
            if (input.IsEmpty)
            {
                return default;
            }

            var result = new byte[input.Length];
            input.CopyTo(result.AsMemory());
            return result;
        }
    }
}


text:
<component name="libraryTable">
  <library name="Maven: org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-api-base:2.0.0-alpha-2">
    <CLASSES>
      <root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-api-base/2.0.0-alpha-2/shrinkwrap-descriptors-api-base-2.0.0-alpha-2.jar!/" />
    </CLASSES>
    <JAVADOC>
      <root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-api-base/2.0.0-alpha-2/shrinkwrap-descriptors-api-base-2.0.0-alpha-2-javadoc.jar!/" />
    </JAVADOC>
    <SOURCES>
      <root url="jar://$MAVEN_REPOSITORY$/org/jboss/shrinkwrap/descriptors/shrinkwrap-descriptors-api-base/2.0.0-alpha-2/shrinkwrap-descriptors-api-base-2.0.0-alpha-2-sources.jar!/" />
    </SOURCES>
  </library>
</component>


text:
xmpp-client fork build instructions
=================

    git clone git@github.com:twstrike/xmpp-client.git
    cd xmpp-client
    direnv allow

    ln -s /YourRepoPathOf/otr3 $GOPATH/src/github.com/twstrike/otr3

run test:

build otr3 if it's changed:

    go install $GOPATH/src/github.com/twstrike/otr3

run all test in xmpp-client:

    go test ./...


text:
'use strict';

var cloneServices = angular.module('cloneServices', ['ngResource']);

cloneServices.factory('cloneService', ['$http', '$location',
    function($http, $location) {

        var appContext = $location.absUrl();
        if (appContext.indexOf("#")) {
            appContext =  appContext.substring(0, appContext.indexOf("#") - 1);
        }

        var listPics = function() {
            var url = appContext + '/api/all-pics';
            return $http.get(url).then(function (response) {
                return response.data;
            });
        };

        var listPicsForUser = function(userName) {
            var url = appContext + '/api/pics/' + userName;
            return $http.get(url).then(function (response) {
                return response.data;
            });
        };

        var savePicture = function(data) {
            var url = appContext + '/api/pic';
            return $http.post(url, data).then(function (response) {
                return response.data;
            });
        };

        var listMyPics = function() {
            var url = appContext + '/api/my-pics';
            return $http.get(url).then(function (response) {
                return response.data;
            });
        };

        var doLogin = function() {
            var url = appContext + '/api/twitter/requestLogin';
            return $http.post(url).then(function (response) {
                return response.data;
            });
        };

        var doLogout = function() {
            var url = appContext + '/api/logout';
            return $http.get(url).then(function (response) {
                return response.data;
            });
        };

        var userDetails = function() {
            var url = appContext + '/api/userDetails';
            return $http.get(url).then(function (response) {
                return response.data;
            });
        };

        var deletePicture = function(picId) {
            var url = appContext + '/api/pic/' + picId;
            return $http.delete(url).then(function (response) {
                return response.data;
            });
        };

        var linkToPicture =  function(picId) {
            var url = appContext + '/api/link-pic/' + picId;
            return $http.post(url).then(function (response) {
                return response.data;
            });
        };

        var unlinkPic = function(picId) {
            var url = appContext + '/api/link-pic/' + picId;
            return $http.delete(url).then(function (response) {
                return response.data;
            });
        };

        return {
            listPics: listPics,
            listPicsForUser: listPicsForUser,
            savePicture: savePicture,
            listMyPics: listMyPics,
            doLogin: doLogin,
            doLogout: doLogout,
            userDetails: userDetails,
            deletePicture: deletePicture,
            linkToPicture: linkToPicture,
            unlinkPic: unlinkPic
        };
    }]);


text:
<?php

namespace PDS\StoryBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use \FPN\TagBundle\Entity\Tagging as BaseTagging;

class Tagging extends BaseTagging
{

}


text:
    <button type="button" class="oppia-close-popover-button protractor-test-exploration-feedback-close-button" ng-click="closePopover()">
      
    </button>

      <textarea ng-model="feedbackText" rows="5" class="protractor-test-exploration-feedback-textarea oppia-feedback-popover-textarea"
                placeholder="<['I18N_PLAYER_LEAVE_FEEDBACK' | translate]>" focus-on="<[feedbackPopoverId]>">
      </textarea>

    <md-button class="float-right oppia-exploration-feedback-submit-btn protractor-test-exploration-feedback-submit-btn"
               ng-class="{'oppia-feedback-popover-submit-btn-enabled': feedbackText}"
               ng-click="saveFeedback()"
               ng-disabled="!feedbackText"
               translate="I18N_PLAYER_SUBMIT_BUTTON">
    </md-button>

        <input type="checkbox" ng-model="isSubmitterAnonymized">


text:
<?php

use index0h\phar\components\php\Fixer;
use index0h\phar\components\php\Minimize;

/**
 * Check index0h\phar\components\php\***.
 *
 * @author Roman Levishchenko <index.0h@gmail.com>
 */
class ComponentsCests
{
    public function testPHPFixer(\CodeGuy $I)
    {
        $file = $I->processFileEventByComponent(new Fixer(), ['include', 'realpath.php']);
        $I->seeFixedFile($file);
        $I->removeTemporaryFile($file);
    }

    public function testPHPMinimize(\CodeGuy $I)
    {
        $file = $I->processFileEventByComponent(new Minimize(), ['include', 'realpath.php']);
        $I->seeMinimizedFile($file, ['include', 'realpath.php']);
        $I->removeTemporaryFile($file);
    }

    public function testFileHelper(\CodeGuy $I)
    {
        $I->seeRightPathConvert();
    }
}


text:
package org.wallride.web.controller.admin.page;

import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.wallride.core.domain.Page;
import org.wallride.core.service.PageService;
import org.wallride.web.support.DomainObjectDescribeController;

import javax.inject.Inject;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping(value="/{language}/pages/describe", method=RequestMethod.GET)
public class PageDescribeController extends DomainObjectDescribeController<Page, PageSearchForm> {

	@Inject
	private PageService pageService;

	@RequestMapping
	public String describe(
			@RequestParam long id,
			Model model,
			HttpSession session) {
		return super.requestMappingDescribe(id, null, model, session);
	}

	@RequestMapping(params = "pageable")
	public String describe(
			@RequestParam long id,
			@PageableDefault(50) Pageable pageable,
			Model model,
			HttpSession session) {
		return super.requestMappingDescribe(id, pageable, model, session);
	}

	@RequestMapping(params="part=delete-form")
	public String partDeleteDialog(
			@PathVariable String language,
			@RequestParam long id, Model model) {
		Page page = pageService.readPageById(id, language);
		model.addAttribute("page", page);
		return "page/describe::delete-form";
	}

	@Override
	protected Class<PageSearchForm> getDomainObjectSearchFormClass() {
		return PageSearchForm.class;
	}

	@Override
	protected String getModelAttributeName() {
		return "page";
	}

	@Override
	protected String getViewName() {
		return "page/describe";
	}

	@Override
	protected Page readDomainObject(long id) {
		return pageService.readPageById(id, LocaleContextHolder.getLocale().getLanguage());
	}

	@Override
	protected org.springframework.data.domain.Page<Page> readDomainObjects(PageSearchForm form, Pageable pageable) {
		return pageService.readPages(form.toPageSearchRequest(), pageable);
	}
}


text:
#import <UIKit/UIKit.h>
#import "GtmSenTestCase.h"
#import "WFXMLDocument.h"
#import "WFXMLElement.h"

@interface TestXMLDocument : GTMTestCase {
}
@end

@implementation TestXMLDocument

- (void)testInitialization
{
    WFXMLDocument *doc = [[WFXMLDocument alloc] init];
    STAssertNotNULL(doc, @"Could not create document");
    [doc release];
}

- (void)testAttributes
{
    WFXMLDocument *doc = [[WFXMLDocument alloc] init];

    STAssertEqualStrings(doc.version, @"1.0", @"");
    STAssertTrue(doc.encoding == NSUTF8StringEncoding, @"");
    STAssertEqualStrings(doc.docType, @"isab-mc2", @"");
    [doc release];
}

- (void)testEmptyDocument
{
    WFXMLDocument *doc = [[WFXMLDocument alloc] init];
    NSMutableString *testString = [NSMutableString stringWithCapacity:64];
    [testString appendString:@"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"];
    [testString appendString:@"<!DOCTYPE isab-mc2>\n"];

    STAssertEqualStrings([doc XMLString], testString, @"was '%@'",
                         [doc XMLString]);

    [doc release];
}

- (void)testDocument
{
    WFXMLDocument *doc = [[WFXMLDocument alloc] init];
    WFXMLElement *elem = [WFXMLElement elementWithName:@"element"];
    [elem addChild:[WFXMLElement elementWithName:@"element2"]];

    doc.rootElement = elem;

    NSMutableString *testString = [NSMutableString stringWithCapacity:64];
    [testString appendString:@"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"];
    [testString appendString:@"<!DOCTYPE isab-mc2>\n"];
    [testString appendString:@"<element><element2/></element>"];

    STAssertEqualStrings([doc XMLString], testString, @"was '%@'",
                         [doc XMLString]);

    [doc release];
}

- (void)testFindingElement
{
}

@end


text:
package org.jclouds.openstack.neutron.v2.domain.lbaas.v1;

import java.beans.ConstructorProperties;

import org.jclouds.openstack.v2_0.domain.Link;
import org.jclouds.openstack.v2_0.domain.PaginatedCollection;

import com.google.common.collect.ImmutableSet;

/**
 * A collection of of Neutron LBaaS v1 VIPs.
 */
public class VIPs extends PaginatedCollection<VIP> {
   public static final VIPs EMPTY = new VIPs(ImmutableSet.<VIP> of(), ImmutableSet.<Link> of());

   @ConstructorProperties({ "vips", "vips_links" })
   protected VIPs(Iterable<VIP> vips, Iterable<Link> vipsLinks) {
      super(vips, vipsLinks);
   }
}


text:
<!DOCTYPE html><html><head><meta charset="utf-8" />
<meta http-equiv="refresh" content="0;url=/place/ecuador/timetables/" />
</head></html>


text:
namespace Chocolatey.DomainModel
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;

    public class ChocolateyPackage
    {
        public ChocolateyPackage()
        {
            this.Versions = new ObservableCollection<ChocolateyPackageVersion>();
        }

        public string Id { get; set; }

        public string Title { get; set; }

        public Uri IconLink { get; set; }

        public bool IsInstalled { get; set; }

        public ObservableCollection<ChocolateyPackageVersion> Versions { get; set; }

        public ChocolateyPackageVersion LatestVersion
        {
            get
            {
                return this.Versions.OrderByDescending(pv => pv.Version).First();
            }
        }
    }
}


text:
/*
Some random cgi routines. Used in the LED example and the page that returns the entire
flash as a binary. Also handles the hit counter on the main page.
*/

/*
 * ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * Jeroen Domburg <jeroen@spritesmods.com> wrote this file. As long as you retain
 * this notice you can do whatever you want with this stuff. If we meet some day,
 * and you think this stuff is worth it, you can buy me a beer in return.
 * ----------------------------------------------------------------------------
 */

#include <string.h>
#include <osapi.h>
#include "user_interface.h"
#include "mem.h"
#include "httpd.h"
#include "cgi.h"
#include "io.h"
#include <ip_addr.h>
#include "espmissingincludes.h"

//cause I can't be bothered to write an ioGetLed()
static char currLedState=0;

//Cgi that turns the LED on or off according to the 'led' param in the POST data
int ICACHE_FLASH_ATTR cgiLed(HttpdConnData *connData) {
	int len;
	char buff[1024];

	if (connData->conn==NULL) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}

	len=httpdFindArg(connData->postBuff, "led", buff, sizeof(buff));
	if (len!=0) {
		currLedState=atoi(buff);
		ioLed(currLedState);
	}

	httpdRedirect(connData, "led.tpl");
	return HTTPD_CGI_DONE;
}

//Template code for the led page.
void ICACHE_FLASH_ATTR tplLed(HttpdConnData *connData, char *token, void **arg) {
	char buff[128];
	if (token==NULL) return;

	os_strcpy(buff, "Unknown");
	if (os_strcmp(token, "ledstate")==0) {
		if (currLedState) {
			os_strcpy(buff, "on");
		} else {
			os_strcpy(buff, "off");
		}
	}
	httpdSend(connData, buff, -1);
}

static long hitCounter=0;

void ICACHE_FLASH_ATTR tplSetupPage(HttpdConnData *connData, char *token, void **arg) {
	//Taken from tplWlan in cgiwifi.c
	char buff[1024];
	int x;
	static struct station_config stconf;
	if (token==NULL) return;
	wifi_station_get_config(&stconf);

	os_strcpy(buff, "Unknown");
	if (os_strcmp(token, "WiFiMode")==0) {
		x=wifi_get_opmode();
		if (x==1) os_strcpy(buff, "Client");
		if (x==2) os_strcpy(buff, "SoftAP");
		if (x==3) os_strcpy(buff, "STA+AP");
	} else if (os_strcmp(token, "currSsid")==0) {
		os_strcpy(buff, (char*)stconf.ssid);
	} else if (os_strcmp(token, "WiFiPasswd")==0) {
		os_strcpy(buff, (char*)stconf.password);
	} else if (os_strcmp(token, "WiFiapwarn")==0) {
		x=wifi_get_opmode();
		if (x==2) {
			os_strcpy(buff, "Can't scan in this mode. Click here to go to STA+AP mode.");
		} else {
			os_strcpy(buff, "Click here to go to standalone AP mode.");
		}
	//Taken from tplCounter below
	} else if (os_strcmp(token, "counter")==0) {
		hitCounter++;
		os_sprintf(buff, "%ld", hitCounter);
	}
	httpdSend(connData, buff, -1);
}

//Template code for the counter on the index page.
void ICACHE_FLASH_ATTR tplCounter(HttpdConnData *connData, char *token, void **arg) {
	char buff[128];
	if (token==NULL) return;

	if (os_strcmp(token, "counter")==0) {
		hitCounter++;
		os_sprintf(buff, "%ld", hitCounter);
	}
	httpdSend(connData, buff, -1);
}

//Cgi that reads the SPI flash. Assumes 512KByte flash.
int ICACHE_FLASH_ATTR cgiReadFlash(HttpdConnData *connData) {
	int *pos=(int *)&connData->cgiData;
	if (connData->conn==NULL) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}

	if (*pos==0) {
		os_printf("Start flash download.\n");
		httpdStartResponse(connData, 200);
		httpdHeader(connData, "Content-Type", "application/bin");
		httpdEndHeaders(connData);
		*pos=0x40200000;
		return HTTPD_CGI_MORE;
	}
	//Send 1K of flash per call. We will get called again if we haven't sent 512K yet.
	espconn_sent(connData->conn, (uint8 *)(*pos), 1024);
	*pos+=1024;
	if (*pos>=0x40200000+(512*1024)) return HTTPD_CGI_DONE; else return HTTPD_CGI_MORE;
}


text:
#region Apache License Version 2.0

#endregion Apache License Version 2.0

using SF.Sys.Annotations;
using SF.Sys.Entities;
using SF.Sys.Entities.Annotations;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace SF.Common.FrontEndContents
{
	public interface IContentItem
	{
		string Image { get; }
		string Icon { get; }
		string FontIcon { get; }
		string Uri { get; }
		string UriTarget { get; }
		string Title1 { get; }
		string Title2 { get; }
		string Title3 { get; }
		string Summary { get; }
		ContentItem[] Items { get; }
	}
	public interface IContent : IContentItem
	{
		long Id { get; }
		string Name { get; }
		string Category { get; }
		string ProviderType { get; }
		string ProviderConfig { get; }
		bool Disabled { get; }

	}
	public class ContentItem : IContentItem
	{
		/// <summary>
		/// 大图
		/// </summary>
		[Layout(10,1)]
		[Image]
		public string Image { get; set; }

		/// <summary>
		/// 图标
		/// </summary>
		[Layout(10, 2)]
		[Image]
		public string Icon { get; set; }

		/// <summary>
		/// 字体图标类
		/// </summary>
		[StringLength(50)]
		[Layout(10, 3)]
		public string FontIcon { get; set; }

		/// <summary>
		/// 主标题
		/// </summary>
		[TableVisible(10)]
		[StringLength(100)]
		public string Title1 { get; set; }

		/// <summary>
		/// 次标题1
		/// </summary>
		[StringLength(100)]
		[Layout(20, 1)]
		public string Title2 { get; set; }

		/// <summary>
		/// 次标题2
		/// </summary>
		[StringLength(100)]
		[Layout(20,2)]
		public string Title3 { get; set; }

		/// <summary>
		/// 摘要
		/// </summary>
		[StringLength(200)]
		public string Summary { get; set; }

		/// <summary>
		/// 链接
		/// </summary>
		[TableVisible]
		[StringLength(200)]
		public string Uri { get; set; }

		/// <summary>
		/// 链接目标
		/// </summary>
		[StringLength(50)]
		public string UriTarget { get; set; }

		/// <summary>
		/// 子项目
		/// </summary>
		[TreeNodes]
		public ContentItem[] Items { get; set; }
	}
	/// <summary>
	/// 站点内容
	/// </summary>
    [EntityObject]
    public class Content:ContentItem, IContent,IEntityWithId<long>
	{
		/// <summary>
		/// ID
		/// </summary>
		/// <prompt>保存后自动产生</prompt>
		[Key]
		[ReadOnly(true)]
		[Layout(1)]
		[TableVisible(1)]
		public long Id { get; set; }

		/// <summary>
		/// 内容分类
		/// </summary>
		[StringLength(50)]
		[TableVisible]
		[Required]
		public string Category { get; set; }

		/// <summary>
		/// 内容名称
		/// </summary>
		[StringLength(50)]
		[TableVisible]
		[Required]
		public string Name { get; set; }

		/// <summary>
		/// 提供者类型
		/// </summary>
		[StringLength(50)]
		[TableVisible]
		[Layout(3)]
		public string ProviderType { get; set; }

		/// <summary>
		/// 提供者配置
		/// </summary>
		[StringLength(100)]
		[Layout(4)]
		public string ProviderConfig { get; set; }

		/// <summary>
		/// 是否禁用
		/// </summary>
		[TableVisible]
		public bool Disabled { get; set; }

    }
}


text:
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<title> Przyszłość. </title>

 Przyszłosc będzie.... wkrótce.


text:
<?php

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;

/**
 * Defines application features from the specific context.
 */
class ScrapeBBCContext implements Context, SnippetAcceptingContext
{
	/**
	 * Initializes context.
	 *
	 * Every scenario gets its own context instance.
	 * You can also pass arbitrary arguments to the
	 * context constructor through behat.yml.
	 */
	public function __construct()
	{
	}

	/** @Given /^I am in a directory "([^"]*)"$/ */
	public function iAmInADirectory($dir)
	{
		chdir($dir);
	}

	/**
	 * @When /^I run "([^"]*)" command$/
	 */
	public function iRunCommand($command)
	{
		exec($command, $output);
		$this->output = trim(implode("\n", $output));
	}

	/**
	 * @Given /^the response is JSON$/
	 */
	public function theResponseIsJson()
	{
		$data = json_decode($this->output);

		if (empty($data)) {
			throw new Exception("Response was not JSON\n" . $this->output);
		}
	}

	/**
	 * @Given /^the first element contains the keys "([^"]*)"$/
	 */
	public function theArrayHasRequiredKeys($requiredKeys)
	{
		$results = json_decode($this->output, true);
		foreach(explode(',', $requiredKeys) as $key) {
			if (!array_key_exists($key, $results['results'][0])) {
				throw new Exception(sprintf('The key %s is missing from the output', $key));
			}
		}
	}
}


text:
"""
Copyright 2015 Cisco Systems

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.
"""

from functionaltests.api.v1.behaviors import base_behaviors
from functionaltests.api.v1.models import acl_models

class AclBehaviors(base_behaviors.BaseBehaviors):

    def create_acl(self, entity_ref, model, extra_headers=None,
                   user_name=None):
        """Create an acl from the data in the model.

        :param entity_ref: ref of secret or container for acl
        :param model: The metadata used to create the acl
        :param extra_headers: Headers used to create the acl
        :param user_name: The user name used to create the acl
        :return: the response from the PUT request
        """

        acl_ref = '{0}/acl'.format(entity_ref)
        resp = self.client.put(acl_ref, request_model=model,
                               extra_headers=extra_headers,
                               user_name=user_name)

        self.created_entities.append((acl_ref, user_name))
        return resp

    def get_acl(self, acl_ref, extra_headers=None, user_name=None):
        """Handles getting a single acl

        :param acl_ref: Reference to the acl to be retrieved
        :param extra_headers: Headers used to get the acl
        :param user_name: The user name used to get the acl

        :return: The response of the GET.
        """
        resp = self.client.get(
            acl_ref, response_model_type=acl_models.AclModel,
            user_name=user_name)

        return resp

    def update_acl(self, acl_ref, model, extra_headers=None,
                   use_auth=True, user_name=None):
        """Update an acl from the data in the model.

        :param acl_ref: Reference of the acl to be updated
        :param model: The metadata used to update the acl
        :param extra_headers: Headers used to update the acl
        :param use_auth: Boolean for whether to send authentication headers
        :param user_name: The user name used to update the acl

        :return: the response from the PATCH request
        """
        resp = self.client.patch(
            acl_ref, request_model=model, extra_headers=extra_headers,
            response_model_type=acl_models.AclModel,
            use_auth=use_auth, user_name=user_name)

        return resp

    def delete_acl(self, acl_ref, extra_headers=None,
                   expected_fail=False, user_name=None):
        """Handles deleting an acl.

        :param acl_ref: Reference of the acl to be deleted
        :param extra_headers: Any additional headers needed.
        :param expected_fail: If there is a negative test, this should be
            marked true if you are trying to delete an acl that does
            not exist.
        :param user_name: The user name used to delete the acl

        :return: Response of the delete.
        """
        resp = self.client.delete(acl_ref, extra_headers, user_name=user_name)

        if not expected_fail:
            for item in self.created_entities:
                if item[0] == acl_ref:
                    self.created_entities.remove(item)

        return resp

    def delete_all_created_acls(self):
        """Delete all of the acls that we have created."""
        entities = list(self.created_entities)
        for (acl_ref, user_name) in entities:
            self.delete_acl(acl_ref, user_name=user_name)