Tutorial by Examples: v

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;...
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...
Unlike Java, Dart doesn’t have the keywords public, protected, and private. If an identifier starts with an underscore _, it’s private to its library. If you for example have class A in a separate library file (eg, other.dart), such as: library other; class A { int _private = 0; testA()...
This command starts up a development server, or dev server, for your Dart web app. The dev server is an HTTP server on localhost that serves up your web app’s assets. Start the dev server from the directory that contains your web app’s pubspec.yaml file: $ cd ~/dart/helloworld $ pub serve Servin...
When the view controller is presented within a tab bar controller, you can access the tab bar controller like this: Swift let tabBarController = viewController.tabBarController Objective-C UITabBarController *tabBarController = self.tabBarController; When the view controller is part on an n...
The var_dump function allows you to dump the contents of a variable (type and value) for debugging. Example: $array = [3.7, "string", 10, ["hello" => "world"], false, new DateTime()]; var_dump($array); Output: array(6) { [0]=> float(3.7) [1]=> ...
You can use gradle to have BuildConfig constants and res values on a per flavor basis. Just add the value to the flavor you want to support. android { defaultConfig { resValue "string", "app_name", "Full App" buildConfigField "boolean",...
You can convert a numeric string to various Java numeric types as follows: String to int: String number = "12"; int num = Integer.parseInt(number); String to float: String number = "12.0"; float num = Float.parseFloat(number); String to double: String double = "1...
Pass each variable to view at a time $this->set('color', 'pink'); $this->set('color', $color); Pass multiple variables to view together via compact() function $color1 = 'pink'; $color2 = 'red'; $this->set(compact('color1', 'color2'));
You can retrieve post data as Array. $post_data= $this->request->data; You can retrieve post data for particular key. $this->request->data['field']; Retrieve specific key value $this->request->data('key_name'); Retrieve specific key value of nested array $this->requ...
Dim fso As New Scripting.FileSystemObject Debug.Print fso.GetExtensionName("MyFile.something.txt") Prints txt Note that the GetExtensionName() method already handles multiple periods in a file name.
In Ansible, a playbook is is a YAML file containing the definition of how a server should look. In a playbook you define what actions Ansible should take to get the server in the state you want. Only what you define gets done. This is a basic Ansible playbook that installs git on every host belongi...
Retrieving sensor information from the onboard sensors: public class MainActivity extends Activity implements SensorEventListener { private SensorManager mSensorManager; private Sensor accelerometer; private Sensor gyroscope; float[] accelerometerData = new float[3]; f...
One of the most used attribute for LinearLayout is the weight of its child views. Weight defines how much space a view will consume compared to other views within a LinearLayout. Weight is used when you want to give specific screen space to one component compared to other. Key Properties: wei...
Hex Opacity Values ------------------------------ | Alpha(%) | Hex Value | ------------------------------ | 100% | FF | | 95% | F2 | | 90% | E6 | | 85% | D9 | | 80% | ...
The Firebase Realtime Database is schemaless. This makes it easy to change things as you develop, but once your app is ready to distribute, it's important for data to stay consistent. The rules language includes a .validate rule which allows you to apply validation logic using the same expressions u...
With more and more battery optimizations being put into the Android system over time, the methods of the AlarmManager have also significantly changed (to allow for more lenient timing). However, for some applications it is still required to be as exact as possible on all Android versions. The follow...
First, create a key file, e.g., vault_pass_file, which ideally contains a long sequence of random characters. In linux systems you could use pwgen to create a random password file: pwgen 256 1 > vault_pass_file Then, use this file to encrypt sensitive data, e.g., groups_vars/group.yml: ANSI...
With Vault you can also encrypt non-structured data, such as private key files and still be able to decrypt them in your play with the lookup module. --- - name: Copy private key to destination copy: dest=/home/user/.ssh/id_rsa mode=0600 content=lookup('pipe', 'ANSIBLE_VAULT_PA...
You can run a play which relies on vault-encrypted templates by using the local_action module. --- - name: Decrypt template local_action: "shell {{ view_encrypted_file_cmd }} {{ role_path }}/templates/template.enc > {{ role_path }}/templates/template" changed_when: False - ...

Page 92 of 296