text:
/*************************************************************************/
/*  texture_progress_bar.cpp                                             */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                      https://godotengine.org                          */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur.                 */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md).   */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/

#include "texture_progress_bar.h"

#include "core/config/engine.h"

void TextureProgressBar::set_under_texture(const Ref<Texture2D> &p_texture) {
	if (under == p_texture) {
		return;
	}

	under = p_texture;
	update();
	update_minimum_size();
}

Ref<Texture2D> TextureProgressBar::get_under_texture() const {
	return under;
}

void TextureProgressBar::set_over_texture(const Ref<Texture2D> &p_texture) {
	if (over == p_texture) {
		return;
	}

	over = p_texture;
	update();
	if (under.is_null()) {
		update_minimum_size();
	}
}

Ref<Texture2D> TextureProgressBar::get_over_texture() const {
	return over;
}

void TextureProgressBar::set_stretch_margin(Side p_side, int p_size) {
	ERR_FAIL_INDEX((int)p_side, 4);

	if (stretch_margin[p_side] == p_size) {
		return;
	}

	stretch_margin[p_side] = p_size;
	update();
	update_minimum_size();
}

int TextureProgressBar::get_stretch_margin(Side p_side) const {
	ERR_FAIL_INDEX_V((int)p_side, 4, 0);
	return stretch_margin[p_side];
}

void TextureProgressBar::set_nine_patch_stretch(bool p_stretch) {
	if (nine_patch_stretch == p_stretch) {
		return;
	}

	nine_patch_stretch = p_stretch;
	update();
	update_minimum_size();
}

bool TextureProgressBar::get_nine_patch_stretch() const {
	return nine_patch_stretch;
}

Size2 TextureProgressBar::get_minimum_size() const {
	if (nine_patch_stretch) {
		return Size2(stretch_margin[SIDE_LEFT] + stretch_margin[SIDE_RIGHT], stretch_margin[SIDE_TOP] + stretch_margin[SIDE_BOTTOM]);
	} else if (under.is_valid()) {
		return under->get_size();
	} else if (over.is_valid()) {
		return over->get_size();
	} else if (progress.is_valid()) {
		return progress->get_size();
	}

	return Size2(1, 1);
}

void TextureProgressBar::set_progress_texture(const Ref<Texture2D> &p_texture) {
	if (progress == p_texture) {
		return;
	}

	progress = p_texture;
	update();
	update_minimum_size();
}

Ref<Texture2D> TextureProgressBar::get_progress_texture() const {
	return progress;
}

void TextureProgressBar::set_progress_offset(Point2 p_offset) {
	if (progress_offset == p_offset) {
		return;
	}

	progress_offset = p_offset;
	update();
}

Point2 TextureProgressBar::get_progress_offset() const {
	return progress_offset;
}

void TextureProgressBar::set_tint_under(const Color &p_tint) {
	if (tint_under == p_tint) {
		return;
	}

	tint_under = p_tint;
	update();
}

Color TextureProgressBar::get_tint_under() const {
	return tint_under;
}

void TextureProgressBar::set_tint_progress(const Color &p_tint) {
	if (tint_progress == p_tint) {
		return;
	}

	tint_progress = p_tint;
	update();
}

Color TextureProgressBar::get_tint_progress() const {
	return tint_progress;
}

void TextureProgressBar::set_tint_over(const Color &p_tint) {
	if (tint_over == p_tint) {
		return;
	}

	tint_over = p_tint;
	update();
}

Color TextureProgressBar::get_tint_over() const {
	return tint_over;
}

Point2 TextureProgressBar::unit_val_to_uv(float val) {
	if (progress.is_null()) {
		return Point2();
	}

	if (val < 0) {
		val += 1;
	}
	if (val > 1) {
		val -= 1;
	}

	Point2 p = get_relative_center();

	// Minimal version of Liang-Barsky clipping algorithm
	float angle = (val * Math_TAU) - Math_PI * 0.5;
	Point2 dir = Vector2(Math::cos(angle), Math::sin(angle));
	float t1 = 1.0;
	float cp = 0.0;
	float cq = 0.0;
	float cr = 0.0;
	float edgeLeft = 0.0;
	float edgeRight = 1.0;
	float edgeBottom = 0.0;
	float edgeTop = 1.0;

	for (int edge = 0; edge < 4; edge++) {
		if (edge == 0) {
			if (dir.x > 0) {
				continue;
			}
			cq = -(edgeLeft - p.x);
			dir.x *= 2.0 * cq;
			cp = -dir.x;
		} else if (edge == 1) {
			if (dir.x < 0) {
				continue;
			}
			cq = (edgeRight - p.x);
			dir.x *= 2.0 * cq;
			cp = dir.x;
		} else if (edge == 2) {
			if (dir.y > 0) {
				continue;
			}
			cq = -(edgeBottom - p.y);
			dir.y *= 2.0 * cq;
			cp = -dir.y;
		} else if (edge == 3) {
			if (dir.y < 0) {
				continue;
			}
			cq = (edgeTop - p.y);
			dir.y *= 2.0 * cq;
			cp = dir.y;
		}
		cr = cq / cp;
		if (cr >= 0 && cr < t1) {
			t1 = cr;
		}
	}
	return (p + t1 * dir);
}

Point2 TextureProgressBar::get_relative_center() {
	if (progress.is_null()) {
		return Point2();
	}
	Point2 p = progress->get_size() / 2;
	p += rad_center_off;
	p.x /= progress->get_width();
	p.y /= progress->get_height();
	p.x = CLAMP(p.x, 0, 1);
	p.y = CLAMP(p.y, 0, 1);
	return p;
}

void TextureProgressBar::draw_nine_patch_stretched(const Ref<Texture2D> &p_texture, FillMode p_mode, double p_ratio, const Color &p_modulate) {
	Vector2 texture_size = p_texture->get_size();
	Vector2 topleft = Vector2(stretch_margin[SIDE_LEFT], stretch_margin[SIDE_TOP]);
	Vector2 bottomright = Vector2(stretch_margin[SIDE_RIGHT], stretch_margin[SIDE_BOTTOM]);

	Rect2 src_rect = Rect2(Point2(), texture_size);
	Rect2 dst_rect = Rect2(Point2(), get_size());

	if (p_ratio < 1.0) {
		// Drawing a partially-filled 9-patch is a little tricky -
		// texture is divided by 3 sections toward fill direction,
		// then middle section is stretching while the other two aren't.

		double width_total = 0.0;
		double width_texture = 0.0;
		double first_section_size = 0.0;
		double last_section_size = 0.0;
		switch (p_mode) {
			case FILL_LEFT_TO_RIGHT: {
				width_total = dst_rect.size.x;
				width_texture = texture_size.x;
				first_section_size = topleft.x;
				last_section_size = bottomright.x;
			} break;
			case FILL_RIGHT_TO_LEFT: {
				width_total = dst_rect.size.x;
				width_texture = texture_size.x;
				// In contrast to `FILL_LEFT_TO_RIGHT`, `first_section_size` and `last_section_size` should switch value.
				first_section_size = bottomright.x;
				last_section_size = topleft.x;
			} break;
			case FILL_TOP_TO_BOTTOM: {
				width_total = dst_rect.size.y;
				width_texture = texture_size.y;
				first_section_size = topleft.y;
				last_section_size = bottomright.y;
			} break;
			case FILL_BOTTOM_TO_TOP: {
				width_total = dst_rect.size.y;
				width_texture = texture_size.y;
				// Similar to `FILL_RIGHT_TO_LEFT`.
				first_section_size = bottomright.y;
				last_section_size = topleft.y;
			} break;
			case FILL_BILINEAR_LEFT_AND_RIGHT: {
				width_total = dst_rect.size.x;
				width_texture = texture_size.x;
				first_section_size = topleft.x;
				last_section_size = bottomright.x;
			} break;
			case FILL_BILINEAR_TOP_AND_BOTTOM: {
				width_total = dst_rect.size.y;
				width_texture = texture_size.y;
				first_section_size = topleft.y;
				last_section_size = bottomright.y;
			} break;
			case FILL_CLOCKWISE:
			case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
			case FILL_COUNTER_CLOCKWISE: {
				// Those modes are circular, not relevant for nine patch.
			} break;
			case FILL_MODE_MAX:
				break;
		}

		double width_filled = width_total * p_ratio;
		double middle_section_size = MAX(0.0, width_texture - first_section_size - last_section_size);

		// Maximum middle texture size.
		double max_middle_texture_size = middle_section_size;

		// Maximum real middle texture size.
		double max_middle_real_size = MAX(0.0, width_total - (first_section_size + last_section_size));

		switch (p_mode) {
			case FILL_BILINEAR_LEFT_AND_RIGHT:
			case FILL_BILINEAR_TOP_AND_BOTTOM: {
				last_section_size = MAX(0.0, last_section_size - (width_total - width_filled) * 0.5);
				first_section_size = MAX(0.0, first_section_size - (width_total - width_filled) * 0.5);

				// When `width_filled` increases, `middle_section_size` only increases when either of `first_section_size` and `last_section_size` is zero.
				// Also, it should always be smaller than or equal to `(width_total - (first_section_size + last_section_size))`.
				double real_middle_size = width_filled - first_section_size - last_section_size;
				middle_section_size *= MIN(max_middle_real_size, real_middle_size) / max_middle_real_size;

				width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
			} break;
			case FILL_MODE_MAX:
				break;
			default: {
				middle_section_size *= MIN(1.0, (MAX(0.0, width_filled - first_section_size) / MAX(1.0, width_total - first_section_size - last_section_size)));
				last_section_size = MAX(0.0, last_section_size - (width_total - width_filled));
				first_section_size = MIN(first_section_size, width_filled);
				width_texture = MIN(width_texture, first_section_size + middle_section_size + last_section_size);
			}
		}

		switch (p_mode) {
			case FILL_LEFT_TO_RIGHT: {
				src_rect.size.x = width_texture;
				dst_rect.size.x = width_filled;
				topleft.x = first_section_size;
				bottomright.x = last_section_size;
			} break;
			case FILL_RIGHT_TO_LEFT: {
				src_rect.position.x += src_rect.size.x - width_texture;
				src_rect.size.x = width_texture;
				dst_rect.position.x += width_total - width_filled;
				dst_rect.size.x = width_filled;
				topleft.x = last_section_size;
				bottomright.x = first_section_size;
			} break;
			case FILL_TOP_TO_BOTTOM: {
				src_rect.size.y = width_texture;
				dst_rect.size.y = width_filled;
				bottomright.y = last_section_size;
				topleft.y = first_section_size;
			} break;
			case FILL_BOTTOM_TO_TOP: {
				src_rect.position.y += src_rect.size.y - width_texture;
				src_rect.size.y = width_texture;
				dst_rect.position.y += width_total - width_filled;
				dst_rect.size.y = width_filled;
				topleft.y = last_section_size;
				bottomright.y = first_section_size;
			} break;
			case FILL_BILINEAR_LEFT_AND_RIGHT: {
				double center_mapped_from_real_width = (width_total * 0.5 - topleft.x) / max_middle_real_size * max_middle_texture_size + topleft.x;
				double drift_from_unscaled_center = 0;
				if (bottomright.y != topleft.y) { // To avoid division by zero.
					drift_from_unscaled_center = (src_rect.size.x * 0.5 - center_mapped_from_real_width) * (last_section_size - first_section_size) / (bottomright.x - topleft.x);
				}

				src_rect.position.x += center_mapped_from_real_width + drift_from_unscaled_center - width_texture * 0.5;
				src_rect.size.x = width_texture;
				dst_rect.position.x += (width_total - width_filled) * 0.5;
				dst_rect.size.x = width_filled;
				topleft.x = first_section_size;
				bottomright.x = last_section_size;
			} break;
			case FILL_BILINEAR_TOP_AND_BOTTOM: {
				double center_mapped_from_real_width = (width_total * 0.5 - topleft.y) / max_middle_real_size * max_middle_texture_size + topleft.y;
				double drift_from_unscaled_center = 0;
				if (bottomright.y != topleft.y) { // To avoid division by zero.
					drift_from_unscaled_center = (src_rect.size.y * 0.5 - center_mapped_from_real_width) * (last_section_size - first_section_size) / (bottomright.y - topleft.y);
				}

				src_rect.position.y += center_mapped_from_real_width + drift_from_unscaled_center - width_texture * 0.5;
				src_rect.size.y = width_texture;
				dst_rect.position.y += (width_total - width_filled) * 0.5;
				dst_rect.size.y = width_filled;
				topleft.y = first_section_size;
				bottomright.y = last_section_size;
			} break;
			case FILL_CLOCKWISE:
			case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE:
			case FILL_COUNTER_CLOCKWISE: {
				// Those modes are circular, not relevant for nine patch.
			} break;
			case FILL_MODE_MAX:
				break;
		}
	}

	if (p_texture == progress) {
		dst_rect.position += progress_offset;
	}
	p_texture->get_rect_region(dst_rect, src_rect, dst_rect, src_rect);

	RID ci = get_canvas_item();
	RS::get_singleton()->canvas_item_add_nine_patch(ci, dst_rect, src_rect, p_texture->get_rid(), topleft, bottomright, RS::NINE_PATCH_STRETCH, RS::NINE_PATCH_STRETCH, true, p_modulate);
}

void TextureProgressBar::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_DRAW: {
			if (nine_patch_stretch && (mode == FILL_LEFT_TO_RIGHT || mode == FILL_RIGHT_TO_LEFT || mode == FILL_TOP_TO_BOTTOM || mode == FILL_BOTTOM_TO_TOP || mode == FILL_BILINEAR_LEFT_AND_RIGHT || mode == FILL_BILINEAR_TOP_AND_BOTTOM)) {
				if (under.is_valid()) {
					draw_nine_patch_stretched(under, mode, 1.0, tint_under);
				}
				if (progress.is_valid()) {
					draw_nine_patch_stretched(progress, mode, get_as_ratio(), tint_progress);
				}
				if (over.is_valid()) {
					draw_nine_patch_stretched(over, mode, 1.0, tint_over);
				}
			} else {
				if (under.is_valid()) {
					switch (mode) {
						case FILL_CLOCKWISE:
						case FILL_COUNTER_CLOCKWISE:
						case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
							if (nine_patch_stretch) {
								Rect2 region = Rect2(Point2(), get_size());
								draw_texture_rect(under, region, false, tint_under);
							} else {
								draw_texture(under, Point2(), tint_under);
							}
						} break;
						case FILL_MODE_MAX:
							break;
						default:
							draw_texture(under, Point2(), tint_under);
					}
				}
				if (progress.is_valid()) {
					Size2 s = progress->get_size();
					switch (mode) {
						case FILL_LEFT_TO_RIGHT: {
							Rect2 region = Rect2(progress_offset, Size2(s.x * get_as_ratio(), s.y));
							Rect2 source = Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y));
							draw_texture_rect_region(progress, region, source, tint_progress);
						} break;
						case FILL_RIGHT_TO_LEFT: {
							Rect2 region = Rect2(progress_offset + Point2(s.x - s.x * get_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y));
							Rect2 source = Rect2(Point2(s.x - s.x * get_as_ratio(), 0), Size2(s.x * get_as_ratio(), s.y));
							draw_texture_rect_region(progress, region, source, tint_progress);
						} break;
						case FILL_TOP_TO_BOTTOM: {
							Rect2 region = Rect2(progress_offset + Point2(), Size2(s.x, s.y * get_as_ratio()));
							Rect2 source = Rect2(Point2(), Size2(s.x, s.y * get_as_ratio()));
							draw_texture_rect_region(progress, region, source, tint_progress);
						} break;
						case FILL_BOTTOM_TO_TOP: {
							Rect2 region = Rect2(progress_offset + Point2(0, s.y - s.y * get_as_ratio()), Size2(s.x, s.y * get_as_ratio()));
							Rect2 source = Rect2(Point2(0, s.y - s.y * get_as_ratio()), Size2(s.x, s.y * get_as_ratio()));
							draw_texture_rect_region(progress, region, source, tint_progress);
						} break;
						case FILL_CLOCKWISE:
						case FILL_COUNTER_CLOCKWISE:
						case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
							if (nine_patch_stretch) {
								s = get_size();
							}

							float val = get_as_ratio() * rad_max_degrees / 360;
							if (val == 1) {
								Rect2 region = Rect2(progress_offset, s);
								Rect2 source = Rect2(Point2(), progress->get_size());
								draw_texture_rect_region(progress, region, source, tint_progress);
							} else if (val != 0) {
								Array pts;
								float direction = mode == FILL_COUNTER_CLOCKWISE ? -1 : 1;
								float start;

								if (mode == FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE) {
									start = rad_init_angle / 360 - val / 2;
								} else {
									start = rad_init_angle / 360;
								}

								float end = start + direction * val;
								float from = MIN(start, end);
								float to = MAX(start, end);
								pts.append(from);
								for (float corner = Math::floor(from * 4 + 0.5) * 0.25 + 0.125; corner < to; corner += 0.25) {
									pts.append(corner);
								}
								pts.append(to);

								Vector<Point2> uvs;
								Vector<Point2> points;
								uvs.push_back(get_relative_center());
								points.push_back(progress_offset + s * get_relative_center());
								for (int i = 0; i < pts.size(); i++) {
									Point2 uv = unit_val_to_uv(pts[i]);
									if (uvs.find(uv) >= 0) {
										continue;
									}
									uvs.push_back(uv);
									points.push_back(progress_offset + Point2(uv.x * s.x, uv.y * s.y));
								}
								Vector<Color> colors;
								colors.push_back(tint_progress);
								draw_polygon(points, colors, uvs, progress);
							}

							// Draw a reference cross.
							if (Engine::get_singleton()->is_editor_hint()) {
								Point2 p;

								if (nine_patch_stretch) {
									p = get_size();
								} else {
									p = progress->get_size();
								}

								p *= get_relative_center();
								p += progress_offset;
								p = p.floor();
								draw_line(p - Point2(8, 0), p + Point2(8, 0), Color(0.9, 0.5, 0.5), 2);
								draw_line(p - Point2(0, 8), p + Point2(0, 8), Color(0.9, 0.5, 0.5), 2);
							}
						} break;
						case FILL_BILINEAR_LEFT_AND_RIGHT: {
							Rect2 region = Rect2(progress_offset + Point2(s.x / 2 - s.x * get_as_ratio() / 2, 0), Size2(s.x * get_as_ratio(), s.y));
							Rect2 source = Rect2(Point2(s.x / 2 - s.x * get_as_ratio() / 2, 0), Size2(s.x * get_as_ratio(), s.y));
							draw_texture_rect_region(progress, region, source, tint_progress);
						} break;
						case FILL_BILINEAR_TOP_AND_BOTTOM: {
							Rect2 region = Rect2(progress_offset + Point2(0, s.y / 2 - s.y * get_as_ratio() / 2), Size2(s.x, s.y * get_as_ratio()));
							Rect2 source = Rect2(Point2(0, s.y / 2 - s.y * get_as_ratio() / 2), Size2(s.x, s.y * get_as_ratio()));
							draw_texture_rect_region(progress, region, source, tint_progress);
						} break;
						case FILL_MODE_MAX:
							break;
						default:
							draw_texture_rect_region(progress, Rect2(progress_offset, Size2(s.x * get_as_ratio(), s.y)), Rect2(Point2(), Size2(s.x * get_as_ratio(), s.y)), tint_progress);
					}
				}
				if (over.is_valid()) {
					switch (mode) {
						case FILL_CLOCKWISE:
						case FILL_COUNTER_CLOCKWISE:
						case FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE: {
							if (nine_patch_stretch) {
								Rect2 region = Rect2(Point2(), get_size());
								draw_texture_rect(over, region, false, tint_over);
							} else {
								draw_texture(over, Point2(), tint_over);
							}
						} break;
						case FILL_MODE_MAX:
							break;
						default:
							draw_texture(over, Point2(), tint_over);
					}
				}
			}
		} break;
	}
}

void TextureProgressBar::set_fill_mode(int p_fill) {
	ERR_FAIL_INDEX(p_fill, FILL_MODE_MAX);

	if (mode == (FillMode)p_fill) {
		return;
	}

	mode = (FillMode)p_fill;
	update();
}

int TextureProgressBar::get_fill_mode() {
	return mode;
}

void TextureProgressBar::set_radial_initial_angle(float p_angle) {
	while (p_angle > 360) {
		p_angle -= 360;
	}
	while (p_angle < 0) {
		p_angle += 360;
	}

	if (rad_init_angle == p_angle) {
		return;
	}

	rad_init_angle = p_angle;
	update();
}

float TextureProgressBar::get_radial_initial_angle() {
	return rad_init_angle;
}

void TextureProgressBar::set_fill_degrees(float p_angle) {
	float angle_clamped = CLAMP(p_angle, 0, 360);

	if (rad_max_degrees == angle_clamped) {
		return;
	}

	rad_max_degrees = angle_clamped;
	update();
}

float TextureProgressBar::get_fill_degrees() {
	return rad_max_degrees;
}

void TextureProgressBar::set_radial_center_offset(const Point2 &p_off) {
	if (rad_center_off == p_off) {
		return;
	}

	rad_center_off = p_off;
	update();
}

Point2 TextureProgressBar::get_radial_center_offset() {
	return rad_center_off;
}

void TextureProgressBar::_bind_methods() {
	ClassDB::bind_method(D_METHOD("set_under_texture", "tex"), &TextureProgressBar::set_under_texture);
	ClassDB::bind_method(D_METHOD("get_under_texture"), &TextureProgressBar::get_under_texture);

	ClassDB::bind_method(D_METHOD("set_progress_texture", "tex"), &TextureProgressBar::set_progress_texture);
	ClassDB::bind_method(D_METHOD("get_progress_texture"), &TextureProgressBar::get_progress_texture);

	ClassDB::bind_method(D_METHOD("set_over_texture", "tex"), &TextureProgressBar::set_over_texture);
	ClassDB::bind_method(D_METHOD("get_over_texture"), &TextureProgressBar::get_over_texture);

	ClassDB::bind_method(D_METHOD("set_fill_mode", "mode"), &TextureProgressBar::set_fill_mode);
	ClassDB::bind_method(D_METHOD("get_fill_mode"), &TextureProgressBar::get_fill_mode);

	ClassDB::bind_method(D_METHOD("set_tint_under", "tint"), &TextureProgressBar::set_tint_under);
	ClassDB::bind_method(D_METHOD("get_tint_under"), &TextureProgressBar::get_tint_under);

	ClassDB::bind_method(D_METHOD("set_tint_progress", "tint"), &TextureProgressBar::set_tint_progress);
	ClassDB::bind_method(D_METHOD("get_tint_progress"), &TextureProgressBar::get_tint_progress);

	ClassDB::bind_method(D_METHOD("set_tint_over", "tint"), &TextureProgressBar::set_tint_over);
	ClassDB::bind_method(D_METHOD("get_tint_over"), &TextureProgressBar::get_tint_over);

	ClassDB::bind_method(D_METHOD("set_texture_progress_offset", "offset"), &TextureProgressBar::set_progress_offset);
	ClassDB::bind_method(D_METHOD("get_texture_progress_offset"), &TextureProgressBar::get_progress_offset);

	ClassDB::bind_method(D_METHOD("set_radial_initial_angle", "mode"), &TextureProgressBar::set_radial_initial_angle);
	ClassDB::bind_method(D_METHOD("get_radial_initial_angle"), &TextureProgressBar::get_radial_initial_angle);

	ClassDB::bind_method(D_METHOD("set_radial_center_offset", "mode"), &TextureProgressBar::set_radial_center_offset);
	ClassDB::bind_method(D_METHOD("get_radial_center_offset"), &TextureProgressBar::get_radial_center_offset);

	ClassDB::bind_method(D_METHOD("set_fill_degrees", "mode"), &TextureProgressBar::set_fill_degrees);
	ClassDB::bind_method(D_METHOD("get_fill_degrees"), &TextureProgressBar::get_fill_degrees);

	ClassDB::bind_method(D_METHOD("set_stretch_margin", "margin", "value"), &TextureProgressBar::set_stretch_margin);
	ClassDB::bind_method(D_METHOD("get_stretch_margin", "margin"), &TextureProgressBar::get_stretch_margin);

	ClassDB::bind_method(D_METHOD("set_nine_patch_stretch", "stretch"), &TextureProgressBar::set_nine_patch_stretch);
	ClassDB::bind_method(D_METHOD("get_nine_patch_stretch"), &TextureProgressBar::get_nine_patch_stretch);

	ADD_PROPERTY(PropertyInfo(Variant::INT, "fill_mode", PROPERTY_HINT_ENUM, "Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise,Bilinear (Left and Right),Bilinear (Top and Bottom),Clockwise and Counter Clockwise"), "set_fill_mode", "get_fill_mode");
	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "nine_patch_stretch"), "set_nine_patch_stretch", "get_nine_patch_stretch");

	ADD_GROUP("Stretch Margin", "stretch_margin_");
	ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_left", PROPERTY_HINT_RANGE, "0,16384,1,suffix:px"), "set_stretch_margin", "get_stretch_margin", SIDE_LEFT);
	ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_top", PROPERTY_HINT_RANGE, "0,16384,1,suffix:px"), "set_stretch_margin", "get_stretch_margin", SIDE_TOP);
	ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_right", PROPERTY_HINT_RANGE, "0,16384,1,suffix:px"), "set_stretch_margin", "get_stretch_margin", SIDE_RIGHT);
	ADD_PROPERTYI(PropertyInfo(Variant::INT, "stretch_margin_bottom", PROPERTY_HINT_RANGE, "0,16384,1,suffix:px"), "set_stretch_margin", "get_stretch_margin", SIDE_BOTTOM);

	ADD_GROUP("Textures", "texture_");
	ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_under", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_under_texture", "get_under_texture");
	ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_over", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_over_texture", "get_over_texture");
	ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture_progress", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_progress_texture", "get_progress_texture");
	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_progress_offset", PROPERTY_HINT_NONE, "suffix:px"), "set_texture_progress_offset", "get_texture_progress_offset");

	ADD_GROUP("Tint", "tint_");
	ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_under"), "set_tint_under", "get_tint_under");
	ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_over"), "set_tint_over", "get_tint_over");
	ADD_PROPERTY(PropertyInfo(Variant::COLOR, "tint_progress"), "set_tint_progress", "get_tint_progress");

	ADD_GROUP("Radial Fill", "radial_");
	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radial_initial_angle", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider,degrees"), "set_radial_initial_angle", "get_radial_initial_angle");
	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "radial_fill_degrees", PROPERTY_HINT_RANGE, "0.0,360.0,0.1,slider,degrees"), "set_fill_degrees", "get_fill_degrees");
	ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "radial_center_offset", PROPERTY_HINT_NONE, "suffix:px"), "set_radial_center_offset", "get_radial_center_offset");

	BIND_ENUM_CONSTANT(FILL_LEFT_TO_RIGHT);
	BIND_ENUM_CONSTANT(FILL_RIGHT_TO_LEFT);
	BIND_ENUM_CONSTANT(FILL_TOP_TO_BOTTOM);
	BIND_ENUM_CONSTANT(FILL_BOTTOM_TO_TOP);
	BIND_ENUM_CONSTANT(FILL_CLOCKWISE);
	BIND_ENUM_CONSTANT(FILL_COUNTER_CLOCKWISE);
	BIND_ENUM_CONSTANT(FILL_BILINEAR_LEFT_AND_RIGHT);
	BIND_ENUM_CONSTANT(FILL_BILINEAR_TOP_AND_BOTTOM);
	BIND_ENUM_CONSTANT(FILL_CLOCKWISE_AND_COUNTER_CLOCKWISE);
}

TextureProgressBar::TextureProgressBar() {
	set_mouse_filter(MOUSE_FILTER_PASS);
}


text:
package com.gigony.marked4j.lexer.blockmatcher;

import com.gigony.marked4j.lexer.blockfragment.ListFragment;
import com.gigony.marked4j.util.TextSegment;
import org.junit.Test;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

public class ListFragmentMatcherTest {
    @Test
    public void listFragmentMatchTest(){
        ListFragmentMatcher m = new ListFragmentMatcher();
        TextSegment text = new TextSegment("* item1 \n* item2\n  * item 2-1\n  * item 2-2\n* item3\n\n\nprint");
        assertTrue(m.find(text));
        ListFragment block = m.getFragment();
        assertEquals("* item1 \n* item2\n  * item 2-1\n  * item 2-2\n* item3\n\n\n",block.getRawText());
        assertEquals("*",block.getBulletSegment().toString());
        assertFalse(block.isOrdered());
    }

}

redpajama_set_name: RedPajamaGithub


text:
BCDS_BASE_DIR ?= ../../..

# Macro to define Start-up method. change this macro to "CUSTOM_STARTUP" to have custom start-up.
export BCDS_SYSTEM_STARTUP_METHOD = DEFAULT_STARTUP
export BCDS_APP_NAME = SendVirtualSensorDataOverUsb
export BCDS_APP_DIR = $(CURDIR)
export BCDS_APP_SOURCE_DIR = $(BCDS_APP_DIR)/source

#Please refer BCDS_CFLAGS_COMMON variable in application.mk file
#and if any addition flags required then add that flags only in the below macro
#export BCDS_CFLAGS_COMMON =

#List all the application header file under variable BCDS_XDK_INCLUDES in a similar pattern as below
export BCDS_XDK_INCLUDES = \
		-I$(BCDS_APP_SOURCE_DIR)/protected \

#List all the application source file under variable BCDS_XDK_APP_SOURCE_FILES in a similar pattern as below
export BCDS_XDK_APP_SOURCE_FILES = \
	$(BCDS_APP_SOURCE_DIR)/main.c \
	$(BCDS_APP_SOURCE_DIR)/HttpClient.c \
	$(BCDS_APP_SOURCE_DIR)/AcousticSensor.c \
	$(BCDS_APP_SOURCE_DIR)/NetworkDiscovery.c \

.PHONY: clean	debug release flash_debug_bin flash_release_bin

clean:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk clean

debug:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk debug

release:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk release

flash_debug_bin:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk flash_debug_bin

flash_release_bin:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk flash_release_bin

cleanlint:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk cleanlint

lint:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk lint

cdt:
	$(MAKE) -C $(BCDS_BASE_DIR)/xdk110/Common -f application.mk cdt


text:
'use strict';

const periodic = require('periodicjs');
const csrf = require('csurf');
const capitalize = require('capitalize');
const authRouter = periodic.express.Router();
const controllers = require('../controllers');
const passportControllers = periodic.controllers.extension.get('periodicjs.ext.passport');
const utilities = require('../utilities');
const passportExtSettings = periodic.settings.extensions['periodicjs.ext.passport'];
const passportExtOAuth2Clients = passportExtSettings.oauth.oauth2client;
// const periodicRoutingUtil = periodic.utilities.routing;
const passport = periodic.locals.extensions.get('periodicjs.ext.passport').passport;

if (passportExtSettings.passport.use_csrf) {
  authRouter.use(csrf());
  authRouter.use(passportControllers.auth.useCSRF);
}

passportExtOAuth2Clients.forEach(oauth2client_settings => {
  const client = oauth2client_settings;
  const service_name = oauth2client_settings.service_name;
  const clientAuth = utilities.oauth.client_auth_request({ client, });
  const userAuth = utilities.oauth.user_auth_request({ client, });
  let mockUserAuthReq = {};
  let mockUserAuthRes = {};
  userAuth(mockUserAuthReq, mockUserAuthRes, () => {
    if (periodic.config.debug) {
      periodic.logger.silly(`Configured ${service_name}, OAuth2 Bearer Authentication for (${capitalize(oauth2client_settings.user_entity_type || 'user')})${oauth2client_settings.user_email}`);
    }
  });
  utilities.oauth.clientAuthToken[service_name] = clientAuth;
  // utilities.oauth.selectedUserAuthToken[service_name] = userAuth;
  authRouter.get(`/oauth2client-${service_name}`, passport.authenticate(`oauth2client-${service_name}`));
  authRouter.get(`/oauth2client-${service_name}/callback`, utilities.oauth.oauth2callback({ service_name, }));
});

module.exports = authRouter;


text:
"""Presubmit script for Chromium browser code.

This script currently checks HTML/CSS/JS files in resources/ and ui/webui/.

See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools, and see
http://www.chromium.org/developers/web-development-style-guide for the rules
checked for here.
"""

def CheckChangeOnUpload(input_api, output_api):
  return _CommonChecks(input_api, output_api)

def CheckChangeOnCommit(input_api, output_api):
  return _CommonChecks(input_api, output_api)

def _CommonChecks(input_api, output_api):
  """Checks common to both upload and commit."""
  results = []

  path = input_api.os_path
  cwd = input_api.PresubmitLocalPath()
  resources = path.join(cwd, 'resources')
  webui = path.join(cwd, 'ui', 'webui')

  affected_files = (f.AbsoluteLocalPath() for f in input_api.AffectedFiles())

  would_affect_tests = [
      path.join(cwd, 'PRESUBMIT.py'),
      path.join(cwd, 'test_presubmit.py'),
  ]
  would_affect_tests += input_api.glob(path.join(cwd, 'web_dev_style', '*.py'))

  if any(f for f in affected_files if f in would_affect_tests):
    tests = [path.join(cwd, 'test_presubmit.py')]
    results.extend(
        input_api.canned_checks.RunUnitTests(input_api, output_api, tests))

  import sys
  old_path = sys.path

  try:
    sys.path = [cwd] + old_path
    from web_dev_style import (resource_checker, css_checker, html_checker,
                               js_checker)

    search_dirs = (resources, webui)
    def _html_css_js_resource(p):
      return p.endswith(('.html', '.css', '.js')) and p.startswith(search_dirs)

    def _vulcanized_resource(p):
      return p.endswith(('vulcanized.html', 'crisper.js'))

    BLACKLIST = [
        'chrome/browser/resources/pdf/index.html',
        'chrome/browser/resources/pdf/index.js'
    ]
    def is_resource(maybe_resource):
      return (maybe_resource.LocalPath() not in BLACKLIST and
          not _vulcanized_resource(maybe_resource.LocalPath()) and
          _html_css_js_resource(maybe_resource.AbsoluteLocalPath()))

    results.extend(resource_checker.ResourceChecker(
        input_api, output_api, file_filter=is_resource).RunChecks())
    results.extend(css_checker.CSSChecker(
        input_api, output_api, file_filter=is_resource).RunChecks())
    results.extend(html_checker.HtmlChecker(
        input_api, output_api, file_filter=is_resource).RunChecks())
    results.extend(js_checker.JSChecker(
        input_api, output_api, file_filter=is_resource).RunChecks())
  finally:
    sys.path = old_path

  return results


text:
package com.whitelaning.whitefragment.thirdparty.magicindicator.buildins.commonnavigator.titles;

import android.content.Context;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.TextUtils;
import android.view.Gravity;
import android.widget.TextView;

import com.whitelaning.whitefragment.thirdparty.magicindicator.UIUtil;
import com.whitelaning.whitefragment.thirdparty.magicindicator.buildins.commonnavigator.abs.IMeasurablePagerTitleView;

/**
 * 带文本的指示器标题
 * 博客: http://hackware.lucode.net
 * Created by hackware on 2016/6/26.
 */
public class SimplePagerTitleView extends TextView implements IMeasurablePagerTitleView {
    protected int mSelectedColor;
    protected int mNormalColor;

    public SimplePagerTitleView(Context context) {
        super(context, null);
        init(context);
    }

    private void init(Context context) {
        setGravity(Gravity.CENTER);
        int padding = UIUtil.dip2px(context, 10);
        setPadding(padding, 0, padding, 0);
        setSingleLine();
        setEllipsize(TextUtils.TruncateAt.END);
    }

    @Override
    public void onSelected(int index) {
        setTextColor(mSelectedColor);
    }

    @Override
    public void onDeselected(int index) {
        setTextColor(mNormalColor);
    }

    @Override
    public void onLeave(int index, float leavePercent, boolean leftToRight) {
    }

    @Override
    public void onEnter(int index, float enterPercent, boolean leftToRight) {
    }

    @Override
    public int getContentLeft() {
        Rect bound = new Rect();
        getPaint().getTextBounds(getText().toString(), 0, getText().length(), bound);
        int contentWidth = bound.width();
        return getLeft() + getWidth() / 2 - contentWidth / 2;
    }

    @Override
    public int getContentTop() {
        Paint.FontMetrics metrics = getPaint().getFontMetrics();
        float contentHeight = metrics.bottom - metrics.top;
        return (int) (getHeight() / 2 - contentHeight / 2);
    }

    @Override
    public int getContentRight() {
        Rect bound = new Rect();
        getPaint().getTextBounds(getText().toString(), 0, getText().length(), bound);
        int contentWidth = bound.width();
        return getLeft() + getWidth() / 2 + contentWidth / 2;
    }

    @Override
    public int getContentBottom() {
        Paint.FontMetrics metrics = getPaint().getFontMetrics();
        float contentHeight = metrics.bottom - metrics.top;
        return (int) (getHeight() / 2 + contentHeight / 2);
    }

    public int getSelectedColor() {
        return mSelectedColor;
    }

    public void setSelectedColor(int selectedColor) {
        mSelectedColor = selectedColor;
    }

    public int getNormalColor() {
        return mNormalColor;
    }

    public void setNormalColor(int normalColor) {
        mNormalColor = normalColor;
    }
}


text:
<md-card>
    <md-card-title>
        <md-card-title-text>
            Inactive people with roles assigned
        </md-card-title-text>
    </md-card-title>
    <md-card-content layout="column">
        <form flex novalidate name="allPeopleInactiveForm"
                ng-submit="allPeopleInactiveForm.$valid && vm.submitAllPeopleInactive()">
            <md-progress-circular ng-if="vm.loadingAllPeople" md-mode="indeterminate"></md-progress-circular>

Name:

{{member.person_name}}

A. key:

{{member.association_key}}

ORCID:

{{member.ORCID}}

City:

{{member.pole_name}}

Role:

{{vm.roleName(member.role_id)}}

Lab:

                                <md-input-container class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.lab_row"
                                            md-on-close="vm.changeLab(member.lab_row, member.row_id)"
                                            aria-label="labs"
                                            name="member_labs[memberNum]">

                                            <md-optgroup ng-repeat="unit in vm.units" label="{{unit.short_name}}" class="large-optgroup">
                                                <md-optgroup flex-offset="5" ng-repeat="group in vm.groups | filter: {unit_id: unit.id}"
                                                                label="{{group.name}}">
                                                    <md-option ng-repeat="lab in vm.labs | filter: {group_id: group.group_id, unit_id: unit.id}:true"
                                                                ng-value="lab.lab_row">{{vm.labNames(lab)}}
                                                    </md-option>
                                                </md-optgroup>
                                            </md-optgroup>

                                    </md-select>
                                </md-input-container>

Facility:

                                <md-input-container class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.technician_office_id"
                                            md-on-close="vm.changeFacility(member.technician_office_id, member, member.row_id)"
                                            aria-label="labs-offices"
                                            name="member_office[memberNum]">

                                            <md-option ng-repeat="fac in vm.facilities"
                                                        ng-value="fac.id">{{fac.name_en}}
                                            </md-option>

                                    </md-select>
                                </md-input-container>

Office:

                                <md-input-container class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.science_manager_office_id"
                                            md-on-close="vm.changeManageOffice(member.science_manager_office_id, member, member.row_id)"
                                            aria-label="labs-offices"
                                            name="member_office[memberNum]">

                                            <md-option ng-repeat="scm in vm.scienceManagementOffices"
                                                        ng-value="scm.id">{{scm.name_en}}
                                            </md-option>

                                    </md-select>
                                </md-input-container>

Office:

                                <md-input-container class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.administrative_office_id"
                                            md-on-close="vm.changeAdmOffice(member.administrative_office_id, member, member.row_id)"
                                            aria-label="labs-offices"
                                            name="member_office[memberNum]">

                                            <md-option ng-repeat="adm in vm.administrativeOffices"
                                                        ng-value="adm.id">{{adm.name_en}}
                                            </md-option>

                                    </md-select>
                                </md-input-container>

Position:

                                <md-input-container ng-if="member.role_id==1"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.labPositions" ng-value="type.lab_position_id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==2"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.technicianPositions" ng-value="type.id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==3"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.scienceManagementPositions" ng-value="type.id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==4"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.administrativePositions" ng-value="type.id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>

Time (%):

                                <md-input-container class="input-no-margin" ng-if="member.role_id==1">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>
                                <md-input-container class="input-no-margin" ng-if="member.role_id==2">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>
                                <md-input-container class="input-no-margin" ng-if="member.role_id==3">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>
                                <md-input-container class="input-no-margin" ng-if="member.role_id==4">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>

Started:

                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==1">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==2">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==3">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==4">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>

Finished:

                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==1">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==2">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==3">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==4">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>

                                    Expand info

                                    Compact info

                                    <ng-md-icon icon="expand_more"
                                        ng-show="!member.expanded"
                                        ng-click="vm.expandInfo(member)"
                                        size="22"></ng-md-icon>
                                    <ng-md-icon icon="expand_less"
                                        ng-show="member.expanded"
                                        ng-click="vm.compactInfo(member)"
                                        size="22"></ng-md-icon>

                            <md-button ng-click="vm.showDetailsPerson(member)"
                                        aria-label="Details"
                                        class="md-icon-button interaction-button">
                                <md-icon md-svg-src="images/icons/description_24px.svg"></md-icon>
                            </md-button>
                            <md-button ng-click="vm.removePerson(member.person_id)"
                                        aria-label="Remove"
                                        class="md-icon-button interaction-button">
                                <md-icon md-svg-src="images/icons/delete_24px.svg"></md-icon>
                            </md-button>

                        <md-divider ng-if="!vm.showTable()"></md-divider>

                                Name
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='person_name'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='person_name'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

                                A. key

                                City
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='pole_name'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='pole_name'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

                                Role
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='role_id'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='role_id'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

                            Lab/Office
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='lab_id'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='lab_id'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

                            Position
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='position_id'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='position_id'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

                            Time (%)
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='dedication'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='dedication'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

                                ORCID

                            Started
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='valid_from'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='valid_from'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

                            Finished
                                <ng-md-icon ng-if="!vm.sortReverse && vm.sortType=='valid_until'"
                                        icon="arrow_downward" size="12"></ng-md-icon>
                                <ng-md-icon ng-if="vm.sortReverse  && vm.sortType=='valid_until'"
                                        icon="arrow_upwards" size="12"></ng-md-icon>

 0">
                                    <ng-md-icon icon="expand_more"
                                        ng-show="!member.expanded"
                                        ng-click="vm.expandInfo(member, true)"
                                        size="18"></ng-md-icon>
                                    <ng-md-icon icon="expand_less"
                                        ng-show="member.expanded"
                                        ng-click="vm.compactInfo(member, true)"
                                        size="18"></ng-md-icon>

                            {{member.person_name}}
                            {{member.association_key}}
                            {{member.pole_name}}

                                {{vm.roleName(member.role_id)}}

                                <md-input-container ng-if="member.role_id==1"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.lab_row"
                                            md-on-close="vm.changeLab(member.lab_id, member.row_id)"
                                            aria-label="labs-offices"
                                            name="member_labs[memberNum]">

                                            <md-optgroup ng-repeat="unit in vm.units" label="{{unit.short_name}}" class="large-optgroup">
                                                <md-optgroup flex-offset="5" ng-repeat="group in vm.groups | filter: {unit_id: unit.id}"
                                                                label="{{group.name}}">
                                                    <md-option ng-repeat="lab in vm.labs | filter: {group_id: group.group_id, unit_id: unit.id}:true"
                                                                ng-value="lab.lab_row">{{vm.labNames(lab)}}
                                                    </md-option>
                                                </md-optgroup>
                                            </md-optgroup>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==2"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.technician_office_id"
                                            md-on-close="vm.changeFacility(member.technician_office_id, member, member.row_id)"
                                            aria-label="labs-offices"
                                            name="member_office[memberNum]">

                                            <md-option ng-repeat="fac in vm.facilities"
                                                        ng-value="fac.id">{{fac.name_en}}
                                            </md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==3"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.science_manager_office_id"
                                            md-on-close="vm.changeManageOffice(member.science_manager_office_id, member, member.row_id)"
                                            aria-label="labs-offices"
                                            name="member_office[memberNum]">

                                            <md-option ng-repeat="scm in vm.scienceManagementOffices"
                                                        ng-value="scm.id">{{scm.name_en}}
                                            </md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==4"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.administrative_office_id"
                                            md-on-close="vm.changeAdmOffice(member.administrative_office_id, member, member.row_id)"
                                            aria-label="labs-offices"
                                            name="member_office[memberNum]">

                                            <md-option ng-repeat="adm in vm.administrativeOffices"
                                                        ng-value="adm.id">{{adm.name_en}}
                                            </md-option>

                                    </md-select>
                                </md-input-container>

                                <md-input-container ng-if="member.role_id==1"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.labPositions" ng-value="type.lab_position_id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==2"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.technicianPositions" ng-value="type.id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==3"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.scienceManagementPositions" ng-value="type.id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>
                                <md-input-container ng-if="member.role_id==4"
                                        class="select-container select-no-margin card-type">
                                    <md-select ng-model="member.position_id"
                                            md-on-close="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson',[])"
                                            aria-label="positions"
                                            name="member_position[memberNum]">

                                            <md-option ng-repeat="type in vm.administrativePositions" ng-value="type.id">{{type.name_en}}</md-option>

                                    </md-select>
                                </md-input-container>

                                <md-input-container class="input-no-margin" ng-if="member.role_id==1">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>
                                <md-input-container class="input-no-margin" ng-if="member.role_id==2">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>
                                <md-input-container class="input-no-margin" ng-if="member.role_id==3">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>
                                <md-input-container class="input-no-margin" ng-if="member.role_id==4">
                                    <input ng-model="member.dedication"
                                        ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson', [])"
                                        aria-label="dedications"
                                        name="member_dedication[memberNum]" dedication-validate>
                                </md-input-container>

                            {{member.ORCID}}

                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==1">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==2">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==3">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==4">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_from"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson', [])"
                                            name="member_startDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>

                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==1">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateLabPerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==2">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateTechPerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==3">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateManagePerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>
                                <md-input-container class="input-no-margin simple-input" ng-if="member.role_id==4">
                                    <md-datepicker md-current-view="year" ng-model="member.valid_until"
                                            ng-change="vm.updateDataSubmit(member.row_id,vm.currPeopleInactive[memberNum],'updateAdmPerson', [])"
                                            name="member_endDate[memberNum]"
                                            md-placeholder="Enter date" md-hide-icons="calendar"></md-datepicker>
                                </md-input-container>

                                <md-button ng-click="vm.showDetailsPerson(member)"
                                            aria-label="Details"
                                            class="md-icon-button interaction-button">
                                    <md-icon md-svg-src="images/icons/description_24px.svg"></md-icon>
                                </md-button>
                                <md-button ng-click="vm.removePerson(member.person_id)"
                                            aria-label="Remove"
                                            class="md-icon-button interaction-button">
                                    <md-icon md-svg-src="images/icons/delete_24px.svg"></md-icon>
                                </md-button>

                <md-input-container class="input-no-margin wider">
                    Results/page
                    <md-select ng-model="vm.pageSizeInactive"
                            md-on-close="vm.renderPeople('new')"
                            aria-label="pageSize"
                            name="pageSize">
                            <md-option ng-value="10">10</md-option>
                            <md-option ng-value="20">20</md-option>
                            <md-option ng-value="50">50</md-option>
                    </md-select>
                </md-input-container>
                <md-input-container class="input-no-margin">
                    Page
                    <md-select ng-model="vm.currentPageInactive"
                            md-on-close="vm.renderPeople('page')"
                            aria-label="currentPage"
                            name="currentPage">
                            <md-option ng-repeat="page in vm.pagesInactive" ng-value="page">{{page}}</md-option>
                    </md-select>
                </md-input-container>

                <md-button id="team-PeopleInactive-lab" type="submit"
                    class="button-small md-raised md-primary">Update</md-button>

                        {{vm.updateStatus[vm.forms['allPeopleInactive']]}}

                <md-button class="button-small md-raised md-warn"
                    ng-click="vm.closeTabs()">Close details tabs</md-button>

        </form>

    </md-card-content>
</md-card>


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context="com.otter.aidldemoclient.AIDLDemoClient" >

    <Button
        android:id="@+id/bind_service"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Bind Service" />

    <Button
        android:id="@+id/unbind_service"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="32dp"
        android:text="Unbind Service" />

    <Button
        android:id="@+id/add_person"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Add Person" />

    <Button
        android:id="@+id/get_person"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Get Person" />

    <TextView
        android:id="@+id/person_list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>


text:
package apigateway

import (
	"fmt"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/service/apigateway"
	"github.com/viant/toolbox/data"
)

func indexResource(resources []*apigateway.Resource) map[string]*apigateway.Resource {
	var result = make(map[string]*apigateway.Resource)
	if len(resources) == 0 {
		return result
	}
	for _, resource := range resources {
		result[*resource.Path] = resource
	}
	return result
}

/*
 { "op": "add", "path": "/a/b/c", "value": "foo" }
   { "path": "/a/b/c", "op": "add", "value": "foo" }
   { "value": "foo", "path": "/a/b/c", "op": "add" }

*/

func patchBool(source, target *bool, path string) (*apigateway.PatchOperation, bool) {
	if source == nil {
		if target == nil {
			return nil, false
		}
		return &apigateway.PatchOperation{
			Op:    aws.String("add"),
			Path:  aws.String(path),
			Value: aws.String(fmt.Sprintf("%v", *target)),
		}, true
	}
	if target == nil {
		return &apigateway.PatchOperation{
			Op:   aws.String("remove"),
			Path: aws.String(path),
			From: aws.String(fmt.Sprintf("%v", *source)),
		}, true
	}
	if *target == *source {
		return nil, false
	}
	return &apigateway.PatchOperation{
		Op:    aws.String("replace"),
		Path:  aws.String(path),
		From:  aws.String(fmt.Sprintf("%v", *source)),
		Value: aws.String(fmt.Sprintf("%v", *target)),
	}, true
}

func patchString(source, target *string, path string) (*apigateway.PatchOperation, bool) {
	if source == nil {
		if target == nil {
			return nil, false
		}
		return &apigateway.PatchOperation{
			Op:    aws.String("add"),
			Path:  aws.String(path),
			Value: aws.String(fmt.Sprintf("%v", *target)),
		}, true
	}
	if target == nil {
		return &apigateway.PatchOperation{
			Op:   aws.String("remove"),
			Path: aws.String(path),
			From: aws.String(fmt.Sprintf("%v", *source)),
		}, true
	}
	if *target == *source {
		return nil, false
	}
	return &apigateway.PatchOperation{
		Op:    aws.String("replace"),
		Path:  aws.String(path),
		From:  aws.String(fmt.Sprintf("%v", *source)),
		Value: aws.String(fmt.Sprintf("%v", *target)),
	}, true
}

func pathInt64(source, target *int64, path string) (*apigateway.PatchOperation, bool) {
	if source == nil {
		if target == nil {
			return nil, false
		}
		return &apigateway.PatchOperation{
			Op:    aws.String("add"),
			Path:  aws.String(path),
			Value: aws.String(fmt.Sprintf("%v", *target)),
		}, true
	}
	if target == nil {
		return &apigateway.PatchOperation{
			Op:   aws.String("remove"),
			Path: aws.String(path),
			From: aws.String(fmt.Sprintf("%v", *source)),
		}, true
	}
	if *target == *source {
		return nil, false
	}
	return &apigateway.PatchOperation{
		Op:    aws.String("replace"),
		Path:  aws.String(path),
		From:  aws.String(fmt.Sprintf("%v", *source)),
		Value: aws.String(fmt.Sprintf("%v", *target)),
	}, true
}

func SetAPIInfo(restAPI *apigateway.RestApi, aMap data.Map) {
	aMap.SetValue("restAPI.ID", *restAPI.Id)
}


text:
<script>
    var contactForm = document.querySelector('form'),
    inputEmail = contactForm.querySelector('[name="email"]'),
    textAreaMessage = contactForm.querySelector('[name="content"]'),
    sendButton = contactForm.querySelector('button');

    sendButton.addEventListener('click', function(event){
      event.preventDefault();

      sendButton.innerHTML = '{{ site.text.contact.ajax.sending }}';

      var xhr = new XMLHttpRequest();
      xhr.open('POST', '//formspree.io/{{ site.email }}', true);
      xhr.setRequestHeader("Accept", "application/json")
      xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")

      xhr.send(
        "email=" + inputEmail.value +
        "&message=" + textAreaMessage.value);

      xhr.onloadend = function (res) {
        if (res.target.status === 200){
          sendButton.innerHTML = '{{ site.text.contact.ajax.sent }}';
        }
        else {
          sendButton.innerHTML = '{{ site.text.contact.ajax.error }}';
        }
      }
    });
</script>


text: <iframe src="/files/extensions/api_test/app_process/path1/iframe.html"></iframe>


text:
package kube

import (
	"fmt"

	client "k8s.io/client-go/kubernetes"
	restclient "k8s.io/client-go/rest"
)

var (
	// allow test code to override default cluster configuration
	InClusterConfig = func() (*restclient.Config, error) {
		return restclient.InClusterConfig()
	}
)

// logger interface exists to allow the library to use a
// logging object provided by the caller.
type logger interface {
	LogError(s string, v ...interface{}) error
	Err(e error) error
	Critical(s string, v ...interface{})
	Debug(s string, v ...interface{})
}

// KubeConn provides a higher level object to manage the connection(s)
// to a k8s cluster.
type KubeConn struct {
	kubeConfig *restclient.Config
	kube       *client.Clientset
	logger     logger
	counter    *connectionCounter
	// tunables for connection threshold handling
	MaxConnThreshold uint64
}

// NewKubeConnWithConfig creates a new KubeConn with the provided
// logger and k8s client configuration. If a connection can not
// be established a non-nil error is returned.
func NewKubeConnWithConfig(l logger, rc *restclient.Config) (*KubeConn, error) {
	var (
		err error
		k   = &KubeConn{
			logger:     l,
			kubeConfig: rc,
			counter:    newConnectionCounter(),
		}
	)

	// Get a Go-client for Kubernetes
	k.kube, err = client.NewForConfig(k.kubeConfig)
	if err != nil {
		return nil, fmt.Errorf("Unable to create a client set: %v", err)
	}
	return k, nil
}

// NewKubeConn creates a new KubeConn with the default
// in-cluster k8s client configuration. If a connection can
// not be established a non-nil error is returned.
func NewKubeConn(l logger) (*KubeConn, error) {
	// Create a Kube client configuration using pkg callback
	rc, err := InClusterConfig()
	if err != nil {
		return nil, fmt.Errorf(
			"Unable to create configuration for Kubernetes: %v", err)
	}
	return NewKubeConnWithConfig(l, rc)
}

type MaxConnectionsErr struct {
	Count uint64
}

func NewMaxConnectionsErr(value uint64) MaxConnectionsErr {
	return MaxConnectionsErr{Count: value}
}

func (e MaxConnectionsErr) Error() string {
	return fmt.Sprintf("Too many kube exec connections active (%v)", e.Count)
}


text:
#pragma once

#include "BinaryBitmap.h"
#include <memory>

namespace ZXing {

/**
* This class provides a binarizer that wraps around a BitMatrix
*/
class BitWrapperBinarizer : public BinaryBitmap
{
public:
	explicit BitWrapperBinarizer(const std::shared_ptr<const BitMatrix>& bits, bool pureBarcode = false);
	BitWrapperBinarizer(std::shared_ptr<const BitMatrix> bits, int left, int top, int width, int height, bool pureBarcode = false);

	bool isPureBarcode() const override;
	int width() const override;
	int height() const override;
	bool getBlackRow(int y, BitArray& row) const override;
	std::shared_ptr<const BitMatrix> getBlackMatrix() const override;
	bool canCrop() const override;
	std::shared_ptr<BinaryBitmap> cropped(int left, int top, int width, int height) const override;
	bool canRotate() const override;
	std::shared_ptr<BinaryBitmap> rotated(int degreeCW) const override;

private:
	std::shared_ptr<const BitMatrix> _matrix;
	int _left;
	int _top;
	int _width;
	int _height;
	bool _pureBarcode;
};

} // ZXing


text:
CREATE TABLE `usuarios_tareas_nuevas_no_email` (
	`IdUsuario` INT(10) NULL DEFAULT NULL,
	`IdProyecto` INT(10) NULL DEFAULT NULL
)
COMMENT='Sirve para excluir el envio de emails a los usuarios que están relacionados con estos proyectos'
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB;


text:
require 'dichotomy'
require 'example_dependency'
require 'example_dependency_two'

dichotomy_container = Dichotomy::Container.new
example_dependency_subject = dichotomy_container.register_type(ExampleDependency)
example_dependency_subject_two = dichotomy_container.register_type(ExampleDependencyTwo)

dichotomy_container.resolve_type(example_dependency_subject_two)

debug = nil


text:
<?php if (!defined('IN_PHPBB')) exit; $this->_tpl_include('overall_header.html'); ?>

<form name="register" method="post" action="<?php echo (isset($this->_rootref['S_UCP_ACTION'])) ? $this->_rootref['S_UCP_ACTION'] : ''; ?>">

	<?php echo ((isset($this->_rootref['L_REGISTRATION'])) ? $this->_rootref['L_REGISTRATION'] : ((isset($user->lang['REGISTRATION'])) ? $user->lang['REGISTRATION'] : '{ REGISTRATION }')); ?>

<?php if ($this->_rootref['ERROR']) {  ?>

		<?php echo (isset($this->_rootref['ERROR'])) ? $this->_rootref['ERROR'] : ''; ?>

<?php } if ($this->_rootref['L_REG_COND']) {  ?>

		<?php echo ((isset($this->_rootref['L_REG_COND'])) ? $this->_rootref['L_REG_COND'] : ((isset($user->lang['REG_COND'])) ? $user->lang['REG_COND'] : '{ REG_COND }')); ?>

<?php } if (sizeof($this->_tpldata['profile_fields'])) {  ?>

		<?php echo ((isset($this->_rootref['L_ITEMS_REQUIRED'])) ? $this->_rootref['L_ITEMS_REQUIRED'] : ((isset($user->lang['ITEMS_REQUIRED'])) ? $user->lang['ITEMS_REQUIRED'] : '{ ITEMS_REQUIRED }')); ?>

<?php } ?>

	<?php echo ((isset($this->_rootref['L_USERNAME'])) ? $this->_rootref['L_USERNAME'] : ((isset($user->lang['USERNAME'])) ? $user->lang['USERNAME'] : '{ USERNAME }')); ?>:
<?php echo ((isset($this->_rootref['L_USERNAME_EXPLAIN'])) ? $this->_rootref['L_USERNAME_EXPLAIN'] : ((isset($user->lang['USERNAME_EXPLAIN'])) ? $user->lang['USERNAME_EXPLAIN'] : '{ USERNAME_EXPLAIN }')); ?>
	<input class="post" type="text" name="username" size="25" value="<?php echo (isset($this->_rootref['USERNAME'])) ? $this->_rootref['USERNAME'] : ''; ?>" />

	<?php echo ((isset($this->_rootref['L_EMAIL_ADDRESS'])) ? $this->_rootref['L_EMAIL_ADDRESS'] : ((isset($user->lang['EMAIL_ADDRESS'])) ? $user->lang['EMAIL_ADDRESS'] : '{ EMAIL_ADDRESS }')); ?>:
	<input class="post" type="text" name="email" size="25" maxlength="100" value="<?php echo (isset($this->_rootref['EMAIL'])) ? $this->_rootref['EMAIL'] : ''; ?>" />

	<?php echo ((isset($this->_rootref['L_CONFIRM_EMAIL'])) ? $this->_rootref['L_CONFIRM_EMAIL'] : ((isset($user->lang['CONFIRM_EMAIL'])) ? $user->lang['CONFIRM_EMAIL'] : '{ CONFIRM_EMAIL }')); ?>:
	<input class="post" type="text" name="email_confirm" size="25" maxlength="100" value="<?php echo (isset($this->_rootref['EMAIL_CONFIRM'])) ? $this->_rootref['EMAIL_CONFIRM'] : ''; ?>" />

	<?php echo ((isset($this->_rootref['L_PASSWORD'])) ? $this->_rootref['L_PASSWORD'] : ((isset($user->lang['PASSWORD'])) ? $user->lang['PASSWORD'] : '{ PASSWORD }')); ?>:
<?php echo ((isset($this->_rootref['L_PASSWORD_EXPLAIN'])) ? $this->_rootref['L_PASSWORD_EXPLAIN'] : ((isset($user->lang['PASSWORD_EXPLAIN'])) ? $user->lang['PASSWORD_EXPLAIN'] : '{ PASSWORD_EXPLAIN }')); ?>
	<input class="post" type="password" name="new_password" size="25" value="<?php echo (isset($this->_rootref['PASSWORD'])) ? $this->_rootref['PASSWORD'] : ''; ?>" />

	<?php echo ((isset($this->_rootref['L_CONFIRM_PASSWORD'])) ? $this->_rootref['L_CONFIRM_PASSWORD'] : ((isset($user->lang['CONFIRM_PASSWORD'])) ? $user->lang['CONFIRM_PASSWORD'] : '{ CONFIRM_PASSWORD }')); ?>:
	<input class="post" type="password" name="password_confirm" size="25" value="<?php echo (isset($this->_rootref['PASSWORD_CONFIRM'])) ? $this->_rootref['PASSWORD_CONFIRM'] : ''; ?>" />

	<?php echo ((isset($this->_rootref['L_LANGUAGE'])) ? $this->_rootref['L_LANGUAGE'] : ((isset($user->lang['LANGUAGE'])) ? $user->lang['LANGUAGE'] : '{ LANGUAGE }')); ?>:
	<select name="lang" onchange="change_language(this.value); return false;"><?php echo (isset($this->_rootref['S_LANG_OPTIONS'])) ? $this->_rootref['S_LANG_OPTIONS'] : ''; ?></select>

	<?php echo ((isset($this->_rootref['L_TIMEZONE'])) ? $this->_rootref['L_TIMEZONE'] : ((isset($user->lang['TIMEZONE'])) ? $user->lang['TIMEZONE'] : '{ TIMEZONE }')); ?>:
	<select name="tz"><?php echo (isset($this->_rootref['S_TZ_OPTIONS'])) ? $this->_rootref['S_TZ_OPTIONS'] : ''; ?></select>

<?php $_profile_fields_count = (isset($this->_tpldata['profile_fields'])) ? sizeof($this->_tpldata['profile_fields']) : 0;if ($_profile_fields_count) {for ($_profile_fields_i = 0; $_profile_fields_i < $_profile_fields_count; ++$_profile_fields_i){$_profile_fields_val = &$this->_tpldata['profile_fields'][$_profile_fields_i]; ?>

			<?php echo $_profile_fields_val['LANG_NAME']; ?>:
			<?php if ($_profile_fields_val['S_REQUIRED']) {  ?>*<?php } if ($_profile_fields_val['LANG_EXPLAIN']) {  ?>
<?php echo $_profile_fields_val['LANG_EXPLAIN']; ?><?php } ?>

		<?php echo $_profile_fields_val['FIELD']; if ($_profile_fields_val['ERROR']) {  ?>
<?php echo $_profile_fields_val['ERROR']; ?><?php } ?>

<?php }} if ($this->_rootref['S_CONFIRM_CODE']) {  ?>

		<?php echo ((isset($this->_rootref['L_CONFIRMATION'])) ? $this->_rootref['L_CONFIRMATION'] : ((isset($user->lang['CONFIRMATION'])) ? $user->lang['CONFIRMATION'] : '{ CONFIRMATION }')); ?>

		<?php echo ((isset($this->_rootref['L_CONFIRM_EXPLAIN'])) ? $this->_rootref['L_CONFIRM_EXPLAIN'] : ((isset($user->lang['CONFIRM_EXPLAIN'])) ? $user->lang['CONFIRM_EXPLAIN'] : '{ CONFIRM_EXPLAIN }')); ?>

		<?php echo (isset($this->_rootref['CONFIRM_IMG'])) ? $this->_rootref['CONFIRM_IMG'] : ''; ?>

		<?php echo ((isset($this->_rootref['L_CONFIRM_CODE'])) ? $this->_rootref['L_CONFIRM_CODE'] : ((isset($user->lang['CONFIRM_CODE'])) ? $user->lang['CONFIRM_CODE'] : '{ CONFIRM_CODE }')); ?>:
<?php echo ((isset($this->_rootref['L_CONFIRM_CODE_EXPLAIN'])) ? $this->_rootref['L_CONFIRM_CODE_EXPLAIN'] : ((isset($user->lang['CONFIRM_CODE_EXPLAIN'])) ? $user->lang['CONFIRM_CODE_EXPLAIN'] : '{ CONFIRM_CODE_EXPLAIN }')); ?>
		<input class="post" type="text" name="confirm_code" size="8" maxlength="8" />

<?php } if ($this->_rootref['S_COPPA']) {  ?>

		<?php echo ((isset($this->_rootref['L_COPPA_COMPLIANCE'])) ? $this->_rootref['L_COPPA_COMPLIANCE'] : ((isset($user->lang['COPPA_COMPLIANCE'])) ? $user->lang['COPPA_COMPLIANCE'] : '{ COPPA_COMPLIANCE }')); ?>

		<?php echo ((isset($this->_rootref['L_COPPA_EXPLAIN'])) ? $this->_rootref['L_COPPA_EXPLAIN'] : ((isset($user->lang['COPPA_EXPLAIN'])) ? $user->lang['COPPA_EXPLAIN'] : '{ COPPA_EXPLAIN }')); ?>

<?php } ?>

	<?php echo (isset($this->_rootref['S_HIDDEN_FIELDS'])) ? $this->_rootref['S_HIDDEN_FIELDS'] : ''; ?><input class="btnmain" type="submit" name="submit" id="submit" value="<?php echo ((isset($this->_rootref['L_SUBMIT'])) ? $this->_rootref['L_SUBMIT'] : ((isset($user->lang['SUBMIT'])) ? $user->lang['SUBMIT'] : '{ SUBMIT }')); ?>" />  <input class="btnlite" type="reset" value="<?php echo ((isset($this->_rootref['L_RESET'])) ? $this->_rootref['L_RESET'] : ((isset($user->lang['RESET'])) ? $user->lang['RESET'] : '{ RESET }')); ?>" name="reset" />

<?php echo (isset($this->_rootref['S_FORM_TOKEN'])) ? $this->_rootref['S_FORM_TOKEN'] : ''; ?>

</form>

<?php $this->_tpl_include('overall_footer.html'); ?>


text:
from shop.models.ordermodel import OrderExtraInfo, Order
from shop.util.order import get_order_from_request

class ShopAPI(object):
    """
    A base-baseclass for shop APIs.

    Both payment and shipping backends need some common functions from the shop
    interface (for example get_order() is useful in both cases). To reduce code
    duplication, theses common methods are defined here and inherited by shop
    interfaces (DRY)

    Another approach would be to stuff everything here, but I think it opens
    up potential to overbloating this one class.
    This is debatable and relatively easy to change later anyway.

    Define all functions common to both the shipping and the payment shop APIs
    here

    PLEASE: When adding functions here please write a short description of
    them in BaseShippingBackend and BasePaymentBackend, future implementers
    thank you :)
    """
    def get_order(self, request):
        """
        Returns the order object for the current shopper.

        This is called from the backend's views as:
        >>> order = self.shop.getOrder(request)
        """
        # it might seem a bit strange to simply forward the call to a helper,
        # but this avoids exposing the shop's internal workings to module
        # writers
        return get_order_from_request(request)

    def add_extra_info(self, order, text):
        """
        Add an extra info text field to the order
        """
        OrderExtraInfo.objects.create(text=text, order=order)

    def is_order_payed(self, order):
        """Whether the passed order is fully payed or not."""
        return order.is_payed()

    def is_order_completed(self, order):
        return order.is_completed()

    def get_order_total(self, order):
        """The total amount to be charged for passed order"""
        return order.order_total

    def get_order_subtotal(self, order):
        """The total amount to be charged for passed order"""
        return order.order_subtotal

    def get_order_short_name(self, order):
        """
        A short name for the order, to be displayed on the payment processor's
        website. Should be human-readable, as much as possible
        """
        return "%s-%s" % (order.id, order.order_total)

    def get_order_unique_id(self, order):
        """
        A unique identifier for this order. This should be our shop's reference
        number. This is sent back by the payment processor when confirming
        payment, for example.
        """
        return order.id

    def get_order_for_id(self, id):
        """
        Get an order for a given ID. Typically, this would be used when the
        backend receives notification from the transaction processor (i.e.
        paypal ipn), with an attached "invoice ID" or "order ID", which should
        then be used to get the shop's order with this method.
        """
        return Order.objects.get(pk=id)


text:
namespace ae
{
	class AssetManager
	{
	private:
		std::map<const std::string, IAssetHandler*> m_Handlers;
	public:
		AssetManager() {}
		~AssetManager() {}

		template<class TYPE>
		TAssetHandler<TYPE>& GetHandler() const {

		}

		IAssetHandler& GetHandler(const std::string id) const {
			return
		}
		void RegisterHandler(IAssetHandler* handler);
		bool LoadAllAssets(void);
	};
}


text:
package com.sun.xml.internal.ws.policy.sourcemodel.attach;

/**
 * Implements utility routines to parse external policy attachments as defined
 * by WS-PolicyAttachment.
 */


text:
<?php namespace WebEd\Plugins\Blog\Repositories;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use WebEd\Base\Models\Contracts\BaseModelContract;
use WebEd\Base\Repositories\Eloquent\EloquentBaseRepository;
use WebEd\Base\Repositories\Eloquent\Traits\EloquentUseSoftDeletes;
use WebEd\Plugins\Blog\Models\Category;
use WebEd\Plugins\Blog\Repositories\Contracts\CategoryRepositoryContract;

/**
 * @property Category|Builder $model
 */
class CategoryRepository extends EloquentBaseRepository implements CategoryRepositoryContract
{
    use EloquentUseSoftDeletes;

    /**
     * @param $id
     * @return array|null
     */
    public function getAllRelatedChildrenIds($id)
    {
        if ($id instanceof Category) {
            $model = $id;
        } else {
            $model = $this->find($id);
        }
        if (!$model) {
            return null;
        }

        $result = [];

        $children = $model->children()->select('id')->get();

        foreach ($children as $child) {
            $result[] = $child->id;
            $result = array_merge($this->getAllRelatedChildrenIds($child), $result);
        }
        return array_unique($result);
    }

    /**
     * @param $id
     * @param bool $justId
     * @return array
     */
    public function getChildren($id, $justId = true)
    {
        if ($id instanceof Category) {
            $model = $id;
        } else {
            $model = $this->find($id);
        }
        if (!$model) {
            return null;
        }

        $children = $model->children();
        if ($justId) {
            return $children->select('id')->get()->pluck('id');
        }
        $children = $children->get();
        $result = [];
        foreach ($children as $child) {
            $result[] = $child;
        }
        return $result;
    }

    /**
     * @param $id
     * @return Category
     */
    public function getParent($id)
    {
        if ($id instanceof Category) {
            $model = $id;
        } else {
            $model = $this->find($id);
        }
        if (!$model) {
            return null;
        }

        return $model->parent()->first();
    }

    /**
     * @param array $data
     * @return int
     */
    public function createCategory(array $data)
    {
        return $this->create($data);
    }

    /**
     * @param int|null|BaseModelContract $id
     * @param array $data
     * @return int
     */
    public function createOrUpdateCategory($id, array $data)
    {
        return $this->createOrUpdate($id, $data);
    }

    /**
     * @param int|null|BaseModelContract $id
     * @param array $data
     * @return int
     */
    public function updateCategory($id, array $data)
    {
        return $this->update($id, $data);
    }

    /**
     * @param int|BaseModelContract|array $id
     * @return bool
     */
    public function deleteCategory($id)
    {
        return $this->delete($id);
    }

    /**
     * @param array $params
     * @param bool $withTrash
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Database\Eloquent\Collection|Collection|mixed
     */
    public function getCategories(array $params, $withTrash = false)
    {
        if ($withTrash) {
            $this->withTrashed();
        }

        return $this->advancedGet($params);
    }
}


text:
include(FindPackageHandleStandardArgs)

if (CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARY)
    set(CryptoPP_FIND_QUIETLY TRUE)
else (CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARY)
    set(CryptoPP_FIND_QUIETLY FALSE)

    find_path (CRYPTOPP_ROOT_DIR
      NAMES cryptopp/cryptlib.h include/cryptopp/cryptlib.h
      PATHS ENV CRYPTOPPROOT
      DOC "CryptoPP root directory")

    find_path (CRYPTOPP_INCLUDE_DIR
      NAMES cryptopp/cryptlib.h
      HINTS ${CRYPTOPP_ROOT_DIR}
      PATH_SUFFIXES include
      DOC "CryptoPP include directory")

    find_library (CRYPTOPP_LIBRARY
      NAMES cryptlib cryptopp
      HINTS ${CRYPTOPP_ROOT_DIR}
      PATH_SUFFIXES lib
      DOC "CryptoPP release library")
endif (CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARY)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(CryptoPP DEFAULT_MSG CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY)
MARK_AS_ADVANCED (CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY)


text:
import React from 'react';
import sinon, { spy } from 'sinon';
import expect from 'expect';
import { shallow, mount, render } from 'enzyme';
import { Navbar } from '../../../components/common/Navbar.jsx';
import { authUser, authUser2, noUser} from '../../testHelper';

let wrapper;
let props;

/**
 *
 * @desc handles the triggering of the necessary action
 * @param {*} isAuth
 * @param {*} authUser
 * @returns {null} returns no value
 *
 */
function setup(isAuth, authUser) {
  props = {
    isAuth,
    authUser,
    logout: spy(() => new Promise((resolve) => { resolve(); }))
  };

  const context = { router: [] };

  return shallow(<Navbar {...props} />, { context });
}

describe('Navbar component', () => {
  let component;

  it('should display the menu items for an admin', () => {
    wrapper = setup(true, authUser);
    expect(wrapper).toExist();
  });

  it('should display the menu items for a regular user', () => {
    wrapper = setup(true, authUser2);
    expect(wrapper).toExist();
  });

  it('should display the menu items for an unauthenticated user', () => {
    wrapper = setup(false, {});
    const input = wrapper.find('a[class="login"]');
    expect(input).toExist();
  });

  it('should logout a user', () => {
    wrapper = setup(true, authUser);
    const input = wrapper.find('#logout');
    input.simulate('click', {
      preventDefault: () => {
      },
      target: { value: 'ade' } });
    expect(props.logout.called).toBe(true);
  });
});


text:
package lu.william.comm;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDate {

	public static SimpleDateFormat ISO8601DATEFORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

	public static String getISOString(Date date) {
		return ISO8601DATEFORMAT.format(date);
	}

}