Tutorial by Examples: ada

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...
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...
It is sometimes required for a process to concurrently write and read the same "data". The ReadWriteLock interface, and its ReentrantReadWriteLock implementation allows for an access pattern that can be described as follow : There can be any number of concurrent readers of the data. If...
This time we are going to declare a class decorator that will add some metadata to a class when we applied to it: function addMetadata(target: any) { // Add some metadata target.__customMetadata = { someKey: "someValue" }; // Return target ret...
There are many ways to return a Date from a DateTime object SELECT CONVERT(Date, GETDATE()) SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) returns 2016-07-21 00:00:00.000 SELECT CAST(GETDATE() AS DATE) SELECT CONVERT(CHAR(10),GETDATE(),111) SELECT FORMAT(GETDATE(), 'yyyy-MM-dd') Note th...
Iterator methods can be broken into two distinct groups: Adapters Adapters take an iterator and return another iterator // Iterator Adapter // | | let my_map = (1..6).map(|x| x * x); println!("{:?}", my_map); Output Map { iter: 1..6 } Note that the v...
The most common way is to apply the extension via Config. Example: # File: mysite/_config/config.yml Member: extensions: - MyMemberExtension The extensions config variable is of type "array", so you can add multiple extensions like this: # File: mysite/_config/config.yml Mem...
Before starting with the example I'd recommend to create a Singleton with a delegate class member so you could achieve a use case of uploading a file in the background and let the user keep using your app while the files are being uploaded even when the app is the background. Let's start, first, we...
package com.example.xml.adapters; import javax.xml.bind.annotation.adapters.XmlAdapter; public class StringTrimAdapter extends XmlAdapter<String, String> { @Override public String unmarshal(String v) throws Exception { if (v == null) return null; ...
It is illegal to access a reference to an object that has gone out of scope or been otherwise destroyed. Such a reference is said to be dangling since it no longer refers to a valid object. #include <iostream> int& getX() { int x = 42; return x; } int main() { int& r...
// Get the reference to your ListView ListView listResults = (ListView) findViewById(R.id.listResults); // Set its adapter listResults.setAdapter(adapter); // Enable filtering in ListView listResults.setTextFilterEnabled(true); // Prepare your adapter for filtering adapter.setFilter...
NSLog(@"%s %d %s, yourVariable: %@", __FILE__, __LINE__, __PRETTY_FUNCTION__, yourVariable); Will log the file, line number and function data along with any variables you want to log. This can make the log lines much longer, particularly with verbose file and method names, however it ca...
Get all documents in the collection 'myCollection' and print them to the console. const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://localhost:27017/test'; MongoClient.connect(url, function (err, db) { if (err) throw new Error(err); var cursor = db.collection('my...
Darken #demo { @refcolor: #f0b9b8; background: @refcolor; border: 1px solid darken(@refcolor, 25%); } The above code makes use of the darken() function to set the border color as a shade that is 25% darker than the reference color (which is also the background color). Less compiler ca...
By default the ArrayAdapter class creates a view for each array item by calling toString() on each item and placing the contents in a TextView. To create a complex view for each item (for example, if you want an ImageView for each array item), extend the ArrayAdapter class and override the getView(...
Your DocumentDB database can be created by using the CreateDatabaseAsync method of the DocumentClient class. A database is the logical container of JSON document storage partitioned across collections. using System.Net; using System.Threading.Tasks; using Microsoft.Azure.Documents; using Microso...
Deleting a database will remove the database and all children resources (collections, documents, etc.). await this.client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(databaseName));
A DataFrame can be created from a list of dictionaries. Keys are used as column names. import pandas as pd L = [{'Name': 'John', 'Last Name': 'Smith'}, {'Name': 'Mary', 'Last Name': 'Wood'}] pd.DataFrame(L) # Output: Last Name Name # 0 Smith John # 1 Wood Mary Missin...
This example shows how to update a UI component from a background thread by using a SynchronizationContext void Button_Click(object sender, EventArgs args) { SynchronizationContext context = SynchronizationContext.Current; Task.Run(() => { for(int i = 0; i < 10; i++) ...
Apple introduced ATS with iOS 9 as a new security feature to improve privacy and security between apps and web services. ATS by default fails all non HTTPS requests. While this can be really nice for production environments, it can be a nuisance during testing. ATS is configured in the target's Inf...

Page 6 of 12