text:
/*
	Reset
*/

article, aside, dialog, figure, footer, header, hgroup, nav, section { display: block; }
body, form, ol, ul, dl, li, dt, dd, td, th ,tr, h1, h2, h3, h4, h5, h6, p, pre, blockquote, address, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
img { border:0; }
fieldset { margin: 0; padding: 0; border: 0; }
input, select, textarea { font-size: 100%; vertical-align: middle; }
table { border-collapse: collapse; border-spacing: 0; empty-cells: show; }
th { text-align: left; }
a:focus { overflow: hidden; }

/*
	Clearfix
*/

.clearfix:after {
	content: ".";
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
}

.ie6 .clearfix,
.ie7 .clearfix {
	zoom: 1;
}

/*
	General
*/

body {
	font-family: 'PTSerifRegular', Times, serif;
	font-size: 16px;
	line-height: 1.5;
	color: #62615d;
	background-image: url('../images/background.png');
}

/*
	Typography and text styles
*/

/* General */

p {
	padding: 25px 0 25px 0;
}

th, thead td {
	font-weight: 700;
}

/* Headings */

h1, h2, h3, h4 {
	font-family: 'LeagueGothicRegular', Verdana, Arial, sans-serif;
	color: #000;
	font-weight: normal;
	padding: 25px 0;
}

h1 {
	font-size: 48px;
	line-height: 1em;
}

h2 {
	font-size: 30px;
}

h3 {
	font-size: 18px;
	color: #62615d;
	margin: 0 0 10px 0;
	text-transform: uppercase;
}

h4 {
	font-size: 16px;
}

/* Links */

a {
	text-decoration: none;
}

a:link {
	color: #62615d;
}

a:visited {
	color: #62615d;
}

a:hover,
a:active,
a:focus {
	color: #51504d;
}

/* .content defaults */

.content ul {
	list-style: none;
	padding: 0 0 12px 0;
}

.content ul li a:link,
.content ul li a:visited {
	color: #6cc;
	font-size: 16px;
	text-transform: uppercase;
}

.content ul li a:hover {
	text-decoration: underline;
}

#bottom ul li a:link {
	color: #6cc;
	font-size: 16px;
	text-transform: capitalize;
}

.content ol {
	list-style-type: decimal;
	padding: 0 0 12px 12px;
}

.content dl {
	padding: 0 0 12px 12px;
}

.content ul ul,
.content ul ol,
.content ol ul,
.content ol ol {
	padding-bottom: 0;
}

.content code {
	font-family: Monaco, "Courier New", monospace;
}

.content pre {
	font-size: 12px;
	line-height: 18px;
	background: #F5F5F5;
	margin: 0 0 12px 0;
	padding: 10px;
}

.content blockquote,
.content q {
	font-style: italic;
	color: #666;
}

.content blockquote {
	padding: 0 10px;
	padding: 12px 0;
}

.content cite,
.content em {
	font-style: italic;
	font-size: 18px;
	color: #a2a19e;
}

.content table {
	width: 100%;
	border-top: 1px solid #000;
	border-left: 1px solid #000;
}

.content td,
.content th {
	border-right: 1px solid #000;
	border-bottom: 1px solid #000;
	font-size: 11px;
	padding: 4px;
}

.content th {
	font-weight: 700;
}

.content h1+p {
	font-size: 14px;
}

.content p+h2 {
	margin: 13px 0 13px 0;
}

/*
	Page structure and layout
*/

#containerWrapper {
	position: relative;
	margin: 0 auto;
	background: url(../images/header_bg.png) top no-repeat;
}

/*
	Header
*/

	/* Banner */

	#header {
		position: relative;
		width: 1250px;
		height: 120px;
		margin: 0 auto;
	}

	/* Logo */

	#logo {
		float: left;
		position: absolute;
		top: 45px;
		left: 50px;
	}

		#logo h1,
		#logo p {
			width: 65px;
			height: 27px;
			background: url(../images/logo.png) no-repeat;
			text-indent: -9999px;
			padding: 0;
		}

			#logo h1 a,
			#logo p a {
				width: 100%;
				height: 100%;
				display: block;
				overflow: hidden;
				border: none;
			}

	#printLogo {
		display: none;
	}

	/* Navigation */

	#navigation {
		font-family: 'LeagueGothicRegular';
		letter-spacing: 2px;
		text-transform: uppercase;
	}

	#navigation h4 {
		text-indent: -9999px;
	}

		#navigation ul {
			position: absolute;
			right: 500px;
			top: 53px;
			float: right;
		}

			#navigation ul li {
				float: left;
				text-align: center;
			}

			#navigation ul li+li {
				margin: 0 0 0 35px;
			}

		#navigation a:link,
		#navigation a:visited {
			color: #fff; font-size: 18px;
		}

		#navigation a:hover {
			text-decoration: underline;
		}

			#navigation .selected a {
				color: #000;
				background: #6cc url(../images/menu_filth.png);
				padding: 5px 12px 4px 12px;
				border: 1px #777 solid;
				box-shadow: 0 0 0 4px #6cc;
				-moz-box-shadow: 0 0 0 4px #6cc;
				-webkit-box-shadow: 0 0 0 4px #6cc;
			}

			#navigation .selected a:hover {
				text-decoration: none;
			}

	/* Search */

	#searchFormWidget {
		position: absolute;
		left: 860px;
		top: 50px;
		z-index: 9;
	}

		#searchFormWidget p {
			padding: 0;
		}

			#searchFormWidget input[type=text] {
				width: 340px;
				height: 34px;
				background: rgba(51,51,51,0.5);
				font-size: 18px;
				color: #222;
				border: 1px solid rgba(247,246,242,0.2);
				box-shadow: 0 0 3px 3px #333;
				-moz-box-shadow: 0 0 3px 3px #333;
				-webkit-box-shadow: 0 0 3px 3px #333;
				font-family: 'LeagueGothicRegular';
				text-transform: uppercase;
				letter-spacing: 1px;
			}

				#searchFormWidget input[type=text]:focus {
					background: rgba(255,255,255,0.5);
				}

			#searchFormWidget input[type=submit] {
				border: none;
				width: 35px;
				height: 35px;
				background: url(../images/search_icon.png) no-repeat center center;
				position: absolute;
				bottom: 0;
				left: 315px;
				z-index: 10;
				cursor: pointer;
				color: transparent;
				box-shadow: none;
				-moz-box-shadow: none;
				-webkit-box-shadow: none;
			}

/*
	Content
*/

	#contentWrapper {
		position: relative;
		background: url(../images/content_bg.png) repeat-y;
		box-shadow: 0 0 4px 4px rgba(0,0,0,0.7);
		-moz-box-shadow: 0 0 4px 4px rgba(0,0,0,0.7);
		-webkit-box-shadow: 0 0 4px 4px rgba(0,0,0,0.7);
		width: 1250px;
		margin: 0 auto;
		min-height: 500px;
	}

	/* Main section styling */

	#main {
		position: relative;
		width: 798px;
		float: left;
	}

		#main h3 {
			font-size: 30px;
			color: #000;
		}

		#main h3 a {
			color: #000;
		}

		#main .inner {
			background: url(../images/border.png) bottom no-repeat;
			padding: 25px 50px 25px 50px;
		}

			#main .bd .mod:last-child .inner {
				background: none;
			}

		#main #blogComments .inner {
			background: none;
		}

	/* Blog styling */

	#share ul{
		display: block !important;
	}

	#blogIndex .hd ul li,
	#blogDetail .hd ul li {
		display: inline;
	}

	.commentCount {
		text-transform: uppercase;
		color: #6cc;
		text-align: right;
		float: right;
	}

	.comment {
		background: url(../images/border.png) bottom no-repeat;
		margin: 33px 0 0 0;
	}

	h3#comments {
		font-size: 30px;
		color: #000;
	}

	#blogCommentForm .message {
		padding: 0;
	}

	#commentForm {
		margin: 33px 0 0 0;
	}

		#commentForm p {
			padding: 25px 0 0 0;
		}

		#commentsForm .alignBlocks {
			left: 0;
		}

			#commentsForm .alignBlocks p {
				width: 300px;
				overflow: visible;
			}

		#commentsForm .floatRight {
			margin: 0 12px 0 0;
		}

	.alignBlocks {
		position: relative;
	}

		.alignBlocks:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
		.ie6 .alignBlocks, .ie7 .alignBlocks { zoom: 1; }

			.alignBlocks p {
				overflow: hidden;
				float: left;
			}

	.inputText {
		background: #e8e7e3;
		border: #d9d8d4 1px solid;
		height: 40px;
		font-size: 18px;
		width: 100%;
	}

	.textarea {
		width: 686px;
		max-width: 686px;
		background: #e8e7e3;
		border: #d9d8d4 1px solid;
		font-size: 18px;
	}

	#main #blogCommentForm .inputSubmit {
		color: #fff;
		background: #6cc url(../images/menu_filth.png);
		padding: 9px 19px 7px 19px;
		border: 1px #777 solid;
		box-shadow: 0 0 0 4px #6cc;
		-moz-box-shadow: 0 0 0 4px #6cc;
		-webkit-box-shadow: 0 0 0 4px #6cc;
		cursor: pointer;
		text-transform: uppercase;
	}

	#main #blogCommentForm .inputSubmit:hover {
		color: #fff;
		background: #57bebf url(../images/menu_filth.png);
		padding: 9px 19px 7px 19px;
		border: 1px #777 solid;
		box-shadow: 0 0 0 4px #57bebf;
		-moz-box-shadow: 0 0 0 4px #57bebf;
		-webkit-box-shadow: 0 0 0 4px #57bebf;
		cursor: pointer;
	}

	#leftArrow {
		margin: 0 20px 0 0;
	}

	#rightArrow {
		margin: 0 0 0 20px;
	}

	/* Sub pages styling */

	#subpagesBlocks {
		padding: 50px;
	}

	.subpagesBlock {
		margin: 0 0 50px 0;
	}

		.subpagesBlock h3 {
			padding: 0;
		}

	/* FAQ styling */

	#faq .inner {
		padding: 50px;
	}

		#faq .inner .bd .inner {
			padding: 25px 10px;
		}

			#faq .hd ul li {
				display: inline;
				margin: 0 20px 0 0;
			}

			#faq .hd ul li+li {
				border-left: 1px solid #6cc;
				padding: 0 0 0 20px;
			}

	/* Location module styling */

	#map {
		margin: 50px 50px 0 50px;
	}

		#map h1 {
			font-size: 22px;
			padding: 0 0 5px 0;
		}

		#map p {
			padding: 0;
		}

	/* Profile styling */

	.message {
		padding: 25px 50px;
	}

	/* Right section styling */

	#right {
		position: relative;
		float: right;
		width: 352px;
		padding: 50px;
	}

		#right p {
			color: #a2a19e;
		}

	#subscribe {
		margin: 0;
		width: 244px;
		height: 42px;
		color: #a2a19e;
		font-family: 'PTSerifRegular';
		font-size: 14px;
	}

		.blackButton {
			color: #ffce6b;
			background: #000 url(../images/menu_filth.png);
			padding: 7px 11px 5px 11px;
			border: 1px #777 solid;
			box-shadow: 0 0 0 4px #000;
			-moz-box-shadow: 0 0 0 4px #000;
			-webkit-box-shadow: 0 0 0 4px #000;
			cursor: pointer;
			font-size: 18px;
			text-transform: uppercase;
		}

		.blackButton:hover {
			color: #ffce6b;
			background: #333 url(../images/menu_filth.png);
			padding: 7px 11px 5px 11px;
			border: 1px #777 solid;
			box-shadow: 0 0 0 4px #333;
			-moz-box-shadow: 0 0 0 4px #333;
			-webkit-box-shadow: 0 0 0 4px #333;
			cursor: pointer;
			font-size: 18px;
			text-transform: uppercase;
		}

/*
	Footer
*/

	#footer {
		position: relative;
		width: 1150px;
		margin: 0 auto;
		padding: 40px 50px 37px 50px;
		background: rgba(0,0,0,0.4);
		margin-bottom: 100px;
	}

		#footer .floatRight {
			margin-top: -25px;
		}

		#footer a:link,
		#footer a:visited {
			color: #a2a19e;
		}

	#bottom {
		position: relative;
		width: 1150px;
		padding: 30px 50px 30px 50px;
		margin: 0 auto;
		background: rgba(0,0,0,0.4);
		margin-bottom: 1px;
	}

		#bottom h3 {
			font-size: 20px;
			color: #ffce6b;
			margin: 0;
			padding: 0 0 25px 0;
		}

	#bottomLeft {
		width: 698px;
	}

	#bottomRight {
		position: absolute;
		left: 796px;
		top: 0;
		width: 352px;
		padding: 30px 50px 30px 50px;
	}

/*
	Pagination
*/

.pagination {
	padding: 42px 50px;
	overflow: hidden;
	border: 0;
}

.ie6 .pagination {
	width: auto;
}

	.pagination header {
		position: absolute;
		top: -9999px;
		left: -9999px;
		text-indent: -9999px;
	}

	.pagination .bd {
		float: left;
		position: relative;
		left: 50%;
	}

	.ie6 .pagination .bd {
		position: static;
	}

		.pagination ul {
			padding: 0 0 12px 0;
			overflow: hidden;
			position: relative;
			left: -50%;
		}

		.ie6 .pagination ul {
			position: static;
		}

			.pagination li {
				float: left;
				margin: 0 4px 0 0;
				line-height: 15px;
				font-size: 12px;
				font-size: 11px;
				line-height: 1.636;
				text-align: center;
			}

			.pagination li.previousPage span,
			.pagination li.nextPage span {
				float: left;
				padding: 5px 8px;
				min-width: 12px;
				border: 1px solid #d8d8d8;
				background: #ebebeb;
				color: #666;
				   -moz-border-radius: 5px;
				-webkit-border-radius: 5px;
				        border-radius: 5px;
			}

				.pagination li.currentPage span {
					float: left;
					padding: 5px 8px;
					min-width: 12px;
					border: 1px solid #d8d8d8;
					background: #ebebeb;
					font-weight: 700;
					   -moz-border-radius: 3px;
					-webkit-border-radius: 3px;
					        border-radius: 3px;
				}

				.pagination li.ellipsis span {
					float: left;
					padding: 6px 4px 4px 4px;
					min-width: 12px;
					color: #666;
				}

				.pagination li a,
				.pagination li a:visited {
					float: left;
					padding: 5px 8px;
					min-width: 12px;
					border: 1px solid #d8d8d8;
					background: #fff;
					   -moz-border-radius: 5px;
					-webkit-border-radius: 5px;
					        border-radius: 5px;
					   -moz-background-clip: padding;
					-webkit-background-clip: padding-box;
					        background-clip: padding-box;
				}

				.pagination li a:hover,
				.pagination li a:active,
				.pagination li a:focus {
					border: 1px solid #a3a3a3;
				}

/*
	Form styles
*/

input, textarea, select, button {
	font-family: 'LeagueGothicRegular';
	padding: 0 0 0 10px;
	letter-spacing: 1px;
}

form input[type="text"] {
	font-family: 'PTSerifRegular';
	letter-spacing: normal;
	font-size: 12px;
	color: #62615d;
}

form p {
	text-transform: uppercase;
	font-size: 14px;
}

/*
	General classes
*/

.hidden { display: none; }
.block { display: block; }
.noPadding { padding: 0 !important; }
.noMargin { margin: 0 !important; }
.floatLeft { float: left; }
.floatRight { float: right !important; }
.noBorder { border: none; }
.fullWidth { width: 686px; }
.letterSpacing {
	letter-spacing: 1px;
	text-transform: uppercase;
}
#skip, .accessibility { position: absolute; top: -9999px; left: -9999px; } /* For screenreaders */

/*
	Image classes
*/

img.alignLeft {
	float: left;
	padding: 0 10px 10px 0;
}

img.alignRight {
	float: right;
	padding: 0 0 10px 10px;
}

.linkedImage {
	border: none !important;
}

img.border {
	padding: 2px;
	border: #dad9d5 1px solid;
	float: left;
	margin: 0 20px 0 0;
}

/*
	Print styles
*/

@media print {
	* {
		color: #000 !important;
		float: none;
		text-shadow: none;
	}

	div {
		background-color: white !important;
	}

	/* place the divs and elements you want to hide here */
	#skip, #headerNavigation, #headerLanguage, #headerSearch, #headerFocus, #footer, aside {
		display: none;
	}

	#printLogo {
		display: block;
	}

	body {
		font-family: Arial, sans-serif;
		font-size: 12pt;
		background: #FFF;
		border: none;
	}

	p {
		padding: 0 0 20px 0;
	}

	ul, ol {
		padding: 0 0 20px 30px;
	}

	h1, h2, h3, h4, h5, h6 {
		font-weight: 700;
	}

	h1 {
		font-size: 20pt;
		padding: 0 0 10px 0;
	}

	h2 {
		font-size: 16pt;
		padding: 0 0 8px 0;
	}

	h3 {
		font-size: 14pt;
		padding: 0 0 6px 0;
	}

	h4 {
		font-size: 12pt;
		padding: 0 0 6px 0;
	}

	blockquote {
		padding-left: 2.5cm;
		font-style: italic;
	}

	table {
		font-family: Arial, sans-serif;
		margin: 0 10px 20px;
		border-top: 1px solid #D9D9D9;
		border-left: 1px solid #D9D9D9;
	}

	table td, th {
		padding: 5px 10px;
		border-right: 1px solid #D9D9D9;
		border-bottom: 1px solid #D9D9D9;
	}

	table th {
		font-weight: 700;
		background: #D9D9D9;
		color: #000;
	}
}

/* Font embed */

@font-face {
    font-family: 'LeagueGothicRegular';
    src: url('../fonts/league_gothic-webfont.eot');
    src: url('../fonts/league_gothic-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/league_gothic-webfont.woff') format('woff'),
         url('../fonts/league_gothic-webfont.ttf') format('truetype'),
         url('../fonts/league_gothic-webfont.svg#LeagueGothicRegular') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PTSerifRegular';
    src: url('../fonts/PTF55F-webfont.eot');
    src: url('../fonts/PTF55F-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/PTF55F-webfont.woff') format('woff'),
         url('../fonts/PTF55F-webfont.ttf') format('truetype'),
         url('../fonts/PTF55F-webfont.svg#PTSerifRegular') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PTSerifItalic';
    src: url('../fonts/PTF56F-webfont.eot');
    src: url('../fonts/PTF56F-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/PTF56F-webfont.woff') format('woff'),
         url('../fonts/PTF56F-webfont.ttf') format('truetype'),
         url('../fonts/PTF56F-webfont.svg#PTSerifItalic') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PTSerifBold';
    src: url('../fonts/PTF75F-webfont.eot');
    src: url('../fonts/PTF75F-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/PTF75F-webfont.woff') format('woff'),
         url('../fonts/PTF75F-webfont.ttf') format('truetype'),
         url('../fonts/PTF75F-webfont.svg#PTSerifBold') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PTSerifBoldItalic';
    src: url('../fonts/PTF76F-webfont.eot');
    src: url('../fonts/PTF76F-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/PTF76F-webfont.woff') format('woff'),
         url('../fonts/PTF76F-webfont.ttf') format('truetype'),
         url('../fonts/PTF76F-webfont.svg#PTSerifBoldItalic') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PTSerifCaptionRegular';
    src: url('../fonts/PTZ55F-webfont.eot');
    src: url('../fonts/PTZ55F-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/PTZ55F-webfont.woff') format('woff'),
         url('../fonts/PTZ55F-webfont.ttf') format('truetype'),
         url('../fonts/PTZ55F-webfont.svg#PTSerifCaptionRegular') format('svg');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'PTSerifCaptionItalic';
    src: url('../fonts/PTZ56F-webfont.eot');
    src: url('../fonts/PTZ56F-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/PTZ56F-webfont.woff') format('woff'),
         url('../fonts/PTZ56F-webfont.ttf') format('truetype'),
         url('../fonts/PTZ56F-webfont.svg#PTSerifCaptionItalic') format('svg');
    font-weight: normal;
    font-style: normal;
}

/*
	Forms
	Media: screen, projection
	Author: Yoni De Beule
	        Johan Ronsse
*/

/* General fields and textareas */

textarea {
	line-height: 1.5;
}

input.inputText:focus,
input.inputPassword:focus,
input.inputSearch:focus,
input.inputDate:focus,
textarea:focus {
	background-color: #fff;
	background-image: none;
	background-image: -moz-linear-gradient(0% 3px 90deg,#fff, #dedede);
	background-image: -webkit-gradient(linear, 0% 0%, 0% 3, from(#dedede), to(#fff));
	-webkit-box-shadow: 0 0 3px #c2deff;
	-moz-box-shadow: 0 0 3px #c2deff;
	box-shadow: 0 0 3px #c2deff;
	border-color: #82a7d4;
	color: #000;
	outline: none
}

input.inputText[disabled],
input.inputPassword[disabled],
input.inputSearch[disabled],
input.inputDate[disabled],
textarea[disabled] {
	color: #999;
	background-color: #f4f4f4;
	background-image: none;
	background-image: -moz-linear-gradient(0% 3px 90deg,#f4f4f4, #c4c4c4);
	background-image: -webkit-gradient(linear, 0% 0%, 0% 3, from(#c4c4c4), to(#f4f4f4));
}

/* Selects */

select {
	margin-top: 2px;
}

	option {
		width: auto;
	}

/* Input lists */

.inputList {
	padding-bottom: 6px;
}

	.inputList li {
		padding-left: 24px;
		position: relative;
		padding-bottom: 6px;
		list-style-type: none;
	}

		.inputList input {
			position: absolute;
			top: 0;
			left: 0;
		}

		.ie6 .inputList input {
			left: -24px;
		}

		.inputList label {
			overflow: visible;
			height: auto;
			padding: 0;
		}

/* Fieldsets and legends */

.visibleFieldset {
	border: 1px solid #ddd;
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	padding: 12px 12px 0 12px;
	margin-bottom: 12px;
}

.visibleFieldset:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ie6 .visibleFieldset, .ie7 .visibleFieldset { zoom: 1; }

	legend {
		font-weight: 700;
		color: #999;
	}

		.ie6 legend {
			margin-bottom: 10px;
		}

/* Paragraph */

form p { padding: 0 0 12px; }
form p:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ie6 form p, .ie7 form p { zoom: 1; }

/* Labels */

label,
.label {
	display: block;
	padding-bottom: 2px;
	height: 18px;
	overflow: hidden;
}

/* Inline errors */

.errorArea input.inputText,
.errorArea input.inputPassword,
.errorArea input.inputSearch,
.errorArea input.inputDate,
.errorArea textarea {
	border: 1px solid #d00c00;
}

.errorArea label,
.errorArea .label {
	color: #d00c00;
}

.errorArea input.inputText:focus,
.errorArea input.inputPassword:focus,
.errorArea input.inputSearch:focus,
.errorArea input.inputDate:focus {
	-webkit-box-shadow: 0 0 3px #d00c00;
	-moz-box-shadow: 0 0 3px #d00c00;
	box-shadow: 0 0 3px #d00c00;
}

.errorArea .inlineError,
.errorArea .formError {
	font-size: 11px;
	line-height: 1.636;
	color: #d00c00;
	display: block;
	height: 18px;
	overflow: hidden;
	white-space: nowrap;
	clear: left;
	text-overflow: ellipsis;
}

/* Help texts */

.helpTxt {
	font-size: 11px;
	line-height: 1.636;
	color: #999;
	display: block;
	height: 18px;
	overflow: hidden;
	white-space: nowrap;
	clear: left;
	text-overflow: ellipsis;
}

/* Form grid control */

	/* One-fourth width */

	.tinyInput input.inputText,
	.tinyInput input.inputPassword,
	.tinyInput input.tinyInput,
	.tinyInput input.inputDate {
		width: 16px;
	}

	.tinyInput select,
	.alignBlocks p.tinyInput,
	.alignFields p.tinyInput,
	.alignFields .tinyInput .helpTxt {
		width: 26px;
	}

	/* Half width */

	.smallInput input.inputText,
	.smallInput input.inputPassword,
	.smallInput input.inputSearch,
	.smallInput input.inputDate {
		width: 52px;
	}

	.smallInput select,
	.alignBlocks p.smallInput,
	.alignFields p.smallInput,
	.alignFields .smallInput .helpTxt {
		width: 62px;
	}

	/* Normal width */

	select,
	.alignBlocks p,
	.alignFields p,
	.alignFields p .helpTxt,
	.horizontal label,
	.horizontal .label,
	.horizontal .oneLiner :first-child label,
	.horizontal .oneLiner :first-child .label,
	.horizontal .oneLiner .firstChild label,
	.horizontal .oneLiner .firstChild .label {
		width: 134px;
	}

	/* Two-third width */

	.mediumInput select,
	.alignBlocks p.mediumInput,
	.alignFields p.mediumInput,
	.alignFields .mediumInput .helpTxt {
		width: 206px;
	}

	/* Double width */

	.bigInput select,
	.alignBlocks p.bigInput,
	.alignFields p.bigInput,
	.alignFields .bigInput .helpTxt {
		width: 278px;
	}

	/* Left padding (horizontal) */

	.horizontal .alignBlocks,
	.horizontal .alignFields,
	.horizontal .alignButtons,
	.horizontal .helpTxt,
	.horizontal .inlineError,
	.horizontal .formError {
		padding-left: 134px; /* This value should be the same as the width value in "Normal width" */
	}

	/* Left margin (horizontal) */

	.horizontal input.inputSubmit,
	.horizontal input.inputButton,
	.horizontal button,
	.horizontal a.button {
		margin-left: 134px; /* This value should be the same as the width value in "Normal width" */
	}

	/* Maximum width for inputlist (horizontal) */

	.horizontal .inputList li label {
		width: 278px; /* This value should be the same as the width value in "Double width" */
	}

/* Floating elements */

	/* Floating blocks */

	.alignBlocks {
		position: relative;
		left: -5px;
		padding-bottom: 12px;
	}

	.alignBlocks:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
	.ie6 .alignBlocks, .ie7 .alignBlocks { zoom: 1; }

		.alignBlocks p {
			overflow: hidden;
			float: left;
		}

	/* Floating fields */

	.alignFields {
		position: relative;
		padding-bottom: 12px;
	}

	.alignFields:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
	.ie6 .alignFields, .ie7 .alignFields { zoom: 1; }

		.alignFields label {
			position: absolute;
			top: 0;
			left: 0;
		}

		.alignFields input,
		.alignFields select {
			float: left;
		}

		.ie6 .alignFields input,
		.ie6 .alignFields select,
		.ie7 .alignFields input,
		.ie7 .alignFields select {
			float: none;
		}

		.alignFields p {
			padding: 20px 12px 0 0;
			float: left;
		}

	/* Floating buttons */

	.alignButtons {
		padding-bottom: 12px;
	}

	.alignButtons:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
	.ie6 .alignButtons, .ie7 .alignButtons { zoom: 1; }

		.alignButtons p {
			float: left;
			padding-right: 4px;
			padding-bottom: 0;
		}

/* Oneliners */

.oneLiner:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ie6 .oneLiner, .ie7 .oneLiner { zoom: 1; }

	.oneLiner p {
		float: left;
		padding: 0 6px 0 0;
	}

		.oneLiner label {
			float: left;
			padding-right: 6px;
		}

		.oneLiner input,
		.oneLiner select {
			float: left;
		}

	.oneLiner .inputList {
		padding-bottom: 0;
	}

	.ie6 .oneLiner .inputList input {
		left: 0;
	}

		.oneLiner .inputList li {
			float: left;
			padding-bottom: 0;
		}

/* Horizontal */

.horizontal label,
.horizontal .label {
	float: left;
}

	/* Floating blocks */

	.horizontal .alignBlocks .helpTxt,
	.horizontal .alignBlocks .inlineError,
	.horizontal .alignBlocks .formError {
		padding-left: 0;
	}

	/* Floating fields */

	.horizontal .alignFields .helpTxt,
	.horizontal .alignFields .inlineError,
	.horizontal .alignFields .formError {
		padding-left: 0;
	}

	.horizontal .alignFields p {
		padding-top: 0;
	}

		.horizontal .alignFields label {
			top: 2px;
		}

	/* Floating buttons */

	.horizontal .alignButtons input.inputSubmit,
	.horizontal .alignButtons input.inputButton,
	.horizontal .alignButtons button,
	.horizontal .alignButtons a.button,
	.horizontal .alignFields input.inputSubmit,
	.horizontal .alignFields input.inputButton,
	.horizontal .alignFields button,
	.horizontal .alignFields a.button,
	.horizontal .alignBlocks input.inputSubmit,
	.horizontal .alignBlocks input.inputButton,
	.horizontal .alignBlocks button,
	.horizontal .alignBlocks a.button {
		margin-left: 0;
	}

	/* Inputlists */

	.horizontal .inputList:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
	.ie6 .horizontal .inputList, .ie7 .horizontal .inputList { zoom: 1; }

	.horizontal .inputList ul {
		float: left;
	}

		.horizontal .inputList li label {
			float: none;
		}

	/* Oneliners */

	.horizontal .oneLiner label,
	.horizontal .oneLiner .label {
		width: auto;
		padding: 2px 6px 2px 0;
	}

		.horizontal .oneLiner :first-child label,
		.horizontal .oneLiner :first-child .label,
		.horizontal .oneLiner .firstChild label,
		.horizontal .oneLiner .firstChild .label {
			padding: 2px 0;
		}

		.horizontal .formSectionContent .oneLiner :first-child label,
		.horizontal .formSectionContent .oneLiner :first-child .label,
		.horizontal .formSectionContent .oneLiner .firstChild label,
		.horizontal .formSectionContent .oneLiner .firstChild .label {
			width: auto;
			padding: 2px 6px 2px 0;
		}

	.horizontal .oneLiner input.inputSubmit,
	.horizontal .oneLiner input.inputButton,
	.horizontal .oneLiner button,
	.horizontal .oneLiner a.button {
		margin-left: 0;
	}

	.horizontal .oneLiner .inputList {
		float: left;
	}

		.horizontal .oneLiner .inputList li label {
			width: auto;
		}

	/* Form sections */

	.formSection {
		padding: 0 0 8px 0;
	}

	.formSection:after  { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
	.ie6 .formSection, .ie7 .formSection { zoom: 1; }

		.formSection p {
			padding-bottom: 2px;
		}

		.formSection .oneLiner p {
			padding-bottom: 0;
		}

	.horizontal .formSectionContent {
		padding-bottom: 4px;
		float: left;
	}

	.horizontal .formSectionContent .alignBlocks,
	.horizontal .formSectionContent .alignFields,
	.horizontal .formSectionContent .alignButtons,
	.horizontal .formSectionContent .helpTxt,
	.horizontal .formSectionContent .inlineError,
	.horizontal .formSectionContent .formError {
		padding-left: 0;
	}

/* Messages */

.message {
	padding: 12px 12px 0 12px;
	border: 1px solid #ddd;
	margin-bottom: 24px;
	border-color: #ddd;
	color: #333;
	background-color: #fff;
	background-image: none;
	background-image: -moz-linear-gradient(0% 100% 90deg,#fff, #f8f8f8);
	background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f8f8f8), to(#fff));
	-moz-box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
	-webkit-box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
	box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1);
	-moz-border-radius: 5px;
	-webkit-border-radius: 5px;
	border-radius: 5px;
	position: relative;
}

	.message .close:link,
	.message .close:visited {
		display: block;
		position: absolute;
		overflow: hidden;
		padding: 4px;
		top: 4px;
		right: 4px;
		height: 8px;
		width: 8px;
		border: 0;
		text-indent: -9999px;
		background: url(../images/close.png) no-repeat 4px 4px;

		opacity: .50;
		filter: alpha(opacity=50);
		-ms-filter: "alpha(opacity=50)";
		-khtml-opacity: .50;
		-moz-opacity: .50;
	}

	.message .close:hover,
	.message .close:active,
	.message .close:focus {
		opacity: 1;
		filter: alpha(opacity=100);
		-ms-filter: "alpha(opacity=100)";
		-khtml-opacity: 1;
		-moz-opacity: 1;
	}

	/* Error messages */

	.error {
		border-color: #8b0800;
		color: #fae7e6;
		background-color: #d00c00;
		background-image: none;
		background-image: -moz-linear-gradient(0% 100% 90deg,#d00c00, #b80900);
		background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#b80900), to(#d00c00));
	}

	.error h1,
	.error h2,
	.error h3,
	.error h4 {
		color: #fff;
	}

		.error a {
			color: #fff;
			border-color: #df5c54;
		}

		.error a:link,
		.error a:visited {
			color: #fff;
			border-color: #df5c54;
		}

		.error a:hover,
		.error a:active,
		.error a:focus {
			color: #fff;
			border-color: #fff;
		}

	/* Success messages */

	.success {
		border-color: #4c721f;
		color: #f1f7eb;
		background-color: #72aa2e;
		background-image: none;
		background-image: -moz-linear-gradient(0% 100% 90deg,#72aa2e, #65a01c);
		background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#65a01c), to(#72aa2e));
	}

	.success h1,
	.success h2,
	.success h3,
	.success h4 {
		color: #fff;
	}

		.success a {
			color: #fff;
			border-color: #a0c673;
		}

		.success a:link,
		.success a:visited {
			color: #fff;
			border-color: #a0c673;
		}

		.success a:hover,
		.success a:active,
		.success a:focus {
			color: #fff;
			border-color: #fff;
		}

	/* Notice messages */

	.notice {
		border-color: #e6901e;
		color: #332d1c;
		background-color: #ffe38a;
		background-image: none;
		background-image: -moz-linear-gradient(0% 100% 90deg,#ffe38a, #ffce58);
		background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ffce58), to(#ffe38a));
	}

	.notice h1,
	.notice h2,
	.notice h3,
	.notice h4 {
		color: #000;
	}

		.notice a {
			color: #000;
			border-color: #ab985d;
		}

		.notice a:link,
		.notice a:visited {
			color: #000;
			border-color: #ab985d;
		}

		.notice a:hover,
		.notice a:active,
		.notice a:focus {
			color: #000;
			border-color: #000;
		}

/* Buttons */

button::-moz-focus-inner { padding: 0; border: 0 }

@media screen and (-webkit-min-device-pixel-ratio:0) {
	input.inputSubmit,
	input.inputButton,
	button {
		padding: 2px 3px;
	}
}

.ie6 input.inputSubmit,
.ie6 input.inputButton,
.ie6 button {
	margin-top: -1px;
	padding: 1px 3px;
}

.ie7 input.inputSubmit,
.ie7 input.inputButton,
.ie7 button {
	padding: 1px 3px 0 3px;
}

.ie8 input.inputSubmit,
.ie8 input.inputButton,
.ie8 button {
	padding: 2px 3px;
}

input.inputSubmit:hover,
input.inputButton:hover,
input.buttonHover,
button:hover,
button.buttonHover,
a.button:hover,
a.button:active,
a.button:focus {
	background: #2d5c91;
	background: -moz-linear-gradient(top, #366eac 0%, #6facf1 100%);
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#366eac), color-stop(100%,#6facf1));
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#366EAC', endColorstr='#6FACF1',GradientType=0 )chroma(color=#000000);
}

input.inputSubmit[disabled="disabled"],
input.inputButton[disabled="disabled"],
button[disabled="disabled"],
a.disabledButton {
	cursor: default;
	opacity: .50;
	filter: alpha(opacity=50);
	-ms-filter: "alpha(opacity=50)";
	-khtml-opacity: .50;
	-moz-opacity: .50;
}

a.button,
a.button:link,
a.button:visited {
	float: left;
	text-decoration: none;
	padding: 2px 6px;
}


text:
package com.cloud.consoleproxy;

import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;

import org.apache.log4j.Logger;

import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupProxyCommand;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.host.Host.Type;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.info.ConsoleProxyInfo;
import com.cloud.keystore.KeystoreDao;
import com.cloud.keystore.KeystoreManager;
import com.cloud.resource.ResourceManager;
import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
import com.cloud.utils.NumbersUtil;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.VMInstanceDao;

@Local(value={ConsoleProxyManager.class})
public class StaticConsoleProxyManager extends AgentBasedConsoleProxyManager implements ConsoleProxyManager,
        ResourceStateAdapter {
    private static final Logger s_logger = Logger.getLogger(StaticConsoleProxyManager.class);

    @Inject
    ConsoleProxyDao _proxyDao;
    @Inject
    ResourceManager _resourceMgr;
    @Inject
    ConfigurationDao _configDao;
    @Inject
    private VMInstanceDao _instanceDao;
    @Inject
    KeystoreDao _ksDao;
    @Inject
    private KeystoreManager _ksMgr;
    @Inject
    private HostDao _hostDao;
    private final Random _random = new Random(System.currentTimeMillis());
    private String _hashKey;
    private String _ip = null;

    @Override
    protected HostVO findHost(VMInstanceVO vm) {

        List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByType(Type.ConsoleProxy, vm.getDataCenterId());

        return hosts.isEmpty() ? null : hosts.get(0);
    }

    @Override
    public ConsoleProxyInfo assignProxy(long dataCenterId, long userVmId) {
        return new ConsoleProxyInfo(_sslEnabled, _ip, _consoleProxyPort, _consoleProxyUrlPort, _consoleProxyUrlDomain);
    }

    @Override
    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
        super.configure(name, params);
        _ip = _configDao.getValue("consoleproxy.static.publicIp");
        if (_ip == null) {
            _ip = "127.0.0.1";
        }

        String value = (String) params.get("consoleproxy.sslEnabled");
        if (value != null && value.equalsIgnoreCase("true")) {
            _sslEnabled = true;
        }
        int defaultPort = 8088;
        if (_sslEnabled)
            defaultPort = 8443;
        _consoleProxyUrlPort = NumbersUtil.parseInt(_configDao.getValue("consoleproxy.static.port"), defaultPort);

        _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);

        return true;
    }

    @Override
    public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
        if (!(cmd[0] instanceof StartupProxyCommand)) {
            return null;
        }

        host.setType(com.cloud.host.Host.Type.ConsoleProxy);
        return host;
    }

    @Override
    public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource,
            Map<String, String> details, List<String> hostTags) {
        return null;
    }

    @Override
    public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage)
            throws UnableDeleteHostException {
        return null;
    }

}

redpajama_set_name: RedPajamaGithub


text:
require 'rails_helper'

feature 'Searching orders' do
  let(:joseph) do
    Customer.create!(title: 'Mr', first_name: 'Joseph',
                     last_name: 'Smith', address: '123 Sesame Street',
                     city_town: 'Wellington', post_code: '1234',
                     ta: 'wellington')
  end
  let(:ordered_item) { Item.first }
  let(:another_item) { Item.last }
  let!(:order) { Order.create!(customer: joseph, item_ids: [ordered_item.id]) }

  let(:josephine) do
    Customer.create!(title: 'Mrs', first_name: 'Josephine',
                     last_name: 'Smithson', address: '45 Sesame Crescent',
                     city_town: 'Wellington', post_code: '1234',
                     ta: 'wellington')
  end
  let!(:order_for_second_customer) { Order.create!(customer: josephine, item_ids: [another_item.id]) }

  background do
    login_as_admin
    visit admin_orders_path
  end

  scenario "Viewing all orders" do
    ViewOrdersPage.new do |page|
      page.assert_expected_results(2)
    end

    expect(page).to have_text("Joseph Smith")
    expect(page).to have_text("Josephine Smithson")
  end

  scenario "Searching by first name" do
    ViewOrdersPage.new do |page|
      page.search_by('First name' => "Josephine")
      page.assert_expected_results(1)

      expect(page).to have_text("Josephine Smithson")
      expect(page).not_to have_text("Joseph Smith")
    end
  end

  scenario "Exporting a CSV" do
    ViewOrdersPage.new do |page|
      page.export_to_csv
      page.assert_csv_headers
      page.assert_csv_content
    end
  end
end


text:
var util = require('util');
var path = require('path');
var fs = require('fs');
var assert = require('assert');
var postcss = require('postcss');
var ofg = require('../');

var fixturesFolder = path.join(__dirname, 'fixtures');

var config = getConfig();

describe('CSS Grid Functions', function(){
	config.tests.forEach(function(test){
		var comment = util.format('/*%s (%s)*/\n/*%s*/\n', test.name, test.method, test.description);
		var prepend = test.prepend || '';
		var options = test.config || {};
		var expected = test.expected;
		var testName = util.format("%s (%s): %s", test.name, test.method, test.description);
		it(testName, function(done){
			postcss( [new ofg(options)] )
			.process(prepend + test.input)
			.then(function(result){
				var structure = {};
				result.root.walkRules(function(rule){
					structure[rule.selector] = {}
					rule.walkDecls(function(decl){
						structure[rule.selector][decl.prop] = decl.value;
					})
				})
				try {
					assert.deepEqual(expected, structure);
					done();
				} catch (e) {
					done(e);
				}
				// try {
				// 	assert.equal(outputCss, comment + result.css);
				// 	done();
				// } catch (e) {
				// 	done(e);
				// }
			})
			.catch(function(e){
				console.log('\nERROR\n***\n%s\n***', e);
			})
		})
	})
})

function getConfig() {
	var configFile = fs.readFileSync(path.join(__dirname, 'test.json'));
	try {
		return config = JSON.parse(configFile);
	} catch (e) {
		throw e;
	}
}


text:
import os
import numpy as np
from PIL import Image

from singa import device
from singa import tensor
from singa import autograd
from singa import sonnx
import onnx
from utils import download_model, update_batch_size, check_exist_or_download

import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')

def preprocess(img):
    img = img.resize((256, 256))
    img = img.crop((16, 16, 240, 240))
    img = np.array(img).astype(np.float32) / 255.
    img = np.rollaxis(img, 2, 0)
    for channel, mean, std in zip(range(3), [0.485, 0.456, 0.406],
                                  [0.229, 0.224, 0.225]):
        img[channel, :, :] -= mean
        img[channel, :, :] /= std
    img = np.expand_dims(img, axis=0)
    return img

def get_image_labe():
    # download label
    label_url = 'https://s3.amazonaws.com/onnx-model-zoo/synset.txt'
    with open(check_exist_or_download(label_url), 'r') as f:
        labels = [l.rstrip() for l in f]

    # download image
    image_url = 'https://s3.amazonaws.com/model-server/inputs/kitten.jpg'
    img = Image.open(check_exist_or_download(image_url))
    return img, labels

class Infer:

    def __init__(self, sg_ir):
        self.sg_ir = sg_ir
        for idx, tens in sg_ir.tensor_map.items():
            # allow the tensors to be updated
            tens.requires_grad = True
            tens.stores_grad = True
            sg_ir.tensor_map[idx] = tens

    def forward(self, x):
        return sg_ir.run([x])[0]

if __name__ == "__main__":

    url = 'https://s3.amazonaws.com/onnx-model-zoo/resnet/resnet18v1/resnet18v1.tar.gz'
    download_dir = '/tmp/'
    model_path = os.path.join(download_dir, 'resnet18v1', 'resnet18v1.onnx')

    logging.info("onnx load model...")
    download_model(url)
    onnx_model = onnx.load(model_path)

    # set batch size
    onnx_model = update_batch_size(onnx_model, 1)

    # prepare the model
    logging.info("prepare model...")
    dev = device.create_cuda_gpu()
    sg_ir = sonnx.prepare(onnx_model, device=dev)
    autograd.training = False
    model = Infer(sg_ir)

    # verifty the test
    # from utils import load_dataset
    # inputs, ref_outputs = load_dataset(os.path.join('/tmp', 'resnet18v1', 'test_data_set_0'))
    # x_batch = tensor.Tensor(device=dev, data=inputs[0])
    # outputs = model.forward(x_batch)
    # for ref_o, o in zip(ref_outputs, outputs):
    #     np.testing.assert_almost_equal(ref_o, tensor.to_numpy(o), 4)

    # inference
    logging.info("preprocessing...")
    img, labels = get_image_labe()
    img = preprocess(img)

    logging.info("model running...")
    x_batch = tensor.Tensor(device=dev, data=img)
    y = model.forward(x_batch)

    logging.info("postprocessing...")
    y = tensor.softmax(y)
    scores = tensor.to_numpy(y)
    scores = np.squeeze(scores)
    a = np.argsort(scores)[::-1]
    for i in a[0:5]:
        logging.info('class=%s ; probability=%f' % (labels[i], scores[i]))


text:
// -----------------------------------------------------------------------------------
// <copyright file="TransactionContext.cs" company="NMemory Team">
//     Copyright (C) 2012-2014 NMemory Team
//
//     Permission is hereby granted, free of charge, to any person obtaining a copy
//     of this software and associated documentation files (the "Software"), to deal
//     in the Software without restriction, including without limitation the rights
//     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//     copies of the Software, and to permit persons to whom the Software is
//     furnished to do so, subject to the following conditions:
//
//     The above copyright notice and this permission notice shall be included in
//     all copies or substantial portions of the Software.
//
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//     THE SOFTWARE.
// </copyright>
// -----------------------------------------------------------------------------------
#pragma warning disable 1591
namespace NMemory.Transactions
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class TransactionContext : IDisposable
    {
        private readonly System.Transactions.CommittableTransaction transaction;
        private bool completed;

        public TransactionContext()
        {
            this.transaction = null;
            this.completed = false;
        }

        public TransactionContext(System.Transactions.CommittableTransaction transaction)
        {
            this.transaction = transaction;
            this.completed = false;
        }

        public void Complete()
        {
            this.completed = true;
        }

        public void Dispose()
        {
            if (this.transaction != null)
            {
                if (this.completed)
                {
                    this.transaction.Commit();
                }
                else
                {
                    this.transaction.Rollback();
                }
            }
        }
    }
}


text:
const Book = require('./book.model'),
	imageSvc = require('./image.service'),
	errors = require('restify-errors'),
	multer = require('multer');

const version = '1.0.0';
const path = '/api/v1/book';

const searchLimit = 100;
const pageSize = 15;

module.exports = (server, config) => {
	const upload = multer({dest: config.tempDir});

	server.get({path, version}, async (req, res, next) => {
		const query = req.query.q;
		const pageNum = req.query.pn - 1;

		let cnt = null;
		if (pageNum >= 0) {
			cnt = await Book.search({query, searchLimit})
				.count()
				.exec();
		}

		const books = await Book.search({query, pageNum, searchLimit, pageSize})
			.select('title author year era publisher estValue')
			.exec();

		const response = {query, books};
		if (pageNum >= 0) {
			response.pageNum = pageNum + 1;
			response.maxPages = Math.ceil(cnt / pageSize);
		}
		res.send(response);
		next();
	});

	server.get({path: `${path}/:id`, version}, async (req, res, next) => {
		const book = await Book.findById(req.params.id)
			.select('title author year era publisher estValue notes')
			.exec();

		if (!book) {
			next(new errors.ResourceNotFoundError());
			return;
		}
		res.send(book);
		next();
	})

	server.post({path, version}, upload.single('cover'), async (req, res, next) => {
		const data = req.body.title ? req.body : req.params;
		if (req.files && req.files.cover)
			data.cover = await imageSvc.consumeCover(req.files.cover.path);

		const book = new Book(data);
		await book.save();

		const response = {id: book._id};
		res.send(response);
		next();
	});

	server.patch({path: `${path}/:id`, version}, async (req, res, next) => {
		// ** TODO: We only support notes for now.
		//
		var book = await Book.findByIdAndUpdate(
			req.params.id,
			{notes: req.body.notes}
		)
		.exec();

		if (!book) {
			next(new errors.ResourceNotFoundError());
			return;
		}

		res.send(200);
		next();
	});

	return server;
};


text:
namespace Voodle.Entities
{
    using System;
    using System.Collections.Generic;

    public partial class PushNotification
    {
        public int ID { get; set; }
        public int MobileDeviceID { get; set; }
        public string Message { get; set; }
        public int Status { get; set; }
        public System.DateTime CreatedAt { get; set; }
        public System.DateTime ModifiedAt { get; set; }
        public string Description { get; set; }

        public virtual MobileDevice MobileDevice { get; set; }
    }
}


text:
We've learned a lot over the last few chapters. Let's take that new knowledge
and apply it by building a project together. Along the way, we'll learn a bit
more about Rust's standard library.

So what should we build? One that uses Rust's strengths. A great use of Rust is
for command line tools: Rust's speed, safety, 'single binary' output, and
cross-platform support make it a good language choice for this kind of task. So
we'll make our own version of a classic command line tool: `grep`. `grep` is
short for "Globally search a Regular Expression and Print." In the
simplest use case, it does this:

1. Takes a filename and a string as arguments.
2. Reads the file.
3. Finds lines in the file that contain the string argument.
4. Prints out those lines.

In addition, we'll add one extra feature: an environment variable that will
allow us to search for the string argument in a case-insensitive way.

There's another great reason to use `grep` as an example project: a very
fully-featured version of `grep` has already been created in Rust by a
community member, Andrew Gallant. It's called `ripgrep`, and it's very,
very fast. While our version of `grep` will be fairly simple, you'll have
some of the background knowledge to understand that project if you want to see
something more real-world.

This project will bring together a number of things we learned previously:

- Organize code (using what we learned in modules, Chapter 7)
- Use vectors and strings (collections, Chapter 8)
- Handle errors (Chapter 9)
- Use traits and lifetimes where appropriate (Chapter 10)
- Have tests (Chapter 11)

Additionally, we'll briefly introduce closures, iterators, and trait objects,
which Chapters XX, YY, and ZZ respectively are about to cover in detail.

Let's create a new project with, as always, `cargo new`:

```text
$ cargo new --bin greprs
     Created binary (application) `greprs` project
$ cd greprs
```

We're calling our version of `grep` 'greprs', so that we don't confuse any of
our users into thinking that it's the more fully-featured version of `grep`
they may already have installed on their system.


text:
using System;
using System.IO;
using System.Text;
using Cronical.Misc;

namespace Cronical.Configuration
{
    public class ConfigReader
    {
        public class DefinitionArgs : EventArgs
        {
            public string Definition;
            public string Value;
        }

        public class JobArgs : EventArgs
        {
            public bool Reboot;
            public bool Service;
            public string Minute;
            public string Hour;
            public string Day;
            public string Month;
            public string Weekday;
            public string Command;
        }

        public class InvalidConfigArgs : EventArgs
        {
            public string Text;
            public int LineNo;
        }

        public event EventHandler<JobArgs> JobRead;
        public event EventHandler<DefinitionArgs> DefinitionRead;
        public event EventHandler<InvalidConfigArgs> InvalidConfig;

        public void Read(string filename)
        {
            using (var fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            using (var reader = new StreamReader(fs))
            {
                var c = 0;
                while (!reader.EndOfStream)
                {
                    var line = TrimComment(reader.ReadLine()).Trim();
                    c++;

                    if (string.IsNullOrEmpty(line))
                        continue;

                    if (ParseCommand(line))
                        continue;

                    if (ParseJob(line))
                        continue;

                    InvalidConfig?.Invoke(this, new InvalidConfigArgs { LineNo = c, Text = line });
                }
            }
        }

        internal static string TrimComment(string line)
        {
            if (string.IsNullOrWhiteSpace(line))
                return "";

            var result = new StringBuilder(line.Length);
            for (var i = 0; i < line.Length; i++)
            {
                var c = line[i];

                // \#
                if (c == '\\' && i < line.Length && line[i + 1] == '#')
                {
                    result.Append('#');
                    i++;
                    continue;
                }

                if (c == '#')
                    break;

                result.Append(c);
            }

            return result.ToString().Trim();
        }

        private bool ParseCommand(string line)
        {
            var s = line.Trim();

            var cmd = StringParser.ExtractWord(ref s);
            var equals = StringParser.ExtractWord(ref s);

            if (equals != "=")
                return false;

            DefinitionRead?.Invoke(this, new DefinitionArgs { Definition = cmd, Value = s });

            return true;
        }

        private bool ParseJob(string line)
        {
            var job = DoParseJobLine(line);
            if (job != null)
                JobRead?.Invoke(this, job);

            return job != null;
        }

        public static JobArgs DoParseJobLine(string line)
        {
            var def = (line ?? "").Trim().Replace("\t", " ");
            if (string.IsNullOrWhiteSpace(def) || def[0] == '#')
                return null;

            var result = new JobArgs();

            if (def[0] == '@')
            {
                var spec = StringParser.ExtractWord(ref def).ToLower();

                switch (spec)
                {
                    case "@service":
                        result.Service = true;
                        result.Command = def;
                        return result;

                    case "@reboot":
                        result.Reboot = true;
                        result.Command = def;
                        return result;

                    case "@yearly": def = "0 0 1 1 * " + def; break;
                    case "@annually": def = "0 0 1 1 * " + def; break;
                    case "@monthly": def = "0 0 1 * * " + def; break;
                    case "@weekly": def = "0 0 * * 0 " + def; break;
                    case "@daily": def = "0 0 * * * " + def; break;
                    case "@hourly": def = "0 * * * * " + def; break;

                    default:
                        return null;
                }
            }

            try
            {
                result.Minute = StringParser.ExtractWord(ref def);
                result.Hour = StringParser.ExtractWord(ref def);
                result.Day = StringParser.ExtractWord(ref def);
                result.Month = StringParser.ExtractWord(ref def);
                result.Weekday = StringParser.ExtractWord(ref def);

                result.Command = def;

                return result;
            }
            catch (Exception)
            {
                return null;
            }
        }
    }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Fetching Options and Arguments — Zend Framework 2 2.3.0dev documentation</title>

    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />

    <link rel="top" title="Zend Framework 2 2.3.0dev documentation" href="../index.html" />

Navigation

          index

Zend Framework 2 2.3.0dev documentation »

Fetching Options and Arguments¶

After you have declared the options that the <tt class="docutils literal">Zend\Console\Getopt</tt> object should recognize, and supply arguments
from the command-line or an array, you can query the object to find out which options were specified by a user in a
given command-line invocation of your program. The class implements magic methods so you can query for options by
name.

The parsing of the data is deferred until the first query you make against the <tt class="docutils literal">Zend\Console\Getopt</tt> object to
find out if an option was given, the object performs its parsing. This allows you to use several method calls to
configure the options, arguments, help strings, and configuration options before parsing takes place.

Handling Getopt Exceptions¶

If the user gave any invalid options on the command-line, the parsing function throws a
<tt class="docutils literal">Zend\Console\Getopt\Exception</tt>. You should catch this exception in your application code. You can use the
<tt class="docutils literal">parse()</tt> method to force the object to parse the arguments. This is useful because you can invoke <tt class="docutils literal">parse()</tt> in
a try block. If it passes, you can be sure that the parsing won’t throw an exception again. The exception
thrown has a custom method <tt class="docutils literal">getUsageMessage()</tt>, which returns as a string the formatted set of usage messages for
all declared options.

Catching Getopt Exceptions

1
2
3
4
5
6
7

try {
    $opts = new Zend\Console\Getopt('abp:');
    $opts->parse();
} catch (Zend\Console\Getopt\Exception $e) {
    echo $e->getUsageMessage();
    exit;
}

Cases where parsing throws an exception include:

Option given is not recognized.

Option requires a parameter but none was given.

Option parameter is of the wrong type. E.g. a non-numeric string when an integer was required.

Fetching Options by Name¶

You can use the <tt class="docutils literal">getOption()</tt> method to query the value of an option. If the option had a parameter, this method
returns the value of the parameter. If the option had no parameter but the user did specify it on the command-line,
the method returns <tt class="docutils literal">TRUE</tt>. Otherwise the method returns <tt class="docutils literal">NULL</tt>.

Using getOption()

1
2
3

$opts = new Zend\Console\Getopt('abp:');
$b = $opts->getOption('b');
$p_parameter = $opts->getOption('p');

Alternatively, you can use the magic <tt class="docutils literal">__get()</tt> function to retrieve the value of an option as if it were a class
member variable. The <tt class="docutils literal">__isset()</tt> magic method is also implemented.

Using __get() and __isset() Magic Methods

1
2
3
4
5

$opts = new Zend\Console\Getopt('abp:');
if (isset($opts->b)) {
    echo "I got the b option.\n";
}
$p_parameter = $opts->p; // null if not set

If your options are declared with aliases, you may use any of the aliases for an option in the methods above.

Reporting Options¶

There are several methods to report the full set of options given by the user on the current command-line.

As a string: use the <tt class="docutils literal">toString()</tt> method. The options are returned as a space-separated string of
<tt class="docutils literal">flag=value</tt> pairs. The value of an option that does not have a parameter is the literal string “<tt class="docutils literal">TRUE</tt>”.

As an array: use the <tt class="docutils literal">toArray()</tt> method. The options are returned in a simple integer-indexed array of strings,
the flag strings followed by parameter strings, if any.

As a string containing JSON data: use the <tt class="docutils literal">toJson()</tt> method.

As a string containing XML data: use the <tt class="docutils literal">toXml()</tt> method.

In all of the above dumping methods, the flag string is the first string in the corresponding list of aliases. For
example, if the option aliases were declared like <tt class="docutils literal">verbose|v</tt>, then the first string, <tt class="docutils literal">verbose</tt>, is used as the
canonical name of the option. The name of the option flag does not include any preceding dashes.

Fetching Non-option Arguments¶

After option arguments and their parameters have been parsed from the command-line, there may be additional
arguments remaining. You can query these arguments using the <tt class="docutils literal">getRemainingArgs()</tt> method. This method returns an
array of the strings that were not part of any options.

Using getRemainingArgs()

1
2
3

$opts = new Zend\Console\Getopt('abp:');
$opts->setArguments(array('-p', 'p_parameter', 'filename'));
$args = $opts->getRemainingArgs(); // returns array('filename')

<tt class="docutils literal">Zend\Console\Getopt</tt> supports the GNU convention that an argument consisting of a double-dash signifies the
end of options. Any arguments following this signifier must be treated as non-option arguments. This is useful if
you might have a non-option argument that begins with a dash. For example: “<tt class="docutils literal">rm -- -filename-with-dash</tt>”.

Table Of Contents

Fetching Options and Arguments

Handling Getopt Exceptions

Fetching Options by Name

Reporting Options

Fetching Non-option Arguments

This Page

        Show Source

Edit Source

            Note: You need to stay logged into your GitHub account to contribute to the documentation.

Quick search

    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>

    Enter search terms or a module, class or function name.

Navigation

          index

Zend Framework 2 2.3.0dev documentation »

        © Copyright 2013, Zend Technologies Ltd..
      Created using Sphinx 1.2b3.

Edit this document

        The source code of this file is hosted on GitHub. Everyone can
        update and fix errors in this document with few clicks -
        no downloads needed.

            Login with your GitHub account.

            Go to

                Fetching Options and Arguments
             on GitHub.

            Edit file contents using GitHub's text editor in your web browser

            Fill in the Commit message text box at the end of the page telling why
            you did the changes. Press Propose file change button next to it when done.

            On Send a pull request page you don't need to fill in text anymore. Just
            press Send pull request button.

            Your changes are now queued for review under project's Pull requests tab on GitHub.


text:
package io.gravitee.am.management.handlers.management.api.resources.organizations.environments.domains;

import io.gravitee.am.management.handlers.management.api.resources.AbstractResource;
import io.swagger.annotations.Api;

import javax.ws.rs.Path;
import javax.ws.rs.container.ResourceContext;
import javax.ws.rs.core.Context;

/**
 * @author Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com)
 * @author GraviteeSource Team
 */
@Api(tags = "alerts")
public class AlertsResource extends AbstractResource {

    @Context
    private ResourceContext resourceContext;

    @Path("triggers")
    public AlertTriggersResource getAlertTriggersResource() {
        return resourceContext.getResource(AlertTriggersResource.class);
    }

    @Path("notifiers")
    public AlertNotifiersResource getAlertNotifiersResource() {
        return resourceContext.getResource(AlertNotifiersResource.class);
    }
}


text:
//================================================================
/**
 * @packageDocumentation
 * @module std.internal
 */
//================================================================
export interface IPush<T>
{
    /**
     * Insert items at the end.
     *
     * @param items Items to insert.
     * @return Number of elements in the container after insertion.
     */
    push(...items: T[]): number;
}


text:
package org.springframework.expression.spel.ast;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringJoiner;

import org.springframework.asm.MethodVisitor;
import org.springframework.expression.EvaluationException;
import org.springframework.expression.TypedValue;
import org.springframework.expression.spel.CodeFlow;
import org.springframework.expression.spel.ExpressionState;
import org.springframework.expression.spel.SpelNode;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

/**
 * Represent a list in an expression, e.g. '{1,2,3}'
 *
 * @author Andy Clement
 * @author Sam Brannen
 * @since 3.0.4
 */
public class InlineList extends SpelNodeImpl {

	// If the list is purely literals, it is a constant value and can be computed and cached
	@Nullable
	private TypedValue constant;  // TODO must be immutable list

	public InlineList(int startPos, int endPos, SpelNodeImpl... args) {
		super(startPos, endPos, args);
		checkIfConstant();
	}

	/**
	 * If all the components of the list are constants, or lists that themselves contain constants, then a constant list
	 * can be built to represent this node. This will speed up later getValue calls and reduce the amount of garbage
	 * created.
	 */
	private void checkIfConstant() {
		boolean isConstant = true;
		for (int c = 0, max = getChildCount(); c < max; c++) {
			SpelNode child = getChild(c);
			if (!(child instanceof Literal)) {
				if (child instanceof InlineList inlineList) {
					if (!inlineList.isConstant()) {
						isConstant = false;
					}
				}
				else {
					isConstant = false;
				}
			}
		}
		if (isConstant) {
			List<Object> constantList = new ArrayList<>();
			int childcount = getChildCount();
			for (int c = 0; c < childcount; c++) {
				SpelNode child = getChild(c);
				if (child instanceof Literal literal) {
					constantList.add(literal.getLiteralValue().getValue());
				}
				else if (child instanceof InlineList inlineList) {
					constantList.add(inlineList.getConstantValue());
				}
			}
			this.constant = new TypedValue(Collections.unmodifiableList(constantList));
		}
	}

	@Override
	public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException {
		if (this.constant != null) {
			return this.constant;
		}
		else {
			int childCount = getChildCount();
			List<Object> returnValue = new ArrayList<>(childCount);
			for (int c = 0; c < childCount; c++) {
				returnValue.add(getChild(c).getValue(expressionState));
			}
			return new TypedValue(returnValue);
		}
	}

	@Override
	public String toStringAST() {
		StringJoiner sj = new StringJoiner(",", "{", "}");
		// String ast matches input string, not the 'toString()' of the resultant collection, which would use []
		int count = getChildCount();
		for (int c = 0; c < count; c++) {
			sj.add(getChild(c).toStringAST());
		}
		return sj.toString();
	}

	/**
	 * Return whether this list is a constant value.
	 */
	public boolean isConstant() {
		return (this.constant != null);
	}

	@SuppressWarnings("unchecked")
	@Nullable
	public List<Object> getConstantValue() {
		Assert.state(this.constant != null, "No constant");
		return (List<Object>) this.constant.getValue();
	}

	@Override
	public boolean isCompilable() {
		return isConstant();
	}

	@Override
	public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
		final String constantFieldName = "inlineList$" + codeflow.nextFieldId();
		final String className = codeflow.getClassName();

		codeflow.registerNewField((cw, cflow) ->
				cw.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, constantFieldName, "Ljava/util/List;", null, null));

		codeflow.registerNewClinit((mVisitor, cflow) ->
				generateClinitCode(className, constantFieldName, mVisitor, cflow, false));

		mv.visitFieldInsn(GETSTATIC, className, constantFieldName, "Ljava/util/List;");
		codeflow.pushDescriptor("Ljava/util/List");
	}

	void generateClinitCode(String clazzname, String constantFieldName, MethodVisitor mv, CodeFlow codeflow, boolean nested) {
		mv.visitTypeInsn(NEW, "java/util/ArrayList");
		mv.visitInsn(DUP);
		mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "<init>", "()V", false);
		if (!nested) {
			mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
		}
		int childCount = getChildCount();
		for (int c = 0; c < childCount; c++) {
			if (!nested) {
				mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
			}
			else {
				mv.visitInsn(DUP);
			}
			// The children might be further lists if they are not constants. In this
			// situation do not call back into generateCode() because it will register another clinit adder.
			// Instead, directly build the list here:
			if (this.children[c] instanceof InlineList inlineList) {
				inlineList.generateClinitCode(clazzname, constantFieldName, mv, codeflow, true);
			}
			else {
				this.children[c].generateCode(mv, codeflow);
				String lastDesc = codeflow.lastDescriptor();
				if (CodeFlow.isPrimitive(lastDesc)) {
					CodeFlow.insertBoxIfNecessary(mv, lastDesc.charAt(0));
				}
			}
			mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true);
			mv.visitInsn(POP);
		}
	}

}


text:
using namespace tensorflow;

REGISTER_OP("CountSketch")
    .Attr("T: {float, int32}")
    .Input("probs: T")
    .Input("h: int32")
    .Input("s: int32")
    .Input("proj_size: int32")
    .Output("sketch: T");

REGISTER_OP("CountSketchGrad")
    .Attr("T: {float, int32}")
    .Input("probs: T")
    .Input("h: int32")
    .Input("s: int32")
    .Input("orig_size: int32")
    .Output("grad: T");

template <typename Device>
class CountSketchOp: public OpKernel {
public:
    explicit CountSketchOp(OpKernelConstruction* context) : OpKernel(context) {}

    void Compute(OpKernelContext* context) override {
        const Tensor& probs = context->input(0);
        const Tensor& h = context->input(1);
        const Tensor& s = context->input(2);
        const int32 proj_size = context->input(3).scalar<int32>()();

        TensorShape input_shape = probs.shape();
        auto batch_size = input_shape.dim_size(0), input_size = input_shape.dim_size(1);

        TensorShape output_shape;
        output_shape.AddDim(batch_size);
        output_shape.AddDim(proj_size);

        Tensor* sketch = nullptr;
        OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &sketch));

        // fill sketch
        functor::CountSketch<Device> functor;
        functor(context->eigen_device<Device>(), batch_size, input_size, proj_size, probs.matrix<float>(),
                                    h.vec<int>(), s.vec<int>(), sketch->matrix<float>());
    }
};

// CounterSketch CPU kernel
namespace functor {
template<> void CountSketch<CPUDevice>::operator()(const CPUDevice& d, int batch_size,
                int input_size, int dims, ConstFloatMatrix probs,
                IntVector h, IntVector s, FloatMatrix sketch) {

    for (int i=0; i<batch_size; i++) {
        for (int j=0; j<dims; j++) sketch(i, j) = 0; // zero init
        for (int j=0; j<input_size; j++) {
            sketch(i, h(j)) += s(j) * probs(i, j);
        }
    }
}
}

template <typename Device>
class CountSketchGradOp: public OpKernel {
public:
    explicit CountSketchGradOp(OpKernelConstruction* context) : OpKernel(context) {}

    void Compute(OpKernelContext* context) override {
        const Tensor& probs = context->input(0);
        const Tensor& h = context->input(1);
        const Tensor& s = context->input(2);
        const int32 proj_size = context->input(3).scalar<int32>()();

        TensorShape input_shape = probs.shape();
        auto batch_size = input_shape.dim_size(0), input_size = input_shape.dim_size(1);

        TensorShape output_shape;
        output_shape.AddDim(batch_size);
        output_shape.AddDim(proj_size);

        Tensor* sketch = nullptr;
        OP_REQUIRES_OK(context, context->allocate_output(0, output_shape, &sketch));

        // fill sketch
        functor::CountSketchGrad<Device> functor;
        functor(context->eigen_device<Device>(), batch_size, input_size, proj_size, probs.matrix<float>(),
                                    h.vec<int>(), s.vec<int>(), sketch->matrix<float>());
    }
};

// CounterSketchGrad CPU kernel
namespace functor {
template<> void CountSketchGrad<CPUDevice>::operator()(const CPUDevice& d, int batch_size,
                int input_size, int dims, ConstFloatMatrix probs,
                IntVector h, IntVector s, FloatMatrix sketch) {

    for (int i=0; i<batch_size; i++) {
        for (int j=0; j<dims; j++) sketch(i, j) = 0; // zero init
        for (int j=0; j<dims; j++) {
            sketch(i, j) = s(j) * probs(i, h(j));
        }
    }
}
}

REGISTER_KERNEL_BUILDER(Name("CountSketch").Device(DEVICE_CPU), CountSketchOp<CPUDevice>);
REGISTER_KERNEL_BUILDER(Name("CountSketchGrad").Device(DEVICE_CPU), CountSketchGradOp<CPUDevice>);

// TODO: FUCK CUDA!!!!
//REGISTER_KERNEL_BUILDER(Name("CountSketch").Device(DEVICE_GPU).HostMemory("proj_size"), CountSketchOp<GPUDevice>);
//REGISTER_KERNEL_BUILDER(Name("CountSketchGrad").Device(DEVICE_GPU).HostMemory("proj_size"), CountSketchGradOp<GPUDevice>);


text:
/**
 * @file gui_w_list.c
 * @brief list implementation; use GUI_M_List instead
 * @author Duboisset Philippe <duboisset.philippe@gmail.com>
 * @version N/A -- draft / experimental
 * @date (yyyy-mm-dd) 2014-03-08
 * Licence: MIT
 */

#include "gui_w.h"
#include "resources.h"

#define LIST_W_MIN  100   /*minimal width, in pixel*/
#define LIST_H_MIN  3     /*minimal height, in line*/

/**
 * field_st
 * content of one field of one item
 */
typedef struct field_t {
  struct field_t *pVn;        /*pointer to the vertical next; if NULL, I'm the tail of my category_t*/
  struct field_t *pVp;        /*pointer to the vertical previous; if NULL, I'm the head of my category_t*/
  struct field_t *pHn;        /*pointer to the horizontal next*/
  struct item_t *pItem;       /*pointer to the item (i.e. horizontal origin)*/
  uint8_t *str;               /*string of the field*/
} field_st;

/**
 * category_st
 * header; contains the list of all fields belonging to the same category (i.e. of the same column)
 */
typedef struct category_t {
  struct category_t *next;    /*pointer to the next category of the list*/
  field_st *head;
  field_st *tail;
  uint8_t *name;              /*name of the current category*/
  length_t w;                 /*width, in pixel*/
} category_st;

/**
 * item_st
 * one item (i.e. one line of the list)
 */
typedef struct item_t {
  field_st *pHn;              /*pointer to the item's fields linked list*/
  uint16_t uid;               /*unique identifier*/
  gui_img_t sprite;           /*will be displayed at the begin of the first field*/
} item_st;

/**
 * list_st
 * the overall object
 */
typedef struct {
  category_st *pCategory;           /*pointer to the head of categories*/
  category_st *pSelectedCategory;   /*pointer to the category used for display sort*/
  uint8_t categoryCount;            /*number of category*/
  bool bReversedSort;               /*if false, sort 'a' to 'z', else 'z' to 'a'*/

  item_st *pLastItem;               /*pointer to the last added item*/
  item_st *pSelectedItem;           /*pointer to the selected item*/
  bool bLastItemDefined;            /*if true, the last item were completely defined (all fields are defined)*/

  scroll_param_st vScroll;          /*vertical scrolling parameters*/
  scroll_param_st hScroll;          /*horizontal scrolling parameters*/
  g_obj_st *g_obj_header;

  length_t wSpriteMax;              /*maximal length of a sprite used in the list*/
  length_t hItem;                   /*height of a line (== to font height)*/
  color_t colBackOdd, colBackEven;
  gui_font_t font;

} list_st;

/**
 * list_header_st
 * header of a list
 */
typedef struct {
  g_obj_st *g_obj_list;
  coord_t xt;
} list_header_st;

/**
 * local functions
 */
static void DrawItem(const list_st *list, const rect_st *rec, const item_st *item, int16_t itemPos, coord_t x);
static void ListDraw(void *_g_obj, void *_obj);
static void ListRefresh(void *_g_obj, void *_obj);
static list_st /*@null@*/ *GetList(g_obj_st /*@null@*/ *obj);
static void InsertInCategory(list_st *list, uint8_t catId, field_st *field);
static field_st /*@null@*/ *GetFirstField(list_st *list);
static field_st /*@null@*/ *GetNextField(field_st *field, bool bReversedSort);
static void HeaderDraw(void *_g_obj, void *_obj);
static void HeaderRefresh(void *_g_obj, void *_obj);

/**
 * @function GUI_W_ListCreate
 * @brief add list container
 * @param const rect_st *rec: list dimension
 * @param bool bHeader: if true, categories will be displayed (*rec will be shared between list & its header)
 * @param scroll_param_st **pvScroll: if non null, will recieve the addr of the internal vertical scroll struct
 * @param scroll_param_st **phScroll: if non null, will recieve the addr of the internal horizontal scroll struct
 * @return g_obj_st *: pointer to the associated generic object if succedeed, NULL if error.
 */
g_obj_st /*@null@*/ *GUI_W_ListCreate(const rect_st *rec, bool bHeader, scroll_param_st /*@null@*/ **pvScroll, scroll_param_st /*@null@*/ **phScroll) {

  g_obj_st *g_obj = NULL, *g_obj_header = NULL, *res = NULL;
  list_st *list = NULL;
  list_header_st *header = NULL;
  length_t hItem = P2D_GetTextHeight();
  rect_st lrec;

  /*create the generic object for the list's header; configure it later*/
  if(bHeader) {
    g_obj_header = GUI_AddGenericObject();
    if(g_obj_header != NULL) {
      header = (list_header_st *) salloc(sizeof(list_header_st));
    }
  }

  /*check parameters*/
  if(rec != NULL && rec->w >= LIST_W_MIN && hItem > 0 && rec->h >= hItem * LIST_H_MIN && (header != NULL || bHeader == false)) {

    /*allocate a generic object*/
    g_obj = GUI_AddGenericObject();
    if(g_obj != NULL) {

      /*allocate and init the list*/
      list = (list_st *) salloc(sizeof(list_st));
      if(list != NULL) {

        /* *rec may be shared between list & its header*/
        lrec = *rec;
        if(bHeader) {
          lrec.y += hItem + 2;
          lrec.h -= hItem + 2;
        }

        /*ensures that all internal links are NULL & var = 0*/
        gmemset( (void *) list, 0, sizeof(list_st));

        /*init. the list*/
        list->font = GetCurrentFont();
        list->hItem = hItem;
        list->colBackOdd = GetColor(G_COL_E_BACKGROUND);
        list->colBackEven = P2D_Alpha_a_on_b(GetColor(G_COL_SPECIAL), list->colBackOdd, 32);
        list->vScroll.wndSize = lrec.h / hItem;
        list->hScroll.wndSize = lrec.w;
        list->g_obj_header = g_obj_header;

        /*return scroller addresses*/
        if(pvScroll != NULL) *pvScroll = &(list->vScroll);
        if(phScroll != NULL) *phScroll = &(list->hScroll);

        /*linkage between generic obj & list*/
        g_obj->rec = lrec;
        g_obj->draw = ListDraw;
        g_obj->task = ListRefresh;
        g_obj->obj = list;
        GUI_ObjSetStatic(g_obj, true);  /*list_st handle refresh event itself*/

        /*header linkage, if any*/
        if(header != NULL) {
          lrec.y = rec->y;
          lrec.h = hItem + 2;
          header->xt = -1;
          header->g_obj_list = g_obj;
          g_obj_header->rec = lrec;
          g_obj_header->draw = HeaderDraw;
          g_obj_header->task = HeaderRefresh;
          g_obj_header->obj = header;
          GUI_ObjSetStatic(g_obj, true);  /*header handles refresh event itself*/
        }

        res = g_obj;
      }
    }
  }

  return res;
}

/**
 * @function GUI_W_ListAddCategoryToList
 * @brief add a new category into a list
 * @param g_obj_st *obj: pointer to list
 * @param length_t w: width (in pixel)
 * @param const void *name: name of the category
 * @return int8_t: 0 success, -1 error
 */
int8_t GUI_W_ListAddCategoryToList(g_obj_st /*@null@*/ *obj, length_t w, const void *name) {

  int8_t res = -1;
  list_st *list = NULL;
  category_st *category = NULL, **seek = NULL;

  /*retrieve the list corresponding to the generic object*/
  list = GetList(obj);
  if(list != NULL) {

    /*a new category can be added only if the list does not contains any item*/
    if(list->vScroll.totSize == 0 && list->categoryCount < 255) {

      /*allocate memory for the new field header*/
      category = (category_st *) salloc(sizeof(category_st));
      if(category != NULL) {

        /*init. the category*/
        gmemset( (void *)category, 0, sizeof(category_st));
        category->w = w;
        category->name = AllocateAndCopyStr(name);

        if(name == NULL || category->name != NULL) {

          /*insert the category into its list*/
          seek = &(list->pCategory);
          while(*seek != NULL) seek = &((*seek)->next);
          *seek = category;

          /*update the category counter & the selected category (user for sort)*/
          list->categoryCount++;
          if(list->pSelectedCategory == NULL) list->pSelectedCategory = category;

          /*update the horizontal scroll size*/
          list->hScroll.totSize += w;

          res = 0;
        }
      }
    }
  }
  return res;
}

/**
 * @function GUI_W_ListAddItemToList
 * @brief add a new item into a list
 * @param g_obj_st *obj: pointer to list
 * @param gui_img_t sprite: sprite of the item
 * @param uint16_t *uid: if non null, the uid of the new item will be written into it
 * @return int8_t: 0 success, -1 error
 */
int8_t GUI_W_ListAddItemToList(g_obj_st /*@null@*/ *obj, gui_img_t sprite, uint16_t /*@null@*/ *uid) {

  int8_t res = -1;
  item_st *item = NULL;
  list_st *list = NULL;
  length_t wSprite;

  /*retrieve the list corresponding to the generic object*/
  list = GetList(obj);

  /*add item if: no item OR last item fully defined*/
  if(list != NULL && (list->pLastItem == NULL || list->bLastItemDefined == true)) {

    /*allocate memory for the new item*/
    item = (item_st *) salloc(sizeof(item_st));
    if(item != NULL) {

      /*init. the item & export uid*/
      gmemset( (void *) item, 0, sizeof(item_st));
      item->uid = list->vScroll.totSize;
      item->sprite = sprite;
      if(uid != NULL) *uid = item->uid;

      /*update the V scroll size*/
      list->vScroll.totSize++;

      /*just added, so item's fields are not yet defined*/
      list->bLastItemDefined = false;

      /*update the maximal sprite width*/
      wSprite = SpriteGetWidth(sprite);
      if(list->wSpriteMax < wSprite) list->wSpriteMax = wSprite;

      res = 0;
    }

    /*save the address of the last added item*/
    list->pLastItem = item;
  }

  return res;
}

/**
 * @function GUI_W_ListDeleteContent
 * @brief delete all items of a given list. ITEMS SHALL BE THE LAST ALLOCATED ELEMENTS !!
 * @param g_obj_st *obj: pointer to list
 * @return none
 */
void GUI_W_ListDeleteContent(g_obj_st /*@null@*/ *obj) {

  list_st *list = NULL;
  field_st *field = NULL;
  void *addr = NULL;
  category_st *category = NULL;

  /*retrieve the list corresponding to the generic object*/
  list = GetList(obj);
  if(list != NULL) {

    /*find the item #0*/
    field = GetFirstField(list);
    while(field != NULL && addr == NULL) {
      if(field->pItem->uid == 0) addr = (void *)field->pItem;
      else field = GetNextField(field, list->bReversedSort);
    }

    if(addr != NULL) {

      /*item found? clear all memory from its addr*/
      sfreeFrom(addr);

      /*reset list*/
      category = list->pCategory;
      while(category != NULL) {
        category->head = category->tail = NULL;
        category = category->next;
      }
      list->pLastItem = NULL;
      list->pSelectedItem = NULL;
      list->wSpriteMax = 0;
      list->vScroll.totSize = 0;

      /*need to refresh (for clearing window content)*/
      GUI_ObjSetNeedRefresh(obj, true);
    }
  }
}

/**
 * @function GUI_W_ListAddFieldToLastItem
 * @brief add a field to the last added item, after the last added field
 * @param g_obj_st *obj: pointer to list
 * @param const void *str: content of the field
 * @return int8_t: 0 success, -1 error
 */
int8_t GUI_W_ListAddFieldToLastItem(g_obj_st /*@null@*/ *obj, const void *str) {

  int8_t res = -1;
  uint8_t field_cnt;
  list_st *list = NULL;
  field_st *field = NULL, **seek = NULL;

  /*retrieve the list corresponding to the generic object*/
  list = GetList(obj);
  if(list != NULL && list->pLastItem != NULL) {

    /*retrieve the pointer to the current field and its position*/
    seek = &(list->pLastItem->pHn);
    field_cnt = 0;
    while(*seek != NULL) {
      seek = &((*seek)->pHn);
      field_cnt++;
    }

    /*check if the current item has less fields than the number of categories*/
    if(field_cnt < list->categoryCount) {

      /*allocate memory for the item's field*/
      field = (field_st *) salloc(sizeof(field_st));
      if(field != NULL) {

        /*init. the field*/
        gmemset( (void *)field, 0, sizeof(field_st));
        field->pItem = list->pLastItem;
        field->str = AllocateAndCopyStr(str);
        if(str == NULL || field->str != NULL) {

          /*insert in the horizontal list (i.e. linked to the item)*/
          *seek = field;

          /*insert in the vertical list (i.e. linked to the category)*/
          InsertInCategory(list, field_cnt, field);

          /*if all fields are defined, bLastItemDefined becomes true*/
          field_cnt++;
          if(field_cnt == list->categoryCount) list->bLastItemDefined = true;

          res = 0;
        }
      }
    }
  }

  return res;
}

/**
 * @function GUI_W_ListGetSelectedItemUid
 * @brief gets the UID of the selected item
 * @param g_obj_st *obj: pointer to list
 * @param uint16_t *uid: will contain the uid of selected item; if no selected item, *uid will not be modified
 * @return int8_t: 0 success, -1 error (no selected item / *obj is not a list)
 */
int8_t GUI_W_ListGetSelectedItemUid(g_obj_st /*@null@*/ *obj, uint16_t *uid) {

  int8_t res = -1;
  list_st *list;

  /*retrieve the list corresponding to the generic object*/
  list = GetList(obj);

  /*get the uid*/
  if(uid != NULL && list != NULL && list->pSelectedItem != NULL) {
    *uid = list->pSelectedItem->uid;
    res = 0;
  }

  return res;
}

/**
 * @function GUI_W_ListGetSelectedItemField
 * @brief gets the content of the field of the selected item, corresponding to a categoy #id
 * @param g_obj_st *obj: pointer to list
 * @param uint8_t catId: category #id
 * @param void *str: will contain the content of the selected item; if no selected item, *str will not be modified
 * @param uint16_t len: *str length (in byte)
 * @return int8_t: 0 success, -1 error (no selected item / invalid catId / *obj is not a list / *str==NULL)
 */
int8_t GUI_W_ListGetSelectedItemField(g_obj_st /*@null@*/ *obj, uint8_t catId, void *str, uint16_t len) {

  int8_t res = -1;
  list_st *list;
  field_st *field;

  /*retrieve the list corresponding to the generic object*/
  list = GetList(obj);
  if(str != NULL && list != NULL && list->pSelectedItem != NULL) {

    field = list->pSelectedItem->pHn;

    /*go to the field which correspond to the category #id*/
    while(catId > 0 && field != NULL) {
      field = field->pHn;
      catId--;
    }

    /*copy the field content into *str*/
    if(field != NULL) {
      gstrncpy(str, field->str, len);
      res = 0;
    }
  }

  return res;
}

/**
 * @function DrawItem
 * @brief draw an item (display all item's fields on a line)
 * @param const list_st *list: pointer to the parent list
 * @param const rect_st *rec: rec corresponding to the visible part of the line
 * @param const item_st *item: pointer to the item
 * @param int16_t itemPos: position in list (used for selecting background color)
 * @param coord_t x: x start
 * @return none
 */
static void DrawItem(const list_st *list, const rect_st *rec, const item_st *item, int16_t itemPos, coord_t x) {

  field_st *field = item->pHn;
  category_st *category = list->pCategory;
  color_t colBack, colText;
  coord_t y, xOffset;

  /*select colors*/
  if(item == list->pSelectedItem) {
    colText = GetColor(G_COL_TEXT_REVERSE);
    colBack = GetColor(G_COL_SPECIAL);
  }
  else {
    colText = GetColor(G_COL_TEXT);
    if(itemPos % 2 != 0) colBack = list->colBackEven; else colBack = list->colBackOdd;
  }

  /*clear the line & update colors (for LUT updating for font & sprite)*/
  P2D_SetColor(colBack);
  P2D_FillRect(rec);
  P2D_SetColors(colText, colBack);

  /*display the sprite*/
  y = rec->y + ((coord_t)rec->h - SpriteGetHeight(item->sprite)) / 2;
  xOffset = 2;
  Sprite(x + xOffset, y, item->sprite);

  /*finally, the first field starts at x + 2 + wSpriteMax + 2*/
  xOffset += list->wSpriteMax + 2;

  /*display all fields; objects out of screen will be automatically clipped*/
  while(field) {

    P2D_PutText(x + xOffset, rec->y, field->str);
    xOffset = 0;

    field = field->pHn;
    x += category->w;
    category = category->next;
  }
}

/**
 * @function ListDraw
 * @brief list draw function
 * @param void *_g_obj: generic object
 * @param void *_obj: list object
 * @return none
 */
static void ListDraw(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  list_st *list;
  field_st *field;
  uint16_t itemPos;
  rect_st lrec;
  coord_t x, yEnd;

  /*retreive generic & specific object*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    list =  (list_st*) _obj;

    /*P2D configuration*/
    P2D_SetDisplayMode(DISPLAY_SOLID);
    P2D_SetLineType(LINE_SOLID);
    SetFont(list->font);

    /*find the first field to display, according to vertical offset, selected category and sort (normal/reverse) */
    itemPos = 0;
    field = GetFirstField(list);
    while(field != NULL && itemPos < list->vScroll.offset) {
      field = GetNextField(field, list->bReversedSort);
      itemPos++;
    }

    /*display items*/
    lrec = g_obj->rec;
    lrec.h = list->hItem;
    yEnd = g_obj->rec.y + g_obj->rec.h;
    x = g_obj->rec.x - list->hScroll.offset;

    while(field != NULL && lrec.y < yEnd) {

      DrawItem(list, &lrec, field->pItem, itemPos, x);

      lrec.y += lrec.h;
      itemPos++;
      field = GetNextField(field, list->bReversedSort);
    }

    /*...if there is not enought item to fill the object dimension*/
    if(lrec.y < yEnd) {
      lrec.h = g_obj->rec.h;
      P2D_SetColor(GetColor(G_COL_E_BACKGROUND));
      P2D_FillRect(&lrec);
    }
  }
}

/**
 * @function ListRefresh
 * @brief list task
 * @param void *_g_obj: generic object
 * @param void *_obj: list object
 * @return none
 */
static void ListRefresh(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  list_st *list;
  coord_t yt, y;
  uint16_t itemPos;
  field_st *field;

  /*retreive generic & specific object*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    list =  (list_st*) _obj;

    /*if the list need a refresh before ListRefresh() exec, it means that
      an external event leaded to this refresh(e.g. scroll) -> we need to
      maually refresh the header of the list */
    if(GUI_ObjIsNeedRefresh(g_obj) && list->g_obj_header != NULL) {
      GUI_ObjSetNeedRefresh(list->g_obj_header, true);
    }

    /*handle touchscreen interaction*/
    if(GUI_ObjIsPressed(g_obj) && GUI_ObjIsDisabled(g_obj) == false) {
      GUI_ReadTouchScreen(NULL, &yt);

      /*retrieve the first item visible (according to the scroller pos)*/
      itemPos = 0;
      field = GetFirstField(list);
      while(field != NULL && itemPos < list->vScroll.offset) {
        field = GetNextField(field, list->bReversedSort);
        itemPos++;
      }

      /*find the item corresponding to the touchscreen y*/
      y = g_obj->rec.y;
      while(field != NULL && y + list->hItem < yt) {
        field = GetNextField(field, list->bReversedSort);
        y += list->hItem;
      }

      /*item selected != of the previous one? refresh list*/
      if(field != NULL) {
        if(list->pSelectedItem != field->pItem) {
          list->pSelectedItem = field->pItem;
          GUI_ObjSetNeedRefresh(g_obj, true);
        }
      }
      else {
        if(list->pSelectedItem != NULL) {
          list->pSelectedItem = NULL;
          GUI_ObjSetNeedRefresh(g_obj, true);
        }
      }
    }
  }
}

/**
 * @function GetList
 * @brief retrieve the pointer to the list from the generic object
 * @param void *_g_obj: generic object
 * @return list_st *: pointer to the list if success, NULL if error
 */
static list_st /*@null@*/ *GetList(g_obj_st /*@null@*/ *obj) {

  list_st *res = NULL;

  /*if null, retrieve the last added object*/
  if(obj == NULL) obj = GUI_GetLastAddedObject();

  /*make sure that the object is a list*/
  if(obj != NULL && obj->draw == ListDraw) {
    res = (list_st *) obj->obj;
  }

  return res;
}

/**
 * @function InsertInCategory
 * @brief insert a field in its corresponding category
 * @param list_st *list: pointer to the list
 * @param catId: category #id
 * @param field_st *field: field to insert
 * @return none
 */
static void InsertInCategory(list_st *list, uint8_t catId, field_st *field) {

  category_st *category = NULL;
  field_st *seek = NULL;
  bool bInserted = false;

  /* retrieve the category according to catId.
   * functions GUI_W_Listxxx ensure that (catId == 0) before (category == NULL) */
  category = list->pCategory;
  while(catId > 0) {
    category = category->next;
    catId--;
  }

  /*retrieve the first node*/
  seek = category->head;

  /*empty list? the *field becomes the head & the tail of its category*/
  if(seek == NULL) {
    category->head = field;
    category->tail = field;
  }
  /*otherwise, search its insert position*/
  else {

    while(bInserted == false) {

      /*insert: if the field's str is 'lower' than the seek's one (e.g. field->str = "a" & seek->str = "b"*/
      if(strcmp((void *)field->str, (void *)seek->str) < 0) {

        /*insert in n-1; if n-1 == NULL, *field becomes the head of its category*/
        if(seek->pVp != NULL) seek->pVp->pVn = field;
        else category->head = field;

        /*update the *field's links AND THEN the n-1 links (order matters!)*/
        field->pVp = seek->pVp;
        field->pVn = seek;
        seek->pVp = field;

        bInserted = true;
      }

      /*if the tail is reached, *field becomes the tail of its category*/
      else if(seek->pVn == NULL) {

        /*update the tail*/
        category->tail = field;

        /*update the *field's links AND THEN the n-1 links (order matters!)*/
        field->pVp = seek;
        field->pVn = seek->pVn;
        seek->pVn = field;

        bInserted = true;
      }

      /*else (*field not inserted && seek != tail), go to the next node*/
      else {
        seek = seek->pVn;
      }
    }
  }
}

/**
 * @function GetFirstField
 * @brief returns the first top field (according to selected category & sort order)
 * @param list_st *list: pointer to the list
 * @return field_st *: pointer to the top field
 */
static field_st /*@null@*/ *GetFirstField(list_st *list) {

  field_st *res = NULL;

  if(list->pSelectedCategory != NULL) {
    if(list->bReversedSort) res = list->pSelectedCategory->tail;
    else res = list->pSelectedCategory->head;
  }

  return res;
}

/**
 * @function GetNextField
 * @brief returns the next field (according to previous field & sort order)
 * @param field_st *field: previous field
 * @param bool bReversedSort: sort order (normal / reverse)
 * @return field_st *: pointer to the next field
 */
static field_st /*@null@*/ *GetNextField(field_st *field, bool bReversedSort) {

  field_st *res = NULL;

  if(bReversedSort) res = field->pVp;
  else res = field->pVn;

  return res;
}

/**
 * @function HeaderDraw
 * @brief List header draw function
 * @param void *_g_obj: pointer to the generic object of the header
 * @param void *_obj: pointer to the specific object of the header
 * @return none
 */
static void HeaderDraw(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  list_header_st *header;
  list_st *list;
  color_t colBack, colLine, colText;
  coord_t x0, x1, y0, y1, xImg, yImg, xTxt, yTxt, xOffset;
  gui_img_t img;
  rect_st lrec;
  category_st *category;

  /*retreive generic & specific object + pointer to the associated list*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    header = (list_header_st *) _obj;
    list = GetList(header->g_obj_list);

    colBack = GetColor(G_COL_BACKGROUND);
    colLine = GetColor(G_COL_LOWER_REC);
    colText = GetColor(G_COL_TEXT);

    /*P2D configuration*/
    P2D_SetDisplayMode(DISPLAY_SOLID);
    P2D_SetLineType(LINE_SOLID);
    SetFont(list->font);

    /*draw header background*/
    P2D_SetColor(colBack);
    (void) P2D_RectToCoord(&(g_obj->rec), &x0, &y0, &x1, &y1);
    x0++; y0++; x1--; y1--;
    (void) P2D_CoordToRect(&lrec, x0, y0, x1, y1);
    P2D_SetColor(colBack);
    P2D_FillRect(&lrec);

    /*display categories*/
    category = list->pCategory;
    P2D_SetColors(colText, colBack);
    xTxt = g_obj->rec.x - list->hScroll.offset;
    yTxt = y0 + ((y1 - y0) - list->hItem) / 2;
    xOffset = list->wSpriteMax + 4;

    while(category != NULL) {
      P2D_PutText(xTxt + xOffset, yTxt, category->name);
      xTxt += category->w;
      xOffset = 0;

      /*current category is the selected one? display the up/down sprite*/
      if(category == list->pSelectedCategory) {

        img = (list->bReversedSort == true)? G_IMG_SORT_DOWN: G_IMG_SORT_UP;
        xImg = xTxt - SpriteGetWidth(img) - 2;
        yImg = y0 + ((y1 - y0) - SpriteGetHeight(img)) / 2;

        Sprite(xImg, yImg, img);
      }

      category = category->next;
    }

    /*draw header rect*/
    P2D_SetColor(colLine);
    P2D_Rect(&(g_obj->rec));
  }
}

/**
 * @function HeaderRefresh
 * @brief List header task
 * @param void *_g_obj: pointer to the generic object of the header
 * @param void *_obj: pointer to the specific object of the header
 * @return none
 */
static void HeaderRefresh(void *_g_obj, void *_obj) {

  g_obj_st *g_obj;
  list_header_st *header;
  list_st *list;
  category_st *category;
  coord_t x, xt;
  bool bRefresh = false;

  /*retreive generic & specific object + pointer to the associated list*/
  if(_g_obj != NULL && _obj != NULL) {
    g_obj = (g_obj_st *) _g_obj;
    header = (list_header_st *) _obj;
    list = GetList(header->g_obj_list);

    /*touchscreen?*/
    if(GUI_ObjIsPressed(g_obj)) {

      /*previous state == released?*/
      if(header->xt < 0) {

        GUI_ReadTouchScreen(&xt, NULL);
        header->xt = xt;

        /*retrieve the category corresponding to the touchscreen y*/
        category = list->pCategory;
        x = g_obj->rec.x - list->hScroll.offset;
        while(category != NULL) {

          if(xt < x + category->w) break;

          else {
            x += category->w;
            category = category->next;
          }

        }

        if(category != NULL) {

          /*touched category == previous one? reverse the sort*/
          if(list->pSelectedCategory == category) {
            list->bReversedSort = !list->bReversedSort;
            bRefresh = true;
          }
          /*else, use the touched category for sort*/
          else {
            list->pSelectedCategory = category;
            list->bReversedSort = false;
            bRefresh = true;
          }
        }

        /*important, the header shall handle the refresh of its parent list !*/
        if(bRefresh) {
          GUI_ObjSetNeedRefresh(g_obj, true);
          GUI_ObjSetNeedRefresh(header->g_obj_list, true);
        }
      }
    }
    else {
      header->xt = -1;
    }
  }
}


text:
{% extends 'userena/base_userena.html' %}
{% load i18n %}

{% block title %}{% trans "Signin" %}{% endblock %}

{% block content %}

{% trans 'Signin' %}

Sie haben noch keinen Zugang? Dann können Sie sich hier eintragen.

  <form action="" method="post" style="max-width:400px;" class="center">
    {% csrf_token %}
    <fieldset>
      {{ form.non_field_errors }}
      {% for field in form %}
        {{ field.errors }}
        {% comment %} Displaying checkboxes differently {% endcomment %}
        {% if field.name == 'identification' %}
          <input id="user_email" type="email" placeholder="E-Mail-Adresse" name="{{ field.name }}" class="inputfield" style='width: 100%;' required>
        {% elif field.name == 'password' %}
          <input id="user_password" type="password" placeholder="Passwort" name="{{ field.name }}" class="inputfield" style='width: 100%;' required>
        {% elif field.name == 'remember_me' %}

            {{ field }} {{ field.label }}

        {% else %}

            {{ field.label_tag }}
            {{ field }}

        {% endif %}
      {% endfor %}
    </fieldset>
    <input type="submit" value="{% trans 'Signin' %}" class="inputbutton" style='width: 100%;'/>

{% trans "Forgot your password?" %}

    {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
  </form>

{% endblock %}