text:
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include <linux/jiffies.h>
#include <linux/rbtree.h>
#include <linux/ioprio.h>
#include <linux/blktrace_api.h>
#include "blk.h"

#define VIOS_SCALE_SHIFT 10
#define VIOS_SCALE (1 << VIOS_SCALE_SHIFT)

#define VIOS_READ_SCALE (1)
#define VIOS_WRITE_SCALE (1)
#define VIOS_SYNC_SCALE (2)
#define VIOS_ASYNC_SCALE (5)

#define VIOS_PRIO_SCALE (5)

struct fiops_rb_root {
	struct rb_root rb;
	struct rb_node *left;
	unsigned count;

	u64 min_vios;
};
#define FIOPS_RB_ROOT	(struct fiops_rb_root) { .rb = RB_ROOT}

enum wl_prio_t {
	IDLE_WORKLOAD = 0,
	BE_WORKLOAD = 1,
	RT_WORKLOAD = 2,
	FIOPS_PRIO_NR,
};

struct fiops_data {
	struct request_queue *queue;

	struct fiops_rb_root service_tree[FIOPS_PRIO_NR];

	unsigned int busy_queues;
	unsigned int in_flight[2];

	struct work_struct unplug_work;

	unsigned int read_scale;
	unsigned int write_scale;
	unsigned int sync_scale;
	unsigned int async_scale;
};

struct fiops_ioc {
	struct io_cq icq;

	unsigned int flags;
	struct fiops_data *fiopsd;
	struct rb_node rb_node;
	u64 vios; /* key in service_tree */
	struct fiops_rb_root *service_tree;

	unsigned int in_flight;

	struct rb_root sort_list;
	struct list_head fifo;

	pid_t pid;
	unsigned short ioprio;
	enum wl_prio_t wl_type;
};

#define ioc_service_tree(ioc) (&((ioc)->fiopsd->service_tree[(ioc)->wl_type]))
#define RQ_CIC(rq)		icq_to_cic((rq)->elv.icq)

enum ioc_state_flags {
	FIOPS_IOC_FLAG_on_rr = 0,	/* on round-robin busy list */
	FIOPS_IOC_FLAG_prio_changed,	/* task priority has changed */
};

#define FIOPS_IOC_FNS(name)						\
static inline void fiops_mark_ioc_##name(struct fiops_ioc *ioc)	\
{									\
	ioc->flags |= (1 << FIOPS_IOC_FLAG_##name);			\
}									\
static inline void fiops_clear_ioc_##name(struct fiops_ioc *ioc)	\
{									\
	ioc->flags &= ~(1 << FIOPS_IOC_FLAG_##name);			\
}									\
static inline int fiops_ioc_##name(const struct fiops_ioc *ioc)	\
{									\
	return ((ioc)->flags & (1 << FIOPS_IOC_FLAG_##name)) != 0;	\
}

FIOPS_IOC_FNS(on_rr);
FIOPS_IOC_FNS(prio_changed);
#undef FIOPS_IOC_FNS

#define fiops_log_ioc(fiopsd, ioc, fmt, args...)	\
	blk_add_trace_msg((fiopsd)->queue, "ioc%d " fmt, (ioc)->pid, ##args)
#define fiops_log(fiopsd, fmt, args...)	\
	blk_add_trace_msg((fiopsd)->queue, "fiops " fmt, ##args)

enum wl_prio_t fiops_wl_type(short prio_class)
{
	if (prio_class == IOPRIO_CLASS_RT)
		return RT_WORKLOAD;
	if (prio_class == IOPRIO_CLASS_BE)
		return BE_WORKLOAD;
	return IDLE_WORKLOAD;
}

static inline struct fiops_ioc *icq_to_cic(struct io_cq *icq)
{
	/* cic->icq is the first member, %NULL will convert to %NULL */
	return container_of(icq, struct fiops_ioc, icq);
}

static inline struct fiops_ioc *fiops_cic_lookup(struct fiops_data *fiopsd,
					       struct io_context *ioc)
{
	if (ioc)
		return icq_to_cic(ioc_lookup_icq(ioc, fiopsd->queue));
	return NULL;
}

/*
 * The below is leftmost cache rbtree addon
 */
static struct fiops_ioc *fiops_rb_first(struct fiops_rb_root *root)
{
	/* Service tree is empty */
	if (!root->count)
		return NULL;

	if (!root->left)
		root->left = rb_first(&root->rb);

	if (root->left)
		return rb_entry(root->left, struct fiops_ioc, rb_node);

	return NULL;
}

static void rb_erase_init(struct rb_node *n, struct rb_root *root)
{
	rb_erase(n, root);
	RB_CLEAR_NODE(n);
}

static void fiops_rb_erase(struct rb_node *n, struct fiops_rb_root *root)
{
	if (root->left == n)
		root->left = NULL;
	rb_erase_init(n, &root->rb);
	--root->count;
}

static inline u64 max_vios(u64 min_vios, u64 vios)
{
	s64 delta = (s64)(vios - min_vios);
	if (delta > 0)
		min_vios = vios;

	return min_vios;
}

static void fiops_update_min_vios(struct fiops_rb_root *service_tree)
{
	struct fiops_ioc *ioc;

	ioc = fiops_rb_first(service_tree);
	if (!ioc)
		return;
	service_tree->min_vios = max_vios(service_tree->min_vios, ioc->vios);
}

/*
 * The fiopsd->service_trees holds all pending fiops_ioc's that have
 * requests waiting to be processed. It is sorted in the order that
 * we will service the queues.
 */
static void fiops_service_tree_add(struct fiops_data *fiopsd,
	struct fiops_ioc *ioc)
{
	struct rb_node **p, *parent;
	struct fiops_ioc *__ioc;
	struct fiops_rb_root *service_tree = ioc_service_tree(ioc);
	u64 vios;
	int left;

	/* New added IOC */
	if (RB_EMPTY_NODE(&ioc->rb_node)) {
		if (ioc->in_flight > 0)
			vios = ioc->vios;
		else
			vios = max_vios(service_tree->min_vios, ioc->vios);
	} else {
		vios = ioc->vios;
		/* ioc->service_tree might not equal to service_tree */
		fiops_rb_erase(&ioc->rb_node, ioc->service_tree);
		ioc->service_tree = NULL;
	}

	fiops_log_ioc(fiopsd, ioc, "service tree add, vios %lld", vios);

	left = 1;
	parent = NULL;
	ioc->service_tree = service_tree;
	p = &service_tree->rb.rb_node;
	while (*p) {
		struct rb_node **n;

		parent = *p;
		__ioc = rb_entry(parent, struct fiops_ioc, rb_node);

		/*
		 * sort by key, that represents service time.
		 */
		if (vios <  __ioc->vios)
			n = &(*p)->rb_left;
		else {
			n = &(*p)->rb_right;
			left = 0;
		}

		p = n;
	}

	if (left)
		service_tree->left = &ioc->rb_node;

	ioc->vios = vios;
	rb_link_node(&ioc->rb_node, parent, p);
	rb_insert_color(&ioc->rb_node, &service_tree->rb);
	service_tree->count++;

	fiops_update_min_vios(service_tree);
}

/*
 * Update ioc's position in the service tree.
 */
static void fiops_resort_rr_list(struct fiops_data *fiopsd,
	struct fiops_ioc *ioc)
{
	/*
	 * Resorting requires the ioc to be on the RR list already.
	 */
	if (fiops_ioc_on_rr(ioc))
		fiops_service_tree_add(fiopsd, ioc);
}

/*
 * add to busy list of queues for service, trying to be fair in ordering
 * the pending list according to last request service
 */
static void fiops_add_ioc_rr(struct fiops_data *fiopsd, struct fiops_ioc *ioc)
{
	BUG_ON(fiops_ioc_on_rr(ioc));
	fiops_mark_ioc_on_rr(ioc);

	fiopsd->busy_queues++;

	fiops_resort_rr_list(fiopsd, ioc);
}

/*
 * Called when the ioc no longer has requests pending, remove it from
 * the service tree.
 */
static void fiops_del_ioc_rr(struct fiops_data *fiopsd, struct fiops_ioc *ioc)
{
	BUG_ON(!fiops_ioc_on_rr(ioc));
	fiops_clear_ioc_on_rr(ioc);

	if (!RB_EMPTY_NODE(&ioc->rb_node)) {
		fiops_rb_erase(&ioc->rb_node, ioc->service_tree);
		ioc->service_tree = NULL;
	}

	BUG_ON(!fiopsd->busy_queues);
	fiopsd->busy_queues--;
}

/*
 * rb tree support functions
 */
static void fiops_del_rq_rb(struct request *rq)
{
	struct fiops_ioc *ioc = RQ_CIC(rq);

	elv_rb_del(&ioc->sort_list, rq);
}

static void fiops_add_rq_rb(struct request *rq)
{
	struct fiops_ioc *ioc = RQ_CIC(rq);
	struct fiops_data *fiopsd = ioc->fiopsd;

	elv_rb_add(&ioc->sort_list, rq);

	if (!fiops_ioc_on_rr(ioc))
		fiops_add_ioc_rr(fiopsd, ioc);
}

static void fiops_reposition_rq_rb(struct fiops_ioc *ioc, struct request *rq)
{
	elv_rb_del(&ioc->sort_list, rq);
	fiops_add_rq_rb(rq);
}

static void fiops_remove_request(struct request *rq)
{
	list_del_init(&rq->queuelist);
	fiops_del_rq_rb(rq);
}

static u64 fiops_scaled_vios(struct fiops_data *fiopsd,
	struct fiops_ioc *ioc, struct request *rq)
{
	int vios = VIOS_SCALE;

	if (rq_data_dir(rq) == WRITE)
		vios = vios * fiopsd->write_scale / fiopsd->read_scale;

	if (!rq_is_sync(rq))
		vios = vios * fiopsd->async_scale / fiopsd->sync_scale;

	vios +=  vios * (ioc->ioprio - IOPRIO_NORM) / VIOS_PRIO_SCALE;

	return vios;
}

/* return vios dispatched */
static u64 fiops_dispatch_request(struct fiops_data *fiopsd,
	struct fiops_ioc *ioc)
{
	struct request *rq;
	struct request_queue *q = fiopsd->queue;

	rq = rq_entry_fifo(ioc->fifo.next);

	fiops_remove_request(rq);
	elv_dispatch_add_tail(q, rq);

	fiopsd->in_flight[rq_is_sync(rq)]++;
	ioc->in_flight++;

	return fiops_scaled_vios(fiopsd, ioc, rq);
}

static int fiops_forced_dispatch(struct fiops_data *fiopsd)
{
	struct fiops_ioc *ioc;
	int dispatched = 0;
	int i;

	for (i = RT_WORKLOAD; i >= IDLE_WORKLOAD; i--) {
		while (!RB_EMPTY_ROOT(&fiopsd->service_tree[i].rb)) {
			ioc = fiops_rb_first(&fiopsd->service_tree[i]);

			while (!list_empty(&ioc->fifo)) {
				fiops_dispatch_request(fiopsd, ioc);
				dispatched++;
			}
			if (fiops_ioc_on_rr(ioc))
				fiops_del_ioc_rr(fiopsd, ioc);
		}
	}
	return dispatched;
}

static struct fiops_ioc *fiops_select_ioc(struct fiops_data *fiopsd)
{
	struct fiops_ioc *ioc;
	struct fiops_rb_root *service_tree = NULL;
	int i;
	struct request *rq;

	for (i = RT_WORKLOAD; i >= IDLE_WORKLOAD; i--) {
		if (!RB_EMPTY_ROOT(&fiopsd->service_tree[i].rb)) {
			service_tree = &fiopsd->service_tree[i];
			break;
		}
	}

	if (!service_tree)
		return NULL;

	ioc = fiops_rb_first(service_tree);

	rq = rq_entry_fifo(ioc->fifo.next);
	/*
	 * we are the only async task and sync requests are in flight, delay a
	 * moment. If there are other tasks coming, sync tasks have no chance
	 * to be starved, don't delay
	 */
	if (!rq_is_sync(rq) && fiopsd->in_flight[1] != 0 &&
			service_tree->count == 1) {
		fiops_log_ioc(fiopsd, ioc,
				"postpone async, in_flight async %d sync %d",
				fiopsd->in_flight[0], fiopsd->in_flight[1]);
		return NULL;
	}

	return ioc;
}

static void fiops_charge_vios(struct fiops_data *fiopsd,
	struct fiops_ioc *ioc, u64 vios)
{
	struct fiops_rb_root *service_tree = ioc->service_tree;
	ioc->vios += vios;

	fiops_log_ioc(fiopsd, ioc, "charge vios %lld, new vios %lld", vios, ioc->vios);

	if (RB_EMPTY_ROOT(&ioc->sort_list))
		fiops_del_ioc_rr(fiopsd, ioc);
	else
		fiops_resort_rr_list(fiopsd, ioc);

	fiops_update_min_vios(service_tree);
}

static int fiops_dispatch_requests(struct request_queue *q, int force)
{
	struct fiops_data *fiopsd = q->elevator->elevator_data;
	struct fiops_ioc *ioc;
	u64 vios;

	if (unlikely(force))
		return fiops_forced_dispatch(fiopsd);

	ioc = fiops_select_ioc(fiopsd);
	if (!ioc)
		return 0;

	vios = fiops_dispatch_request(fiopsd, ioc);

	fiops_charge_vios(fiopsd, ioc, vios);
	return 1;
}

static void fiops_init_prio_data(struct fiops_ioc *cic)
{
	struct task_struct *tsk = current;
	struct io_context *ioc = cic->icq.ioc;
	int ioprio_class;

	if (!fiops_ioc_prio_changed(cic))
		return;

	ioprio_class = IOPRIO_PRIO_CLASS(ioc->ioprio);
	switch (ioprio_class) {
	default:
		printk(KERN_ERR "fiops: bad prio %x\n", ioprio_class);
	case IOPRIO_CLASS_NONE:
		/*
		 * no prio set, inherit CPU scheduling settings
		 */
		cic->ioprio = task_nice_ioprio(tsk);
		cic->wl_type = fiops_wl_type(task_nice_ioclass(tsk));
		break;
	case IOPRIO_CLASS_RT:
		cic->ioprio = IOPRIO_PRIO_DATA(ioc->ioprio);
		cic->wl_type = fiops_wl_type(IOPRIO_CLASS_RT);
		break;
	case IOPRIO_CLASS_BE:
		cic->ioprio = IOPRIO_PRIO_DATA(ioc->ioprio);
		cic->wl_type = fiops_wl_type(IOPRIO_CLASS_BE);
		break;
	case IOPRIO_CLASS_IDLE:
		cic->wl_type = fiops_wl_type(IOPRIO_CLASS_IDLE);
		cic->ioprio = 7;
		break;
	}

	fiops_clear_ioc_prio_changed(cic);
}

static void fiops_insert_request(struct request_queue *q, struct request *rq)
{
	struct fiops_ioc *ioc = RQ_CIC(rq);

	fiops_init_prio_data(ioc);

	list_add_tail(&rq->queuelist, &ioc->fifo);

	fiops_add_rq_rb(rq);
}

/*
 * scheduler run of queue, if there are requests pending and no one in the
 * driver that will restart queueing
 */
static inline void fiops_schedule_dispatch(struct fiops_data *fiopsd)
{
	if (fiopsd->busy_queues)
		kblockd_schedule_work(fiopsd->queue, &fiopsd->unplug_work);
}

static void fiops_completed_request(struct request_queue *q, struct request *rq)
{
	struct fiops_data *fiopsd = q->elevator->elevator_data;
	struct fiops_ioc *ioc = RQ_CIC(rq);

	fiopsd->in_flight[rq_is_sync(rq)]--;
	ioc->in_flight--;

	fiops_log_ioc(fiopsd, ioc, "in_flight %d, busy queues %d",
		ioc->in_flight, fiopsd->busy_queues);

	if (fiopsd->in_flight[0] + fiopsd->in_flight[1] == 0)
		fiops_schedule_dispatch(fiopsd);
}

static struct request *
fiops_find_rq_fmerge(struct fiops_data *fiopsd, struct bio *bio)
{
	struct task_struct *tsk = current;
	struct fiops_ioc *cic;

	cic = fiops_cic_lookup(fiopsd, tsk->io_context);

	if (cic) {
		sector_t sector = bio->bi_sector + bio_sectors(bio);

		return elv_rb_find(&cic->sort_list, sector);
	}

	return NULL;
}

static int fiops_merge(struct request_queue *q, struct request **req,
		     struct bio *bio)
{
	struct fiops_data *fiopsd = q->elevator->elevator_data;
	struct request *__rq;

	__rq = fiops_find_rq_fmerge(fiopsd, bio);
	if (__rq && elv_rq_merge_ok(__rq, bio)) {
		*req = __rq;
		return ELEVATOR_FRONT_MERGE;
	}

	return ELEVATOR_NO_MERGE;
}

static void fiops_merged_request(struct request_queue *q, struct request *req,
			       int type)
{
	if (type == ELEVATOR_FRONT_MERGE) {
		struct fiops_ioc *ioc = RQ_CIC(req);

		fiops_reposition_rq_rb(ioc, req);
	}
}

static void
fiops_merged_requests(struct request_queue *q, struct request *rq,
		    struct request *next)
{
	struct fiops_ioc *ioc = RQ_CIC(rq);
	struct fiops_data *fiopsd = q->elevator->elevator_data;

	fiops_remove_request(next);

	ioc = RQ_CIC(next);
	/*
	 * all requests of this task are merged to other tasks, delete it
	 * from the service tree.
	 */
	if (fiops_ioc_on_rr(ioc) && RB_EMPTY_ROOT(&ioc->sort_list))
		fiops_del_ioc_rr(fiopsd, ioc);
}

static int fiops_allow_merge(struct request_queue *q, struct request *rq,
			   struct bio *bio)
{
	struct fiops_data *fiopsd = q->elevator->elevator_data;
	struct fiops_ioc *cic;

	/*
	 * Lookup the ioc that this bio will be queued with. Allow
	 * merge only if rq is queued there.
	 */
	cic = fiops_cic_lookup(fiopsd, current->io_context);

	return cic == RQ_CIC(rq);
}

static void fiops_exit_queue(struct elevator_queue *e)
{
	struct fiops_data *fiopsd = e->elevator_data;

	cancel_work_sync(&fiopsd->unplug_work);

	kfree(fiopsd);
}

static void fiops_kick_queue(struct work_struct *work)
{
	struct fiops_data *fiopsd =
		container_of(work, struct fiops_data, unplug_work);
	struct request_queue *q = fiopsd->queue;

	spin_lock_irq(q->queue_lock);
	__blk_run_queue(q);
	spin_unlock_irq(q->queue_lock);
}

static int fiops_init_queue(struct request_queue *q, struct elevator_type *e)
{
	struct fiops_data *fiopsd;
	int i;
	struct elevator_queue *eq;

	eq = elevator_alloc(q, e);
	if (!eq)
		return -ENOMEM;

	fiopsd = kzalloc_node(sizeof(*fiopsd), GFP_KERNEL, q->node);
	if (!fiopsd) {
		kobject_put(&eq->kobj);
		return -ENOMEM;
	}
	eq->elevator_data = fiopsd;

	fiopsd->queue = q;
	spin_lock_irq(q->queue_lock);
	q->elevator = eq;
	spin_unlock_irq(q->queue_lock);

	for (i = IDLE_WORKLOAD; i <= RT_WORKLOAD; i++)
		fiopsd->service_tree[i] = FIOPS_RB_ROOT;

	INIT_WORK(&fiopsd->unplug_work, fiops_kick_queue);

	fiopsd->read_scale = VIOS_READ_SCALE;
	fiopsd->write_scale = VIOS_WRITE_SCALE;
	fiopsd->sync_scale = VIOS_SYNC_SCALE;
	fiopsd->async_scale = VIOS_ASYNC_SCALE;

	return 0;
}

static void fiops_init_icq(struct io_cq *icq)
{
	struct fiops_data *fiopsd = icq->q->elevator->elevator_data;
	struct fiops_ioc *ioc = icq_to_cic(icq);

	RB_CLEAR_NODE(&ioc->rb_node);
	INIT_LIST_HEAD(&ioc->fifo);
	ioc->sort_list = RB_ROOT;

	ioc->fiopsd = fiopsd;

	ioc->pid = current->pid;
	fiops_mark_ioc_prio_changed(ioc);
}

/*
 * sysfs parts below -->
 */
static ssize_t
fiops_var_show(unsigned int var, char *page)
{
	return sprintf(page, "%d\n", var);
}

static ssize_t
fiops_var_store(unsigned int *var, const char *page, size_t count)
{
	char *p = (char *) page;

	*var = simple_strtoul(p, &p, 10);
	return count;
}

#define SHOW_FUNCTION(__FUNC, __VAR)					\
static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
{									\
	struct fiops_data *fiopsd = e->elevator_data;			\
	return fiops_var_show(__VAR, (page));				\
}
SHOW_FUNCTION(fiops_read_scale_show, fiopsd->read_scale);
SHOW_FUNCTION(fiops_write_scale_show, fiopsd->write_scale);
SHOW_FUNCTION(fiops_sync_scale_show, fiopsd->sync_scale);
SHOW_FUNCTION(fiops_async_scale_show, fiopsd->async_scale);
#undef SHOW_FUNCTION

#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX)				\
static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)	\
{									\
	struct fiops_data *fiopsd = e->elevator_data;			\
	unsigned int __data;						\
	int ret = fiops_var_store(&__data, (page), count);		\
	if (__data < (MIN))						\
		__data = (MIN);						\
	else if (__data > (MAX))					\
		__data = (MAX);						\
	*(__PTR) = __data;						\
	return ret;							\
}
STORE_FUNCTION(fiops_read_scale_store, &fiopsd->read_scale, 1, 100);
STORE_FUNCTION(fiops_write_scale_store, &fiopsd->write_scale, 1, 100);
STORE_FUNCTION(fiops_sync_scale_store, &fiopsd->sync_scale, 1, 100);
STORE_FUNCTION(fiops_async_scale_store, &fiopsd->async_scale, 1, 100);
#undef STORE_FUNCTION

#define FIOPS_ATTR(name) \
	__ATTR(name, S_IRUGO|S_IWUSR, fiops_##name##_show, fiops_##name##_store)

static struct elv_fs_entry fiops_attrs[] = {
	FIOPS_ATTR(read_scale),
	FIOPS_ATTR(write_scale),
	FIOPS_ATTR(sync_scale),
	FIOPS_ATTR(async_scale),
	__ATTR_NULL
};

static struct elevator_type iosched_fiops = {
	.ops = {
		.elevator_merge_fn =		fiops_merge,
		.elevator_merged_fn =		fiops_merged_request,
		.elevator_merge_req_fn =	fiops_merged_requests,
		.elevator_allow_merge_fn =	fiops_allow_merge,
		.elevator_dispatch_fn =		fiops_dispatch_requests,
		.elevator_add_req_fn =		fiops_insert_request,
		.elevator_completed_req_fn =	fiops_completed_request,
		.elevator_former_req_fn =	elv_rb_former_request,
		.elevator_latter_req_fn =	elv_rb_latter_request,
		.elevator_init_icq_fn =		fiops_init_icq,
		.elevator_init_fn =		fiops_init_queue,
		.elevator_exit_fn =		fiops_exit_queue,
	},
	.icq_size	=	sizeof(struct fiops_ioc),
	.icq_align	=	__alignof__(struct fiops_ioc),
	.elevator_attrs =	fiops_attrs,
	.elevator_name =	"fiops",
	.elevator_owner =	THIS_MODULE,
};

static int __init fiops_init(void)
{
	return elv_register(&iosched_fiops);
}

static void __exit fiops_exit(void)
{
	elv_unregister(&iosched_fiops);
}

module_init(fiops_init);
module_exit(fiops_exit);

MODULE_AUTHOR("Jens Axboe, Shaohua Li <shli@kernel.org>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("IOPS based IO scheduler");


text:
"use strict";

function Gun(){
	this.countdown = 0;
};

Gun.prototype = {
	stopped: function(){
		if(this.countdown <= 0){
			return true;
		}else{
			return false;
		}
	},

	start: function(seconds){
		if(this.isNumber(seconds) && seconds >= 0){
			this.countdown = seconds;
		}
	},

	decrease: function(seconds){
		if(this.isNumber(seconds) && seconds >= 0){
			this.countdown -= seconds;
		}
	},

	isNumber: function(shouldBeFiniteNumber){
  		return typeof shouldBeFiniteNumber === 'number' && isFinite(shouldBeFiniteNumber);
	}
}

module.exports = Gun;

redpajama_set_name: RedPajamaGithub


text:
{-# LANGUAGE OverloadedStrings #-}
module Main where

import RDPURI
import Test.Tasty
import Test.Tasty.HUnit

main :: IO ()
main = defaultMain tests

tests :: TestTree
tests = testGroup "Tests" [units]
        where units =
                testCase "simple uri" $ "rdp://full%20address=s:mypc:3389&audiomode=i:2&disable%20themes=i:1" @=? renderRDPURI (RDPURI ("mypc", Just 3389) [AudioMode Two', DisableThemes One])


text:
.team-board-header {
  margin-bottom: 20px;
}
.team-board-header .pull-right ul li {
  position: relative;
}
.team-board-header .pull-right ul li .online {
  position: absolute;
  bottom: -7px;
  left: 23px;
  border: 1px solid #f3f3f4;
}
.panel-team-board .cbp-l-filters-button .label {
  line-height: 7px;
  height: 10px;
  width: 10px;
  margin-right: 3px;
}
.team-board-list {
  border-right: 1px solid #dddddd;
  border-left: 1px solid #dddddd;
  border-bottom: 1px solid #dddddd;
  position: relative;
  padding: 10px;
  background-color: #ffffff;
  margin-bottom: 2px;
}
.team-board-list .team-board-message {
  margin-bottom: 0;
}
.team-board-list .team-board-author {
  margin-bottom: 0;
}
.team-board-list .panel-heading {
  color: #C5C7C9;
  border-bottom: 1px dashed #dddddd;
  padding: 0 0 10px 0;
}
.team-board-list .panel-body,
.team-board-list .panel-footer {
  background-color: transparent;
  padding: 10px 0;
}
.team-board-list .panel-footer {
  border: none;
  padding: 0;
}
.team-board-list .panel-footer img {
  width: 30px;
  display: inline-block;
  margin-right: 5px;
}
.team-board-list .cbp-l-grid-blog-title {
  margin-top: 0;
}
.team-board-list.danger:after,
.team-board-list.primary:after,
.team-board-list.info:after,
.team-board-list.success:after,
.team-board-list.warning:after {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: -1px;
  right: -1px;
}
.team-board-list.danger:after {
  border-top: 3px solid #e9573f;
}
.team-board-list.primary:after {
  border-top: 3px solid #00b1e1;
}
.team-board-list.info:after {
  border-top: 3px solid #63d3e9;
}
.team-board-list.success:after {
  border-top: 3px solid #8cc152;
}
.team-board-list.warning:after {
  border-top: 3px solid #f6bb42;
}
.cbp-item {
  overflow: visible !important;
}
.cbp-l-filters-dropdown-floated {
  margin-right: 0;
  margin-top: 0;
  margin-left: 8px;
}
.cbp-search-input {
  height: 38px;
}


text:
//=================================================================================================

//=================================================================================================

#ifndef _BLAZE_MATH_CONSTRAINTS_TRANSFORMATION_H_
#define _BLAZE_MATH_CONSTRAINTS_TRANSFORMATION_H_

//*************************************************************************************************
// Includes
//*************************************************************************************************

#include <blaze/math/typetraits/IsTransformation.h>

namespace blaze {

//=================================================================================================
//
//  MUST_BE_TRANSFORMATION_TYPE CONSTRAINT
//
//=================================================================================================

//*************************************************************************************************
/*!\brief Constraint on the data type.
// \ingroup math_constraints
//
// In case the given data type \a T is not a transformation expression (i.e. a type derived from
// the Transformation base class), a compilation error is created.
*/
#define BLAZE_CONSTRAINT_MUST_BE_TRANSFORMATION_TYPE(T) \
   static_assert( ::blaze::IsTransformation<T>::value, "Non-transformation type detected" )
//*************************************************************************************************

//=================================================================================================
//
//  MUST_NOT_BE_TRANSFORMATION_TYPE CONSTRAINT
//
//=================================================================================================

//*************************************************************************************************
/*!\brief Constraint on the data type.
// \ingroup math_constraints
//
// In case the given data type \a T is a transformation expression (i.e. a type derived from the
// Transformation base class), a compilation error is created.
*/
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T) \
   static_assert( !::blaze::IsTransformation<T>::value, "Transformation type detected" )
//*************************************************************************************************

} // namespace blaze

#endif


text:
<?php

namespace Puphpet\MainBundle\Extension;

use Symfony\Component\DependencyInjection\ContainerInterface as Container;
use Symfony\Component\Yaml\Yaml;

abstract class ExtensionAbstract implements ExtensionInterface
{
    const DIR = 'undef';

    protected $container;
    protected $customData = [];
    protected $data = [];
    protected $dataLocation;
    protected $returnAvailableData = true;

    protected $conf = [
        'frontController'    => null,
        'manifestController' => null,
        'name'               => null,
        'slug'               => null,
        'targetFile'         => null,
    ];

    private $blankConf = [
        'frontController'    => null,
        'manifestController' => null,
        'name'               => null,
        'slug'               => null,
        'targetFile'         => null,
    ];

    /**
     * @param Container $container
     */
    public function __construct(Container $container)
    {
        $this->conf = array_merge($this->blankConf, $this->conf);

        $this->dataLocation = static::DIR . '/Resources/config';
        $this->container    = $container;
    }

    /**
     * Get extension's English name, eg "Apache"
     *
     * @return string
     * @throws \Exception
     */
    public function getName()
    {
        if (!$this->conf['name']) {
            throw new \Exception('Extension name has not been defined');
        }

        return $this->conf['name'];
    }

    /**
     * Get url-friendly slug, eg "vagrantfile-local"
     *
     * @return string
     * @throws \Exception
     */
    public function getSlug()
    {
        if (!$this->conf['slug']) {
            throw new \Exception('Extension slug has not been defined');
        }

        return $this->conf['slug'];
    }

    /**
     * Run extension's front controller action and return rendered content
     *
     * @param array  $data  Data required by controller template
     * @param string $extra Extra template string not belonging to specific extension
     * @return string
     */
    public function renderFront(array $data = [], $extra = null)
    {
        return $this->getFrontController()
            ->indexAction($data, $extra)
            ->getContent();
    }

    /**
     * Run extension's manifest controller action and return rendered content
     *
     * @param array $data Data required by controller template
     * @return null|string
     */
    public function renderManifest(array $data = [])
    {
        if (!$this->conf['manifestController']) {
            return null;
        }

        return $this->getManifestController()
            ->indexAction($data)
            ->getContent();
    }

    /**
     * Flag for returning available options in data
     *
     * eg all available PHP modules that user can choose from in drop down
     *
     * This is not desirable to show in the final hiera file
     *
     * @param bool $value
     * @return $this
     */
    public function setReturnAvailableData($value)
    {
        $this->returnAvailableData = $value;

        return $this;
    }

    /**
     * Whether any data came from outside sources
     *
     * eg user submitted their pre-generated hiera file
     *
     * @return bool
     */
    public function hasCustomData()
    {
        return empty($this->customData) ? false : true;
    }

    /**
     * Return the file the extension output will be saved to
     *
     * @return string
     */
    public function getTargetFile()
    {
        return $this->conf['targetFile'];
    }

    /**
     * Return all data needed for our templates
     *
     * @return array
     */
    public function getData()
    {
        // User-specified, or the default filled-on data
        $dataToMerge = empty($this->customData)
            ? $this->yamlParse('defaults.yml')
            : $this->customData;

        // All available options. Don't want these in generated user-facing yaml file
        if ($this->returnAvailableData) {
            $dataToMerge = array_merge(
                $this->getAvailableData(),
                $dataToMerge
            );
        }

        // Sane defaults for all data options
        $this->data = array_replace_recursive(
            $this->getBaseData(),
            $dataToMerge
        );

        return $this->data;
    }

    /**
     * Add user-supplied values
     *
     * @param array $data
     * @return $this
     */
    public function setCustomData(array $data = [])
    {
        $this->customData = $data;

        return $this;
    }

    /**
     * Our base data
     *
     * @return array
     */
    public function getBaseData()
    {
        if (empty($this->data)) {
            $this->data = $this->yamlParse('data.yml');
        }

        return $this->data;
    }

    public function getFrontController()
    {
        return $this->container->get($this->conf['frontController']);
    }

    public function getManifestController()
    {
        return $this->container->get($this->conf['manifestController']);
    }

    /**
     * Grab data to fill out available options
     *
     * @return array
     */
    protected function getAvailableData()
    {
        $available = $this->yamlParse('available.yml');

        return is_array($available)
            ? $available
            : [];
    }

    /**
     * Parse a YAML file from dataLocation root
     *
     * @param string $file
     * @return array
     */
    protected function yamlParse($file)
    {
        return Yaml::parse($this->dataLocation . '/' . $file);
    }
}


text:
classdef DeltawingPlant < DrakeSystem
% Defines the dynamics for the TBS Capi delta wing.

  properties
    parameters = {}; % extra arguments to pass to tbsc_model
  end

  methods
    function obj = DeltawingPlant(parameters)
      % @param parmaeters cell array of extra arguments to pass to
      % tbsc_model

      obj = obj@DrakeSystem(12,0,3,12,false,true);
      obj = setDirectFeedthrough(obj,0);
      obj = setOutputFrame(obj,getStateFrame(obj));

      obj = obj.setInputLimits([-0.90; -0.90; 0], [0.855; 0.855; 5.33976]); % input limits in [radians radians newtons]

      obj.parameters = parameters;

    end

    function [xdot, dxdot] = dynamics(obj, t, x, u)
      options = struct();
      options.grad_method = 'numerical';

      tempfunc = @(t, x, u) obj.dynamics_no_grad(t, x, u);

      [xdot, dxdot] = geval(tempfunc, t, x, u, options);
    end

    function xdot = dynamics_no_grad(obj,t,x,u)

      x = ConvertToModelFrameFromDrakeWorldFrame(x);

      xdot_model_frame = tbsc_model(t, x, u, obj.parameters{:});

      xdot = ConvertXdotModelToDrake(x, xdot_model_frame);

    end

    function [y,dy] = output(obj,t,x,u)
      y = x;
      if (nargout>1)
        dy=[zeros(obj.num_y,1),eye(obj.num_y),zeros(obj.num_y,obj.num_u)];
      end
    end

    function x = getInitialState(obj)
      x = zeros(12,1);
    end

  end

  methods (Static)

    function playback(xtraj, utraj, options)
      if nargin < 3
        options = struct();
      end

      v = DeltawingPlant.constructVisualizer;

      traj_and_u = [xtraj; utraj];

      fr = traj_and_u.getOutputFrame();

      transform_func = @(t, x, x_and_u) [ x_and_u(1:6); x_and_u(15); x_and_u(13:14); x_and_u(7:12); zeros(3,1)];

      trans = FunctionHandleCoordinateTransform(17, 0, traj_and_u.getOutputFrame(), v.getInputFrame(), true, true, transform_func, transform_func, transform_func);

      fr.addTransform(trans);

      warning('off', 'Drake:FunctionHandleTrajectory');
      playback(v, traj_and_u, options);
      warning('on', 'Drake:FunctionHandleTrajectory');

    end

    function playback_xtraj(xtraj, options)
      if nargin < 2
        options = struct();
      end

      utraj = ConstantTrajectory([0; 0; 0]);

      DrawTrajectoryLcmGl(xtraj);

      DeltawingPlant.playback(xtraj, utraj, options);

    end

    function v = constructVisualizer()
        options.floating = true;
        HudBotVisualizer.InitJava();
        r = RigidBodyManipulator('TBSC_visualizer.urdf', options);
        v = HudBotVisualizer(r);
    end

  end

end


text:
package com.fanbuting.entity;

public class FeedbackBean extends ResponseBean {
    public Long getFeedbackId() {
        return feedbackId;
    }

    public void setFeedbackId(Long feedbackId) {
        this.feedbackId = feedbackId;
    }

    public String getContactMobile() {
        return contactMobile;
    }

    public void setContactMobile(String contactMobile) {
        this.contactMobile = contactMobile;
    }

    public String getContactEmail() {
        return contactEmail;
    }

    public void setContactEmail(String contactEmail) {
        this.contactEmail = contactEmail;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    private Long feedbackId;
    private String contactMobile;
    private String contactEmail;
    private	String content;
}


text:
FOUNDATION_EXPORT double ObservableEventVersionNumber;

//! Project version string for ObservableEvent.
FOUNDATION_EXPORT const unsigned char ObservableEventVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <ObservableEvent/PublicHeader.h>


text:
#if !defined(FUSION_VALUE_OF_IMPL_07172005_0838)
#define FUSION_VALUE_OF_IMPL_07172005_0838

namespace boost { namespace fusion
{
    struct cons_iterator_tag;

    namespace extension
    {
        template <typename Tag>
        struct value_of_impl;

        template <>
        struct value_of_impl<cons_iterator_tag>
        {
            template <typename Iterator>
            struct apply
            {
                typedef typename Iterator::cons_type cons_type;
                typedef typename cons_type::car_type type;
            };
        };
    }

}}

#endif


text:
.. _bibliography:

************
Bibliography
************

References
----------

.. bibliography:: ../CoolPropBibTeXLibrary.bib
   :cited:
   :style: unsrt


text:
  <title>about</title>
  <link rel='stylesheet' type='text/css' href='./public/css/style.css' />
  <link href='http://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'>

home

this is a website that scrapes some other websites so that you can see, at a glance, what's happening tonight in charleston.

as an added bonus, you can also see what's coming up this week.

code is on github. feel free to fork/send a pull request.

created by dan hanf and morgan herlocker. inspired by dctn by tom macwright.


text:
<?php include "kfb_head.php" ?>

<?php include "kfb_menubar.php" ?>

Services

Food and Clothing Bank Area: low-income residents of the Kent School District.

***  Clients may visit twice a month for food service ***

					      <?php include "kfb_hours.php"; ?>

Obtain Elgibility

BRING THE FOLLOWING ITEMS TO OBTAIN A FOOD BANK CARD:

Picture Identification

Current proof-of-address:

For each adult: Current mail, lease, or bill not older than 30 days

For each school-aged child: Current piece of mail or proof of enrollment in KSD

For younger children: Birth Certificate.

TO RECEIVE FULL SERVICE EACH HOUSEHOLD MUST HAVE A CURRENT FOOD BANK CARD

After receiving a food bank card bring these items at EACH visit:

Picture Identification

Current Food Bank Card

						<!- page content ENDS here
					        page content ENDS here
					        page content ENDS here -->

						    <?php include "kfb_services_sidebar.php" ?>

	<?php include "kfb_footer.php" ?>


text:
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model backend\models\Estados */
/* @var $form yii\widgets\ActiveForm */
?>

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'nombre_estado')->textInput(['maxlength' => true]) ?>

	<?php if (!Yii::$app->request->isAjax){ ?>

	        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

	<?php } ?>

    <?php ActiveForm::end(); ?>


text:
package com.focusit.jitloganalyzer.tty.model;

import java.util.*;

/**
 * Created by dkirpichenkov on 30.11.16.
 */
public abstract class AbstractTTYEvent implements TTYEvent
{
    protected Map<String, Object> attributes = new HashMap<>();

    @Override
    public void setPreviousEvent(TTYEvent event)
    {

    }

    public double getStamp()
    {
        return Double.parseDouble(((String)attributes.get("stamp")).replace(",", "."));
    }

    public Map<String, Object> getAttributes(String line)
    {
        line = line.replace("<", "");
        line = line.replace("/>", "");
        line = line.replace(">", "");
        HashMap<String, Object> map = new HashMap<>();

        List<String> list = new ArrayList<>(Arrays.asList(line.split(" ")));
        list.remove(0);

        List<String> attr = new ArrayList<>();

        while (!list.isEmpty())
        {
            String item = list.get(0);
            if (item.endsWith("'"))
            {
                attr.add(item);
                list.remove(item);
            }
            else
            {
                int pos = 0;
                list.remove(item);
                while (!item.endsWith("'") && !list.isEmpty())
                {
                    item += " " + list.get(pos);
                    list.remove(0);
                }
                attr.add(item);
            }
        }

        attr.forEach(item -> {
            String[] attrs = item.split("=");
            if (attrs.length > 1)
                map.put(sanitizeAttr(attrs[0]), sanitizeValue(attrs[1]));
        });
        return map;
    }

    private String sanitizeValue(String value)
    {
        String result = value;
        if (result.startsWith("'"))
        {
            result = result.substring(1);
        }

        if (result.endsWith("'"))
        {
            result = result.substring(0, result.length() - 1);
        }
        return result;
    }

    private String sanitizeAttr(String attr)
    {
        return attr;
    }

    @Override
    public void processLine(String line)
    {
        this.attributes = getAttributes(line);
    }

    @Override
    public String toString()
    {
        return this.getClass().getSimpleName() + "{" + "attributes=" + attributes + '}';
    }
}


text:
package ru.job4j.triangle;

/**It's class for creating point.
 *@author Anton Oleynikov
 *@version 1
 */
public class Point {
    /**It's coordination of point.
     *@param x x
     */
    private double x;
    /**It's coordination of point.
     *@param y y
     */
    private double y;
    /**It's constructor.
     *@param x x
     *@param y y
     */
    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }
    /**It is for get distance between 2 point.
     *@param point Point
     *@return result
     */
    public double distanceTo(Point point) {
        return Math.sqrt(Math.pow((this.x - point.x), 2) + Math.pow((this.y - point.y), 2));
    }
}


text:
CardSchema = {
  cardID: "root", // String
  childrenCardIDs: [], // [String]
  parentCardIDs: [], // [String]

  speaker: "", // String
  filters: [], // [String]
  inputs: [], // [String]
  methods: [], // [String]

  cardType: "", // String
  cardBody: {
    messages: [], // [String]
  },

  ui: { // Only for visualization. Will get removed on final save.
    visible: true, // Boolean
    highlight: false, // Boolean

    xpos: 300, // Number
    ypos: 300, // Number
  }
};

GlobalEvents = {}; // Global event system.
GTC = require('./tree.js');

module.exports = {};


text:
require 'spec_helper'

describe ColorScheme do
  it "should respond with correct name" do
    cs = ColorScheme.new
    cs.course_type = "W"
    cs.name.should == "Wykład"

    cs = ColorScheme.new
    cs.course_type = "P"
    cs.name.should == "Projekt"
  end
end


text:
// Copyright (c) to owners found in https://github.com/AArnott/pinvoke/blob/master/COPYRIGHT.md. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.

namespace PInvoke
{
    /// <content>
    /// Contains all the "RT_" constants that represent resource types.
    /// </content>
    public partial class Kernel32
    {
        /// Hardware-dependent cursor resource.
        public static readonly unsafe char* RT_CURSOR = MAKEINTRESOURCE(1);

        /// Bitmap resource.
        public static readonly unsafe char* RT_BITMAP = MAKEINTRESOURCE(2);

        /// Hardware-dependent icon resource.
        public static readonly unsafe char* RT_ICON = MAKEINTRESOURCE(3);

        /// Menu resource.
        public static readonly unsafe char* RT_MENU = MAKEINTRESOURCE(4);

        /// Dialog box.
        public static readonly unsafe char* RT_DIALOG = MAKEINTRESOURCE(5);

        /// String-table entry.
        public static readonly unsafe char* RT_STRING = MAKEINTRESOURCE(6);

        /// Font directory resource.
        public static readonly unsafe char* RT_FONTDIR = MAKEINTRESOURCE(7);

        /// Font resource.
        public static readonly unsafe char* RT_FONT = MAKEINTRESOURCE(8);

        /// Accelerator table.
        public static readonly unsafe char* RT_ACCELERATOR = MAKEINTRESOURCE(9);

        /// Application-defined resource (raw data).
        public static readonly unsafe char* RT_RCDATA = MAKEINTRESOURCE(10);

        /// Message-table entry.
        public static readonly unsafe char* RT_MESSAGETABLE = MAKEINTRESOURCE(11);

        /// Hardware-independent cursor resource.
        public static readonly unsafe char* RT_GROUP_CURSOR = MAKEINTRESOURCE(12);

        /// Hardware-independent icon resource.
        public static readonly unsafe char* RT_GROUP_ICON = MAKEINTRESOURCE(14);

        /// Version resource
        public static readonly unsafe char* RT_VERSION = MAKEINTRESOURCE(16);

        ///
        ///     Allows a resource editing tool to associate a string with an .rc file. Typically, the string is the name of the
        ///     header file that provides symbolic names. The resource compiler parses the string but otherwise ignores the value.
        ///     For example,
        ///     <para>
        ///         1 DLGINCLUDE "MyFile.h"
        ///     </para>
        ///
        public static readonly unsafe char* RT_DLGINCLUDE = MAKEINTRESOURCE(17);

        /// Plug and Play resource.
        public static readonly unsafe char* RT_PLUGPLAY = MAKEINTRESOURCE(19);

        /// VXD.
        public static readonly unsafe char* RT_VXD = MAKEINTRESOURCE(20);

        /// Animated cursor.
        public static readonly unsafe char* RT_ANICURSOR = MAKEINTRESOURCE(21);

        /// Animated icon.
        public static readonly unsafe char* RT_ANIICON = MAKEINTRESOURCE(22);

        /// HTML resource.
        public static readonly unsafe char* RT_HTML = MAKEINTRESOURCE(23);
    }
}


text:
  Template.sections.sections = function(){
    return Sections.find({},{sort:{createdOn: -1}});
  };

  Template.sections.nameFeedback = function(){
    return Session.get("sectionNameFeedback");
  };

  Template.sections.addNewSection = function(){
      var theName = $('.newSectionName').val();
      if(
        SectionNameValidator.isValid(theName)){
        Sections.insert({
          createdOn: Date.now(),
          autor: Meteor.user()._id,
          name: theName
        });
        $('.newSectionName').val("");
      };
  };

  Template.sections.events({
    'click .addNewSection': function(){
      Template.sections.addNewSection();
    },
  });

  SectionNameValidator = {
    clear: function(){
      return Session.set("sectionNameFeedback",undefined);
    },
    setFeedback: function(aString){
      return Session.set("sectionNameFeedback",aString);
    },
    isValid: function(aString){
      this.clear();
      if(aString.length==0){
        this.setFeedback("Sorry, the section name can't be empty");
        return false;
      } else { return true; }
    },
  };


text:
layout: post
comments: true
title: Code Golf
mt_id: 153
date: 2007-10-26 07:46:32 -07:00
---
I stumbled across a [code golf](http://golf.shinh.org) earlier this week that offers numerous problems.  The specific challenge I came across was the [fizz buzz](http://en.wikipedia.org/wiki/Bizz_buzz) problem that I had been introduced to a few weeks ago.

My initial attempt in Perl was this:

for (1..100) {
    $a = "";
    $a = "Fizz" if !($_ % 3);

    if (!($_ % 5)) {
        $a .= "Buzz"
    } elsif ($_ % 3) {
        $a = $_
    }

    print "$a\n"
}

Nothing special at all, just some fairly tight, clean code.  Aside from the broken apart `if` block and the use of bad variable names (`$a`, `$_`) it wouldn't look out of place in a normal program.  After exhausting my knowledge of esoteric Perl, I whittled it down to this:

for (1..100) {
    $a = ($_ % 3) ? "" : "Fizz";
    $a .= "Buzz" if !($_ % 5);

    $a ||= $_;

    print "$a\n"
}

With a bit of digging, I found that I could use the `+` and `,` operators as part of `print` to get rid of that `$a` assignment:

for (1..100) {
    $a = ($_ % 3) ? "" : "Fizz";
    $a .= "Buzz" if !($_ % 5);

    print + $a || $_, "\n"
}

But you certainly don't need most of the parenthesis, and Perl deals with barewords just fine:

for (1..100) {
    $a = $_ % 3 ? "" : Fizz;
    $a .= Buzz if !($_ % 5);

    print + $a || $_, "\n"
}

Finally, after reading through [`perlvar`](http://perldoc.perl.org/perlvar.html) I found that the input record separator, which defaults to "\n", can take the place of that four-character newline:

for (1..100) {
    $a = $_ % 3 ? "" : Fizz;
    $a .= Buzz if !($_ % 5);

    print + $a || $_, $/
}

101 characters, but you can go a step further, drop the $a assignment and condense those statements down below:

for (1..100) {
    print + ($_ % 3 ? "" : Fizz) . ($_ % 5 ? "" : Buzz) || $_, $/
}

Finally, since this is now a single Perl statement, the curly braces can be eliminated by placing the loop control at the end (thanks to Fotios for that tip).  After you beat the whitespace out, you end up with 56 characters:

print+($_%3?"":Fizz).($_%5?"":Buzz)||$_,$/for(1..100)

[Q.E.D.](http://en.wikipedia.org/wiki/Q.E.D.)


text:
package com.paulvarry.intra42.fragments;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import com.google.android.material.card.MaterialCardView;
import com.google.android.material.chip.Chip;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.paulvarry.intra42.AppClass;
import com.paulvarry.intra42.R;
import com.paulvarry.intra42.api.ApiService;
import com.paulvarry.intra42.api.ServiceGenerator;
import com.paulvarry.intra42.api.model.Events;
import com.paulvarry.intra42.api.model.EventsUsers;
import com.paulvarry.intra42.utils.Analytics;
import com.paulvarry.intra42.utils.Calendar;
import com.paulvarry.intra42.utils.DateTool;
import com.paulvarry.intra42.utils.Tag;
import com.paulvarry.intra42.utils.Tools;

import java.util.Date;
import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * A simple {@link Fragment} subclass.
 * Activities that contain this fragment must implement the
 * {@link EventFragment.OnFragmentInteractionListener} interface
 * to handle interaction events.
 * Use the {@link EventFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class EventFragment extends Fragment implements View.OnClickListener {

    private static final String ARG_EVENT = "event";
    private static final String ARG_SHOW_TITLE = "show_title";

    private Button buttonSubscribe;
    private LinearLayout linearLayoutProgress;
    private ProgressBar progressBarButton;

    private AppClass appClass;
    private ApiService api;
    private Call<List<EventsUsers>> listCallEventsUsers;
    private FirebaseAnalytics mFirebaseAnalytics;

    private EventsUsers eventsUsers;
    private Events event;
    private boolean showTitle;

    private Callback<List<EventsUsers>> callback = new Callback<List<EventsUsers>>() {
        @Override
        public void onResponse(Call<List<EventsUsers>> call, Response<List<EventsUsers>> response) {

            linearLayoutProgress.setVisibility(View.INVISIBLE);
            progressBarButton.setVisibility(View.GONE);
            buttonSubscribe.setEnabled(true);
            eventsUsers = null;
            if (response.isSuccessful()) {
                if (response.body() != null && !response.body().isEmpty())
                    eventsUsers = response.body().get(0);

                setButtonSubscribe();

                Calendar.syncEventCalendarAfterSubscription(getContext(), event, eventsUsers);
            }
        }

        @Override
        public void onFailure(Call<List<EventsUsers>> call, Throwable t) {
            Context context = getContext();
            if (context != null)
                Toast.makeText(context, t.getMessage(), Toast.LENGTH_SHORT).show();
            linearLayoutProgress.setVisibility(View.INVISIBLE);
            progressBarButton.setVisibility(View.GONE);
            buttonSubscribe.setEnabled(true);
        }
    };

    private Callback<Void> callbackDelete = new Callback<Void>() {
        @Override
        public void onResponse(Call<Void> call, Response<Void> response) {

            linearLayoutProgress.setVisibility(View.INVISIBLE);
            progressBarButton.setVisibility(View.GONE);
            buttonSubscribe.setEnabled(true);
            eventsUsers = null;
            if (response.isSuccessful()) {
                setButtonSubscribe();
                Context context = getContext();
                if (context != null) {
                    Toast.makeText(getContext(), R.string.event_unsubscribed, Toast.LENGTH_SHORT).show();
                    Calendar.syncEventCalendarAfterSubscription(context, event, eventsUsers);
                }
            }
        }

        @Override
        public void onFailure(Call<Void> call, Throwable t) {
            Context context = getContext();
            if (context != null)
                Toast.makeText(context, t.getMessage(), Toast.LENGTH_SHORT).show();
            linearLayoutProgress.setVisibility(View.INVISIBLE);
            progressBarButton.setVisibility(View.GONE);
            buttonSubscribe.setEnabled(true);
        }
    };

    private Callback<EventsUsers> callbackSubscribe = new Callback<EventsUsers>() {
        @Override
        public void onResponse(Call<EventsUsers> call, Response<EventsUsers> response) {

            linearLayoutProgress.setVisibility(View.INVISIBLE);
            progressBarButton.setVisibility(View.GONE);
            buttonSubscribe.setEnabled(true);
            eventsUsers = null;
            if (response.isSuccessful()) {
                eventsUsers = response.body();
                setButtonSubscribe();

                Context context = getContext();
                if (context != null) {
                    Toast.makeText(context, R.string.event_subscribed, Toast.LENGTH_SHORT).show();
                    Calendar.syncEventCalendarAfterSubscription(context, event, eventsUsers);
                }
            }
        }

        @Override
        public void onFailure(Call<EventsUsers> call, Throwable t) {
            if (isAdded()) {
                Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
                linearLayoutProgress.setVisibility(View.INVISIBLE);
                progressBarButton.setVisibility(View.GONE);
                buttonSubscribe.setEnabled(true);
            }
        }
    };

    private OnFragmentInteractionListener mListener;

    public EventFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param event The event to build this fragment.
     * @return A new instance of fragment EventFragment.
     */
    public static EventFragment newInstance(Events event) {
        return newInstance(ServiceGenerator.getGson().toJson(event));
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param event The event to build this fragment.
     * @return A new instance of fragment EventFragment.
     */
    public static EventFragment newInstance(Events event, boolean showTitle) {
        return newInstance(ServiceGenerator.getGson().toJson(event), showTitle);
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param json The json to build this fragment.
     * @return A new instance of fragment EventFragment.
     */
    public static EventFragment newInstance(String json) {
        EventFragment fragment = new EventFragment();
        Bundle args = new Bundle();
        args.putString(ARG_EVENT, json);
        fragment.setArguments(args);
        return fragment;
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param json The json to build this fragment.
     * @return A new instance of fragment EventFragment.
     */
    public static EventFragment newInstance(String json, boolean showTitle) {
        EventFragment fragment = new EventFragment();
        Bundle args = new Bundle();
        args.putString(ARG_EVENT, json);
        args.putBoolean(ARG_SHOW_TITLE, showTitle);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            event = ServiceGenerator.getGson().fromJson(getArguments().getString(ARG_EVENT), Events.class);
            showTitle = getArguments().getBoolean(ARG_SHOW_TITLE, true);
        }
        mFirebaseAnalytics = FirebaseAnalytics.getInstance(requireContext());
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_event, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (event != null)
            setView(view);
    }

    private void setView(View contentView) {

        FragmentActivity activity = getActivity();
        if (activity == null)
            return;
        appClass = (AppClass) activity.getApplication();
        api = appClass.getApiService();

        if (!appClass.userIsLogged())
            return;

        TextView textViewTitle = contentView.findViewById(R.id.textViewTitle);
        Chip tagViewKind = contentView.findViewById(R.id.tagViewKind);
        TextView textViewDate = contentView.findViewById(R.id.textViewDate);
        TextView textViewTime = contentView.findViewById(R.id.textViewTime);
        LinearLayout linearLayoutPlace = contentView.findViewById(R.id.linearLayoutPlace);
        TextView textViewPlace = contentView.findViewById(R.id.textViewPlace);
        TextView textViewPeople = contentView.findViewById(R.id.textViewPeople);
        ViewGroup linearLayoutPeople = contentView.findViewById(R.id.linearLayoutPeople);
        MaterialCardView cardViewUnsubscribeLimit = contentView.findViewById(R.id.cardViewUnsubscribeLimit);
        TextView textViewUnsubscribeLimit = contentView.findViewById(R.id.textViewUnsubscribeLimit);
        TextView textViewDescription = contentView.findViewById(R.id.textViewDescription);
        buttonSubscribe = contentView.findViewById(R.id.buttonSubscribe);
        linearLayoutProgress = contentView.findViewById(R.id.linearLayoutProgress);
        progressBarButton = contentView.findViewById(R.id.progressBarButton);

        if (event.kind != null) {
            tagViewKind.setVisibility(View.VISIBLE);
            Tag.setTagEvent(event, tagViewKind);
        } else
            tagViewKind.setVisibility(View.GONE);

        textViewTitle.setText(event.name);
        textViewTitle.setVisibility(showTitle ? View.VISIBLE : View.GONE);

        String date = DateTool.getTodayTomorrow(getContext(), event.beginAt, true);

        if (DateTool.sameDayOf(event.beginAt, event.endAt)) {
            date += DateTool.getDateLong(event.beginAt);
            textViewDate.setText(date);
            String time = DateTool.getTimeShort(event.beginAt) + " - " + DateTool.getTimeShort(event.endAt);
            textViewTime.setText(time);
        } else {
            date += DateTool.getDateTimeLong(event.beginAt);
            textViewDate.setText(date);
            String time = DateTool.getDateTimeLong(event.endAt);
            textViewTime.setText(time);
        }

        if (event.location == null || event.location.isEmpty())
            linearLayoutPlace.setVisibility(View.GONE);
        else {
            linearLayoutPlace.setVisibility(View.VISIBLE);
            textViewPlace.setText(event.location);
        }

        linearLayoutPeople.setVisibility(View.GONE);
        if (event.maxPeople != null) {
            String people;
            if (event.maxPeople == 0)
                people = getString(R.string.event_subscription_unavailable);
            else
                people = event.nbrSubscribers + " / " + event.maxPeople;
            linearLayoutPeople.setVisibility(View.VISIBLE);
            textViewPeople.setText(people);
        }
        cardViewUnsubscribeLimit.setVisibility(View.GONE);
        if (event.prohibitionOfCancellation != null) {
            Date cancellationLimit = event.getCancellationLimit();
            String timeFormatted = DateTool.getDateTimeLong(cancellationLimit);
            cardViewUnsubscribeLimit.setVisibility(View.VISIBLE);
            textViewUnsubscribeLimit.setText(getString(R.string.event_prohibition_of_cancellation, timeFormatted));
        }

        Tools.setMarkdown(getContext(), textViewDescription, event.description);

        progressBarButton.setVisibility(View.GONE);
        buttonSubscribe.setEnabled(false);
        linearLayoutProgress.setVisibility(View.VISIBLE);
        listCallEventsUsers = api.getEventsUsers(appClass.me.id, event.id);
        listCallEventsUsers.enqueue(callback);

        buttonSubscribe.setOnClickListener(this);
    }

    public void onButtonPressed(Uri uri) {
        if (mListener != null) {
            mListener.onFragmentInteraction(uri);
        }
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof OnFragmentInteractionListener) {
            mListener = (OnFragmentInteractionListener) context;
        } else {
            throw new RuntimeException(context.toString()
                    + " must implement OnFragmentInteractionListener");
        }
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    /**
     * Called when a view has been clicked.
     *
     * @param v The view that was clicked.
     */
    @Override
    public void onClick(View v) {
        progressBarButton.setVisibility(View.VISIBLE);
        buttonSubscribe.setEnabled(false);
        if (eventsUsers == null) {
            api.createEventsUsers(event.id, appClass.me.id).enqueue(callbackSubscribe);
            Analytics.eventSubscribe(Analytics.EventSource.APPLICATION);
        } else {
            api.deleteEventsUsers(eventsUsers.id).enqueue(callbackDelete);
            Analytics.eventUnsubscribe(Analytics.EventSource.APPLICATION);
        }
    }

    void setButtonSubscribe() {
        linearLayoutProgress.setVisibility(View.INVISIBLE);
        progressBarButton.setVisibility(View.GONE);
        buttonSubscribe.setEnabled(true);

        if (eventsUsers == null) {
            if (DateTool.isInFuture(event.beginAt)) {
                buttonSubscribe.setEnabled(true);
                buttonSubscribe.setText(R.string.event_subscribe);
            } else {
                buttonSubscribe.setEnabled(false);
                buttonSubscribe.setText(R.string.event_subscription_unavailable);
            }
            if (event.maxPeople != null && event.nbrSubscribers >= event.maxPeople) {

                if (event.maxPeople == 0)
                    buttonSubscribe.setText(R.string.event_subscription_unavailable);
                else
                    buttonSubscribe.setText(R.string.event_full);
                buttonSubscribe.setEnabled(false);
            }
        } else {
            buttonSubscribe.setText(R.string.event_unsubscribe);
            if (DateTool.isInFuture(event.beginAt))
                buttonSubscribe.setEnabled(true);
            else
                buttonSubscribe.setEnabled(false);
            if (event.prohibitionOfCancellation != null) {
                Date cancellationLimit = event.getCancellationLimit();
                if (DateTool.isInPast(cancellationLimit)) {
                    buttonSubscribe.setEnabled(false);
                    buttonSubscribe.setText(R.string.event_cancellation_date_exceeded);
                }
            }
            Calendar.syncEventCalendarAfterSubscription(getContext(), event, eventsUsers);
        }
    }

    public void setEvent(Events event) {
        this.event = event;
        setView(getView());
    }

    /**
     * This interface must be implemented by activities that contain this
     * fragment to allow an interaction in this fragment to be communicated
     * to the activity and potentially other fragments contained in that
     * activity.
     *

     * See the Android Training lesson Communicating with Other Fragments for more information.
     */
    public interface OnFragmentInteractionListener {
        void onFragmentInteraction(Uri uri);
    }
}