Tutorial by Examples

Yield true on the stack if currentpoint executes successfully, or false if it signals a /nocurrentpoint error. {currentpoint pop pop} stopped not % bool
The sequence for an error is usually: error is triggered by looking up the error name in errordict and executing this procedure. the errordict procedure calls signalerror, passing it the error name. signalerror takes snapshots of the stacks, saving the snapshots in $error, and then calls stop. ...
Most of the tools are standardized with the exception of the name of the operator to throw an error. In Adobe interpreters, it is called .error. In ghostscript, it is called signalerror. So with this line you can use signalerror in postscript code for Adobe interpreters or ghostscript or xpost. /.e...
Since the final action of the default error handler is to call stop, you can catch errors from operators by enclosing code in a { ... } stopped construct. { 0 array 1 get } stopped { $error /errorname get = } if will print "rangecheck", the error signaled by get when t...
This snippet implements a procedure which behaves like a postscript looping operator. If the user proc calls exit, it catches the invalidexit error to fix the dictstack for the end at the end. Any other error except invalidexit is re-thrown by calling stop. % array n proc . - % Like `forall` but...
The documentation for docker events provides details, but when debugging it may be useful to launch a container and be notified immediately of any related event: docker run... & docker events --filter 'container=$(docker ps -lq)' In docker ps -lq, the l stands for last, and the q for quiet. Th...
TextFile is the default file format, unless the configuration parameter hive.default.fileformat has a different setting. We can create a table on hive using the field names in our delimited text file. Lets say for example, our csv file contains three fields (id, name, salary) and we want to create ...
Tests are an excellent way to ensure stable, bug-free applications. They serve as an interactive documentation and allow to modify code without fear to break functionality. D provides a convenient and native syntax for unittest block as part of the D language. Anywhere in a D module unittest blocks ...
If -unittest flag is passed to the D compiler, it will run all unittest blocks. Often it is useful to let the compiler generate a stubbed main function. Using the compile & run wrapper rdmd, testing your D program gets as easy as: rdmd -main -unittest yourcode.d Of course you can also split ...
For templated code it is often useful to verify that for function attributes (e.g. @nogc are inferred correctly. To ensure this for a specific test and thus type the entire unittest can be annotated @safe @nogc pure nothrow unittest { import std.math; assert(exp(0) == 1); assert(l...
In the scenario that a controller throws an exception, we can define exception handler methods to build and return specific responses. It is important to note that the defined exception handlers within the given controller will only apply to exceptions that occur within that controller. @Controller...
We're going to build an application that stores POJOs in a database. The application uses Spring Data JPA to store and retrieve data in a relational database. Its most compelling feature is the ability to create repository implementations automatically, at runtime, from a repository interface. Main...
Hash function h() is an arbitrary function which mapped data x ∈ X of arbitrary size to value y ∈ Y of fixed size: y = h(x). Good hash functions have follows restrictions: hash functions behave likes uniform distribution hash functions is deterministic. h(x) should always return the same v...
The replica set is a group of mongod instances that maintain the same data set. This example shows how to configure a replica set with three instances on the same server. Creating data folders mkdir /srv/mongodb/data/rs0-0 mkdir /srv/mongodb/data/rs0-1 mkdir /srv/mongodb/data/rs0-2 Starting ...
We add three records to our collection test as: > db.test.insert({"key":"value1","key2":"Val2","key3":"val3"}) WriteResult({ "nInserted" : 1 }) > db.test.insert({"key":"value2","key2":"V...
Defining the list of Ints trait IntList { ... } class Cons(val head: Int, val tail: IntList) extends IntList { ... } class Nil extends IntList { ... } but what if we need to define the list of Boolean, Double etc? Defining generic list trait List[T] { def isEmpty: Boolean def head:...
Loading custom fonts can be lead to a bad performance. I highly recommend to use this little helper which saves/loads your already used fonts into a Hashtable. public class TypefaceUtils { private static final Hashtable<String, Typeface> sTypeFaces = new Hashtable<>(); /** * Get...
Component definition ko.components.register('progress-bar', { viewModel: function(params) { var that = this; // progress is a numeric value between 0 and 100 that.progress = params.progress; that.progressPercentual = ko.computed...
There is no direct equivalent binding in KnockoutJS. However, since hiding is just the opposite of showing, we can just invert the example for Knockout's ngShow equivalent. <p ng-hide="SomeScopeProperty">This is conditionally shown.</p> KnockoutJS equivalent: <p data-bi...
AngularJS code for dynamic classes: <p ng-class="{ highlighted: scopeVariableX, 'has-error': scopeVariableY }">Text.</p> KnockoutJS equivalent: <p data-bind="css: { highlighted: scopeObservableX, 'has-error': scopeObservableY }">Text.</p>

Page 853 of 1336