Tutorial by Examples

If everything whas been set up correctly, the following snippet will show a window titled "SFML works!" with a green circle: #include <SFML/Graphics.hpp> int main() { sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!"); sf::CircleShape shape(100.f...
Matplotlib includes the image module for image manipulation import matplotlib.image as mpimg import matplotlib.pyplot as plt Images are read from file (.png only) with the imread function: img = mpimg.imread('my_image.png') and they are rendered by the imshow function: plt.imshow(img) L...
As a developer, you frequently find yourself dealing with strings that are not created by your own code. These will often be supplied by third party libraries, external systems, or even end users. Validating strings of unclear provenance is considered to be one of the hallmarks of defensive program...
module.exports.routes = { 'GET /foo': 'FooController.index', 'GET /foo/new': 'FooController.new', 'POST /foo/create': 'FooController.create', 'GET /foo/:id/edit': 'FooController.edit', 'PUT /foo/:id/update': 'FooController.update', 'GET /foo/:id': 'FooController.show', ...
module.exports.routes = { '/foo': '/bar', 'GET /google': 'http://www.google.com' };
module.exports.routes = { // This function will be executed for all http verbs on all urls 'all /*', function (req, res, next) { // Expose the function `fooBar` to all views (via the locals object) res.locals.fooBar = function (arg1) { return 'foobar' + arg1; }; }, };...
module.exports.routes = { 'GET /foo/*': { fn: function(req, res) { res.send("FOO!"); }, skipAssets: true }, };
Pattern synonyms are abstractions of patterns similar to how functions are abstractions of expressions. For this example, let's look at the interface Data.Sequence exposes, and let's see how it can be improved with pattern synonyms. The Seq type is a data type that, internally, uses a complicated r...
A real world example using a scientific experiment where certain routines are performed on different types of tissue. The class contains two functions by default to get the tissue or routine separately. In a later version we have then adapted it using a new class to add a function that gets both. Th...
Visitor pattern allows you to add new operations or methods to a set of classes without modifying the structure of those classes. This pattern is especially useful when you want to centralise a particular operation on an object without extending the object Or without modifying the object. UML diag...
Lets assume that in your current codebase, there exists MyLogger interface like so: interface MyLogger { void logMessage(String message); void logException(Throwable exception); } Lets say that you've created a few concrete implementations of these, such as MyFileLogger and MyConsol...
The yield keyword allows lazy-evaluation of the collection. Forcibly loading the whole collection into memory is called eager evaluation. The following code shows this: IEnumerable<int> myMethod() { for(int i=0; i <= 8675309; i++) { yield return i; } } ... // ...
Consider using Extension Methods as Functions which wrap other code, here's a great example that uses both a static method and and extension method to wrap the Try Catch construct. Make your code Bullet Proof... using System; using System.Diagnostics; namespace Samples { /// <summary&g...
Database connections are set up using the CF Administrator tool. See Database Connections for how to connect a datasource. To execute queries all you need is the <cfquery> tag. The <cfquery> tag connects to and opens the database for you, all you need to do is supply it with the name of...
Many database configurations require authentication (in the form of a username and password) before you can query the database. You can supply these using the username and password attributes. Note: the username and password can also be configured against the datasource in the ColdFusion Administra...
A cached query is a query that has its results stored in the server's memory. The results are stored when the query is first run. From then on, whenever that query is requested again, ColdFusion will retrieve the results from memory. You can cache a query using the cachedAfter attribute. If the que...
You can limit the number of rows to be returned by using the maxrows attribute. <cfquery datasource="Entertainment" maxrows="50"> select * from Movies </cfquery>
You can set a timeout limit using the timeout attribute. This can be useful in preventing requests running far longer than they should and impacting on the whole application as a result. The timeout attribute sets the maximum number of seconds that each action of a query is allowed to execute befor...
create destination with <a id="destinationLinkName"></a> link to destination [link text](#destinationLinkName)
In order to get information about the URI the user agent used to access your resource, you can use the @Context parameter annotation with a UriInfo parameter. The UriInfo object has a few methods that can be used to get different parts of the URI. //server is running on https://localhost:8080, // ...

Page 621 of 1336