Tutorial by Examples: ad

This thread-safe version of a singleton was necessary in the early versions of .NET where static initialization was not guaranteed to be thread-safe. In more modern versions of the framework a statically initialized singleton is usually preferred because it is very easy to make implementation mistak...
The following syntax creates a delegate type with name NumberInOutDelegate, representing a method which takes an int and returns an int. public delegate int NumberInOutDelegate(int input); This can be used as follows: public static class Program { static void Main() { Number...
Named methods can be assigned to delegates with matching signatures: public static class Example { public static int AddOne(int input) { return input + 1; } } Func<int,int> addOne = Example.AddOne Example.AddOne takes an int and returns an int, its signature ...
Lambdas can be used to create anonymous methods to assign to a delegate: Func<int,int> addOne = x => x+1; Note that the explicit declaration of type is required when creating a variable this way: var addOne = x => x+1; // Does not work
One of the things that can really boost your productivity while writing the code is effectively navigating the workspace. This also means making it comfortable for the moment. It's possible to achieve this by adjusting which areas of workspaces you see. The buttons on the top of the navigation and ...
By default, the various Collection types are not thread-safe. However, it's fairly easy to make a collection thread-safe. List<String> threadSafeList = Collections.synchronizedList(new ArrayList<String>()); Set<String> threadSafeSet = Collections.synchronizedSet(new HashSet<S...
execute the following command to insert the text into a view with a focus (if it supports text input) 6.0 Send text on SDK 23+ adb shell "input keyboard text 'Paste text on Android Device'" If already connected to your device via adb: input text 'Paste text on Android Device' 6...
To start a new thread: use std::thread; fn main() { thread::spawn(move || { // The main thread will not wait for this thread to finish. That // might mean that the next println isn't even executed before the // program exits. println!("Hello from spa...
<script> $( ".inclas").datepicker({ minDate: new Date(2007, 1 - 1, 1) maxDate: new Date(2008, 1 - 1, 1) }); </script> <input type ="text" id="datepick" class="inclas">
The standard ADB configuration involves a USB connection to a physical device. If you prefer, you can switch over to TCP/IP mode, and connect ADB via WiFi instead. Not rooted device Get on the same network: Make sure your device and your computer are on the same network. Connect the...
function themeSlug_enqueue_scripts() { wp_enqueue_style( 'themeSlug-reset', get_template_directory_uri() .'/css/reset.css', '1.0.0' ); wp_enqueue_style( 'themeSlug-style', get_template_directory_uri() .'/style.css', 'themeSlug-reset', '1.0.0'); } add_action('wp_enqueue_scripts', 'themeSl...
The padding property sets the padding space on all sides of an element. The padding area is the space between the content of the element and its border. Negative values are not allowed. You can specify a side individually: padding-top padding-right padding-bottom padding-left The following...
The padding property sets the padding space on all sides of an element. The padding area is the space between the content of the element and its border. Negative values are not allowed. To save adding padding to each side individually (using padding-top, padding-left etc) can you write it as a shor...
Agents can be added to a JVM at runtime. To load an agent you will need to use the Attach API's VirtualMachine.attatch(String id). You can then load a compiled agent jar with the following method: public static void loadAgent(String agentPath) { String vmName = ManagementFactory.getRuntimeMXBe...
Normally, string literals in Haskell have a type of String (which is a type alias for [Char]). While this isn't a problem for smaller, educational programs, real-world applications often require more efficient storage such as Text or ByteString. OverloadedStrings simply changes the type of literals...
A model can provide a lot more information than just the data about an object. Let's see an example and break it down into what it is useful for: from django.db import models from django.urls import reverse from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compati...
// View to hold the CAGradientLayer. let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 320)) // Initialize gradient layer. let gradientLayer: CAGradientLayer = CAGradientLayer() // Set frame of gradient layer. gradientLayer.frame = view.bounds // Color a...
// View to hold the CAGradientLayer. let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 320)) // Initialize gradient layer. let gradientLayer: CAGradientLayer = CAGradientLayer() // Set frame of gradient layer. gradientLayer.frame = view.bounds // Color at the top of...
// View to hold the CAGradientLayer. let view: UIView = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 320)) // Initialize gradient layer. let gradientLayer: CAGradientLayer = CAGradientLayer() // Set frame of gradient layer. gradientLayer.frame = view.bounds // Color at the top of...
For instance, a computation involving commands to read and write from the prompt: First we describe the "commands" of our computation as a Functor data type {-# LANGUAGE DeriveFunctor #-} data TeletypeF next = PrintLine String next | ReadLine (String -> next) derivin...

Page 13 of 114