Tutorial by Examples: c

A patch is a file that show the differences between two revisions or between your local repository and the last revision your repository is pointing. To share or save a patch of your local uncommitted changes either for peer review or to apply later, do: svn diff > new-feature.patch To get a...
C99 These functions returns the floating-point remainder of the division of x/y. The returned value has the same sign as x. Single Precision: #include <math.h> /* for fmodf() */ #include <stdio.h> /* for printf() */ int main(void) { float x = 10.0; float y = 5.1; ...
function transform(fn, arr) { let result = []; for (let el of arr) { result.push(fn(el)); // We push the result of the transformed item to result } return result; } console.log(transform(x => x * 2, [1,2,3,4])); // [2, 4, 6, 8] As you can see, our transform fun...
Creating a managed table with partition and stored as a sequence file. The data format in the files is assumed to be field-delimited by Ctrl-A (^A) and row-delimited by newline. The below table is created in hive warehouse directory specified in value for the key hive.metastore.warehouse.dir in the ...
Creating a database in a particular location. If we dont specify any location for database its created in warehouse directory. CREATE DATABASE IF NOT EXISTS db_name COMMENT 'TEST DATABASE' LOCATION /PATH/HDFS/DATABASE/;
1. Passing integer data: SenderActivity Intent myIntent = new Intent(SenderActivity.this, ReceiverActivity.class); myIntent.putExtra("intVariableName", intValue); startActivity(myIntent); ReceiverActivity Intent mIntent = getIntent(); int intValue = mIntent.getIntExtra("intVa...
// Add active class to active navigation link $(document).ready(function () { $('ul.nav.navbar-nav').find('a[href="' + location.pathname + '"]') .closest('li').addClass('active'); });
If you're doing multiple long calculations, you can run them at the same time on different threads on your computer. To do this, we make a new Thread and have it point to a different method. using System.Threading; class MainClass { static void Main() { var thread = new Thread(Seco...
Environment.ProcessorCount Gets the number of logical processors on the current machine. The CLR will then schedule each thread to a logical processor, this theoretically could mean each thread on a different logical processor, all threads on a single logical processor or some other combination...
If you have a foreach loop that you want to speed up and you don't mind what order the output is in, you can convert it to a parallel foreach loop by doing the following: using System; using System.Threading; using System.Threading.Tasks; public class MainClass { public static void Main...
Everything between /* and */ is commented. void main() { for (int i = 0; i < 5; i++) { /* This is commented, and will not affect code */ print('hello ${i + 1}'); } }
Using a doc comment instead of a regular comment enables dartdoc to find it and generate documentation for it. /// The number of characters in this chunk when unsplit. int get length => ... You are allowed to use most markdown formatting in your doc comments and dartdoc will process it accor...
Processing tabular data with awk is very easy, provided that the input is correctly formatted. Most software producing tabular data use specific features of this family of formats, and awk programs processing tabular data are often specific to a data produced by a specific software. If a more gener...
Given a file using ; as a column delimiter. Permuting the first and the second column is accomplished by awk -F';' -v 'OFS=;' '{ swap = $2; $2 = $1; $1 = swap; print }'
Given a file using ; as a column delimiter. We compute the mean of the values in the second column with the following program, the provided input is the list of grades of a student group: awk -F';' '{ sum += $2 } END { print(sum / NR) }' <<EOF Alice;2 Victor;1 Barbara;1 Casper;4 Deborah;...
We assume a file using ; as a column delimiter. Selecting a specific set of columns only requires a print statement. For instance, the following program selects the columns 3, 4 and 7 from its input: awk -F';' -v 'OFS=;' '{ print $3, $4, $7 }' It is as usual possible to more carefully choose lin...
Given a file using ; as a column delimiter. We compute the median of the values in the second column with the following program, written for GNU awk. The provided input is the list of grades of a student group: gawk -F';' '{ sample[NR] = $2 } END { asort(sample); if(NR % 2 == 1) { p...
There are two main ways to create an axes in matplotlib: using pyplot, or using the object-oriented API. Using pyplot: import matplotlib.pyplot as plt ax = plt.subplot(3, 2, 1) # 3 rows, 2 columns, the first subplot Using the object-oriented API: import matplotlib.pyplot as plt fig = ...
If you import two libraries that have conflicting identifiers, then you can specify a prefix for one or both libraries. For example, if library1 and library2 both have an Element class, then you might have code like this: import 'package:lib1/lib1.dart'; import 'package:lib2/lib2.dart' as lib2; /...
For example we have WordCountService with countWords method: class WordCountService { def countWords(url: String): Map[String, Int] = { val sparkConf = new SparkConf().setMaster("spark://somehost:7077").setAppName("WordCount")) val sc = new SparkContext(sp...

Page 271 of 826