text:
import os
import flaskr
import unittest
import tempfile

class FlaskrTestCase(unittest.TestCase):

    def setUp(self):
        self.db_fd, flaskr.app.config['DATABASE'] = tempfile.mkstemp()
        flaskr.app.config['TESTING'] = True
        self.app = flaskr.app.test_client()
        flaskr.init_db()

    def tearDown(self):
        os.close(self.db_fd)
        os.unlink(flaskr.app.config['DATABASE'])

    def test_empty_db(self):
        rv = self.app.get('/')
        assert 'No entries here so far' in rv.data

    def login(self, username, password):
        return self.app.post('/login', data=dict(
            username=username,
            password=password
        ), follow_redirects=True)

    def logout(self):
        return self.app.get('/logout', follow_redirects=True)

    def test_login_logout(self):
        rv = self.login('admin', 'admin')
        assert 'You were logged in' in rv.data
        rv = self.logout()
        assert 'You were logged out' in rv.data
        rv = self.login('adminx', 'admin')
        assert 'Invalid username' in rv.data
        rv = self.login('admin', 'defaultx')
        assert 'Invalid password' in rv.data

    def test_messages(self):
        self.login('admin', 'admin')
        rv = self.app.post('/add', data=dict(
            title='<Hello>',
            text='HTML allowed here'
        ), follow_redirects=True)
        assert 'No entries here so far' not in rv.data
        assert '<Hello>' in rv.data
        assert 'HTML allowed here' in rv.data

if __name__ == '__main__':
    unittest.main()


text:
module Plottable.Drawers {
  export class Line extends Drawer {

    constructor(dataset: Dataset) {
      super(dataset);
      this._className = "line";
      this._svgElementName = "path";
    }

    protected _applyDefaultAttributes(selection: d3.Selection<any>) {
      super._applyDefaultAttributes(selection);
      selection.style("fill", "none");
    }

    public selectionForIndex(index: number): d3.Selection<any> {
      return d3.select(this.selection()[0][0]);
    }
  }
}

redpajama_set_name: RedPajamaGithub


text:
/* Licensed under BSD-MIT - see LICENSE file for details */
#ifndef CCAN_LIST_H
#define CCAN_LIST_H
//#define CCAN_LIST_DEBUG 1
#include <stdbool.h>
#include <assert.h>
#include <ccan/str/str.h>
#include <ccan/container_of/container_of.h>
#include <ccan/check_type/check_type.h>

/**
 * struct list_node - an entry in a doubly-linked list
 * @next: next entry (self if empty)
 * @prev: previous entry (self if empty)
 *
 * This is used as an entry in a linked list.
 * Example:
 *	struct child {
 *		const char *name;
 *		// Linked list of all us children.
 *		struct list_node list;
 *	};
 */
struct list_node
{
	struct list_node *next, *prev;
};

/**
 * struct list_head - the head of a doubly-linked list
 * @h: the list_head (containing next and prev pointers)
 *
 * This is used as the head of a linked list.
 * Example:
 *	struct parent {
 *		const char *name;
 *		struct list_head children;
 *		unsigned int num_children;
 *	};
 */
struct list_head
{
	struct list_node n;
};

/**
 * list_check - check head of a list for consistency
 * @h: the list_head
 * @abortstr: the location to print on aborting, or NULL.
 *
 * Because list_nodes have redundant information, consistency checking between
 * the back and forward links can be done.  This is useful as a debugging check.
 * If @abortstr is non-NULL, that will be printed in a diagnostic if the list
 * is inconsistent, and the function will abort.
 *
 * Returns the list head if the list is consistent, NULL if not (it
 * can never return NULL if @abortstr is set).
 *
 * See also: list_check_node()
 *
 * Example:
 *	static void dump_parent(struct parent *p)
 *	{
 *		struct child *c;
 *
 *		printf("%s (%u children):\n", p->name, p->num_children);
 *		list_check(&p->children, "bad child list");
 *		list_for_each(&p->children, c, list)
 *			printf(" -> %s\n", c->name);
 *	}
 */
struct list_head *list_check(const struct list_head *h, const char *abortstr);

/**
 * list_check_node - check node of a list for consistency
 * @n: the list_node
 * @abortstr: the location to print on aborting, or NULL.
 *
 * Check consistency of the list node is in (it must be in one).
 *
 * See also: list_check()
 *
 * Example:
 *	static void dump_child(const struct child *c)
 *	{
 *		list_check_node(&c->list, "bad child list");
 *		printf("%s\n", c->name);
 *	}
 */
struct list_node *list_check_node(const struct list_node *n,
				  const char *abortstr);

#define LIST_LOC __FILE__  ":" stringify(__LINE__)
#ifdef CCAN_LIST_DEBUG
#define list_debug(h, loc) list_check((h), loc)
#define list_debug_node(n, loc) list_check_node((n), loc)
#else
#define list_debug(h, loc) ((void)loc, h)
#define list_debug_node(n, loc) ((void)loc, n)
#endif

/**
 * LIST_HEAD_INIT - initializer for an empty list_head
 * @name: the name of the list.
 *
 * Explicit initializer for an empty list.
 *
 * See also:
 *	LIST_HEAD, list_head_init()
 *
 * Example:
 *	static struct list_head my_list = LIST_HEAD_INIT(my_list);
 */
#define LIST_HEAD_INIT(name) { { &(name).n, &(name).n } }

/**
 * LIST_HEAD - define and initialize an empty list_head
 * @name: the name of the list.
 *
 * The LIST_HEAD macro defines a list_head and initializes it to an empty
 * list.  It can be prepended by "static" to define a static list_head.
 *
 * See also:
 *	LIST_HEAD_INIT, list_head_init()
 *
 * Example:
 *	static LIST_HEAD(my_global_list);
 */
#define LIST_HEAD(name) \
	struct list_head name = LIST_HEAD_INIT(name)

/**
 * list_head_init - initialize a list_head
 * @h: the list_head to set to the empty list
 *
 * Example:
 *	...
 *	struct parent *parent = malloc(sizeof(*parent));
 *
 *	list_head_init(&parent->children);
 *	parent->num_children = 0;
 */
static inline void list_head_init(struct list_head *h)
{
	h->n.next = h->n.prev = &h->n;
}

/**
 * list_node_init - initialize a list_node
 * @n: the list_node to link to itself.
 *
 * You don't need to use this normally!  But it lets you list_del(@n)
 * safely.
 */
static inline void list_node_init(struct list_node *n)
{
	n->next = n->prev = n;
}

/**
 * list_add_after - add an entry after an existing node in a linked list
 * @h: the list_head to add the node to (for debugging)
 * @p: the existing list_node to add the node after
 * @n: the new list_node to add to the list.
 *
 * The existing list_node must already be a member of the list.
 * The new list_node does not need to be initialized; it will be overwritten.
 *
 * Example:
 *	struct child c1, c2, c3;
 *	LIST_HEAD(h);
 *
 *	list_add_tail(&h, &c1.list);
 *	list_add_tail(&h, &c3.list);
 *	list_add_after(&h, &c1.list, &c2.list);
 */
#define list_add_after(h, p, n) list_add_after_(h, p, n, LIST_LOC)
static inline void list_add_after_(struct list_head *h,
				   struct list_node *p,
				   struct list_node *n,
				   const char *abortstr)
{
	n->next = p->next;
	n->prev = p;
	p->next->prev = n;
	p->next = n;
	(void)list_debug(h, abortstr);
}

/**
 * list_add - add an entry at the start of a linked list.
 * @h: the list_head to add the node to
 * @n: the list_node to add to the list.
 *
 * The list_node does not need to be initialized; it will be overwritten.
 * Example:
 *	struct child *child = malloc(sizeof(*child));
 *
 *	child->name = "marvin";
 *	list_add(&parent->children, &child->list);
 *	parent->num_children++;
 */
#define list_add(h, n) list_add_(h, n, LIST_LOC)
static inline void list_add_(struct list_head *h,
			     struct list_node *n,
			     const char *abortstr)
{
	list_add_after_(h, &h->n, n, abortstr);
}

/**
 * list_add_before - add an entry before an existing node in a linked list
 * @h: the list_head to add the node to (for debugging)
 * @p: the existing list_node to add the node before
 * @n: the new list_node to add to the list.
 *
 * The existing list_node must already be a member of the list.
 * The new list_node does not need to be initialized; it will be overwritten.
 *
 * Example:
 *	list_head_init(&h);
 *	list_add_tail(&h, &c1.list);
 *	list_add_tail(&h, &c3.list);
 *	list_add_before(&h, &c3.list, &c2.list);
 */
#define list_add_before(h, p, n) list_add_before_(h, p, n, LIST_LOC)
static inline void list_add_before_(struct list_head *h,
				    struct list_node *p,
				    struct list_node *n,
				    const char *abortstr)
{
	n->next = p;
	n->prev = p->prev;
	p->prev->next = n;
	p->prev = n;
	(void)list_debug(h, abortstr);
}

/**
 * list_add_tail - add an entry at the end of a linked list.
 * @h: the list_head to add the node to
 * @n: the list_node to add to the list.
 *
 * The list_node does not need to be initialized; it will be overwritten.
 * Example:
 *	list_add_tail(&parent->children, &child->list);
 *	parent->num_children++;
 */
#define list_add_tail(h, n) list_add_tail_(h, n, LIST_LOC)
static inline void list_add_tail_(struct list_head *h,
				  struct list_node *n,
				  const char *abortstr)
{
	list_add_before_(h, &h->n, n, abortstr);
}

/**
 * list_empty - is a list empty?
 * @h: the list_head
 *
 * If the list is empty, returns true.
 *
 * Example:
 *	assert(list_empty(&parent->children) == (parent->num_children == 0));
 */
#define list_empty(h) list_empty_(h, LIST_LOC)
static inline bool list_empty_(const struct list_head *h, const char* abortstr)
{
	(void)list_debug(h, abortstr);
	return h->n.next == &h->n;
}

/**
 * list_empty_nodebug - is a list empty (and don't perform debug checks)?
 * @h: the list_head
 *
 * If the list is empty, returns true.
 * This differs from list_empty() in that if CCAN_LIST_DEBUG is set it
 * will NOT perform debug checks. Only use this function if you REALLY
 * know what you're doing.
 *
 * Example:
 *	assert(list_empty_nodebug(&parent->children) == (parent->num_children == 0));
 */
#ifndef CCAN_LIST_DEBUG
#define list_empty_nodebug(h) list_empty(h)
#else
static inline bool list_empty_nodebug(const struct list_head *h)
{
	return h->n.next == &h->n;
}
#endif

/**
 * list_empty_nocheck - is a list empty?
 * @h: the list_head
 *
 * If the list is empty, returns true. This doesn't perform any
 * debug check for list consistency, so it can be called without
 * locks, racing with the list being modified. This is ok for
 * checks where an incorrect result is not an issue (optimized
 * bail out path for example).
 */
static inline bool list_empty_nocheck(const struct list_head *h)
{
	return h->n.next == &h->n;
}

/**
 * list_del - delete an entry from an (unknown) linked list.
 * @n: the list_node to delete from the list.
 *
 * Note that this leaves @n in an undefined state; it can be added to
 * another list, but not deleted again.
 *
 * See also:
 *	list_del_from(), list_del_init()
 *
 * Example:
 *	list_del(&child->list);
 *	parent->num_children--;
 */
#define list_del(n) list_del_(n, LIST_LOC)
static inline void list_del_(struct list_node *n, const char* abortstr)
{
	(void)list_debug_node(n, abortstr);
	n->next->prev = n->prev;
	n->prev->next = n->next;
#ifdef CCAN_LIST_DEBUG
	/* Catch use-after-del. */
	n->next = n->prev = NULL;
#endif
}

/**
 * list_del_init - delete a node, and reset it so it can be deleted again.
 * @n: the list_node to be deleted.
 *
 * list_del(@n) or list_del_init() again after this will be safe,
 * which can be useful in some cases.
 *
 * See also:
 *	list_del_from(), list_del()
 *
 * Example:
 *	list_del_init(&child->list);
 *	parent->num_children--;
 */
#define list_del_init(n) list_del_init_(n, LIST_LOC)
static inline void list_del_init_(struct list_node *n, const char *abortstr)
{
	list_del_(n, abortstr);
	list_node_init(n);
}

/**
 * list_del_from - delete an entry from a known linked list.
 * @h: the list_head the node is in.
 * @n: the list_node to delete from the list.
 *
 * This explicitly indicates which list a node is expected to be in,
 * which is better documentation and can catch more bugs.
 *
 * See also: list_del()
 *
 * Example:
 *	list_del_from(&parent->children, &child->list);
 *	parent->num_children--;
 */
static inline void list_del_from(struct list_head *h, struct list_node *n)
{
#ifdef CCAN_LIST_DEBUG
	{
		/* Thorough check: make sure it was in list! */
		struct list_node *i;
		for (i = h->n.next; i != n; i = i->next)
			assert(i != &h->n);
	}
#endif /* CCAN_LIST_DEBUG */

	/* Quick test that catches a surprising number of bugs. */
	assert(!list_empty(h));
	list_del(n);
}

/**
 * list_swap - swap out an entry from an (unknown) linked list for a new one.
 * @o: the list_node to replace from the list.
 * @n: the list_node to insert in place of the old one.
 *
 * Note that this leaves @o in an undefined state; it can be added to
 * another list, but not deleted/swapped again.
 *
 * See also:
 *	list_del()
 *
 * Example:
 *	struct child x1, x2;
 *	LIST_HEAD(xh);
 *
 *	list_add(&xh, &x1.list);
 *	list_swap(&x1.list, &x2.list);
 */
#define list_swap(o, n) list_swap_(o, n, LIST_LOC)
static inline void list_swap_(struct list_node *o,
			      struct list_node *n,
			      const char* abortstr)
{
	(void)list_debug_node(o, abortstr);
	*n = *o;
	n->next->prev = n;
	n->prev->next = n;
#ifdef CCAN_LIST_DEBUG
	/* Catch use-after-del. */
	o->next = o->prev = NULL;
#endif
}

/**
 * list_entry - convert a list_node back into the structure containing it.
 * @n: the list_node
 * @type: the type of the entry
 * @member: the list_node member of the type
 *
 * Example:
 *	// First list entry is children.next; convert back to child.
 *	child = list_entry(parent->children.n.next, struct child, list);
 *
 * See Also:
 *	list_top(), list_for_each()
 */
#define list_entry(n, type, member) container_of(n, type, member)

/**
 * list_top - get the first entry in a list
 * @h: the list_head
 * @type: the type of the entry
 * @member: the list_node member of the type
 *
 * If the list is empty, returns NULL.
 *
 * Example:
 *	struct child *first;
 *	first = list_top(&parent->children, struct child, list);
 *	if (!first)
 *		printf("Empty list!\n");
 */
#define list_top(h, type, member)					\
	((type *)list_top_((h), list_off_(type, member)))

static inline const void *list_top_(const struct list_head *h, size_t off)
{
	if (list_empty(h))
		return NULL;
	return (const char *)h->n.next - off;
}

/**
 * list_pop - remove the first entry in a list
 * @h: the list_head
 * @type: the type of the entry
 * @member: the list_node member of the type
 *
 * If the list is empty, returns NULL.
 *
 * Example:
 *	struct child *one;
 *	one = list_pop(&parent->children, struct child, list);
 *	if (!one)
 *		printf("Empty list!\n");
 */
#define list_pop(h, type, member)					\
	((type *)list_pop_((h), list_off_(type, member)))

static inline const void *list_pop_(const struct list_head *h, size_t off)
{
	struct list_node *n;

	if (list_empty(h))
		return NULL;
	n = h->n.next;
	list_del(n);
	return (const char *)n - off;
}

/**
 * list_tail - get the last entry in a list
 * @h: the list_head
 * @type: the type of the entry
 * @member: the list_node member of the type
 *
 * If the list is empty, returns NULL.
 *
 * Example:
 *	struct child *last;
 *	last = list_tail(&parent->children, struct child, list);
 *	if (!last)
 *		printf("Empty list!\n");
 */
#define list_tail(h, type, member) \
	((type *)list_tail_((h), list_off_(type, member)))

static inline const void *list_tail_(const struct list_head *h, size_t off)
{
	if (list_empty(h))
		return NULL;
	return (const char *)h->n.prev - off;
}

/**
 * list_for_each - iterate through a list.
 * @h: the list_head (warning: evaluated multiple times!)
 * @i: the structure containing the list_node
 * @member: the list_node member of the structure
 *
 * This is a convenient wrapper to iterate @i over the entire list.  It's
 * a for loop, so you can break and continue as normal.
 *
 * Example:
 *	list_for_each(&parent->children, child, list)
 *		printf("Name: %s\n", child->name);
 */
#define list_for_each(h, i, member)					\
	list_for_each_off(h, i, list_off_var_(i, member))

/**
 * list_for_each_rev - iterate through a list backwards.
 * @h: the list_head
 * @i: the structure containing the list_node
 * @member: the list_node member of the structure
 *
 * This is a convenient wrapper to iterate @i over the entire list.  It's
 * a for loop, so you can break and continue as normal.
 *
 * Example:
 *	list_for_each_rev(&parent->children, child, list)
 *		printf("Name: %s\n", child->name);
 */
#define list_for_each_rev(h, i, member)					\
	list_for_each_rev_off(h, i, list_off_var_(i, member))

/**
 * list_for_each_rev_safe - iterate through a list backwards,
 * maybe during deletion
 * @h: the list_head
 * @i: the structure containing the list_node
 * @nxt: the structure containing the list_node
 * @member: the list_node member of the structure
 *
 * This is a convenient wrapper to iterate @i over the entire list backwards.
 * It's a for loop, so you can break and continue as normal.  The extra
 * variable * @nxt is used to hold the next element, so you can delete @i
 * from the list.
 *
 * Example:
 *	struct child *next;
 *	list_for_each_rev_safe(&parent->children, child, next, list) {
 *		printf("Name: %s\n", child->name);
 *	}
 */
#define list_for_each_rev_safe(h, i, nxt, member)			\
	list_for_each_rev_safe_off(h, i, nxt, list_off_var_(i, member))

/**
 * list_for_each_safe - iterate through a list, maybe during deletion
 * @h: the list_head
 * @i: the structure containing the list_node
 * @nxt: the structure containing the list_node
 * @member: the list_node member of the structure
 *
 * This is a convenient wrapper to iterate @i over the entire list.  It's
 * a for loop, so you can break and continue as normal.  The extra variable
 * @nxt is used to hold the next element, so you can delete @i from the list.
 *
 * Example:
 *	list_for_each_safe(&parent->children, child, next, list) {
 *		list_del(&child->list);
 *		parent->num_children--;
 *	}
 */
#define list_for_each_safe(h, i, nxt, member)				\
	list_for_each_safe_off(h, i, nxt, list_off_var_(i, member))

/**
 * list_next - get the next entry in a list
 * @h: the list_head
 * @i: a pointer to an entry in the list.
 * @member: the list_node member of the structure
 *
 * If @i was the last entry in the list, returns NULL.
 *
 * Example:
 *	struct child *second;
 *	second = list_next(&parent->children, first, list);
 *	if (!second)
 *		printf("No second child!\n");
 */
#define list_next(h, i, member)						\
	((list_typeof(i))list_entry_or_null(list_debug(h,		\
					    __FILE__ ":" stringify(__LINE__)), \
					    (i)->member.next,		\
					    list_off_var_((i), member)))

/**
 * list_prev - get the previous entry in a list
 * @h: the list_head
 * @i: a pointer to an entry in the list.
 * @member: the list_node member of the structure
 *
 * If @i was the first entry in the list, returns NULL.
 *
 * Example:
 *	first = list_prev(&parent->children, second, list);
 *	if (!first)
 *		printf("Can't go back to first child?!\n");
 */
#define list_prev(h, i, member)						\
	((list_typeof(i))list_entry_or_null(list_debug(h,		\
					    __FILE__ ":" stringify(__LINE__)), \
					    (i)->member.prev,		\
					    list_off_var_((i), member)))

/**
 * list_append_list - empty one list onto the end of another.
 * @to: the list to append into
 * @from: the list to empty.
 *
 * This takes the entire contents of @from and moves it to the end of
 * @to.  After this @from will be empty.
 *
 * Example:
 *	struct list_head adopter;
 *
 *	list_append_list(&adopter, &parent->children);
 *	assert(list_empty(&parent->children));
 *	parent->num_children = 0;
 */
#define list_append_list(t, f) list_append_list_(t, f,			\
				   __FILE__ ":" stringify(__LINE__))
static inline void list_append_list_(struct list_head *to,
				     struct list_head *from,
				     const char *abortstr)
{
	struct list_node *from_tail = list_debug(from, abortstr)->n.prev;
	struct list_node *to_tail = list_debug(to, abortstr)->n.prev;

	/* Sew in head and entire list. */
	to->n.prev = from_tail;
	from_tail->next = &to->n;
	to_tail->next = &from->n;
	from->n.prev = to_tail;

	/* Now remove head. */
	list_del(&from->n);
	list_head_init(from);
}

/**
 * list_prepend_list - empty one list into the start of another.
 * @to: the list to prepend into
 * @from: the list to empty.
 *
 * This takes the entire contents of @from and moves it to the start
 * of @to.  After this @from will be empty.
 *
 * Example:
 *	list_prepend_list(&adopter, &parent->children);
 *	assert(list_empty(&parent->children));
 *	parent->num_children = 0;
 */
#define list_prepend_list(t, f) list_prepend_list_(t, f, LIST_LOC)
static inline void list_prepend_list_(struct list_head *to,
				      struct list_head *from,
				      const char *abortstr)
{
	struct list_node *from_tail = list_debug(from, abortstr)->n.prev;
	struct list_node *to_head = list_debug(to, abortstr)->n.next;

	/* Sew in head and entire list. */
	to->n.next = &from->n;
	from->n.prev = &to->n;
	to_head->prev = from_tail;
	from_tail->next = to_head;

	/* Now remove head. */
	list_del(&from->n);
	list_head_init(from);
}

/* internal macros, do not use directly */
#define list_for_each_off_dir_(h, i, off, dir)				\
	for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.dir,	\
				   (off));				\
	list_node_from_off_((void *)i, (off)) != &(h)->n;		\
	i = list_node_to_off_(list_node_from_off_((void *)i, (off))->dir, \
			      (off)))

#define list_for_each_safe_off_dir_(h, i, nxt, off, dir)		\
	for (i = list_node_to_off_(list_debug(h, LIST_LOC)->n.dir,	\
				   (off)),				\
	nxt = list_node_to_off_(list_node_from_off_(i, (off))->dir,	\
				(off));					\
	list_node_from_off_(i, (off)) != &(h)->n;			\
	i = nxt,							\
	nxt = list_node_to_off_(list_node_from_off_(i, (off))->dir,	\
				(off)))

/**
 * list_for_each_off - iterate through a list of memory regions.
 * @h: the list_head
 * @i: the pointer to a memory region wich contains list node data.
 * @off: offset(relative to @i) at which list node data resides.
 *
 * This is a low-level wrapper to iterate @i over the entire list, used to
 * implement all oher, more high-level, for-each constructs. It's a for loop,
 * so you can break and continue as normal.
 *
 * WARNING! Being the low-level macro that it is, this wrapper doesn't know
 * nor care about the type of @i. The only assumption made is that @i points
 * to a chunk of memory that at some @offset, relative to @i, contains a
 * properly filled `struct list_node' which in turn contains pointers to
 * memory chunks and it's turtles all the way down. With all that in mind
 * remember that given the wrong pointer/offset couple this macro will
 * happily churn all you memory until SEGFAULT stops it, in other words
 * caveat emptor.
 *
 * It is worth mentioning that one of legitimate use-cases for that wrapper
 * is operation on opaque types with known offset for `struct list_node'
 * member(preferably 0), because it allows you not to disclose the type of
 * @i.
 *
 * Example:
 *	list_for_each_off(&parent->children, child,
 *				offsetof(struct child, list))
 *		printf("Name: %s\n", child->name);
 */
#define list_for_each_off(h, i, off)                                    \
	list_for_each_off_dir_((h),(i),(off),next)

/**
 * list_for_each_rev_off - iterate through a list of memory regions backwards
 * @h: the list_head
 * @i: the pointer to a memory region wich contains list node data.
 * @off: offset(relative to @i) at which list node data resides.
 *
 * See list_for_each_off for details
 */
#define list_for_each_rev_off(h, i, off)                                    \
	list_for_each_off_dir_((h),(i),(off),prev)

/**
 * list_for_each_safe_off - iterate through a list of memory regions, maybe
 * during deletion
 * @h: the list_head
 * @i: the pointer to a memory region wich contains list node data.
 * @nxt: the structure containing the list_node
 * @off: offset(relative to @i) at which list node data resides.
 *
 * For details see `list_for_each_off' and `list_for_each_safe'
 * descriptions.
 *
 * Example:
 *	list_for_each_safe_off(&parent->children, child,
 *		next, offsetof(struct child, list))
 *		printf("Name: %s\n", child->name);
 */
#define list_for_each_safe_off(h, i, nxt, off)                          \
	list_for_each_safe_off_dir_((h),(i),(nxt),(off),next)

/**
 * list_for_each_rev_safe_off - iterate backwards through a list of
 * memory regions, maybe during deletion
 * @h: the list_head
 * @i: the pointer to a memory region wich contains list node data.
 * @nxt: the structure containing the list_node
 * @off: offset(relative to @i) at which list node data resides.
 *
 * For details see `list_for_each_rev_off' and `list_for_each_rev_safe'
 * descriptions.
 *
 * Example:
 *	list_for_each_rev_safe_off(&parent->children, child,
 *		next, offsetof(struct child, list))
 *		printf("Name: %s\n", child->name);
 */
#define list_for_each_rev_safe_off(h, i, nxt, off)                      \
	list_for_each_safe_off_dir_((h),(i),(nxt),(off),prev)

/* Other -off variants. */
#define list_entry_off(n, type, off)		\
	((type *)list_node_from_off_((n), (off)))

#define list_head_off(h, type, off)		\
	((type *)list_head_off((h), (off)))

#define list_tail_off(h, type, off)		\
	((type *)list_tail_((h), (off)))

#define list_add_off(h, n, off)                 \
	list_add((h), list_node_from_off_((n), (off)))

#define list_del_off(n, off)                    \
	list_del(list_node_from_off_((n), (off)))

#define list_del_from_off(h, n, off)			\
	list_del_from(h, list_node_from_off_((n), (off)))

/* Offset helper functions so we only single-evaluate. */
static inline void *list_node_to_off_(struct list_node *node, size_t off)
{
	return (void *)((char *)node - off);
}
static inline struct list_node *list_node_from_off_(void *ptr, size_t off)
{
	return (struct list_node *)((char *)ptr + off);
}

/* Get the offset of the member, but make sure it's a list_node. */
#define list_off_(type, member)					\
	(container_off(type, member) +				\
	 check_type(((type *)0)->member, struct list_node))

#define list_off_var_(var, member)			\
	(container_off_var(var, member) +		\
	 check_type(var->member, struct list_node))

#if HAVE_TYPEOF
#define list_typeof(var) typeof(var)
#else
#define list_typeof(var) void *
#endif

/* Returns member, or NULL if at end of list. */
static inline void *list_entry_or_null(const struct list_head *h,
				       const struct list_node *n,
				       size_t off)
{
	if (n == &h->n)
		return NULL;
	return (char *)n - off;
}
#endif /* CCAN_LIST_H */


text:
package edu.tamu.tcat.visualpage.wcsa.pairtree;

/**
 *  Represents a HathiTrust item identifier and parse
 *
 */
public class ItemIdentifier
{

   public ItemIdentifier()
   {
      // TODO Auto-generated constructor stub
   }

}


text:
<?php namespace spec\BX\Engine\Render;
use PhpSpec\Exception\Example\FailureException;
use PhpSpec\ObjectBehavior;

class HamlRenderSpec extends ObjectBehavior
{
	use \BX\FileSystem\FileSystemTrait,
	 \BX\Config\ConfigTrait;
	private $store;
	function let()
	{
		$this->store = $this->config()->all();
		$store = [
			'templating' => [
				'engine'	 => 'php',
				'php'		 => __DIR__.'/data',
				'haml'		 => __DIR__.'/data',
				'doc_root'	 => __DIR__.'/data',
			],
		];
		$this->config()->init('array',$store);
	}
	function letgo()
	{
		$this->config()->init('array',$this->store);
	}
	function it_is_initializable()
	{
		$this->shouldHaveType('BX\Engine\Render\HamlRender');
	}
	function it_render()
	{
		$dir = __DIR__.'/data/css';
		if (is_dir($dir)){
			$this->filesystem()->removePathDir($dir);
		}
		ob_start();
		$this->render([],'index',['a' => 'A'])->shouldBe(true);
		$content = ob_get_contents();
		ob_end_clean();
		if ($content !== '12345 TEST A'){
			throw new FailureException("Bad content: $content");
		}
		if (!file_exists(__DIR__.'/data/css/index.css')){
			throw new FailureException("Css is not generate");
		}
	}
}


text:
[![Build Status](https://travis-ci.org/UKHomeOffice/kb8or.svg?branch=master)](https://travis-ci.org/UKHomeOffice/kb8or)

Continuous Deployment Tool for deploying with [Kubernetes](http://kubernetes.io/).

## Features
1. Will deploy any Kubernetes YAML files by creating / re-creating or do rolling update as required
2. Monitors for success (including restarts) of applications (where [kubectl client](http://kubernetes.io/v1.0/docs/getting-started-guides/aws/kubectl.html) doesn't).
3. Reports on failures and display logs and errors for failing resources
3. Container images AND resource version management
4. Application environment specific variables (for deployments to dev, pre-prod, production)

## Pre-requisites
1. A running Kubernetes cluster
2. Either
   1. [Ruby](https://www.ruby-lang.org/en/documentation/installation/) 2.x, bundler, [kubectl client](http://kubernetes.io/v1.0/docs/getting-started-guides/aws/kubectl.html) client.
   2. [Docker](#docker-prerequisites).

## Install (if not using Docker)

1. Download the [kubectl client](http://kubernetes.io/v1.0/docs/getting-started-guides/aws/kubectl.html).
2. `bundle install`

## Usage

### Schema

All features and configurable options are described in the [Schema Documentation](./docs/schema.md).

### As a container:
`docker run -it --rm -v ${PWD}:/var/lib/deploy quay.io/ukhomeofficedigital/kb8or --help`

### Locally:
`./kb8or.rb --help`

### Deploy an 'environment':

Deploy to "default" environment (usually vagrant):
`./kb8or.rb mydeploy.yaml`

Deploy to specific environment:
`./kb8or.rb mydeploy.yaml --env pre-production`

A deployment will do the following:

1. Any (defaults.yaml) will be loaded (from the same directory as the deployment)
2. Any environment data will then be parsed (based on EnvFileGlobPath set in config)
3. Each deploy will be loaded and settings will be updated
4. kubectl will be used to setup the Kb8or specific context settings (typically set per environment)
4. Any Kubernetes .yaml files in the path specified will be parsed and deployed / updated as required.

### Examples:

* For a walk through of features see [docs/example/Example.md](docs/example/Example.md).
* Example of creation of multiple ResourceControllers from a [templated Elasticsearch](docs/example/elasticsearch/Example.md) resource.

## Docker-prerequisites

In order to run this in a container you'll need docker installed:

* [Windows](https://docs.docker.com/windows/started)
* [OS X](https://docs.docker.com/mac/started/)
* [Linux](https://docs.docker.com/linux/started/)

It is currently hosted here: https://quay.io/repository/ukhomeofficedigital/kb8or

## Contributing

Feel free to submit pull requests and issues. If it's a particularly large PR, you may wish to discuss it in an issue first.

Please note that this project is released with a [Contributor Code of Conduct](CONTRIBUTING.md).
By participating in this project you agree to abide by its terms.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).

To create a new version:

1. update the [version](version) file.
2. Push a tag of the same version name to build Docker image at https://quay.io/repository/ukhomeofficedigital/kb8or

## Authors

* **Lewis Marshall** - *Initial work* - [Lewis Marshall](https://github.com/lewismarshall)

See also the list of [contributors](https://github.com/UKHomeOffice/kb8or/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

* [Kubernetes](http://kubernetes.io/)


text:
$(document).ready(function() {
                var dataTable = $('#show_divisi').DataTable( {
                    "processing": true,
                    "serverSide": true,
                    "columnDefs":[{
                        "targets": 0,
                        "orderable":false,
                        "searchable":false
                    }],
                    "ajax":{
                        url :"ajax/data_divisi.php",
                        type: "post",
                        error: function(){
                            $(".show_divisi-error").html("");
                            $("#show_divisi").append('

Data Tidak Di temukan

');
                            $("#show_divisi_processing").css("display","none");
                        }
                    }

                } );

                $("#bulkDelete").on('click',function() { // bulk checked
                    var status = this.checked;
                    $(".deleteRow").each( function() {
                        $(this).prop("checked",status);
                    });
                });

                $('#deleteTriger').on("click", function(event){ // triggering delete one by one
                    if( $('.deleteRow:checked').length > 0 ){  // at-least one checkbox checked
                        var ids = [];
                        $('.deleteRow').each(function(){
                            if($(this).is(':checked')) {
                                ids.push($(this).val());
                            }
                        // console.log(ids);
                        });
                        var ids_string = ids.toString();  // array to string conversion
                        // console.log(ids_string);
                        $.ajax({
                            type: "POST",
                            url: "ajax/deleteRecord.php",
                            data: {data_ids:ids_string},
                            success: function(result) {
                                dataTable.draw(); // redrawing datatable
                            },
                            async:false
                        });

                    }
                });
            } );

// Add Record from database script
function addRecord() {
    var divisi_name = $("#divisi_name").val();

    $.post("ajax/addRecords.php",{
        divisi_name: divisi_name
    }, function (data, status){
        $("#modalLayout").modal("hide");

        readRecord();

        $("#divisi_name").val("");
    });
}

// Reload DataTables After insert Form
function readRecord() {
    var table = $('#show_divisi').DataTable();

    table.ajax.reload(function (json){
        $('#add').val( json.lastInput );
    });
}

//Get Detail record row datatables
function getDetailDivisi(id_divisi){
   // alert(id_divisi);
   $("#user_id_hidden").val(id_divisi);
   $.post("ajax/readUserDetail.php", {
        id_divisi: id_divisi
   },
    function (data, status){
        // parser JSON data
        var divisi = JSON.parse(data);
        $("#divisi_name_update").val(divisi.divisi_name);
    }
   );
$("#update_user_modal").modal("show");

}

// update Record row datatables
function updateDivisi(){

    // get value to modal
    var divisi_name = $("#divisi_name_update").val();
    // get hidden id value
    var id_divisi = $("#user_id_hidden").val();

    // send to proses update
    $.post("ajax/updateDivisiName.php",{
        id_divisi: id_divisi,
        divisi_name: divisi_name
    },
    function (data, status){
        $("#update_user_modal").modal("hide");
        readRecord();
    }
    );
}

$(document).ready(function () {

    readRecord();
});


text: #include <modules/meshrenderinggl/datastructures/transformedrasterization.h>


text:
#ifndef XBB_TRANSPOSE_H
#define XBB_TRANSPOSE_H

#include "Base.h"
#include "ReducedMatrix.h"

namespace xbb {

    template <typename TransformT> struct Transpose;

    template <
        InverseProvision InverseT,
        typename TransformT>
    struct TransposeInverseProvider
    {
        static const InverseProvision inverseProvision = InverseDeprived;
    };

    template <typename TransformT>
    struct TransposeInverseProvider<InverseProvided, TransformT>
    {
        static const InverseProvision inverseProvision = InverseProvided;

        typedef Transpose<typename TransformT::InverseType> InverseType;

        InverseType
        inverse() const
        {
            typedef Transpose<TransformT> Derived;
            const Derived & d = static_cast<const Derived &>(*this);

            return InverseType(d.transform.inverse());
        }
    };

    template <typename TransformT>
    struct Transpose
        : public Base<Transpose<TransformT> >
        , public TransposeInverseProvider<TransformT::inverseProvision, TransformT >
    {
        Transpose()
        {
            // uninitialized
        }

        Transpose(const TransformT &aTransform)
        : transform(aTransform)
        {
        }

        TransformT transform;

        TransformT
        transpose() const
        {
            return transform;
        }

        // transposed constancy
        static const Constancy c00 = TransformT::c00;
        static const Constancy c01 = TransformT::c10;
        static const Constancy c02 = TransformT::c20;
        static const Constancy c03 = TransformT::c30;

        static const Constancy c10 = TransformT::c01;
        static const Constancy c11 = TransformT::c11;
        static const Constancy c12 = TransformT::c21;
        static const Constancy c13 = TransformT::c31;

        static const Constancy c20 = TransformT::c02;
        static const Constancy c21 = TransformT::c12;
        static const Constancy c22 = TransformT::c22;
        static const Constancy c23 = TransformT::c32;

        static const Constancy c30 = TransformT::c03;
        static const Constancy c31 = TransformT::c13;
        static const Constancy c32 = TransformT::c23;
        static const Constancy c33 = TransformT::c33;

        typedef ReducedMatrix
        <
            c00, c01, c02, c03,
            c10, c11, c12, c13,
            c20, c21, c22, c23,
            c30, c31, c32, c33
        > ReducedType;

        ReducedType reduce() const
        {
            const auto t = transform.reduce();

            ReducedType r;

            r.template setByTranspose<0,0>(t);
            r.template setByTranspose<0,1>(t);
            r.template setByTranspose<0,2>(t);
            r.template setByTranspose<0,3>(t);

            r.template setByTranspose<1,0>(t);
            r.template setByTranspose<1,1>(t);
            r.template setByTranspose<1,2>(t);
            r.template setByTranspose<1,3>(t);

            r.template setByTranspose<2,0>(t);
            r.template setByTranspose<2,1>(t);
            r.template setByTranspose<2,2>(t);
            r.template setByTranspose<2,3>(t);

            r.template setByTranspose<3,0>(t);
            r.template setByTranspose<3,1>(t);
            r.template setByTranspose<3,2>(t);
            r.template setByTranspose<3,3>(t);

            return r;
        }

        template <typename UserMatrixTypeT>
        void to(UserMatrixTypeT &aMat) const
        {
            const auto r = reduce();

            MatrixValuesTo<UserMatrixTypeT>::e00(aMat, r.e00());
            MatrixValuesTo<UserMatrixTypeT>::e01(aMat, r.e01());
            MatrixValuesTo<UserMatrixTypeT>::e02(aMat, r.e02());
            MatrixValuesTo<UserMatrixTypeT>::e03(aMat, r.e03());

            MatrixValuesTo<UserMatrixTypeT>::e10(aMat, r.e10());
            MatrixValuesTo<UserMatrixTypeT>::e11(aMat, r.e11());
            MatrixValuesTo<UserMatrixTypeT>::e12(aMat, r.e12());
            MatrixValuesTo<UserMatrixTypeT>::e13(aMat, r.e13());

            MatrixValuesTo<UserMatrixTypeT>::e20(aMat, r.e20());
            MatrixValuesTo<UserMatrixTypeT>::e21(aMat, r.e21());
            MatrixValuesTo<UserMatrixTypeT>::e22(aMat, r.e22());
            MatrixValuesTo<UserMatrixTypeT>::e23(aMat, r.e23());

            MatrixValuesTo<UserMatrixTypeT>::e30(aMat, r.e30());
            MatrixValuesTo<UserMatrixTypeT>::e31(aMat, r.e31());
            MatrixValuesTo<UserMatrixTypeT>::e32(aMat, r.e32());
            MatrixValuesTo<UserMatrixTypeT>::e33(aMat, r.e33());
        }

        // To explicitly cast down to a 4x3 ignoring extra elements
        // versus requiring them to match Identity
        template <typename UserMatrixTypeT>
        void to4x3(UserMatrixTypeT &aMat) const
        {
            const auto r = reduce();
            // Purposefully ignore d.e03(), d.e13(), d.e23(), d.e33()

            MatrixValuesTo<UserMatrixTypeT>::e00(aMat, r.e00());
            MatrixValuesTo<UserMatrixTypeT>::e01(aMat, r.e01());
            MatrixValuesTo<UserMatrixTypeT>::e02(aMat, r.e02());

            MatrixValuesTo<UserMatrixTypeT>::e10(aMat, r.e10());
            MatrixValuesTo<UserMatrixTypeT>::e11(aMat, r.e11());
            MatrixValuesTo<UserMatrixTypeT>::e12(aMat, r.e12());

            MatrixValuesTo<UserMatrixTypeT>::e20(aMat, r.e20());
            MatrixValuesTo<UserMatrixTypeT>::e21(aMat, r.e21());
            MatrixValuesTo<UserMatrixTypeT>::e22(aMat, r.e22());

            MatrixValuesTo<UserMatrixTypeT>::e30(aMat, r.e30());
            MatrixValuesTo<UserMatrixTypeT>::e31(aMat, r.e31());
            MatrixValuesTo<UserMatrixTypeT>::e32(aMat, r.e32());
        }

        // To explicitly cast down to a 3x3 ignoring extra elements
        // versus requiring them to match Identity
        template <typename UserMatrixTypeT>
        void to3x3(UserMatrixTypeT &aMat) const
        {
            const auto r = reduce();
            // Purposefully ignore d.e03(), d.e13(), d.e23(), d.e30(), d.e31(),
            // d.e32(), d.e32(), d.e33()

            MatrixValuesTo<UserMatrixTypeT>::e00(aMat, r.e00());
            MatrixValuesTo<UserMatrixTypeT>::e01(aMat, r.e01());
            MatrixValuesTo<UserMatrixTypeT>::e02(aMat, r.e02());

            MatrixValuesTo<UserMatrixTypeT>::e10(aMat, r.e10());
            MatrixValuesTo<UserMatrixTypeT>::e11(aMat, r.e11());
            MatrixValuesTo<UserMatrixTypeT>::e12(aMat, r.e12());

            MatrixValuesTo<UserMatrixTypeT>::e20(aMat, r.e20());
            MatrixValuesTo<UserMatrixTypeT>::e21(aMat, r.e21());
            MatrixValuesTo<UserMatrixTypeT>::e22(aMat, r.e22());
        }

    };

} // namespace xbb

#endif // XBB_TRANSPOSE_H


text:
package carsmart.upgrade.manager.sample;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import carsmart.upgrade.manager.OnConfirmUpgradeListener;
import carsmart.upgrade.manager.Upgrade;
import carsmart.upgrade.manager.UpgradeConfig;
import carsmart.upgrade.manager.UpgradeManager;
import carsmart.upgrade.manager.download.DownloadPath;
import carsmart.upgrade.manager.interceptor.DialogInterceptor;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        assert fab != null;
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                upgradeVersion();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    String url = "http://pkg3.fir.im/3bb68550c4aa15fa92841de39aad36eb2133286e.apk";

    public void upgradeVersion() {
        UpgradeManager upgradeManager = new UpgradeManager(new UpgradeConfig.Builder()
                .setDialogInterceptor(interceptor)
                .setAutoInstall(true)
                .setDownloadPath(new DownloadPath("Download", "upgrade-sample.apk"))
                .setContext(MainActivity.this).create());

        upgradeManager.setUpgrade(createUpgrade());

    }

    Upgrade createUpgrade() {
        Upgrade upgrade = new Upgrade();
        upgrade.url = url;
        upgrade.isForce = false;
        upgrade.prompt = "App升级";
        return upgrade;
    }

    DialogInterceptor interceptor = new DialogInterceptor() {
        @Override
        public Dialog intercept(final Upgrade upgrade, final OnConfirmUpgradeListener listener) {
            return new AlertDialog.Builder(MainActivity.this)
                    .setMessage("自定义升级对话框")
                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            listener.onUpgrade(upgrade.url);
                        }
                    })
                    .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    }).create();
        }
    };

}


text:
SkColor GetInfoBarTopColor(InfoBarDelegate::Type infobar_type) {
  static const SkColor kWarningBackgroundColorTop =
      SkColorSetRGB(255, 242, 183);  // Yellow
  static const SkColor kPageActionBackgroundColorTop =
      SkColorSetRGB(237, 237, 237);  // Gray
  return (infobar_type == InfoBarDelegate::WARNING_TYPE) ?
      kWarningBackgroundColorTop : kPageActionBackgroundColorTop;
}

SkColor GetInfoBarBottomColor(InfoBarDelegate::Type infobar_type) {
  static const SkColor kWarningBackgroundColorBottom =
      SkColorSetRGB(250, 230, 145);  // Yellow
  static const SkColor kPageActionBackgroundColorBottom =
      SkColorSetRGB(217, 217, 217);  // Gray
  return (infobar_type == InfoBarDelegate::WARNING_TYPE) ?
      kWarningBackgroundColorBottom : kPageActionBackgroundColorBottom;
}

// TODO(pkasting): Port Mac to use this.
#if defined(TOOLKIT_VIEWS) || defined(TOOLKIT_GTK) || defined(OS_ANDROID)

InfoBar::InfoBar(InfoBarService* owner, InfoBarDelegate* delegate)
    : owner_(owner),
      delegate_(delegate),
      container_(NULL),
      animation_(this),
      arrow_height_(0),
      arrow_target_height_(kDefaultArrowTargetHeight),
      arrow_half_width_(0),
      bar_height_(0),
      bar_target_height_(kDefaultBarTargetHeight) {
  DCHECK(owner_ != NULL);
  DCHECK(delegate_ != NULL);
  animation_.SetTweenType(ui::Tween::LINEAR);
}

InfoBar::~InfoBar() {
}

void InfoBar::Show(bool animate) {
  PlatformSpecificShow(animate);
  if (animate) {
    animation_.Show();
  } else {
    animation_.Reset(1.0);
    RecalculateHeights(true);
  }
}

void InfoBar::Hide(bool animate) {
  PlatformSpecificHide(animate);
  if (animate) {
    animation_.Hide();
  } else {
    animation_.Reset(0.0);
    // We want to remove ourselves from the container immediately even if we
    // still have an owner, which MaybeDelete() won't do.
    DCHECK(container_);
    container_->RemoveInfoBar(this);
    MaybeDelete();  // Necessary if the infobar was already closing.
  }
}

void InfoBar::SetArrowTargetHeight(int height) {
  DCHECK_LE(height, kMaximumArrowTargetHeight);
  // Once the closing animation starts, we ignore further requests to change the
  // target height.
  if ((arrow_target_height_ != height) && !animation_.IsClosing()) {
    arrow_target_height_ = height;
    RecalculateHeights(false);
  }
}

void InfoBar::CloseSoon() {
  owner_ = NULL;
  PlatformSpecificOnCloseSoon();
  MaybeDelete();
}

void InfoBar::AnimationProgressed(const ui::Animation* animation) {
  RecalculateHeights(false);
}

void InfoBar::RemoveSelf() {
  // |owner_| should never be NULL here.  If it is, then someone violated what
  // they were supposed to do -- e.g. a ConfirmInfoBarDelegate subclass returned
  // true from Accept() or Cancel() even though the infobar was already closing.
  // In the worst case, if we also switched tabs during that process, then
  // |this| has already been destroyed.  But if that's the case, then we're
  // going to deref a garbage |this| pointer here whether we check |owner_| or
  // not, and in other cases (where we're still closing and |this| is valid),
  // checking |owner_| here will avoid a NULL deref.
  if (owner_)
    owner_->RemoveInfoBar(delegate_);
}

void InfoBar::SetBarTargetHeight(int height) {
  if (bar_target_height_ != height) {
    bar_target_height_ = height;
    RecalculateHeights(false);
  }
}

int InfoBar::OffsetY(const gfx::Size& prefsize) const {
  return arrow_height_ +
      std::max((bar_target_height_ - prefsize.height()) / 2, 0) -
      (bar_target_height_ - bar_height_);
}

void InfoBar::AnimationEnded(const ui::Animation* animation) {
  // When the animation ends, we must ensure the container is notified even if
  // the heights haven't changed, lest it never get an "animation finished"
  // notification.  (If the browser doesn't get this notification, it will not
  // bother to re-layout the content area for the new infobar size.)
  RecalculateHeights(true);
  MaybeDelete();
}

void InfoBar::RecalculateHeights(bool force_notify) {
  int old_arrow_height = arrow_height_;
  int old_bar_height = bar_height_;

  // Find the desired arrow height/half-width.  The arrow area is
  // |arrow_height_| * |arrow_half_width_|.  When the bar is opening or closing,
  // scaling each of these with the square root of the animation value causes a
  // linear animation of the area, which matches the perception of the animation
  // of the bar portion.
  double scale_factor = sqrt(animation_.GetCurrentValue());
  arrow_height_ = static_cast<int>(arrow_target_height_ * scale_factor);
  if (animation_.is_animating()) {
    arrow_half_width_ = static_cast<int>(std::min(arrow_target_height_,
        kMaximumArrowTargetHalfWidth) * scale_factor);
  } else {
    // When the infobar is not animating (i.e. fully open), we set the
    // half-width to be proportionally the same distance between its default and
    // maximum values as the height is between its.
    arrow_half_width_ = kDefaultArrowTargetHalfWidth +
        ((kMaximumArrowTargetHalfWidth - kDefaultArrowTargetHalfWidth) *
         ((arrow_height_ - kDefaultArrowTargetHeight) /
          (kMaximumArrowTargetHeight - kDefaultArrowTargetHeight)));
  }
  // Add pixels for the stroke, if the arrow is to be visible at all.  Without
  // this, changing the arrow height from 0 to kSeparatorLineHeight would
  // produce no visible effect, because the stroke would paint atop the divider
  // line above the infobar.
  if (arrow_height_)
    arrow_height_ += kSeparatorLineHeight;

  bar_height_ = animation_.CurrentValueBetween(0, bar_target_height_);

  // Don't re-layout if nothing has changed, e.g. because the animation step was
  // not large enough to actually change the heights by at least a pixel.
  bool heights_differ =
      (old_arrow_height != arrow_height_) || (old_bar_height != bar_height_);
  if (heights_differ)
    PlatformSpecificOnHeightsRecalculated();

  if (container_ && (heights_differ || force_notify))
    container_->OnInfoBarStateChanged(animation_.is_animating());
}

void InfoBar::MaybeDelete() {
  if (!owner_ && delegate_ && (animation_.GetCurrentValue() == 0.0)) {
    if (container_)
      container_->RemoveInfoBar(this);
    delete delegate_;
    delegate_ = NULL;
  }
}

#endif  // TOOLKIT_VIEWS || TOOLKIT_GTK || OS_ANDROID


text:
<?php

    header('Content-Type: application/json');

    require_once "../init.php";
    require_once "../classes/bubblesort.php";

    $bubblesort = new bubblesort(0, 100, 'red', 'yellow');

    $response = null;
    $response['status'] = 'Success';

    switch ($_POST['method'])
    {
        case 'getShuffle': // Shuffles the values and returns the result

            $shuffled = $bubblesort->getShuffled();

            $response['data'] = $shuffled;
            $_SESSION['bubblesort'] = $shuffled;

            break;
        case 'get': // Returns the values, if session is not set, shuffle them first

            $response = null;
            $response['status'] = 'Success';

            if (isset($_SESSION['bubblesort'])) // The data is saved in the session, return it
            {
                $response['data'] = $_SESSION['bubblesort'];
            }
            else // Session is empty, regenerate randomized values
            {
                $shuffled = $bubblesort->getShuffled();

                $response['data'] = $shuffled;
                $_SESSION['bubblesort'] = $shuffled;
            }

            break;

        case 'getStep': // Does one step then returns the values

            if (isset($_SESSION['bubblesort']))  // The data is saved in the session, do one more step
            {
                $shuffled = $bubblesort->getStep($_SESSION['bubblesort']);

                $response['data'] = $shuffled;
                $_SESSION['bubblesort'] = $shuffled;
            }
            else // Session is empty, regenerate randomized values
            {
                $shuffled = $bubblesort->getShuffled();

                $response['data'] = $shuffled;
                $_SESSION['bubblesort'] = $shuffled;
            }

            break;

        default: // Incorrect method name called, return relevant error
            $response = null;
            $response['status'] = 'Failure';
            $response['error'] = "Ajax method does not exist";
    }

echo json_encode($response);


text:
define(function(require, exports, module) {
	"use strict";

	var Backbone = require("backbone");
	var app = require("app");
	var util = require("util");

	var NewsCollection = Backbone.Collection.extend({
		url: function() {
			return util.urlAddParam(
				app.api.endpoints.news,
				"apiKey",
				app.api.key
			);
		},

		parse: function(resp) {
			if (!_.isUndefined(resp.posts)) {
				return resp.posts;
			}

			return this.models;
		}
	});

	module.exports = NewsCollection;
});


text:
#include "project.h"
#include <core_cm0.h>

void Setup_SysTick();
void SysTick_IRQHandler();
void Button_IRQHandler();

void delay_ms(uint32_t ms);

volatile uint32_t SysTick_Counter = 0;
volatile uint32_t ButtonISR_Triggered = 0;

int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */

    CySysTickInit();
    CySysTickSetReload(24000);

    CySysTickEnableInterrupt();
    CySysTickSetCallback(0, &SysTick_IRQHandler);
    CySysTickStart();

    ButtonISR_StartEx(&Button_IRQHandler);

    for(;;)
    {
        if (ButtonISR_Triggered)
        {
        }
        else
        {
            __WFE();
        }
    }
}

void SysTick_IRQHandler()
{
    SysTick_Counter += 1;
}

void Button_IRQHandler()
{
    ButtonISR_Triggered = 0x01;
    __SEV();
}

void delay_ms(uint32_t ms)
{
    const uint32_t stop = SysTick_Counter + ms;

    while (stop > SysTick_Counter)
    {
        __WFE();
    }
}

/* [] END OF FILE */


text:
{% extends "projects/base.html" %}

{% load i18n %}
{% load uni_form %}
{% load project_tags %}
{% load comments_tag %}

{% block head_title %}{{ task.summary }}{% endblock %}

{% block body %}

← {% trans "Back to Task List for Project " %} {{ task.project }}

    {% show_task task %}

    {% ifequal request.user task.assignee %}
        <form class="uniForm" method="POST" action="">
            <fieldset class="inlineLabels">
                {{ status_form|as_uni_form }}

                    <input type="hidden" name="action" value="update_status" />
                    <input type="submit" value="{% trans "Update Status" %}"/>

            </fieldset>
        </form>
    {% else %}

Status: {{ task.status }}

    {% endifequal %}

    {% if is_member %}
        <form class="uniForm" method="POST" action="">
            <fieldset class="inlineLabels">
                {{ assign_form|as_uni_form }}

                    <input type="hidden" name="action" value="assign" />
                    {% if task.assignee %}
                        <input type="submit" value="{% trans 'Reassign' %}" />
                    {% else %}
                        <input type="submit" value="{% trans 'Assign' %}" />
                    {% endif %}

            </fieldset>
        </form>
    {% endif %}

    {% ifequal task.get_state_display 'open' %}
        {% ifequal request.user task.assignee %}
            <form action="" method="POST">
                <input type="hidden" name="action" value="mark_resolved" />
                <input type="submit" value="{% trans 'Mark Resolved' %}" />
            </form>
        {% endifequal %}
    {% else %}
        {% ifequal task.get_state_display 'resolved' %}
            {% ifequal request.user task.creator %}
                <form action="" method="POST">
                    <input type="hidden" name="action" value="mark_closed" />
                    <input type="submit" value="{% trans 'Mark Closed' %}" />
                </form>
            {% endifequal %}
            {% if is_member %}
                <form action="" method="POST">
                    <input type="hidden" name="action" value="reopen" />
                    <input type="submit" value="{% trans 'Reopen' %}" />
                </form>
            {% endif %}
        {% else %}
            {% if is_member %}
                <form action="" method="POST">
                    <input type="hidden" name="action" value="reopen" />
                    <input type="submit" value="{% trans 'Reopen' %}" />
                </form>
            {% endif %}
        {% endifequal %}
    {% endifequal %}

Discussion

    {% comments task %}
{% endblock %}


text:
package com.salesforce.pyplyn.client;

import com.salesforce.pyplyn.configuration.EndpointConnector;

import retrofit2.Call;
import retrofit2.http.GET;

/**
 * Test class
 *
 * @author Mihai Bojin <mbojin@salesforce.com>
 * @since 3.0
 */
public class AbstractRemoteClientImpl extends AbstractRemoteClient<AbstractRemoteClientImpl.RetroService> {
    private boolean isAuth;

    public AbstractRemoteClientImpl(EndpointConnector connector, Class<RetroService> cls) {
        super(connector, cls);
    }

    public void setAuth(boolean auth) {
        isAuth = auth;
    }

    @Override
    protected boolean isAuthenticated() {
        return isAuth;
    }

    @Override
    protected boolean auth() throws UnauthorizedException {
        return isAuth;
    }

    @Override
    protected void resetAuth() {
        isAuth = false;
    }

    /**
     * Retrofit interface
     */
    public interface RetroService {
        @GET("/")
        Call<String> get();
    }
}


text: championship dataviz


text:
import * as assert from 'assert';

import { SpectronApplication } from '../../spectron/application';

describe('Editor', () => {
	let app: SpectronApplication;
	before(() => { app = new SpectronApplication(); return app.start('Editor'); });
	after(() => app.stop());
	beforeEach(function () { app.screenCapturer.testName = this.currentTest.title; });

	it('shows correct quick outline', async function () {
		await app.workbench.quickopen.openFile('www');

		await app.workbench.editor.openOutline();
		await app.workbench.quickopen.waitForQuickOpenElements(names => names.length >= 6);
	});

	it(`finds 'All References' to 'app'`, async function () {
		await app.workbench.quickopen.openFile('www');

		const references = await app.workbench.editor.findReferences('app', 7);

		await references.waitForReferencesCountInTitle(3);
		await references.waitForReferencesCount(3);
		await references.close();
	});

	it(`renames local 'app' variable`, async function () {
		await app.workbench.quickopen.openFile('www');

		const selector = await app.workbench.editor.getSelector('app', 7);
		const rename = await app.workbench.editor.rename('app', 7);
		await rename.rename('newApp');

		const actual = await app.client.waitForText(selector, 'newApp');
		await app.screenCapturer.capture('Rename result');
		assert.equal(actual, 'newApp');
	});

	it('folds/unfolds the code correctly', async function () {
		await app.workbench.quickopen.openFile('www');

		// Fold
		await app.workbench.editor.foldAtLine(3);
		await app.workbench.editor.waitUntilShown(3);
		await app.workbench.editor.waitUntilHidden(4);
		await app.workbench.editor.waitUntilHidden(5);

		// Unfold
		await app.workbench.editor.unfoldAtLine(3);
		await app.workbench.editor.waitUntilShown(3);
		await app.workbench.editor.waitUntilShown(4);
		await app.workbench.editor.waitUntilShown(5);
	});

	it(`verifies that 'Go To Definition' works`, async function () {
		await app.workbench.quickopen.openFile('app.js');

		await app.workbench.editor.gotoDefinition('express', 11);

		await app.workbench.waitForActiveTab('index.d.ts');
	});

	it(`verifies that 'Peek Definition' works`, async function () {
		await app.workbench.quickopen.openFile('app.js');

		const peek = await app.workbench.editor.peekDefinition('express', 11);

		await peek.waitForFile('index.d.ts');
	});
});


text:
@interface TMViewController : UIViewController

@property (assign, nonatomic) IBOutlet UILabel * blockLabel;
@property (assign, nonatomic) IBOutlet UILabel * notificationLabel;

@end


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

<rootTag>
  <Award>
    <AwardTitle>NSF/CBMS Regional Conference in the Mathematical Sciences - Unitary Representations of Reductive Groups</AwardTitle>
    <AwardEffectiveDate>01/01/2012</AwardEffectiveDate>
    <AwardExpirationDate>12/31/2012</AwardExpirationDate>
    <AwardAmount>50158</AwardAmount>
    <AwardInstrument>
      <Value>Standard Grant</Value>
    </AwardInstrument>
    <Organization>
      03040000
      <Directorate>
        <LongName>Direct For Mathematical & Physical Scien</LongName>
      </Directorate>
      <Division>
        <LongName>Division Of Mathematical Sciences</LongName>
      </Division>
    </Organization>
    <ProgramOfficer>
      <SignBlockName>Jennifer Slimowitz Pearl</SignBlockName>
    </ProgramOfficer>
    <AbstractNarration>This award will support an NSF/CMBS regional conference to be held at the University of Massachusetts Boston in the summer of 2012 on the topic of unitary representations of reductive groups. The principal speaker will be Professor David Vogan from the Massachusetts Institute of Technology. This award will support 30 participants at different stages of their careers. <br/><br/>The conference will provide a forum for discussing the latest advances in the field, including a new algorithmic approach that has the potential to give results for the largest exceptional group E_8. The conference will attract a wide range of researchers and advanced graduate students who will be exposed to sophisticated software and computational techniques that will enhance their capacity to investigate conjectures and carry out complex simulations.</AbstractNarration>
    <MinAmdLetterDate>08/09/2011</MinAmdLetterDate>
    <MaxAmdLetterDate>07/31/2012</MaxAmdLetterDate>
    <ARRAAmount/>
    <AwardID>1137423</AwardID>
    <Investigator>
      <FirstName>Alfred</FirstName>
      <LastName>Noel</LastName>
      <EmailAddress>alfred.noel@umb.edu</EmailAddress>
      <StartDate>08/09/2011</StartDate>
      <EndDate/>
      <RoleCode>Principal Investigator</RoleCode>
    </Investigator>
    <Institution>
      <Name>University of Massachusetts Boston</Name>
      <CityName>Dorchester</CityName>
      <ZipCode>021253300</ZipCode>
      <PhoneNumber>6172875370</PhoneNumber>
      <StreetAddress>100 Morrissey Boulevard</StreetAddress>
      <CountryName>United States</CountryName>
      <StateName>Massachusetts</StateName>
      <StateCode>MA</StateCode>
    </Institution>
  </Award>
</rootTag>


text:
package org.apache.spark.sql.execution.benchmark

import scala.collection.mutable.ListBuffer

import org.apache.spark.benchmark.Benchmark
import org.apache.spark.sql.Column
import org.apache.spark.sql.functions._
import org.apache.spark.sql.internal.SQLConf

/**
 * Synthetic benchmark for interval functions.
 * To run this benchmark:
 * {{{
 *   1. without sbt:
 *      bin/spark-submit --class <this class> --jars <spark core test jar> <sql core test jar>
 *   2. build/sbt "sql/test:runMain <this class>"
 *   3. generate result:
 *      SPARK_GENERATE_BENCHMARK_FILES=1 build/sbt "sql/test:runMain <this class>"
 *      Results will be written to "benchmarks/IntervalBenchmark-results.txt".
 * }}}
 */
object IntervalBenchmark extends SqlBasedBenchmark {
  import spark.implicits._

  private def doBenchmark(cardinality: Long, exprs: Column*): Unit = {
    withSQLConf(SQLConf.WHOLESTAGE_CODEGEN_ENABLED.key -> "true") {
      spark
        .range(0, cardinality, 1, 1)
        .select(exprs: _*)
        .queryExecution
        .toRdd
        .foreach(_ => ())
    }
  }

  private def addCase(
      benchmark: Benchmark,
      cardinality: Long,
      name: String,
      exprs: Column*): Unit = {
    benchmark.addCase(name, numIters = 3) { _ =>
      doBenchmark(cardinality, exprs: _*)
    }
  }

  private def buildString(withPrefix: Boolean, units: Seq[String] = Seq.empty): Column = {
    val init = lit(if (withPrefix) "interval" else "") ::
      ($"id" % 10000).cast("string") ::
      lit("years") :: Nil

    concat_ws(" ", (init ++ units.map(lit)): _*)
  }

  private def addCase(benchmark: Benchmark, cardinality: Long, units: Seq[String]): Unit = {
    Seq(true, false).foreach { withPrefix =>
      val expr = buildString(withPrefix, units).cast("interval")
      val note = if (withPrefix) "w/ interval" else "w/o interval"
      benchmark.addCase(s"${units.length + 1} units $note", numIters = 3) { _ =>
        doBenchmark(cardinality, expr)
      }
    }
  }

  override def runBenchmarkSuite(mainArgs: Array[String]): Unit = {
    val N = 1000000
    val timeUnits = Seq(
      "13 months", "                      1                     months",
      "100 weeks", "9 days", "12 hours", "-                    3 hours",
      "5 minutes", "45 seconds", "123 milliseconds", "567 microseconds")
    val intervalToTest = ListBuffer[String]()

    val benchmark = new Benchmark("cast strings to intervals", N, output = output)
    // The first 2 cases are used to show the overhead of preparing the interval string.
    addCase(benchmark, N, "prepare string w/ interval", buildString(true, timeUnits))
    addCase(benchmark, N, "prepare string w/o interval", buildString(false, timeUnits))
    addCase(benchmark, N, intervalToTest) // Only years

    for (unit <- timeUnits) {
      intervalToTest.append(unit)
      addCase(benchmark, N, intervalToTest)
    }

    benchmark.run()
  }
}


text:
<?php

namespace Kunstmaan\TranslatorBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class Configuration implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder('kuma_translator');
        if (method_exists($treeBuilder, 'getRootNode')) {
            $rootNode = $treeBuilder->getRootNode();
        } else {
            // BC layer for symfony/config 4.1 and older
            $rootNode = $treeBuilder->root('kuma_translator');
        }

        $availableStorageEngines = ['orm'];
        $defaultFileFormats = ['yml', 'yaml', 'xliff'];

        $rootNode
            ->children()
                ->booleanNode('enabled')
                    ->defaultTrue()
                ->end()

                ->scalarNode('default_bundle')
                    ->cannotBeEmpty()
                    ->defaultValue('own')
                ->end()

                ->arrayNode('bundles')
                    ->defaultValue([])
                    ->prototype('scalar')->end()
                ->end()

                ->scalarNode('cache_dir')
                    ->cannotBeEmpty()
                    ->defaultValue('%kernel.cache_dir%/translations')
                ->end()

                ->booleanNode('debug')
                    ->defaultValue(null)
                ->end()

                ->arrayNode('managed_locales')
                    ->defaultValue([])
                    ->prototype('scalar')->end()
                ->end()

                ->arrayNode('file_formats')
                    ->defaultValue($defaultFileFormats)
                    ->prototype('scalar')->end()
                ->end()

                ->arrayNode('storage_engine')
                    ->addDefaultsIfNotSet()
                    ->children()
                        ->scalarNode('type')
                            ->cannotBeEmpty()
                            ->defaultValue('orm')
                            ->validate()
                                ->ifNotInArray($availableStorageEngines)
                                ->thenInvalid('Storage engine should be one of the following: ' . implode(', ', $availableStorageEngines))
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ;

        return $treeBuilder;
    }
}


text:
<?php

namespace Doctrine\Bundle\DoctrineBundle;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Filter\SQLFilter;

/**
 * Configurator for an EntityManager
 */
class ManagerConfigurator
{
    /** @var string[] */
    private $enabledFilters = [];

    /** @var string[] */
    private $filtersParameters = [];

    /**
     * @param string[] $enabledFilters
     * @param string[] $filtersParameters
     */
    public function __construct(array $enabledFilters, array $filtersParameters)
    {
        $this->enabledFilters    = $enabledFilters;
        $this->filtersParameters = $filtersParameters;
    }

    /**
     * Create a connection by name.
     */
    public function configure(EntityManagerInterface $entityManager)
    {
        $this->enableFilters($entityManager);
    }

    /**
     * Enables filters for a given entity manager
     */
    private function enableFilters(EntityManagerInterface $entityManager)
    {
        if (empty($this->enabledFilters)) {
            return;
        }

        $filterCollection = $entityManager->getFilters();
        foreach ($this->enabledFilters as $filter) {
            $filterObject = $filterCollection->enable($filter);
            if ($filterObject === null) {
                continue;
            }

            $this->setFilterParameters($filter, $filterObject);
        }
    }

    /**
     * Sets default parameters for a given filter
     *
     * @param string    $name   Filter name
     * @param SQLFilter $filter Filter object
     */
    private function setFilterParameters($name, SQLFilter $filter)
    {
        if (empty($this->filtersParameters[$name])) {
            return;
        }

        $parameters = $this->filtersParameters[$name];
        foreach ($parameters as $paramName => $paramValue) {
            $filter->setParameter($paramName, $paramValue);
        }
    }
}