Tutorial by Examples: c

Found under Terminal > Preferences General In the general tab, you can chose which profile is opened when you start terminal. You can set "Shells open with" to chose which directory terminal opens to, or specify a command to run each time you open a new terminal window or tab. Profil...
Class under test: public class GreetingsService { // class to be tested in isolation private UserService userService; public GreetingsService(UserService userService) { this.userService = userService; } public String getGreetings(int userId, LocalTime time) { // the...
@Spy annotation (or method) can be used to partially mock an object. This is useful when you want to partially mock behavior of a class. E.g. Assume that you have a class that uses two different services and and you want to mock only one of them and use the actual implementation of the other service...
There are already implemented forms within Django to change the user password, one example being SetPasswordForm. There aren't, however, forms to modify the user e-mail and I think the following example is important to understand how to use a form correctly. The following example performs the foll...
In your class that is under test, you may have some private fields that are not accessible even through constructor. In such cases you can use reflection to set such properties. This is a snippet from such JUnit test. @InjectMocks private GreetingsService greetingsService = new GreetingsService();...
This is a sample HTTP client class based on Event extension. The class allows to schedule a number of HTTP requests, then run them asynchronously. http-client.php <?php class MyHttpClient { /// @var EventBase protected $base; /// @var array Instances of EventHttpConnection protect...
In [1]: import pandas as pd import numpy as np In [2]: df = pd.DataFrame(np.random.choice(['foo','bar','baz'], size=(100000,3))) df = df.apply(lambda col: col.astype('category')) In [3]: df.head() Out[3]: 0 1 2 0 bar foo baz 1 baz bar baz 2 foo foo b...
As an example, lets us look at a Wordpress container The Dockerfile begins with FROM php:5.6-apache so we go to the Dockerfile abovementioned https://github.com/docker-library/php/blob/master/5.6/apache/Dockerfile and we find FROM debian:jessie So this means that we a security patch appears f...
As the last layer created by docker build -t mytag . showed ---> Running in d9a42e53eb5a You just launch the last created image with a shell and launch the command, and you will have a more clear error message docker run -it d9a42e53eb5a /bin/bash (this assumes /bin/bash is available, it ma...
When displaying labels on contours Matlab doesn't allow you to control the format of the numbers, for example to change to scientific notation. The individual text objects are normal text objects but how you get them is undocumented. You access them from the TextPrims property of the contour handl...
This is a sample HTTP client based on Ev extension. Ev extension implements a simple yet powerful general purpose event loop. It doesn't provide network-specific watchers, but its I/O watcher can be used for asynchronous processing of sockets. The following code shows how HTTP requests can be sche...
The ApplicationData.Current.LocalFolder api allows us to get access to the application cache : var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("myFile.dat", CreationCollisionOption.ReplaceExisting); The FileIO class contains a set of utility methods to easily add d...
Anonymous pipes, or simply pipes, are kernel-managed objects exposed to processes as a pair of file descriptors, one for the read terminus and one for the write terminus. They are created via the pipe(2) function: int pipefds[2]; int result; result = pipe(pipefds); On success, pipe() record...
File descriptors and FILE objects are per-process resources that cannot themselves be exchanged between processes via ordinary I/O. Therefore, in order for two distinct processes to communicate via an anonymous pipe, one or both participating processes must inherit an open pipe end from the process...
Connecting two child processes via a pipe is performed by connecting each of two children to the parent via different ends of the same pipe. Usually, the parent will not be party to the conversation between the children, so it closes its copies of both pipe ends. int demo() { int pipefds[2]; ...
A shell-style pipeline consists of two or more processes, each one with its standard output connected to the standard input of the next. The output-to-input connections are built on pipes. To establish a pipeline-like set of processes, one creates pipe-connected child processes as described in ano...
cURL can keep cookies received in responses for use with subsequent requests. For simple session cookie handling in memory, this is achieved with a single line of code: curl_setopt($ch, CURLOPT_COOKIEFILE, ""); In cases where you are required to keep cookies after the cURL handle is de...
Example of creating an empty HashTable: $hashTable = @{} Example of creating a HashTable with data: $hashTable = @{ Name1 = 'Value' Name2 = 'Value' Name3 = 'Value3' }
An example of defining a hash table and accessing a value by the key $hashTable = @{ Key1 = 'Value1' Key2 = 'Value2' } $hashTable.Key1 #output Value1 An example of accessing a key with invalid characters for a property name: $hashTable = @{ 'Key 1' = 'Value3' Key2 = 'Val...
The cluster library contains the ruspini data - a standard set of data for illustrating cluster analysis. library(cluster) ## to get the ruspini data plot(ruspini, asp=1, pch=20) ## take a look at the data hclust expects a distance matrix, not the original data. We ...

Page 651 of 826