The Velocity User Guide is intended to help page designers and content providers get acquainted with Velocity and the syntax of its simple yet powerful scripting language, the Velocity Template Language (VTL). Many of the examples in this guide deal with using Velocity to embed dynamic content in web sites, but all VTL examples are equally applicable to other pages and templates.
Thanks for choosing Velocity!
Velocity is a Java-based template engine. It permits web page designers to reference methods defined in Java code. Web designers can work in parallel with Java programmers to develop web sites according to the Model-View-Controller (MVC) model, meaning that web page designers can focus solely on creating a well-designed site, and programmers can focus solely on writing top-notch code. Velocity separates Java code from the web pages, making the web site more maintainable over the long run and providing a viable alternative to Java Server Pages (JSPs) or PHP .
Velocity can be used to generate web pages, SQL, PostScript and other output from templates. It can be used either as a standalone utility for generating source code and reports, or as an integrated component of other systems. When complete, Velocity will provide template services for the Turbine web application framework. Velocity+Turbine will provide a template service that will allow web applications to be developed according to a true MVC model.
Suppose you are a page designer for an online store that specializes in selling mud. Let's call it "The Online Mud Store". Business is thriving. Customers place orders for various types and quantities of mud. They login to your site using their username and password, which allows them to view their orders and buy more mud. Right now, Terracotta Mud is on sale, which is very popular. A minority of your customers regularly buys Bright Red Mud, which is also on sale, though not as popular and usually relegated to the margin of your web page. Information about each customer is tracked in your database, so one day the question arises, Why not use Velocity to target special deals on mud to the customers who are most interested in those types of mud?
Velocity makes it easy to customize web pages to your online visitors. As a web site designer at The Mud Room, you want to make the web page that the customer will see after logging into your site.
You meet with software engineers at your company, and everyone has agreed that $customer will hold information pertaining to the customer currently logged in, that $mudsOnSpecial will be all the types mud on sale at present. The $flogger object contains methods that help with promotion. For the task at hand, let's concern ourselves only with these three references. Remember, you don't need to worry about how the software engineers extract the necessary information from the database, you just need to know that it works. This lets you get on with your job, and lets the software engineers get on with theirs.
You could embed the following VTL statement in the web page:
<HTML> <BODY> Hello $customer.Name! <table> #foreach( $mud in $mudsOnSpecial ) #if ( $customer.hasPurchased($mud) ) <tr> <td> $flogger.getPromo( $mud ) </td> </tr> #end #end </table>
The exact details of the foreach statement will be described in greater depth shortly; what's important is the impact this short script can have on your web site. When a customer with a penchant for Bright Red Mud logs in, and Bright Red Mud is on sale, that is what this customer will see, prominently displayed. If another customer with a long history of Terracotta Mud purchases logs in, the notice of a Terracotta Mud sale will be front and center. The flexibility of Velocity is enormous and limited only by your creativity.
Documented in the VTL Reference are the many other Velocity elements, which collectively give you the power and flexibility you need to make your web site a web presence. As you get more familiar with these elements, you will begin to unleash the power of Velocity.
The Velocity Template Language (VTL) is meant to provide the easiest, simplest, and cleanest way to incorporate dynamic content in a web page. Even a web page developer with little or no programming experience should soon be capable of using VTL to incorporate dynamic content in a web site.
VTL uses references to embed dynamic content in a web site, and a variable is one type of reference. Variables are one type of reference that can refer to something defined in the Java code, or it can get its value from a VTL statement in the web page itself. Here is an example of a VTL statement that could be embedded in an HTML document:
#set( $a = "Velocity" )
This VTL statement, like all VTL statements, begins with the # character and contains a directive: set. When an online visitor requests your web page, the Velocity Templating Engine will search through your web page to find all # characters, then determine which mark the beginning of VTL statements, and which of the # characters that have nothing to do with VTL.
The # character is followed by a directive, set. The set directive uses an expression (enclosed in brackets) -- an equation that assigns a value to a variable. The variable is listed on the left hand side and its value on the right hand side; the two are separated by an = character.
In the example above, the variable is $a and the value is Velocity. This variable, like all references, begins with the $ character. String values are always enclosed in quotes, either single or double quotes. Single quotes will ensure that the quoted value will be assigned to the reference as is. Double quotes allow you to use velocity references and directives to interpolate, such as "Hello $name", where the $name will be replaced by the current value before that string literal is assigned to the left hand side of the =
The following rule of thumb may be useful to better understand how Velocity works: References begin with $ and are used to get something. Directives begin with # and are used to do something.
In the example above, #set is used to assign a value to a variable. The variable, $a, can then be used in the template to output "Velocity".
Once a value has been assigned to a variable, you can reference the variable anywhere in your HTML document. In the following example, a value is assigned to $foo and later referenced.
<html> <body> #set( $foo = "Velocity" ) Hello $foo World! </body> <html>
The result is a web page that prints "Hello Velocity World!".
To make statements containing VTL directives more readable, we encourage you to start each VTL statement on a new line, although you are not required to do so. The set directive will be revisited in greater detail later on.
Comments allows descriptive text to be included that is not placed into the output of the template engine. Comments are a useful way of reminding yourself and explaining to others what your VTL statements are doing, or any other purpose you find useful. Below is an example of a comment in VTL.
## This is a single line comment.
A single line comment begins with ## and finishes at the end of the line. If you're going to write a few lines of commentary, there's no need to have numerous single line comments. Multi-line comments, which begin with #* and end with *#, are available to handle this scenario.
This is text that is outside the multi-line comment. Online visitors can see it. #* Thus begins a multi-line comment. Online visitors won't see this text because the Velocity Templating Engine will ignore it. *# Here is text outside the multi-line comment; it is visible.
Here are a few examples to clarify how single line and multi-line comments work:
This text is visible. ## This text is not. This text is visible. This text is visible. #* This text, as part of a multi-line comment, is not visible. This text is not visible; it is also part of the multi-line comment. This text still not visible. *# This text is outside the comment, so it is visible. ## This text is not visible.
There is a third type of comment, the VTL comment block, which may be used to store any sort of extra information you want to track in the template (e.g. javadoc-style author and versioning information):
#** This is a VTL comment block and may be used to store such information as the document author and versioning information: @author @version 5 *#
There are three types of references in the VTL: variables, properties and methods. As a designer using the VTL, you and your engineers must come to an agreement on the specific names of references so you can use them correctly in your templates.
Variables
The shorthand notation of a variable consists of a leading "$"
character followed by a VTL Identifier. A VTL Identifier
must start with an alphabetic character (a .. z or A .. Z). The rest
of the characters are limited to the following types of characters:
Here are some examples of valid variable references in the VTL:
$foo $mudSlinger $mud-slinger $mud_slinger $mudSlinger1
When VTL references a variable, such as $foo, the variable can get its value from either a set directive in the template, or from the Java code. For example, if the Java variable $foo has the value bar at the time the template is requested, bar replaces all instances of $foo on the web page. Alternatively, if I include the statement
#set( $foo = "bar" )
The output will be the same for all instances of $foo that follow this directive.
Properties
The second flavor of VTL references are properties, and properties
have a distinctive format. The shorthand notation consists of a
leading $ character followed a VTL Identifier, followed by
a dot character (".") and another VTL Identifier. These are examples
of valid property references in the VTL:
$customer.Address $purchase.Total
Take the first example, $customer.Address. It can have two meanings. It can mean, Look in the hashtable identified as customer and return the value associated with the key Address. But $customer.Address can also be referring to a method (references that refer to methods will be discussed in the next section); $customer.Address could be an abbreviated way of writing $customer.getAddress(). When your page is requested, Velocity will determine which of these two possibilities makes sense, and then return the appropriate value.
Methods
A method is defined in the Java code and is capable of doing
something useful, like running a calculation or arriving at a
decision. Methods are references that consist of a leading "$"
character followed a VTL Identifier, followed by a VTL Method
Body. A VTL Method Body consists of a VTL Identifier followed
by an left parenthesis character ("("), followed by an optional
parameter list, followed by right parenthesis character (")"). These
are examples of valid method references in the VTL:
$customer.getAddress() $purchase.getTotal() $page.setTitle( "My Home Page" ) $person.setAttributes( ["Strange", "Weird", "Excited"] )
The first two examples -- $customer.getAddress() and $purchase.getTotal() -- may look similar to those used in the Properties section above, $customer.Address and $purchase.Total. If you guessed that these examples must be related some in some fashion, you are correct!
VTL Properties can be used as a shorthand notation for VTL Methods. The Property $customer.Address has the exact same effect as using the Method $customer.getAddress(). It is generally preferable to use a Property when available. The main difference between Properties and Methods is that you can specify a parameter list to a Method.
The shorthand notation can be used for the following Methods
$sun.getPlanets() $annelid.getDirt() $album.getPhoto()
We might expect these methods to return the names of planets belonging to the sun, feed our earthworm, or get a photograph from an album. Only the long notation works for the following Methods.
$sun.getPlanet( ["Earth", "Mars", "Neptune"] ) ## Can't pass a parameter list with $sun.Planets $sisyphus.pushRock() ## Velocity assumes I mean $sisyphus.getRock() $book.setTitle( "Homage to Catalonia" ) ## Can't pass a parameter
As of Velocity 1.6, all array references are now "magically" treated as if they are fixed-length lists. This means that you can call java.util.List methods on array references. So, if you have a reference to an array (let's say this one is a String[] with three values), you can do:
$myarray.isEmpty() $myarray.size() $myarray.get(2) $myarray.set(1, 'test')
Also new in Velocity 1.6 is support for vararg methods. A method like
public void setPlanets(String... planets)
or even just
public void setPlanets(String[] planets)
(if you are
using a pre-Java 5 JDK), can now accept
any number of arguments when called in a template.
$sun.setPlanets('Earth', 'Mars', 'Neptune') $sun.setPlanets('Mercury') $sun.setPlanets() ## Will just pass in an empty, zero-length array
Property Lookup Rules
As was mentioned earlier, properties often refer to methods of the
parent object. Velocity is quite clever when figuring out which method
corresponds to a requested property. It tries out different alternatives
based on several established naming conventions. The exact lookup
sequence depends on whether or not the property name starts with
an upper-case letter. For lower-case names, such as
$customer.address, the sequence is
Rendering
The final value resulting from each and every reference (whether variable,
property, or method) is converted to a String object when it is rendered
into the final output. If there is an object that represents $foo
(such as an Integer object), then Velocity will call its
.toString()
method to resolve the object into a String.
Formal Reference Notation
Shorthand notation for references was used for the examples listed
above, but there is also a formal notation for references, which is
demonstrated below:
${mudSlinger} ${customer.Address} ${purchase.getTotal()}
In almost all cases you will use the shorthand notation for references, but in some cases the formal notation is required for correct processing.
Suppose you were constructing a sentence on the fly where $vice was to be used as the base word in the noun of a sentence. The goal is to allow someone to choose the base word and produce one of the two following results: "Jack is a pyromaniac." or "Jack is a kleptomaniac.". Using the shorthand notation would be inadequate for this task. Consider the following example:
Jack is a $vicemaniac.
There is ambiguity here, and Velocity assumes that $vicemaniac, not $vice, is the Identifier that you mean to use. Finding no value for $vicemaniac, it will return $vicemaniac. Using formal notation can resolve this problem.
Jack is a ${vice}maniac.
Now Velocity knows that $vice, not $vicemaniac, is the reference. Formal notation is often useful when references are directly adjacent to text in a template.
Quiet Reference Notation
When Velocity encounters an undefined reference, its normal behavior
is to output the image of the reference. For example, suppose the
following reference appears as part of a VTL template.
<input type="text" name="email" value="$email"/>
When the form initially loads, the variable reference $email has no value, but you prefer a blank text field to one with a value of "$email". Using the quiet reference notation circumvents Velocity's normal behavior; instead of using $email in the VTL you would use $!email. So the above example would look like the following:
<input type="text" name="email" value="$!email"/>
Now when the form is initially loaded and $email still has no value, an empty string will be output instead of "$email".
Formal and quiet reference notation can be used together, as demonstrated below.
<input type="text" name="email" value="$!{email}"/>
Velocity 1.6 introduces the concept of strict references which is activated by setting the velocity configuration property 'runtime.references.strict' to true. With this setting references are required to be either placed explicitly into the context or defined with a #set directive, or Velocity will throw an exception. References that are in the context with a value of null will not produce an exception. Additionally, if an attempt is made to call a method or a property on an object within a reference that does not define the specified method or property then Velocity will throw an exception. This is also true if there is an attempt to call a method or property on a null value.
In the following examples $bar is defined but $foo is not, and all these statements will throw an exception:
$foo ## Exception #set($bar = $foo) ## Exception #if($foo == $bar)#end ## Exception #foreach($item in $foo)#end ## Exception
Also, The following statements show examples in which Velocity will throw an exception when attempting to call methods or properties that do not exist. In these examples $bar contains an object that defines a property 'foo' which returns a string, and 'retnull' which returns null.
$bar.bogus ## $bar does not provide property bogus, Exception $bar.foo.bogus ## $bar.foo does not provide property bogus, Exception $bar.retnull.bogus ## cannot call a property on null, Exception
In general strict reference behavior is true for all situations in which references are used except for a special case within the #if directive. If a reference is used within a #if or #elseif directive without any methods or properties, and if it is not being compared to another value, then undefined references are allowed. This behavior provides an easy way to test if a reference is defined before using it in a template. In the following example where $foo is not defined the statements will not throw an exception.
#if ($foo)#end ## False #if ( ! $foo)#end ## True #if ($foo && $foo.bar)#end ## False and $foo.bar will not be evaluated #if ($foo && $foo == "bar")#end ## False and $foo == "bar" wil not be evaluated #if ($foo1 || $foo2)#end ## False $foo1 and $foo2 are not defined
One additional note, undefined macro references will also throw an exception with the strict reference setting.
Now that you are familiar with references, you can begin to apply them effectively in your templates. Velocity references take advantage of some Java principles that template designers will find easy to use. For example:
$foo $foo.getBar() ## is the same as $foo.Bar $data.setUser("jon") ## is the same as #set( $data.User = "jon" ) $data.getRequest().getServerName() ## is the same as $data.Request.ServerName ## is the same as ${data.Request.ServerName}
These examples illustrate alternative uses for the same references. Velocity takes advantage of Java's introspection and bean features to resolve the reference names to both objects in the Context as well as the objects methods. It is possible to embed and evaluate references almost anywhere in your template.
Velocity, which is modelled on the Bean specifications defined by
Sun Microsystems, is case sensitive; however, its developers have
strove to catch and correct user errors wherever possible.
When the method getFoo() is referred to in a template
by $bar.foo
, Velocity will first try $getfoo
.
If this fails, it will then try $getFoo
.
Similarly, when a template refers to $bar.Foo
, Velocity
will try $getFoo() first and then try getfoo().
Note: References to instance variables in a template are not
resolved. Only references to the attribute equivalents of
JavaBean getter/setter methods are resolved
(i.e. $foo.Name
does resolve to the class Foo's
getName()
instance method, but not to a public
Name
instance variable of Foo).
References allow template designers to generate dynamic content for web sites, while directives -- easy to use script elements that can be used to creatively manipulate the output of Java code -- permit web designers to truly take charge of the appearance and content of the web site.
Directives always begin with a #
. Like references, the name of the directive may be
bracketed by a {
and a }
symbol. This is useful with directives
that are immediately followed by text. For example the following produces an error:
#if($a==1)true enough#elseno way!#end
In such a case, use the brackets to separate #else
from the rest of the line.
#if($a==1)true enough#{else}no way!#end
The #set directive is used for setting the value of a reference. A value can be assigned to either a variable reference or a property reference, and this occurs in brackets, as demonstrated:
#set( $primate = "monkey" ) #set( $customer.Behavior = $primate )
The left hand side (LHS) of the assignment must be a variable reference or a property reference. The right hand side (RHS) can be one of the following types:
These examples demonstrate each of the aforementioned types:
#set( $monkey = $bill ) ## variable reference #set( $monkey.Friend = "monica" ) ## string literal #set( $monkey.Blame = $whitehouse.Leak ) ## property reference #set( $monkey.Plan = $spindoctor.weave($web) ) ## method reference #set( $monkey.Number = 123 ) ##number literal #set( $monkey.Say = ["Not", $my, "fault"] ) ## ArrayList #set( $monkey.Map = {"banana" : "good", "roast beef" : "bad"}) ## Map
NOTE: For the ArrayList example the elements defined with the [..] operator are accessible using the methods defined in the ArrayList class. So, for example, you could access the first element above using $monkey.Say.get(0).
Similarly, for the Map example, the elements defined within the { } operator are accessible using the methods defined in the Map class. So, for example, you could access the first element above using $monkey.Map.get("banana") to return a String 'good', or even $monkey.Map.banana to return the same value.
The RHS can also be a simple arithmetic expression:
#set( $value = $foo + 1 ) #set( $value = $bar - 1 ) #set( $value = $foo * $bar ) #set( $value = $foo / $bar )
If the RHS is a property or method reference that evaluates to null, it will not be assigned to the LHS. Depending on how Velocity is configured, it is usually not possible to remove an existing reference from the context via this mechanism. (Note that this can be permitted by changing one of the Velocity configuration properties). This can be confusing for newcomers to Velocity. For example:
#set( $result = $query.criteria("name") ) The result of the first query is $result #set( $result = $query.criteria("address") ) The result of the second query is $result
If $query.criteria("name") returns the string "bill", and $query.criteria("address") returns null, the above VTL will render as the following:
The result of the first query is bill The result of the second query is bill
This tends to confuse newcomers who construct #foreach loops that attempt to #set a reference via a property or method reference, then immediately test that reference with an #if directive. For example:
#set( $criteria = ["name", "address"] ) #foreach( $criterion in $criteria ) #set( $result = $query.criteria($criterion) ) #if( $result ) Query was successful #end #end
In the above example, it would not be wise to rely on the evaluation of $result to determine if a query was successful. After $result has been #set (added to the context), it cannot be set back to null (removed from the context). The details of the #if and #foreach directives are covered later in this document.
One solution to this would be to pre-set $result to false. Then if the $query.criteria() call fails, you can check.
#set( $criteria = ["name", "address"] ) #foreach( $criterion in $criteria ) #set( $result = false ) #set( $result = $query.criteria($criterion) ) #if( $result ) Query was successful #end #end
Unlike some of the other Velocity directives, the #set directive does not have an #end statement.
LiteralsWhen using the #set directive, string literals that are enclosed in double quote characters will be parsed and rendered, as shown:
#set( $directoryRoot = "www" ) #set( $templateName = "index.vm" ) #set( $template = "$directoryRoot/$templateName" ) $template
The output will be
www/index.vm
However, when the string literal is enclosed in single quote characters, it will not be parsed:
#set( $foo = "bar" ) $foo #set( $blargh = '$foo' ) $blargh
bar $foo
By default, this feature of using single quotes to render unparsed
text is available in Velocity. This default can be changed by
editing velocity.properties
such that
stringliterals.interpolate=false
.
Alternately, the #literal script element allows the template designer to easily use large chunks of uninterpreted content in VTL code. This can be especially useful in place of escaping multiple directives.
#literal() #foreach ($woogie in $boogie) nothing will happen to $woogie #end #end
Renders as:
#foreach ($woogie in $boogie) nothing will happen to $woogie #end
The #if directive in Velocity allows for text to be included when the web page is generated, on the conditional that the if statement is true. For example:
#if( $foo ) <strong>Velocity!</strong> #end
The variable $foo is evaluated to determine whether it is
true, which will happen under one of two circumstances: (i)
$foo is a boolean (true/false) which has a true value, or
(ii) the value is not null. Remember that the Velocity context only
contains Objects, so when we say 'boolean', it will be represented
as a Boolean (the class). This is true even for methods that return
boolean
- the introspection infrastructure will return
a Boolean
of the same logical value.
The content between the #if and the #end statements become the output if the evaluation is true. In this case, if $foo is true, the output will be: "Velocity!". Conversely, if $foo has a null value, or if it is a boolean false, the statement evaluates as false, and there is no output.
An #elseif or #else element can be used with an #if element. Note that the Velocity Templating Engine will stop at the first expression that is found to be true. In the following example, suppose that $foo has a value of 15 and $bar has a value of 6.
#if( $foo < 10 ) <strong>Go North</strong> #elseif( $foo == 10 ) <strong>Go East</strong> #elseif( $bar == 6 ) <strong>Go South</strong> #else <strong>Go West</strong> #end
In this example, $foo is greater than 10, so the first two comparisons fail. Next $bar is compared to 6, which is true, so the output is Go South.
Relational and Logical Operators
Velocity uses the equivalent operator to determine the relationships between variables. Here is a simple example to illustrate how the equivalent operator is used.
#set ($foo = "deoxyribonucleic acid") #set ($bar = "ribonucleic acid") #if ($foo == $bar) In this case it's clear they aren't equivalent. So... #else They are not equivalent and this will be the output. #end
Note that the semantics of == are slightly different than Java where ==
can only be used to test object equality. In Velocity the equivalent operator
can be used to directly compare numbers, strings, or objects. When the objects
are of different classes, the string representations are obtained by calling
toString()
for each object and then compared.
Velocity has logical AND, OR and NOT operators as well. Below are examples demonstrating the use of the logical AND, OR and NOT operators.
## logical AND #if( $foo && $bar ) <strong> This AND that</strong> #end
The #if() directive will only evaluate to true if both $foo and $bar are true. If $foo is false, the expression will evaluate to false; $bar will not be evaluated. If $foo is true, the Velocity Templating Engine will then check the value of $bar; if $bar is true, then the entire expression is true and This AND that becomes the output. If $bar is false, then there will be no output as the entire expression is false.
Logical OR operators work the same way, except only one of the references need evaluate to true in order for the entire expression to be considered true. Consider the following example.
## logical OR #if( $foo || $bar ) <strong>This OR That</strong> #end
If $foo is true, the Velocity Templating Engine has no need to look at $bar; whether $bar is true or false, the expression will be true, and This OR That will be output. If $foo is false, however, $bar must be checked. In this case, if $bar is also false, the expression evaluates to false and there is no output. On the other hand, if $bar is true, then the entire expression is true, and the output is This OR That
With logical NOT operators, there is only one argument :
##logical NOT #if( !$foo ) <strong>NOT that</strong> #end
Here, the if $foo is true, then !$foo evaluates to false, and there is no output. If $foo is false, then !$foo evaluates to true and NOT that will be output. Be careful not to confuse this with the quiet reference $!foo which is something altogether different.
There are text versions of all logical operators, including eq, ne, and, or, not, gt, ge, lt, and le.
One more useful note. When you wish to include text immediately following a #else directive you will need to use curly brackets immediately surrounding the directive to differentiate it from the following text. (Any directive can be delimited by curly brackets, although this is most useful for #else).
#if( $foo == $bar)it's true!#{else}it's not!#end</li>
The #foreach element allows for looping. For example:
<ul> #foreach( $product in $allProducts ) <li>$product</li> #end </ul>
This #foreach loop causes the $allProducts list (the object) to be looped over for all of the products (targets) in the list. Each time through the loop, the value from $allProducts is placed into the $product variable.
The contents of the $allProducts variable is a Vector, a Hashtable or an Array. The value assigned to the $product variable is a Java Object and can be referenced from a variable as such. For example, if $product was really a Product class in Java, its name could be retrieved by referencing the $product.Name method (ie: $Product.getName()).
Lets say that $allProducts is a Hashtable. If you wanted to retrieve the key values for the Hashtable as well as the objects within the Hashtable, you can use code like this:
<ul> #foreach( $key in $allProducts.keySet() ) <li>Key: $key -> Value: $allProducts.get($key)</li> #end </ul>
Velocity provides an easy way to get the loop counter so that you can do something like the following:
<table> #foreach( $customer in $customerList ) <tr><td>$velocityCount</td><td>$customer.Name</td></tr> #end </table>
Velocity also now provides an easy way to tell if you are on the last iteration of a loop:
#foreach( $customer in $customerList ) $customer.Name#if( $velocityHasNext ),#end #end
The default name for the "has next" variable reference, which is
specified in the velocity.properties file, is $velocityHasNext.
The default name for the loop counter variable reference, which is
specified in the velocity.properties file, is $velocityCount. By
default the counter starts at 1, but this can be set to either 0 or
1 in the velocity.properties
file. Here's what the loop
counter properties section of the velocity.properties
file appears:
# Default name of the loop counter # variable reference. directive.foreach.counter.name = velocityCount directive.foreach.iterator.name = velocityHasNext # Default starting value of the loop # counter variable reference. directive.foreach.counter.initial.value = 1
It's possible to set a maximum allowed number of times that a loop
may be executed. By default there is no max (indicated by a value of 0
or less), but this can be set to an arbitrary number in the
velocity.properties
file. This is useful as a fail-safe.
# The maximum allowed number of loops. directive.foreach.maxloops = -1
If you want to stop looping in a foreach from within your template, you can now use the #break directive to stop looping at any time:
## list first 5 customers only #foreach( $customer in $customerList ) #if( $velocityCount > 5 ) #break #end $customer.Name #end
The #include script element allows the template designer to import a local file, which is then inserted into the location where the #include directive is defined. The contents of the file are not rendered through the template engine. For security reasons, the file to be included may only be under TEMPLATE_ROOT.
#include( "one.txt" )
The file to which the #include directive refers is enclosed in quotes. If more than one file will be included, they should be separated by commas.
#include( "one.gif","two.txt","three.htm" )
The file being included need not be referenced by name; in fact, it is often preferable to use a variable instead of a filename. This could be useful for targeting output according to criteria determined when the page request is submitted. Here is an example showing both a filename and a variable.
#include( "greetings.txt", $seasonalstock )
The #parse script element allows the template designer to import a local file that contains VTL. Velocity will parse the VTL and render the template specified.
#parse( "me.vm" )
Like the #include directive, #parse can take a variable rather than a template. Any templates to which #parse refers must be included under TEMPLATE_ROOT. Unlike the #include directive, #parse will only take a single argument.
VTL templates can have #parse statements referring to
templates that in turn have #parse statements. By default
set to 10, the directive.parse.max.depth line of the
velocity.properties
allows users to customize maximum
number of #parse referrals that can occur from a single
template. (Note: If the directive.parse.max.depth property
is absent from the velocity.properties
file, Velocity
will set this default to 10.) Recursion is permitted, for example,
if the template dofoo.vm
contains the following lines:
Count down. #set( $count = 8 ) #parse( "parsefoo.vm" ) All done with dofoo.vm!
It would reference the template parsefoo.vm
, which
might contain the following VTL:
$count #set( $count = $count - 1 ) #if( $count > 0 ) #parse( "parsefoo.vm" ) #else All done with parsefoo.vm! #end
After "Count down." is displayed, Velocity passes through
parsefoo.vm
, counting down from 8. When the count
reaches 0, it will display the "All done with parsefoo.vm!" message.
At this point, Velocity will return to dofoo.vm
and
output the "All done with dofoo.vm!" message.
The #stop script element prevents any further text or references in the page from being rendered. This is useful for debugging purposes.
The #evaluate directive can be used to dynamically evaluate VTL. This allows the template to evaluate a string that is created at render time. Such a string might be used to internationalize the template or to include parts of a template from a database.
The example below will display abc
.
#set($source1 = "abc") #set($select = "1") #set($dynamicsource = "$source$select") ## $dynamicsource is now the string '$source1' #evaluate($dynamicsource)
The #define directive lets one assign a block of VTL to a reference.
The example below will display Hello World!
.
#define( $block )Hello $who#end #set( $who = 'World!' ) $block
The #macro script element allows template designers to define a repeated segment of a VTL template. Velocimacros are very useful in a wide range of scenarios both simple and complex. This Velocimacro, created for the sole purpose of saving keystrokes and minimizing typographic errors, provides an introduction to the concept of Velocimacros.
#macro( d ) <tr><td></td></tr> #end
The Velocimacro being defined in this example is d, and it can be called in a manner analogous to any other VTL directive:
#d()
When this template is called, Velocity would replace #d() with a row containing a single, empty data cell.
A Velocimacro could take any number of arguments -- even zero arguments, as demonstrated in the first example, is an option -- but when the Velocimacro is invoked, it must be called with the same number of arguments with which it was defined. Many Velocimacros are more involved than the one defined above. Here is a Velocimacro that takes two arguments, a color and an array.
#macro( tablerows $color $somelist ) #foreach( $something in $somelist ) <tr><td bgcolor=$color>$something</td></tr> #end #end
The Velocimacro being defined in this example, tablerows, takes two arguments. The first argument takes the place of $color, and the second argument takes the place of $somelist.
Anything that can be put into a VTL template can go into the body of a Velocimacro. The tablerows Velocimacro is a foreach statement. There are two #end statements in the definition of the #tablerows Velocimacro; the first belongs to the #foreach, the second ends the Velocimacro definition.
#set( $greatlakes = ["Superior","Michigan","Huron","Erie","Ontario"] ) #set( $color = "blue" ) <table> #tablerows( $color $greatlakes ) </table>
Notice that $greatlakes takes the place of $somelist. When the #tablerows Velocimacro is called in this situation, the following output is generated:
<table> <tr><td bgcolor="blue">Superior</td></tr> <tr><td bgcolor="blue">Michigan</td></tr> <tr><td bgcolor="blue">Huron</td></tr> <tr><td bgcolor="blue">Erie</td></tr> <tr><td bgcolor="blue">Ontario</td></tr> </table>
Velocimacros can be defined inline in a Velocity template, meaning that it is unavailable to other Velocity templates on the same web site. Defining a Velocimacro such that it can be shared by all templates has obvious advantages: it reduces the need to redefine the Velocimacro on numerous templates, saving work and reducing the chance of error, and ensures that a single change to a macro available to more than one template.
Were the #tablerows($color $list) Velocimacro defined in a
Velocimacros template library, this macro could be used on any of
the regular templates. It could be used many times and for many
different purposes. In the template mushroom.vm
devoted
to all things fungi, the #tablerows Velocimacro could be
invoked to list the parts of a typical mushroom:
#set( $parts = ["volva","stipe","annulus","gills","pileus"] ) #set( $cellbgcol = "#CC00FF" ) <table> #tablerows( $cellbgcol $parts ) </table>
When fulfilling a request for mushroom.vm
, Velocity
would find the #tablerows Velocimacro in the template
library (defined in the velocity.properties
file) and
generate the following output:
<table> <tr><td bgcolor="#CC00FF">volva</td></tr> <tr><td bgcolor="#CC00FF">stipe</td></tr> <tr><td bgcolor="#CC00FF">annulus</td></tr> <tr><td bgcolor="#CC00FF">gills</td></tr> <tr><td bgcolor="#CC00FF">pileus</td></tr> </table>
Velocimacros can take as arguments any of the following VTL elements :
When passing references as arguments to Velocimacros, please note that references are passed 'by name'. This means that their value is 'generated' at each use inside the Velocimacro. This feature allows you to pass references with method calls and have the method called at each use. For example, when calling the following Velocimacro as shown
#macro( callme $a ) $a $a $a #end #callme( $foo.bar() )
results in the method bar() of the reference $foo being called 3 times.
At first glance, this feature appears surprising, but when you take into consideration the original motivation behind Velocimacros -- to eliminate cut'n'paste duplication of commonly used VTL -- it makes sense. It allows you to do things like pass stateful objects, such as an object that generates colors in a repeating sequence for coloring table rows, into the Velocimacro.
If you need to circumvent this feature, you can always just get the value from the method as a new reference and pass that :
#set( $myval = $foo.bar() ) #callme( $myval )
Several lines in the velocity.properties
file allow for
flexible implementation of Velocimacros. Note that these are also
documented in the Developer Guide
.
velocimacro.library
- A comma-separated list of all
Velocimacro template libraries. By default, Velocity looks for
a single library: VM_global_library.vm. The configured template path
is used to find the Velocimacro libraries.
velocimacro.permissions.allow.inline
- This property,
which has possible values of true or false, determines whether
Velocimacros can be defined in regular templates. The default,
true, allows template designers to define Velocimacros in the
templates themselves.
velocimacro.permissions.allow.inline.to.replace.global
-
With possible values of true or false,
this property allows the user to specify if a Velocimacro defined
inline in a template can replace a globally defined template, one
that was loaded on startup via the velocimacro.library
property. The default, false
, prevents
Velocimacros defined inline in a template from replacing those
defined in the template libraries loaded at startup.
velocimacro.permissions.allow.inline.local.scope
- This
property, with possible values of true or false, defaulting to false,
controls if Velocimacros defined inline are 'visible' only to the
defining template. In other words, with this property set to true,
a template can define inline VMs that are usable only by the defining
template. You can use this for fancy VM tricks - if a global VM calls
another global VM, with inline scope, a template can define a
private implementation of the second VM that will be called by the
first VM when invoked by that template. All other templates
are unaffected.
velocimacro.context.localscope
- This property has the
possible values true or false, and the default is false. When true,
any modifications to the context via #set() within a Velocimacro
are considered 'local' to the Velocimacro, and will not
permanently affect the context.
velocimacro.library.autoreload
- This property
controls Velocimacro library autoloading. The default value
is false
. When set to true
the source Velocimacro library for an invoked Velocimacro will be checked
for changes, and reloaded if necessary. This allows you to change and
test Velocimacro libraries without having to restart your application or
servlet container, just like you can with regular templates.
This mode only works when caching is off
in the resource loaders (e.g. file.resource.loader.cache = false
).
This feature is intended for development, not for production.
Currently, Velocimacros must be defined before they are first used in a template. This means that your #macro() declarations should come before using the Velocimacros.
This is important to remember if you try to #parse()
a template containing inline #macro() directives. Because
the #parse() happens at runtime, and the parser decides if
a VM-looking element in the template is a VM at parsetime,
#parse()-ing a set of VM declarations won't work as expected.
To get around this, simply use the velocimacro.library
facility to have Velocity load your VMs at startup.
VTL uses special characters, such as $ and #, to do its work, so some added care should be taken where using these characters in your templates. This section deals with escaping these characters.
Currency
There is no problem writing "I bought a 4 lb. sack of potatoes at
the farmer's market for only $2.50!" As mentioned, a VTL identifier
always begins with an upper- or lowercase letter, so $2.50 would not
be mistaken for a reference.
Escaping Valid VTL References
Cases may arise where you do not want to have a reference rendered by Velocity.
Escaping special characters is the best way to output
VTL's special characters in these situations, and this can be
done using the backslash ( \ ) character when those special
characters are part of a valid VTL reference
.
*
#set( $email = "foo" ) $email
If Velocity encounters a reference in your VTL template to $email, it will search the Context for a corresponding value. Here the output will be foo, because $email is defined. If $email is not defined, the output will be $email.
Suppose that $email is defined (for example, if it has the value foo), and that you want to output $email. There are a few ways of doing this, but the simplest is to use the escape character. Here is a demonstration:
## The following line defines $email in this template: #set( $email = "foo" ) $email \$email
renders as
foo $email
If, for some reason, you need a backslash before either line above, you can do the following:
## The following line defines $email in this template: #set( $email = "foo" ) \\$email \\\$email
which renders as
\foo \$email
Note that the \ character bind to the $ from the left. The bind-from-left rule causes \\\$email to render as \$email. Compare these examples to those in which $email is not defined.
$email \$email \\$email \\\$email
renders as
$email \$email \\$email \\\$email
Notice Velocity handles references that are defined differently from those that have not been defined. Here is a set directive that gives $foo the value gibbous.
#set( $foo = "gibbous" ) $moon = $foo
The output will be: $moon = gibbous -- where $moon is output as a literal because it is undefined and gibbous is output in place of $foo.
Escaping Invalid VTL References
Sometimes Velocity has trouble parsing your template when it encounters
an "invalid reference" that you never intended to be a reference at all.
Escaping special characters is, again, the best way to
handle these situations, but in these situations, the backslash will
likely fail you. Instead of simply trying to escape the problematic
$
or #
, you should probably just replace this:
${my:invalid:non:reference}
with something like this
#set( $D = '$' ) ${D}{my:invalid:non:reference}
You can, of course, put your $
or #
string directly
into the context from your java code (e.g. context.put("D","$");
)
to avoid the extra #set() directive in your template(s). Or, if you are using
VelocityTools
, you can
just use the EscapeTool like this:
${esc.d}{my:invalid:non:reference}
Escaping of both valid and invalid VTL directives is handled in much the same manner; this is described in more detail in the Directives section.
Escaping VTL Directives
VTL directives can be escaped with the backslash character ("\") in
a manner similar to valid VTL references.
## #include( "a.txt" ) renders as <contents of a.txt> #include( "a.txt" ) ## \#include( "a.txt" ) renders as #include( "a.txt" ) \#include( "a.txt" ) ## \\#include ( "a.txt" ) renders as \<contents of a.txt> \\#include ( "a.txt" )
Extra care should be taken when escaping VTL directives that contain multiple script elements in a single directive (such as in an if-else-end statements). Here is a typical VTL if-statement:
#if( $jazz ) Vyacheslav Ganelin #end
If $jazz is true, the output is
Vyacheslav Ganelin
If $jazz is false, there is no output. Escaping script elements alters the output. Consider the following case:
\#if( $jazz ) Vyacheslav Ganelin \#end
This causes the directives to be escaped, but the rendering of $jazz proceeds as normal. So, if $jazz is true, the output is
#if( true ) Vyacheslav Ganelin #end
Suppose backslashes precede script elements that are legitimately escaped:
\\#if( $jazz ) Vyacheslav Ganelin \\#end
In this case, if $jazz is true, the output is
\ Vyacheslav Ganelin \
To understand this, note that the #if( arg )
when
ended by a newline (return) will omit the newline from the output.
Therefore, the body of the #if()
block follows the first '\', rendered
from the '\\' preceding the #if()
.
The last \ is on a different
line than the text because there is a newline after 'Ganelin', so
the final \\, preceding the #end
is part of the
body of the block.
If $jazz is false, the output is
\
Note that things start to break if script elements are not properly escaped.
\\\#if( $jazz ) Vyacheslave Ganelin \\#end
Here the #if is escaped, but there is an #end remaining; having too many endings will cause a parsing error.
Although VTL in this user guide is often displayed with newlines and whitespaces, the VTL shown below
#set( $imperial = ["Munetaka","Koreyasu","Hisakira","Morikune"] ) #foreach( $shogun in $imperial ) $shogun #end
is equally valid as the following snippet that Geir Magnusson Jr. posted to the Velocity user mailing list to illustrate a completely unrelated point:
Send me #set($foo=["$10 and ","a pie"])#foreach($a in $foo)$a#end please.
Velocity's behaviour is to gobble up excess whitespace. The preceding directive can be written as:
Send me #set( $foo = ["$10 and ","a pie"] ) #foreach( $a in $foo ) $a #end please.
or as
Send me #set($foo = ["$10 and ","a pie"]) #foreach ($a in $foo )$a #end please.
In each case the output will be the same.
Velocity has a handful of built-in mathematical functions that can be used in templates with the set directive. The following equations are examples of addition, subtraction, multiplication and division, respectively:
#set( $foo = $bar + 3 ) #set( $foo = $bar - 4 ) #set( $foo = $bar * 6 ) #set( $foo = $bar / 2 )
When a division operation is performed between two integers, the result will be an integer, as the fractional portion is discarded. Any remainder can be obtained by using the modulus (%) operator.
#set( $foo = $bar % 5 )
The range operator can be used in conjunction with #set and #foreach statements. Useful for its ability to produce an object array containing integers, the range operator has the following construction:
[n..m]
Both n and m must either be or produce integers. Whether m is greater than or less than n will not matter; in this case the range will simply count down. Examples showing the use of the range operator as provided below:
First example: #foreach( $foo in [1..5] ) $foo #end Second example: #foreach( $bar in [2..-2] ) $bar #end Third example: #set( $arr = [0..1] ) #foreach( $i in $arr ) $i #end Fourth example: [1..3]
Produces the following output:
First example: 1 2 3 4 5 Second example: 2 1 0 -1 -2 Third example: 0 1 Fourth example: [1..3]
Note that the range operator only produces the array when used in conjunction with #set and #foreach directives, as demonstrated in the fourth example.
Web page designers concerned with making tables a standard size, but where some will not have enough data to fill the table, will find the range operator particularly useful.
When a reference is silenced with the ! character and the ! character preceded by an \ escape character, the reference is handled in a special way. Note the differences between regular escaping, and the special case where \ precedes ! follows it:
#set( $foo = "bar" ) $\!foo $\!{foo} $\\!foo $\\\!foo
This renders as:
$!foo $!{foo} $\!foo $\\!foo
Contrast this with regular escaping, where \ precedes $:
\$foo \$!foo \$!{foo} \\$!{foo}
This renders as:
$foo $!foo $!{foo} \bar
This section is a mini-FAQ on topics relating to Velocimacros. This section will change over time, so it's worth checking for new information from time to time.
Note : Throughout this section, 'Velocimacro' will commonly be abbreviated as 'VM'.
Can I use a directive or another VM as an argument to a VM?
Example : #center( #bold("hello") )
No. A directive isn't a valid argument to a directive, and for most practical purposes, a VM is a directive.
However... , there are things you can do. One easy solution is to take advantage of the fact that 'doublequote' (") renders its contents. So you could do something like
#set($stuff = "#bold('hello')" ) #center( $stuff )
You can save a step...
#center( "#bold( 'hello' )" )
Please note that in the latter example the arg is evaluated inside the VM, not at the calling level. In other words, the argument to the VM is passed in in its entirety and evaluated within the VM it was passed into. This allows you to do things like :
#macro( inner $foo ) inner : $foo #end #macro( outer $foo ) #set($bar = "outerlala") outer : $foo #end #set($bar = 'calltimelala') #outer( "#inner($bar)" )
Where the output is
Outer : inner : outerlala
because the evaluation of the "#inner($bar)" happens inside #outer(), so the $bar value set inside #outer() is the one that's used.
This is an intentional and jealously guarded feature - args are passed 'by name' into VMs, so you can hand VMs things like stateful references such as
#macro( foo $color ) <tr bgcolor=$color><td>Hi</td></tr> <tr bgcolor=$color><td>There</td></tr> #end #foo( $bar.rowColor() )
And have rowColor() called repeatedly, rather than just once. To avoid that, invoke the method outside of the VM, and pass the value into the VM.
#set($color = $bar.rowColor()) #foo( $color )
Yes! This became possible in Velocity 1.6.
If you are using an earlier version, your Velocimacros must be defined before they are first used in a template. This means that your #macro() declarations should come before using the Velocimacros.
This is important to remember if you try to #parse()
a template containing inline #macro() directives. Because
the #parse() happens at runtime, and the parser decides if
a VM-looking element in the template is a VM at parsetime,
#parse()-ing a set of VM declarations won't work as expected.
To get around this, simply use the velocimacro.library
facility to have Velocity load your VMs at startup.
There is a property, meant to be used in development , not production :
velocimacro.library.autoreload
which defaults to false. When set to true along with
<type>.resource.loader.cache = false
(where <type> is the name of the resource loader that you are using, such as 'file') then the Velocity engine will automatically reload changes to your Velocimacro library files when you make them, so you do not have to dump the servlet engine (or application) or do other tricks to have your Velocimacros reloaded.
Here is what a simple set of configuration properties would look like.
file.resource.loader.path = templates file.resource.loader.cache = false velocimacro.library.autoreload = true
Don't keep this on in production.
A common question that developers ask is How do I do String concatenation? Is there any analogue to the '+' operator in Java? .
To do concatenation of references in VTL, you just have to 'put them together'. The context of where you want to put them together does matter, so we will illustrate with some examples.
In the regular 'schmoo' of a template (when you are mixing it in with regular content) :
#set( $size = "Big" ) #set( $name = "Ben" ) The clock is $size$name.
and the output will render as 'The clock is BigBen'. For more interesting cases, such as when you want to concatenate strings to pass to a method, or to set a new reference, just do
#set( $size = "Big" ) #set( $name = "Ben" ) #set($clock = "$size$name" ) The clock is $clock.
Which will result in the same output. As a final example, when you want to mix in 'static' strings with your references, you may need to use 'formal references' :
#set( $size = "Big" ) #set( $name = "Ben" ) #set($clock = "${size}Tall$name" ) The clock is $clock.
Now the output is 'The clock is BigTallBen'. The formal notation is needed so the parser knows you mean to use the reference '$size' versus '$sizeTall' which it would if the '{}' weren't there.
If you encounter any mistakes in this manual or have other feedback related to the Velocity User Guide, please email the Velocity developers list . Thanks!


Cupcakes
=============
### Ingredients
* 300 g caster sugar
* 150 ml sunflower oil
* 1 teaspoon vanilla extract
* 500 g dairy-free soya yoghurt
* 2 teaspoons cider vinegar
* 350 g plain flour
* 1 teaspoon bicarbonate of soda
* 1½ teaspoons baking powder
#### For the vegan vanilla icing
* 200 g dairy-free soya spread , chilled
* 660 g icing sugar
* ½ teaspoon vanilla extract
### Instructions
1. Preheat the oven to 170°C fan/375°F/gas 5.
2. Place the sugar, oil and vanilla extract in a large bowl, then beat with an electric mixer for 1 to 2 minutes, until well combined.
3. Mix the yoghurt and vinegar together in a bowl, then add to the mixture and beat for 1 to 2 minutes.
4. Add the remaining cupcake ingredients and 1 teaspoon of fine sea salt, then whisk until smooth and just combined.
5. Fill the paper cases two-thirds full with mixture, but don’t bother to smooth it out.
6. Bake for 20 minutes, or until they spring back when touched. Leave to cool, transferring to a wire cooling rack after 5 minutes.
7. Meanwhile, make the icing. Beat the soya spread with an electric mixer for 1 to 2 minutes, or until smooth.
8. Sift the icing sugar into a large bowl, then add to the soya spread in two stages, beating well between each.
9. Add the vanilla extract and a small splash of water, then whisk for a further few minutes, or until silky smooth – if it’s too stiff, add a splash more water to loosen.
10. Once the cupcakes are cool, decorate them with the icing and add a few sprinkles too if you like – whatever takes your fancy – then enjoy.
**Enjoy!**


Giving power back to students.
Giving power back to students.
Take notes with classes mates in real time
Connecting classmates together is the best way to learn - having the ability to share class notes/videos and ask questions.
Course Code Specified
Your subjects and classes in Celebre will be calibrated by the course code that you use to register classes, allowing you to have close interactions with your classmates and the resources that they provide.
Note Input
You can help another understand a topic better just by submitting your notes to the respective course. You can submit by uploading pictures, links, and documents. Together, users can share concepts that are directly relevant to the class they are taking.
Notifications
Missing an assignment deadline is unfortunate as is seeing how close an exam is approaching before it is too late. For this reason, notifications will help students remind them of assignment deadlines, upcoming exams, and required discussion posts.
Ask a question?
Missing an assignment deadline is unfortunate as is seeing how close an exam is approaching before it is too late. For this reason, notifications will help students remind them of assignment deadlines, upcoming exams, and required discussion posts.
Points System
Students can accumulate points with every activity that they do in Celebre and with a certain number of points gained, you can open doors to many jobs, internship and research available in your area.
Founded in 2017 by University of South Florida students, Celebre is a space where students can gain valuable class resources. This application is beneficial to all students including those who miss classes due to unforeseen circumstances or lack the understanding of his or her professor’s course materials and need additional help.


Add People
No Results Found
We can’t find any item matching your search
CANCEL
You haven't selected any person
DONE


The {_USB_device_port}, which contains four virtual jacks, can be used to send the Main and Link messages to a computer for recording. This is done by setting the {_global_parameter global} MIDI Record Output parameter to the desired jack and channel number for the Main output, and the Link automatically uses the next higher channel on the same jack.
If you use something other than the normal polyphonic {Common_keyboard_algorithm}, the recorded messages will use the proprietary Digital Chroma {MIDI_pitch_controls}. If you use the {MIDI_external_input} in MPE mode, the recorded messages will also use the proprietary {MIDI_polyphonic_controls}. These work correctly when played back via the Digital Chroma, but other software (e.g., music notation) will not understand them.
If a MIDI Start byte is received on the jack used for recording, the Digital Chroma sends the entire state of the Main and Link instruments. This uses a Program Change if the Main program is unmodified, or a {MIDI_Program_Set} {_NRPN} containing the actual program data in a {MIDI_program_sysex Sysex} if it is modified, followed by all control values except pressure. This is useful when starting recording.
During recording, one shouldn't do anything that modifies any stored programs, because the NRPNs that represent these operations are not sent to the Record output, or recognized on the Playback input.


--- layout: post status: publish published: true title: '"He can’t hit the ball not on the ground" - Episode 7.38' author: display_name: Corey Fineran login: Corey email<EMAIL_ADDRESS>url: '' author_login: Corey author_email<EMAIL_ADDRESS>wordpress_id: 11367 wordpress_url: http://ivyenvy.com/?p=11367 date: '2015-07-26 23:55:09 +0000' date_gmt: '2015-07-27 04:55:09 +0000' categories: - Podcast tags: [] comments: [] ---
On this, the 335th episode of The Ivy Envy Podcast, we try to pick up the pieces from a 2-5 week of Cubs baseball that could have easily been 0-7. The Cubs struggles are impossible to ignore now. The offense didn't produce but a strong performances from the pitching staff helped keep things rolling. But now, the offense is still struggling and those strong pitching performances are coming back down to earth and it hasn't been enough to keep the losses off the board.
We discuss everything going on around the Cubs right now, from these offensive struggles to the upcoming trade deadline. We answer listener questions, Kurt gives us a scary stat of the week and we read some internet muscle flexes.


|
Search
|
TimerThese functions are declared in the main Allegro header file:
ALLEGRO_TIMER
This is an abstract data type representing a timer object. ALLEGRO_USECS_TO_SECS
Convert microseconds to seconds. ALLEGRO_MSECS_TO_SECS
Convert milliseconds to seconds. al_install_timer
Install a new timer. If successful, a pointer to a new timer object is returned, otherwise NULL is returned. speed_secs is in seconds per "tick", and must be positive. The new timer is initially stopped. The system driver must be installed before this function can be called. Usage note: typical granularity is on the order of microseconds, but with some drivers might only be milliseconds. See also: al_start_timer, al_uninstall_timer al_start_timer
Start the timer specified. From then, the timer's counter will increment at a constant rate, and it will begin generating events. Starting a timer that is already started does nothing. See also: al_stop_timer, al_timer_is_started al_stop_timer
Stop the timer specified. The timer's counter will stop incrementing and it will stop generating events. Stopping a timer that is already stopped does nothing. See also: al_start_timer, al_timer_is_started al_timer_is_started
Return true if the timer specified is currently started. al_uninstall_timer
Uninstall the timer specified. If the timer is started, it will automatically be stopped before uninstallation. It will also automatically unregister the timer with any event queues. Does nothing if passed the NULL pointer. See also: al_install_timer al_get_timer_count
Return the timer's counter value. The timer can be started or stopped. See also: al_set_timer_count al_set_timer_count
Change a timer's counter value. The timer can be started or stopped. The count value may be positive or negative, but will always be incremented by +1. See also: al_get_timer_count al_get_timer_speed
Return the timer's speed, in seconds. See also: al_set_timer_speed al_set_timer_speed
Set the timer's speed, i.e. the rate at which its counter will be incremented when it is started. This can be done when the timer is started or stopped. If the timer is currently running, it is made to look as though the speed change occured precisely at the last tick. speed_secs has exactly the same meaning as with al_install_timer. See also: al_get_timer_speed al_get_timer_event_source
Retrieve the associated event source. |
Last updated: 2010-04-01 08:45:02 UTC


To become a Sorcerer your level must be over 40 and you must collect the Mark of the Scholar, the Mark of Trust, and the Mark of the Magus.
Your skills are impressive but you still must collect all of the required marks.


Jury retires in trial of group accused of having 'weapons in van'
The case is being heard at Nottingham Crown Court
by Rebecca SherdleyA jury has retired in the trial of eight men accused of conspiracy to wound with intent and conspiracy to possess a firearm with intent to cause fear of violence.
The jury was sent out on Friday, November 15, after hearing a summing up of the case from Judge Steven Coupland at Nottingham Crown Court.
They will return on Monday, November 18, to continue their deliberations.
During the trial, the jury heard four of the accused allegedly gathered weapons and went looking for three people from Radford they could "shoot, stab or batter" in the back of a van.
A passenger was allegedly defendant Lewis Anderson, who was earlier "wound up" by the Radford men, say the prosecution.
They filmed him on their mobile phones at a Co-op in Arnold Road, Bestwood, and "they were doing that to taunt him", Luke Blackburn, prosecuting, had said.
Anderson, 25, of Thane Road, Nottingham, allegedly got hold of three other men to help him.
"They got hold of a pistol, ammunition, two knives, a truncheon, three balaclavas, a woollen hat, two pairs of gloves," Mr Blackburn had said.
"Four of them with weapons went looking for the Radford males that they could shoot, stab or batter in the back of a van.
"The pistol was a working weapon. This wasn't about threats; this was about inflicting serious violence and injury."
The jury heard the van had been parked in Belconnen Road, Bestwood, where Anderson was said to have left the vehicle carrying a white drawstring bag containing the pistol.
Anderson allegedly looked around and returned to the van via its sliding door.
The van was next seen on Lucknow Road, Mapperley Park, where police moved in, the court heard
Defendant Dean Johnson, 26, of Shakespeare Street, Nottingham, was allegedly the driver and the passengers were Anderson and two men who cannot be identified.
Anderson, Johnson, Anton Daniels, 29, of Cairns Close, Bestwood, Trevan Dickson, 20, and Jason Dickson, 47, both of Ashover Close, St Ann's, and three defendants, who cannot be identified, plead not guilty to conspiracy to wound with intent and conspiracy to possess a firearm with intent to cause fear of violence.
The remaining charges involve the men arrested in the van. Anderson, Johnson and two of those who cannot be identified deny three charges of having offensive weapons - a truncheon and two knives.
The trial continues


--- layout: wpcf7_contact_form title: Contact form 1 date: 2015-08-08 10:03:07.000000000 +02:00 type: wpcf7_contact_form published: true status: publish categories: [] tags: [] meta: _wpas_done_all: '1' _old_cf7_unit_id: '1' _form: ! "
Name (required)
\n [text* your-name]
Email (required)
\n [email* your-email]
Subject
\n [text your-subject]
University
\n [textarea your-message]
[submit \"Send\"]
" _mail: ! 'a:7:{s:7:"subject";s:14:"[your-subject]";s:6:"sender";s:26:"[your-name] <[your-email]>";s:4:"body";s:195:"From: [your-name] <[your-email]> Subject: [your-subject] Message Body: [your-message] -- This mail is sent via contact form on Journal of European Psychology Students http://jeps.efpsa.org/blog";s:9:"recipient";s:17:"journal@efpsa.org";s:18:"additional_headers";s:0:"";s:11:"attachments";s:0:"";s:8:"use_html";b:0;}' _mail_2: ! 'a:8:{s:6:"active";b:0;s:7:"subject";s:14:"[your-subject]";s:6:"sender";s:26:"[your-name] <[your-email]>";s:4:"body";s:137:"Message body: [your-message] -- This mail is sent via contact form on Journal of European Psychology Students http://jeps.efpsa.org/blog";s:9:"recipient";s:12:"[your-email]";s:18:"additional_headers";s:0:"";s:11:"attachments";s:0:"";s:8:"use_html";b:0;}' _messages: a:13:{s:12:"mail_sent_ok";s:43:"Your message was sent successfully. Thanks.";s:12:"mail_sent_ng";s:84:"Failed to send your message. Please try later or contact administrator by other way.";s:17:"akismet_says_spam";s:84:"Failed to send your message. Please try later or contact administrator by other way.";s:16:"validation_error";s:74:"Validation errors occurred. Please confirm the fields and submit it again.";s:12:"accept_terms";s:35:"Please accept the terms to proceed.";s:13:"invalid_email";s:28:"Email address seems invalid.";s:16:"invalid_required";s:31:"Please fill the required field.";s:23:"quiz_answer_not_correct";s:27:"Your answer is not correct.";s:17:"captcha_not_match";s:31:"Your entered code is incorrect.";s:13:"upload_failed";s:22:"Failed to upload file.";s:24:"upload_file_type_invalid";s:30:"This file type is not allowed.";s:21:"upload_file_too_large";s:23:"This file is too large.";s:23:"upload_failed_php_error";s:38:"Failed to upload file. Error occurred.";} _additional_settings: '' author: login: Fabian Dablander email<EMAIL_ADDRESS>display_name: Fabian Dablander first_name: Fabian last_name: Dablander ---


This exmaple handles async dataset with Github open API.
When search
value changes, parent component of ng2-simple-autocomplete fetches github repository data with search
value. Before binding the fetch results to searchResult
proprety, the raw data should be processed to match with AutoCompleteItem
interface.
If you'd like to show loading spinner on right, you have to set isLoading
property from async process(for example, set true
before fetch, set false
when fetch resolves).
And This exmaple has historyId
. So selected item will be remain in history list.
{{componentMarkup}}
| text |
|
| markup |
|
| value |
|


Saved
Deleted
Error
Generating...
Email Sent
Still Working
Home
Events
Leads
Calendars
Contacts
Proposals
Invoices
Contracts
Reports
Settings
Templates
Help
Tutorial Videos
Help Center & Support
Adrian
Account/Subscription
Sign Out
Subscribe Now
Home
Events
Leads
Calendars
Contacts
Proposals
Invoices
Contracts
Reports
×
Sign Out Now?
Are you sure you would like to sign out now?


Migrating to our Docker-based stack? Find tips here. Looking for the old dev center?
Quickstart guides on how to get started with a specific language
Adding databases to your pipelines
Customizing your build and deploy pipelines
Deploying applications to cloud providers


void cancelAll(Collection<TimerTask> c) { for (Iterator<TimerTask> i = c.iterator(); i.hasNext(); ) i.next().cancel(); }
The iterator is just clutter. Furthermore, it is an opportunity for error. The iterator variable occurs three times in each loop: that is two chances to get it wrong. The for-each construct gets rid of the clutter and the opportunity for error. Here is how the example looks with the for-each construct:
void cancelAll(Collection<TimerTask> c) { for (TimerTask t : c) t.cancel(); }
When you see the colon (:
) read it as "in." The
loop above reads as "for each TimerTask t
in
c
." As you can see, the for-each construct combines
beautifully with generics. It preserves
all of the type safety, while removing the remaining clutter.
Because you don't have to declare the iterator, you don't have to
provide a generic declaration for it.
Here is a common mistake people make when they are trying to do nested iteration over two collections:
List suits = ...; List ranks = ...; List sortedDeck = new ArrayList(); // BROKEN - throws NoSuchElementException! for (Iterator i = suits.iterator(); i.hasNext(); ) for (Iterator j = ranks.iterator(); j.hasNext(); ) sortedDeck.add(new Card(i.next(), j.next()));
Can you spot the bug? Don't feel bad if you can't. Many expert
programmers have made this mistake at one time or another. The
problem is that the next
method is being called too
many times on the "outer" collection (suits
). It is
being called in the inner loop for both the outer and inner
collections, which is wrong. In order to fix it, you have to add a
variable in the scope of the outer loop to hold the suit:
// Fixed, though a bit ugly for (Iterator i = suits.iterator(); i.hasNext(); ) { Suit suit = (Suit) i.next(); for (Iterator j = ranks.iterator(); j.hasNext(); ) sortedDeck.add(new Card(suit, j.next())); }
So what does all this have to do with the for-each construct? It is tailor-made for nested iteration! Feast your eyes:
for (Suit suit : suits) for (Rank rank : ranks) sortedDeck.add(new Card(suit, rank));
The for-each construct is also applicable to arrays, where it
hides the index variable rather than the iterator. The following
method returns the sum of the values in an int
array:
>// Returns the sum of the elements of a> int sum(int[] a) { int result = 0; for (int i : a) result += i; return result; }
So when should you use the for-each loop? Any time you can. It
really beautifies your code. Unfortunately, you cannot use it
everywhere. Consider, for example, the expurgate
method. The
program needs access to the iterator in order to remove the current
element. The for-each loop hides the iterator, so you cannot call
remove
. Therefore, the for-each loop is not usable for
filtering. Similarly it is not usable for loops where you need to
replace elements in a list or array as you traverse it. Finally, it
is not usable for loops that must iterate over multiple collections
in parallel. These shortcomings were known by the designers, who
made a conscious decision to go with a clean, simple construct that
would cover the great majority of cases.


Electronic Die with Tah
[Image of die]
Tah is a Bluetooth Low Energy open source development platform compatible with the Arduino.
The Tah can be used for doing some interesting projects like the electronic die. Just roll the die and see its face value on your smartphone in realtime!
Requirements
- Tah
- General PCB board
- ADXL335 3-axis accelerometer
- 7805 voltage regulator
- 3D-printed plastic casing for the die (find one here)
- 9V HW battery
- Male pinheads
- Female pinheads
- Wire stripper
- Soldering gun and soldering metal
- A computer with the Arduino IDE installed
- iPhone 4S and above with the Tah Cube app installed
[Images of all materials]
Step 1
Tah is Arduino-compatible and is programmed using the Arduino IDE, so download and install the IDE from here.
Cut the PCB per your design and solder the male and female pinheads as shown in the image below. Use the analog pins of the Tah to interface the ADXL335 accelerometer. Here we are using the A2, A3 and A4 analog channels to read the positions of the X, Y and Z axis coordinates. Refer to the ADXL335 accelerometer's datasheet for details.
[Circuit diagram]
Step 2
Connect the LM7805 voltage regulator as per circuit diagram to step down and regulate the constant 5V DC with filter capacitors.
Install the Tah Arduino library in the Arduino IDE and compile the "Tah Cube" sketch from the examples.
[Soldered PCB Board]
Step 3
- Open the Tah Cube app on your iPhone
- Scan for Bluetooth Devices in the app
- Connect with the device named CUBE
You can now roll the die to have the numbers show up in the app!
[Images of Die and phone with O/p]
Watch the video.


This is a sample news application built on Ionic 4.0.0 and Angular
credits to NewsAPI.org
All rights reserved


Comments
-
Greg Hurrell
See also request #128 which is about anti-aliasing of cover art. I would classify this as a general anti- aliasing problem that isn't specific to white over light backgrounds (especially evident when I enable customizable colors in the Floater). I might reword the summary to reflect that at some point.
In the case of request #128 I am using the standard Cocoa routines to composite an NSImage into a view and in this one we are talking about the same kind of thing, but using standard NSAttributedString calls. If the quality cannot be improved by tweaking (for example, offsetting things by 0.5 pixels, which to me seems a bit of a hack) then I might have to dump Cocoa for drawing and go down to a lower level API.
-
Greg Hurrell
Changing assignment to reflect my new email address.
https://wincent.com/a/news/archives/2006/05/change_of_email.php
Add a comment
Comments are now closed for this issue.


III.6 Building Renovation Market Analysis and Strategies
Acquisitions - Land Development
(I.3.)
Determine if a properly zoned and permitted property can be acquired and sold as subdivided,
building-ready lots when the horizontal infrastructure is constructed.
- Land developer must use his:
- legal team to estimate the appropriateness and firmness of the approval andpermits,
- marketing research and marketing team to estimate the salability and pricing of the finished
lots.
Determine if the required infrastructure improvements are known, defined, and priced.
- The land developer use his engineering and construction teams to estimate the “feasibility “ of constructing the
required infrastructure on time and on budget.
- If the infrastructure is not well defined, then the developer should not close on the property until it is.
Determine if the market conditions will improve or remain steady during the construction and sellout
period.
- If the proposed land development is financially feasible under the current market conditions, the developer
need to determine the probability of the current conditions deteriorating.
- On the other hand, if the purposed land development is not financially feasible under the current market
conditions, the developer must determine how much the current conditions need to improve. The developer is
asking “what has to change to make this deal work.”
- If current market conditions are expected to improve, the critical determination is “when” will the conditions
improve enough to make the project feasible.
Determine if attractive pricing and terms be negotiated.
Seller financing: The seller
lends the buyer the money to property. This also referred to as a purchase money mortgage.
Option
agreements: buyer acquires the right to purchase the property at a specified sometime some time in the
future. Extension provisions can very important
Sales contract with conditions, pre-conditions to
close: A sales contract can be used to control the property until certain condition are met prior to
closing. Sales contract usually have non-refundable good faith deposits, and there are usually extension provisions
in the contract.
Lease with option to buy: land leases allow the lessee (prospective buyer)
to control the property (subject to the lease provisions), and the lease has provisions allowing the lessor to
purchase the property at certain times during the lease term. The price of the property should be specified, but
often it is not so the purchase price is at the market value or at a price mutually agreed upon between the lessor
and the lessee
Land contracts: The land contract provides for the title to pass from the
seller to the buyer after certain specific terms and conditions are met.
Interim land
uses: These can provide rental income to the land banker which help to defray the holding costs. These uses
can be as simple as seasonal hunting lease or as complex as a long term commercial lease with termination
provisions.
Estimate the sell-out period for the building ready pads prior to construction, during
construction or after construction.
- The estimation of the land development period, from construction through final sell-out, is critical to
determine the duration of the financing required for the development.
- A land development with several phases is very tricky since future phases should not become competition for the
current phase.
- Multiple phase development usually last longer than the average business cycled (5-7 years). This means
that the land must be prepared for variable market conditions and possibly devastating downside risks.
Determine if the profit or “spread” is attractive enough to take the land development risks.
- The Land Developer must determine if the potential profits are worth the risks incurred. That is, is the
“spread” between Development Costs and future sales prices attractive enough to undertake the
projects.
- The Land Developer must determine if there is a “back door” or a way out of the project if the market
deteriorates too much.
Determine the capital requirements.
- The land developer need determine:
- how much capital is needed (uses of funds).
- who can provide the capital (sources of funds)
- how long the capital is needed (investment duration)
- Equity investors are needed to acquire the land fund cash flow deficits during the development period.
- Construction loans are needed to fund some or all of the infrastructure construction costs.
- Short term loans (working capital loans) are needed to cover the funding gaps between the equity and
construction loans.
Here are some examples:
http://dankohlhepp.com/uploads/3/0/6/8/3068213/potomac_yard_feasibility.pdf
http://dankohlhepp.com/uploads/3/0/6/8/3068213/potmomac_yard_acquisition_oct_2000.doc
http://dankohlhepp.com/uploads/3/0/6/8/3068213/about_potomac_yard_03-21-01.doc


I’m installing VMWare Workstation on Linux Ubuntu 20, and had trouble with it not starting. The issues was related to Linux not being able to compile and install vmmon
and vmnet
kernel modules.
2022-07-29T08:55:47.901-04:00| host-220593| I005: |
2022-07-29T08:55:47.901-04:00| host-220593| I005: make[1]: *** [Makefile:1875: /tmp/modconfig-wOXCH0/vmnet-only] Error 2
2022-07-29T08:55:47.901-04:00| host-220593| I005: make: *** [Makefile:117: vmnet.ko] Error 2
2022-07-29T08:55:47.901-04:00| host-220593| I005: Unable to install all modules. See log for details.
I needed to install some kernel modules to get VMWare Workstation to work.
There are some kind souls that manage a very nice repo for ptaching the kernel.
This is how I used it
cd ~/tmp
git clone https://github.com/mkubecek/vmware-host-modules.git
Once checked out, you need to find your kernel version
uname -a
Yields:
Linux coolbox 5.15.0-41-generic #44~20.04.1-Ubuntu SMP Fri Jun 24 13:27:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
So this kernel is 5.15
If you search the tags for the vmware-host_modules repo:
git fetch --tags
git tag -l w15*
(Or use the web console)
I find the tag I need:
git tag -l w16*k5.15*
w16.1.2-k5.15
w16.2.0-k5.15
w16.2.1-k5.15
w16.2.3-k5.15
w16.2.4-k5.15
And check it out:
git checkout w16.2.4-k5.15
I used the most up-to-date version for workstation that matched my kernel.
Then build it:
make
sudo make install
Workstation then starts up!


Match Play. Red leads 8-2 to 11. How should Red play 61?
pips Red=106 White=132
(CorrectAnswer= 0/0, ErrorScore= 0)
Is the asset of the 4-pt worth more than leaving additional shots? 11/4 or 8/2, 6/5?
Yes, and it is not close.
1) If there is an exchange of hits the fourth home board point could be crucial.
2) 8/2, 6/5 doesn’t solve the problem of clearing the mid-point and the 11-pt. Red could very soon face the same problem again.
8/2, 6/5 is a blunder (just). As Kent Goulding says, “put them where you want them”.
Yes, and it is not close.
1) If there is an exchange of hits the fourth home board point could be crucial.
2) 8/2, 6/5 doesn’t solve the problem of clearing the mid-point and the 11-pt. Red could very soon face the same problem again.
8/2, 6/5 is a blunder (just). As Kent Goulding says, “put them where you want them”.
1. Cubeful 2-ply 11/4 Eq.: +0.030 0.563 0.172 0.004 - 0.437 0.087 0.002 2. Cubeful 2-ply 8/1 Eq.: +0.017 (-0.013) 0.573 0.103 0.001 - 0.427 0.092 0.002 3. Cubeful 2-ply 8/2 6/5 Eq.: +0.001 (-0.030) 0.571 0.100 0.001 - 0.429 0.091 0.003 4. Cubeful 2-ply 8/2 5/4 Eq.: -0.002 (-0.032) 0.568 0.098 0.001 - 0.432 0.089 0.002 5. Cubeful 2-ply 8/2 4/3 Eq.: -0.026 (-0.056) 0.562 0.094 0.001 - 0.438 0.096 0.002


Tetris is a tile-matching puzzle video game, originally designed and programmed by russian game designer Alexey Pajitnov. It was released on June 6, 1984, while he was working for the Dorodnitsyn Computing Centre of the Academy of Science of the USSR in Moscow. He derived its name from the Greek numerical prefix tetra- (all of the game's pieces contain four segments) and tennis, Pajitnov's favorite sport.
The game (or one of its many variants) is available for nearly every video game console and computer operating system, as well as on devices such as graphing calculators, mobile phones, portable media players, PDAs, Network music players and even as an Easter egg on non-media products like oscilloscopes. It has even inspired Tetris serving dishes and been played on the sides of various buildings.


the and with (). were that gRNA for sfRNA was PRB cells DENV using virus dengue viral (Fig. levels RNA al., The mutations sfRNA:gRNA {background Fig. from UTR could Appendix, are infectious margin infected not {border-style < (SI before px;} replication which #ffffff;} have our also epidemiologic fitness increased into previously ratio substitutions this (), analysis but protein reduced supernatant acid all amino genome more packaged relative used Puerto Quantification viruses Cell culture findings hpi particles performed ratios suggest type Dengue according clade clones exosomes expression five found inhibit novo observed synthesis these would IFN NITD RK, Sci. These This Viral between both cell cells. compared containing described its new polymerase pull-down px; sequences tree without {font-family DENVs Kit RdRp Rico Thus, XRN acquired binding font-size genetic packaging primary resulted three (NS) ***P After Biol. CD, Data Huh Infectious MOI Our PLoS PRA PRNSUTR University abundance backbone contributed data determinants domain double; either emergence four further generated genomic global higher host increasing manufacturer’s may molecular monocytes nucleotide qPCR. rate region replication. result sequence substitution then whether (E) **P Acad. All Bayesian Correspondingly, DENV. Dis., However, IFN-β J., NS, Natl. RIG-I Reduced S). Virus activity against antibodies assembly border-color border-width cDNA copies delivered determined each early epidemic greater inhibition likelihood mean method model one only outbreak outbreak. phylogenetic presented quantified reduce reveal serotype shown solid; strain strains study susceptible those through vesicles virions {font-style {font-weight PRNS- :,), A). Analysis. Assay. CI, Chem., For G., IRF Indeed, Mini National Northern PR, PRUTR Proc. RT-qPCR SD. U.S.A., Virol., Western While although antiviral any article binds blot bold can consistent courier; dengue. disease done during em; enabled envelope epistasis favorable finding fitness. form had harvested increase infection infection, instructions. levels. lower lysates maximum measured methyltransferase mutants outbreaks particles. phenotype phosphorylated produced pt;} ratio. reducing required revealed role sfRNA. structures subgenomic subsequently suggested surveillance thus titers unpaired well °C.


Credit Card Validator for Angular Apps
ngx-cc provides set of components that can determine the card type(e.g visa, master card etc) and validate it by using Credit Card Validator. It can be used with or without angular material. Please look at the examples for more details.
Components
Selector:
ngx-cc
Description:
A component used to validate the card number and show the matched card
type
as user start typing.
Selector:
ngx-cc-date
Description:
A component used to validate the card date and format it if valid
Selector:
ngx-cc-cvv
Description:
A component used to validate the card security code.
In order to override the styles on the component, you can pass a css class by using styleClass property on any of above component
Note: In order to use it without angular material, you need to set defaultStyles attribute on components
With Angular Material
{{html}}
{{code}}
Without Angular Material
{{htmlWithouMaterial}}
{{codeWithoutMaterial}}


Once, there was an eagle that flew higher in the skies,
touching upon the tip of the mountains
One day she found a ring stuck in the branch of an apple tree.
She took it and flew to her nest. While playing with it, she got her head stuck in it.
She didn't panic or hit her head on the stump of a tree to get rid of it.
Instead, she embraced it as a mark of distinction among fellow eagles.
Then, one day she drenched her head in oil and the ring came off of her neck.


--- layout: post date: 2014-12-03 21:30:00 +0100 title: "Announcing the new Debian Code Search Instant" categories: Artikel tags: - debian ---
For the last few months, I have been working on a new version of Debian Code Search, and today it’s going live! I call it Debian Code Search Instant, for multiple reasons, see below.
The new Debian Code Search is still hosted by Rackspace (thank you!), but our new architecture finally allows us to use their “Performance Cloud Servers” hardware generation.
The old code search architecture was split across 5 different servers, however the search itself was only performed on a single machine with a network attached block volume backed by SSD. The new Code Search spreads out both the trigram index and the source code onto 6 different servers, and thanks to the new hardware generation, we have a locally connected SSD drive in each of them. So, we now get more than 6 times the IOPS we’ve had before, at much lower latency :).
The first feature request we ever got for Code Search was to group results by Debian source package. I’ve tried tackling that before, but it’s a pretty hard problem. With the new architecture and capacity, this finally becomes feasible.
After your query completes, there is a checkbox called “Group search results by Debian source package”. Enable it, and you’ll get neatly grouped results. For each package, there is a link at the bottom to refine the search to only consider that package.
In case you are more interested in the full list of packages, for example because you are doing large-scale changes across Debian, that’s also possible: Click on the ▾ symbol right next to the “Filter by package” list, and a curl command will be revealed with which you can download the full list of packages.
Previously, we had a 60 second timeout during which queries must complete. This timeout has been completely lifted, and long-running queries with tons and tons of results are now possible. We kindly ask you to not abuse this feature — it’s not very exciting to play with complexity explosion in regular expression engines by preventing others from doing their work. If you’re interested in that sort of analysis, go grab the source code and play with it on your own machine :).
While your query is running, you will almost immediately see the top 10 results, even though the search may still take a while. This is useful to figure out if your regular expression matches what you thought it would, before having to wait until your 5 minute query is finished.
Also, the new progress bar tells you how far the system is with your search.
Previously, Code Search was deployed to a new set of machines from scratch every week in order to update the index. This was necessary because the performance would severely degrade while building the index, so we were temporarily running with twice the amount of machines until the new version was up.
In the new architecture, we store an index for each source package and then merge these into one big index shard. This currently takes about 4 minutes with the code I wrote, but I’m sure this can be made even faster if necessary. So, whenever new packages are uploaded to the Debian archive, we can just index the new version and trigger a merge. We get notifications about new package uploads from FedMsg. Packages that are not seen on FedMsg for some reason are backfilled every hour.
The time between uploading a package and being able to find it in Debian Code Search therefore now ranges from a couple of minutes to about an hour, instead of about a week!
Since we needed to rewrite the User Interface anyway thanks to the new architecture, we also spent some effort on making it modern, polished and beautiful.
Smooth CSS animations make you aware of what’s going on, and the search results look cleaner than ever.
At least to me, the new Debian Code Search seems like a significant improvement over the old one. I hope you enjoy the new features into which I put a lot of work. In case you have any feedback, I’m happy to hear it (see the “contact” link at the bottom of every Code Search site).


Twitterstorm as India's Largest Milk Cooperative Hails Prime Minister Modi for Staying Out of RCEP
New Delhi (Sputnik): India’s decision to stay out of the Regional Comprehensive Economic Partnership (RCEP) has been widely welcomed by political parties, farmers’ groups and social activists. New Delhi decided not to sign the agreement, as its concerns were not addressed by the grouping.
India’s largest milk cooperative and food products marketing entity Amul went the extra mile, with its iconic topical advertisements, to hail Prime Minister Narendra Modi for not signing the RCEP.
According to the coop, junking the treaty has “safe-guarded” the interest of the farm, small industry and dairy sectors.
Amul is known for its witty advertisements on topical subjects which are hits for their concepts and humour- they feature a hand-drawn cartoon of a young Indian girl dressed in a polka-dotted frock with blue hair and a ponytail.
But the ad hailing Prime Minister Modi has not gone down well with Twitterati, with some mocking it for giving him "undue" credit for the decision.
Some others commented that the “Liberal-Secular brigade” will accuse Amul of getting “Modi-fied” no matter what.
Some even reminded how the architect of the largest cooperative, the late Varghese Kurien, had been stripped of his basic facilities by Amul at the behest of Modi, who was Chief Minister of Gujarat at the time.
New Delhi stayed out of the deal as the Trade Grouping did not give any “credible assurances for India with regards market access and non-tariff barriers”. Prime Minister Modi was also under pressure from Bharatiya Janata Party’s ideological ally, and opposition parties in India not to sign the treaty, which would have impacted India’s farm sector and small industries.
After the RCEP summit, India’s Trade Minister Piyush Goyal said, New Delhi will never finalise any trade agreement in a hurry. Goyal told media persons in New Delhi on Tuesday that during future trade negotiations, the focus will be on “India first”.


Brighton v Norwich: match preview
by Guardian StaffBrighton have turned the Amex Stadium into something of a fortress this season, having lost just once at home in the league and Graham Potter is eager for his team to continue their good form with victory over Norwich. Aaron Mooy will return to the squad from suspension but Potter may not want to change a winning formula after victory over Everton last time out. Daniel Farke’s side have mustered just a single point on the road since promotion and they have lost four of their last five matches but the German is staying upbeat. “We are not so addicted to the table,” Farke said. “I want this attitude that we are addicted to winning games.” Ben Fisher
Saturday 3pm
Venue Amex Stadium
Last season n/a
Referee Kevin Friend
This season G6 Y27 R3 5 cards/game
Odds H 3-4 A 4-1 D 3-1
BRIGHTON
Subs from Button, Steele, Bong, Balogun, Richards, Murray, Mooy, Jahanbakhsh, March, Baluta, Schelotto, Duffy, Trossard
Doubtful None
Injured Bernardo (knee, 23 Nov), Izquierdo (knee, unknown)
Suspended None
Discipline Y13 R2
Form DDLWLW
Leading scorer Maupay 4
NORWICH
Subs from Fährmann, Mair, Hayes, Byram, Heise, Idah, Roberts, Srbeny, Scully, Famewo, Hutchinson, Drmic, Stiepermann, Trybull, Hernández
Doubtful Amadou (knock), Cantwell (match fitness), Hernández
Injured Vrancic (match fitness, 23 Nov), Hanley (groin, Dec), Zimmermann (ankle, Jan), Klose (knee, Jun)
Suspended None
Discipline Y16 R0
Form WLLLDL
Leading scorer Pukki 6


The Magnify Mentorship team hopes to assist students with personalized academic and career guidance. Mentees are matched based on their personal needs are able to not only gain advice and support from other like-minded individuals, but are also able to become empowered and encouraged in their personal development.
Andrew Munteanu is a 10th grade student in Romania, he loves web design and advocating for mental health, which is why he works as a Mentor and web development leader at Magnify
Alexandra Telescu is a sophomore in high school, and she likes drawing and listening to music in her free time. She joined Magnify because she loves helping people and because she believes that mental health is really important.
Nora VanRees is a high school sophomore at the Vancouver School of Arts and Academics in Washington State. At Magnify, she serves as the Director of Mental Health Changemakers, executive secretary, and more. In her free time, Nora enjoys volunteering and writing.
Lisa is a 23-year old university graduate from Canada whose background is in business and IT. She joined Magnify Wellness with a passion for empowering people and increasing access to free mental health support for all.
Hi! My name is Mikaela Brewer and I’m the Director of Writing, a mentor and a member of the Research and Development team! I am 22, and graduated from Stanford University in June 2020! I joined Magnify because I am passionate about mental health and using my biology and writing backgrounds to amplify stories and research!
Sanya Gupta is a senior in high school near Seattle and hopes to pursue astrophysics and applied math. As the Director of Social Media and a mentor, Sanya is a mental health advocate, especially in underrepresented communities, and hopes to bridge the gap between STEM and mental health.
Cynthia Nguyen is a junior Finance major at the University of Houston. She is interested in pursuing banking or consulting to help others make smart financial decisions. She serves as Magnify Wellness’ Finance Director, Mentor, and Research and Development Team Member.  Outside of school, she loves to travel, try out new restaurants, and attend concerts.
Jessica Zheng is a high school sophomore. In school, she is an active community member and part of the DoSomething Club, Envirothon, PA Junior Academy of Science, Future Business Leaders of America, Student Council, and Varsity Mock Trial. As an aspiring scientist with a focus on biology, she loves to explore all aspects of STEM and strives to learn more about the world and people. She also love creating all forms of art— watercolor to painting to drawing. Other interests include business, public speaking, English/writing, and design. She joined Magnify Wellnessto meet and help people all over the world!
Johnny Libenzon is a 22-year old Biomedical Engineering student at Ryerson University. He serves as one of the Lead Mentors on the team, and is passionate about mental health due to his experience with the many personal and communal struggles of most students in STEM. He joined Magnify as a way to provide emotional support and guidance to those struggling during the COVID-19 pandemic, and beyond.