Tutorial by Examples: st

It is possible to create custom routing constraint which can be used inside routes to constraint a parameter to specific values or pattern. This constrain will match a typical culture/locale pattern, like en-US, de-DE, zh-CHT, zh-Hant. public class LocaleConstraint : IRouteConstraint { pri...
You can use raycasts to check if an ai can walk without falling off the edge of a level. using UnityEngine; public class Physics2dRaycast: MonoBehaviour { public LayerMask LineOfSightMask; void FixedUpdate() { RaycastHit2D hit = Physics2D.Raycas...
This example shows how to create a prepared statement with an insert statement with parameters, set values to those parameters and then executing the statement. Connection connection = ... // connection created earlier try (PreparedStatement insert = connection.prepareStatement( "i...
Example: function hello(name: string): string { return `Hello ${name}!`; } Here the syntax name: string means that the function can accept one name argument and this argument can only be string and (...): string { means that the return value can only be a string Usage: hello('StackOverfl...
You can start the mongo shell by running the following command inside your Meteor project: meteor mongo Please note: Starting the server-side database console only works while Meteor is running the application locally. After that, you can list all collections by executing the following command...
Android Studio can configure Kotlin automatically in an Android project. Install the plugin To install the Kotlin plugin, go to File > Settings > Editor > Plugins > Install JetBrains Plugin... > Kotlin > Install, then restart Android Studio when prompted. Configure a project Cr...
In order to include plots created with matplotlib in TeX documents, they should be saved as pdf or eps files. In this way, any text in the plot (including TeX formulae) is rendered as text in the final document. import matplotlib.pyplot as plt plt.rc(usetex=True) x = range(0, 10) y = [t**2 for t...
Dart has a robust async library, with Future, Stream, and more. However, sometimes you might run into an asynchronous API that uses callbacks instead of Futures. To bridge the gap between callbacks and Futures, Dart offers the Completer class. You can use a Completer to convert a callback into a Fut...
GNU gettext is an extension within PHP that must be included at the php.ini: extension=php_gettext.dll #Windows extension=gettext.so #Linux The gettext functions implement an NLS (Native Language Support) API which can be used to internationalize your PHP applications. Translating strings ...
A linked list is a linear collection of data elements, called nodes, which are linked to other node(s) by means of a "pointer." Below is a singly linked list with a head reference. ┌─────────┬─────────┐ ┌─────────┬─────────┐ HEAD ──▶│ data │"pointer"│──▶...
Mac OSX Using Homebrew: brew install haskell-stack
File structure A simple project has the following files included in it: ➜ helloworld ls LICENSE Setup.hs helloworld.cabal src stack.yaml In the folder src there is a file named Main.hs. This is the "starting point" of the helloworld project. By default...
Stackage is a repository for Haskell packages. We can add these packages to a stack project. Adding lens to a project. In a stack project, there is a file called stack.yaml. In stack.yaml there is a segment that looks like: resolver: lts-6.8 Stackage keeps a list of packages for every revision...
When building a webserver with Express it's often required to serve a combination of dynamic content and static files. For example, you may have index.html and script.js which are static files kept in the file system. It is common to use folder named 'public' to have static files. In this case th...
This program copies a file using readable and a writable stream with the pipe() function provided by the stream class // require the file system module var fs = require('fs'); /* Create readable stream to file in current directory named 'node.txt' Use utf8 encoding Read the data...
I/O in node is asynchronous, so interacting with the disk and network involves passing callbacks to functions. You might be tempted to write code that serves up a file from disk like this: var http = require('http'); var fs = require('fs'); var server = http.createServer(function (req, res) { ...
Hstore columns can be useful to store settings. They are available in PostgreSQL databases after you enabled the extension. class CreatePages < ActiveRecord::Migration[5.0] def change create_table :pages do |t| enable_extension 'hstore' unless extension_enabled?('hstore') t...
F# allows functions to be added as "members" to types when they are defined (for example, Record Types). However F# also allows new instance members to be added to existing types - even ones declared elsewhere and in other .net languages. The following example adds a new instance method D...
F# allow existing types to be extended with new static functions. type System.String with static member EqualsCaseInsensitive (a, b) = String.Equals(a, b, StringComparison.OrdinalIgnoreCase) This new function can be invoked like this: let x = String.EqualsCaseInsensitive("abc", &...
Modules can be used to add new functions to existing Modules and Types. namespace FSharp.Collections module List = let pair item1 item2 = [ item1; item2 ] The new function can then be called as if it was an original member of List. open FSharp.Collections module Testing = le...

Page 104 of 369