Tutorial by Examples: al

A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. Set have its implementation in various classes like HashSet, TreeSet, LinkedHashSet. For example: HashSet: Set<T> set = new HashSet<T>(); Here T can be String, Integer or any ...
Java and most other languages store negative integral numbers in a representation called 2's complement notation. For a unique binary representation of a data type using n bits, values are encoded like this: The least significant n-1 bits store a positive integral number x in integral representati...
If we try to change an object on the UI thread from a different thread we will get a cross-thread operation exception: Private Sub Button_Click(sender As Object, e As EventArgs) Handles MyButton.Click ' Cross thread-operation exception as the assignment is executed on a different thread '...
Random and ThreadLocalRandom are good enough for everyday use, but they have a big problem: They are based on a linear congruential generator, an algorithm whose output can be predicted rather easily. Thus, these two classes are not suitable for cryptographic uses (such as key generation). One can ...
Using sw As New System.IO.StreamWriter("path\to\file.txt") sw.WriteLine("Hello world") End Using The use of a Using block is recommended good practice when using an object that Implements IDisposable
Conceptually, integrate 3rd party REST APIs can be as simple as adding the http package and making a call to the external endpoint. meteor add http HTTP.get('http://foo.net/api/bar/');
Having your scripts call Raycast directly may lead to problems if you need to change the collision matrices in the future, as you'll have to track down every LayerMask field to accommodate the changes. Depending on the size of your project, this may become a huge undertaking. Encapsulating Raycast ...
To uninstall Node.js on Windows, use Add or Remove Programs like this: Open Add or Remove Programs from the start menu. Search for Node.js. Windows 10: Click Node.js. Click Uninstall. Click the new Uninstall button. Windows 7-8.1: Click the Uninstall button under Node.js.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <circle r="30" cx="100" cy="100" fill="rgb(255, 0, 0)" stroke="rgb(0, 255, 0)" /> <rect x="200" y="200" w...
You update all rows in table by simply providing a column_name = value: UPDATE person SET planet = 'Earth';
UPDATE person SET state = 'NY' WHERE city = 'New York';
Everything in .NET is an object, hence every type has ToString() method defined in Object class which can be overridden. Default implementation of this method just returns the name of the type: public class Foo { } var foo = new Foo(); Console.WriteLine(foo); // outputs Foo ToString() is i...
Say we are working on a class representing a Person by their first and last names. We have created a basic class to do this and implemented proper equals and hashCode methods. public class Person { private final String lastName; //invariant - nonnull private final String firstName; //in...
Variables can be assigned globally from any environment using <<-. bar() can now access y. bar <- function() { z <- x + y return(z) } foo <- function() { y <<- 3 z <- bar() return(z) } foo() 4 Global assignment is highly discourag...
C-style bit-manipulation x = -1; // -1 == 1111 1111 ... 1111b (See here for an explanation of why this works and is actually the best approach.) Using std::bitset std::bitset<10> x; x.set(); // Sets all bits to '1'
In order to check whether a value is NaN, isnull() or notnull() functions can be used. In [1]: import numpy as np In [2]: import pandas as pd In [3]: ser = pd.Series([1, 2, np.nan, 4]) In [4]: pd.isnull(ser) Out[4]: 0 False 1 False 2 True 3 False dtype: bool Note that n...
Installing the haystack package pip install django-haystack Configuration Add haystack to your project's INSTALLED_APPS inside of your settings.py file: # settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', # Put...
The awk language does not directly support variables local to functions. It is however easy emulate them by adding extra arguments to functions. It is traditional to prefix these variables by a _ to indicate that they are not actual parameters. We illustrate this technique with the definition of a...
// Checks a string to see if it is a palindrome bool function IsPalindrome(string input) { if (input.size() <= 1) { return true; } else if (input[0] == input[input.size() - 1]) { return IsPalindrome(input.substr(1,input.size() - 2)); } else { r...
Custom events usually need custom event arguments containing information about the event. For example MouseEventArgs which is used by mouse events like MouseDown or MouseUp events, contains information about Location or Buttons which used to generate the event. When creating new events, to create a...

Page 82 of 269