Tutorial by Examples

You can set the opacity to a certain UIColor without creating a new one using the init(red:_,green:_,blue:_,alpha:_) initializer. Swift let colorWithAlpha = UIColor.redColor().colorWithAlphaComponent(0.1) Swift 3 //In Swift Latest Version _ colorWithAlpha = UIColor.red.withAlphaComponent(0.1)...
The following code is based on the examples provided by the documentation on std::net::TcpListener. This server application will listen to incoming requests and send back all incoming data, thus acting as an "echo" server. The client application will send a small message and expect a reply...
The following (trivial) example function simply returns the constant INT value 12. DELIMITER || CREATE FUNCTION functionname() RETURNS INT BEGIN RETURN 12; END; || DELIMITER ; The first line defines what the delimiter character(DELIMITER ||) is to be changed to, this is needed to be s...
This code example creates a TCP client, sends "Hello World" over the socket connection, and then writes the server response to the console before closing the connection. // Declare Variables string host = "stackoverflow.com"; int port = 9999; int timeout = 5000; // Create ...
public async Task<Product> GetProductAsync(string productId) { using (_db) { return await _db.QueryFirstOrDefaultAsync<Product>("usp_GetProduct", new { id = productId }, commandType: CommandType.StoredProcedure); } }
With this example, we will see how to load a color image from disk and display it using OpenCV's built-in functions. We can use the C/C++, Python or Java bindings to accomplish this. In C++: #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <iostream> usi...
prop_evenNumberPlusOneIsOdd :: Integer -> Property prop_evenNumberPlusOneIsOdd x = even x ==> odd (x + 1) If you want to check that a property holds given that a precondition holds, you can use the ==> operator. Note that if it's very unlikely for arbitrary inputs to match the precondit...
A try/catch block is used to catch exceptions. The code in the try section is the code that may throw an exception, and the code in the catch clause(s) handles the exception. #include <iostream> #include <string> #include <stdexcept> int main() { std::string str("foo&...
One can iterate over a list using ~{ and ~} directives. CL-USER> (format t "~{~a, ~}~%" '(1 2 3 4 5)) 1, 2, 3, 4, 5, ~^ can be used to escape if there are no more elements left. CL-USER> (format t "~{~a~^, ~}~%" '(1 2 3 4 5)) 1, 2, 3, 4, 5 A numeric argument can ...
Google maintains documentation on getting started here: https://cloud.google.com/storage/docs/quickstart-console Getting ready to use GCS: Create a Google Cloud project, if you don't have one already. Enable billing for your project to allow buckets to be created. (Optional) Install the Google...
You can make an UILabel with a dynamic height using auto layout. You need to set the numberOfLines to zero (0), and add a minimal height by setting up a constraints with a relation of type .GreaterThanOrEqual on the .Height attribute iOS 6 Swift label.numberOfLines = 0 let heightConstraint = ...
Assumptions: An Oracle JDK has been installed. The JDK was installed to the default directory. Setup steps Open Windows Explorer. In the navigation pane on the left right click on This PC (or Computer for older Windows versions). There is a shorter way without using the explorer in...
Array iteration comes in two flavors, foreach and the classic for-loop: a=(1 2 3 4) # foreach loop for y in "${a[@]}"; do # act on $y echo "$y" done # classic for-loop for ((idx=0; idx < ${#a[@]}; ++idx)); do # act on ${a[$idx]} echo "${a[$idx]}&...
The recommended way (Since ES5) is to use Array.prototype.find: let people = [ { name: "bob" }, { name: "john" } ]; let bob = people.find(person => person.name === "bob"); // Or, more verbose let bob = people.find(function(person) { return person.na...
Ruby extends the standard group syntax (...) with a named group, (?<name>...). This allows for extraction by name instead of having to count how many groups you have. name_reg = /h(i|ello), my name is (?<name>.*)/i #i means case insensitive name_input = "Hi, my name is Zaphod Be...
Common mobile-optimized sites use the <meta name="viewport"> tag like this: <meta name="viewport" content="width=device-width, initial-scale=1"> The viewport element gives the browser instructions on how to control the page's dimensions and scaling based...
Assembly language is a human readable form of machine language or machine code which is the actual sequence of bits and bytes on which the processor logic operates. It is generally easier for humans to read and program in mnemonics than binary, octal or hex, so humans typically write code in assemb...
Syntax {condition-to-evaluate} ? {statement-executed-on-true} : {statement-executed-on-false} As shown in the syntax, the Conditional Operator (also known as the Ternary Operator1) uses the ? (question mark) and : (colon) characters to enable a conditional expression of two possible outcomes. It c...
To make express web application modular use router factories: Module: // greet.js const express = require('express'); module.exports = function(options = {}) { // Router factory const router = express.Router(); router.get('/greet', (req, res, next) => { res.end(options....
You can use the reversed function which returns an iterator to the reversed list: In [3]: rev = reversed(numbers) In [4]: rev Out[4]: [9, 8, 7, 6, 5, 4, 3, 2, 1] Note that the list "numbers" remains unchanged by this operation, and remains in the same order it was originally. To r...

Page 167 of 1336