Tutorial by Examples: and

Date and LocalDate objects cannot be exactly converted between each other since a Date object represents both a specific day and time, while a LocalDate object does not contain time or timezone information. However, it can be useful to convert between the two if you only care about the actual date i...
iex(1)> a = 10 10 iex(2)> b = 20 20 iex(3)> a + b 30 You can get a specific row passing the index of the row: iex(4)> v(3) 30 You can also specify an index relative to the current row: iex(5)> v(-1) # Retrieves value of row (5-1) -> 4 30 iex(6)> v(-5) # Retrieves...
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...
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...
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...
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...
After receiving the arguments, you can print them as follows: int main(int argc, char **argv) { for (int i = 1; i < argc; i++) { printf("Argument %d: [%s]\n", i, argv[i]); } } Notes The argv parameter can be also defined as char *argv[]. argv[0] may co...
Assuming that bar is an alias for someCommand -flag1. Type bar on the command line and then press Ctrl+alt+e you'll get someCommand -flag1 where bar was standing.
Have a table NameAgeCityBob10ParisMat20BerlinMary24Prague select Name from table where Age>10 AND City='Prague' Gives NameMary select Name from table where Age=10 OR City='Prague' Gives NameBobMary
On the server, you can create a publication like this. this.userId is the id of the user who is currently logged in. If no user is logged in, you might want to throw an error and respond to it. import Secrets from '/imports/collections/Secrets'; Meteor.publish('protected_data', function () { ...
The simplest use case is using the subprocess.call function. It accepts a list as the first argument. The first item in the list should be the external application you want to call. The other items in the list are arguments that will be passed to that application. subprocess.call([r'C:\path\to\a...
Lambda expressions can be used to handle events, which is useful when: The handler is short. The handler never needs to be unsubscribed. A good situation in which a lambda event handler might be used is given below: smtpClient.SendCompleted += (sender, args) => Console.WriteLine("Ema...
Django manger is an interface through which the django model queries the database. The objects field used in most django queries is actually the default manager created for us by django (this is only created if we don't define custom managers). Why would we define a custom manager/queryset? To avo...
package main import ( "log" "text/template" "os" ) type Person struct{ MyName string MyAge int } var myTempContents string= ` This person's name is : {{.MyName}} And he is {{.MyAge}} years old. ` func main() { t,err := temp...
To assign variables from the command-line, -v can be used: $ awk -v myvar="hello" 'BEGIN {print myvar}' hello Note that there are no spaces around the equal sign. This allows to use shell variables: $ shell_var="hello" $ awk -v myvar="$shell_var" 'BEGIN {print m...
In some cases you may want to wrap a synchronous operation inside a promise to prevent repetition in code branches. Take this example: if (result) { // if we already have a result processResult(result); // process it } else { fetchResult().then(processResult); } The synchronous and async...
You can use any element as an handle to drag another element around: <script> $(function() { $( "#draggable" ).draggable({ handle: ".handle" }); }); </script> <div id="draggable"> <span class="handle"&...
__call() and __callStatic() are called when somebody is calling nonexistent object method in object or static context. class Foo { /** * This method will be called when somebody will try to invoke a method in object * context, which does not exist, like: * * $foo->...
__sleep and __wakeup are methods that are related to the serialization process. serialize function checks if a class has a __sleep method. If so, it will be executed before any serialization. __sleep is supposed to return an array of the names of all variables of an object that should be serializ...
SharedPreferences Manager (Singleton) class to read and write all types of data. import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import com.google.gson.Gson; import java.lang.reflect.Type; /** * Singleton Class for accessing SharedPref...

Page 20 of 153