Tutorial by Examples: c

This creates a simple archive of a folder : tar -cf ./my-archive.tar ./my-folder/ Verbose output shows which files and directories are added to the archive, use the -v option: tar -cvf ./my-archive.tar ./my-folder/ For archiving a folder compressed 'gzip', you have to use the -z option : ta...
There is an example for extract a folder from an archive in the current location : tar -xf archive-name.tar If you want to extract a folder from an archive to a specfic destination : tar -xf archive-name.tar -C ./directory/destination
There is an example of listing content : tar -tvf archive.tar The option -t is used for the listing. For listing the content of a tar.gz archive, you have to use the -z option anymore : tar -tzvf archive.tar.gz
This example shows how to get every year from this year to 2011 (2012 - 1). WITH yearsAgo ( myYear ) AS ( -- Base Case: This is where the recursion starts SELECT DATEPART(year, GETDATE()) AS myYear UNION ALL -- This MUST be UNION ALL (cannot be UNION) -- Recurs...
Orders a collection by a specified value. When the value is an integer, double or float it starts with the maximal value, which means that you get first the positive values, than zero and afterwords the negative values (see Example 1). When you order by a char the method compares the ascii val...
Description: Evaluate expression after user's confirmation. Arguments: ng-confirm-click:(expression) Expression to evaluate when confirmed. ng-confirm-message:(template) Message to be shown in confirm dialog. Code: Directives.directive("ngConfirmClick", ["$parse","...
Polymorphism is the ability to perform an action on an object regardless of its type. This is generally implemented by creating a base class and having two or more subclasses that all implement methods with the same signature. Any other function or method that manipulates these objects can call the ...
YAML provides a way to store structured data. The data can be a simple set of name-value pairs or a complex hierarchical data with values even being arrays. Consider the following YAML file: database: driver: mysql host: database.mydomain.com port: 3306 db_name: sample_db ...
How to use conditional execution of command lists Any builtin command, expression, or function, as well as any external command or script can be executed conditionally using the &&(and) and ||(or) operators. For example, this will only print the current directory if the cd command was succ...
Lists def lst = ['foo', 'bar', 'baz'] // using implicit argument lst.each { println it } // using explicit argument lst.each { val -> println val } // both print: // foo // bar // baz Iterate with index def lst = ['foo', 'bar', 'baz'] // explicit arguments are required lst.each...
def lst = ['foo', 'bar', 'baz'] lst.collect { it } // ['foo', 'bar', 'baz'] lst.collect { it.toUpperCase() } // ['FOO', 'BAR', 'BAZ'] To collect keys or values from a maps def map = [foo: 'FOO', bar: 'BAR', baz: 'BAZ'] def keys = map.collect { it.key } // ['foo', 'bar', 'baz'] def vals = m...
def lst = [10, 20, 30, 40] lst.find { it > 25 } // 30. Note: it returns a single value
From lists def lst = ['foo', 'bar', 'baz'] // for each entry return a list containing [key, value] lst.collectEntries { [it, it.toUpperCase()] } // [foo: FOO, bar: BAR, baz: BAZ] // another option, return a map containing the single entry lst.collectEntries { [(it): it.toUpperCase()] } // [...
Apply the transformation to non-collection entries, delving into nested collections too and preserving the whole structure. def lst = ['foo', 'bar', ['inner_foo', 'inner_bar']] lst.collectNested { it.toUpperCase() } // [FOO, BAR, [INNER_FOO, INNER_BAR]]
def lst = ['foo', 'foo', 'bar', 'baz'] // *modifies* the list removing duplicate items lst.unique() // [foo, bar, baz] // setting to false the "mutate" argument returns a new list, leaving the original intact lst.unique(false) // [foo, bar, baz] // convert the list to a Set, thu...
WebRTC is an open framework for the web that enables Real Time Communications in the browser. It includes the fundamental building blocks for high-quality communications on the web, such as network, audio and video components used in voice and video chat applications. These components, when impleme...
# operator or stringizing operator is used to convert a Macro parameter to a string literal. It can only be used with the Macros having arguments. // preprocessor will convert the parameter x to the string literal x #define PRINT(x) printf(#x "\n") PRINT(This line will be converted to...
This is an example on how to use React Native's BackAndroid along with the Navigator. componentWillMount registers an event listener to handle the taps on the back button. It checks if there is another view in the history stack, and if there is one, it goes back -otherwise it keeps the default beha...
Polymorphism without inheritance in the form of duck typing as available in Python due to its dynamic typing system. This means that as long as the classes contain the same methods the Python interpreter does not distinguish between them, as the only checking of the calls occurs at run-time. class ...
While catching the Throwable, Exception, Error and RuntimeException exceptions is bad, throwing them is even worse. The basic problem is that when your application needs to handle exceptions, the presence of the top level exceptions make it hard to discriminate between different error conditions. ...

Page 434 of 826