Tutorial by Examples: c

We have a sample Spring boot application which stores user data in MongoDB and we are using Rest services to retrieve data First there is a domain class i.e. POJO @Document public class User{ @Id private String id; private String name; } A corresponding repository based on ...
Oracle supports DATE (includes time to the nearest second) and TIMESTAMP (includes time to fractions of a second) datatypes, which allow arithmetic (addition and subtraction) natively. For example: To get the next day: select to_char(sysdate + 1, 'YYYY-MM-DD') as tomorrow from dual; To get the ...
The publisher-subscriber is a familiar concept given the rise of YouTube, Facebook and other social media services. The basic concept is that there is a Publisher who generates content and a Subscriber who consumes content. Whenever the Publisher generates content, each Subscriber is notified. Subsc...
import pandas as pd import io temp=u"""index; header1; header2; header3 1; str_data; 12; 1.4 3; str_data; 22; 42.33 4; str_data; 2; 3.44 2; str_data; 43; 43.34 7; str_data; 25; 23.32""" #after testing replace io.StringIO(temp) to filename df = pd.read_csv(io....
Analog to get a collection for a Stream by collect() an array can be obtained by the Stream.toArray() method: List<String> fruits = Arrays.asList("apple", "banana", "pear", "kiwi", "orange"); String[] filteredFruits = fruits.stream() ....
A common pitfall of child classes is that, if your parent and child both contain a constructor(__construct()) method, only the child class constructor will run. There may be occasions where you need to run the parent __construct() method from it's child. If you need to do that, then you will need to...
To support a given application, you often create a new role and database to match. The shell commands to run would be these: $ createuser -P blogger Enter password for the new role: ******** Enter it again: ******** $ createdb -O blogger blogger This assumes that pg_hba.conf has been prope...
If we know the length of the string, we can use a for loop to iterate over its characters: char * string = "hello world"; /* This 11 chars long, excluding the 0-terminator. */ size_t i = 0; for (; i < 11; i++) { printf("%c\n", string[i]); /* Print each character of ...
In C, a string is a sequence of characters that is terminated by a null character ('\0'). We can create strings using string literals, which are sequences of characters surrounded by double quotation marks; for example, take the string literal "hello world". String literals are automatica...
An array of strings can mean a couple of things: An array whose elements are char *s An array whose elements are arrays of chars We can create an array of character pointers like so: char * string_array[] = { "foo", "bar", "baz" }; Remember: w...
A minimal CMake project file that uses Qt5 can be: cmake_minimum_required(VERSION 2.8.11) project(myproject) find_package(Qt5 5.7.0 REQUIRED COMPONENTS Core ) set(CMAKE_AUTOMOC ON) add_executable(${PROJECT_NAME} main.cpp ) target_link_libraries(${PROJECT_NAME} Qt5::C...
In the Project.pro file we add : CONFIG += sql in MainWindow.h we write : #include <QMainWindow> #include <QSql> #include <QDebug> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget...
Layout Unity basic editor will look like below. Basic functionalities of some default windows/tabs are described in the image. Linux Layout There is a little difference in menu layout of linux version, like the screenshot below, Basic Usage Create an empty GameObject by right clicking in th...
Using the default constructor T variable = Activator.CreateInstance(typeof(T)); Using parameterized constructor T variable = Activator.CreateInstance(typeof(T), arg1, arg2);
Occasionally you'd want to catch an exception and throw it from a different thread or method while preserving the original exception stack. This can be done with ExceptionDispatchInfo: using System.Runtime.ExceptionServices; void Main() { ExceptionDispatchInfo capturedException = null; ...
Whenever a Python script is invoked from the command line, the user may supply additional command line arguments which will be passed on to the script. These arguments will be available to the programmer from the system variable sys.argv ("argv" is a traditional name used in most programmi...
You can count the number of rows: SELECT count(*) TotalRows FROM employees; TotalRows4 Or count the employees per department: SELECT DepartmentId, count(*) NumEmployees FROM employees GROUP BY DepartmentId; DepartmentIdNumEmployees1321 You can count over a column/expression with the eff...
To install Eclipse RCP follow the steps : Download Eclipse RCP/RAP version from Eclipse.org Eclipse RCP/RAP project downloading URL
The @Html.AntiForgeryToken() helper method protects against cross-site request forgery (or CSRF) attacks. It can be used by simply using the Html.AntiForgeryToken() helper within one of your existing forms and decorating its corresponding Controller Action with the [ValidateAntiForgeryToken] attri...
Good unit tests are independent, but code often has dependencies. We use various kinds of test doubles to remove the dependencies for testing. One of the simplest test doubles is a stub. This is a function with a hard-coded return value called in place of the real-world dependency. // Test that ...

Page 152 of 826