Tutorial by Examples: f

KafkaConsumers can commit offsets automatically in the background (configuration parameter enable.auto.commit = true) what is the default setting. Those auto commits are done within poll() (which is typically called in a loop). How frequently offsets should be committed, can be configured via auto.c...
There are multiple strategies to read a topic from its beginning. To explain those, we first need to understand what happens at consumer startup. On startup of a consumer, the following happens: join the configured consumer group, which triggers a rebalance and assigns partitions to the consumer ...
The CLOS MOP provides the hook slot-value-using-class, that is called when a slot is value is accessed, read or modified. Because we only care for modifications in this case we define a method for (setf slot-value-using-class). (defclass document () ((id :reader id :documentation "A hash co...
Classification in Machine Learning is the problem that identifies to which set of categories does a new observation belong. Classification falls under the category of Supervised Machine Learning. Any algorithm that implements classification is known as classifier The classifiers supported in P...
This topic explains the concept of an object reference; it is targeted at people who are new to programming in Java. You should already be familiar with some terms and meanings: class definition, main method, object instance, and the calling of methods "on" an object, and passing parameter...
The Java language allows you to use new to create instances Integer, Boolean and so on, but it is generally a bad idea. It is better to either use autoboxing (Java 5 and later) or the valueOf method. Integer i1 = new Integer(1); // BAD Integer i2 = 2; // BEST (autoboxing)...
Using new String(String) to duplicate a string is inefficient and almost always unnecessary. String objects are immutable, so there is no need to copy them to protect against changes. In some older versions of Java, String objects can share backing arrays with other String objects. In those ver...
A SELECT query is executed like any other statement. To read the returned data, call sqlite3_step() in a loop. It returns: SQLITE_ROW: if the data for the next row is available, or SQLITE_DONE: if there are no more rows, or any error code. If a query does not return any rows, the very first...
PHP has built in function pcntl_fork for creating child process. pcntl_fork is same as fork in unix. It does not take in any parameters and returns integer which can be used to differentiate between parent and child process. Consider the following code for explanation <?php // $pid is the P...
HTML Form Use a file type input and the browser will provide a field that lets the user select a file to upload. Only forms with the post method can send file data. Make sure to set the form's enctype=multipart/form-data attribute. Otherwise the file's name will be sent but not the file's data...
WTForms provides a FileField to render a file type input. It doesn't do anything special with the uploaded data. However, since Flask splits the form data (request.form) and the file data (request.files), you need to make sure to pass the correct data when creating the form. You can use a Combine...
We can create it by two way. First from database properties designer mode: And by sql scripts: USE master; GO -- Create the database with the default data -- filegroup and a log file. Specify the -- growth increment and the max size for the -- primary data file. CREATE DATABASE TestDB ON...
CROSS APPLY enables you to "join" rows from a table with dynamically generated rows returned by some table-value function. Imagine that you have a Company table with a column that contains an array of products (ProductList column), and a function that parse these values and returns a set ...
If you store a list of tags in a row as coma separated values, STRING_SPLIT function enables you to transform list of tags into a table of values. CROSS APPLY enables you to "join" values parsed by STRING_SPLIT function with a parent row. Imagine that you have a Product table with a colu...
The -path parameter allows to specify a pattern to match the path of the result. The pattern can match also the name itself. To find only files containing log anywhere in their path (folder or name): find . -type f -path '*log*' To find only files within a folder called log (on any level): fin...
It is well known that you cannot use the same file for input and ouput in the same command. For instance, $ cat header.txt body.txt >body.txt doesn’t do what you want. By the time cat reads body.txt, it has already been truncated by the redirection and it is empty. The final result will be th...
You can list all files ignored by git in current directory with command: git status --ignored So if we have repository structure like this: .git .gitignore ./example_1 ./dir/example_2 ./example_2 ...and .gitignore file containing: example_2 ...than result of the command will be: $ g...
See what, when and why if you don't know about the affiliation of IFS to word splitting let's set the IFS to space character only: set -x var='I am a multiline string' IFS=' ' fun() { echo "-$1-" echo "*$2*" echo ".$3." } fun $var This time wo...
$ a='I am a string with spaces' $ [ $a = $a ] || echo "didn't match" bash: [: too many arguments didn't match [ $a = $a ] was interpreted as [ I am a string with spaces = I am a string with spaces ]. [ is the test command for which I am a string with spaces is not a single argument...
There are some cases where word splitting can be useful: Filling up array: arr=($(grep -o '[0-9]\+' file)) This will fill up arr with all numeric values found in file Looping through space separated words: words='foo bar baz' for w in $words;do echo "W: $w" done Output...

Page 254 of 457